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"); ITS->MakeBranch("R",0);
43 //////////////// Taken from ITSHitsToFastPoints.C ///////////////////////
44 AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
45 for (Int_t i=0;i<3;i++) { ITS->SetSimulationModel(i,sim); }
49 Int_t bgr_ev=Int_t(ev/nsignal);
50 ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
51 //////////////////////////////////////////////////////////////////////////
52 delete gAlice; gAlice=0;
55 ///////////////// Conversion AliITSRecPoint -> AliITSclusterV2 //////////////
56 /*TFile */in=TFile::Open("galice.root");
58 if (gAlice) {delete gAlice; gAlice=0;}
60 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
61 cerr<<"Can't find gAlice !\n";
67 /*AliITS */ITS = (AliITS*)gAlice->GetModule("ITS");
69 cerr<<"Can't find the ITS !\n";
72 AliITSgeom *geom=ITS->GetITSgeom();
74 TFile *out=TFile::Open("AliITSclustersV2.root","new");
76 cerr<<"Delete old AliITSclustersV2.root !\n";
81 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
82 TTree *cTree=new TTree("cTree","ITS clusters");
83 cTree->Branch("Clusters",&clusters);
85 TTree *pTree=gAlice->TreeR();
87 cerr<<"Can't get TreeR !\n";
90 TBranch *branch=pTree->GetBranch("ITSRecPoints");
92 cerr<<"Can't get ITSRecPoints branch !\n";
95 TClonesArray *points=new TClonesArray("AliITSRecPoint",10000);
96 branch->SetAddress(&points);
98 TClonesArray &cl=*clusters;
100 Int_t nentr=(Int_t)pTree->GetEntries();
102 cerr<<"Number of entries: "<<nentr<<endl;
104 for (Int_t i=0; i<nentr; i++) {
105 if (!pTree->GetEvent(i)) {cTree->Fill(); continue;}
106 Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det);
107 Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift);
108 Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot);
109 Double_t yshift = x*rot[0] + y*rot[1];
110 Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1);
111 Int_t ncl=points->GetEntriesFast();
113 for (Int_t j=0; j<ncl; j++) {
114 AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j);
116 lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0];
117 lp[1]=p->GetZ()+zshift;
118 lp[2]=p->GetSigmaX2();
119 lp[3]=p->GetSigmaZ2();
122 lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2);
126 TParticle *part=(TParticle*)gAlice->Particle(label);
128 while (part->P() < 0.005) {
129 Int_t m=part->GetFirstMother();
130 if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;}
132 part=(TParticle*)gAlice->Particle(label);
134 if (lab[1]<0) lab[1]=label;
135 else if (lab[2]<0) lab[2]=label;
136 else cerr<<"No empty labels !\n";
138 new(cl[j]) AliITSclusterV2(lab,lp);
140 cTree->Fill(); clusters->Delete();
145 cerr<<"Number of clusters: "<<nclusters<<endl;
147 delete cTree; delete clusters; delete points;
149 delete gAlice; gAlice=0;