6 #include "AliITSgeom.h"
7 #include "AliITSRecPoint.h"
8 #include "AliITSclusterV2.h"
9 #include "AliITSsimulationFastPoints.h"
13 #include "TParticle.h"
16 Int_t AliITSFindClustersV2() {
17 /****************************************************************
18 * Just something to start with *
19 ****************************************************************/
20 cerr<<"Looking for clusters...\n";
22 if (gAlice) {delete gAlice; gAlice=0;}
24 TFile *in=TFile::Open("galice.root","update");
26 cerr<<"Can't open galice.root !\n";
30 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
31 cerr<<"Can't find gAlice !\n";
38 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
40 cerr<<"Can't find the ITS !\n";
44 gAlice->MakeTree("R"); ITS->MakeBranch("R",0);
45 //////////////// Taken from ITSHitsToFastPoints.C ///////////////////////
46 ITS->SetSimulationModel(0,new AliITSsimulationFastPoints());
47 ITS->SetSimulationModel(1,new AliITSsimulationFastPoints());
48 ITS->SetSimulationModel(2,new AliITSsimulationFastPoints());
51 Int_t bgr_ev=Int_t(ev/nsignal);
52 ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
53 //////////////////////////////////////////////////////////////////////////
55 delete gAlice; gAlice=0;
58 ///////////////// Conversion AliITSRecPoint -> AliITSclusterV2 //////////////
59 /*TFile */in=TFile::Open("galice.root");
61 if (gAlice) {delete gAlice; gAlice=0;}
63 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
64 cerr<<"Can't find gAlice !\n";
70 /*AliITS */ITS = (AliITS*)gAlice->GetModule("ITS");
72 cerr<<"Can't find the ITS !\n";
75 AliITSgeom *geom=ITS->GetITSgeom();
77 TFile *out=TFile::Open("AliITSclustersV2.root","new");
79 cerr<<"Delete old AliITSclustersV2.root !\n";
84 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
85 TTree *cTree=new TTree("TreeC_ITS_0","ITS clusters");
86 cTree->Branch("Clusters",&clusters);
88 TTree *pTree=gAlice->TreeR();
90 cerr<<"Can't get TreeR !\n";
93 TBranch *branch=pTree->GetBranch("ITSRecPoints");
95 cerr<<"Can't get ITSRecPoints branch !\n";
98 TClonesArray *points=new TClonesArray("AliITSRecPoint",10000);
99 branch->SetAddress(&points);
101 TClonesArray &cl=*clusters;
103 Int_t nentr=(Int_t)pTree->GetEntries();
105 cerr<<"Number of entries: "<<nentr<<endl;
107 Float_t lp[5]; Int_t lab[6]; //Why can't it be inside a loop ?
109 for (Int_t i=0; i<nentr; i++) {
112 Int_t ncl=points->GetEntriesFast(); if (ncl==0){cTree->Fill();continue;}
113 Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det);
114 Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift);
115 Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot);
116 Double_t yshift = x*rot[0] + y*rot[1];
117 Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1);
119 for (Int_t j=0; j<ncl; j++) {
120 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j);
122 lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0];
123 lp[1]=p->GetZ()+zshift;
124 lp[2]=p->GetSigmaX2();
125 lp[3]=p->GetSigmaZ2();
128 lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2);
132 TParticle *part=(TParticle*)gAlice->Particle(label);
134 while (part->P() < 0.005) {
135 Int_t m=part->GetFirstMother();
136 if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;}
138 part=(TParticle*)gAlice->Particle(label);
140 if (lab[1]<0) lab[1]=label;
141 else if (lab[2]<0) lab[2]=label;
142 else cerr<<"No empty labels !\n";
144 new(cl[j]) AliITSclusterV2(lab,lp);
146 cTree->Fill(); clusters->Delete();
150 cerr<<"Number of clusters: "<<nclusters<<endl;
152 delete cTree; delete clusters; delete points;
154 delete gAlice; gAlice=0;