]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITS.cxx
SDD digits modified. Both compressed and decompressed ADC values are stored - Tempora...
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18
19///////////////////////////////////////////////////////////////////////////////
20//
21// An overview of the basic philosophy of the ITS code development
22// and analysis is show in the figure below.
23//Begin_Html
24/*
25<img src="picts/ITS/ITS_Analysis_schema.gif">
26</pre>
27<br clear=left>
28<font size=+2 color=red>
29<p>Roberto Barbera is in charge of the ITS Offline code (1999).
30<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
31</font>
32<pre>
33*/
34//End_Html
35//
36// AliITS. Inner Traking System base class.
37// This class contains the base procedures for the Inner Tracking System
38//
39//Begin_Html
40/*
41<img src="picts/ITS/AliITS_Class_Diagram.gif">
42</pre>
43<br clear=left>
44<font size=+2 color=red>
45<p>This show the class diagram of the different elements that are part of
46the AliITS class.
47</font>
48<pre>
49*/
50//End_Html
51//
52// Version: 0
53// Written by Rene Brun, Federico Carminati, and Roberto Barbera
54//
55// Version: 1
56// Modified and documented by Bjorn S. Nilsen
57// July 11 1999
58//
59// Version: 2
60// Modified and documented by A. Bologna
61// October 18 1999
62//
63// AliITS is the general base class for the ITS. Also see AliDetector for
64// futher information.
65//
66///////////////////////////////////////////////////////////////////////////////
67
68#include <Riostream.h>
69#include <stdlib.h>
70
71#include <TBranch.h>
72#include <TClonesArray.h>
73#include <TFile.h>
74#include <TMath.h>
75#include <TObjectTable.h>
76#include <TROOT.h>
77#include <TRandom.h>
78#include <TString.h>
79#include <TTree.h>
80#include <TVector.h>
81#include <TVirtualMC.h>
82
83#include "AliConfig.h"
84#include "AliHeader.h"
85#include "AliITS.h"
86#include "AliITSClusterFinderSDD.h"
87#include "AliITSClusterFinderSPD.h"
88#include "AliITSClusterFinderSSD.h"
89#include "AliITSDetType.h"
90#include "AliITSLoader.h"
91#include "AliITSRawClusterSPD.h"
92#include "AliITSRawClusterSDD.h"
93#include "AliITSRawClusterSSD.h"
94#include "AliITSRecPoint.h"
95#include "AliITSdigitSPD.h"
96#include "AliITSdigitSDD.h"
97#include "AliITSdigitSSD.h"
98#include "AliITSgeom.h"
99#include "AliITShit.h"
100#include "AliITSmodule.h"
101#include "AliITSpList.h"
102#include "AliITSresponseSDD.h"
103#include "AliITSresponseSPD.h"
104#include "AliITSresponseSSD.h"
105#include "AliITSsegmentationSDD.h"
106#include "AliITSsegmentationSPD.h"
107#include "AliITSsegmentationSSD.h"
108#include "AliITSsimulationSDD.h"
109#include "AliITSsimulationSPD.h"
110#include "AliITSsimulationSSD.h"
111#include "AliMC.h"
112#include "AliITSDigitizer.h"
113#include "AliITSclustererV2.h"
114#include "AliITStrackerV2.h"
115#include "AliITSpidESD.h"
116#include "AliV0vertexer.h"
117#include "AliCascadeVertexer.h"
118#include "AliESD.h"
119
120ClassImp(AliITS)
121
122//______________________________________________________________________
123AliITS::AliITS() : AliDetector() {
124 // Default initializer for ITS
125 // The default constructor of the AliITS class. In addition to
126 // creating the AliITS class it zeros the variables fIshunt (a member
127 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
128 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
129 // is also called.
130 // Inputs:
131 // none.
132 // Outputs:
133 // none.
134 // Return:
135 // Blank ITS class.
136
137 fIshunt = 0; // not zeroed in AliDetector.
138
139 // AliITS variables.
140 fEuclidOut = 0;
141 fITSgeom = 0;
142 fITSmodules = 0;
143 fOpt = "All";
144// SetDetectors(); // default to fOpt="All". This variable not written out.
145
146 fIdN = 0;
147 fIdName = 0;
148 fIdSens = 0;
149
150 fNDetTypes = kNTYPES;
151 fDetTypes = 0;
152
153 fSDigits = 0;
154 fNSDigits = 0;
155
156 fNdtype = 0;
157 fDtype = 0;
158
159 fCtype = 0;
160 fNctype = 0;
161
162 fRecPoints = 0;
163 fNRecPoints = 0;
164
165 SetMarkerColor(kRed);
166}
167//______________________________________________________________________
168AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
169 // The standard Constructor for the ITS class. In addition to
170 // creating the AliITS class, it allocates memory for the TClonesArrays
171 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
172 // (clusters). It also zeros the variables
173 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
174 // the pointers fIdSens and fIdName. To help in displaying hits via the
175 // ROOT macro display.C AliITS also sets the marker color to red. The
176 // variables passes with this constructor, const char *name and *title,
177 // are used by the constructor of AliDetector class. See AliDetector
178 // class for a description of these parameters and its constructor
179 // functions.
180 // Inputs:
181 // const char *name Detector name. Should always be "ITS"
182 // const char *title Detector title.
183 // Outputs:
184 // none.
185 // Return:
186 // An ITS class.
187
188 fIshunt = 0; // not zeroed in AliDetector
189 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
190 gAlice->GetMCApp()->AddHitList(fHits); // Not done in AliDetector.
191
192 fEuclidOut = 0;
193 fITSgeom = 0;
194 fITSmodules = 0;
195 SetDetectors(); // default to fOpt="All". This variable not written out.
196
197 fIdN = 0;
198 fIdName = 0;
199 fIdSens = 0;
200
201 fNDetTypes = kNTYPES;
202 fDetTypes = new TObjArray(fNDetTypes);
203
204 fSDigits = new TClonesArray("AliITSpListItem",1000);
205 fNSDigits = 0;
206
207 fNdtype = new Int_t[fNDetTypes];
208 fDtype = new TObjArray(fNDetTypes);
209
210 fCtype = new TObjArray(fNDetTypes);
211 fNctype = new Int_t[fNDetTypes];
212
213 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
214 fNRecPoints = 0;
215
216 Int_t i;
217 for(i=0;i<fNDetTypes;i++) {
218 fDetTypes->AddAt(new AliITSDetType(),i);
219 fNdtype[i] = 0;
220 fNctype[i] = 0;
221 } // end for i
222
223 SetMarkerColor(kRed);
224
225}
226//______________________________________________________________________
227AliITS::~AliITS(){
228 // Default destructor for ITS.
229 // The default destructor of the AliITS class. In addition to deleting
230 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
231 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
232 // fITSpoints, fDetType and it's contents.
233 // Inputs:
234 // none.
235 // Outputs:
236 // none.
237 // Return:
238 // none.
239
240 if (fHits) {
241 fHits->Delete();
242 delete fHits;
243 fHits=0;
244 }
245 if (fSDigits) {
246 fSDigits->Delete();
247 delete fSDigits;
248 fSDigits=0;
249 }
250 if (fDigits) {
251 fDigits->Delete();
252 delete fDigits;
253 fDigits=0;
254 }
255 if (fRecPoints) {
256 fRecPoints->Delete();
257 delete fRecPoints;
258 fRecPoints=0;
259 }
260 delete[] fIdName; // Array of TStrings
261 delete[] fIdSens;
262 if(fITSmodules) {
263 this->ClearModules();
264 delete fITSmodules;
265 fITSmodules = 0;
266 }// end if fITSmodules!=0
267
268 if(fDtype) {
269 fDtype->Delete();
270 delete fDtype;
271 } // end if fDtype
272 delete [] fNdtype;
273 if (fCtype) {
274 fCtype->Delete();
275 delete fCtype;
276 fCtype = 0;
277 } // end if fCtype
278 delete [] fNctype;
279
280 if (fDetTypes) {
281 fDetTypes->Delete();
282 delete fDetTypes;
283 fDetTypes = 0;
284 } // end if fDetTypes
285
286
287 if (fITSgeom) delete fITSgeom;
288}
289//______________________________________________________________________
290AliITS::AliITS(const AliITS &source) : AliDetector(source){
291 // Copy constructor. This is a function which is not allowed to be
292 // done to the ITS. It exits with an error.
293 // Inputs:
294 // AliITS &source An AliITS class.
295 // Outputs:
296 // none.
297 // Return:
298 // none.
299
300 if(this==&source) return;
301 Error("Copy constructor",
302 "You are not allowed to make a copy of the AliITS");
303 exit(1);
304}
305//______________________________________________________________________
306AliITS& AliITS::operator=(AliITS &source){
307 // Assignment operator. This is a function which is not allowed to be
308 // done to the ITS. It exits with an error.
309 // Inputs:
310 // AliITS &source An AliITS class.
311 // Outputs:
312 // none.
313 // Return:
314 // none.
315
316 if(this==&source) return *this;
317 Error("operator=","You are not allowed to make a copy of the AliITS");
318 exit(1);
319 return *this; //fake return
320}
321//______________________________________________________________________
322Int_t AliITS::DistancetoPrimitive(Int_t,Int_t) const{
323 // Distance from mouse to ITS on the screen. Dummy routine
324 // A dummy routine used by the ROOT macro display.C to allow for the
325 // use of the mouse (pointing device) in the macro. In general this should
326 // never be called. If it is it returns the number 9999 for any value of
327 // x and y.
328 // Inputs:
329 // Int_t Dummy screen coordinate.
330 // Int_t Dummy screen coordinate.
331 // Outputs:
332 // none.
333 // Return:
334 // Int_t Dummy = 9999 distance to ITS.
335
336 return 9999;
337}
338//______________________________________________________________________
339void AliITS::Init(){
340 // Initializer ITS after it has been built
341 // This routine initializes the AliITS class. It is intended to be
342 // called from the Init function in AliITSv?. Besides displaying a banner
343 // indicating that it has been called it initializes the array fIdSens
344 // and sets the default segmentation, response, digit and raw cluster
345 // classes therefore it should be called after a call to CreateGeometry.
346 // Inputs:
347 // none.
348 // Outputs:
349 // none.
350 // Return:
351 // none.
352 Int_t i;
353
354 SetDefaults();
355 // Array of TStrings
356 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
357}
358//______________________________________________________________________
359void AliITS::SetDefaults(){
360 // sets the default segmentation, response, digit and raw cluster classes.
361 // Inputs:
362 // none.
363 // Outputs:
364 // none.
365 // Return:
366 // none.
367
368 if(fDebug) printf("%s: SetDefaults\n",ClassName());
369
370 AliITSDetType *iDetType;
371
372 //SPD
373 iDetType=DetType(0);
374 if (!iDetType->GetSegmentationModel()) {
375 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
376 SetSegmentationModel(0,seg0);
377 } // end if
378 if (!iDetType->GetResponseModel()) {
379 SetResponseModel(0,new AliITSresponseSPD());
380 } // end if
381 // set digit and raw cluster classes to be used
382
383 const char *kData0=(iDetType->GetResponseModel())->DataType();
384 if (strstr(kData0,"real")) {
385 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
386 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
387
388 // SDD
389 iDetType=DetType(1);
390 if (!iDetType->GetResponseModel()) {
391 SetResponseModel(1,new AliITSresponseSDD("simulated"));
392 } // end if
393 AliITSresponse *resp1=iDetType->GetResponseModel();
394 if (!iDetType->GetSegmentationModel()) {
395 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
396 SetSegmentationModel(1,seg1);
397 } // end if
398 const char *kData1=(iDetType->GetResponseModel())->DataType();
399 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
400 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
401 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
402 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
403
404 // SSD
405 iDetType=DetType(2);
406 if (!iDetType->GetSegmentationModel()) {
407 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
408 SetSegmentationModel(2,seg2);
409 } // end if
410 if (!iDetType->GetResponseModel()) {
411 SetResponseModel(2,new AliITSresponseSSD("simulated"));
412 } // end if
413 const char *kData2=(iDetType->GetResponseModel())->DataType();
414 if (strstr(kData2,"real")) {
415 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
416 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
417
418 if (kNTYPES>3) {
419 Warning("SetDefaults",
420 "Only the three basic detector types are initialized!");
421 } // end if
422}
423//______________________________________________________________________
424void AliITS::SetDefaultSimulation(){
425 // sets the default simulation.
426 // Inputs:
427 // none.
428 // Outputs:
429 // none.
430 // Return:
431 // none.
432
433 AliITSDetType *iDetType;
434 AliITSsimulation *sim;
435 iDetType=DetType(0);
436 sim = iDetType->GetSimulationModel();
437 if (!sim) {
438 AliITSsegmentation *seg0=
439 (AliITSsegmentation*)iDetType->GetSegmentationModel();
440 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
441 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
442 SetSimulationModel(0,sim0);
443 }else{ // simulation exists, make sure it is set up properly.
444 ((AliITSsimulationSPD*)sim)->Init(
445 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
446 (AliITSresponseSPD*) iDetType->GetResponseModel());
447// if(sim->GetResponseModel()==0) sim->SetResponseModel(
448// (AliITSresponse*)iDetType->GetResponseModel());
449// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
450// (AliITSsegmentation*)iDetType->GetSegmentationModel());
451 } // end if
452 iDetType=DetType(1);
453 sim = iDetType->GetSimulationModel();
454 if (!sim) {
455 AliITSsegmentation *seg1=
456 (AliITSsegmentation*)iDetType->GetSegmentationModel();
457 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
458 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
459 SetSimulationModel(1,sim1);
460 }else{ // simulation exists, make sure it is set up properly.
461 ((AliITSsimulationSDD*)sim)->Init(
462 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
463 (AliITSresponseSDD*) iDetType->GetResponseModel());
464// if(sim->GetResponseModel()==0) sim->SetResponseModel(
465// (AliITSresponse*)iDetType->GetResponseModel());
466// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
467// (AliITSsegmentation*)iDetType->GetSegmentationModel());
468 } //end if
469 iDetType=DetType(2);
470 sim = iDetType->GetSimulationModel();
471 if (!sim) {
472 AliITSsegmentation *seg2=
473 (AliITSsegmentation*)iDetType->GetSegmentationModel();
474 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
475 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
476 SetSimulationModel(2,sim2);
477 }else{ // simulation exists, make sure it is set up properly.
478 ((AliITSsimulationSSD*)sim)->Init(
479 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
480 (AliITSresponseSSD*) iDetType->GetResponseModel());
481// if(sim->GetResponseModel()==0) sim->SetResponseModel(
482// (AliITSresponse*)iDetType->GetResponseModel());
483// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
484// (AliITSsegmentation*)iDetType->GetSegmentationModel());
485 } // end if
486}
487//______________________________________________________________________
488void AliITS::SetDefaultClusterFinders(){
489 // Sets the default cluster finders. Used in finding RecPoints.
490 // Inputs:
491 // none.
492 // Outputs:
493 // none.
494 // Return:
495 // none.
496
497 MakeTreeC();
498 AliITSDetType *iDetType;
499
500 // SPD
501 iDetType=DetType(0);
502 if (!iDetType->GetReconstructionModel()) {
503 AliITSsegmentation *seg0 =
504 (AliITSsegmentation*)iDetType->GetSegmentationModel();
505 TClonesArray *dig0=DigitsAddress(0);
506 TClonesArray *recp0=ClustersAddress(0);
507 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
508 recp0);
509 SetReconstructionModel(0,rec0);
510 } // end if
511
512 // SDD
513 iDetType=DetType(1);
514 if (!iDetType->GetReconstructionModel()) {
515 AliITSsegmentation *seg1 =
516 (AliITSsegmentation*)iDetType->GetSegmentationModel();
517 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
518 TClonesArray *dig1=DigitsAddress(1);
519 TClonesArray *recp1=ClustersAddress(1);
520 AliITSClusterFinderSDD *rec1 =
521 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
522 SetReconstructionModel(1,rec1);
523 } // end if
524
525 // SSD
526 iDetType=DetType(2);
527 if (!iDetType->GetReconstructionModel()) {
528 AliITSsegmentation *seg2=
529 (AliITSsegmentation*)iDetType->GetSegmentationModel();
530 TClonesArray *dig2=DigitsAddress(2);
531 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
532 SetReconstructionModel(2,rec2);
533 } // end if
534}
535//______________________________________________________________________
536void AliITS::MakeBranch(Option_t* option){
537 // Creates Tree branches for the ITS.
538 // Inputs:
539 // Option_t *option String of Tree types S,D, and/or R.
540 // const char *file String of the file name where these branches
541 // are to be stored. If blank then these branches
542 // are written to the same tree as the Hits were
543 // read from.
544 // Outputs:
545 // none.
546 // Return:
547 // none.
548 Bool_t cH = (strstr(option,"H")!=0);
549 Bool_t cS = (strstr(option,"S")!=0);
550 Bool_t cD = (strstr(option,"D")!=0);
551 Bool_t cR = (strstr(option,"R")!=0);
552 Bool_t cRF = (strstr(option,"RF")!=0);
553
554 if(cRF)cR = kFALSE;
555 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
556
557 AliDetector::MakeBranch(option);
558
559 if(cS) MakeBranchS(0);
560 if(cD) MakeBranchD(0);
561 if(cR) MakeBranchR(0);
562 if(cRF) MakeBranchRF(0);
563}
564//______________________________________________________________________
565void AliITS::SetTreeAddress(){
566 // Set branch address for the Trees.
567 // Inputs:
568 // none.
569 // Outputs:
570 // none.
571 // Return:
572 // none.
573 TTree *treeS = fLoader->TreeS();
574 TTree *treeD = fLoader->TreeD();
575 TTree *treeR = fLoader->TreeR();
576 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
577
578 AliDetector::SetTreeAddress();
579
580 SetTreeAddressS(treeS);
581 SetTreeAddressD(treeD);
582 SetTreeAddressR(treeR);
583}
584//______________________________________________________________________
585AliITSDetType* AliITS::DetType(Int_t id){
586 // Return pointer to id detector type.
587 // Inputs:
588 // Int_t id detector id number.
589 // Outputs:
590 // none.
591 // Return:
592 // returned, a pointer to a AliITSDetType.
593
594 return ((AliITSDetType*) fDetTypes->At(id));
595}
596//______________________________________________________________________
597void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
598 // Set the response model for the id detector type.
599 // Inputs:
600 // Int_t id detector id number.
601 // AliITSresponse* a pointer containing an instance of AliITSresponse
602 // to be stored/owned b y AliITSDetType.
603 // Outputs:
604 // none.
605 // Return:
606 // none.
607
608 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
609}
610//______________________________________________________________________
611void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
612 // Set the segmentation model for the id detector type.
613 // Inputs:
614 // Int_t id detector id number.
615 // AliITSsegmentation* a pointer containing an instance of
616 // AliITSsegmentation to be stored/owned b y
617 // AliITSDetType.
618 // Outputs:
619 // none.
620 // Return:
621 // none.
622
623 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
624}
625//______________________________________________________________________
626void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
627 // Set the simulation model for the id detector type.
628 // Inputs:
629 // Int_t id detector id number.
630 // AliITSresponse* a pointer containing an instance of AliITSresponse
631 // to be stored/owned b y AliITSDetType.
632 // Outputs:
633 // none.
634 // Return:
635 // none.
636
637 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
638
639}
640//______________________________________________________________________
641void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
642 // Set the cluster finder model for the id detector type.
643 // Inputs:
644 // Int_t id detector id number.
645 // AliITSClusterFinder* a pointer containing an instance of
646 // AliITSClusterFinder to be stored/owned b y
647 // AliITSDetType.
648 // Outputs:
649 // none.
650 // Return:
651 // none.
652
653 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
654}
655//______________________________________________________________________
656void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
657 // Set the digit and cluster classes name to be used for the id detector
658 // type.
659 // Inputs:
660 // Int_t id detector id number.
661 // const char *digit Digit class name for detector id.
662 // const char *cluster Cluster class name for detector id.
663 // Outputs:
664 // none.
665 // Return:
666 // none.
667
668 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
669}
670//______________________________________________________________________
671void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
672 // Add an ITS hit
673 // The function to add information to the AliITShit class. See the
674 // AliITShit class for a full description. This function allocates the
675 // necessary new space for the hit information and passes the variable
676 // track, and the pointers *vol and *hits to the AliITShit constructor
677 // function.
678 // Inputs:
679 // Int_t track Track number which produced this hit.
680 // Int_t *vol Array of Integer Hit information. See AliITShit.h
681 // Float_t *hits Array of Floating Hit information. see AliITShit.h
682 // Outputs:
683 // none.
684 // Return:
685 // none.
686
687 TClonesArray &lhits = *fHits;
688 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
689}
690//______________________________________________________________________
691void AliITS::InitModules(Int_t size,Int_t &nmodules){
692 // Initialize the modules array.
693 // Inputs:
694 // Int_t size Size of array of the number of modules to be
695 // created. If size <=0 then the number of modules
696 // is gotten from AliITSgeom class kept in fITSgeom.
697 // Outputs:
698 // Int_t &nmodules The number of modules existing.
699 // Return:
700 // none.
701
702 if(fITSmodules){
703 fITSmodules->Delete();
704 delete fITSmodules;
705 } // end fir fITSmoudles
706
707 Int_t nl,indexMAX,index;
708
709 if(size<=0){ // default to using data stored in AliITSgeom
710 if(fITSgeom==0) {
711 Error("InitModules","fITSgeom not defined");
712 return;
713 } // end if fITSgeom==0
714 nl = fITSgeom->GetNlayers();
715 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
716 fITSgeom->GetNdetectors(nl))+1;
717 nmodules = indexMAX;
718 fITSmodules = new TObjArray(indexMAX);
719 for(index=0;index<indexMAX;index++){
720 fITSmodules->AddAt( new AliITSmodule(index),index);
721 } // end for index
722 }else{
723 fITSmodules = new TObjArray(size);
724 for(index=0;index<size;index++) {
725 fITSmodules->AddAt( new AliITSmodule(index),index);
726 } // end for index
727
728 nmodules = size;
729 } // end i size<=0
730}
731//______________________________________________________________________
732void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
733 Option_t *option,Text_t *filename){
734 // fill the modules with the sorted by module hits; add hits from
735 // background if option=Add.
736 // Inputs:
737 // Int_t evnt Event to be processed.
738 // Int_t bgrev Background Hit tree number.
739 // Int_t nmodules Not used.
740 // Option_t *option String indicating if merging hits or not. To
741 // merge hits set equal to "Add". Otherwise no
742 // background hits are considered.
743 // Test_t *filename File name containing the background hits..
744 // Outputs:
745 // none.
746 // Return:
747 // none.
748 static TTree *trH1; //Tree with background hits
749 static Bool_t first=kTRUE;
750 static TFile *file;
751 const char *addBgr = strstr(option,"Add");
752
753 evnt = nmodules; // Dummy use of variables to remove warnings
754 if (addBgr ) {
755 if(first) {
756 file=new TFile(filename);
757 } // end if first
758 first=kFALSE;
759 file->cd();
760 file->ls();
761 // Get Hits Tree header from file
762 if(trH1) delete trH1;
763 trH1=0;
764
765 char treeName[20];
766 sprintf(treeName,"TreeH%d",bgrev);
767 trH1 = (TTree*)gDirectory->Get(treeName);
768 if (!trH1) {
769 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
770 } // end if !trH1
771 // Set branch addresses
772 } // end if addBgr
773
774 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
775
776 if (addBgr ) {
777 FillModules(trH1,10000000); // Default mask 10M.
778 TTree *fAli=fLoader->GetRunLoader()->TreeK();
779 TFile *fileAli=0;
780 if (fAli) fileAli =fAli->GetCurrentFile();
781 fileAli->cd();
782 } // end if add
783}
784//______________________________________________________________________
785void AliITS::FillModules(TTree *treeH, Int_t mask) {
786 // fill the modules with the sorted by module hits;
787 // can be called many times to do a merging
788 // Inputs:
789 // TTree *treeH The tree containing the hits to be copied into
790 // the modules.
791 // Int_t mask The track number mask to indecate which file
792 // this hits came from.
793 // Outputs:
794 // none.
795 // Return:
796 // none.
797
798 if (treeH == 0x0)
799 {
800 Error("FillModules","Tree is NULL");
801 }
802 Int_t lay,lad,det,index;
803 AliITShit *itsHit=0;
804 AliITSmodule *mod=0;
805 char branchname[20];
806 sprintf(branchname,"%s",GetName());
807 TBranch *branch = treeH->GetBranch(branchname);
808 if (!branch) {
809 Error("FillModules","%s branch in TreeH not found",branchname);
810 return;
811 } // end if !branch
812 branch->SetAddress(&fHits);
813 Int_t nTracks =(Int_t) treeH->GetEntries();
814 Int_t iPrimTrack,h;
815 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
816 ResetHits();
817 Int_t nBytes = treeH->GetEvent(iPrimTrack);
818 if (nBytes <= 0) continue;
819 Int_t nHits = fHits->GetEntriesFast();
820 for(h=0; h<nHits; h++){
821 itsHit = (AliITShit *)fHits->UncheckedAt(h);
822 itsHit->GetDetectorID(lay,lad,det);
823 if (fITSgeom) {
824 index = fITSgeom->GetModuleIndex(lay,lad,det);
825 } else {
826 index=det-1; // This should not be used.
827 } // end if [You must have fITSgeom for this to work!]
828 mod = GetModule(index);
829 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
830 mod->AddHit(itsHit,iPrimTrack,h);
831 } // end loop over hits
832 } // end loop over tracks
833}
834//______________________________________________________________________
835void AliITS::ClearModules(){
836 // Clear the modules TObjArray.
837 // Inputs:
838 // none.
839 // Outputs:
840 // none.
841
842 if(fITSmodules) fITSmodules->Delete();
843}
844//______________________________________________________________________
845void AliITS::MakeBranchS(const char *fl){
846 // Creates Tree Branch for the ITS summable digits.
847 // Inputs:
848 // cont char *fl File name where SDigits branch is to be written
849 // to. If blank it write the SDigits to the same
850 // file in which the Hits were found.
851 // Outputs:
852 // none.
853 // Return:
854 // none.
855 Int_t buffersize = 4000;
856 char branchname[30];
857
858 // only one branch for SDigits.
859 sprintf(branchname,"%s",GetName());
860
861
862 if(fLoader->TreeS()){
863 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
864 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
865 } // end if
866}
867//______________________________________________________________________
868void AliITS::SetTreeAddressS(TTree *treeS){
869 // Set branch address for the ITS summable digits Trees.
870 // Inputs:
871 // TTree *treeS Tree containing the SDigits.
872 // Outputs:
873 // none.
874 // Return:
875 // none.
876 char branchname[30];
877
878 if(!treeS) return;
879 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
880 TBranch *branch;
881 sprintf(branchname,"%s",GetName());
882 branch = treeS->GetBranch(branchname);
883 if (branch) branch->SetAddress(&fSDigits);
884}
885//______________________________________________________________________
886void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
887 // Creates Tree branches for the ITS.
888 // Inputs:
889 // TTree *treeD Pointer to the Digits Tree.
890 // cont char *file File name where Digits branch is to be written
891 // to. If blank it write the SDigits to the same
892 // file in which the Hits were found.
893 // Outputs:
894 // none.
895 // Return:
896 // none.
897 Int_t buffersize = 4000;
898 char branchname[30];
899
900 sprintf(branchname,"%s",GetName());
901 // one branch for digits per type of detector
902 const char *det[3] = {"SPD","SDD","SSD"};
903 char digclass[40];
904 char clclass[40];
905 Int_t i;
906 for (i=0; i<kNTYPES ;i++) {
907 DetType(i)->GetClassNames(digclass,clclass);
908 // digits
909 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
910 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
911 else ResetDigits(i);
912 } // end for i
913 for (i=0; i<kNTYPES ;i++) {
914 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
915 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
916 if (fDtype && treeD) {
917 MakeBranchInTree(treeD, branchname, &((*fDtype)[i]),buffersize,file);
918 } // end if
919 } // end for i
920}
921//______________________________________________________________________
922void AliITS::SetTreeAddressD(TTree *treeD){
923 // Set branch address for the Trees.
924 // Inputs:
925 // TTree *treeD Tree containing the Digits.
926 // Outputs:
927 // none.
928 // Return:
929 // none.
930 char branchname[30];
931 const char *det[3] = {"SPD","SDD","SSD"};
932 TBranch *branch;
933 char digclass[40];
934 char clclass[40];
935 Int_t i;
936
937 if(!treeD) return;
938 for (i=0; i<kNTYPES; i++) {
939 DetType(i)->GetClassNames(digclass,clclass);
940 // digits
941 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
942 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
943 else ResetDigits(i);
944 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
945 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
946 if (fDtype) {
947 branch = treeD->GetBranch(branchname);
948 if (branch) branch->SetAddress(&((*fDtype)[i]));
949 } // end if fDtype
950 } // end for i
951}
952//______________________________________________________________________
953void AliITS::Hits2SDigits(){
954 // Standard Hits to summable Digits function.
955 // Inputs:
956 // none.
957 // Outputs:
958 // none.
959
960// return; // Using Hits in place of the larger sDigits.
961 fLoader->LoadHits("read");
962 fLoader->LoadSDigits("recreate");
963 AliRunLoader* rl = fLoader->GetRunLoader();
964
965 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
966 // Do the Hits to Digits operation. Use Standard input values.
967 // Event number from file, no background hit merging , use size from
968 // AliITSgeom class, option="All", input from this file only.
969 rl->GetEvent(iEvent);
970 if (!fLoader->TreeS()) fLoader->MakeTree("S");
971 MakeBranch("S");
972 SetTreeAddress();
973 HitsToSDigits(iEvent,0,-1," ",fOpt," ");
974 }
975
976 fLoader->UnloadHits();
977 fLoader->UnloadSDigits();
978}
979//______________________________________________________________________
980void AliITS::Hits2PreDigits(){
981 // Standard Hits to summable Digits function.
982 // Inputs:
983 // none.
984 // Outputs:
985 // none.
986
987 AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file.
988 // Do the Hits to Digits operation. Use Standard input values.
989 // Event number from file, no background hit merging , use size from
990 // AliITSgeom class, option="All", input from this file only.
991 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
992}
993//______________________________________________________________________
994AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) const
995{
996 return new AliITSDigitizer(manager);
997}
998//______________________________________________________________________
999void AliITS::SDigitsToDigits(Option_t *opt){
1000 // Standard Summable digits to Digits function.
1001 // Inputs:
1002 // none.
1003 // Outputs:
1004 // none.
1005 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1006
1007 if(!GetITSgeom()) return; // need transformations to do digitization.
1008 AliITSgeom *geom = GetITSgeom();
1009
1010 const char *all = strstr(opt,"All");
1011 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1012 strstr(opt,"SSD")};
1013 if( !det[0] && !det[1] && !det[2] ) all = "All";
1014 else all = 0;
1015 static Bool_t setDef=kTRUE;
1016 if (setDef) SetDefaultSimulation();
1017 setDef=kFALSE;
1018
1019 AliITSsimulation *sim = 0;
1020 AliITSDetType *iDetType = 0;
1021 TTree *trees = fLoader->TreeS();
1022 if( !(trees && this->GetSDigits()) ){
1023 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1024 return;
1025 } // end if
1026 sprintf( name, "%s", this->GetName() );
1027 TBranch *brchSDigits = trees->GetBranch( name );
1028
1029 Int_t id,module;
1030 for(module=0;module<geom->GetIndexMax();module++){
1031 id = geom->GetModuleType(module);
1032 if (!all && !det[id]) continue;
1033 iDetType = DetType(id);
1034 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1035 if (!sim) {
1036 Error("SDigit2Digits",
1037 "The simulation class was not instanciated!");
1038 exit(1);
1039 } // end if !sim
1040 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1041//
1042 // add summable digits to module
1043 this->GetSDigits()->Clear();
1044 brchSDigits->GetEvent(module);
1045 sim->AddSDigitsToModule(GetSDigits(),0);
1046//
1047 // Digitise current module sum(SDigits)->Digits
1048 sim->FinishSDigitiseModule();
1049
1050 // fills all branches - wasted disk space
1051 fLoader->TreeD()->Fill();
1052 this->ResetDigits();
1053 } // end for module
1054
1055 fLoader->TreeD()->GetEntries();
1056
1057 fLoader->TreeD()->AutoSave();
1058 // reset tree
1059 fLoader->TreeD()->Reset();
1060
1061}
1062//______________________________________________________________________
1063void AliITS::Hits2Digits(){
1064 // Standard Hits to Digits function.
1065 // Inputs:
1066 // none.
1067 // Outputs:
1068 // none.
1069
1070 fLoader->LoadHits("read");
1071 fLoader->LoadDigits("recreate");
1072 AliRunLoader* rl = fLoader->GetRunLoader();
1073
1074 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1075 // Do the Hits to Digits operation. Use Standard input values.
1076 // Event number from file, no background hit merging , use size from
1077 // AliITSgeom class, option="All", input from this file only.
1078 rl->GetEvent(iEvent);
1079 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1080 MakeBranch("D");
1081 SetTreeAddress();
1082 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1083 }
1084
1085 fLoader->UnloadHits();
1086 fLoader->UnloadDigits();
1087}
1088//______________________________________________________________________
1089void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1090 Option_t *option, Option_t *opt,Text_t *filename){
1091 // keep galice.root for signal and name differently the file for
1092 // background when add! otherwise the track info for signal will be lost !
1093 // the condition below will disappear when the geom class will be
1094 // initialized for all versions - for the moment it is only for v5 !
1095 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1096 // Digits.
1097 // Inputs:
1098 // Int_t evnt Event to be processed.
1099 // Int_t bgrev Background Hit tree number.
1100 // Int_t nmodules Not used.
1101 // Option_t *option String indicating if merging hits or not. To
1102 // merge hits set equal to "Add". Otherwise no
1103 // background hits are considered.
1104 // Test_t *filename File name containing the background hits..
1105 // Outputs:
1106 // none.
1107 // Return:
1108 // none.
1109// return; // using Hits instead of the larger sdigits.
1110
1111 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1112}
1113//______________________________________________________________________
1114void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1115 Option_t *option, Option_t *opt,Text_t *filename){
1116 // Keep galice.root for signal and name differently the file for
1117 // background when add! otherwise the track info for signal will be lost !
1118 // the condition below will disappear when the geom class will be
1119 // initialized for all versions - for the moment it is only for v5 !
1120 // 7 is the SDD beam test version.
1121 // Inputs:
1122 // Int_t evnt Event to be processed.
1123 // Int_t bgrev Background Hit tree number.
1124 // Int_t nmodules Not used.
1125 // Option_t *option String indicating if merging hits or not. To
1126 // merge hits set equal to "Add". Otherwise no
1127 // background hits are considered.
1128 // Test_t *filename File name containing the background hits..
1129 // Outputs:
1130 // none.
1131 // Return:
1132 // none.
1133
1134 if(!GetITSgeom()) return; // need transformations to do digitization.
1135 AliITSgeom *geom = GetITSgeom();
1136
1137 const char *all = strstr(opt,"All");
1138 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1139 strstr(opt,"SSD")};
1140 static Bool_t setDef=kTRUE;
1141 if (setDef) SetDefaultSimulation();
1142 setDef=kFALSE;
1143
1144 Int_t nmodules;
1145 InitModules(size,nmodules);
1146 FillModules(evNumber,bgrev,nmodules,option,filename);
1147
1148 AliITSsimulation *sim = 0;
1149 AliITSDetType *iDetType = 0;
1150 AliITSmodule *mod = 0;
1151 Int_t id,module;
1152 for(module=0;module<geom->GetIndexMax();module++){
1153 id = geom->GetModuleType(module);
1154 if (!all && !det[id]) continue;
1155 iDetType = DetType(id);
1156 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1157 if (!sim) {
1158 Error("HitsToSDigits",
1159 "The simulation class was not instanciated!");
1160 exit(1);
1161 } // end if !sim
1162 mod = (AliITSmodule *)fITSmodules->At(module);
1163 sim->SDigitiseModule(mod,module,evNumber);
1164 // fills all branches - wasted disk space
1165 fLoader->TreeS()->Fill();
1166 ResetSDigits();
1167 } // end for module
1168
1169 ClearModules();
1170
1171 fLoader->TreeS()->GetEntries();
1172 fLoader->TreeS()->AutoSave();
1173 fLoader->WriteSDigits("OVERWRITE");
1174 // reset tree
1175 fLoader->TreeS()->Reset();
1176}
1177//______________________________________________________________________
1178void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1179 Option_t *option, Option_t *opt,Text_t *filename){
1180 // Keep galice.root for signal and name differently the file for
1181 // background when add! otherwise the track info for signal will be lost !
1182 // the condition below will disappear when the geom class will be
1183 // initialized for all versions - for the moment it is only for v5 !
1184 // 7 is the SDD beam test version.
1185 // Inputs:
1186 // Int_t evnt Event to be processed.
1187 // Int_t bgrev Background Hit tree number.
1188 // Int_t nmodules Not used.
1189 // Option_t *option String indicating if merging hits or not. To
1190 // merge hits set equal to "Add". Otherwise no
1191 // background hits are considered.
1192 // Test_t *filename File name containing the background hits..
1193 // Outputs:
1194 // none.
1195 // Return:
1196 // none.
1197
1198 if(!GetITSgeom()) return; // need transformations to do digitization.
1199 AliITSgeom *geom = GetITSgeom();
1200
1201 const char *all = strstr(opt,"All");
1202 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1203 strstr(opt,"SSD")};
1204 static Bool_t setDef=kTRUE;
1205 if (setDef) SetDefaultSimulation();
1206 setDef=kFALSE;
1207
1208 Int_t nmodules;
1209 InitModules(size,nmodules);
1210 FillModules(evNumber,bgrev,nmodules,option,filename);
1211
1212 AliITSsimulation *sim = 0;
1213 AliITSDetType *iDetType = 0;
1214 AliITSmodule *mod = 0;
1215 Int_t id,module;
1216 for(module=0;module<geom->GetIndexMax();module++){
1217 id = geom->GetModuleType(module);
1218 if (!all && !det[id]) continue;
1219 iDetType = DetType(id);
1220 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1221 if (!sim) {
1222 Error("HitsToDigits",
1223 "The simulation class was not instanciated!");
1224 exit(1);
1225 } // end if !sim
1226 mod = (AliITSmodule *)fITSmodules->At(module);
1227 sim->DigitiseModule(mod,module,evNumber);
1228 // fills all branches - wasted disk space
1229 fLoader->TreeD()->Fill();
1230 ResetDigits();
1231 } // end for module
1232
1233 ClearModules();
1234
1235 fLoader->TreeD()->GetEntries();
1236 fLoader->TreeD()->AutoSave();
1237 // reset tree
1238 fLoader->TreeD()->Reset();
1239}
1240//______________________________________________________________________
1241void AliITS::ResetSDigits(){
1242 // Reset the Summable Digits array.
1243 // Inputs:
1244 // none.
1245 // Outputs:
1246 // none.
1247
1248 if (fSDigits) fSDigits->Clear();
1249 fNSDigits = 0;
1250}
1251//______________________________________________________________________
1252void AliITS::ResetDigits(){
1253 // Reset number of digits and the digits array for the ITS detector.
1254 // Inputs:
1255 // none.
1256 // Outputs:
1257 // none.
1258
1259 if (!fDtype) return;
1260
1261 Int_t i;
1262 for (i=0;i<kNTYPES;i++ ) {
1263 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1264 if (fNdtype) fNdtype[i]=0;
1265 } // end for i
1266}
1267//______________________________________________________________________
1268void AliITS::ResetDigits(Int_t i){
1269 // Reset number of digits and the digits array for this branch.
1270 // Inputs:
1271 // none.
1272 // Outputs:
1273 // none.
1274
1275 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1276 if (fNdtype) fNdtype[i]=0;
1277}
1278//______________________________________________________________________
1279void AliITS::AddSumDigit(AliITSpListItem &sdig){
1280 // Adds the a module full of summable digits to the summable digits tree.
1281 // Inputs:
1282 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1283 // Outputs:
1284 // none.
1285 // Return:
1286 // none.
1287
1288 TClonesArray &lsdig = *fSDigits;
1289 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1290}
1291//______________________________________________________________________
1292void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1293 // Add a real digit - as coming from data.
1294 // Inputs:
1295 // Int_t id Detector type number.
1296 // Int_t *digits Integer array containing the digits info. See
1297 // AliITSdigit.h
1298 // Outputs:
1299 // none.
1300 // Return:
1301 // none.
1302
1303 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1304 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1305}
1306//______________________________________________________________________
1307void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1308 // Add a simulated digit.
1309 // Inputs:
1310 // Int_t id Detector type number.
1311 // AliITSdigit *d Digit to be added to the Digits Tree. See
1312 // AliITSdigit.h
1313 // Outputs:
1314 // none.
1315 // Return:
1316 // none.
1317
1318 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1319
1320 switch(id){
1321 case 0:
1322 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1323 break;
1324 case 1:
1325 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1326 break;
1327 case 2:
1328 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1329 break;
1330 } // end switch id
1331}
1332//______________________________________________________________________
1333void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1334 Int_t *hits,Float_t *charges){
1335 // Add a simulated digit to the list.
1336 // Inputs:
1337 // Int_t id Detector type number.
1338 // Float_t phys Physics indicator. See AliITSdigits.h
1339 // Int_t *digits Integer array containing the digits info. See
1340 // AliITSdigit.h
1341 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1342 // containing the track numbers that contributed to
1343 // this digit.
1344 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1345 // containing the hit numbers, from AliITSmodule, that
1346 // contributed to this digit.
1347 // Float_t *charge Floating point array of the signals contributed
1348 // to this digit by each track.
1349 // Outputs:
1350 // none.
1351 // Return:
1352 // none.
1353
1354 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1355 AliITSresponseSDD *resp = 0;
1356 switch(id){
1357 case 0:
1358 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1359 break;
1360 case 1:
1361 resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel();
1362 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1363 hits,charges,resp);
1364 break;
1365 case 2:
1366 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1367 break;
1368 } // end switch id
1369}
1370//______________________________________________________________________
1371void AliITS::MakeTreeC(Option_t *option){
1372 // Create a separate tree to store the clusters.
1373 // Inputs:
1374 // Option_t *option string which must contain "C" otherwise
1375 // no Cluster Tree is created.
1376 // Outputs:
1377 // none.
1378 // Return:
1379 // none.
1380
1381 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1382
1383 if (pITSLoader == 0x0) {
1384 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1385 return;
1386 }
1387 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1388 MakeBranchC();
1389}
1390
1391void AliITS::MakeBranchC()
1392{
1393//Makes barnches in treeC
1394 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1395 if (pITSLoader == 0x0)
1396 {
1397 Error("MakeTreeC","fLoader == 0x0");
1398 return;
1399 }
1400 TTree * lTC = pITSLoader->TreeC();
1401 if (lTC == 0x0)
1402 {
1403 Error("MakeTreeC","Can not get TreeC from Loader");
1404 return;
1405 }
1406
1407 Int_t buffersize = 4000;
1408 char branchname[30];
1409 const char *det[3] = {"SPD","SDD","SSD"};
1410 char digclass[40];
1411 char clclass[40];
1412
1413 // one branch for Clusters per type of detector
1414 Int_t i;
1415 for (i=0; i<kNTYPES ;i++)
1416 {
1417 AliITSDetType *iDetType=DetType(i);
1418 iDetType->GetClassNames(digclass,clclass);
1419 // clusters
1420 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1421 if(!ClustersAddress(i))
1422 {
1423 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1424 }
1425 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1426 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1427 if (fCtype && lTC)
1428 {
1429 if (lTC->GetBranch(branchname))
1430 {
1431 Warning("MakeBranchC","Branch %s alread exists in TreeC",branchname);
1432 }
1433 else
1434 {
1435 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1436 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1437 }
1438 } // end if fCtype && lTC
1439 } // end for i
1440}
1441
1442//______________________________________________________________________
1443void AliITS::GetTreeC(Int_t event){
1444 // Get the clusters tree for this event and set the branch address.
1445 // Inputs:
1446 // Int_t event Event number for the cluster tree.
1447 // Outputs:
1448 // none.
1449 // Return:
1450 // none.
1451 char branchname[30];
1452 const char *det[3] = {"SPD","SDD","SSD"};
1453
1454 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1455 TTree * lTC = pITSLoader->TreeC();
1456
1457 ResetClusters();
1458 if (lTC) {
1459 pITSLoader->CleanRawClusters();
1460 } // end if TreeC()
1461
1462
1463 TBranch *branch;
1464
1465 if (lTC) {
1466 Int_t i;
1467 char digclass[40];
1468 char clclass[40];
1469 for (i=0; i<kNTYPES; i++) {
1470 AliITSDetType *iDetType=DetType(i);
1471 iDetType->GetClassNames(digclass,clclass);
1472 // clusters
1473 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1474 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1475 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1476 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1477 if (fCtype) {
1478 branch = lTC->GetBranch(branchname);
1479 if (branch) branch->SetAddress(&((*fCtype)[i]));
1480 } // end if fCtype
1481 } // end for i
1482 } else {
1483 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1484 } // end if lTC
1485}
1486//______________________________________________________________________
1487void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1488 // Add a cluster to the list.
1489 // Inputs:
1490 // Int_t id Detector type number.
1491 // AliITSRawCluster *c Cluster class to be added to the tree of
1492 // clusters.
1493 // Outputs:
1494 // none.
1495 // Return:
1496 // none.
1497
1498 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1499
1500 switch(id){
1501 case 0:
1502 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1503 break;
1504 case 1:
1505 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1506 break;
1507 case 2:
1508 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1509 break;
1510 } // end switch id
1511}
1512//______________________________________________________________________
1513void AliITS::ResetClusters(){
1514 // Reset number of clusters and the clusters array for ITS.
1515 // Inputs:
1516 // none.
1517 // Outputs:
1518 // none.
1519
1520 Int_t i;
1521 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1522}
1523//______________________________________________________________________
1524void AliITS::ResetClusters(Int_t i){
1525 // Reset number of clusters and the clusters array for this branch.
1526 // Inputs:
1527 // Int_t i Detector type number.
1528 // Outputs:
1529 // none.
1530 // Return:
1531 // none.
1532
1533 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1534 if (fNctype) fNctype[i]=0;
1535}
1536//______________________________________________________________________
1537void AliITS::MakeBranchR(const char *file, Option_t *opt){
1538 // Creates Tree branches for the ITS Reconstructed points.
1539 // Inputs:
1540 // cont char *file File name where RecPoints branch is to be written
1541 // to. If blank it write the SDigits to the same
1542 // file in which the Hits were found.
1543 // Outputs:
1544 // none.
1545 // Return:
1546 // none.
1547 Int_t buffsz = 4000;
1548 char branchname[30];
1549
1550 // only one branch for rec points for all detector types
1551 Bool_t oFast= (strstr(opt,"Fast")!=0);
1552 if(oFast){
1553 sprintf(branchname,"%sRecPointsF",GetName());
1554 } else {
1555 sprintf(branchname,"%sRecPoints",GetName());
1556 }
1557
1558
1559 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1560 if (fLoader->TreeR()) {
1561 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1562 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1563 } // end if
1564}
1565//______________________________________________________________________
1566void AliITS::SetTreeAddressR(TTree *treeR){
1567 // Set branch address for the Reconstructed points Trees.
1568 // Inputs:
1569 // TTree *treeR Tree containing the RecPoints.
1570 // Outputs:
1571 // none.
1572 // Return:
1573 // none.
1574 char branchname[30];
1575
1576 if(!treeR) return;
1577 if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1578 TBranch *branch;
1579 sprintf(branchname,"%sRecPoints",GetName());
1580 branch = treeR->GetBranch(branchname);
1581 if (branch) {
1582 branch->SetAddress(&fRecPoints);
1583 }
1584 else {
1585 sprintf(branchname,"%sRecPointsF",GetName());
1586 branch = treeR->GetBranch(branchname);
1587 if (branch) {
1588 branch->SetAddress(&fRecPoints);
1589 }
1590 }
1591}
1592//______________________________________________________________________
1593void AliITS::AddRecPoint(const AliITSRecPoint &r){
1594 // Add a reconstructed space point to the list
1595 // Inputs:
1596 // const AliITSRecPoint &r RecPoint class to be added to the tree
1597 // of reconstructed points TreeR.
1598 // Outputs:
1599 // none.
1600 // Return:
1601 // none.
1602
1603 TClonesArray &lrecp = *fRecPoints;
1604 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1605}
1606//______________________________________________________________________
1607void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1608 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1609 // keep galice.root for signal and name differently the file for
1610 // background when add! otherwise the track info for signal will be lost !
1611 // the condition below will disappear when the geom class will be
1612 // initialized for all versions - for the moment it is only for v5 !
1613 // Inputs:
1614 // Int_t evnt Event to be processed.
1615 // Int_t bgrev Background Hit tree number.
1616 // Int_t size Size used by InitModules. See InitModules.
1617 // Option_t *opt0 Option passed to FillModules. See FillModules.
1618 // Option_t *opt1 String indicating if merging hits or not. To
1619 // merge hits set equal to "Add". Otherwise no
1620 // background hits are considered.
1621 // Test_t *flnm File name containing the background hits..
1622 // Outputs:
1623 // none.
1624 // Return:
1625 // none.
1626
1627 if(!GetITSgeom()) return;
1628 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1629 AliITSgeom *geom = GetITSgeom();
1630
1631 const char *all = strstr(opt1,"All");
1632 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1633 strstr(opt1,"SSD")};
1634 Int_t nmodules;
1635 InitModules(size,nmodules);
1636 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1637
1638 AliITSsimulation *sim = 0;
1639 AliITSDetType *iDetType = 0;
1640 AliITSmodule *mod = 0;
1641 Int_t id,module;
1642
1643 //m.b. : this change is nothing but a nice way to make sure
1644 //the CPU goes up !
1645
1646 cout<<"HitsToFastRecPoints: N mod = "<<geom->GetIndexMax()<<endl;
1647
1648 for(module=0;module<geom->GetIndexMax();module++)
1649 {
1650 id = geom->GetModuleType(module);
1651 if (!all && !det[id]) continue;
1652 iDetType = DetType(id);
1653 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1654 if (!sim)
1655 {
1656 Error("HitsToFastPoints","The simulation class was not instanciated!");
1657 exit(1);
1658 } // end if !sim
1659 mod = (AliITSmodule *)fITSmodules->At(module);
1660 sim->CreateFastRecPoints(mod,module,gRandom);
1661 cout<<module<<"\r";fflush(0);
1662 //gAlice->TreeR()->Fill();
1663 TTree *lTR = pITSloader->TreeR();
1664 TBranch *br=lTR->GetBranch("ITSRecPointsF");
1665 br->Fill();
1666 ResetRecPoints();
1667 } // end for module
1668
1669 ClearModules();
1670
1671 fLoader->WriteRecPoints("OVERWRITE");
1672}
1673//______________________________________________________________________
1674void AliITS::Digits2Reco(){
1675 // Find clusters and reconstruct space points.
1676 // Inputs:
1677 // none.
1678 // Outputs:
1679 // none.
1680
1681 AliHeader *header=fLoader->GetRunLoader()->GetHeader();
1682 // to Digits to RecPoints for event in file, all digits in file, and
1683 // all ITS detectors.
1684 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1685}
1686//______________________________________________________________________
1687void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1688 // cluster finding and reconstruction of space points
1689 // the condition below will disappear when the geom class will be
1690 // initialized for all versions - for the moment it is only for v5 !
1691 // 7 is the SDD beam test version
1692 // Inputs:
1693 // Int_t evNumber Event number to be processed.
1694 // Int_t lastentry Offset for module when not all of the modules
1695 // are processed.
1696 // Option_t *opt String indicating which ITS sub-detectors should
1697 // be processed. If ="All" then all of the ITS
1698 // sub detectors are processed.
1699 // Outputs:
1700 // none.
1701 // Return:
1702 // none.
1703
1704 if(!GetITSgeom()) return;
1705 AliITSgeom *geom = GetITSgeom();
1706
1707 const char *all = strstr(opt,"All");
1708 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1709 strstr(opt,"SSD")};
1710 static Bool_t setRec=kTRUE;
1711 if (setRec) SetDefaultClusterFinders();
1712 setRec=kFALSE;
1713
1714 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1715 TTree *treeC=pITSloader->TreeC();
1716 AliITSClusterFinder *rec = 0;
1717 AliITSDetType *iDetType = 0;
1718 Int_t id,module,first=0;
1719 for(module=0;module<geom->GetIndexMax();module++){
1720 id = geom->GetModuleType(module);
1721 if (!all && !det[id]) continue;
1722 if(det[id]) first = geom->GetStartDet(id);
1723 iDetType = DetType(id);
1724 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1725 TClonesArray *itsDigits = this->DigitsAddress(id);
1726 if (!rec) {
1727 Error("DigitsToRecPoints",
1728 "The reconstruction class was not instanciated! event=%d",
1729 evNumber);
1730 exit(1);
1731 } // end if !rec
1732 this->ResetDigits();
1733 TTree *lTD = pITSloader->TreeD();
1734 if (all) {
1735 lTD->GetEvent(lastentry+module);
1736 }else {
1737 lTD->GetEvent(lastentry+(module-first));
1738 }
1739 Int_t ndigits = itsDigits->GetEntriesFast();
1740 if (ndigits) rec->FindRawClusters(module);
1741 pITSloader->TreeR()->Fill();
1742 ResetRecPoints();
1743 treeC->Fill();
1744 ResetClusters();
1745 } // end for module
1746
1747
1748 pITSloader->WriteRecPoints("OVERWRITE");
1749 pITSloader->WriteRawClusters("OVERWRITE");
1750}
1751//______________________________________________________________________
1752void AliITS::ResetRecPoints(){
1753 // Reset number of rec points and the rec points array.
1754 // Inputs:
1755 // none.
1756 // Outputs:
1757 // none.
1758
1759 if (fRecPoints) fRecPoints->Clear();
1760 fNRecPoints = 0;
1761}
1762//______________________________________________________________________
1763AliLoader* AliITS::MakeLoader(const char* topfoldername)
1764{
1765 //builds ITSgetter (AliLoader type)
1766 //if detector wants to use castomized getter, it must overload this method
1767
1768 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",topfoldername);
1769 fLoader = new AliITSLoader(GetName(),topfoldername);
1770 return fLoader;
1771}
1772
1773
1774//_____________________________________________________________________________
1775void AliITS::Reconstruct() const
1776{
1777// reconstruct clusters
1778
1779 AliLoader* loader = GetLoader();
1780 loader->LoadRecPoints("recreate");
1781 loader->LoadDigits("read");
1782
1783 AliITSclustererV2 clusterer(GetITSgeom());
1784 AliRunLoader* runLoader = loader->GetRunLoader();
1785 Int_t nEvents = runLoader->GetNumberOfEvents();
1786
1787 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1788 runLoader->GetEvent(iEvent);
1789
1790 TTree* treeClusters = loader->TreeR();
1791 if (!treeClusters) {
1792 loader->MakeTree("R");
1793 treeClusters = loader->TreeR();
1794 }
1795 TTree* treeDigits = loader->TreeD();
1796 if (!treeDigits) {
1797 Error("Reconstruct", "Can't get digits tree !");
1798 return;
1799 }
1800
1801 clusterer.Digits2Clusters(treeDigits, treeClusters);
1802
1803 loader->WriteRecPoints("OVERWRITE");
1804 }
1805
1806 loader->UnloadRecPoints();
1807 loader->UnloadDigits();
1808}
1809
1810//_____________________________________________________________________________
1811AliTracker* AliITS::CreateTracker() const
1812{
1813// create an ITS tracker
1814
1815 return new AliITStrackerV2(GetITSgeom());
1816}
1817
1818//_____________________________________________________________________________
1819void AliITS::FillESD(AliESD* esd) const
1820{
1821// make PID, find V0s and cascades
1822
1823 Double_t parITS[] = {34., 0.15, 10.};
1824 AliITSpidESD itsPID(parITS);
1825 itsPID.MakePID(esd);
1826
1827 // V0 finding
1828 Double_t cuts[]={33, // max. allowed chi2
1829 0.16,// min. allowed negative daughter's impact parameter
1830 0.05,// min. allowed positive daughter's impact parameter
1831 0.080,// max. allowed DCA between the daughter tracks
1832 0.998,// max. allowed cosine of V0's pointing angle
1833 0.9, // min. radius of the fiducial volume
1834 2.9 // max. radius of the fiducial volume
1835 };
1836 AliV0vertexer vtxer(cuts);
1837 Double_t vtx[3], cvtx[6];
1838 esd->GetVertex(vtx, cvtx);
1839 vtxer.SetVertex(vtx);
1840 vtxer.Tracks2V0vertices(esd);
1841
1842 // cascade finding
1843 Double_t cts[]={33., // max. allowed chi2
1844 0.05, // min. allowed V0 impact parameter
1845 0.008, // window around the Lambda mass
1846 0.035, // min. allowed bachelor's impact parameter
1847 0.10, // max. allowed DCA between a V0 and a track
1848 0.9985, //max. allowed cosine of the cascade pointing angle
1849 0.9, // min. radius of the fiducial volume
1850 2.9 // max. radius of the fiducial volume
1851 };
1852 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
1853 cvtxer.V0sTracks2CascadeVertices(esd);
1854}
1855