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.76 2002/11/21 23:05:27 alibrary
19 Removing AliMC and AliMCProcess
21 Revision 1.75 2002/10/22 14:45:25 alibrary
22 Introducing Riostream.h
24 Revision 1.74 2002/10/14 14:57:00 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.67.4.3 2002/10/14 13:14:07 hristov
28 Updating VirtualMC to v3-09-02
30 Revision 1.73 2002/09/09 17:14:25 nilsen
31 Update of documentation to reflect changes in AliITSdigitS?D classes.
33 Revision 1.72 2002/06/10 17:28:55 nilsen
34 Added new FillModules routine and cleaned up the old one.
36 Revision 1.71 2002/05/13 14:27:56 hristov
37 TreeC created once per event (M.Masera)
39 Revision 1.70 2002/05/10 22:28:30 nilsen
40 Changes by Massimo Masera to allow the TTree of clusters to be written to a
41 file otherthan the one with digits in it.
43 Revision 1.69 2002/05/05 21:06:55 nilsen
44 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
45 proper initilization when a simulation has already been defined.
47 Revision 1.68 2002/05/02 18:51:53 nilsen
49 Method MakeBranchR has now a second argument, with a default value:
50 Option_t *opt=" ". Opt="Fast" is to create a separate branch
51 for fast points in TreeR
52 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
55 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
57 2) Changes in MakeBranchR to allow the creation of a special branch
60 Revision 1.67 2002/03/15 17:22:51 nilsen
61 Intoduced SDigits2Digits and SDigitsToDigits functions.
63 Revision 1.66 2001/11/28 01:35:45 nilsen
64 Using standard constructors instead of default constructors for Clusterfinder,
65 Response, and FastSimulator.
67 Revision 1.65 2001/11/27 16:27:28 nilsen
68 Adding AliITSDigitizer class to do merging and digitization . Based on the
69 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
70 file. The following files required minor changes. AliITS, added functions
71 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
72 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
73 the original Root Directory in function Compress1D. Now it uses gDirectory.
75 Revision 1.64 2001/11/19 16:17:02 nilsen
76 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
77 bugs found by Rene require more work to fix. Will be fixed soon.
79 Revision 1.63 2001/10/24 21:16:34 nilsen
80 Removed some dead code and improved comments/documntation.
82 Revision 1.62 2001/10/21 19:23:21 nilsen
83 Added function to allow to limit which detectors to digitize and reconstruct.
84 The default is All. This change makes no changes to any root file.
86 Revision 1.61 2001/10/11 15:26:07 mariana
87 Correct HitsToFastRecPoints
89 Revision 1.60 2001/10/04 22:38:10 nilsen
90 Changes made to support PreDigits (SDigits) plus other helpful changes.
92 Revision 1.59 2001/08/30 09:56:18 hristov
93 The operator[] is replaced by At() or AddAt() in case of TObjArray.
95 Revision 1.58 2001/07/26 15:05:29 hristov
96 Use global gRandom generator (M.Ivanov)
98 Revision 1.57 2001/07/24 14:26:11 mariana
99 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
101 Revision 1.56 2001/07/05 12:49:49 mariana
102 Temporary patches required by root.v3.01.05
104 Revision 1.55 2001/06/14 14:59:00 barbera
105 Tracking V1 decoupled from AliITS
107 Revision 1.54 2001/05/31 20:37:56 barbera
108 Bari/Salerno model set as defaault SPD simulation
110 Revision 1.53 2001/05/31 18:52:24 barbera
111 Bari model becomes the default
113 Revision 1.53 2001/05/30 07:52:24 hristov
114 TPC and CONTAINERS included in the search path
116 Revision 1.52 2001/05/30 06:04:58 hristov
117 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
119 Revision 1.51 2001/05/16 14:57:15 alibrary
120 New files for folders and Stack
122 Revision 1.50 2001/05/11 09:15:21 barbera
123 Corrected to make fast point creation working with PPR geometry
125 Revision 1.49 2001/05/11 07:37:49 hristov
126 Legacy lines commented
128 Revision 1.48 2001/05/10 18:14:25 barbera
131 Revision 1.47 2001/05/10 17:55:59 barbera
132 Modified to create rec points also for PPR geometries
134 Revision 1.46 2001/05/10 00:05:28 nilsen
135 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
136 should probably be cleaned up to only check to make sure that fITSgeom has
137 been properly defined.
139 Revision 1.45 2001/05/01 22:35:48 nilsen
140 Remove/commented a number of cout<< statements. and made change needed by
143 Revision 1.44 2001/04/26 22:44:01 nilsen
144 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
145 done properly in AliITSv???.cxx via SetDefaults.
147 Revision 1.43 2001/04/26 13:22:52 barbera
148 TMatrix and TVector elimininated to speed up the code
150 Revision 1.42 2001/04/25 21:55:12 barbera
151 Updated version to be compatible with actual verion of STEER and TPC
153 Revision 1.41 2001/04/21 15:16:51 barbera
154 Updated with the new SSD reconstruction code
156 Revision 1.40 2001/03/17 15:07:06 mariana
157 Update SDD response parameters
159 Revision 1.39 2001/03/12 17:45:32 hristov
160 Changes needed on Sun with CC 5.0
162 Revision 1.38 2001/03/07 14:04:51 barbera
163 Some vector dimensions increased to cope with full events
165 Revision 1.37 2001/03/07 12:36:35 barbera
166 A change added in the tracking part to manage delta rays
168 Revision 1.36 2001/03/02 19:44:11 barbera
169 modified to taking into account new version tracking v1
171 Revision 1.35 2001/02/28 18:16:46 mariana
172 Make the code compatible with the new AliRun
174 Revision 1.34 2001/02/11 15:51:39 mariana
175 Set protection in MakeBranch
177 Revision 1.33 2001/02/10 22:26:39 mariana
178 Move the initialization of the containers for raw clusters in MakeTreeC()
180 Revision 1.32 2001/02/08 23:55:31 nilsen
181 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
182 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
184 Revision 1.31 2001/02/02 23:57:28 nilsen
185 Added include file that are no londer included in AliITSgeom.h
187 Revision 1.30 2001/01/30 09:23:13 hristov
188 Streamers removed (R.Brun)
190 Revision 1.29 2001/01/26 20:01:09 hristov
191 Major upgrade of AliRoot code
193 Revision 1.28 2000/12/18 14:02:00 barbera
194 new version of the ITS tracking to take into account the new TPC track parametrization
196 Revision 1.27 2000/12/08 13:49:27 barbera
197 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
199 Revision 1.26 2000/11/27 13:12:13 barbera
200 New version containing the files for tracking
202 Revision 1.25 2000/11/12 22:38:05 barbera
203 Added header file for the SPD Bari model
205 Revision 1.24 2000/10/09 22:18:12 barbera
206 Bug fixes from MAriana to le AliITStest.C run correctly
208 Revision 1.23 2000/10/05 20:47:42 nilsen
209 fixed dependencies of include files. Tryed but failed to get a root automaticly
210 generates streamer function to work. Modified SetDefaults.
212 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
213 Needed to include stdlib.h
216 Revision 1.22 2000/10/04 19:45:52 barbera
217 Corrected by F. Carminati for v3.04
219 Revision 1.21 2000/10/02 21:28:08 fca
220 Removal of useless dependecies via forward declarations
222 Revision 1.20 2000/10/02 16:31:39 barbera
223 General code clean-up
225 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
226 General code clean-up (e.g., printf -> cout)
228 Revision 1.19 2000/09/22 12:13:25 nilsen
229 Patches and updates for fixes to this and other routines.
231 Revision 1.18 2000/07/12 05:32:20 fca
232 Correcting several syntax problem with static members
234 Revision 1.17 2000/07/10 16:07:18 fca
235 Release version of ITS code
237 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
238 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
240 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
241 //fixed FillModule. Removed fi(fabs(xl)<dx....
243 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
244 This is the version of the files after the merging done in December 1999.
245 See the ReadMe110100.txt file for details
247 Revision 1.9 1999/11/14 14:33:25 fca
248 Correct problems with distructors and pointers, thanks to I.Hrivnacova
250 Revision 1.8 1999/09/29 09:24:19 fca
251 Introduction of the Copyright and cvs Log
255 ///////////////////////////////////////////////////////////////////////////////
257 // An overview of the basic philosophy of the ITS code development
258 // and analysis is show in the figure below.
261 <img src="picts/ITS/ITS_Analysis_schema.gif">
264 <font size=+2 color=red>
265 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
266 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
272 // AliITS. Inner Traking System base class.
273 // This class contains the base procedures for the Inner Tracking System
277 <img src="picts/ITS/AliITS_Class_Diagram.gif">
280 <font size=+2 color=red>
281 <p>This show the class diagram of the different elements that are part of
289 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
292 // Modified and documented by Bjorn S. Nilsen
296 // Modified and documented by A. Bologna
299 // AliITS is the general base class for the ITS. Also see AliDetector for
300 // futher information.
302 ///////////////////////////////////////////////////////////////////////////////
303 #include <Riostream.h>
309 #include <TClonesArray.h>
311 #include <TObjectTable.h>
316 #include "AliHeader.h"
319 #include "AliITSDetType.h"
320 #include "AliITSresponseSPD.h"
321 #include "AliITSresponseSDD.h"
322 #include "AliITSresponseSSD.h"
323 #include "AliITSsegmentationSPD.h"
324 #include "AliITSsegmentationSDD.h"
325 #include "AliITSsegmentationSSD.h"
326 #include "AliITSsimulationSPD.h"
327 #include "AliITSsimulationSDD.h"
328 #include "AliITSsimulationSSD.h"
329 #include "AliITSClusterFinderSPD.h"
330 #include "AliITSClusterFinderSDD.h"
331 #include "AliITSClusterFinderSSD.h"
332 #include "AliITShit.h"
333 #include "AliITSgeom.h"
334 #include "AliITSpList.h"
335 #include "AliITSdigit.h"
336 #include "AliITSmodule.h"
337 #include "AliITSRecPoint.h"
338 #include "AliITSRawCluster.h"
342 //______________________________________________________________________
343 AliITS::AliITS() : AliDetector() {
344 // Default initializer for ITS
345 // The default constructor of the AliITS class. In addition to
346 // creating the AliITS class it zeros the variables fIshunt (a member
347 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
348 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
357 fIshunt = 0; // not zeroed in AliDetector.
364 // SetDetectors(); // default to fOpt="All". This variable not written out.
370 fNDetTypes = kNTYPES;
386 SetMarkerColor(kRed);
388 //______________________________________________________________________
389 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
390 // The standard Constructor for the ITS class. In addition to
391 // creating the AliITS class, it allocates memory for the TClonesArrays
392 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
393 // (clusters). It also zeros the variables
394 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
395 // the pointers fIdSens and fIdName. To help in displaying hits via the
396 // ROOT macro display.C AliITS also sets the marker color to red. The
397 // variables passes with this constructor, const char *name and *title,
398 // are used by the constructor of AliDetector class. See AliDetector
399 // class for a description of these parameters and its constructor
402 // const char *name Detector name. Should always be "ITS"
403 // const char *title Detector title.
409 fIshunt = 0; // not zeroed in AliDetector
410 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
411 gAlice->AddHitList(fHits); // Not done in AliDetector.
416 SetDetectors(); // default to fOpt="All". This variable not written out.
422 fNDetTypes = kNTYPES;
423 fDetTypes = new TObjArray(fNDetTypes);
425 fSDigits = new TClonesArray("AliITSpListItem",1000);
428 fNdtype = new Int_t[fNDetTypes];
429 fDtype = new TObjArray(fNDetTypes);
431 fCtype = new TObjArray(fNDetTypes);
432 fNctype = new Int_t[fNDetTypes];
435 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
439 for(i=0;i<fNDetTypes;i++) {
440 fDetTypes->AddAt(new AliITSDetType(),i);
445 SetMarkerColor(kRed);
447 //______________________________________________________________________
449 // Default destructor for ITS.
450 // The default destructor of the AliITS class. In addition to deleting
451 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
452 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
453 // fITSpoints, fDetType and it's contents.
471 // delete fDigits; fDigits=0;
473 fRecPoints->Delete();
477 delete[] fIdName; // Array of TStrings
480 this->ClearModules();
483 }// end if fITSmodules!=0
499 } // end if fDetTypes
501 if (fTreeC) delete fTreeC;
503 if (fITSgeom) delete fITSgeom;
505 //______________________________________________________________________
506 AliITS::AliITS(AliITS &source){
507 // Copy constructor. 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;
517 Error("Copy constructor",
518 "You are not allowed to make a copy of the AliITS");
521 //______________________________________________________________________
522 AliITS& AliITS::operator=(AliITS &source){
523 // Assignment operator. This is a function which is not allowed to be
524 // done to the ITS. It exits with an error.
526 // AliITS &source An AliITS class.
532 if(this==&source) return *this;
533 Error("operator=","You are not allowed to make a copy of the AliITS");
535 return *this; //fake return
537 //______________________________________________________________________
538 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
539 // Distance from mouse to ITS on the screen. Dummy routine
540 // A dummy routine used by the ROOT macro display.C to allow for the
541 // use of the mouse (pointing device) in the macro. In general this should
542 // never be called. If it is it returns the number 9999 for any value of
545 // Int_t Dummy screen coordinate.
546 // Int_t Dummy screen coordinate.
550 // Int_t Dummy = 9999 distance to ITS.
554 //______________________________________________________________________
556 // Initializer ITS after it has been built
557 // This routine initializes the AliITS class. It is intended to be
558 // called from the Init function in AliITSv?. Besides displaying a banner
559 // indicating that it has been called it initializes the array fIdSens
560 // and sets the default segmentation, response, digit and raw cluster
561 // classes therefore it should be called after a call to CreateGeometry.
572 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
574 //______________________________________________________________________
575 void AliITS::SetDefaults(){
576 // sets the default segmentation, response, digit and raw cluster classes.
584 if(fDebug) printf("%s: SetDefaults\n",ClassName());
586 AliITSDetType *iDetType;
590 if (!iDetType->GetSegmentationModel()) {
591 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
592 SetSegmentationModel(0,seg0);
594 if (!iDetType->GetResponseModel()) {
595 SetResponseModel(0,new AliITSresponseSPD());
597 // set digit and raw cluster classes to be used
599 const char *kData0=(iDetType->GetResponseModel())->DataType();
600 if (strstr(kData0,"real")) {
601 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
602 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
606 if (!iDetType->GetResponseModel()) {
607 SetResponseModel(1,new AliITSresponseSDD("simulated"));
609 AliITSresponse *resp1=iDetType->GetResponseModel();
610 if (!iDetType->GetSegmentationModel()) {
611 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
612 SetSegmentationModel(1,seg1);
614 const char *kData1=(iDetType->GetResponseModel())->DataType();
615 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
616 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
617 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
618 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
622 if (!iDetType->GetSegmentationModel()) {
623 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
624 SetSegmentationModel(2,seg2);
626 if (!iDetType->GetResponseModel()) {
627 SetResponseModel(2,new AliITSresponseSSD("simulated"));
629 const char *kData2=(iDetType->GetResponseModel())->DataType();
630 if (strstr(kData2,"real")) {
631 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
632 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
635 Warning("SetDefaults",
636 "Only the three basic detector types are initialized!");
639 //______________________________________________________________________
640 void AliITS::SetDefaultSimulation(){
641 // sets the default simulation.
649 AliITSDetType *iDetType;
650 AliITSsimulation *sim;
652 sim = iDetType->GetSimulationModel();
654 AliITSsegmentation *seg0=
655 (AliITSsegmentation*)iDetType->GetSegmentationModel();
656 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
657 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
658 SetSimulationModel(0,sim0);
659 }else{ // simulation exists, make sure it is set up properly.
660 ((AliITSsimulationSPD*)sim)->Init(
661 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
662 (AliITSresponseSPD*) iDetType->GetResponseModel());
663 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
664 // (AliITSresponse*)iDetType->GetResponseModel());
665 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
666 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
669 sim = iDetType->GetSimulationModel();
671 AliITSsegmentation *seg1=
672 (AliITSsegmentation*)iDetType->GetSegmentationModel();
673 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
674 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
675 SetSimulationModel(1,sim1);
676 }else{ // simulation exists, make sure it is set up properly.
677 ((AliITSsimulationSDD*)sim)->Init(
678 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
679 (AliITSresponseSDD*) iDetType->GetResponseModel());
680 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
681 // (AliITSresponse*)iDetType->GetResponseModel());
682 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
683 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
686 sim = iDetType->GetSimulationModel();
688 AliITSsegmentation *seg2=
689 (AliITSsegmentation*)iDetType->GetSegmentationModel();
690 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
691 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
692 SetSimulationModel(2,sim2);
693 }else{ // simulation exists, make sure it is set up properly.
694 ((AliITSsimulationSSD*)sim)->Init(
695 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
696 (AliITSresponseSSD*) iDetType->GetResponseModel());
697 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
698 // (AliITSresponse*)iDetType->GetResponseModel());
699 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
700 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
703 //______________________________________________________________________
704 void AliITS::SetDefaultClusterFinders(){
705 // Sets the default cluster finders. Used in finding RecPoints.
714 AliITSDetType *iDetType;
718 if (!iDetType->GetReconstructionModel()) {
719 AliITSsegmentation *seg0 =
720 (AliITSsegmentation*)iDetType->GetSegmentationModel();
721 TClonesArray *dig0=DigitsAddress(0);
722 TClonesArray *recp0=ClustersAddress(0);
723 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
725 SetReconstructionModel(0,rec0);
730 if (!iDetType->GetReconstructionModel()) {
731 AliITSsegmentation *seg1 =
732 (AliITSsegmentation*)iDetType->GetSegmentationModel();
733 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
734 TClonesArray *dig1=DigitsAddress(1);
735 TClonesArray *recp1=ClustersAddress(1);
736 AliITSClusterFinderSDD *rec1 =
737 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
738 SetReconstructionModel(1,rec1);
743 if (!iDetType->GetReconstructionModel()) {
744 AliITSsegmentation *seg2=
745 (AliITSsegmentation*)iDetType->GetSegmentationModel();
746 TClonesArray *dig2=DigitsAddress(2);
747 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
748 SetReconstructionModel(2,rec2);
751 //______________________________________________________________________
752 void AliITS::MakeBranch(Option_t* option, const char *file){
753 // Creates Tree branches for the ITS.
755 // Option_t *option String of Tree types S,D, and/or R.
756 // const char *file String of the file name where these branches
757 // are to be stored. If blank then these branches
758 // are written to the same tree as the Hits were
764 Bool_t cS = (strstr(option,"S")!=0);
765 Bool_t cD = (strstr(option,"D")!=0);
766 Bool_t cR = (strstr(option,"R")!=0);
767 Bool_t cRF = (strstr(option,"RF")!=0);
770 AliDetector::MakeBranch(option,file);
772 if(cS) MakeBranchS(file);
773 if(cD) MakeBranchD(file);
774 if(cR) MakeBranchR(file);
775 if(cRF) MakeBranchRF(file);
777 //______________________________________________________________________
778 void AliITS::SetTreeAddress(){
779 // Set branch address for the Trees.
786 TTree *treeS = gAlice->TreeS();
787 TTree *treeD = gAlice->TreeD();
788 TTree *treeR = gAlice->TreeR();
790 AliDetector::SetTreeAddress();
792 SetTreeAddressS(treeS);
793 SetTreeAddressD(treeD);
794 SetTreeAddressR(treeR);
796 //______________________________________________________________________
797 AliITSDetType* AliITS::DetType(Int_t id){
798 // Return pointer to id detector type.
800 // Int_t id detector id number.
804 // returned, a pointer to a AliITSDetType.
806 return ((AliITSDetType*) fDetTypes->At(id));
808 //______________________________________________________________________
809 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
810 // Set the response model for the id detector type.
812 // Int_t id detector id number.
813 // AliITSresponse* a pointer containing an instance of AliITSresponse
814 // to be stored/owned b y AliITSDetType.
820 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
822 //______________________________________________________________________
823 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
824 // Set the segmentation model for the id detector type.
826 // Int_t id detector id number.
827 // AliITSsegmentation* a pointer containing an instance of
828 // AliITSsegmentation to be stored/owned b y
835 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
837 //______________________________________________________________________
838 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
839 // Set the simulation model for the id detector type.
841 // Int_t id detector id number.
842 // AliITSresponse* a pointer containing an instance of AliITSresponse
843 // to be stored/owned b y AliITSDetType.
849 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
852 //______________________________________________________________________
853 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
854 // Set the cluster finder model for the id detector type.
856 // Int_t id detector id number.
857 // AliITSClusterFinder* a pointer containing an instance of
858 // AliITSClusterFinder to be stored/owned b y
865 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
867 //______________________________________________________________________
868 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
869 // Set the digit and cluster classes name to be used for the id detector
872 // Int_t id detector id number.
873 // const char *digit Digit class name for detector id.
874 // const char *cluster Cluster class name for detector id.
880 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
882 //______________________________________________________________________
883 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
885 // The function to add information to the AliITShit class. See the
886 // AliITShit class for a full description. This function allocates the
887 // necessary new space for the hit information and passes the variable
888 // track, and the pointers *vol and *hits to the AliITShit constructor
891 // Int_t track Track number which produced this hit.
892 // Int_t *vol Array of Integer Hit information. See AliITShit.h
893 // Float_t *hits Array of Floating Hit information. see AliITShit.h
899 TClonesArray &lhits = *fHits;
900 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
902 //______________________________________________________________________
903 void AliITS::InitModules(Int_t size,Int_t &nmodules){
904 // Initialize the modules array.
906 // Int_t size Size of array of the number of modules to be
907 // created. If size <=0 then the number of modules
908 // is gotten from AliITSgeom class kept in fITSgeom.
910 // Int_t &nmodules The number of modules existing.
915 fITSmodules->Delete();
917 } // end fir fITSmoudles
919 Int_t nl,indexMAX,index;
921 if(size<=0){ // default to using data stored in AliITSgeom
923 Error("InitModules","fITSgeom not defined");
925 } // end if fITSgeom==0
926 nl = fITSgeom->GetNlayers();
927 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
928 fITSgeom->GetNdetectors(nl))+1;
930 fITSmodules = new TObjArray(indexMAX);
931 for(index=0;index<indexMAX;index++){
932 fITSmodules->AddAt( new AliITSmodule(index),index);
935 fITSmodules = new TObjArray(size);
936 for(index=0;index<size;index++) {
937 fITSmodules->AddAt( new AliITSmodule(index),index);
943 //______________________________________________________________________
944 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
945 Option_t *option,Text_t *filename){
946 // fill the modules with the sorted by module hits; add hits from
947 // background if option=Add.
949 // Int_t evnt Event to be processed.
950 // Int_t bgrev Background Hit tree number.
951 // Int_t nmodules Not used.
952 // Option_t *option String indicating if merging hits or not. To
953 // merge hits set equal to "Add". Otherwise no
954 // background hits are considered.
955 // Test_t *filename File name containing the background hits..
960 static TTree *trH1; //Tree with background hits
961 // static TClonesArray *fHits2; //List of hits for one track only
962 static Bool_t first=kTRUE;
964 const char *addBgr = strstr(option,"Add");
968 file=new TFile(filename);
969 // fHits2 = new TClonesArray("AliITShit",1000 );
974 // Get Hits Tree header from file
975 // if(fHits2) fHits2->Clear();
976 if(trH1) delete trH1;
980 sprintf(treeName,"TreeH%d",bgrev);
981 trH1 = (TTree*)gDirectory->Get(treeName);
983 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
985 // Set branch addresses
989 sprintf(branchname,"%s",GetName());
990 if (trH1 && fHits2) {
991 branch = trH1->GetBranch(branchname);
992 if (branch) branch->SetAddress(&fHits2);
993 } // end if trH1 && fHits
997 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
999 TClonesArray *itsHits = this->Hits();
1000 Int_t lay,lad,det,index;
1001 AliITShit *itsHit=0;
1002 AliITSmodule *mod=0;
1003 TTree *iTH = gAlice->TreeH();
1004 Int_t ntracks =(Int_t) iTH->GetEntries();
1006 for(t=0; t<ntracks; t++){
1007 gAlice->ResetHits();
1009 Int_t nhits = itsHits->GetEntriesFast();
1010 if (!nhits) continue;
1011 for(h=0; h<nhits; h++){
1012 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
1013 itsHit->GetDetectorID(lay,lad,det);
1014 // temporarily index=det-1 !!!
1015 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1018 mod = this->GetModule(index);
1019 mod->AddHit(itsHit,t,h);
1020 } // end loop over hits
1021 } // end loop over tracks
1023 // open the file with background
1026 FillModules(trH1,10000000); // Default mask 10M.
1029 ntracks =(Int_t)trH1->GetEntries();
1031 for (track=0; track<ntracks; track++) {
1032 if (fHits2) fHits2->Clear();
1033 trH1->GetEvent(track);
1035 for(i=0;i<fHits2->GetEntriesFast();++i) {
1036 itsHit=(AliITShit*) (*fHits2)[i];
1037 itsHit->GetDetectorID(lay,lad,det);
1038 // temporarily index=det-1 !!!
1039 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1042 mod = this->GetModule(index);
1043 mod->AddHit(itsHit,track,i);
1044 } // end loop over hits
1045 } // end loop over tracks
1047 TTree *fAli=gAlice->TreeK();
1049 if (fAli) fileAli =fAli->GetCurrentFile();
1053 //______________________________________________________________________
1054 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1055 // fill the modules with the sorted by module hits;
1056 // can be called many times to do a merging
1058 // TTree *treeH The tree containing the hits to be copied into
1060 // Int_t mask The track number mask to indecate which file
1061 // this hits came from.
1067 Int_t lay,lad,det,index;
1068 AliITShit *itsHit=0;
1069 AliITSmodule *mod=0;
1070 char branchname[20];
1071 sprintf(branchname,"%s",GetName());
1072 TBranch *branch = treeH->GetBranch(branchname);
1074 Error("FillModules","%s branch in TreeH not found",branchname);
1077 branch->SetAddress(&fHits);
1078 Int_t nTracks =(Int_t) treeH->GetEntries();
1080 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1082 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1083 if (nBytes <= 0) continue;
1084 Int_t nHits = fHits->GetEntriesFast();
1085 for(h=0; h<nHits; h++){
1086 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1087 itsHit->GetDetectorID(lay,lad,det);
1089 index = fITSgeom->GetModuleIndex(lay,lad,det);
1091 index=det-1; // This should not be used.
1092 } // end if [You must have fITSgeom for this to work!]
1093 mod = GetModule(index);
1094 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1095 mod->AddHit(itsHit,iPrimTrack,h);
1096 } // end loop over hits
1097 } // end loop over tracks
1099 //______________________________________________________________________
1100 void AliITS::ClearModules(){
1101 // Clear the modules TObjArray.
1107 if(fITSmodules) fITSmodules->Delete();
1109 //______________________________________________________________________
1110 void AliITS::MakeBranchS(const char *fl){
1111 // Creates Tree Branch for the ITS summable digits.
1113 // cont char *fl File name where SDigits branch is to be written
1114 // to. If blank it write the SDigits to the same
1115 // file in which the Hits were found.
1120 Int_t buffersize = 4000;
1121 char branchname[30];
1123 // only one branch for SDigits.
1124 sprintf(branchname,"%s",GetName());
1125 if(fSDigits && gAlice->TreeS()){
1126 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1129 //______________________________________________________________________
1130 void AliITS::SetTreeAddressS(TTree *treeS){
1131 // Set branch address for the ITS summable digits Trees.
1133 // TTree *treeS Tree containing the SDigits.
1138 char branchname[30];
1142 sprintf(branchname,"%s",GetName());
1143 branch = treeS->GetBranch(branchname);
1144 if (branch) branch->SetAddress(&fSDigits);
1146 //______________________________________________________________________
1147 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1148 // Creates Tree branches for the ITS.
1150 // TTree *treeD Pointer to the Digits Tree.
1151 // cont char *file File name where Digits branch is to be written
1152 // to. If blank it write the SDigits to the same
1153 // file in which the Hits were found.
1158 Int_t buffersize = 4000;
1159 char branchname[30];
1161 sprintf(branchname,"%s",GetName());
1162 // one branch for digits per type of detector
1163 const char *det[3] = {"SPD","SDD","SSD"};
1167 for (i=0; i<kNTYPES ;i++) {
1168 DetType(i)->GetClassNames(digclass,clclass);
1170 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1171 else ResetDigits(i);
1173 for (i=0; i<kNTYPES ;i++) {
1174 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1175 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1176 if (fDtype && treeD) {
1177 MakeBranchInTree(treeD,
1178 branchname, &((*fDtype)[i]),buffersize,file);
1182 //______________________________________________________________________
1183 void AliITS::SetTreeAddressD(TTree *treeD){
1184 // Set branch address for the Trees.
1186 // TTree *treeD Tree containing the Digits.
1191 char branchname[30];
1192 const char *det[3] = {"SPD","SDD","SSD"};
1199 for (i=0; i<kNTYPES; i++) {
1200 DetType(i)->GetClassNames(digclass,clclass);
1202 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1203 else ResetDigits(i);
1204 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1205 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1207 branch = treeD->GetBranch(branchname);
1208 if (branch) branch->SetAddress(&((*fDtype)[i]));
1212 //______________________________________________________________________
1213 void AliITS::Hits2SDigits(){
1214 // Standard Hits to summable Digits function.
1220 // return; // Using Hits in place of the larger sDigits.
1221 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1222 // Do the Hits to Digits operation. Use Standard input values.
1223 // Event number from file, no background hit merging , use size from
1224 // AliITSgeom class, option="All", input from this file only.
1225 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1227 //______________________________________________________________________
1228 void AliITS::Hits2PreDigits(){
1229 // Standard Hits to summable Digits function.
1235 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1236 // Do the Hits to Digits operation. Use Standard input values.
1237 // Event number from file, no background hit merging , use size from
1238 // AliITSgeom class, option="All", input from this file only.
1239 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1241 //______________________________________________________________________
1242 void AliITS::SDigitsToDigits(Option_t *opt){
1243 // Standard Summable digits to Digits function.
1248 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1250 if(!GetITSgeom()) return; // need transformations to do digitization.
1251 AliITSgeom *geom = GetITSgeom();
1253 const char *all = strstr(opt,"All");
1254 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1256 if( !det[0] && !det[1] && !det[2] ) all = "All";
1258 static Bool_t setDef=kTRUE;
1259 if (setDef) SetDefaultSimulation();
1262 AliITSsimulation *sim = 0;
1263 AliITSDetType *iDetType = 0;
1264 TTree *trees = gAlice->TreeS();
1265 if( !(trees && this->GetSDigits()) ){
1266 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1269 sprintf( name, "%s", this->GetName() );
1270 TBranch *brchSDigits = trees->GetBranch( name );
1273 for(module=0;module<geom->GetIndexMax();module++){
1274 id = geom->GetModuleType(module);
1275 if (!all && !det[id]) continue;
1276 iDetType = DetType(id);
1277 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1279 Error("SDigit2Digits",
1280 "The simulation class was not instanciated!");
1283 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1285 // add summable digits to module
1286 this->GetSDigits()->Clear();
1287 brchSDigits->GetEvent(module);
1288 sim->AddSDigitsToModule(GetSDigits(),0);
1290 // Digitise current module sum(SDigits)->Digits
1291 sim->FinishSDigitiseModule();
1293 // fills all branches - wasted disk space
1294 gAlice->TreeD()->Fill();
1295 this->ResetDigits();
1298 gAlice->TreeD()->GetEntries();
1300 gAlice->TreeD()->AutoSave();
1302 gAlice->TreeD()->Reset();
1305 //______________________________________________________________________
1306 void AliITS::Hits2Digits(){
1307 // Standard Hits to Digits function.
1313 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1314 // Do the Hits to Digits operation. Use Standard input values.
1315 // Event number from file, no background hit merging , use size from
1316 // AliITSgeom class, option="All", input from this file only.
1317 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1319 //______________________________________________________________________
1320 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1321 Option_t *option, Option_t *opt,Text_t *filename){
1322 // keep galice.root for signal and name differently the file for
1323 // background when add! otherwise the track info for signal will be lost !
1324 // the condition below will disappear when the geom class will be
1325 // initialized for all versions - for the moment it is only for v5 !
1326 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1329 // Int_t evnt Event to be processed.
1330 // Int_t bgrev Background Hit tree number.
1331 // Int_t nmodules Not used.
1332 // Option_t *option String indicating if merging hits or not. To
1333 // merge hits set equal to "Add". Otherwise no
1334 // background hits are considered.
1335 // Test_t *filename File name containing the background hits..
1340 // return; // using Hits instead of the larger sdigits.
1342 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1344 //______________________________________________________________________
1345 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1346 Option_t *option, Option_t *opt,Text_t *filename){
1347 // Keep galice.root for signal and name differently the file for
1348 // background when add! otherwise the track info for signal will be lost !
1349 // the condition below will disappear when the geom class will be
1350 // initialized for all versions - for the moment it is only for v5 !
1351 // 7 is the SDD beam test version.
1353 // Int_t evnt Event to be processed.
1354 // Int_t bgrev Background Hit tree number.
1355 // Int_t nmodules Not used.
1356 // Option_t *option String indicating if merging hits or not. To
1357 // merge hits set equal to "Add". Otherwise no
1358 // background hits are considered.
1359 // Test_t *filename File name containing the background hits..
1365 if(!GetITSgeom()) return; // need transformations to do digitization.
1366 AliITSgeom *geom = GetITSgeom();
1368 const char *all = strstr(opt,"All");
1369 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1371 static Bool_t setDef=kTRUE;
1372 if (setDef) SetDefaultSimulation();
1376 InitModules(size,nmodules);
1377 FillModules(evNumber,bgrev,nmodules,option,filename);
1379 AliITSsimulation *sim = 0;
1380 AliITSDetType *iDetType = 0;
1381 AliITSmodule *mod = 0;
1383 for(module=0;module<geom->GetIndexMax();module++){
1384 id = geom->GetModuleType(module);
1385 if (!all && !det[id]) continue;
1386 iDetType = DetType(id);
1387 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1389 Error("HitsToSDigits",
1390 "The simulation class was not instanciated!");
1393 mod = (AliITSmodule *)fITSmodules->At(module);
1394 sim->SDigitiseModule(mod,module,evNumber);
1395 // fills all branches - wasted disk space
1396 gAlice->TreeS()->Fill();
1402 gAlice->TreeS()->GetEntries();
1403 gAlice->TreeS()->AutoSave();
1405 gAlice->TreeS()->Reset();
1407 //______________________________________________________________________
1408 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1409 Option_t *option, Option_t *opt,Text_t *filename){
1410 // Keep galice.root for signal and name differently the file for
1411 // background when add! otherwise the track info for signal will be lost !
1412 // the condition below will disappear when the geom class will be
1413 // initialized for all versions - for the moment it is only for v5 !
1414 // 7 is the SDD beam test version.
1416 // Int_t evnt Event to be processed.
1417 // Int_t bgrev Background Hit tree number.
1418 // Int_t nmodules Not used.
1419 // Option_t *option String indicating if merging hits or not. To
1420 // merge hits set equal to "Add". Otherwise no
1421 // background hits are considered.
1422 // Test_t *filename File name containing the background hits..
1428 if(!GetITSgeom()) return; // need transformations to do digitization.
1429 AliITSgeom *geom = GetITSgeom();
1431 const char *all = strstr(opt,"All");
1432 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1434 static Bool_t setDef=kTRUE;
1435 if (setDef) SetDefaultSimulation();
1439 InitModules(size,nmodules);
1440 FillModules(evNumber,bgrev,nmodules,option,filename);
1442 AliITSsimulation *sim = 0;
1443 AliITSDetType *iDetType = 0;
1444 AliITSmodule *mod = 0;
1446 for(module=0;module<geom->GetIndexMax();module++){
1447 id = geom->GetModuleType(module);
1448 if (!all && !det[id]) continue;
1449 iDetType = DetType(id);
1450 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1452 Error("HitsToDigits",
1453 "The simulation class was not instanciated!");
1456 mod = (AliITSmodule *)fITSmodules->At(module);
1457 sim->DigitiseModule(mod,module,evNumber);
1458 // fills all branches - wasted disk space
1459 gAlice->TreeD()->Fill();
1465 gAlice->TreeD()->GetEntries();
1466 gAlice->TreeD()->AutoSave();
1468 gAlice->TreeD()->Reset();
1470 //______________________________________________________________________
1471 void AliITS::ResetSDigits(){
1472 // Reset the Summable Digits array.
1478 if (fSDigits) fSDigits->Clear();
1481 //______________________________________________________________________
1482 void AliITS::ResetDigits(){
1483 // Reset number of digits and the digits array for the ITS detector.
1489 if (!fDtype) return;
1492 for (i=0;i<kNTYPES;i++ ) {
1493 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1494 if (fNdtype) fNdtype[i]=0;
1497 //______________________________________________________________________
1498 void AliITS::ResetDigits(Int_t i){
1499 // Reset number of digits and the digits array for this branch.
1505 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1506 if (fNdtype) fNdtype[i]=0;
1508 //______________________________________________________________________
1509 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1510 // Adds the a module full of summable digits to the summable digits tree.
1512 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1518 TClonesArray &lsdig = *fSDigits;
1519 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1521 //______________________________________________________________________
1522 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1523 // Add a real digit - as coming from data.
1525 // Int_t id Detector type number.
1526 // Int_t *digits Integer array containing the digits info. See
1533 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1534 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1536 //______________________________________________________________________
1537 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1538 // Add a simulated digit.
1540 // Int_t id Detector type number.
1541 // AliITSdigit *d Digit to be added to the Digits Tree. See
1548 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1552 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1555 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1558 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1562 //______________________________________________________________________
1563 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1564 Int_t *hits,Float_t *charges){
1565 // Add a simulated digit to the list.
1567 // Int_t id Detector type number.
1568 // Float_t phys Physics indicator. See AliITSdigits.h
1569 // Int_t *digits Integer array containing the digits info. See
1571 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1572 // containing the track numbers that contributed to
1574 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1575 // containing the hit numbers, from AliITSmodule, that
1576 // contributed to this digit.
1577 // Float_t *charge Floating point array of the signals contributed
1578 // to this digit by each track.
1584 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1587 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1590 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1594 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1598 //______________________________________________________________________
1599 void AliITS::MakeTreeC(Option_t *option){
1600 // Create a separate tree to store the clusters.
1602 // Option_t *option string which must contain "C" otherwise
1603 // no Cluster Tree is created.
1608 TDirectory *cwd = gDirectory;
1609 TFile *fileRecPoints = gAlice->GetTreeRFile();
1610 if(fileRecPoints)fileRecPoints->cd();
1611 const char *optC = strstr(option,"C");
1613 Int_t cureve = gAlice->GetEvNumber();
1614 sprintf(hname,"TreeC%d",cureve);
1616 const char *curname = fTreeC->GetName();
1617 char *exists = strstr(hname,curname);
1623 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1626 Int_t buffersize = 4000;
1627 char branchname[30];
1628 const char *det[3] = {"SPD","SDD","SSD"};
1632 // one branch for Clusters per type of detector
1634 for (i=0; i<kNTYPES ;i++) {
1635 AliITSDetType *iDetType=DetType(i);
1636 iDetType->GetClassNames(digclass,clclass);
1638 if(!ClustersAddress(i)){
1639 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1641 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1642 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1643 if (fCtype && fTreeC) {
1644 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1645 } // end if fCtype && fTreeC
1649 //______________________________________________________________________
1650 void AliITS::GetTreeC(Int_t event){
1651 // Get the clusters tree for this event and set the branch address.
1653 // Int_t event Event number for the cluster tree.
1659 char branchname[30];
1660 const char *det[3] = {"SPD","SDD","SSD"};
1667 sprintf(treeName,"TreeC%d",event);
1668 TFile *fileRecPoints = gAlice->GetTreeRFile();
1670 fTreeC = (TTree*)gDirectory->Get(treeName);
1673 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1682 for (i=0; i<kNTYPES; i++) {
1683 AliITSDetType *iDetType=DetType(i);
1684 iDetType->GetClassNames(digclass,clclass);
1686 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1687 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1688 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1690 branch = fTreeC->GetBranch(branchname);
1691 if (branch) branch->SetAddress(&((*fCtype)[i]));
1695 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1698 //______________________________________________________________________
1699 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1700 // Add a cluster to the list.
1702 // Int_t id Detector type number.
1703 // AliITSRawCluster *c Cluster class to be added to the tree of
1710 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1714 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1717 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1720 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1724 //______________________________________________________________________
1725 void AliITS::ResetClusters(){
1726 // Reset number of clusters and the clusters array for ITS.
1733 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1735 //______________________________________________________________________
1736 void AliITS::ResetClusters(Int_t i){
1737 // Reset number of clusters and the clusters array for this branch.
1739 // Int_t i Detector type number.
1745 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1746 if (fNctype) fNctype[i]=0;
1748 //______________________________________________________________________
1749 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1750 // Creates Tree branches for the ITS Reconstructed points.
1752 // cont char *file File name where RecPoints branch is to be written
1753 // to. If blank it write the SDigits to the same
1754 // file in which the Hits were found.
1759 Int_t buffsz = 4000;
1760 char branchname[30];
1762 // only one branch for rec points for all detector types
1763 Bool_t oFast= (strstr(opt,"Fast")!=0);
1765 sprintf(branchname,"%sRecPointsF",GetName());
1767 sprintf(branchname,"%sRecPoints",GetName());
1769 if (fRecPoints && gAlice->TreeR()) {
1770 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1773 //______________________________________________________________________
1774 void AliITS::SetTreeAddressR(TTree *treeR){
1775 // Set branch address for the Reconstructed points Trees.
1777 // TTree *treeR Tree containing the RecPoints.
1782 char branchname[30];
1786 sprintf(branchname,"%sRecPoints",GetName());
1787 branch = treeR->GetBranch(branchname);
1789 branch->SetAddress(&fRecPoints);
1792 sprintf(branchname,"%sRecPointsF",GetName());
1793 branch = treeR->GetBranch(branchname);
1795 branch->SetAddress(&fRecPoints);
1799 //______________________________________________________________________
1800 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1801 // Add a reconstructed space point to the list
1803 // const AliITSRecPoint &r RecPoint class to be added to the tree
1804 // of reconstructed points TreeR.
1810 TClonesArray &lrecp = *fRecPoints;
1811 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1813 //______________________________________________________________________
1814 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1815 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1816 // keep galice.root for signal and name differently the file for
1817 // background when add! otherwise the track info for signal will be lost !
1818 // the condition below will disappear when the geom class will be
1819 // initialized for all versions - for the moment it is only for v5 !
1821 // Int_t evnt Event to be processed.
1822 // Int_t bgrev Background Hit tree number.
1823 // Int_t size Size used by InitModules. See InitModules.
1824 // Option_t *opt0 Option passed to FillModules. See FillModules.
1825 // Option_t *opt1 String indicating if merging hits or not. To
1826 // merge hits set equal to "Add". Otherwise no
1827 // background hits are considered.
1828 // Test_t *flnm File name containing the background hits..
1834 if(!GetITSgeom()) return;
1835 AliITSgeom *geom = GetITSgeom();
1837 const char *all = strstr(opt1,"All");
1838 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1839 strstr(opt1,"SSD")};
1841 InitModules(size,nmodules);
1842 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1844 AliITSsimulation *sim = 0;
1845 AliITSDetType *iDetType = 0;
1846 AliITSmodule *mod = 0;
1849 //m.b. : this change is nothing but a nice way to make sure
1851 for(module=0;module<geom->GetIndexMax();module++){
1852 id = geom->GetModuleType(module);
1853 if (!all && !det[id]) continue;
1854 iDetType = DetType(id);
1855 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1857 Error("HitsToFastPoints",
1858 "The simulation class was not instanciated!");
1861 mod = (AliITSmodule *)fITSmodules->At(module);
1862 sim->CreateFastRecPoints(mod,module,gRandom);
1863 // gAlice->TreeR()->Fill();
1864 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1871 gAlice->TreeR()->AutoSave();
1873 gAlice->TreeR()->Reset();
1875 //______________________________________________________________________
1876 void AliITS::Digits2Reco(){
1877 // Find clusters and reconstruct space points.
1883 AliHeader *header=gAlice->GetHeader();
1884 // to Digits to RecPoints for event in file, all digits in file, and
1885 // all ITS detectors.
1886 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1888 //______________________________________________________________________
1889 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1890 // cluster finding and reconstruction of space points
1891 // the condition below will disappear when the geom class will be
1892 // initialized for all versions - for the moment it is only for v5 !
1893 // 7 is the SDD beam test version
1895 // Int_t evNumber Event number to be processed.
1896 // Int_t lastentry Offset for module when not all of the modules
1898 // Option_t *opt String indicating which ITS sub-detectors should
1899 // be processed. If ="All" then all of the ITS
1900 // sub detectors are processed.
1906 if(!GetITSgeom()) return;
1907 AliITSgeom *geom = GetITSgeom();
1909 const char *all = strstr(opt,"All");
1910 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1912 static Bool_t setRec=kTRUE;
1913 if (setRec) SetDefaultClusterFinders();
1916 TTree *treeC=TreeC();
1917 AliITSClusterFinder *rec = 0;
1918 AliITSDetType *iDetType = 0;
1919 Int_t id,module,first=0;
1920 for(module=0;module<geom->GetIndexMax();module++){
1921 id = geom->GetModuleType(module);
1922 if (!all && !det[id]) continue;
1923 if(det[id]) first = geom->GetStartDet(id);
1924 iDetType = DetType(id);
1925 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1926 TClonesArray *itsDigits = this->DigitsAddress(id);
1928 Error("DigitsToRecPoints",
1929 "The reconstruction class was not instanciated!");
1932 this->ResetDigits();
1933 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1934 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1935 Int_t ndigits = itsDigits->GetEntriesFast();
1936 if (ndigits) rec->FindRawClusters(module);
1937 gAlice->TreeR()->Fill();
1943 gAlice->TreeR()->GetEntries();
1944 treeC->GetEntries();
1945 gAlice->TreeR()->AutoSave();
1947 gAlice->TreeR()->Reset();
1952 //______________________________________________________________________
1953 void AliITS::ResetRecPoints(){
1954 // Reset number of rec points and the rec points array.
1960 if (fRecPoints) fRecPoints->Clear();