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.67.4.3 2002/10/14 13:14:07 hristov
19 Updating VirtualMC to v3-09-02
21 Revision 1.73 2002/09/09 17:14:25 nilsen
22 Update of documentation to reflect changes in AliITSdigitS?D classes.
24 Revision 1.72 2002/06/10 17:28:55 nilsen
25 Added new FillModules routine and cleaned up the old one.
27 Revision 1.71 2002/05/13 14:27:56 hristov
28 TreeC created once per event (M.Masera)
30 Revision 1.70 2002/05/10 22:28:30 nilsen
31 Changes by Massimo Masera to allow the TTree of clusters to be written to a
32 file otherthan the one with digits in it.
34 Revision 1.69 2002/05/05 21:06:55 nilsen
35 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
36 proper initilization when a simulation has already been defined.
38 Revision 1.68 2002/05/02 18:51:53 nilsen
40 Method MakeBranchR has now a second argument, with a default value:
41 Option_t *opt=" ". Opt="Fast" is to create a separate branch
42 for fast points in TreeR
43 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
46 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
48 2) Changes in MakeBranchR to allow the creation of a special branch
51 Revision 1.67 2002/03/15 17:22:51 nilsen
52 Intoduced SDigits2Digits and SDigitsToDigits functions.
54 Revision 1.66 2001/11/28 01:35:45 nilsen
55 Using standard constructors instead of default constructors for Clusterfinder,
56 Response, and FastSimulator.
58 Revision 1.65 2001/11/27 16:27:28 nilsen
59 Adding AliITSDigitizer class to do merging and digitization . Based on the
60 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
61 file. The following files required minor changes. AliITS, added functions
62 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
63 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
64 the original Root Directory in function Compress1D. Now it uses gDirectory.
66 Revision 1.64 2001/11/19 16:17:02 nilsen
67 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
68 bugs found by Rene require more work to fix. Will be fixed soon.
70 Revision 1.63 2001/10/24 21:16:34 nilsen
71 Removed some dead code and improved comments/documntation.
73 Revision 1.62 2001/10/21 19:23:21 nilsen
74 Added function to allow to limit which detectors to digitize and reconstruct.
75 The default is All. This change makes no changes to any root file.
77 Revision 1.61 2001/10/11 15:26:07 mariana
78 Correct HitsToFastRecPoints
80 Revision 1.60 2001/10/04 22:38:10 nilsen
81 Changes made to support PreDigits (SDigits) plus other helpful changes.
83 Revision 1.59 2001/08/30 09:56:18 hristov
84 The operator[] is replaced by At() or AddAt() in case of TObjArray.
86 Revision 1.58 2001/07/26 15:05:29 hristov
87 Use global gRandom generator (M.Ivanov)
89 Revision 1.57 2001/07/24 14:26:11 mariana
90 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
92 Revision 1.56 2001/07/05 12:49:49 mariana
93 Temporary patches required by root.v3.01.05
95 Revision 1.55 2001/06/14 14:59:00 barbera
96 Tracking V1 decoupled from AliITS
98 Revision 1.54 2001/05/31 20:37:56 barbera
99 Bari/Salerno model set as defaault SPD simulation
101 Revision 1.53 2001/05/31 18:52:24 barbera
102 Bari model becomes the default
104 Revision 1.53 2001/05/30 07:52:24 hristov
105 TPC and CONTAINERS included in the search path
107 Revision 1.52 2001/05/30 06:04:58 hristov
108 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
110 Revision 1.51 2001/05/16 14:57:15 alibrary
111 New files for folders and Stack
113 Revision 1.50 2001/05/11 09:15:21 barbera
114 Corrected to make fast point creation working with PPR geometry
116 Revision 1.49 2001/05/11 07:37:49 hristov
117 Legacy lines commented
119 Revision 1.48 2001/05/10 18:14:25 barbera
122 Revision 1.47 2001/05/10 17:55:59 barbera
123 Modified to create rec points also for PPR geometries
125 Revision 1.46 2001/05/10 00:05:28 nilsen
126 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
127 should probably be cleaned up to only check to make sure that fITSgeom has
128 been properly defined.
130 Revision 1.45 2001/05/01 22:35:48 nilsen
131 Remove/commented a number of cout<< statements. and made change needed by
134 Revision 1.44 2001/04/26 22:44:01 nilsen
135 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
136 done properly in AliITSv???.cxx via SetDefaults.
138 Revision 1.43 2001/04/26 13:22:52 barbera
139 TMatrix and TVector elimininated to speed up the code
141 Revision 1.42 2001/04/25 21:55:12 barbera
142 Updated version to be compatible with actual verion of STEER and TPC
144 Revision 1.41 2001/04/21 15:16:51 barbera
145 Updated with the new SSD reconstruction code
147 Revision 1.40 2001/03/17 15:07:06 mariana
148 Update SDD response parameters
150 Revision 1.39 2001/03/12 17:45:32 hristov
151 Changes needed on Sun with CC 5.0
153 Revision 1.38 2001/03/07 14:04:51 barbera
154 Some vector dimensions increased to cope with full events
156 Revision 1.37 2001/03/07 12:36:35 barbera
157 A change added in the tracking part to manage delta rays
159 Revision 1.36 2001/03/02 19:44:11 barbera
160 modified to taking into account new version tracking v1
162 Revision 1.35 2001/02/28 18:16:46 mariana
163 Make the code compatible with the new AliRun
165 Revision 1.34 2001/02/11 15:51:39 mariana
166 Set protection in MakeBranch
168 Revision 1.33 2001/02/10 22:26:39 mariana
169 Move the initialization of the containers for raw clusters in MakeTreeC()
171 Revision 1.32 2001/02/08 23:55:31 nilsen
172 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
173 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
175 Revision 1.31 2001/02/02 23:57:28 nilsen
176 Added include file that are no londer included in AliITSgeom.h
178 Revision 1.30 2001/01/30 09:23:13 hristov
179 Streamers removed (R.Brun)
181 Revision 1.29 2001/01/26 20:01:09 hristov
182 Major upgrade of AliRoot code
184 Revision 1.28 2000/12/18 14:02:00 barbera
185 new version of the ITS tracking to take into account the new TPC track parametrization
187 Revision 1.27 2000/12/08 13:49:27 barbera
188 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
190 Revision 1.26 2000/11/27 13:12:13 barbera
191 New version containing the files for tracking
193 Revision 1.25 2000/11/12 22:38:05 barbera
194 Added header file for the SPD Bari model
196 Revision 1.24 2000/10/09 22:18:12 barbera
197 Bug fixes from MAriana to le AliITStest.C run correctly
199 Revision 1.23 2000/10/05 20:47:42 nilsen
200 fixed dependencies of include files. Tryed but failed to get a root automaticly
201 generates streamer function to work. Modified SetDefaults.
203 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
204 Needed to include stdlib.h
207 Revision 1.22 2000/10/04 19:45:52 barbera
208 Corrected by F. Carminati for v3.04
210 Revision 1.21 2000/10/02 21:28:08 fca
211 Removal of useless dependecies via forward declarations
213 Revision 1.20 2000/10/02 16:31:39 barbera
214 General code clean-up
216 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
217 General code clean-up (e.g., printf -> cout)
219 Revision 1.19 2000/09/22 12:13:25 nilsen
220 Patches and updates for fixes to this and other routines.
222 Revision 1.18 2000/07/12 05:32:20 fca
223 Correcting several syntax problem with static members
225 Revision 1.17 2000/07/10 16:07:18 fca
226 Release version of ITS code
228 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
229 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
231 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
232 //fixed FillModule. Removed fi(fabs(xl)<dx....
234 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
235 This is the version of the files after the merging done in December 1999.
236 See the ReadMe110100.txt file for details
238 Revision 1.9 1999/11/14 14:33:25 fca
239 Correct problems with distructors and pointers, thanks to I.Hrivnacova
241 Revision 1.8 1999/09/29 09:24:19 fca
242 Introduction of the Copyright and cvs Log
246 ///////////////////////////////////////////////////////////////////////////////
248 // An overview of the basic philosophy of the ITS code development
249 // and analysis is show in the figure below.
252 <img src="picts/ITS/ITS_Analysis_schema.gif">
255 <font size=+2 color=red>
256 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
257 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
263 // AliITS. Inner Traking System base class.
264 // This class contains the base procedures for the Inner Tracking System
268 <img src="picts/ITS/AliITS_Class_Diagram.gif">
271 <font size=+2 color=red>
272 <p>This show the class diagram of the different elements that are part of
280 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
283 // Modified and documented by Bjorn S. Nilsen
287 // Modified and documented by A. Bologna
290 // AliITS is the general base class for the ITS. Also see AliDetector for
291 // futher information.
293 ///////////////////////////////////////////////////////////////////////////////
294 #include <iostream.h>
302 #include <TClonesArray.h>
304 #include <TObjectTable.h>
310 #include "AliHeader.h"
313 #include "AliITSDetType.h"
314 #include "AliITSresponseSPD.h"
315 #include "AliITSresponseSDD.h"
316 #include "AliITSresponseSSD.h"
317 #include "AliITSsegmentationSPD.h"
318 #include "AliITSsegmentationSDD.h"
319 #include "AliITSsegmentationSSD.h"
320 #include "AliITSsimulationSPD.h"
321 #include "AliITSsimulationSDD.h"
322 #include "AliITSsimulationSSD.h"
323 #include "AliITSClusterFinderSPD.h"
324 #include "AliITSClusterFinderSDD.h"
325 #include "AliITSClusterFinderSSD.h"
326 #include "AliITShit.h"
327 #include "AliITSgeom.h"
328 #include "AliITSpList.h"
329 #include "AliITSdigit.h"
330 #include "AliITSmodule.h"
331 #include "AliITSRecPoint.h"
332 #include "AliITSRawCluster.h"
336 //______________________________________________________________________
337 AliITS::AliITS() : AliDetector() {
338 // Default initializer for ITS
339 // The default constructor of the AliITS class. In addition to
340 // creating the AliITS class it zeros the variables fIshunt (a member
341 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
342 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
351 fIshunt = 0; // not zeroed in AliDetector.
358 // SetDetectors(); // default to fOpt="All". This variable not written out.
364 fNDetTypes = kNTYPES;
380 SetMarkerColor(kRed);
382 //______________________________________________________________________
383 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
384 // The standard Constructor for the ITS class. In addition to
385 // creating the AliITS class, it allocates memory for the TClonesArrays
386 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
387 // (clusters). It also zeros the variables
388 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
389 // the pointers fIdSens and fIdName. To help in displaying hits via the
390 // ROOT macro display.C AliITS also sets the marker color to red. The
391 // variables passes with this constructor, const char *name and *title,
392 // are used by the constructor of AliDetector class. See AliDetector
393 // class for a description of these parameters and its constructor
396 // const char *name Detector name. Should always be "ITS"
397 // const char *title Detector title.
403 fIshunt = 0; // not zeroed in AliDetector
404 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
405 gAlice->AddHitList(fHits); // Not done in AliDetector.
410 SetDetectors(); // default to fOpt="All". This variable not written out.
416 fNDetTypes = kNTYPES;
417 fDetTypes = new TObjArray(fNDetTypes);
419 fSDigits = new TClonesArray("AliITSpListItem",1000);
422 fNdtype = new Int_t[fNDetTypes];
423 fDtype = new TObjArray(fNDetTypes);
425 fCtype = new TObjArray(fNDetTypes);
426 fNctype = new Int_t[fNDetTypes];
429 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
433 for(i=0;i<fNDetTypes;i++) {
434 fDetTypes->AddAt(new AliITSDetType(),i);
439 SetMarkerColor(kRed);
441 //______________________________________________________________________
443 // Default destructor for ITS.
444 // The default destructor of the AliITS class. In addition to deleting
445 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
446 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
447 // fITSpoints, fDetType and it's contents.
455 delete fHits; fHits=0;
456 delete fSDigits; fSDigits=0;
457 // delete fDigits; fDigits=0;
458 delete fRecPoints; fRecPoints=0;
459 if(fIdName!=0) delete[] fIdName; // Array of TStrings
460 if(fIdSens!=0) delete[] fIdSens;
462 this->ClearModules();
464 }// end if fITSmodules!=0
480 } // end if fDetTypes
482 if (fTreeC) delete fTreeC;
484 if (fITSgeom) delete fITSgeom;
486 //______________________________________________________________________
487 AliITS::AliITS(AliITS &source){
488 // Copy constructor. This is a function which is not allowed to be
489 // done to the ITS. It exits with an error.
491 // AliITS &source An AliITS class.
497 if(this==&source) return;
498 Error("Copy constructor",
499 "You are not allowed to make a copy of the AliITS");
502 //______________________________________________________________________
503 AliITS& AliITS::operator=(AliITS &source){
504 // Assignment operator. This is a function which is not allowed to be
505 // done to the ITS. It exits with an error.
507 // AliITS &source An AliITS class.
513 if(this==&source) return *this;
514 Error("operator=","You are not allowed to make a copy of the AliITS");
516 return *this; //fake return
518 //______________________________________________________________________
519 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
520 // Distance from mouse to ITS on the screen. Dummy routine
521 // A dummy routine used by the ROOT macro display.C to allow for the
522 // use of the mouse (pointing device) in the macro. In general this should
523 // never be called. If it is it returns the number 9999 for any value of
526 // Int_t Dummy screen coordinate.
527 // Int_t Dummy screen coordinate.
531 // Int_t Dummy = 9999 distance to ITS.
535 //______________________________________________________________________
537 // Initializer ITS after it has been built
538 // This routine initializes the AliITS class. It is intended to be
539 // called from the Init function in AliITSv?. Besides displaying a banner
540 // indicating that it has been called it initializes the array fIdSens
541 // and sets the default segmentation, response, digit and raw cluster
542 // classes therefore it should be called after a call to CreateGeometry.
553 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
555 //______________________________________________________________________
556 void AliITS::SetDefaults(){
557 // sets the default segmentation, response, digit and raw cluster classes.
565 if(fDebug) printf("%s: SetDefaults\n",ClassName());
567 AliITSDetType *iDetType;
571 if (!iDetType->GetSegmentationModel()) {
572 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
573 SetSegmentationModel(0,seg0);
575 if (!iDetType->GetResponseModel()) {
576 SetResponseModel(0,new AliITSresponseSPD());
578 // set digit and raw cluster classes to be used
580 const char *kData0=(iDetType->GetResponseModel())->DataType();
581 if (strstr(kData0,"real")) {
582 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
583 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
587 if (!iDetType->GetResponseModel()) {
588 SetResponseModel(1,new AliITSresponseSDD("simulated"));
590 AliITSresponse *resp1=iDetType->GetResponseModel();
591 if (!iDetType->GetSegmentationModel()) {
592 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
593 SetSegmentationModel(1,seg1);
595 const char *kData1=(iDetType->GetResponseModel())->DataType();
596 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
597 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
598 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
599 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
603 if (!iDetType->GetSegmentationModel()) {
604 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
605 SetSegmentationModel(2,seg2);
607 if (!iDetType->GetResponseModel()) {
608 SetResponseModel(2,new AliITSresponseSSD("simulated"));
610 const char *kData2=(iDetType->GetResponseModel())->DataType();
611 if (strstr(kData2,"real")) {
612 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
613 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
616 Warning("SetDefaults",
617 "Only the three basic detector types are initialized!");
620 //______________________________________________________________________
621 void AliITS::SetDefaultSimulation(){
622 // sets the default simulation.
630 AliITSDetType *iDetType;
631 AliITSsimulation *sim;
633 sim = iDetType->GetSimulationModel();
635 AliITSsegmentation *seg0=
636 (AliITSsegmentation*)iDetType->GetSegmentationModel();
637 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
638 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
639 SetSimulationModel(0,sim0);
640 }else{ // simulation exists, make sure it is set up properly.
641 ((AliITSsimulationSPD*)sim)->Init(
642 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
643 (AliITSresponseSPD*) iDetType->GetResponseModel());
644 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
645 // (AliITSresponse*)iDetType->GetResponseModel());
646 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
647 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
650 sim = iDetType->GetSimulationModel();
652 AliITSsegmentation *seg1=
653 (AliITSsegmentation*)iDetType->GetSegmentationModel();
654 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
655 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
656 SetSimulationModel(1,sim1);
657 }else{ // simulation exists, make sure it is set up properly.
658 ((AliITSsimulationSDD*)sim)->Init(
659 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
660 (AliITSresponseSDD*) iDetType->GetResponseModel());
661 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
662 // (AliITSresponse*)iDetType->GetResponseModel());
663 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
664 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
667 sim = iDetType->GetSimulationModel();
669 AliITSsegmentation *seg2=
670 (AliITSsegmentation*)iDetType->GetSegmentationModel();
671 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
672 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
673 SetSimulationModel(2,sim2);
674 }else{ // simulation exists, make sure it is set up properly.
675 ((AliITSsimulationSSD*)sim)->Init(
676 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
677 (AliITSresponseSSD*) iDetType->GetResponseModel());
678 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
679 // (AliITSresponse*)iDetType->GetResponseModel());
680 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
681 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
684 //______________________________________________________________________
685 void AliITS::SetDefaultClusterFinders(){
686 // Sets the default cluster finders. Used in finding RecPoints.
695 AliITSDetType *iDetType;
699 if (!iDetType->GetReconstructionModel()) {
700 AliITSsegmentation *seg0 =
701 (AliITSsegmentation*)iDetType->GetSegmentationModel();
702 TClonesArray *dig0=DigitsAddress(0);
703 TClonesArray *recp0=ClustersAddress(0);
704 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
706 SetReconstructionModel(0,rec0);
711 if (!iDetType->GetReconstructionModel()) {
712 AliITSsegmentation *seg1 =
713 (AliITSsegmentation*)iDetType->GetSegmentationModel();
714 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
715 TClonesArray *dig1=DigitsAddress(1);
716 TClonesArray *recp1=ClustersAddress(1);
717 AliITSClusterFinderSDD *rec1 =
718 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
719 SetReconstructionModel(1,rec1);
724 if (!iDetType->GetReconstructionModel()) {
725 AliITSsegmentation *seg2=
726 (AliITSsegmentation*)iDetType->GetSegmentationModel();
727 TClonesArray *dig2=DigitsAddress(2);
728 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
729 SetReconstructionModel(2,rec2);
732 //______________________________________________________________________
733 void AliITS::MakeBranch(Option_t* option, const char *file){
734 // Creates Tree branches for the ITS.
736 // Option_t *option String of Tree types S,D, and/or R.
737 // const char *file String of the file name where these branches
738 // are to be stored. If blank then these branches
739 // are written to the same tree as the Hits were
745 Bool_t cS = (strstr(option,"S")!=0);
746 Bool_t cD = (strstr(option,"D")!=0);
747 Bool_t cR = (strstr(option,"R")!=0);
748 Bool_t cRF = (strstr(option,"RF")!=0);
751 AliDetector::MakeBranch(option,file);
753 if(cS) MakeBranchS(file);
754 if(cD) MakeBranchD(file);
755 if(cR) MakeBranchR(file);
756 if(cRF) MakeBranchRF(file);
758 //______________________________________________________________________
759 void AliITS::SetTreeAddress(){
760 // Set branch address for the Trees.
767 TTree *treeS = gAlice->TreeS();
768 TTree *treeD = gAlice->TreeD();
769 TTree *treeR = gAlice->TreeR();
771 AliDetector::SetTreeAddress();
773 SetTreeAddressS(treeS);
774 SetTreeAddressD(treeD);
775 SetTreeAddressR(treeR);
777 //______________________________________________________________________
778 AliITSDetType* AliITS::DetType(Int_t id){
779 // Return pointer to id detector type.
781 // Int_t id detector id number.
785 // returned, a pointer to a AliITSDetType.
787 return ((AliITSDetType*) fDetTypes->At(id));
789 //______________________________________________________________________
790 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
791 // Set the response model for the id detector type.
793 // Int_t id detector id number.
794 // AliITSresponse* a pointer containing an instance of AliITSresponse
795 // to be stored/owned b y AliITSDetType.
801 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
803 //______________________________________________________________________
804 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
805 // Set the segmentation model for the id detector type.
807 // Int_t id detector id number.
808 // AliITSsegmentation* a pointer containing an instance of
809 // AliITSsegmentation to be stored/owned b y
816 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
818 //______________________________________________________________________
819 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
820 // Set the simulation model for the id detector type.
822 // Int_t id detector id number.
823 // AliITSresponse* a pointer containing an instance of AliITSresponse
824 // to be stored/owned b y AliITSDetType.
830 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
833 //______________________________________________________________________
834 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
835 // Set the cluster finder model for the id detector type.
837 // Int_t id detector id number.
838 // AliITSClusterFinder* a pointer containing an instance of
839 // AliITSClusterFinder to be stored/owned b y
846 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
848 //______________________________________________________________________
849 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
850 // Set the digit and cluster classes name to be used for the id detector
853 // Int_t id detector id number.
854 // const char *digit Digit class name for detector id.
855 // const char *cluster Cluster class name for detector id.
861 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
863 //______________________________________________________________________
864 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
866 // The function to add information to the AliITShit class. See the
867 // AliITShit class for a full description. This function allocates the
868 // necessary new space for the hit information and passes the variable
869 // track, and the pointers *vol and *hits to the AliITShit constructor
872 // Int_t track Track number which produced this hit.
873 // Int_t *vol Array of Integer Hit information. See AliITShit.h
874 // Float_t *hits Array of Floating Hit information. see AliITShit.h
880 TClonesArray &lhits = *fHits;
881 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
883 //______________________________________________________________________
884 void AliITS::InitModules(Int_t size,Int_t &nmodules){
885 // Initialize the modules array.
887 // Int_t size Size of array of the number of modules to be
888 // created. If size <=0 then the number of modules
889 // is gotten from AliITSgeom class kept in fITSgeom.
891 // Int_t &nmodules The number of modules existing.
896 fITSmodules->Delete();
898 } // end fir fITSmoudles
900 Int_t nl,indexMAX,index;
902 if(size<=0){ // default to using data stored in AliITSgeom
904 Error("InitModules","fITSgeom not defined");
906 } // end if fITSgeom==0
907 nl = fITSgeom->GetNlayers();
908 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
909 fITSgeom->GetNdetectors(nl))+1;
911 fITSmodules = new TObjArray(indexMAX);
912 for(index=0;index<indexMAX;index++){
913 fITSmodules->AddAt( new AliITSmodule(index),index);
916 fITSmodules = new TObjArray(size);
917 for(index=0;index<size;index++) {
918 fITSmodules->AddAt( new AliITSmodule(index),index);
924 //______________________________________________________________________
925 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
926 Option_t *option,Text_t *filename){
927 // fill the modules with the sorted by module hits; add hits from
928 // background if option=Add.
930 // Int_t evnt Event to be processed.
931 // Int_t bgrev Background Hit tree number.
932 // Int_t nmodules Not used.
933 // Option_t *option String indicating if merging hits or not. To
934 // merge hits set equal to "Add". Otherwise no
935 // background hits are considered.
936 // Test_t *filename File name containing the background hits..
941 static TTree *trH1; //Tree with background hits
942 // static TClonesArray *fHits2; //List of hits for one track only
943 static Bool_t first=kTRUE;
945 const char *addBgr = strstr(option,"Add");
949 file=new TFile(filename);
950 // fHits2 = new TClonesArray("AliITShit",1000 );
955 // Get Hits Tree header from file
956 // if(fHits2) fHits2->Clear();
957 if(trH1) delete trH1;
961 sprintf(treeName,"TreeH%d",bgrev);
962 trH1 = (TTree*)gDirectory->Get(treeName);
964 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
966 // Set branch addresses
970 sprintf(branchname,"%s",GetName());
971 if (trH1 && fHits2) {
972 branch = trH1->GetBranch(branchname);
973 if (branch) branch->SetAddress(&fHits2);
974 } // end if trH1 && fHits
978 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
980 TClonesArray *itsHits = this->Hits();
981 Int_t lay,lad,det,index;
984 TTree *iTH = gAlice->TreeH();
985 Int_t ntracks =(Int_t) iTH->GetEntries();
987 for(t=0; t<ntracks; t++){
990 Int_t nhits = itsHits->GetEntriesFast();
991 if (!nhits) continue;
992 for(h=0; h<nhits; h++){
993 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
994 itsHit->GetDetectorID(lay,lad,det);
995 // temporarily index=det-1 !!!
996 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
999 mod = this->GetModule(index);
1000 mod->AddHit(itsHit,t,h);
1001 } // end loop over hits
1002 } // end loop over tracks
1004 // open the file with background
1007 FillModules(trH1,10000000); // Default mask 10M.
1010 ntracks =(Int_t)trH1->GetEntries();
1012 for (track=0; track<ntracks; track++) {
1013 if (fHits2) fHits2->Clear();
1014 trH1->GetEvent(track);
1016 for(i=0;i<fHits2->GetEntriesFast();++i) {
1017 itsHit=(AliITShit*) (*fHits2)[i];
1018 itsHit->GetDetectorID(lay,lad,det);
1019 // temporarily index=det-1 !!!
1020 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1023 mod = this->GetModule(index);
1024 mod->AddHit(itsHit,track,i);
1025 } // end loop over hits
1026 } // end loop over tracks
1028 TTree *fAli=gAlice->TreeK();
1030 if (fAli) fileAli =fAli->GetCurrentFile();
1034 //______________________________________________________________________
1035 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1036 // fill the modules with the sorted by module hits;
1037 // can be called many times to do a merging
1039 // TTree *treeH The tree containing the hits to be copied into
1041 // Int_t mask The track number mask to indecate which file
1042 // this hits came from.
1048 Int_t lay,lad,det,index;
1049 AliITShit *itsHit=0;
1050 AliITSmodule *mod=0;
1051 char branchname[20];
1052 sprintf(branchname,"%s",GetName());
1053 TBranch *branch = treeH->GetBranch(branchname);
1055 Error("FillModules","%s branch in TreeH not found",branchname);
1058 branch->SetAddress(&fHits);
1059 Int_t nTracks =(Int_t) treeH->GetEntries();
1061 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1063 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1064 if (nBytes <= 0) continue;
1065 Int_t nHits = fHits->GetEntriesFast();
1066 for(h=0; h<nHits; h++){
1067 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1068 itsHit->GetDetectorID(lay,lad,det);
1070 index = fITSgeom->GetModuleIndex(lay,lad,det);
1072 index=det-1; // This should not be used.
1073 } // end if [You must have fITSgeom for this to work!]
1074 mod = GetModule(index);
1075 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1076 mod->AddHit(itsHit,iPrimTrack,h);
1077 } // end loop over hits
1078 } // end loop over tracks
1080 //______________________________________________________________________
1081 void AliITS::ClearModules(){
1082 // Clear the modules TObjArray.
1088 if(fITSmodules) fITSmodules->Delete();
1090 //______________________________________________________________________
1091 void AliITS::MakeBranchS(const char *fl){
1092 // Creates Tree Branch for the ITS summable digits.
1094 // cont char *fl File name where SDigits branch is to be written
1095 // to. If blank it write the SDigits to the same
1096 // file in which the Hits were found.
1101 Int_t buffersize = 4000;
1102 char branchname[30];
1104 // only one branch for SDigits.
1105 sprintf(branchname,"%s",GetName());
1106 if(fSDigits && gAlice->TreeS()){
1107 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1110 //______________________________________________________________________
1111 void AliITS::SetTreeAddressS(TTree *treeS){
1112 // Set branch address for the ITS summable digits Trees.
1114 // TTree *treeS Tree containing the SDigits.
1119 char branchname[30];
1123 sprintf(branchname,"%s",GetName());
1124 branch = treeS->GetBranch(branchname);
1125 if (branch) branch->SetAddress(&fSDigits);
1127 //______________________________________________________________________
1128 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1129 // Creates Tree branches for the ITS.
1131 // TTree *treeD Pointer to the Digits Tree.
1132 // cont char *file File name where Digits branch is to be written
1133 // to. If blank it write the SDigits to the same
1134 // file in which the Hits were found.
1139 Int_t buffersize = 4000;
1140 char branchname[30];
1142 sprintf(branchname,"%s",GetName());
1143 // one branch for digits per type of detector
1144 const char *det[3] = {"SPD","SDD","SSD"};
1148 for (i=0; i<kNTYPES ;i++) {
1149 DetType(i)->GetClassNames(digclass,clclass);
1151 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1152 else ResetDigits(i);
1154 for (i=0; i<kNTYPES ;i++) {
1155 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1156 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1157 if (fDtype && treeD) {
1158 MakeBranchInTree(treeD,
1159 branchname, &((*fDtype)[i]),buffersize,file);
1163 //______________________________________________________________________
1164 void AliITS::SetTreeAddressD(TTree *treeD){
1165 // Set branch address for the Trees.
1167 // TTree *treeD Tree containing the Digits.
1172 char branchname[30];
1173 const char *det[3] = {"SPD","SDD","SSD"};
1180 for (i=0; i<kNTYPES; i++) {
1181 DetType(i)->GetClassNames(digclass,clclass);
1183 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1184 else ResetDigits(i);
1185 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1186 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1188 branch = treeD->GetBranch(branchname);
1189 if (branch) branch->SetAddress(&((*fDtype)[i]));
1193 //______________________________________________________________________
1194 void AliITS::Hits2SDigits(){
1195 // Standard Hits to summable Digits function.
1201 // return; // Using Hits in place of the larger sDigits.
1202 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1203 // Do the Hits to Digits operation. Use Standard input values.
1204 // Event number from file, no background hit merging , use size from
1205 // AliITSgeom class, option="All", input from this file only.
1206 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1208 //______________________________________________________________________
1209 void AliITS::Hits2PreDigits(){
1210 // Standard Hits to summable Digits function.
1216 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1217 // Do the Hits to Digits operation. Use Standard input values.
1218 // Event number from file, no background hit merging , use size from
1219 // AliITSgeom class, option="All", input from this file only.
1220 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1222 //______________________________________________________________________
1223 void AliITS::SDigitsToDigits(Option_t *opt){
1224 // Standard Summable digits to Digits function.
1229 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1231 if(!GetITSgeom()) return; // need transformations to do digitization.
1232 AliITSgeom *geom = GetITSgeom();
1234 const char *all = strstr(opt,"All");
1235 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1237 if( !det[0] && !det[1] && !det[2] ) all = "All";
1239 static Bool_t setDef=kTRUE;
1240 if (setDef) SetDefaultSimulation();
1243 AliITSsimulation *sim = 0;
1244 AliITSDetType *iDetType = 0;
1245 TTree *trees = gAlice->TreeS();
1246 if( !(trees && this->GetSDigits()) ){
1247 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1250 sprintf( name, "%s", this->GetName() );
1251 TBranch *brchSDigits = trees->GetBranch( name );
1254 for(module=0;module<geom->GetIndexMax();module++){
1255 id = geom->GetModuleType(module);
1256 if (!all && !det[id]) continue;
1257 iDetType = DetType(id);
1258 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1260 Error("SDigit2Digits",
1261 "The simulation class was not instanciated!");
1264 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1266 // add summable digits to module
1267 this->GetSDigits()->Clear();
1268 brchSDigits->GetEvent(module);
1269 sim->AddSDigitsToModule(GetSDigits(),0);
1271 // Digitise current module sum(SDigits)->Digits
1272 sim->FinishSDigitiseModule();
1274 // fills all branches - wasted disk space
1275 gAlice->TreeD()->Fill();
1276 this->ResetDigits();
1279 gAlice->TreeD()->GetEntries();
1281 gAlice->TreeD()->AutoSave();
1283 gAlice->TreeD()->Reset();
1286 //______________________________________________________________________
1287 void AliITS::Hits2Digits(){
1288 // Standard Hits to Digits function.
1294 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1295 // Do the Hits to Digits operation. Use Standard input values.
1296 // Event number from file, no background hit merging , use size from
1297 // AliITSgeom class, option="All", input from this file only.
1298 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1300 //______________________________________________________________________
1301 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1302 Option_t *option, Option_t *opt,Text_t *filename){
1303 // keep galice.root for signal and name differently the file for
1304 // background when add! otherwise the track info for signal will be lost !
1305 // the condition below will disappear when the geom class will be
1306 // initialized for all versions - for the moment it is only for v5 !
1307 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1310 // Int_t evnt Event to be processed.
1311 // Int_t bgrev Background Hit tree number.
1312 // Int_t nmodules Not used.
1313 // Option_t *option String indicating if merging hits or not. To
1314 // merge hits set equal to "Add". Otherwise no
1315 // background hits are considered.
1316 // Test_t *filename File name containing the background hits..
1321 // return; // using Hits instead of the larger sdigits.
1323 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1325 //______________________________________________________________________
1326 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1327 Option_t *option, Option_t *opt,Text_t *filename){
1328 // Keep galice.root for signal and name differently the file for
1329 // background when add! otherwise the track info for signal will be lost !
1330 // the condition below will disappear when the geom class will be
1331 // initialized for all versions - for the moment it is only for v5 !
1332 // 7 is the SDD beam test version.
1334 // Int_t evnt Event to be processed.
1335 // Int_t bgrev Background Hit tree number.
1336 // Int_t nmodules Not used.
1337 // Option_t *option String indicating if merging hits or not. To
1338 // merge hits set equal to "Add". Otherwise no
1339 // background hits are considered.
1340 // Test_t *filename File name containing the background hits..
1346 if(!GetITSgeom()) return; // need transformations to do digitization.
1347 AliITSgeom *geom = GetITSgeom();
1349 const char *all = strstr(opt,"All");
1350 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1352 static Bool_t setDef=kTRUE;
1353 if (setDef) SetDefaultSimulation();
1357 InitModules(size,nmodules);
1358 FillModules(evNumber,bgrev,nmodules,option,filename);
1360 AliITSsimulation *sim = 0;
1361 AliITSDetType *iDetType = 0;
1362 AliITSmodule *mod = 0;
1364 for(module=0;module<geom->GetIndexMax();module++){
1365 id = geom->GetModuleType(module);
1366 if (!all && !det[id]) continue;
1367 iDetType = DetType(id);
1368 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1370 Error("HitsToSDigits",
1371 "The simulation class was not instanciated!");
1374 mod = (AliITSmodule *)fITSmodules->At(module);
1375 sim->SDigitiseModule(mod,module,evNumber);
1376 // fills all branches - wasted disk space
1377 gAlice->TreeS()->Fill();
1383 gAlice->TreeS()->GetEntries();
1384 gAlice->TreeS()->AutoSave();
1386 gAlice->TreeS()->Reset();
1388 //______________________________________________________________________
1389 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1390 Option_t *option, Option_t *opt,Text_t *filename){
1391 // Keep galice.root for signal and name differently the file for
1392 // background when add! otherwise the track info for signal will be lost !
1393 // the condition below will disappear when the geom class will be
1394 // initialized for all versions - for the moment it is only for v5 !
1395 // 7 is the SDD beam test version.
1397 // Int_t evnt Event to be processed.
1398 // Int_t bgrev Background Hit tree number.
1399 // Int_t nmodules Not used.
1400 // Option_t *option String indicating if merging hits or not. To
1401 // merge hits set equal to "Add". Otherwise no
1402 // background hits are considered.
1403 // Test_t *filename File name containing the background hits..
1409 if(!GetITSgeom()) return; // need transformations to do digitization.
1410 AliITSgeom *geom = GetITSgeom();
1412 const char *all = strstr(opt,"All");
1413 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1415 static Bool_t setDef=kTRUE;
1416 if (setDef) SetDefaultSimulation();
1420 InitModules(size,nmodules);
1421 FillModules(evNumber,bgrev,nmodules,option,filename);
1423 AliITSsimulation *sim = 0;
1424 AliITSDetType *iDetType = 0;
1425 AliITSmodule *mod = 0;
1427 for(module=0;module<geom->GetIndexMax();module++){
1428 id = geom->GetModuleType(module);
1429 if (!all && !det[id]) continue;
1430 iDetType = DetType(id);
1431 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1433 Error("HitsToDigits",
1434 "The simulation class was not instanciated!");
1437 mod = (AliITSmodule *)fITSmodules->At(module);
1438 sim->DigitiseModule(mod,module,evNumber);
1439 // fills all branches - wasted disk space
1440 gAlice->TreeD()->Fill();
1446 gAlice->TreeD()->GetEntries();
1447 gAlice->TreeD()->AutoSave();
1449 gAlice->TreeD()->Reset();
1451 //______________________________________________________________________
1452 void AliITS::ResetSDigits(){
1453 // Reset the Summable Digits array.
1459 if (fSDigits) fSDigits->Clear();
1462 //______________________________________________________________________
1463 void AliITS::ResetDigits(){
1464 // Reset number of digits and the digits array for the ITS detector.
1470 if (!fDtype) return;
1473 for (i=0;i<kNTYPES;i++ ) {
1474 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1475 if (fNdtype) fNdtype[i]=0;
1478 //______________________________________________________________________
1479 void AliITS::ResetDigits(Int_t i){
1480 // Reset number of digits and the digits array for this branch.
1486 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1487 if (fNdtype) fNdtype[i]=0;
1489 //______________________________________________________________________
1490 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1491 // Adds the a module full of summable digits to the summable digits tree.
1493 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1499 TClonesArray &lsdig = *fSDigits;
1500 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1502 //______________________________________________________________________
1503 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1504 // Add a real digit - as coming from data.
1506 // Int_t id Detector type number.
1507 // Int_t *digits Integer array containing the digits info. See
1514 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1515 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1517 //______________________________________________________________________
1518 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1519 // Add a simulated digit.
1521 // Int_t id Detector type number.
1522 // AliITSdigit *d Digit to be added to the Digits Tree. See
1529 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1533 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1536 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1539 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1543 //______________________________________________________________________
1544 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1545 Int_t *hits,Float_t *charges){
1546 // Add a simulated digit to the list.
1548 // Int_t id Detector type number.
1549 // Float_t phys Physics indicator. See AliITSdigits.h
1550 // Int_t *digits Integer array containing the digits info. See
1552 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1553 // containing the track numbers that contributed to
1555 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1556 // containing the hit numbers, from AliITSmodule, that
1557 // contributed to this digit.
1558 // Float_t *charge Floating point array of the signals contributed
1559 // to this digit by each track.
1565 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1568 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1571 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1575 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1579 //______________________________________________________________________
1580 void AliITS::MakeTreeC(Option_t *option){
1581 // Create a separate tree to store the clusters.
1583 // Option_t *option string which must contain "C" otherwise
1584 // no Cluster Tree is created.
1589 TDirectory *cwd = gDirectory;
1590 TFile *fileRecPoints = gAlice->GetTreeRFile();
1591 if(fileRecPoints)fileRecPoints->cd();
1592 const char *optC = strstr(option,"C");
1594 Int_t cureve = gAlice->GetEvNumber();
1595 sprintf(hname,"TreeC%d",cureve);
1597 const char *curname = fTreeC->GetName();
1598 char *exists = strstr(hname,curname);
1604 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1607 Int_t buffersize = 4000;
1608 char branchname[30];
1609 const char *det[3] = {"SPD","SDD","SSD"};
1613 // one branch for Clusters per type of detector
1615 for (i=0; i<kNTYPES ;i++) {
1616 AliITSDetType *iDetType=DetType(i);
1617 iDetType->GetClassNames(digclass,clclass);
1619 if(!ClustersAddress(i)){
1620 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1622 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1623 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1624 if (fCtype && fTreeC) {
1625 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1626 } // end if fCtype && fTreeC
1630 //______________________________________________________________________
1631 void AliITS::GetTreeC(Int_t event){
1632 // Get the clusters tree for this event and set the branch address.
1634 // Int_t event Event number for the cluster tree.
1640 char branchname[30];
1641 const char *det[3] = {"SPD","SDD","SSD"};
1648 sprintf(treeName,"TreeC%d",event);
1649 TFile *fileRecPoints = gAlice->GetTreeRFile();
1651 fTreeC = (TTree*)gDirectory->Get(treeName);
1654 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1663 for (i=0; i<kNTYPES; i++) {
1664 AliITSDetType *iDetType=DetType(i);
1665 iDetType->GetClassNames(digclass,clclass);
1667 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1668 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1669 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1671 branch = fTreeC->GetBranch(branchname);
1672 if (branch) branch->SetAddress(&((*fCtype)[i]));
1676 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1679 //______________________________________________________________________
1680 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1681 // Add a cluster to the list.
1683 // Int_t id Detector type number.
1684 // AliITSRawCluster *c Cluster class to be added to the tree of
1691 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1695 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1698 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1701 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1705 //______________________________________________________________________
1706 void AliITS::ResetClusters(){
1707 // Reset number of clusters and the clusters array for ITS.
1714 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1716 //______________________________________________________________________
1717 void AliITS::ResetClusters(Int_t i){
1718 // Reset number of clusters and the clusters array for this branch.
1720 // Int_t i Detector type number.
1726 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1727 if (fNctype) fNctype[i]=0;
1729 //______________________________________________________________________
1730 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1731 // Creates Tree branches for the ITS Reconstructed points.
1733 // cont char *file File name where RecPoints branch is to be written
1734 // to. If blank it write the SDigits to the same
1735 // file in which the Hits were found.
1740 Int_t buffsz = 4000;
1741 char branchname[30];
1743 // only one branch for rec points for all detector types
1744 Bool_t oFast= (strstr(opt,"Fast")!=0);
1746 sprintf(branchname,"%sRecPointsF",GetName());
1748 sprintf(branchname,"%sRecPoints",GetName());
1750 if (fRecPoints && gAlice->TreeR()) {
1751 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1754 //______________________________________________________________________
1755 void AliITS::SetTreeAddressR(TTree *treeR){
1756 // Set branch address for the Reconstructed points Trees.
1758 // TTree *treeR Tree containing the RecPoints.
1763 char branchname[30];
1767 sprintf(branchname,"%sRecPoints",GetName());
1768 branch = treeR->GetBranch(branchname);
1770 branch->SetAddress(&fRecPoints);
1773 sprintf(branchname,"%sRecPointsF",GetName());
1774 branch = treeR->GetBranch(branchname);
1776 branch->SetAddress(&fRecPoints);
1780 //______________________________________________________________________
1781 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1782 // Add a reconstructed space point to the list
1784 // const AliITSRecPoint &r RecPoint class to be added to the tree
1785 // of reconstructed points TreeR.
1791 TClonesArray &lrecp = *fRecPoints;
1792 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1794 //______________________________________________________________________
1795 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1796 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1797 // keep galice.root for signal and name differently the file for
1798 // background when add! otherwise the track info for signal will be lost !
1799 // the condition below will disappear when the geom class will be
1800 // initialized for all versions - for the moment it is only for v5 !
1802 // Int_t evnt Event to be processed.
1803 // Int_t bgrev Background Hit tree number.
1804 // Int_t size Size used by InitModules. See InitModules.
1805 // Option_t *opt0 Option passed to FillModules. See FillModules.
1806 // Option_t *opt1 String indicating if merging hits or not. To
1807 // merge hits set equal to "Add". Otherwise no
1808 // background hits are considered.
1809 // Test_t *flnm File name containing the background hits..
1815 if(!GetITSgeom()) return;
1816 AliITSgeom *geom = GetITSgeom();
1818 const char *all = strstr(opt1,"All");
1819 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1820 strstr(opt1,"SSD")};
1822 InitModules(size,nmodules);
1823 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1825 AliITSsimulation *sim = 0;
1826 AliITSDetType *iDetType = 0;
1827 AliITSmodule *mod = 0;
1830 //m.b. : this change is nothing but a nice way to make sure
1832 for(module=0;module<geom->GetIndexMax();module++){
1833 id = geom->GetModuleType(module);
1834 if (!all && !det[id]) continue;
1835 iDetType = DetType(id);
1836 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1838 Error("HitsToFastPoints",
1839 "The simulation class was not instanciated!");
1842 mod = (AliITSmodule *)fITSmodules->At(module);
1843 sim->CreateFastRecPoints(mod,module,gRandom);
1844 // gAlice->TreeR()->Fill();
1845 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1852 gAlice->TreeR()->AutoSave();
1854 gAlice->TreeR()->Reset();
1856 //______________________________________________________________________
1857 void AliITS::Digits2Reco(){
1858 // Find clusters and reconstruct space points.
1864 AliHeader *header=gAlice->GetHeader();
1865 // to Digits to RecPoints for event in file, all digits in file, and
1866 // all ITS detectors.
1867 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1869 //______________________________________________________________________
1870 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1871 // cluster finding and reconstruction of space points
1872 // the condition below will disappear when the geom class will be
1873 // initialized for all versions - for the moment it is only for v5 !
1874 // 7 is the SDD beam test version
1876 // Int_t evNumber Event number to be processed.
1877 // Int_t lastentry Offset for module when not all of the modules
1879 // Option_t *opt String indicating which ITS sub-detectors should
1880 // be processed. If ="All" then all of the ITS
1881 // sub detectors are processed.
1887 if(!GetITSgeom()) return;
1888 AliITSgeom *geom = GetITSgeom();
1890 const char *all = strstr(opt,"All");
1891 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1893 static Bool_t setRec=kTRUE;
1894 if (setRec) SetDefaultClusterFinders();
1897 TTree *treeC=TreeC();
1898 AliITSClusterFinder *rec = 0;
1899 AliITSDetType *iDetType = 0;
1900 Int_t id,module,first=0;
1901 for(module=0;module<geom->GetIndexMax();module++){
1902 id = geom->GetModuleType(module);
1903 if (!all && !det[id]) continue;
1904 if(det[id]) first = geom->GetStartDet(id);
1905 iDetType = DetType(id);
1906 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1907 TClonesArray *itsDigits = this->DigitsAddress(id);
1909 Error("DigitsToRecPoints",
1910 "The reconstruction class was not instanciated!");
1913 this->ResetDigits();
1914 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1915 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1916 Int_t ndigits = itsDigits->GetEntriesFast();
1917 if (ndigits) rec->FindRawClusters(module);
1918 gAlice->TreeR()->Fill();
1924 gAlice->TreeR()->GetEntries();
1925 treeC->GetEntries();
1926 gAlice->TreeR()->AutoSave();
1928 gAlice->TreeR()->Reset();
1933 //______________________________________________________________________
1934 void AliITS::ResetRecPoints(){
1935 // Reset number of rec points and the rec points array.
1941 if (fRecPoints) fRecPoints->Clear();