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