]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSGeoPlot.C
Example macro for the creation of tags (P.Christakoglou)
[u/mrichter/AliRoot.git] / ITS / AliITSGeoPlot.C
CommitLineData
813e97e8 1#if !defined(__CINT__) || defined(__MAKECINT__)
88cb7938 2#include<Riostream.h>
af8e1c2d 3#include<TROOT.h>
4#include<TArrayI.h>
813e97e8 5#include<TBranch.h>
af8e1c2d 6#include<TCanvas.h>
7#include<TClassTable.h>
8#include<TClonesArray.h>
9#include<TFile.h>
10#include<TH1.h>
11#include<TH2.h>
a6c9fb45 12#include <TInterpreter.h>
af8e1c2d 13#include<TObject.h>
14#include<TObjArray.h>
15#include<TTree.h>
979e3647 16#include "AliGenEventHeader.h"
af8e1c2d 17#include <AliRun.h>
18#include <AliITS.h>
19#include <AliITSgeom.h>
7d62fb64 20#include <AliITSDetTypeRec.h>
af8e1c2d 21#include <AliITSRecPoint.h>
a6c9fb45 22#include <AliITSclusterV2.h>
af8e1c2d 23#include <AliITSdigit.h>
a6c9fb45 24#include <AliITSdigitSSD.h>
af8e1c2d 25#include <AliITShit.h>
26#include <AliITSmodule.h>
27#include <AliITSsegmentation.h>
28#include <AliITSsegmentationSPD.h>
29#include <AliITSsegmentationSDD.h>
30#include <AliITSsegmentationSSD.h>
88cb7938 31#include <AliRunLoader.h>
32#include <AliITSLoader.h>
33#include <AliHeader.h>
af8e1c2d 34#endif
813e97e8 35void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb);
36Int_t GetRecCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb);
a6c9fb45 37Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb);
813e97e8 38void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, Int_t mod, Bool_t verbose, TObjArray & histos);
39
7d62fb64 40Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+ClustersV2", char *filename="galice.root", Int_t isfastpoints = 0) {
af8e1c2d 41 /*******************************************************************
42 * This macro displays geometrical information related to the
a6c9fb45 43 * hits, digits and rec points (or V2 clusters) in ITS.
af8e1c2d 44 * There are histograms that are not displayed (i.e. energy
45 * deposition) but that are saved onto a file (see below)
46 *
813e97e8 47 * INPUT arguments:
48 *
49 * Int_t evesel: the selected event number. It's =0 by default
50 *
af8e1c2d 51 * Options: Any combination of:
52 * 1) subdetector name: "SPD", "SDD", "SSD", "All" (default)
53 * 2) Printouts: "Verbose" Almost everything is printed out:
54 * it is wise to redirect the output onto a file
813e97e8 55 * e.g.: .x AliITSGeoPlot.C("All+Verbose") > out.log
af8e1c2d 56 * 3) Rec Points option: "Rec" ---> Uses Rec. Points (default)
a6c9fb45 57 *
58 * 4) ClustersV2 option: "ClustersV2" ---->Uses ClustersV2
59 * otherwise ---->uses hits and digits only
af8e1c2d 60 * Examples:
813e97e8 61 * .x AliITSGeoPlot(); (All subdetectors; no-verbose; no-recpoints)
62 * .x AliITSGeoPlot("SPD+SSD+Verbose+Rec");
63 *
88cb7938 64 * filename: It's "galice.root" by default.
813e97e8 65 * isfastpoints: integer. It is set to 0 by defaults. This means that
66 * slow reconstruction is assumed. If fast recpoint are in
67 * in use, isfastpoints must be set =1.
af8e1c2d 68 *
69 * OUTPUT: It produces a root file with a list of histograms
813e97e8 70 *
af8e1c2d 71 * WARNING: spatial information for SSD/DIGITS is obtained by pairing
72 * digits on p and n side originating from the same track, when
73 * possible. This (mis)use of DIGITS is tolerated for debugging
74 * purposes only !!!! The pairing in real life should be done
75 * starting from info really available...
76 *
77 * COMPILATION: this macro can be compiled.
813e97e8 78 * 1) You need to set your include path with
af8e1c2d 79 * gSystem->SetIncludePath("-I- -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -g");
80 * 3) If you are using root instead of aliroot you need to
81 * execute the macro loadlibs.C in advance
82 * 4) To compile this macro from root (or aliroot):
813e97e8 83 * --- .L AliITSGeoPlot.C++
84 * --- AliITSGeoPlot();
af8e1c2d 85 *
86 * M.Masera 14/05/2001 18:30
a6c9fb45 87 * Last rev. 31/05/2004 14:00 (Clusters V2 added) E.C.
af8e1c2d 88 ********************************************************************/
89
af8e1c2d 90 //Options
91 TString choice(opt);
92 Bool_t All = choice.Contains("All");
93 Bool_t verbose=choice.Contains("Verbose");
94 Bool_t userec=choice.Contains("Rec");
a6c9fb45 95 Bool_t useclustersv2=choice.Contains("ClustersV2");
af8e1c2d 96 Int_t retcode=1; //return code
a6c9fb45 97
af8e1c2d 98 if (gClassTable->GetID("AliRun") < 0) {
a6c9fb45 99 gInterpreter->ExecuteMacro("loadlibs.C");
af8e1c2d 100 }
a6c9fb45 101 else {
af8e1c2d 102 if(gAlice){
88cb7938 103 delete gAlice->GetRunLoader();
af8e1c2d 104 delete gAlice;
105 gAlice=0;
106 }
af8e1c2d 107 }
a6c9fb45 108
109 AliRunLoader* rl = AliRunLoader::Open(filename);
110 if (rl == 0x0){
111 cerr<<"AliITSGeoPlot.C : Can not open session RL=NULL"<< endl;
112 return -1;
113 }
114 Int_t retval = rl->LoadgAlice();
115 if (retval){
116 cerr<<"AliITSGeoPlot.C : LoadgAlice returned error"<<endl;
117 return -1;
118 }
119 gAlice=rl->GetAliRun();
88cb7938 120
a6c9fb45 121 retval = rl->LoadHeader();
122 if (retval){
123 cerr<<"AliITSGeoPlot.C : LoadHeader returned error"<<endl;
124 return -1;
125 }
88cb7938 126
a6c9fb45 127 AliITSLoader* ITSloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
88cb7938 128
a6c9fb45 129 if(!ITSloader){
130 cerr<<"AliITSGeoPlot.C : ITS loader not found"<<endl;
131 return -1;
132 }
88cb7938 133
a6c9fb45 134 ITSloader->LoadHits("read");
135 ITSloader->LoadDigits("read");
136 if(isfastpoints==1)ITSloader->SetRecPointsFileName("ITS.FastRecPoints.root");
137 ITSloader->LoadRecPoints("read");
138 rl->GetEvent(evesel);
139 Int_t nparticles = rl->GetHeader()->GetNtrack();
140 AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
141 ITS->SetTreeAddress();
af8e1c2d 142 if(verbose) {
143 cout<<" "<<endl<<" "<<endl;
144 cout<<"******* Event processing started *******"<<endl;
145 cout<<"In the following, hits with 'StatusEntering' flag active"<<endl;
146 cout<<"will not be processed"<<endl;
147 cout << "Number of particles= " << nparticles <<endl;
148 }
149
150 // HITS
88cb7938 151 TTree *TH = ITSloader->TreeH();
af8e1c2d 152 Stat_t ntracks = TH->GetEntries();
153 if(verbose)cout<<"Number of primary tracks= "<<ntracks<<endl;
154
155 // ITS
af8e1c2d 156 Int_t nmodules;
157 ITS->InitModules(-1,nmodules);
158 cout<<"Number of ITS modules= "<<nmodules<<endl;
159 cout<<"Filling modules... It takes a while, now. Please be patient"<<endl;
160 ITS->FillModules(0,0,nmodules," "," ");
161 cout<<"ITS modules .... DONE!"<<endl;
7d62fb64 162
163 AliITSDetTypeRec* detTypeRec = new AliITSDetTypeRec();
164 detTypeRec->SetLoader(ITSloader);
165 detTypeRec->SetITSgeom(ITS->GetITSgeom());
166 detTypeRec->SetDefaults();
af8e1c2d 167 // DIGITS
88cb7938 168 TTree *TD = ITSloader->TreeD();
af8e1c2d 169
a6c9fb45 170 //RECPOINTS (V2 clusters)
88cb7938 171 TTree *TR = ITSloader->TreeR();
7d62fb64 172 TClonesArray *ITSrec = detTypeRec->RecPoints();
173 TClonesArray *ITScl = detTypeRec->ClustersV2();
813e97e8 174 TBranch *branch = 0;
175 if(userec && TR && ITSrec){
176 if(isfastpoints==1){
88cb7938 177 branch = ITSloader->TreeR()->GetBranch("ITSRecPointsF");
813e97e8 178 cout<<"using fast points\n";
179 }
180 else {
88cb7938 181 branch = ITSloader->TreeR()->GetBranch("ITSRecPoints");
813e97e8 182 }
183 if(branch)branch->SetAddress(&ITSrec);
184 }
185
186 if(userec && (!TR || !ITSrec || !branch)){
af8e1c2d 187 userec = kFALSE;
813e97e8 188 cout<<"\n ======================================================= \n";
189 cout<<"WARNING: there are no RECPOINTS on this file ! \n";
190 cout<<"======================================================= \n \n";
af8e1c2d 191 }
7d62fb64 192 if(useclustersv2 && TR && ITScl){
a6c9fb45 193 branch = ITSloader->TreeR()->GetBranch("Clusters");
7d62fb64 194 if(branch)branch->SetAddress(&ITScl);
a6c9fb45 195 }
196
197 if(useclustersv2 && (!TR || !ITSrec || !branch)){
198 useclustersv2 = kFALSE;
199 cout<<"\n ======================================================= \n";
200 cout<<"WARNING: there are no CLUSTERSV2 on this file ! \n";
201 cout<<"======================================================= \n \n";
202 }
203
813e97e8 204
af8e1c2d 205 //local variables
206 Int_t mod; //module number
207 Int_t nbytes = 0;
208 Double_t pos[3]; // Global position of the current module
209 Float_t ragdet; // Radius of detector (x y plane)
210 Int_t first; // first module
211 Int_t last; // last module
212 Int_t nrecp; //number of RecPoints for a given module
213
214 //List of histograms
215 TObjArray histos(26,0); // contains the pointers to the histograms
216 // Book histograms SPD
217 TH2F *rspd = new TH2F("rspd","Radii of digits - SPD",50,-10.,10.,50,-10.,10.);
218 TH2F *rhspd = new TH2F("rhspd","Radii of hits - SPD",50,-10.,10.,50,-10.,10.);
219 TH2F *rmspd = new TH2F("rmspd","Radii of SPD modules",50,-10.,10.,50,-10.,10.);
220 TH1F *zspd = new TH1F("zspd","Z of digits - SPD",100,-30.,30.);
221 TH1F *zhspd = new TH1F("zhspd","Z of hits - SPD",100,-30.,30.);
222 TH1F *zmspd = new TH1F("zmspd","Z of SPD modules",100,-30,30.);
a6c9fb45 223
224 Char_t title1[50]="";
225 Char_t title2[50]="";
226 if(userec){
227 sprintf(title1,"Radii of recpoints - %s","SPD");
228 sprintf(title2,"Z of recpoints - %s","SPD");
229 }
230 if(useclustersv2){
231 sprintf(title1,"Radii of clustersV2 - %s","SPD");
232 sprintf(title2,"Z of clustersV2 - %s","SPD");
233 }
234 TH2F *rrspd = new TH2F("rrspd",title1,50,-10.,10.,50,-10.,10.);
235 TH1F *zrspd = new TH1F("zrspd",title2,100,-30.,30.);
af8e1c2d 236 TH1F *enespd = new TH1F("enespd","Energy deposition SPD (KeV)",100,0.,1000.);
237 histos.AddLast(rspd); // 0
238 histos.AddLast(rhspd); // 1
239 histos.AddLast(rmspd); // 2
240 histos.AddLast(zspd); // 3
241 histos.AddLast(zhspd); // 4
242 histos.AddLast(zmspd); // 5
243 histos.AddLast(rrspd); // 6
244 histos.AddLast(zrspd); // 7
245 histos.AddLast(enespd); // 8
246 // Book histograms SDD
247 TH2F *rsdd = new TH2F("rsdd","Radii of digits - SDD",50,-40.,40.,50,-40.,40.);
248 TH2F *rhsdd = new TH2F("rhsdd","Radii of hits - SDD",50,-40.,40.,50,-40.,40.);
249 TH2F *rmsdd = new TH2F("rmsdd","Radii of SDD modules",50,-40.,40.,50,-40.,40.);
250 TH1F *zsdd = new TH1F("zsdd","Z of digits - SDD",100,-40.,40.);
251 TH1F *zhsdd = new TH1F("zhsdd","Z of hits - SDD",100,-40.,40.);
252 TH1F *zmsdd = new TH1F("zmsdd","Z of SDD modules",100,-40,40.);
a6c9fb45 253 Char_t title3[50];
254 Char_t title4[50];
255 if(userec){
256 sprintf(title3,"Radii of recpoints - %s","SDD");
257 sprintf(title4,"Z of recpoints - %s","SDD");
258 }
259 if(useclustersv2){
260 sprintf(title3,"Radii of clustersV2 - %s","SDD");
261 sprintf(title4,"Z of clustersV2 - %s","SDD");
262 }
263 TH2F *rrsdd = new TH2F("rrsdd",title3,50,-40.,40.,50,-40.,40.);
264 TH1F *zrsdd = new TH1F("zrsdd",title4,100,-40.,40.);
af8e1c2d 265 TH1F *enesdd = new TH1F("enesdd","Energy deposition SDD (KeV)",100,0.,1000.);
266 histos.AddLast(rsdd); // 9
267 histos.AddLast(rhsdd); // 10
268 histos.AddLast(rmsdd); // 11
269 histos.AddLast(zsdd); // 12
270 histos.AddLast(zhsdd); // 13
271 histos.AddLast(zmsdd); // 14
272 histos.AddLast(rrsdd); // 15
273 histos.AddLast(zrsdd); // 16
274 histos.AddLast(enesdd); // 17
275 // Book histogram SSD
276 TH2F *rssd = new TH2F("rssd","Radii of digits - SSD",50,-50.,50.,50,-50.,50.);
277 TH2F *rhssd = new TH2F("rhssd","Radii of hits - SSD",50,-50.,50.,50,-50.,50.);
278 TH2F *rmssd = new TH2F("rmssd","Radii of SSD modules",50,-50.,50.,50,-50.,50.);
279 TH1F *zssd = new TH1F("zssd","Z of digits - SSD",100,-70.,70.);
280 TH1F *zhssd = new TH1F("zhssd","Z of hits - SSD",100,-70.,70.);
281 TH1F *zmssd = new TH1F("zmssd","Z of SSD modules",100,-70,70.);
a6c9fb45 282 Char_t title5[50];
283 Char_t title6[50];
284 if(userec){
285 sprintf(title5,"Radii of recpoints - %s","SSD");
286 sprintf(title6,"Z of recpoints - %s","SSD");
287 }
288 if(useclustersv2){
289 sprintf(title5,"Radii of clustersV2 - %s","SSD");
290 sprintf(title6,"Z of clustersV2 - %s","SSD");
291 }
292
293 TH2F *rrssd = new TH2F("rrssd",title5,50,-50.,50.,50,-50.,50.);
294 TH1F *zrssd = new TH1F("zrssd",title6,100,-70.,70.);
af8e1c2d 295 TH1F *enessd = new TH1F("enessd","Energy deposition SSD (KeV)",100,0.,1000.);
296 histos.AddLast(rssd); // 18
297 histos.AddLast(rhssd); // 19
298 histos.AddLast(rmssd); // 20
299 histos.AddLast(zssd); // 21
300 histos.AddLast(zhssd); // 22
301 histos.AddLast(zmssd); // 23
302 histos.AddLast(rrssd); // 24
303 histos.AddLast(zrssd); // 25
304 histos.AddLast(enessd); // 26
305 //
306 // Loop on subdetectors
307 //
308 AliITSgeom *geom = ITS->GetITSgeom();
309 TString detna; // subdetector name
310 for(Int_t subd=0;subd<3;subd++){
311 if(All || (choice.Contains("SPD") && subd==0) || (choice.Contains("SDD") && subd==1) || (choice.Contains("SSD") && subd==2)){
312 // Prepare array for the digits
313 TClonesArray *ITSdigits = ITS->DigitsAddress(subd);
314 Bool_t usedigits = kTRUE;
315 if(!ITSdigits){
316 usedigits = kFALSE;
813e97e8 317 cout<<"\n ======================================================= \n";
318 cout<<"WARNING: there are no DIGITS on this file ! \n";
319 cout<<"======================================================= \n \n";
af8e1c2d 320 }
321 // Get segmentation model
af8e1c2d 322 if(subd==0)detna="SPD";
323 if(subd==1)detna="SDD";
324 if(subd==2)detna="SSD";
7d62fb64 325 AliITSsegmentation *seg=(AliITSsegmentation*)detTypeRec->GetSegmentationModel(subd);
af8e1c2d 326 // Loop on modules
327 first = geom->GetStartDet(subd);
328 last = geom->GetLastDet(subd);
329 if(verbose){
330 cout<<" "<<endl<<"-------------------------------------"<<endl;
331 cout<<"Start processing subdetector "<<detna<<endl;
332 cout<<detna<<" first module "<<first<<endl;
333 cout<<detna<<" last module "<<last<<endl;
334 cout<<" "<<endl<<" "<<endl;
335 }
336 for (mod=first; mod<=last; mod++){
337 geom->GetTrans(mod,pos); // position of the module in the MRS
338 ragdet=sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
339 // The following 2 histos are a check of the geometry
340 TH2F *bidi = (TH2F*)histos.At(2+subd*9);
341 TH1F *uni = (TH1F*)histos.At(5+subd*9);
342 bidi->Fill(pos[0],pos[1]);
343 uni->Fill(pos[2]);
344 if(verbose){
813e97e8 345 cout<<"=========================================================\n";
af8e1c2d 346 cout<<detna<<" module="<<mod<<endl;
813e97e8 347 cout<<"Mod. coordinates: "<<pos[0]<<", "<<pos[1]<<", ";
348 cout<<pos[2]<<" Radius "<<ragdet<<endl;
af8e1c2d 349 }
350
351 // Hits
352 GetHitsCoor(ITS,mod,histos,subd,verbose);
353
354 //RecPoints
355 if(userec){
7d62fb64 356 detTypeRec->ResetRecPoints();
813e97e8 357 branch->GetEvent(mod);
af8e1c2d 358 TH2F *bidi=(TH2F*)histos.At(6+subd*9);
359 TH1F *uni=(TH1F*)histos.At(7+subd*9);
360 nrecp=GetRecCoor(geom,ITSrec,mod,bidi,uni,verbose);
361 }
a6c9fb45 362 if(useclustersv2){
7d62fb64 363 detTypeRec->ResetClustersV2();
a6c9fb45 364 branch->GetEvent(mod);
365 TH2F *bidi=(TH2F*)histos.At(6+subd*9);
366 TH1F *uni=(TH1F*)histos.At(7+subd*9);
7d62fb64 367 nrecp=GetClusCoor(geom,ITScl,mod,bidi,uni,verbose);
368
a6c9fb45 369 }
af8e1c2d 370
371 // Digits
372 if(usedigits){
7d62fb64 373 detTypeRec->ResetDigits();
af8e1c2d 374 nbytes += TD->GetEvent(mod);
375 GetDigits(seg,geom,ITSdigits,subd,mod,verbose,histos);
376 }
377
378 } // End of loop on the modules
379 TH1F *h1tmp;
380 TH2F *h2tmp;
381 // Plot the histograms
382 TCanvas *current=0; // current Canvas (1--> SPD, 2---> SDD, 3---> SSD)
383 if(subd==0){
384 // Prepare canvas 1
385 TCanvas *c1 = new TCanvas("c1","SPD",10,10,600,900);
386 c1->Divide(2,3);
387 current=c1;
388 }
389 if(subd==1){
390 // Prepare canvas 2
391 TCanvas *c2 = new TCanvas("c2","SDD",40,40,600,900);
392 c2->Divide(2,3);
393 current=c2;
394 }
395 if(subd==2){
396 // Prepare canvas 3
397 TCanvas *c3 = new TCanvas("c3","SSD",70,70,600,900);
398 c3->Divide(2,3);
399 current=c3;
400 }
401 current->cd(1);
402 h2tmp = (TH2F*)histos.At(9*subd);
403 h2tmp->Draw();
404 current->cd(2);
405 h1tmp=(TH1F*)histos.At(3+subd*9);
406 h1tmp->Draw();
407 current->cd(3);
408 h2tmp=(TH2F*)histos.At(1+9*subd);
409 h2tmp->Draw();
410 current->cd(4);
411 h1tmp=(TH1F*)histos.At(4+subd*9);
412 h1tmp->Draw();
413
a6c9fb45 414 if(userec || useclustersv2){
af8e1c2d 415 current->cd(5);
416 h2tmp=(TH2F*)histos.At(6+9*subd);
417 h2tmp->Draw();
418 current->cd(6);
419 h1tmp=(TH1F*)histos.At(7+subd*9);
420 h1tmp->Draw();
421 }
422
423 else {
424 current->cd(5);
425 h2tmp=(TH2F*)histos.At(2+9*subd);
426 h2tmp->Draw();
427 current->cd(6);
428 h2tmp=(TH2F*)histos.At(5+9*subd);
429 h2tmp->Draw();
430 }
431 } // if(All.....
432 } // end of loop on subdetectors
433 // Save the histograms
813e97e8 434 TFile *fh = new TFile("AliITSGeoPlot.root","recreate");
af8e1c2d 435 // The list is written to file as a single entry
436 TList *lihi = new TList();
437 // copy the pointers to the histograms to a TList object.
438 // The histograms concerning recpoints are not copied if
439 // 'userec' is false.
440 for(Int_t i=0;i<histos.GetEntriesFast();i++){
441 if(choice.Contains("All") || (choice.Contains("SPD") && i<8) || (choice.Contains("SDD") && i>7 && i<16) || (choice.Contains("SSD") && i>15)){
442 if(!(!userec && ((i+2)%9==0 || (i+1)%9==0)))lihi->Add(histos.At(i));
443 }
444 }
445 lihi->Write("Histograms ITS hits+digits+recpoints",TObject::kSingleKey);
446 fh->Close();
447
448 return retcode;
449}
450
451
452void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb){
453 TH2F *h2=(TH2F*)histos.At(1+subd*9);
454 TH1F *h1=(TH1F*)histos.At(4+subd*9);
455 TH1F *ener=(TH1F*)histos.At(8+subd*9);
456 AliITS *ITS= (AliITS*)its;
457 AliITSmodule *modu = ITS->GetModule(mod);
458 TObjArray *fHits = modu->GetHits();
459 Int_t nhits = fHits->GetEntriesFast();
460 if(nhits>0){
461 if(verb){
462 cout<<"-------------------------------------------------------"<<endl;
463 cout<<"Number of HITS for module "<<mod<<": "<<nhits<<endl;
464 }
465 for (Int_t hit=0;hit<nhits;hit++) {
466 AliITShit *iHit = (AliITShit*) fHits->At(hit);
467 if(!iHit->StatusEntering()){
468 Float_t x=iHit->GetXG();
469 Float_t y=iHit->GetYG();
470 Float_t z=iHit->GetZG();
471 Float_t edep=iHit->GetIonization()*1000000;
472 h2->Fill(x,y);
473 h1->Fill(z);
474 ener->Fill(edep);
475 if(verb){
476 cout<<"hit # "<<hit<<" Global coordinates "<<x<<" "<<y<<" "<<z<<endl;
813e97e8 477 cout<<"track # "<<iHit->GetTrack()<<" energy deposition (KeV)= ";
478 cout<<edep<<endl;
af8e1c2d 479 }
480 }
481 }
482 }
483}
484
485
a6c9fb45 486Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb){
7d62fb64 487
a6c9fb45 488 AliITSgeom *geom = (AliITSgeom*)ge;
489 Int_t nrecp = ITSrec->GetEntries();
490 if(nrecp>0){
491 Float_t lc[3]; for(Int_t i=0; i<3; i++) lc[i]=0.;
492 Float_t gc[3]; for(Int_t i=0; i<3; i++) gc[i]=0.;
493 if(verb){
494 cout<<"-------------------------------------------------------"<<endl;
495 cout<<"Number of CLUSTERS for module "<<mod<<": "<<nrecp<<endl;
496 }
497 for(Int_t irec=0;irec<nrecp;irec++) {
498 AliITSclusterV2 *recp = (AliITSclusterV2*)ITSrec->At(irec);
499 Double_t rot[9];
500 geom->GetRotMatrix(mod,rot);
501 Int_t lay,lad,det;
502 geom->GetModuleId(mod,lay,lad,det);
503 Float_t tx,ty,tz;
504 geom->GetTrans(lay,lad,det,tx,ty,tz);
505
506 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
507 Double_t phi1=TMath::Pi()/2+alpha;
508 if(lay==1) phi1+=TMath::Pi();
509
510 Float_t cp=TMath::Cos(phi1), sp=TMath::Sin(phi1);
511 Float_t r=tx*cp+ty*sp;
512 gc[0]= r*cp - recp->GetY()*sp;
513 gc[1]= r*sp + recp->GetY()*cp;
514 gc[2]=recp->GetZ();
515
516 if(verb){
517 Float_t r=sqrt(gc[0]*gc[0]+gc[1]*gc[1]);
518 cout<<"Global coor. + radius "<<gc[0]<<" "<<gc[1]<<" "<<gc[2]<<" ";
519 cout<<r<<endl;
520 cout<<"Associated track "<<recp->GetLabel(0)<<endl;
521 }
522 h2->Fill(gc[0],gc[1]);
523 h1->Fill(gc[2]);
7d62fb64 524
a6c9fb45 525 }
526 }
527 return nrecp;
528}
af8e1c2d 529Int_t GetRecCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb){
530 AliITSgeom *geom = (AliITSgeom*)ge;
531 Int_t nrecp = ITSrec->GetEntries();
532 if(nrecp>0){
533 Float_t lc[3]; for(Int_t i=0; i<3; i++) lc[i]=0.;
534 Float_t gc[3]; for(Int_t i=0; i<3; i++) gc[i]=0.;
535 if(verb){
536 cout<<"-------------------------------------------------------"<<endl;
537 cout<<"Number of REC POINTS for module "<<mod<<": "<<nrecp<<endl;
538 }
539 for(Int_t irec=0;irec<nrecp;irec++) {
540 AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(irec);
541 lc[0]=recp->GetX();
542 lc[2]=recp->GetZ();
543 geom->LtoG(mod,lc,gc);
544 if(verb){
813e97e8 545 cout<<"recp # "<<irec<<" local coordinates. lx= "<<lc[0]<<" lz= ";
546 cout<<lc[2]<<endl;
af8e1c2d 547 Float_t r=sqrt(gc[0]*gc[0]+gc[1]*gc[1]);
813e97e8 548 cout<<"Global coor. + radius "<<gc[0]<<" "<<gc[1]<<" "<<gc[2]<<" ";
549 cout<<r<<endl;
550 cout<<"Associated track "<<recp->GetLabel(0)<<endl;
af8e1c2d 551 }
552 h2->Fill(gc[0],gc[1]);
553 h1->Fill(gc[2]);
554 }
555 }
556 return nrecp;
557}
558
559void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, Int_t mod, Bool_t verbose, TObjArray & histos){
560 AliITSsegmentation *seg = (AliITSsegmentation*)tmps;
561 AliITSgeom *geom = (AliITSgeom*)ge;
562 Int_t layer;
563 Int_t ladder;
564 Int_t detec;
565 if(subd==2){
566 geom->GetModuleId(mod,layer,ladder,detec);
567 seg->SetLayer(layer);
568 }
569 Float_t lcoor[3]; for(Int_t j=0; j<3; j++) lcoor[j]=0.; //local coord dig.
570 Float_t gcoor[3]; for(Int_t j=0; j<3; j++) gcoor[j]=0.; // global coo. dig.
571 Float_t ragdig; // Radius digit
572 TArrayI ssdone(5000); // used to match p and n side digits of strips
573 TArrayI pair(5000); // as above
574 Int_t ndigits = ITSdigits->GetEntries();
575 AliITSdigit *digs;
576 if(ndigits){
577 if(verbose){
578 cout<<"-------------------------------------------------------"<<endl;
579 cout<<"Number of DIGITS for module "<<mod<<": "<<ndigits<<endl;
580 }
581 // Get the coordinates of the module
582 if(subd==2){
583 for (Int_t digit=0;digit<ndigits;digit++){
584 ssdone[digit]=0;
585 pair[digit]=0;
586 }
587 }
588 for (Int_t digit=0;digit<ndigits;digit++) {
589 digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit);
0be9848a 590 Int_t iz=digs->GetCoord1(); // cell number z
591 Int_t ix=digs->GetCoord2(); // cell number x
af8e1c2d 592 // Get local coordinates of the element
593 if(subd<2){
594 seg->DetToLocal(ix,iz,lcoor[0],lcoor[2]);
595 }
596 else{
597 // SSD: if iz==0 ---> N side; if iz==1 P side
598 if(ssdone[digit]==0){
599 ssdone[digit]=1;
600 pair[digit]=-1;
601 Bool_t pside=(iz==1);
602 Bool_t impaired=kTRUE;
603 Int_t pstrip=0;
604 Int_t nstrip=0;
605 if(pside)pstrip=ix;
606 if(!pside)nstrip=ix;
607 for(Int_t digi2=0;digi2<ndigits;digi2++){
608 if(ssdone[digi2]==0 && impaired){
609 AliITSdigitSSD *dig2=(AliITSdigitSSD*)ITSdigits->UncheckedAt(digi2);
0be9848a 610 if(dig2->GetCoord1() != iz && dig2->GetTrack(0)==digs->GetTrack(0) && dig2->GetTrack(0)>0){
af8e1c2d 611 ssdone[digi2]=2;
612 pair[digit]=digi2;
0be9848a 613 if(pside)nstrip=dig2->GetCoord2();
614 if(!pside)pstrip=dig2->GetCoord2();
af8e1c2d 615 impaired=kFALSE;
616 }
617 }
618 }
619 if(!impaired)seg->GetPadCxz(pstrip,nstrip,lcoor[0],lcoor[2]);
620 }
621 }
622 if(subd<2 || (subd==2 && ssdone[digit]==1)){
0be9848a 623 Int_t coor1=digs->GetCoord1();
624 Int_t coor2=digs->GetCoord2();
af8e1c2d 625 Int_t tra0=digs->GetTrack(0);
626 if(verbose){
813e97e8 627 cout<<"digit # "<<digit<<" fCoord1= "<<coor1<<" fCoord2= ";
628 cout<<coor2<<" track "<<tra0<<" "<<endl;
629 if(subd<2)cout<<"local coordinates -- x="<<lcoor[0]<<", z=";
630 cout<<lcoor[2]<<endl;
af8e1c2d 631 if(subd==2){
632 if(pair[digit]==-1){
633 cout<<"(digit not paired)"<<endl;
634 }
635 else {
813e97e8 636 cout<<"local coordinates -- x="<<lcoor[0]<<", z="<<lcoor[2];
637 cout<<endl;
af8e1c2d 638 Int_t dtmp=pair[digit];
639 AliITSdigitSSD *dig2=(AliITSdigitSSD*)ITSdigits->UncheckedAt(dtmp);
0be9848a 640 Int_t coor1b=dig2->GetCoord1();
641 Int_t coor2b=dig2->GetCoord2();
af8e1c2d 642 Int_t tra0b=dig2->GetTrack(0);
643 cout<<"(digit paired with digit #"<<dtmp<<endl;
813e97e8 644 cout<<"with fCoord1= "<<coor1b<<" fCoord2= "<<coor2b;
645 cout<<" track "<<tra0b<<")"<<endl;
af8e1c2d 646 }
647 }
648 }
649 if(subd<2 || (subd==2 && pair[digit]!=-1)){
650 // Global coordinates of the element
651 //SDD and SPD use cm, SSD microns (GetPadCxz)
652 if(subd==2)for(Int_t j=0;j<3;j++)lcoor[j]=lcoor[j]/10000.;
653 lcoor[1]=0.;
654 geom->LtoG(mod,lcoor,gcoor); // global coord. in cm
655 ragdig=sqrt(gcoor[0]*gcoor[0]+gcoor[1]*gcoor[1]);
544f2385 656 if(verbose){
a6c9fb45 657 cout<<"global coordinates "<<gcoor[0]<<" "<<gcoor[1];
658 cout<<" "<<gcoor[2]<<" Radius "<<ragdig<<endl;
544f2385 659 }
af8e1c2d 660 //Fill histograms
661 TH2F *bidi = (TH2F*)histos.At(subd*9);
662 TH1F *uni = (TH1F*)histos.At(3+subd*9);
663 bidi->Fill(gcoor[0],gcoor[1]);
664 uni->Fill(gcoor[2]);
665 }
666 }
667 } // loop on digits for this module
668 } // if(ndigits>0....
669}