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.74 2002/10/14 14:57:00 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.67.4.3 2002/10/14 13:14:07 hristov
22 Updating VirtualMC to v3-09-02
24 Revision 1.73 2002/09/09 17:14:25 nilsen
25 Update of documentation to reflect changes in AliITSdigitS?D classes.
27 Revision 1.72 2002/06/10 17:28:55 nilsen
28 Added new FillModules routine and cleaned up the old one.
30 Revision 1.71 2002/05/13 14:27:56 hristov
31 TreeC created once per event (M.Masera)
33 Revision 1.70 2002/05/10 22:28:30 nilsen
34 Changes by Massimo Masera to allow the TTree of clusters to be written to a
35 file otherthan the one with digits in it.
37 Revision 1.69 2002/05/05 21:06:55 nilsen
38 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
39 proper initilization when a simulation has already been defined.
41 Revision 1.68 2002/05/02 18:51:53 nilsen
43 Method MakeBranchR has now a second argument, with a default value:
44 Option_t *opt=" ". Opt="Fast" is to create a separate branch
45 for fast points in TreeR
46 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
49 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
51 2) Changes in MakeBranchR to allow the creation of a special branch
54 Revision 1.67 2002/03/15 17:22:51 nilsen
55 Intoduced SDigits2Digits and SDigitsToDigits functions.
57 Revision 1.66 2001/11/28 01:35:45 nilsen
58 Using standard constructors instead of default constructors for Clusterfinder,
59 Response, and FastSimulator.
61 Revision 1.65 2001/11/27 16:27:28 nilsen
62 Adding AliITSDigitizer class to do merging and digitization . Based on the
63 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
64 file. The following files required minor changes. AliITS, added functions
65 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
66 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
67 the original Root Directory in function Compress1D. Now it uses gDirectory.
69 Revision 1.64 2001/11/19 16:17:02 nilsen
70 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
71 bugs found by Rene require more work to fix. Will be fixed soon.
73 Revision 1.63 2001/10/24 21:16:34 nilsen
74 Removed some dead code and improved comments/documntation.
76 Revision 1.62 2001/10/21 19:23:21 nilsen
77 Added function to allow to limit which detectors to digitize and reconstruct.
78 The default is All. This change makes no changes to any root file.
80 Revision 1.61 2001/10/11 15:26:07 mariana
81 Correct HitsToFastRecPoints
83 Revision 1.60 2001/10/04 22:38:10 nilsen
84 Changes made to support PreDigits (SDigits) plus other helpful changes.
86 Revision 1.59 2001/08/30 09:56:18 hristov
87 The operator[] is replaced by At() or AddAt() in case of TObjArray.
89 Revision 1.58 2001/07/26 15:05:29 hristov
90 Use global gRandom generator (M.Ivanov)
92 Revision 1.57 2001/07/24 14:26:11 mariana
93 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
95 Revision 1.56 2001/07/05 12:49:49 mariana
96 Temporary patches required by root.v3.01.05
98 Revision 1.55 2001/06/14 14:59:00 barbera
99 Tracking V1 decoupled from AliITS
101 Revision 1.54 2001/05/31 20:37:56 barbera
102 Bari/Salerno model set as defaault SPD simulation
104 Revision 1.53 2001/05/31 18:52:24 barbera
105 Bari model becomes the default
107 Revision 1.53 2001/05/30 07:52:24 hristov
108 TPC and CONTAINERS included in the search path
110 Revision 1.52 2001/05/30 06:04:58 hristov
111 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
113 Revision 1.51 2001/05/16 14:57:15 alibrary
114 New files for folders and Stack
116 Revision 1.50 2001/05/11 09:15:21 barbera
117 Corrected to make fast point creation working with PPR geometry
119 Revision 1.49 2001/05/11 07:37:49 hristov
120 Legacy lines commented
122 Revision 1.48 2001/05/10 18:14:25 barbera
125 Revision 1.47 2001/05/10 17:55:59 barbera
126 Modified to create rec points also for PPR geometries
128 Revision 1.46 2001/05/10 00:05:28 nilsen
129 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
130 should probably be cleaned up to only check to make sure that fITSgeom has
131 been properly defined.
133 Revision 1.45 2001/05/01 22:35:48 nilsen
134 Remove/commented a number of cout<< statements. and made change needed by
137 Revision 1.44 2001/04/26 22:44:01 nilsen
138 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
139 done properly in AliITSv???.cxx via SetDefaults.
141 Revision 1.43 2001/04/26 13:22:52 barbera
142 TMatrix and TVector elimininated to speed up the code
144 Revision 1.42 2001/04/25 21:55:12 barbera
145 Updated version to be compatible with actual verion of STEER and TPC
147 Revision 1.41 2001/04/21 15:16:51 barbera
148 Updated with the new SSD reconstruction code
150 Revision 1.40 2001/03/17 15:07:06 mariana
151 Update SDD response parameters
153 Revision 1.39 2001/03/12 17:45:32 hristov
154 Changes needed on Sun with CC 5.0
156 Revision 1.38 2001/03/07 14:04:51 barbera
157 Some vector dimensions increased to cope with full events
159 Revision 1.37 2001/03/07 12:36:35 barbera
160 A change added in the tracking part to manage delta rays
162 Revision 1.36 2001/03/02 19:44:11 barbera
163 modified to taking into account new version tracking v1
165 Revision 1.35 2001/02/28 18:16:46 mariana
166 Make the code compatible with the new AliRun
168 Revision 1.34 2001/02/11 15:51:39 mariana
169 Set protection in MakeBranch
171 Revision 1.33 2001/02/10 22:26:39 mariana
172 Move the initialization of the containers for raw clusters in MakeTreeC()
174 Revision 1.32 2001/02/08 23:55:31 nilsen
175 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
176 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
178 Revision 1.31 2001/02/02 23:57:28 nilsen
179 Added include file that are no londer included in AliITSgeom.h
181 Revision 1.30 2001/01/30 09:23:13 hristov
182 Streamers removed (R.Brun)
184 Revision 1.29 2001/01/26 20:01:09 hristov
185 Major upgrade of AliRoot code
187 Revision 1.28 2000/12/18 14:02:00 barbera
188 new version of the ITS tracking to take into account the new TPC track parametrization
190 Revision 1.27 2000/12/08 13:49:27 barbera
191 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
193 Revision 1.26 2000/11/27 13:12:13 barbera
194 New version containing the files for tracking
196 Revision 1.25 2000/11/12 22:38:05 barbera
197 Added header file for the SPD Bari model
199 Revision 1.24 2000/10/09 22:18:12 barbera
200 Bug fixes from MAriana to le AliITStest.C run correctly
202 Revision 1.23 2000/10/05 20:47:42 nilsen
203 fixed dependencies of include files. Tryed but failed to get a root automaticly
204 generates streamer function to work. Modified SetDefaults.
206 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
207 Needed to include stdlib.h
210 Revision 1.22 2000/10/04 19:45:52 barbera
211 Corrected by F. Carminati for v3.04
213 Revision 1.21 2000/10/02 21:28:08 fca
214 Removal of useless dependecies via forward declarations
216 Revision 1.20 2000/10/02 16:31:39 barbera
217 General code clean-up
219 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
220 General code clean-up (e.g., printf -> cout)
222 Revision 1.19 2000/09/22 12:13:25 nilsen
223 Patches and updates for fixes to this and other routines.
225 Revision 1.18 2000/07/12 05:32:20 fca
226 Correcting several syntax problem with static members
228 Revision 1.17 2000/07/10 16:07:18 fca
229 Release version of ITS code
231 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
232 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
234 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
235 //fixed FillModule. Removed fi(fabs(xl)<dx....
237 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
238 This is the version of the files after the merging done in December 1999.
239 See the ReadMe110100.txt file for details
241 Revision 1.9 1999/11/14 14:33:25 fca
242 Correct problems with distructors and pointers, thanks to I.Hrivnacova
244 Revision 1.8 1999/09/29 09:24:19 fca
245 Introduction of the Copyright and cvs Log
249 ///////////////////////////////////////////////////////////////////////////////
251 // An overview of the basic philosophy of the ITS code development
252 // and analysis is show in the figure below.
255 <img src="picts/ITS/ITS_Analysis_schema.gif">
258 <font size=+2 color=red>
259 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
260 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
266 // AliITS. Inner Traking System base class.
267 // This class contains the base procedures for the Inner Tracking System
271 <img src="picts/ITS/AliITS_Class_Diagram.gif">
274 <font size=+2 color=red>
275 <p>This show the class diagram of the different elements that are part of
283 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
286 // Modified and documented by Bjorn S. Nilsen
290 // Modified and documented by A. Bologna
293 // AliITS is the general base class for the ITS. Also see AliDetector for
294 // futher information.
296 ///////////////////////////////////////////////////////////////////////////////
297 #include <Riostream.h>
303 #include <TClonesArray.h>
305 #include <TObjectTable.h>
311 #include "AliHeader.h"
314 #include "AliITSDetType.h"
315 #include "AliITSresponseSPD.h"
316 #include "AliITSresponseSDD.h"
317 #include "AliITSresponseSSD.h"
318 #include "AliITSsegmentationSPD.h"
319 #include "AliITSsegmentationSDD.h"
320 #include "AliITSsegmentationSSD.h"
321 #include "AliITSsimulationSPD.h"
322 #include "AliITSsimulationSDD.h"
323 #include "AliITSsimulationSSD.h"
324 #include "AliITSClusterFinderSPD.h"
325 #include "AliITSClusterFinderSDD.h"
326 #include "AliITSClusterFinderSSD.h"
327 #include "AliITShit.h"
328 #include "AliITSgeom.h"
329 #include "AliITSpList.h"
330 #include "AliITSdigit.h"
331 #include "AliITSmodule.h"
332 #include "AliITSRecPoint.h"
333 #include "AliITSRawCluster.h"
337 //______________________________________________________________________
338 AliITS::AliITS() : AliDetector() {
339 // Default initializer for ITS
340 // The default constructor of the AliITS class. In addition to
341 // creating the AliITS class it zeros the variables fIshunt (a member
342 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
343 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
352 fIshunt = 0; // not zeroed in AliDetector.
359 // SetDetectors(); // default to fOpt="All". This variable not written out.
365 fNDetTypes = kNTYPES;
381 SetMarkerColor(kRed);
383 //______________________________________________________________________
384 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
385 // The standard Constructor for the ITS class. In addition to
386 // creating the AliITS class, it allocates memory for the TClonesArrays
387 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
388 // (clusters). It also zeros the variables
389 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
390 // the pointers fIdSens and fIdName. To help in displaying hits via the
391 // ROOT macro display.C AliITS also sets the marker color to red. The
392 // variables passes with this constructor, const char *name and *title,
393 // are used by the constructor of AliDetector class. See AliDetector
394 // class for a description of these parameters and its constructor
397 // const char *name Detector name. Should always be "ITS"
398 // const char *title Detector title.
404 fIshunt = 0; // not zeroed in AliDetector
405 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
406 gAlice->AddHitList(fHits); // Not done in AliDetector.
411 SetDetectors(); // default to fOpt="All". This variable not written out.
417 fNDetTypes = kNTYPES;
418 fDetTypes = new TObjArray(fNDetTypes);
420 fSDigits = new TClonesArray("AliITSpListItem",1000);
423 fNdtype = new Int_t[fNDetTypes];
424 fDtype = new TObjArray(fNDetTypes);
426 fCtype = new TObjArray(fNDetTypes);
427 fNctype = new Int_t[fNDetTypes];
430 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
434 for(i=0;i<fNDetTypes;i++) {
435 fDetTypes->AddAt(new AliITSDetType(),i);
440 SetMarkerColor(kRed);
442 //______________________________________________________________________
444 // Default destructor for ITS.
445 // The default destructor of the AliITS class. In addition to deleting
446 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
447 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
448 // fITSpoints, fDetType and it's contents.
456 delete fHits; fHits=0;
457 delete fSDigits; fSDigits=0;
458 // delete fDigits; fDigits=0;
459 delete fRecPoints; fRecPoints=0;
460 if(fIdName!=0) delete[] fIdName; // Array of TStrings
461 if(fIdSens!=0) delete[] fIdSens;
463 this->ClearModules();
465 }// end if fITSmodules!=0
481 } // end if fDetTypes
483 if (fTreeC) delete fTreeC;
485 if (fITSgeom) delete fITSgeom;
487 //______________________________________________________________________
488 AliITS::AliITS(AliITS &source){
489 // Copy constructor. This is a function which is not allowed to be
490 // done to the ITS. It exits with an error.
492 // AliITS &source An AliITS class.
498 if(this==&source) return;
499 Error("Copy constructor",
500 "You are not allowed to make a copy of the AliITS");
503 //______________________________________________________________________
504 AliITS& AliITS::operator=(AliITS &source){
505 // Assignment operator. This is a function which is not allowed to be
506 // done to the ITS. It exits with an error.
508 // AliITS &source An AliITS class.
514 if(this==&source) return *this;
515 Error("operator=","You are not allowed to make a copy of the AliITS");
517 return *this; //fake return
519 //______________________________________________________________________
520 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
521 // Distance from mouse to ITS on the screen. Dummy routine
522 // A dummy routine used by the ROOT macro display.C to allow for the
523 // use of the mouse (pointing device) in the macro. In general this should
524 // never be called. If it is it returns the number 9999 for any value of
527 // Int_t Dummy screen coordinate.
528 // Int_t Dummy screen coordinate.
532 // Int_t Dummy = 9999 distance to ITS.
536 //______________________________________________________________________
538 // Initializer ITS after it has been built
539 // This routine initializes the AliITS class. It is intended to be
540 // called from the Init function in AliITSv?. Besides displaying a banner
541 // indicating that it has been called it initializes the array fIdSens
542 // and sets the default segmentation, response, digit and raw cluster
543 // classes therefore it should be called after a call to CreateGeometry.
554 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
556 //______________________________________________________________________
557 void AliITS::SetDefaults(){
558 // sets the default segmentation, response, digit and raw cluster classes.
566 if(fDebug) printf("%s: SetDefaults\n",ClassName());
568 AliITSDetType *iDetType;
572 if (!iDetType->GetSegmentationModel()) {
573 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
574 SetSegmentationModel(0,seg0);
576 if (!iDetType->GetResponseModel()) {
577 SetResponseModel(0,new AliITSresponseSPD());
579 // set digit and raw cluster classes to be used
581 const char *kData0=(iDetType->GetResponseModel())->DataType();
582 if (strstr(kData0,"real")) {
583 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
584 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
588 if (!iDetType->GetResponseModel()) {
589 SetResponseModel(1,new AliITSresponseSDD("simulated"));
591 AliITSresponse *resp1=iDetType->GetResponseModel();
592 if (!iDetType->GetSegmentationModel()) {
593 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
594 SetSegmentationModel(1,seg1);
596 const char *kData1=(iDetType->GetResponseModel())->DataType();
597 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
598 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
599 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
600 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
604 if (!iDetType->GetSegmentationModel()) {
605 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
606 SetSegmentationModel(2,seg2);
608 if (!iDetType->GetResponseModel()) {
609 SetResponseModel(2,new AliITSresponseSSD("simulated"));
611 const char *kData2=(iDetType->GetResponseModel())->DataType();
612 if (strstr(kData2,"real")) {
613 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
614 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
617 Warning("SetDefaults",
618 "Only the three basic detector types are initialized!");
621 //______________________________________________________________________
622 void AliITS::SetDefaultSimulation(){
623 // sets the default simulation.
631 AliITSDetType *iDetType;
632 AliITSsimulation *sim;
634 sim = iDetType->GetSimulationModel();
636 AliITSsegmentation *seg0=
637 (AliITSsegmentation*)iDetType->GetSegmentationModel();
638 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
639 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
640 SetSimulationModel(0,sim0);
641 }else{ // simulation exists, make sure it is set up properly.
642 ((AliITSsimulationSPD*)sim)->Init(
643 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
644 (AliITSresponseSPD*) iDetType->GetResponseModel());
645 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
646 // (AliITSresponse*)iDetType->GetResponseModel());
647 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
648 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
651 sim = iDetType->GetSimulationModel();
653 AliITSsegmentation *seg1=
654 (AliITSsegmentation*)iDetType->GetSegmentationModel();
655 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
656 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
657 SetSimulationModel(1,sim1);
658 }else{ // simulation exists, make sure it is set up properly.
659 ((AliITSsimulationSDD*)sim)->Init(
660 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
661 (AliITSresponseSDD*) iDetType->GetResponseModel());
662 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
663 // (AliITSresponse*)iDetType->GetResponseModel());
664 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
665 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
668 sim = iDetType->GetSimulationModel();
670 AliITSsegmentation *seg2=
671 (AliITSsegmentation*)iDetType->GetSegmentationModel();
672 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
673 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
674 SetSimulationModel(2,sim2);
675 }else{ // simulation exists, make sure it is set up properly.
676 ((AliITSsimulationSSD*)sim)->Init(
677 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
678 (AliITSresponseSSD*) iDetType->GetResponseModel());
679 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
680 // (AliITSresponse*)iDetType->GetResponseModel());
681 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
682 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
685 //______________________________________________________________________
686 void AliITS::SetDefaultClusterFinders(){
687 // Sets the default cluster finders. Used in finding RecPoints.
696 AliITSDetType *iDetType;
700 if (!iDetType->GetReconstructionModel()) {
701 AliITSsegmentation *seg0 =
702 (AliITSsegmentation*)iDetType->GetSegmentationModel();
703 TClonesArray *dig0=DigitsAddress(0);
704 TClonesArray *recp0=ClustersAddress(0);
705 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
707 SetReconstructionModel(0,rec0);
712 if (!iDetType->GetReconstructionModel()) {
713 AliITSsegmentation *seg1 =
714 (AliITSsegmentation*)iDetType->GetSegmentationModel();
715 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
716 TClonesArray *dig1=DigitsAddress(1);
717 TClonesArray *recp1=ClustersAddress(1);
718 AliITSClusterFinderSDD *rec1 =
719 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
720 SetReconstructionModel(1,rec1);
725 if (!iDetType->GetReconstructionModel()) {
726 AliITSsegmentation *seg2=
727 (AliITSsegmentation*)iDetType->GetSegmentationModel();
728 TClonesArray *dig2=DigitsAddress(2);
729 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
730 SetReconstructionModel(2,rec2);
733 //______________________________________________________________________
734 void AliITS::MakeBranch(Option_t* option, const char *file){
735 // Creates Tree branches for the ITS.
737 // Option_t *option String of Tree types S,D, and/or R.
738 // const char *file String of the file name where these branches
739 // are to be stored. If blank then these branches
740 // are written to the same tree as the Hits were
746 Bool_t cS = (strstr(option,"S")!=0);
747 Bool_t cD = (strstr(option,"D")!=0);
748 Bool_t cR = (strstr(option,"R")!=0);
749 Bool_t cRF = (strstr(option,"RF")!=0);
752 AliDetector::MakeBranch(option,file);
754 if(cS) MakeBranchS(file);
755 if(cD) MakeBranchD(file);
756 if(cR) MakeBranchR(file);
757 if(cRF) MakeBranchRF(file);
759 //______________________________________________________________________
760 void AliITS::SetTreeAddress(){
761 // Set branch address for the Trees.
768 TTree *treeS = gAlice->TreeS();
769 TTree *treeD = gAlice->TreeD();
770 TTree *treeR = gAlice->TreeR();
772 AliDetector::SetTreeAddress();
774 SetTreeAddressS(treeS);
775 SetTreeAddressD(treeD);
776 SetTreeAddressR(treeR);
778 //______________________________________________________________________
779 AliITSDetType* AliITS::DetType(Int_t id){
780 // Return pointer to id detector type.
782 // Int_t id detector id number.
786 // returned, a pointer to a AliITSDetType.
788 return ((AliITSDetType*) fDetTypes->At(id));
790 //______________________________________________________________________
791 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
792 // Set the response model for the id detector type.
794 // Int_t id detector id number.
795 // AliITSresponse* a pointer containing an instance of AliITSresponse
796 // to be stored/owned b y AliITSDetType.
802 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
804 //______________________________________________________________________
805 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
806 // Set the segmentation model for the id detector type.
808 // Int_t id detector id number.
809 // AliITSsegmentation* a pointer containing an instance of
810 // AliITSsegmentation to be stored/owned b y
817 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
819 //______________________________________________________________________
820 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
821 // Set the simulation model for the id detector type.
823 // Int_t id detector id number.
824 // AliITSresponse* a pointer containing an instance of AliITSresponse
825 // to be stored/owned b y AliITSDetType.
831 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
834 //______________________________________________________________________
835 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
836 // Set the cluster finder model for the id detector type.
838 // Int_t id detector id number.
839 // AliITSClusterFinder* a pointer containing an instance of
840 // AliITSClusterFinder to be stored/owned b y
847 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
849 //______________________________________________________________________
850 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
851 // Set the digit and cluster classes name to be used for the id detector
854 // Int_t id detector id number.
855 // const char *digit Digit class name for detector id.
856 // const char *cluster Cluster class name for detector id.
862 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
864 //______________________________________________________________________
865 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
867 // The function to add information to the AliITShit class. See the
868 // AliITShit class for a full description. This function allocates the
869 // necessary new space for the hit information and passes the variable
870 // track, and the pointers *vol and *hits to the AliITShit constructor
873 // Int_t track Track number which produced this hit.
874 // Int_t *vol Array of Integer Hit information. See AliITShit.h
875 // Float_t *hits Array of Floating Hit information. see AliITShit.h
881 TClonesArray &lhits = *fHits;
882 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
884 //______________________________________________________________________
885 void AliITS::InitModules(Int_t size,Int_t &nmodules){
886 // Initialize the modules array.
888 // Int_t size Size of array of the number of modules to be
889 // created. If size <=0 then the number of modules
890 // is gotten from AliITSgeom class kept in fITSgeom.
892 // Int_t &nmodules The number of modules existing.
897 fITSmodules->Delete();
899 } // end fir fITSmoudles
901 Int_t nl,indexMAX,index;
903 if(size<=0){ // default to using data stored in AliITSgeom
905 Error("InitModules","fITSgeom not defined");
907 } // end if fITSgeom==0
908 nl = fITSgeom->GetNlayers();
909 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
910 fITSgeom->GetNdetectors(nl))+1;
912 fITSmodules = new TObjArray(indexMAX);
913 for(index=0;index<indexMAX;index++){
914 fITSmodules->AddAt( new AliITSmodule(index),index);
917 fITSmodules = new TObjArray(size);
918 for(index=0;index<size;index++) {
919 fITSmodules->AddAt( new AliITSmodule(index),index);
925 //______________________________________________________________________
926 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
927 Option_t *option,Text_t *filename){
928 // fill the modules with the sorted by module hits; add hits from
929 // background if option=Add.
931 // Int_t evnt Event to be processed.
932 // Int_t bgrev Background Hit tree number.
933 // Int_t nmodules Not used.
934 // Option_t *option String indicating if merging hits or not. To
935 // merge hits set equal to "Add". Otherwise no
936 // background hits are considered.
937 // Test_t *filename File name containing the background hits..
942 static TTree *trH1; //Tree with background hits
943 // static TClonesArray *fHits2; //List of hits for one track only
944 static Bool_t first=kTRUE;
946 const char *addBgr = strstr(option,"Add");
950 file=new TFile(filename);
951 // fHits2 = new TClonesArray("AliITShit",1000 );
956 // Get Hits Tree header from file
957 // if(fHits2) fHits2->Clear();
958 if(trH1) delete trH1;
962 sprintf(treeName,"TreeH%d",bgrev);
963 trH1 = (TTree*)gDirectory->Get(treeName);
965 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
967 // Set branch addresses
971 sprintf(branchname,"%s",GetName());
972 if (trH1 && fHits2) {
973 branch = trH1->GetBranch(branchname);
974 if (branch) branch->SetAddress(&fHits2);
975 } // end if trH1 && fHits
979 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
981 TClonesArray *itsHits = this->Hits();
982 Int_t lay,lad,det,index;
985 TTree *iTH = gAlice->TreeH();
986 Int_t ntracks =(Int_t) iTH->GetEntries();
988 for(t=0; t<ntracks; t++){
991 Int_t nhits = itsHits->GetEntriesFast();
992 if (!nhits) continue;
993 for(h=0; h<nhits; h++){
994 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
995 itsHit->GetDetectorID(lay,lad,det);
996 // temporarily index=det-1 !!!
997 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1000 mod = this->GetModule(index);
1001 mod->AddHit(itsHit,t,h);
1002 } // end loop over hits
1003 } // end loop over tracks
1005 // open the file with background
1008 FillModules(trH1,10000000); // Default mask 10M.
1011 ntracks =(Int_t)trH1->GetEntries();
1013 for (track=0; track<ntracks; track++) {
1014 if (fHits2) fHits2->Clear();
1015 trH1->GetEvent(track);
1017 for(i=0;i<fHits2->GetEntriesFast();++i) {
1018 itsHit=(AliITShit*) (*fHits2)[i];
1019 itsHit->GetDetectorID(lay,lad,det);
1020 // temporarily index=det-1 !!!
1021 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1024 mod = this->GetModule(index);
1025 mod->AddHit(itsHit,track,i);
1026 } // end loop over hits
1027 } // end loop over tracks
1029 TTree *fAli=gAlice->TreeK();
1031 if (fAli) fileAli =fAli->GetCurrentFile();
1035 //______________________________________________________________________
1036 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1037 // fill the modules with the sorted by module hits;
1038 // can be called many times to do a merging
1040 // TTree *treeH The tree containing the hits to be copied into
1042 // Int_t mask The track number mask to indecate which file
1043 // this hits came from.
1049 Int_t lay,lad,det,index;
1050 AliITShit *itsHit=0;
1051 AliITSmodule *mod=0;
1052 char branchname[20];
1053 sprintf(branchname,"%s",GetName());
1054 TBranch *branch = treeH->GetBranch(branchname);
1056 Error("FillModules","%s branch in TreeH not found",branchname);
1059 branch->SetAddress(&fHits);
1060 Int_t nTracks =(Int_t) treeH->GetEntries();
1062 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1064 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1065 if (nBytes <= 0) continue;
1066 Int_t nHits = fHits->GetEntriesFast();
1067 for(h=0; h<nHits; h++){
1068 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1069 itsHit->GetDetectorID(lay,lad,det);
1071 index = fITSgeom->GetModuleIndex(lay,lad,det);
1073 index=det-1; // This should not be used.
1074 } // end if [You must have fITSgeom for this to work!]
1075 mod = GetModule(index);
1076 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1077 mod->AddHit(itsHit,iPrimTrack,h);
1078 } // end loop over hits
1079 } // end loop over tracks
1081 //______________________________________________________________________
1082 void AliITS::ClearModules(){
1083 // Clear the modules TObjArray.
1089 if(fITSmodules) fITSmodules->Delete();
1091 //______________________________________________________________________
1092 void AliITS::MakeBranchS(const char *fl){
1093 // Creates Tree Branch for the ITS summable digits.
1095 // cont char *fl File name where SDigits branch is to be written
1096 // to. If blank it write the SDigits to the same
1097 // file in which the Hits were found.
1102 Int_t buffersize = 4000;
1103 char branchname[30];
1105 // only one branch for SDigits.
1106 sprintf(branchname,"%s",GetName());
1107 if(fSDigits && gAlice->TreeS()){
1108 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1111 //______________________________________________________________________
1112 void AliITS::SetTreeAddressS(TTree *treeS){
1113 // Set branch address for the ITS summable digits Trees.
1115 // TTree *treeS Tree containing the SDigits.
1120 char branchname[30];
1124 sprintf(branchname,"%s",GetName());
1125 branch = treeS->GetBranch(branchname);
1126 if (branch) branch->SetAddress(&fSDigits);
1128 //______________________________________________________________________
1129 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1130 // Creates Tree branches for the ITS.
1132 // TTree *treeD Pointer to the Digits Tree.
1133 // cont char *file File name where Digits branch is to be written
1134 // to. If blank it write the SDigits to the same
1135 // file in which the Hits were found.
1140 Int_t buffersize = 4000;
1141 char branchname[30];
1143 sprintf(branchname,"%s",GetName());
1144 // one branch for digits per type of detector
1145 const char *det[3] = {"SPD","SDD","SSD"};
1149 for (i=0; i<kNTYPES ;i++) {
1150 DetType(i)->GetClassNames(digclass,clclass);
1152 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1153 else ResetDigits(i);
1155 for (i=0; i<kNTYPES ;i++) {
1156 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1157 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1158 if (fDtype && treeD) {
1159 MakeBranchInTree(treeD,
1160 branchname, &((*fDtype)[i]),buffersize,file);
1164 //______________________________________________________________________
1165 void AliITS::SetTreeAddressD(TTree *treeD){
1166 // Set branch address for the Trees.
1168 // TTree *treeD Tree containing the Digits.
1173 char branchname[30];
1174 const char *det[3] = {"SPD","SDD","SSD"};
1181 for (i=0; i<kNTYPES; i++) {
1182 DetType(i)->GetClassNames(digclass,clclass);
1184 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1185 else ResetDigits(i);
1186 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1187 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1189 branch = treeD->GetBranch(branchname);
1190 if (branch) branch->SetAddress(&((*fDtype)[i]));
1194 //______________________________________________________________________
1195 void AliITS::Hits2SDigits(){
1196 // Standard Hits to summable Digits function.
1202 // return; // Using Hits in place of the larger sDigits.
1203 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1204 // Do the Hits to Digits operation. Use Standard input values.
1205 // Event number from file, no background hit merging , use size from
1206 // AliITSgeom class, option="All", input from this file only.
1207 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1209 //______________________________________________________________________
1210 void AliITS::Hits2PreDigits(){
1211 // Standard Hits to summable Digits function.
1217 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1218 // Do the Hits to Digits operation. Use Standard input values.
1219 // Event number from file, no background hit merging , use size from
1220 // AliITSgeom class, option="All", input from this file only.
1221 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1223 //______________________________________________________________________
1224 void AliITS::SDigitsToDigits(Option_t *opt){
1225 // Standard Summable digits to Digits function.
1230 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1232 if(!GetITSgeom()) return; // need transformations to do digitization.
1233 AliITSgeom *geom = GetITSgeom();
1235 const char *all = strstr(opt,"All");
1236 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1238 if( !det[0] && !det[1] && !det[2] ) all = "All";
1240 static Bool_t setDef=kTRUE;
1241 if (setDef) SetDefaultSimulation();
1244 AliITSsimulation *sim = 0;
1245 AliITSDetType *iDetType = 0;
1246 TTree *trees = gAlice->TreeS();
1247 if( !(trees && this->GetSDigits()) ){
1248 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1251 sprintf( name, "%s", this->GetName() );
1252 TBranch *brchSDigits = trees->GetBranch( name );
1255 for(module=0;module<geom->GetIndexMax();module++){
1256 id = geom->GetModuleType(module);
1257 if (!all && !det[id]) continue;
1258 iDetType = DetType(id);
1259 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1261 Error("SDigit2Digits",
1262 "The simulation class was not instanciated!");
1265 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1267 // add summable digits to module
1268 this->GetSDigits()->Clear();
1269 brchSDigits->GetEvent(module);
1270 sim->AddSDigitsToModule(GetSDigits(),0);
1272 // Digitise current module sum(SDigits)->Digits
1273 sim->FinishSDigitiseModule();
1275 // fills all branches - wasted disk space
1276 gAlice->TreeD()->Fill();
1277 this->ResetDigits();
1280 gAlice->TreeD()->GetEntries();
1282 gAlice->TreeD()->AutoSave();
1284 gAlice->TreeD()->Reset();
1287 //______________________________________________________________________
1288 void AliITS::Hits2Digits(){
1289 // Standard Hits to Digits function.
1295 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1296 // Do the Hits to Digits operation. Use Standard input values.
1297 // Event number from file, no background hit merging , use size from
1298 // AliITSgeom class, option="All", input from this file only.
1299 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1301 //______________________________________________________________________
1302 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1303 Option_t *option, Option_t *opt,Text_t *filename){
1304 // keep galice.root for signal and name differently the file for
1305 // background when add! otherwise the track info for signal will be lost !
1306 // the condition below will disappear when the geom class will be
1307 // initialized for all versions - for the moment it is only for v5 !
1308 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1311 // Int_t evnt Event to be processed.
1312 // Int_t bgrev Background Hit tree number.
1313 // Int_t nmodules Not used.
1314 // Option_t *option String indicating if merging hits or not. To
1315 // merge hits set equal to "Add". Otherwise no
1316 // background hits are considered.
1317 // Test_t *filename File name containing the background hits..
1322 // return; // using Hits instead of the larger sdigits.
1324 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1326 //______________________________________________________________________
1327 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1328 Option_t *option, Option_t *opt,Text_t *filename){
1329 // Keep galice.root for signal and name differently the file for
1330 // background when add! otherwise the track info for signal will be lost !
1331 // the condition below will disappear when the geom class will be
1332 // initialized for all versions - for the moment it is only for v5 !
1333 // 7 is the SDD beam test version.
1335 // Int_t evnt Event to be processed.
1336 // Int_t bgrev Background Hit tree number.
1337 // Int_t nmodules Not used.
1338 // Option_t *option String indicating if merging hits or not. To
1339 // merge hits set equal to "Add". Otherwise no
1340 // background hits are considered.
1341 // Test_t *filename File name containing the background hits..
1347 if(!GetITSgeom()) return; // need transformations to do digitization.
1348 AliITSgeom *geom = GetITSgeom();
1350 const char *all = strstr(opt,"All");
1351 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1353 static Bool_t setDef=kTRUE;
1354 if (setDef) SetDefaultSimulation();
1358 InitModules(size,nmodules);
1359 FillModules(evNumber,bgrev,nmodules,option,filename);
1361 AliITSsimulation *sim = 0;
1362 AliITSDetType *iDetType = 0;
1363 AliITSmodule *mod = 0;
1365 for(module=0;module<geom->GetIndexMax();module++){
1366 id = geom->GetModuleType(module);
1367 if (!all && !det[id]) continue;
1368 iDetType = DetType(id);
1369 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1371 Error("HitsToSDigits",
1372 "The simulation class was not instanciated!");
1375 mod = (AliITSmodule *)fITSmodules->At(module);
1376 sim->SDigitiseModule(mod,module,evNumber);
1377 // fills all branches - wasted disk space
1378 gAlice->TreeS()->Fill();
1384 gAlice->TreeS()->GetEntries();
1385 gAlice->TreeS()->AutoSave();
1387 gAlice->TreeS()->Reset();
1389 //______________________________________________________________________
1390 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1391 Option_t *option, Option_t *opt,Text_t *filename){
1392 // Keep galice.root for signal and name differently the file for
1393 // background when add! otherwise the track info for signal will be lost !
1394 // the condition below will disappear when the geom class will be
1395 // initialized for all versions - for the moment it is only for v5 !
1396 // 7 is the SDD beam test version.
1398 // Int_t evnt Event to be processed.
1399 // Int_t bgrev Background Hit tree number.
1400 // Int_t nmodules Not used.
1401 // Option_t *option String indicating if merging hits or not. To
1402 // merge hits set equal to "Add". Otherwise no
1403 // background hits are considered.
1404 // Test_t *filename File name containing the background hits..
1410 if(!GetITSgeom()) return; // need transformations to do digitization.
1411 AliITSgeom *geom = GetITSgeom();
1413 const char *all = strstr(opt,"All");
1414 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1416 static Bool_t setDef=kTRUE;
1417 if (setDef) SetDefaultSimulation();
1421 InitModules(size,nmodules);
1422 FillModules(evNumber,bgrev,nmodules,option,filename);
1424 AliITSsimulation *sim = 0;
1425 AliITSDetType *iDetType = 0;
1426 AliITSmodule *mod = 0;
1428 for(module=0;module<geom->GetIndexMax();module++){
1429 id = geom->GetModuleType(module);
1430 if (!all && !det[id]) continue;
1431 iDetType = DetType(id);
1432 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1434 Error("HitsToDigits",
1435 "The simulation class was not instanciated!");
1438 mod = (AliITSmodule *)fITSmodules->At(module);
1439 sim->DigitiseModule(mod,module,evNumber);
1440 // fills all branches - wasted disk space
1441 gAlice->TreeD()->Fill();
1447 gAlice->TreeD()->GetEntries();
1448 gAlice->TreeD()->AutoSave();
1450 gAlice->TreeD()->Reset();
1452 //______________________________________________________________________
1453 void AliITS::ResetSDigits(){
1454 // Reset the Summable Digits array.
1460 if (fSDigits) fSDigits->Clear();
1463 //______________________________________________________________________
1464 void AliITS::ResetDigits(){
1465 // Reset number of digits and the digits array for the ITS detector.
1471 if (!fDtype) return;
1474 for (i=0;i<kNTYPES;i++ ) {
1475 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1476 if (fNdtype) fNdtype[i]=0;
1479 //______________________________________________________________________
1480 void AliITS::ResetDigits(Int_t i){
1481 // Reset number of digits and the digits array for this branch.
1487 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1488 if (fNdtype) fNdtype[i]=0;
1490 //______________________________________________________________________
1491 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1492 // Adds the a module full of summable digits to the summable digits tree.
1494 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1500 TClonesArray &lsdig = *fSDigits;
1501 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1503 //______________________________________________________________________
1504 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1505 // Add a real digit - as coming from data.
1507 // Int_t id Detector type number.
1508 // Int_t *digits Integer array containing the digits info. See
1515 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1516 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1518 //______________________________________________________________________
1519 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1520 // Add a simulated digit.
1522 // Int_t id Detector type number.
1523 // AliITSdigit *d Digit to be added to the Digits Tree. See
1530 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1534 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1537 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1540 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1544 //______________________________________________________________________
1545 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1546 Int_t *hits,Float_t *charges){
1547 // Add a simulated digit to the list.
1549 // Int_t id Detector type number.
1550 // Float_t phys Physics indicator. See AliITSdigits.h
1551 // Int_t *digits Integer array containing the digits info. See
1553 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1554 // containing the track numbers that contributed to
1556 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1557 // containing the hit numbers, from AliITSmodule, that
1558 // contributed to this digit.
1559 // Float_t *charge Floating point array of the signals contributed
1560 // to this digit by each track.
1566 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1569 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1572 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1576 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1580 //______________________________________________________________________
1581 void AliITS::MakeTreeC(Option_t *option){
1582 // Create a separate tree to store the clusters.
1584 // Option_t *option string which must contain "C" otherwise
1585 // no Cluster Tree is created.
1590 TDirectory *cwd = gDirectory;
1591 TFile *fileRecPoints = gAlice->GetTreeRFile();
1592 if(fileRecPoints)fileRecPoints->cd();
1593 const char *optC = strstr(option,"C");
1595 Int_t cureve = gAlice->GetEvNumber();
1596 sprintf(hname,"TreeC%d",cureve);
1598 const char *curname = fTreeC->GetName();
1599 char *exists = strstr(hname,curname);
1605 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1608 Int_t buffersize = 4000;
1609 char branchname[30];
1610 const char *det[3] = {"SPD","SDD","SSD"};
1614 // one branch for Clusters per type of detector
1616 for (i=0; i<kNTYPES ;i++) {
1617 AliITSDetType *iDetType=DetType(i);
1618 iDetType->GetClassNames(digclass,clclass);
1620 if(!ClustersAddress(i)){
1621 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1623 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1624 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1625 if (fCtype && fTreeC) {
1626 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1627 } // end if fCtype && fTreeC
1631 //______________________________________________________________________
1632 void AliITS::GetTreeC(Int_t event){
1633 // Get the clusters tree for this event and set the branch address.
1635 // Int_t event Event number for the cluster tree.
1641 char branchname[30];
1642 const char *det[3] = {"SPD","SDD","SSD"};
1649 sprintf(treeName,"TreeC%d",event);
1650 TFile *fileRecPoints = gAlice->GetTreeRFile();
1652 fTreeC = (TTree*)gDirectory->Get(treeName);
1655 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1664 for (i=0; i<kNTYPES; i++) {
1665 AliITSDetType *iDetType=DetType(i);
1666 iDetType->GetClassNames(digclass,clclass);
1668 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1669 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1670 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1672 branch = fTreeC->GetBranch(branchname);
1673 if (branch) branch->SetAddress(&((*fCtype)[i]));
1677 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1680 //______________________________________________________________________
1681 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1682 // Add a cluster to the list.
1684 // Int_t id Detector type number.
1685 // AliITSRawCluster *c Cluster class to be added to the tree of
1692 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1696 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1699 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1702 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1706 //______________________________________________________________________
1707 void AliITS::ResetClusters(){
1708 // Reset number of clusters and the clusters array for ITS.
1715 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1717 //______________________________________________________________________
1718 void AliITS::ResetClusters(Int_t i){
1719 // Reset number of clusters and the clusters array for this branch.
1721 // Int_t i Detector type number.
1727 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1728 if (fNctype) fNctype[i]=0;
1730 //______________________________________________________________________
1731 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1732 // Creates Tree branches for the ITS Reconstructed points.
1734 // cont char *file File name where RecPoints branch is to be written
1735 // to. If blank it write the SDigits to the same
1736 // file in which the Hits were found.
1741 Int_t buffsz = 4000;
1742 char branchname[30];
1744 // only one branch for rec points for all detector types
1745 Bool_t oFast= (strstr(opt,"Fast")!=0);
1747 sprintf(branchname,"%sRecPointsF",GetName());
1749 sprintf(branchname,"%sRecPoints",GetName());
1751 if (fRecPoints && gAlice->TreeR()) {
1752 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1755 //______________________________________________________________________
1756 void AliITS::SetTreeAddressR(TTree *treeR){
1757 // Set branch address for the Reconstructed points Trees.
1759 // TTree *treeR Tree containing the RecPoints.
1764 char branchname[30];
1768 sprintf(branchname,"%sRecPoints",GetName());
1769 branch = treeR->GetBranch(branchname);
1771 branch->SetAddress(&fRecPoints);
1774 sprintf(branchname,"%sRecPointsF",GetName());
1775 branch = treeR->GetBranch(branchname);
1777 branch->SetAddress(&fRecPoints);
1781 //______________________________________________________________________
1782 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1783 // Add a reconstructed space point to the list
1785 // const AliITSRecPoint &r RecPoint class to be added to the tree
1786 // of reconstructed points TreeR.
1792 TClonesArray &lrecp = *fRecPoints;
1793 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1795 //______________________________________________________________________
1796 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1797 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1798 // keep galice.root for signal and name differently the file for
1799 // background when add! otherwise the track info for signal will be lost !
1800 // the condition below will disappear when the geom class will be
1801 // initialized for all versions - for the moment it is only for v5 !
1803 // Int_t evnt Event to be processed.
1804 // Int_t bgrev Background Hit tree number.
1805 // Int_t size Size used by InitModules. See InitModules.
1806 // Option_t *opt0 Option passed to FillModules. See FillModules.
1807 // Option_t *opt1 String indicating if merging hits or not. To
1808 // merge hits set equal to "Add". Otherwise no
1809 // background hits are considered.
1810 // Test_t *flnm File name containing the background hits..
1816 if(!GetITSgeom()) return;
1817 AliITSgeom *geom = GetITSgeom();
1819 const char *all = strstr(opt1,"All");
1820 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1821 strstr(opt1,"SSD")};
1823 InitModules(size,nmodules);
1824 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1826 AliITSsimulation *sim = 0;
1827 AliITSDetType *iDetType = 0;
1828 AliITSmodule *mod = 0;
1831 //m.b. : this change is nothing but a nice way to make sure
1833 for(module=0;module<geom->GetIndexMax();module++){
1834 id = geom->GetModuleType(module);
1835 if (!all && !det[id]) continue;
1836 iDetType = DetType(id);
1837 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1839 Error("HitsToFastPoints",
1840 "The simulation class was not instanciated!");
1843 mod = (AliITSmodule *)fITSmodules->At(module);
1844 sim->CreateFastRecPoints(mod,module,gRandom);
1845 // gAlice->TreeR()->Fill();
1846 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1853 gAlice->TreeR()->AutoSave();
1855 gAlice->TreeR()->Reset();
1857 //______________________________________________________________________
1858 void AliITS::Digits2Reco(){
1859 // Find clusters and reconstruct space points.
1865 AliHeader *header=gAlice->GetHeader();
1866 // to Digits to RecPoints for event in file, all digits in file, and
1867 // all ITS detectors.
1868 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1870 //______________________________________________________________________
1871 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1872 // cluster finding and reconstruction of space points
1873 // the condition below will disappear when the geom class will be
1874 // initialized for all versions - for the moment it is only for v5 !
1875 // 7 is the SDD beam test version
1877 // Int_t evNumber Event number to be processed.
1878 // Int_t lastentry Offset for module when not all of the modules
1880 // Option_t *opt String indicating which ITS sub-detectors should
1881 // be processed. If ="All" then all of the ITS
1882 // sub detectors are processed.
1888 if(!GetITSgeom()) return;
1889 AliITSgeom *geom = GetITSgeom();
1891 const char *all = strstr(opt,"All");
1892 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1894 static Bool_t setRec=kTRUE;
1895 if (setRec) SetDefaultClusterFinders();
1898 TTree *treeC=TreeC();
1899 AliITSClusterFinder *rec = 0;
1900 AliITSDetType *iDetType = 0;
1901 Int_t id,module,first=0;
1902 for(module=0;module<geom->GetIndexMax();module++){
1903 id = geom->GetModuleType(module);
1904 if (!all && !det[id]) continue;
1905 if(det[id]) first = geom->GetStartDet(id);
1906 iDetType = DetType(id);
1907 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1908 TClonesArray *itsDigits = this->DigitsAddress(id);
1910 Error("DigitsToRecPoints",
1911 "The reconstruction class was not instanciated!");
1914 this->ResetDigits();
1915 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1916 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1917 Int_t ndigits = itsDigits->GetEntriesFast();
1918 if (ndigits) rec->FindRawClusters(module);
1919 gAlice->TreeR()->Fill();
1925 gAlice->TreeR()->GetEntries();
1926 treeC->GetEntries();
1927 gAlice->TreeR()->AutoSave();
1929 gAlice->TreeR()->Reset();
1934 //______________________________________________________________________
1935 void AliITS::ResetRecPoints(){
1936 // Reset number of rec points and the rec points array.
1942 if (fRecPoints) fRecPoints->Clear();