ROOT logo

/****************************************************************************
 *           Origin: A.Matyja amatyja@cern.ch                               *
 ****************************************************************************/

/*

  macro to create array of clusters from TPC digits
  input files - galice.root 
                digits.root - file with digits - usualy use link to galice.root
		            - in splitted mode - neccesary to create link to proper file
			    
   output file - TPC.RecPoints.root


//  Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
	       
 
*/


#ifndef __CINT__
#include <iostream.h>
#include "AliRun.h"
#include "AliTPCv4.h"
#include "AliTPCParam.h"
#include "AliTPCclusterKr.h"
#include "AliTPCclustererKr.h"
#include "TFile.h"
#include "TStopwatch.h"
#include "TTree.h"
#endif

Int_t FindKrClusters(){

  //
  //Load DataBase
  //
  //char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";
  //char *ocdbpath ="local:///home/matyja/baza/OCDB";
  char *ocdbpath ="local:///data/baza/OCDB";
  if (ocdbpath==0){
    ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";
  }
  printf("OCDB PATH = %s\n",ocdbpath); 
  AliCDBManager * man = AliCDBManager::Instance();
  man->SetDefaultStorage(ocdbpath);
  man->SetRun(0);

  AliRunLoader* rl = AliRunLoader::Open("galice.root");
  if (rl == 0x0) {
    cerr<<"Can not open session"<<endl;
    return 1;
  }
  
  AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
  if (tpcl == 0x0) {
    cerr<<"Can not get TPC Loader"<<endl;
    return 1;
  }

  if (tpcl->LoadDigits()) {
    cerr<<"Error occured while loading digits"<<endl;
    return 1;
  }

  if (rl->LoadgAlice()) {
    cerr<<"Error occured while LoadgAlice"<<endl;
    return 1;
  }
  
  gAlice=rl->GetAliRun();
  if (!gAlice) {
    cerr<<"Can't get gAlice !\n";
    return 1;
  }

  TDirectory *cwd = gDirectory;

  AliTPCv4 *tpc = (AliTPCv4*)gAlice->GetDetector("TPC");
  Int_t ver = tpc->IsVersion(); 
  cerr<<"TPC version "<<ver<<" has been found !\n";

  rl->CdGAFile();
  
  AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
  if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}
  
  AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
  digarr->Setup(param);

  cerr<<"It has begun"<<endl;  
  TStopwatch timer;
  timer.Start();
  cwd->cd();

  TTree *output_tree;
  
  AliTPCclustererKr *clusters = new AliTPCclustererKr();
  clusters->SetParam(param);
  clusters->SetOutput(output_tree);

  clusters->SetMinAdc(3);//signal threshold (everything below is treated as 0)
  clusters->SetMinTimeBins(2);//number of neighbouring timebins
  clusters->SetMaxPadRangeCm(5.);//distance of the cluster center to the center of a pad (in cm)
  clusters->SetMaxRowRangeCm(5.);//distance of the cluster center to the center of a padrow (in cm)
  clusters->SetMaxTimeRange(7.);//distance of the cluster center to the max time bin on a pad (in tackts)
  //ie. fabs(centerT - time)<7

  clusters->SetIsolCut(3);//set isolation cut threshold
  clusters->SetValueToSize(3.1);//cut reduce peak at 0

  Int_t nevmax=rl->GetNumberOfEvents();//number of events in run
  for(Int_t nev=0;nev<nevmax /*&& nev<1*/ ;nev++){
    rl->GetEvent(nev);
    
    TTree* input_tree= tpcl->TreeD();//tree with digits
    if (input_tree == 0x0){
      cerr << "Can not get TreeD for event " <<nev<<endl;
      continue;
    }
    digarr->ConnectTree(input_tree);
    clusters->SetInput(input_tree);
    clusters->SetDigArr(digarr);
    cout<<"Processing event "<<nev<<endl;
    clusters->FinderIO();

  }
  delete clusters;
  timer.Stop(); timer.Print();
  
  delete rl;//cleans everything
  
  return 0;
}
 FindKrClusters.C:1
 FindKrClusters.C:2
 FindKrClusters.C:3
 FindKrClusters.C:4
 FindKrClusters.C:5
 FindKrClusters.C:6
 FindKrClusters.C:7
 FindKrClusters.C:8
 FindKrClusters.C:9
 FindKrClusters.C:10
 FindKrClusters.C:11
 FindKrClusters.C:12
 FindKrClusters.C:13
 FindKrClusters.C:14
 FindKrClusters.C:15
 FindKrClusters.C:16
 FindKrClusters.C:17
 FindKrClusters.C:18
 FindKrClusters.C:19
 FindKrClusters.C:20
 FindKrClusters.C:21
 FindKrClusters.C:22
 FindKrClusters.C:23
 FindKrClusters.C:24
 FindKrClusters.C:25
 FindKrClusters.C:26
 FindKrClusters.C:27
 FindKrClusters.C:28
 FindKrClusters.C:29
 FindKrClusters.C:30
 FindKrClusters.C:31
 FindKrClusters.C:32
 FindKrClusters.C:33
 FindKrClusters.C:34
 FindKrClusters.C:35
 FindKrClusters.C:36
 FindKrClusters.C:37
 FindKrClusters.C:38
 FindKrClusters.C:39
 FindKrClusters.C:40
 FindKrClusters.C:41
 FindKrClusters.C:42
 FindKrClusters.C:43
 FindKrClusters.C:44
 FindKrClusters.C:45
 FindKrClusters.C:46
 FindKrClusters.C:47
 FindKrClusters.C:48
 FindKrClusters.C:49
 FindKrClusters.C:50
 FindKrClusters.C:51
 FindKrClusters.C:52
 FindKrClusters.C:53
 FindKrClusters.C:54
 FindKrClusters.C:55
 FindKrClusters.C:56
 FindKrClusters.C:57
 FindKrClusters.C:58
 FindKrClusters.C:59
 FindKrClusters.C:60
 FindKrClusters.C:61
 FindKrClusters.C:62
 FindKrClusters.C:63
 FindKrClusters.C:64
 FindKrClusters.C:65
 FindKrClusters.C:66
 FindKrClusters.C:67
 FindKrClusters.C:68
 FindKrClusters.C:69
 FindKrClusters.C:70
 FindKrClusters.C:71
 FindKrClusters.C:72
 FindKrClusters.C:73
 FindKrClusters.C:74
 FindKrClusters.C:75
 FindKrClusters.C:76
 FindKrClusters.C:77
 FindKrClusters.C:78
 FindKrClusters.C:79
 FindKrClusters.C:80
 FindKrClusters.C:81
 FindKrClusters.C:82
 FindKrClusters.C:83
 FindKrClusters.C:84
 FindKrClusters.C:85
 FindKrClusters.C:86
 FindKrClusters.C:87
 FindKrClusters.C:88
 FindKrClusters.C:89
 FindKrClusters.C:90
 FindKrClusters.C:91
 FindKrClusters.C:92
 FindKrClusters.C:93
 FindKrClusters.C:94
 FindKrClusters.C:95
 FindKrClusters.C:96
 FindKrClusters.C:97
 FindKrClusters.C:98
 FindKrClusters.C:99
 FindKrClusters.C:100
 FindKrClusters.C:101
 FindKrClusters.C:102
 FindKrClusters.C:103
 FindKrClusters.C:104
 FindKrClusters.C:105
 FindKrClusters.C:106
 FindKrClusters.C:107
 FindKrClusters.C:108
 FindKrClusters.C:109
 FindKrClusters.C:110
 FindKrClusters.C:111
 FindKrClusters.C:112
 FindKrClusters.C:113
 FindKrClusters.C:114
 FindKrClusters.C:115
 FindKrClusters.C:116
 FindKrClusters.C:117
 FindKrClusters.C:118
 FindKrClusters.C:119
 FindKrClusters.C:120
 FindKrClusters.C:121
 FindKrClusters.C:122
 FindKrClusters.C:123
 FindKrClusters.C:124
 FindKrClusters.C:125
 FindKrClusters.C:126
 FindKrClusters.C:127
 FindKrClusters.C:128
 FindKrClusters.C:129
 FindKrClusters.C:130
 FindKrClusters.C:131
 FindKrClusters.C:132
 FindKrClusters.C:133
 FindKrClusters.C:134
 FindKrClusters.C:135
 FindKrClusters.C:136