4 #include "AliITSgeom.h"
5 #include "AliITSRecPoint.h"
6 #include "AliITSclusterV2.h"
7 #include "AliITSsimulationFastPoints.h"
11 #include "TParticle.h"
14 Int_t AliITSFindClustersV2() {
15 /****************************************************************
16 * Just something to start with *
17 ****************************************************************/
18 cerr<<"Looking for clusters...\n";
20 if (gAlice) {delete gAlice; gAlice=0;}
22 TFile *in=TFile::Open("galice.root","update");
24 cerr<<"Can't open galice.root !\n";
28 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
29 cerr<<"Can't find gAlice !\n";
36 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
38 cerr<<"Can't find the ITS !\n";
42 gAlice->MakeTree("R");
43 ITS->MakeBranch("R",0);
44 gAlice->TreeR()->Fill();
46 //////////////// Taken from ITSHitsToFastPoints.C ///////////////////////
47 AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
48 for (Int_t i=0;i<3;i++) { ITS->SetSimulationModel(i,sim); }
52 Int_t bgr_ev=Int_t(ev/nsignal);
53 ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
54 //////////////////////////////////////////////////////////////////////////
56 delete gAlice; gAlice=0;
59 ///////////////// Conversion AliITSRecPoint -> AliITSclusterV2 //////////////
60 /*TFile */in=TFile::Open("galice.root");
62 if (gAlice) {delete gAlice; gAlice=0;}
64 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
65 cerr<<"Can't find gAlice !\n";
71 /*AliITS */ITS = (AliITS*)gAlice->GetModule("ITS");
73 cerr<<"Can't find the ITS !\n";
76 AliITSgeom *geom=ITS->GetITSgeom();
78 TFile *out=TFile::Open("AliITSclustersV2.root","new");
80 cerr<<"Delete old AliITSclustersV2.root !\n";
85 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
86 TTree *cTree=new TTree("cTree","ITS clusters");
87 cTree->Branch("Clusters",&clusters);
89 TTree *pTree=gAlice->TreeR();
91 cerr<<"Can't get TreeR !\n";
94 TBranch *branch=pTree->GetBranch("ITSRecPoints");
96 cerr<<"Can't get ITSRecPoints branch !\n";
99 TClonesArray *points=new TClonesArray("AliITSRecPoint",10000);
100 branch->SetAddress(&points);
102 TClonesArray &cl=*clusters;
104 Int_t nentr=(Int_t)pTree->GetEntries();
106 cerr<<"Number of entries: "<<nentr<<endl;
108 for (Int_t i=0; i<nentr; i++) {
109 if (!pTree->GetEvent(i)) {cTree->Fill(); continue;}
110 Int_t lay,lad,det; geom->GetModuleId(i-1,lay,lad,det);
111 Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift);
112 Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot);
113 Double_t yshift = x*rot[0] + y*rot[1];
114 Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1);
115 Int_t ncl=points->GetEntriesFast();
117 for (Int_t j=0; j<ncl; j++) {
118 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j);
120 lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0];
121 lp[1]=p->GetZ()+zshift;
122 lp[2]=p->GetSigmaX2();
123 lp[3]=p->GetSigmaZ2();
126 lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2);
130 TParticle *part=(TParticle*)gAlice->Particle(label);
132 while (part->P() < 0.005) {
133 Int_t m=part->GetFirstMother();
134 if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;}
136 part=(TParticle*)gAlice->Particle(label);
138 if (lab[1]<0) lab[1]=label;
139 else if (lab[2]<0) lab[2]=label;
140 else cerr<<"No empty labels !\n";
142 new(cl[j]) AliITSclusterV2(lab,lp);
144 cTree->Fill(); clusters->Delete();
149 cerr<<"Number of clusters: "<<nclusters<<endl;
151 delete cTree; delete clusters; delete points;
153 delete gAlice; gAlice=0;