1 /****************************************************************
2 * This macro converts AliITSRecPoint(s) to AliITSclusterV2(s) *
3 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
4 *****************************************************************/
10 #include "AliRunLoader.h"
11 #include "AliLoader.h"
13 #include "AliITSgeom.h"
14 #include "AliITSclustererV2.h"
16 #include "TStopwatch.h"
19 Int_t AliITSFindClustersV2(Char_t SlowOrFast='f')
22 cerr<<"AliITSRecPoint(s) -> AliITSclusterV2(s)...\n";
26 delete gAlice->GetRunLoader();
31 AliRunLoader* rl = AliRunLoader::Open("galice.root");
34 cerr<<"AliITSHits2DigitsDefault.C : Can not open session RL=NULL"
39 Int_t retval = rl->LoadgAlice();
42 cerr<<"AliITSHits2DigitsDefault.C : LoadgAlice returned error"
47 gAlice=rl->GetAliRun();
49 retval = rl->LoadKinematics();
52 cerr<<"AliITSHits2DigitsDefault.C : LoadKinematics returned error"
58 AliITSLoader* gime = (AliITSLoader*)rl->GetLoader("ITSLoader");
61 cerr<<"AliITSHits2DigitsDefault.C : can not get ITS loader"
67 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
68 if (!ITS) { cerr<<"Can't find the ITS !\n"; delete rl; return 3; }
69 AliITSgeom *geom=ITS->GetITSgeom();
71 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
73 gime->LoadRawClusters("recreate");
77 gime->SetRecPointsFileName("ITS.FastRecPoints.root");
79 if (gime->LoadRecPoints())
81 cerr<<"Load Rec Pints returned error !\n";
86 TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
92 for (iEvent = 0; iEvent< rl->GetNumberOfEvents() ; iEvent++)
97 TTree *cTree = gime->TreeC();
101 cTree = gime->TreeC();
104 cTree->Branch("Clusters",&clusters);
106 TTree *pTree=gime->TreeR();
109 cerr<<"Can not get TreeR !\n"; delete rl;return 5;
112 if (SlowOrFast=='f') {
113 branch = pTree->GetBranch("ITSRecPointsF");
116 branch = pTree->GetBranch("ITSRecPoints");
120 cerr<<"Can't get ITSRecPoints branch !\n";
125 branch->SetAddress(&points);
127 AliStack* stack = rl->Stack();
130 cerr<<"AliITSFindClustersV2.C : Can not get stack"
136 TClonesArray &cl=*clusters;
138 Int_t nentr=(Int_t)branch->GetEntries();
140 cerr<<"Number of entries: "<<nentr<<endl;
142 for (Int_t i=0; i<nentr; i++)
147 Int_t ncl=points->GetEntriesFast(); if (ncl==0){cTree->Fill();continue;}
148 Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det);
149 if ( (lay<0) || (lad<0) || (det<0))
151 ::Error("AliITSFindClustersV2.C","No such a module %d",i);
154 Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift);
155 Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot);
156 Double_t yshift = x*rot[0] + y*rot[1];
157 Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1);
160 Float_t kmip=1; // ADC->mip normalization factor for the SDD and SSD
161 if(lay==4 || lay==3){kmip=280.;};
162 if(lay==6 || lay==5){kmip=38.;};
164 for (Int_t j=0; j<ncl; j++)
166 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j);
168 lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0];
169 lp[1]=p->GetZ()+zshift;
170 lp[2]=p->GetSigmaX2();
171 lp[3]=p->GetSigmaZ2();
172 lp[4]=p->GetQ(); lp[4]/=kmip;
174 lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2);
179 TParticle *part=(TParticle*)stack->Particle(label);
181 cerr<<"Can not get particle with label "<<label<<endl;
183 while (part->P() < 0.005) {
184 Int_t m=part->GetFirstMother();
185 if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;}
187 part=(TParticle*)gAlice->Particle(label);
189 if (lab[1]<0) lab[1]=label;
190 else if (lab[2]<0) lab[2]=label;
191 else cerr<<"No empty labels !\n";
194 new(cl[j]) AliITSclusterV2(lab,lp);
197 // clusters->Delete(); points->Delete();
199 gime->WriteRawClusters("OVERWRITE");
200 cerr<<"Number of clusters: "<<nclusters<<endl;