]>
Commit | Line | Data |
---|---|---|
006b5f7f | 1 | #ifndef __CINT__ |
c7ee21ca | 2 | #include <iostream.h> |
3 | ||
006b5f7f | 4 | #include "AliRun.h" |
5 | #include "AliITS.h" | |
6 | #include "AliITSgeom.h" | |
7 | #include "AliITSRecPoint.h" | |
8 | #include "AliITSclusterV2.h" | |
9 | #include "AliITSsimulationFastPoints.h" | |
10 | ||
11 | #include "TFile.h" | |
12 | #include "TTree.h" | |
13 | #include "TParticle.h" | |
14 | #endif | |
15 | ||
16 | Int_t AliITSFindClustersV2() { | |
17 | /**************************************************************** | |
18 | * Just something to start with * | |
19 | ****************************************************************/ | |
20 | cerr<<"Looking for clusters...\n"; | |
21 | ||
22 | if (gAlice) {delete gAlice; gAlice=0;} | |
23 | ||
24 | TFile *in=TFile::Open("galice.root","update"); | |
25 | if (!in->IsOpen()) { | |
26 | cerr<<"Can't open galice.root !\n"; | |
27 | return 1; | |
28 | } | |
29 | ||
30 | if (!(gAlice=(AliRun*)in->Get("gAlice"))) { | |
31 | cerr<<"Can't find gAlice !\n"; | |
32 | return 2; | |
33 | } | |
34 | ||
35 | Int_t ev=0; | |
36 | gAlice->GetEvent(ev); | |
37 | ||
38 | AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); | |
39 | if (!ITS) { | |
40 | cerr<<"Can't find the ITS !\n"; | |
41 | return 3; | |
42 | } | |
43 | ||
14825d5a | 44 | gAlice->MakeTree("R"); ITS->MakeBranch("R",0); |
45 | //////////////// Taken from ITSHitsToFastPoints.C /////////////////////// | |
c7ee21ca | 46 | ITS->SetSimulationModel(0,new AliITSsimulationFastPoints()); |
47 | ITS->SetSimulationModel(1,new AliITSsimulationFastPoints()); | |
48 | ITS->SetSimulationModel(2,new AliITSsimulationFastPoints()); | |
006b5f7f | 49 | Int_t nsignal=25; |
50 | Int_t size=-1; | |
51 | Int_t bgr_ev=Int_t(ev/nsignal); | |
52 | ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," "); | |
14825d5a | 53 | ////////////////////////////////////////////////////////////////////////// |
c7ee21ca | 54 | |
006b5f7f | 55 | delete gAlice; gAlice=0; |
56 | in->Close(); | |
57 | ||
58 | ///////////////// Conversion AliITSRecPoint -> AliITSclusterV2 ////////////// | |
59 | /*TFile */in=TFile::Open("galice.root"); | |
60 | ||
61 | if (gAlice) {delete gAlice; gAlice=0;} | |
62 | ||
63 | if (!(gAlice=(AliRun*)in->Get("gAlice"))) { | |
64 | cerr<<"Can't find gAlice !\n"; | |
65 | return 4; | |
66 | } | |
67 | ||
68 | gAlice->GetEvent(0); | |
69 | ||
70 | /*AliITS */ITS = (AliITS*)gAlice->GetModule("ITS"); | |
71 | if (!ITS) { | |
72 | cerr<<"Can't find the ITS !\n"; | |
73 | return 5; | |
74 | } | |
75 | AliITSgeom *geom=ITS->GetITSgeom(); | |
76 | ||
77 | TFile *out=TFile::Open("AliITSclustersV2.root","new"); | |
78 | if (!out->IsOpen()) { | |
79 | cerr<<"Delete old AliITSclustersV2.root !\n"; | |
80 | return 6; | |
81 | } | |
82 | geom->Write(); | |
83 | ||
84 | TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000); | |
c7ee21ca | 85 | //TTree *cTree=new TTree("cTree","ITS clusters"); |
86 | TTree *cTree=new TTree("TreeC_ITS_0","ITS clusters"); | |
006b5f7f | 87 | cTree->Branch("Clusters",&clusters); |
88 | ||
89 | TTree *pTree=gAlice->TreeR(); | |
c7ee21ca | 90 | if (!pTree) { |
006b5f7f | 91 | cerr<<"Can't get TreeR !\n"; |
92 | return 7; | |
93 | } | |
94 | TBranch *branch=pTree->GetBranch("ITSRecPoints"); | |
95 | if (!branch) { | |
96 | cerr<<"Can't get ITSRecPoints branch !\n"; | |
97 | return 8; | |
98 | } | |
99 | TClonesArray *points=new TClonesArray("AliITSRecPoint",10000); | |
100 | branch->SetAddress(&points); | |
101 | ||
102 | TClonesArray &cl=*clusters; | |
103 | Int_t nclusters=0; | |
104 | Int_t nentr=(Int_t)pTree->GetEntries(); | |
105 | ||
106 | cerr<<"Number of entries: "<<nentr<<endl; | |
107 | ||
108 | for (Int_t i=0; i<nentr; i++) { | |
c7ee21ca | 109 | points->Clear(); |
110 | pTree->GetEvent(i); | |
111 | Int_t ncl=points->GetEntriesFast(); if (ncl==0){cTree->Fill();continue;} | |
14825d5a | 112 | Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det); |
006b5f7f | 113 | Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift); |
114 | Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot); | |
115 | Double_t yshift = x*rot[0] + y*rot[1]; | |
116 | Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1); | |
006b5f7f | 117 | nclusters+=ncl; |
118 | for (Int_t j=0; j<ncl; j++) { | |
119 | AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j); | |
120 | Float_t lp[5]; | |
121 | lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0]; | |
122 | lp[1]=p->GetZ()+zshift; | |
123 | lp[2]=p->GetSigmaX2(); | |
124 | lp[3]=p->GetSigmaZ2(); | |
125 | lp[4]=p->GetQ(); | |
126 | Int_t lab[6]; | |
127 | lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2); | |
128 | lab[3]=ndet; | |
129 | ||
130 | Int_t label=lab[0]; | |
131 | TParticle *part=(TParticle*)gAlice->Particle(label); | |
132 | label=-3; | |
133 | while (part->P() < 0.005) { | |
134 | Int_t m=part->GetFirstMother(); | |
135 | if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;} | |
136 | label=m; | |
137 | part=(TParticle*)gAlice->Particle(label); | |
138 | } | |
139 | if (lab[1]<0) lab[1]=label; | |
140 | else if (lab[2]<0) lab[2]=label; | |
141 | else cerr<<"No empty labels !\n"; | |
142 | ||
143 | new(cl[j]) AliITSclusterV2(lab,lp); | |
144 | } | |
145 | cTree->Fill(); clusters->Delete(); | |
146 | points->Delete(); | |
147 | } | |
148 | cTree->Write(); | |
149 | ||
150 | cerr<<"Number of clusters: "<<nclusters<<endl; | |
151 | ||
152 | delete cTree; delete clusters; delete points; | |
153 | ||
154 | delete gAlice; gAlice=0; | |
c7ee21ca | 155 | |
006b5f7f | 156 | in->Close(); |
157 | out->Close(); | |
158 | ||
159 | return 0; | |
c7ee21ca | 160 | |
006b5f7f | 161 | } |
162 | ||
163 | ||
164 | ||
165 | ||
166 | ||
167 | ||
168 | ||
169 | ||
170 | ||
171 | ||
172 | ||
173 | ||
174 | ||
175 |