]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/FindKrClusters.C
Corrected overlaps
[u/mrichter/AliRoot.git] / TPC / FindKrClusters.C
1 /****************************************************************************
2  *           Origin: A.Matyja amatyja@cern.ch                               *
3  ****************************************************************************/
4
5 /*
6
7   macro to create array of clusters from TPC digits
8   input files - galice.root 
9                 digits.root - file with digits - usualy use link to galice.root
10                             - in splitted mode - neccesary to create link to proper file
11                             
12    output file - TPC.RecPoints.root
13
14
15 //  Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
16                
17  
18 */
19
20
21 #ifndef __CINT__
22 #include <iostream.h>
23 #include "AliRun.h"
24 #include "AliTPCv4.h"
25 #include "AliTPCParam.h"
26 #include "AliTPCclusterKr.h"
27 #include "AliTPCclustererKr.h"
28 #include "TFile.h"
29 #include "TStopwatch.h"
30 #include "TTree.h"
31 #endif
32
33 Int_t FindKrClusters(){
34
35   //
36   //Load DataBase
37   //
38   char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";
39   //char *ocdbpath ="local:///home/matyja/baza/OCDB";
40   if (ocdbpath==0){
41     ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";
42   }
43   printf("OCDB PATH = %s\n",ocdbpath); 
44   AliCDBManager * man = AliCDBManager::Instance();
45   man->SetDefaultStorage(ocdbpath);
46   man->SetRun(0);
47
48   AliRunLoader* rl = AliRunLoader::Open("galice.root");
49   if (rl == 0x0) {
50     cerr<<"Can not open session"<<endl;
51     return 1;
52   }
53   
54   AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
55   if (tpcl == 0x0) {
56     cerr<<"Can not get TPC Loader"<<endl;
57     return 1;
58   }
59
60   if (tpcl->LoadDigits()) {
61     cerr<<"Error occured while loading digits"<<endl;
62     return 1;
63   }
64
65   if (rl->LoadgAlice()) {
66     cerr<<"Error occured while LoadgAlice"<<endl;
67     return 1;
68   }
69   
70   gAlice=rl->GetAliRun();
71   if (!gAlice) {
72     cerr<<"Can't get gAlice !\n";
73     return 1;
74   }
75
76   TDirectory *cwd = gDirectory;
77
78   AliTPCv4 *tpc = (AliTPCv4*)gAlice->GetDetector("TPC");
79   Int_t ver = tpc->IsVersion(); 
80   cerr<<"TPC version "<<ver<<" has been found !\n";
81
82   rl->CdGAFile();
83   
84   AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
85   if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}
86   
87   AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
88   digarr->Setup(param);
89
90   cerr<<"It has begun"<<endl;  
91   TStopwatch timer;
92   timer.Start();
93   cwd->cd();
94   
95   Int_t nevmax=rl->GetNumberOfEvents();//number of events in run
96   for(Int_t nev=0;nev<nevmax /*&& nev<1*/ ;nev++){
97     rl->GetEvent(nev);
98     
99     TTree* input_tree= tpcl->TreeD();//tree with digits
100     if (input_tree == 0x0){
101       cerr << "Can not get TreeD for event " <<nev<<endl;
102       continue;
103     }
104     
105     digarr->ConnectTree(input_tree);
106     
107     TTree *output_tree =tpcl->TreeR();
108     if(output_tree==0x0){
109       tpcl->MakeTree("R");
110       output_tree = tpcl->TreeR();
111       if (output_tree == 0x0){
112         cerr << "Problems with output tree (TreeR) for event "<<nev<<endl;
113         continue;
114       }
115     }
116     
117     cout<<"Processing event "<<nev<<endl;
118
119     //test
120     //cout<<"nentries"<<input_tree->GetEntries();
121
122     AliTPCclustererKr *clusters = new AliTPCclustererKr();
123     clusters->SetParam(param);
124     clusters->SetInput(input_tree);
125     clusters->SetOutput(output_tree);
126     clusters->SetDigArr(digarr);
127     clusters->FinderIO();
128
129     tpcl->WriteRecPoints("OVERWRITE");
130   }
131   
132
133   timer.Stop(); timer.Print();
134   
135   delete rl;//cleans everything
136   
137   return 0;
138 }