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