1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.75 2002/10/22 14:45:25 alibrary
19 Introducing Riostream.h
21 Revision 1.74 2002/10/14 14:57:00 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.67.4.3 2002/10/14 13:14:07 hristov
25 Updating VirtualMC to v3-09-02
27 Revision 1.73 2002/09/09 17:14:25 nilsen
28 Update of documentation to reflect changes in AliITSdigitS?D classes.
30 Revision 1.72 2002/06/10 17:28:55 nilsen
31 Added new FillModules routine and cleaned up the old one.
33 Revision 1.71 2002/05/13 14:27:56 hristov
34 TreeC created once per event (M.Masera)
36 Revision 1.70 2002/05/10 22:28:30 nilsen
37 Changes by Massimo Masera to allow the TTree of clusters to be written to a
38 file otherthan the one with digits in it.
40 Revision 1.69 2002/05/05 21:06:55 nilsen
41 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
42 proper initilization when a simulation has already been defined.
44 Revision 1.68 2002/05/02 18:51:53 nilsen
46 Method MakeBranchR has now a second argument, with a default value:
47 Option_t *opt=" ". Opt="Fast" is to create a separate branch
48 for fast points in TreeR
49 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
52 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
54 2) Changes in MakeBranchR to allow the creation of a special branch
57 Revision 1.67 2002/03/15 17:22:51 nilsen
58 Intoduced SDigits2Digits and SDigitsToDigits functions.
60 Revision 1.66 2001/11/28 01:35:45 nilsen
61 Using standard constructors instead of default constructors for Clusterfinder,
62 Response, and FastSimulator.
64 Revision 1.65 2001/11/27 16:27:28 nilsen
65 Adding AliITSDigitizer class to do merging and digitization . Based on the
66 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
67 file. The following files required minor changes. AliITS, added functions
68 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
69 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
70 the original Root Directory in function Compress1D. Now it uses gDirectory.
72 Revision 1.64 2001/11/19 16:17:02 nilsen
73 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
74 bugs found by Rene require more work to fix. Will be fixed soon.
76 Revision 1.63 2001/10/24 21:16:34 nilsen
77 Removed some dead code and improved comments/documntation.
79 Revision 1.62 2001/10/21 19:23:21 nilsen
80 Added function to allow to limit which detectors to digitize and reconstruct.
81 The default is All. This change makes no changes to any root file.
83 Revision 1.61 2001/10/11 15:26:07 mariana
84 Correct HitsToFastRecPoints
86 Revision 1.60 2001/10/04 22:38:10 nilsen
87 Changes made to support PreDigits (SDigits) plus other helpful changes.
89 Revision 1.59 2001/08/30 09:56:18 hristov
90 The operator[] is replaced by At() or AddAt() in case of TObjArray.
92 Revision 1.58 2001/07/26 15:05:29 hristov
93 Use global gRandom generator (M.Ivanov)
95 Revision 1.57 2001/07/24 14:26:11 mariana
96 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
98 Revision 1.56 2001/07/05 12:49:49 mariana
99 Temporary patches required by root.v3.01.05
101 Revision 1.55 2001/06/14 14:59:00 barbera
102 Tracking V1 decoupled from AliITS
104 Revision 1.54 2001/05/31 20:37:56 barbera
105 Bari/Salerno model set as defaault SPD simulation
107 Revision 1.53 2001/05/31 18:52:24 barbera
108 Bari model becomes the default
110 Revision 1.53 2001/05/30 07:52:24 hristov
111 TPC and CONTAINERS included in the search path
113 Revision 1.52 2001/05/30 06:04:58 hristov
114 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
116 Revision 1.51 2001/05/16 14:57:15 alibrary
117 New files for folders and Stack
119 Revision 1.50 2001/05/11 09:15:21 barbera
120 Corrected to make fast point creation working with PPR geometry
122 Revision 1.49 2001/05/11 07:37:49 hristov
123 Legacy lines commented
125 Revision 1.48 2001/05/10 18:14:25 barbera
128 Revision 1.47 2001/05/10 17:55:59 barbera
129 Modified to create rec points also for PPR geometries
131 Revision 1.46 2001/05/10 00:05:28 nilsen
132 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
133 should probably be cleaned up to only check to make sure that fITSgeom has
134 been properly defined.
136 Revision 1.45 2001/05/01 22:35:48 nilsen
137 Remove/commented a number of cout<< statements. and made change needed by
140 Revision 1.44 2001/04/26 22:44:01 nilsen
141 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
142 done properly in AliITSv???.cxx via SetDefaults.
144 Revision 1.43 2001/04/26 13:22:52 barbera
145 TMatrix and TVector elimininated to speed up the code
147 Revision 1.42 2001/04/25 21:55:12 barbera
148 Updated version to be compatible with actual verion of STEER and TPC
150 Revision 1.41 2001/04/21 15:16:51 barbera
151 Updated with the new SSD reconstruction code
153 Revision 1.40 2001/03/17 15:07:06 mariana
154 Update SDD response parameters
156 Revision 1.39 2001/03/12 17:45:32 hristov
157 Changes needed on Sun with CC 5.0
159 Revision 1.38 2001/03/07 14:04:51 barbera
160 Some vector dimensions increased to cope with full events
162 Revision 1.37 2001/03/07 12:36:35 barbera
163 A change added in the tracking part to manage delta rays
165 Revision 1.36 2001/03/02 19:44:11 barbera
166 modified to taking into account new version tracking v1
168 Revision 1.35 2001/02/28 18:16:46 mariana
169 Make the code compatible with the new AliRun
171 Revision 1.34 2001/02/11 15:51:39 mariana
172 Set protection in MakeBranch
174 Revision 1.33 2001/02/10 22:26:39 mariana
175 Move the initialization of the containers for raw clusters in MakeTreeC()
177 Revision 1.32 2001/02/08 23:55:31 nilsen
178 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
179 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
181 Revision 1.31 2001/02/02 23:57:28 nilsen
182 Added include file that are no londer included in AliITSgeom.h
184 Revision 1.30 2001/01/30 09:23:13 hristov
185 Streamers removed (R.Brun)
187 Revision 1.29 2001/01/26 20:01:09 hristov
188 Major upgrade of AliRoot code
190 Revision 1.28 2000/12/18 14:02:00 barbera
191 new version of the ITS tracking to take into account the new TPC track parametrization
193 Revision 1.27 2000/12/08 13:49:27 barbera
194 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
196 Revision 1.26 2000/11/27 13:12:13 barbera
197 New version containing the files for tracking
199 Revision 1.25 2000/11/12 22:38:05 barbera
200 Added header file for the SPD Bari model
202 Revision 1.24 2000/10/09 22:18:12 barbera
203 Bug fixes from MAriana to le AliITStest.C run correctly
205 Revision 1.23 2000/10/05 20:47:42 nilsen
206 fixed dependencies of include files. Tryed but failed to get a root automaticly
207 generates streamer function to work. Modified SetDefaults.
209 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
210 Needed to include stdlib.h
213 Revision 1.22 2000/10/04 19:45:52 barbera
214 Corrected by F. Carminati for v3.04
216 Revision 1.21 2000/10/02 21:28:08 fca
217 Removal of useless dependecies via forward declarations
219 Revision 1.20 2000/10/02 16:31:39 barbera
220 General code clean-up
222 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
223 General code clean-up (e.g., printf -> cout)
225 Revision 1.19 2000/09/22 12:13:25 nilsen
226 Patches and updates for fixes to this and other routines.
228 Revision 1.18 2000/07/12 05:32:20 fca
229 Correcting several syntax problem with static members
231 Revision 1.17 2000/07/10 16:07:18 fca
232 Release version of ITS code
234 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
235 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
237 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
238 //fixed FillModule. Removed fi(fabs(xl)<dx....
240 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
241 This is the version of the files after the merging done in December 1999.
242 See the ReadMe110100.txt file for details
244 Revision 1.9 1999/11/14 14:33:25 fca
245 Correct problems with distructors and pointers, thanks to I.Hrivnacova
247 Revision 1.8 1999/09/29 09:24:19 fca
248 Introduction of the Copyright and cvs Log
252 ///////////////////////////////////////////////////////////////////////////////
254 // An overview of the basic philosophy of the ITS code development
255 // and analysis is show in the figure below.
258 <img src="picts/ITS/ITS_Analysis_schema.gif">
261 <font size=+2 color=red>
262 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
263 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
269 // AliITS. Inner Traking System base class.
270 // This class contains the base procedures for the Inner Tracking System
274 <img src="picts/ITS/AliITS_Class_Diagram.gif">
277 <font size=+2 color=red>
278 <p>This show the class diagram of the different elements that are part of
286 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
289 // Modified and documented by Bjorn S. Nilsen
293 // Modified and documented by A. Bologna
296 // AliITS is the general base class for the ITS. Also see AliDetector for
297 // futher information.
299 ///////////////////////////////////////////////////////////////////////////////
300 #include <Riostream.h>
306 #include <TClonesArray.h>
308 #include <TObjectTable.h>
313 #include "AliHeader.h"
316 #include "AliITSDetType.h"
317 #include "AliITSresponseSPD.h"
318 #include "AliITSresponseSDD.h"
319 #include "AliITSresponseSSD.h"
320 #include "AliITSsegmentationSPD.h"
321 #include "AliITSsegmentationSDD.h"
322 #include "AliITSsegmentationSSD.h"
323 #include "AliITSsimulationSPD.h"
324 #include "AliITSsimulationSDD.h"
325 #include "AliITSsimulationSSD.h"
326 #include "AliITSClusterFinderSPD.h"
327 #include "AliITSClusterFinderSDD.h"
328 #include "AliITSClusterFinderSSD.h"
329 #include "AliITShit.h"
330 #include "AliITSgeom.h"
331 #include "AliITSpList.h"
332 #include "AliITSdigit.h"
333 #include "AliITSmodule.h"
334 #include "AliITSRecPoint.h"
335 #include "AliITSRawCluster.h"
339 //______________________________________________________________________
340 AliITS::AliITS() : AliDetector() {
341 // Default initializer for ITS
342 // The default constructor of the AliITS class. In addition to
343 // creating the AliITS class it zeros the variables fIshunt (a member
344 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
345 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
354 fIshunt = 0; // not zeroed in AliDetector.
361 // SetDetectors(); // default to fOpt="All". This variable not written out.
367 fNDetTypes = kNTYPES;
383 SetMarkerColor(kRed);
385 //______________________________________________________________________
386 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
387 // The standard Constructor for the ITS class. In addition to
388 // creating the AliITS class, it allocates memory for the TClonesArrays
389 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
390 // (clusters). It also zeros the variables
391 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
392 // the pointers fIdSens and fIdName. To help in displaying hits via the
393 // ROOT macro display.C AliITS also sets the marker color to red. The
394 // variables passes with this constructor, const char *name and *title,
395 // are used by the constructor of AliDetector class. See AliDetector
396 // class for a description of these parameters and its constructor
399 // const char *name Detector name. Should always be "ITS"
400 // const char *title Detector title.
406 fIshunt = 0; // not zeroed in AliDetector
407 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
408 gAlice->AddHitList(fHits); // Not done in AliDetector.
413 SetDetectors(); // default to fOpt="All". This variable not written out.
419 fNDetTypes = kNTYPES;
420 fDetTypes = new TObjArray(fNDetTypes);
422 fSDigits = new TClonesArray("AliITSpListItem",1000);
425 fNdtype = new Int_t[fNDetTypes];
426 fDtype = new TObjArray(fNDetTypes);
428 fCtype = new TObjArray(fNDetTypes);
429 fNctype = new Int_t[fNDetTypes];
432 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
436 for(i=0;i<fNDetTypes;i++) {
437 fDetTypes->AddAt(new AliITSDetType(),i);
442 SetMarkerColor(kRed);
444 //______________________________________________________________________
446 // Default destructor for ITS.
447 // The default destructor of the AliITS class. In addition to deleting
448 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
449 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
450 // fITSpoints, fDetType and it's contents.
458 delete fHits; fHits=0;
459 delete fSDigits; fSDigits=0;
460 // delete fDigits; fDigits=0;
461 delete fRecPoints; fRecPoints=0;
462 if(fIdName!=0) delete[] fIdName; // Array of TStrings
463 if(fIdSens!=0) delete[] fIdSens;
465 this->ClearModules();
467 }// end if fITSmodules!=0
483 } // end if fDetTypes
485 if (fTreeC) delete fTreeC;
487 if (fITSgeom) delete fITSgeom;
489 //______________________________________________________________________
490 AliITS::AliITS(AliITS &source){
491 // Copy constructor. This is a function which is not allowed to be
492 // done to the ITS. It exits with an error.
494 // AliITS &source An AliITS class.
500 if(this==&source) return;
501 Error("Copy constructor",
502 "You are not allowed to make a copy of the AliITS");
505 //______________________________________________________________________
506 AliITS& AliITS::operator=(AliITS &source){
507 // Assignment operator. This is a function which is not allowed to be
508 // done to the ITS. It exits with an error.
510 // AliITS &source An AliITS class.
516 if(this==&source) return *this;
517 Error("operator=","You are not allowed to make a copy of the AliITS");
519 return *this; //fake return
521 //______________________________________________________________________
522 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
523 // Distance from mouse to ITS on the screen. Dummy routine
524 // A dummy routine used by the ROOT macro display.C to allow for the
525 // use of the mouse (pointing device) in the macro. In general this should
526 // never be called. If it is it returns the number 9999 for any value of
529 // Int_t Dummy screen coordinate.
530 // Int_t Dummy screen coordinate.
534 // Int_t Dummy = 9999 distance to ITS.
538 //______________________________________________________________________
540 // Initializer ITS after it has been built
541 // This routine initializes the AliITS class. It is intended to be
542 // called from the Init function in AliITSv?. Besides displaying a banner
543 // indicating that it has been called it initializes the array fIdSens
544 // and sets the default segmentation, response, digit and raw cluster
545 // classes therefore it should be called after a call to CreateGeometry.
556 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
558 //______________________________________________________________________
559 void AliITS::SetDefaults(){
560 // sets the default segmentation, response, digit and raw cluster classes.
568 if(fDebug) printf("%s: SetDefaults\n",ClassName());
570 AliITSDetType *iDetType;
574 if (!iDetType->GetSegmentationModel()) {
575 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
576 SetSegmentationModel(0,seg0);
578 if (!iDetType->GetResponseModel()) {
579 SetResponseModel(0,new AliITSresponseSPD());
581 // set digit and raw cluster classes to be used
583 const char *kData0=(iDetType->GetResponseModel())->DataType();
584 if (strstr(kData0,"real")) {
585 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
586 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
590 if (!iDetType->GetResponseModel()) {
591 SetResponseModel(1,new AliITSresponseSDD("simulated"));
593 AliITSresponse *resp1=iDetType->GetResponseModel();
594 if (!iDetType->GetSegmentationModel()) {
595 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
596 SetSegmentationModel(1,seg1);
598 const char *kData1=(iDetType->GetResponseModel())->DataType();
599 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
600 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
601 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
602 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
606 if (!iDetType->GetSegmentationModel()) {
607 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
608 SetSegmentationModel(2,seg2);
610 if (!iDetType->GetResponseModel()) {
611 SetResponseModel(2,new AliITSresponseSSD("simulated"));
613 const char *kData2=(iDetType->GetResponseModel())->DataType();
614 if (strstr(kData2,"real")) {
615 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
616 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
619 Warning("SetDefaults",
620 "Only the three basic detector types are initialized!");
623 //______________________________________________________________________
624 void AliITS::SetDefaultSimulation(){
625 // sets the default simulation.
633 AliITSDetType *iDetType;
634 AliITSsimulation *sim;
636 sim = iDetType->GetSimulationModel();
638 AliITSsegmentation *seg0=
639 (AliITSsegmentation*)iDetType->GetSegmentationModel();
640 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
641 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
642 SetSimulationModel(0,sim0);
643 }else{ // simulation exists, make sure it is set up properly.
644 ((AliITSsimulationSPD*)sim)->Init(
645 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
646 (AliITSresponseSPD*) iDetType->GetResponseModel());
647 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
648 // (AliITSresponse*)iDetType->GetResponseModel());
649 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
650 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
653 sim = iDetType->GetSimulationModel();
655 AliITSsegmentation *seg1=
656 (AliITSsegmentation*)iDetType->GetSegmentationModel();
657 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
658 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
659 SetSimulationModel(1,sim1);
660 }else{ // simulation exists, make sure it is set up properly.
661 ((AliITSsimulationSDD*)sim)->Init(
662 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
663 (AliITSresponseSDD*) iDetType->GetResponseModel());
664 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
665 // (AliITSresponse*)iDetType->GetResponseModel());
666 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
667 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
670 sim = iDetType->GetSimulationModel();
672 AliITSsegmentation *seg2=
673 (AliITSsegmentation*)iDetType->GetSegmentationModel();
674 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
675 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
676 SetSimulationModel(2,sim2);
677 }else{ // simulation exists, make sure it is set up properly.
678 ((AliITSsimulationSSD*)sim)->Init(
679 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
680 (AliITSresponseSSD*) iDetType->GetResponseModel());
681 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
682 // (AliITSresponse*)iDetType->GetResponseModel());
683 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
684 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
687 //______________________________________________________________________
688 void AliITS::SetDefaultClusterFinders(){
689 // Sets the default cluster finders. Used in finding RecPoints.
698 AliITSDetType *iDetType;
702 if (!iDetType->GetReconstructionModel()) {
703 AliITSsegmentation *seg0 =
704 (AliITSsegmentation*)iDetType->GetSegmentationModel();
705 TClonesArray *dig0=DigitsAddress(0);
706 TClonesArray *recp0=ClustersAddress(0);
707 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
709 SetReconstructionModel(0,rec0);
714 if (!iDetType->GetReconstructionModel()) {
715 AliITSsegmentation *seg1 =
716 (AliITSsegmentation*)iDetType->GetSegmentationModel();
717 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
718 TClonesArray *dig1=DigitsAddress(1);
719 TClonesArray *recp1=ClustersAddress(1);
720 AliITSClusterFinderSDD *rec1 =
721 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
722 SetReconstructionModel(1,rec1);
727 if (!iDetType->GetReconstructionModel()) {
728 AliITSsegmentation *seg2=
729 (AliITSsegmentation*)iDetType->GetSegmentationModel();
730 TClonesArray *dig2=DigitsAddress(2);
731 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
732 SetReconstructionModel(2,rec2);
735 //______________________________________________________________________
736 void AliITS::MakeBranch(Option_t* option, const char *file){
737 // Creates Tree branches for the ITS.
739 // Option_t *option String of Tree types S,D, and/or R.
740 // const char *file String of the file name where these branches
741 // are to be stored. If blank then these branches
742 // are written to the same tree as the Hits were
748 Bool_t cS = (strstr(option,"S")!=0);
749 Bool_t cD = (strstr(option,"D")!=0);
750 Bool_t cR = (strstr(option,"R")!=0);
751 Bool_t cRF = (strstr(option,"RF")!=0);
754 AliDetector::MakeBranch(option,file);
756 if(cS) MakeBranchS(file);
757 if(cD) MakeBranchD(file);
758 if(cR) MakeBranchR(file);
759 if(cRF) MakeBranchRF(file);
761 //______________________________________________________________________
762 void AliITS::SetTreeAddress(){
763 // Set branch address for the Trees.
770 TTree *treeS = gAlice->TreeS();
771 TTree *treeD = gAlice->TreeD();
772 TTree *treeR = gAlice->TreeR();
774 AliDetector::SetTreeAddress();
776 SetTreeAddressS(treeS);
777 SetTreeAddressD(treeD);
778 SetTreeAddressR(treeR);
780 //______________________________________________________________________
781 AliITSDetType* AliITS::DetType(Int_t id){
782 // Return pointer to id detector type.
784 // Int_t id detector id number.
788 // returned, a pointer to a AliITSDetType.
790 return ((AliITSDetType*) fDetTypes->At(id));
792 //______________________________________________________________________
793 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
794 // Set the response model for the id detector type.
796 // Int_t id detector id number.
797 // AliITSresponse* a pointer containing an instance of AliITSresponse
798 // to be stored/owned b y AliITSDetType.
804 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
806 //______________________________________________________________________
807 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
808 // Set the segmentation model for the id detector type.
810 // Int_t id detector id number.
811 // AliITSsegmentation* a pointer containing an instance of
812 // AliITSsegmentation to be stored/owned b y
819 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
821 //______________________________________________________________________
822 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
823 // Set the simulation model for the id detector type.
825 // Int_t id detector id number.
826 // AliITSresponse* a pointer containing an instance of AliITSresponse
827 // to be stored/owned b y AliITSDetType.
833 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
836 //______________________________________________________________________
837 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
838 // Set the cluster finder model for the id detector type.
840 // Int_t id detector id number.
841 // AliITSClusterFinder* a pointer containing an instance of
842 // AliITSClusterFinder to be stored/owned b y
849 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
851 //______________________________________________________________________
852 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
853 // Set the digit and cluster classes name to be used for the id detector
856 // Int_t id detector id number.
857 // const char *digit Digit class name for detector id.
858 // const char *cluster Cluster class name for detector id.
864 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
866 //______________________________________________________________________
867 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
869 // The function to add information to the AliITShit class. See the
870 // AliITShit class for a full description. This function allocates the
871 // necessary new space for the hit information and passes the variable
872 // track, and the pointers *vol and *hits to the AliITShit constructor
875 // Int_t track Track number which produced this hit.
876 // Int_t *vol Array of Integer Hit information. See AliITShit.h
877 // Float_t *hits Array of Floating Hit information. see AliITShit.h
883 TClonesArray &lhits = *fHits;
884 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
886 //______________________________________________________________________
887 void AliITS::InitModules(Int_t size,Int_t &nmodules){
888 // Initialize the modules array.
890 // Int_t size Size of array of the number of modules to be
891 // created. If size <=0 then the number of modules
892 // is gotten from AliITSgeom class kept in fITSgeom.
894 // Int_t &nmodules The number of modules existing.
899 fITSmodules->Delete();
901 } // end fir fITSmoudles
903 Int_t nl,indexMAX,index;
905 if(size<=0){ // default to using data stored in AliITSgeom
907 Error("InitModules","fITSgeom not defined");
909 } // end if fITSgeom==0
910 nl = fITSgeom->GetNlayers();
911 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
912 fITSgeom->GetNdetectors(nl))+1;
914 fITSmodules = new TObjArray(indexMAX);
915 for(index=0;index<indexMAX;index++){
916 fITSmodules->AddAt( new AliITSmodule(index),index);
919 fITSmodules = new TObjArray(size);
920 for(index=0;index<size;index++) {
921 fITSmodules->AddAt( new AliITSmodule(index),index);
927 //______________________________________________________________________
928 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
929 Option_t *option,Text_t *filename){
930 // fill the modules with the sorted by module hits; add hits from
931 // background if option=Add.
933 // Int_t evnt Event to be processed.
934 // Int_t bgrev Background Hit tree number.
935 // Int_t nmodules Not used.
936 // Option_t *option String indicating if merging hits or not. To
937 // merge hits set equal to "Add". Otherwise no
938 // background hits are considered.
939 // Test_t *filename File name containing the background hits..
944 static TTree *trH1; //Tree with background hits
945 // static TClonesArray *fHits2; //List of hits for one track only
946 static Bool_t first=kTRUE;
948 const char *addBgr = strstr(option,"Add");
952 file=new TFile(filename);
953 // fHits2 = new TClonesArray("AliITShit",1000 );
958 // Get Hits Tree header from file
959 // if(fHits2) fHits2->Clear();
960 if(trH1) delete trH1;
964 sprintf(treeName,"TreeH%d",bgrev);
965 trH1 = (TTree*)gDirectory->Get(treeName);
967 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
969 // Set branch addresses
973 sprintf(branchname,"%s",GetName());
974 if (trH1 && fHits2) {
975 branch = trH1->GetBranch(branchname);
976 if (branch) branch->SetAddress(&fHits2);
977 } // end if trH1 && fHits
981 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
983 TClonesArray *itsHits = this->Hits();
984 Int_t lay,lad,det,index;
987 TTree *iTH = gAlice->TreeH();
988 Int_t ntracks =(Int_t) iTH->GetEntries();
990 for(t=0; t<ntracks; t++){
993 Int_t nhits = itsHits->GetEntriesFast();
994 if (!nhits) continue;
995 for(h=0; h<nhits; h++){
996 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
997 itsHit->GetDetectorID(lay,lad,det);
998 // temporarily index=det-1 !!!
999 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1002 mod = this->GetModule(index);
1003 mod->AddHit(itsHit,t,h);
1004 } // end loop over hits
1005 } // end loop over tracks
1007 // open the file with background
1010 FillModules(trH1,10000000); // Default mask 10M.
1013 ntracks =(Int_t)trH1->GetEntries();
1015 for (track=0; track<ntracks; track++) {
1016 if (fHits2) fHits2->Clear();
1017 trH1->GetEvent(track);
1019 for(i=0;i<fHits2->GetEntriesFast();++i) {
1020 itsHit=(AliITShit*) (*fHits2)[i];
1021 itsHit->GetDetectorID(lay,lad,det);
1022 // temporarily index=det-1 !!!
1023 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1026 mod = this->GetModule(index);
1027 mod->AddHit(itsHit,track,i);
1028 } // end loop over hits
1029 } // end loop over tracks
1031 TTree *fAli=gAlice->TreeK();
1033 if (fAli) fileAli =fAli->GetCurrentFile();
1037 //______________________________________________________________________
1038 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1039 // fill the modules with the sorted by module hits;
1040 // can be called many times to do a merging
1042 // TTree *treeH The tree containing the hits to be copied into
1044 // Int_t mask The track number mask to indecate which file
1045 // this hits came from.
1051 Int_t lay,lad,det,index;
1052 AliITShit *itsHit=0;
1053 AliITSmodule *mod=0;
1054 char branchname[20];
1055 sprintf(branchname,"%s",GetName());
1056 TBranch *branch = treeH->GetBranch(branchname);
1058 Error("FillModules","%s branch in TreeH not found",branchname);
1061 branch->SetAddress(&fHits);
1062 Int_t nTracks =(Int_t) treeH->GetEntries();
1064 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1066 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1067 if (nBytes <= 0) continue;
1068 Int_t nHits = fHits->GetEntriesFast();
1069 for(h=0; h<nHits; h++){
1070 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1071 itsHit->GetDetectorID(lay,lad,det);
1073 index = fITSgeom->GetModuleIndex(lay,lad,det);
1075 index=det-1; // This should not be used.
1076 } // end if [You must have fITSgeom for this to work!]
1077 mod = GetModule(index);
1078 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1079 mod->AddHit(itsHit,iPrimTrack,h);
1080 } // end loop over hits
1081 } // end loop over tracks
1083 //______________________________________________________________________
1084 void AliITS::ClearModules(){
1085 // Clear the modules TObjArray.
1091 if(fITSmodules) fITSmodules->Delete();
1093 //______________________________________________________________________
1094 void AliITS::MakeBranchS(const char *fl){
1095 // Creates Tree Branch for the ITS summable digits.
1097 // cont char *fl File name where SDigits branch is to be written
1098 // to. If blank it write the SDigits to the same
1099 // file in which the Hits were found.
1104 Int_t buffersize = 4000;
1105 char branchname[30];
1107 // only one branch for SDigits.
1108 sprintf(branchname,"%s",GetName());
1109 if(fSDigits && gAlice->TreeS()){
1110 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1113 //______________________________________________________________________
1114 void AliITS::SetTreeAddressS(TTree *treeS){
1115 // Set branch address for the ITS summable digits Trees.
1117 // TTree *treeS Tree containing the SDigits.
1122 char branchname[30];
1126 sprintf(branchname,"%s",GetName());
1127 branch = treeS->GetBranch(branchname);
1128 if (branch) branch->SetAddress(&fSDigits);
1130 //______________________________________________________________________
1131 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1132 // Creates Tree branches for the ITS.
1134 // TTree *treeD Pointer to the Digits Tree.
1135 // cont char *file File name where Digits branch is to be written
1136 // to. If blank it write the SDigits to the same
1137 // file in which the Hits were found.
1142 Int_t buffersize = 4000;
1143 char branchname[30];
1145 sprintf(branchname,"%s",GetName());
1146 // one branch for digits per type of detector
1147 const char *det[3] = {"SPD","SDD","SSD"};
1151 for (i=0; i<kNTYPES ;i++) {
1152 DetType(i)->GetClassNames(digclass,clclass);
1154 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1155 else ResetDigits(i);
1157 for (i=0; i<kNTYPES ;i++) {
1158 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1159 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1160 if (fDtype && treeD) {
1161 MakeBranchInTree(treeD,
1162 branchname, &((*fDtype)[i]),buffersize,file);
1166 //______________________________________________________________________
1167 void AliITS::SetTreeAddressD(TTree *treeD){
1168 // Set branch address for the Trees.
1170 // TTree *treeD Tree containing the Digits.
1175 char branchname[30];
1176 const char *det[3] = {"SPD","SDD","SSD"};
1183 for (i=0; i<kNTYPES; i++) {
1184 DetType(i)->GetClassNames(digclass,clclass);
1186 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1187 else ResetDigits(i);
1188 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1189 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1191 branch = treeD->GetBranch(branchname);
1192 if (branch) branch->SetAddress(&((*fDtype)[i]));
1196 //______________________________________________________________________
1197 void AliITS::Hits2SDigits(){
1198 // Standard Hits to summable Digits function.
1204 // return; // Using Hits in place of the larger sDigits.
1205 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1206 // Do the Hits to Digits operation. Use Standard input values.
1207 // Event number from file, no background hit merging , use size from
1208 // AliITSgeom class, option="All", input from this file only.
1209 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1211 //______________________________________________________________________
1212 void AliITS::Hits2PreDigits(){
1213 // Standard Hits to summable Digits function.
1219 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1220 // Do the Hits to Digits operation. Use Standard input values.
1221 // Event number from file, no background hit merging , use size from
1222 // AliITSgeom class, option="All", input from this file only.
1223 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1225 //______________________________________________________________________
1226 void AliITS::SDigitsToDigits(Option_t *opt){
1227 // Standard Summable digits to Digits function.
1232 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1234 if(!GetITSgeom()) return; // need transformations to do digitization.
1235 AliITSgeom *geom = GetITSgeom();
1237 const char *all = strstr(opt,"All");
1238 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1240 if( !det[0] && !det[1] && !det[2] ) all = "All";
1242 static Bool_t setDef=kTRUE;
1243 if (setDef) SetDefaultSimulation();
1246 AliITSsimulation *sim = 0;
1247 AliITSDetType *iDetType = 0;
1248 TTree *trees = gAlice->TreeS();
1249 if( !(trees && this->GetSDigits()) ){
1250 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1253 sprintf( name, "%s", this->GetName() );
1254 TBranch *brchSDigits = trees->GetBranch( name );
1257 for(module=0;module<geom->GetIndexMax();module++){
1258 id = geom->GetModuleType(module);
1259 if (!all && !det[id]) continue;
1260 iDetType = DetType(id);
1261 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1263 Error("SDigit2Digits",
1264 "The simulation class was not instanciated!");
1267 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1269 // add summable digits to module
1270 this->GetSDigits()->Clear();
1271 brchSDigits->GetEvent(module);
1272 sim->AddSDigitsToModule(GetSDigits(),0);
1274 // Digitise current module sum(SDigits)->Digits
1275 sim->FinishSDigitiseModule();
1277 // fills all branches - wasted disk space
1278 gAlice->TreeD()->Fill();
1279 this->ResetDigits();
1282 gAlice->TreeD()->GetEntries();
1284 gAlice->TreeD()->AutoSave();
1286 gAlice->TreeD()->Reset();
1289 //______________________________________________________________________
1290 void AliITS::Hits2Digits(){
1291 // Standard Hits to Digits function.
1297 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1298 // Do the Hits to Digits operation. Use Standard input values.
1299 // Event number from file, no background hit merging , use size from
1300 // AliITSgeom class, option="All", input from this file only.
1301 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1303 //______________________________________________________________________
1304 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1305 Option_t *option, Option_t *opt,Text_t *filename){
1306 // keep galice.root for signal and name differently the file for
1307 // background when add! otherwise the track info for signal will be lost !
1308 // the condition below will disappear when the geom class will be
1309 // initialized for all versions - for the moment it is only for v5 !
1310 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1313 // Int_t evnt Event to be processed.
1314 // Int_t bgrev Background Hit tree number.
1315 // Int_t nmodules Not used.
1316 // Option_t *option String indicating if merging hits or not. To
1317 // merge hits set equal to "Add". Otherwise no
1318 // background hits are considered.
1319 // Test_t *filename File name containing the background hits..
1324 // return; // using Hits instead of the larger sdigits.
1326 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1328 //______________________________________________________________________
1329 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1330 Option_t *option, Option_t *opt,Text_t *filename){
1331 // Keep galice.root for signal and name differently the file for
1332 // background when add! otherwise the track info for signal will be lost !
1333 // the condition below will disappear when the geom class will be
1334 // initialized for all versions - for the moment it is only for v5 !
1335 // 7 is the SDD beam test version.
1337 // Int_t evnt Event to be processed.
1338 // Int_t bgrev Background Hit tree number.
1339 // Int_t nmodules Not used.
1340 // Option_t *option String indicating if merging hits or not. To
1341 // merge hits set equal to "Add". Otherwise no
1342 // background hits are considered.
1343 // Test_t *filename File name containing the background hits..
1349 if(!GetITSgeom()) return; // need transformations to do digitization.
1350 AliITSgeom *geom = GetITSgeom();
1352 const char *all = strstr(opt,"All");
1353 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1355 static Bool_t setDef=kTRUE;
1356 if (setDef) SetDefaultSimulation();
1360 InitModules(size,nmodules);
1361 FillModules(evNumber,bgrev,nmodules,option,filename);
1363 AliITSsimulation *sim = 0;
1364 AliITSDetType *iDetType = 0;
1365 AliITSmodule *mod = 0;
1367 for(module=0;module<geom->GetIndexMax();module++){
1368 id = geom->GetModuleType(module);
1369 if (!all && !det[id]) continue;
1370 iDetType = DetType(id);
1371 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1373 Error("HitsToSDigits",
1374 "The simulation class was not instanciated!");
1377 mod = (AliITSmodule *)fITSmodules->At(module);
1378 sim->SDigitiseModule(mod,module,evNumber);
1379 // fills all branches - wasted disk space
1380 gAlice->TreeS()->Fill();
1386 gAlice->TreeS()->GetEntries();
1387 gAlice->TreeS()->AutoSave();
1389 gAlice->TreeS()->Reset();
1391 //______________________________________________________________________
1392 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1393 Option_t *option, Option_t *opt,Text_t *filename){
1394 // Keep galice.root for signal and name differently the file for
1395 // background when add! otherwise the track info for signal will be lost !
1396 // the condition below will disappear when the geom class will be
1397 // initialized for all versions - for the moment it is only for v5 !
1398 // 7 is the SDD beam test version.
1400 // Int_t evnt Event to be processed.
1401 // Int_t bgrev Background Hit tree number.
1402 // Int_t nmodules Not used.
1403 // Option_t *option String indicating if merging hits or not. To
1404 // merge hits set equal to "Add". Otherwise no
1405 // background hits are considered.
1406 // Test_t *filename File name containing the background hits..
1412 if(!GetITSgeom()) return; // need transformations to do digitization.
1413 AliITSgeom *geom = GetITSgeom();
1415 const char *all = strstr(opt,"All");
1416 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1418 static Bool_t setDef=kTRUE;
1419 if (setDef) SetDefaultSimulation();
1423 InitModules(size,nmodules);
1424 FillModules(evNumber,bgrev,nmodules,option,filename);
1426 AliITSsimulation *sim = 0;
1427 AliITSDetType *iDetType = 0;
1428 AliITSmodule *mod = 0;
1430 for(module=0;module<geom->GetIndexMax();module++){
1431 id = geom->GetModuleType(module);
1432 if (!all && !det[id]) continue;
1433 iDetType = DetType(id);
1434 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1436 Error("HitsToDigits",
1437 "The simulation class was not instanciated!");
1440 mod = (AliITSmodule *)fITSmodules->At(module);
1441 sim->DigitiseModule(mod,module,evNumber);
1442 // fills all branches - wasted disk space
1443 gAlice->TreeD()->Fill();
1449 gAlice->TreeD()->GetEntries();
1450 gAlice->TreeD()->AutoSave();
1452 gAlice->TreeD()->Reset();
1454 //______________________________________________________________________
1455 void AliITS::ResetSDigits(){
1456 // Reset the Summable Digits array.
1462 if (fSDigits) fSDigits->Clear();
1465 //______________________________________________________________________
1466 void AliITS::ResetDigits(){
1467 // Reset number of digits and the digits array for the ITS detector.
1473 if (!fDtype) return;
1476 for (i=0;i<kNTYPES;i++ ) {
1477 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1478 if (fNdtype) fNdtype[i]=0;
1481 //______________________________________________________________________
1482 void AliITS::ResetDigits(Int_t i){
1483 // Reset number of digits and the digits array for this branch.
1489 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1490 if (fNdtype) fNdtype[i]=0;
1492 //______________________________________________________________________
1493 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1494 // Adds the a module full of summable digits to the summable digits tree.
1496 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1502 TClonesArray &lsdig = *fSDigits;
1503 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1505 //______________________________________________________________________
1506 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1507 // Add a real digit - as coming from data.
1509 // Int_t id Detector type number.
1510 // Int_t *digits Integer array containing the digits info. See
1517 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1518 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1520 //______________________________________________________________________
1521 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1522 // Add a simulated digit.
1524 // Int_t id Detector type number.
1525 // AliITSdigit *d Digit to be added to the Digits Tree. See
1532 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1536 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1539 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1542 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1546 //______________________________________________________________________
1547 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1548 Int_t *hits,Float_t *charges){
1549 // Add a simulated digit to the list.
1551 // Int_t id Detector type number.
1552 // Float_t phys Physics indicator. See AliITSdigits.h
1553 // Int_t *digits Integer array containing the digits info. See
1555 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1556 // containing the track numbers that contributed to
1558 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1559 // containing the hit numbers, from AliITSmodule, that
1560 // contributed to this digit.
1561 // Float_t *charge Floating point array of the signals contributed
1562 // to this digit by each track.
1568 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1571 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1574 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1578 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1582 //______________________________________________________________________
1583 void AliITS::MakeTreeC(Option_t *option){
1584 // Create a separate tree to store the clusters.
1586 // Option_t *option string which must contain "C" otherwise
1587 // no Cluster Tree is created.
1592 TDirectory *cwd = gDirectory;
1593 TFile *fileRecPoints = gAlice->GetTreeRFile();
1594 if(fileRecPoints)fileRecPoints->cd();
1595 const char *optC = strstr(option,"C");
1597 Int_t cureve = gAlice->GetEvNumber();
1598 sprintf(hname,"TreeC%d",cureve);
1600 const char *curname = fTreeC->GetName();
1601 char *exists = strstr(hname,curname);
1607 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1610 Int_t buffersize = 4000;
1611 char branchname[30];
1612 const char *det[3] = {"SPD","SDD","SSD"};
1616 // one branch for Clusters per type of detector
1618 for (i=0; i<kNTYPES ;i++) {
1619 AliITSDetType *iDetType=DetType(i);
1620 iDetType->GetClassNames(digclass,clclass);
1622 if(!ClustersAddress(i)){
1623 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1625 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1626 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1627 if (fCtype && fTreeC) {
1628 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1629 } // end if fCtype && fTreeC
1633 //______________________________________________________________________
1634 void AliITS::GetTreeC(Int_t event){
1635 // Get the clusters tree for this event and set the branch address.
1637 // Int_t event Event number for the cluster tree.
1643 char branchname[30];
1644 const char *det[3] = {"SPD","SDD","SSD"};
1651 sprintf(treeName,"TreeC%d",event);
1652 TFile *fileRecPoints = gAlice->GetTreeRFile();
1654 fTreeC = (TTree*)gDirectory->Get(treeName);
1657 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1666 for (i=0; i<kNTYPES; i++) {
1667 AliITSDetType *iDetType=DetType(i);
1668 iDetType->GetClassNames(digclass,clclass);
1670 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1671 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1672 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1674 branch = fTreeC->GetBranch(branchname);
1675 if (branch) branch->SetAddress(&((*fCtype)[i]));
1679 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1682 //______________________________________________________________________
1683 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1684 // Add a cluster to the list.
1686 // Int_t id Detector type number.
1687 // AliITSRawCluster *c Cluster class to be added to the tree of
1694 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1698 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1701 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1704 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1708 //______________________________________________________________________
1709 void AliITS::ResetClusters(){
1710 // Reset number of clusters and the clusters array for ITS.
1717 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1719 //______________________________________________________________________
1720 void AliITS::ResetClusters(Int_t i){
1721 // Reset number of clusters and the clusters array for this branch.
1723 // Int_t i Detector type number.
1729 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1730 if (fNctype) fNctype[i]=0;
1732 //______________________________________________________________________
1733 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1734 // Creates Tree branches for the ITS Reconstructed points.
1736 // cont char *file File name where RecPoints branch is to be written
1737 // to. If blank it write the SDigits to the same
1738 // file in which the Hits were found.
1743 Int_t buffsz = 4000;
1744 char branchname[30];
1746 // only one branch for rec points for all detector types
1747 Bool_t oFast= (strstr(opt,"Fast")!=0);
1749 sprintf(branchname,"%sRecPointsF",GetName());
1751 sprintf(branchname,"%sRecPoints",GetName());
1753 if (fRecPoints && gAlice->TreeR()) {
1754 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1757 //______________________________________________________________________
1758 void AliITS::SetTreeAddressR(TTree *treeR){
1759 // Set branch address for the Reconstructed points Trees.
1761 // TTree *treeR Tree containing the RecPoints.
1766 char branchname[30];
1770 sprintf(branchname,"%sRecPoints",GetName());
1771 branch = treeR->GetBranch(branchname);
1773 branch->SetAddress(&fRecPoints);
1776 sprintf(branchname,"%sRecPointsF",GetName());
1777 branch = treeR->GetBranch(branchname);
1779 branch->SetAddress(&fRecPoints);
1783 //______________________________________________________________________
1784 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1785 // Add a reconstructed space point to the list
1787 // const AliITSRecPoint &r RecPoint class to be added to the tree
1788 // of reconstructed points TreeR.
1794 TClonesArray &lrecp = *fRecPoints;
1795 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1797 //______________________________________________________________________
1798 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1799 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1800 // keep galice.root for signal and name differently the file for
1801 // background when add! otherwise the track info for signal will be lost !
1802 // the condition below will disappear when the geom class will be
1803 // initialized for all versions - for the moment it is only for v5 !
1805 // Int_t evnt Event to be processed.
1806 // Int_t bgrev Background Hit tree number.
1807 // Int_t size Size used by InitModules. See InitModules.
1808 // Option_t *opt0 Option passed to FillModules. See FillModules.
1809 // Option_t *opt1 String indicating if merging hits or not. To
1810 // merge hits set equal to "Add". Otherwise no
1811 // background hits are considered.
1812 // Test_t *flnm File name containing the background hits..
1818 if(!GetITSgeom()) return;
1819 AliITSgeom *geom = GetITSgeom();
1821 const char *all = strstr(opt1,"All");
1822 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1823 strstr(opt1,"SSD")};
1825 InitModules(size,nmodules);
1826 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1828 AliITSsimulation *sim = 0;
1829 AliITSDetType *iDetType = 0;
1830 AliITSmodule *mod = 0;
1833 //m.b. : this change is nothing but a nice way to make sure
1835 for(module=0;module<geom->GetIndexMax();module++){
1836 id = geom->GetModuleType(module);
1837 if (!all && !det[id]) continue;
1838 iDetType = DetType(id);
1839 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1841 Error("HitsToFastPoints",
1842 "The simulation class was not instanciated!");
1845 mod = (AliITSmodule *)fITSmodules->At(module);
1846 sim->CreateFastRecPoints(mod,module,gRandom);
1847 // gAlice->TreeR()->Fill();
1848 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1855 gAlice->TreeR()->AutoSave();
1857 gAlice->TreeR()->Reset();
1859 //______________________________________________________________________
1860 void AliITS::Digits2Reco(){
1861 // Find clusters and reconstruct space points.
1867 AliHeader *header=gAlice->GetHeader();
1868 // to Digits to RecPoints for event in file, all digits in file, and
1869 // all ITS detectors.
1870 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1872 //______________________________________________________________________
1873 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1874 // cluster finding and reconstruction of space points
1875 // the condition below will disappear when the geom class will be
1876 // initialized for all versions - for the moment it is only for v5 !
1877 // 7 is the SDD beam test version
1879 // Int_t evNumber Event number to be processed.
1880 // Int_t lastentry Offset for module when not all of the modules
1882 // Option_t *opt String indicating which ITS sub-detectors should
1883 // be processed. If ="All" then all of the ITS
1884 // sub detectors are processed.
1890 if(!GetITSgeom()) return;
1891 AliITSgeom *geom = GetITSgeom();
1893 const char *all = strstr(opt,"All");
1894 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1896 static Bool_t setRec=kTRUE;
1897 if (setRec) SetDefaultClusterFinders();
1900 TTree *treeC=TreeC();
1901 AliITSClusterFinder *rec = 0;
1902 AliITSDetType *iDetType = 0;
1903 Int_t id,module,first=0;
1904 for(module=0;module<geom->GetIndexMax();module++){
1905 id = geom->GetModuleType(module);
1906 if (!all && !det[id]) continue;
1907 if(det[id]) first = geom->GetStartDet(id);
1908 iDetType = DetType(id);
1909 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1910 TClonesArray *itsDigits = this->DigitsAddress(id);
1912 Error("DigitsToRecPoints",
1913 "The reconstruction class was not instanciated!");
1916 this->ResetDigits();
1917 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1918 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1919 Int_t ndigits = itsDigits->GetEntriesFast();
1920 if (ndigits) rec->FindRawClusters(module);
1921 gAlice->TreeR()->Fill();
1927 gAlice->TreeR()->GetEntries();
1928 treeC->GetEntries();
1929 gAlice->TreeR()->AutoSave();
1931 gAlice->TreeR()->Reset();
1936 //______________________________________________________________________
1937 void AliITS::ResetRecPoints(){
1938 // Reset number of rec points and the rec points array.
1944 if (fRecPoints) fRecPoints->Clear();