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.72 2002/06/10 17:28:55 nilsen
19 Added new FillModules routine and cleaned up the old one.
21 Revision 1.71 2002/05/13 14:27:56 hristov
22 TreeC created once per event (M.Masera)
24 Revision 1.70 2002/05/10 22:28:30 nilsen
25 Changes by Massimo Masera to allow the TTree of clusters to be written to a
26 file otherthan the one with digits in it.
28 Revision 1.69 2002/05/05 21:06:55 nilsen
29 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
30 proper initilization when a simulation has already been defined.
32 Revision 1.68 2002/05/02 18:51:53 nilsen
34 Method MakeBranchR has now a second argument, with a default value:
35 Option_t *opt=" ". Opt="Fast" is to create a separate branch
36 for fast points in TreeR
37 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
40 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
42 2) Changes in MakeBranchR to allow the creation of a special branch
45 Revision 1.67 2002/03/15 17:22:51 nilsen
46 Intoduced SDigits2Digits and SDigitsToDigits functions.
48 Revision 1.66 2001/11/28 01:35:45 nilsen
49 Using standard constructors instead of default constructors for Clusterfinder,
50 Response, and FastSimulator.
52 Revision 1.65 2001/11/27 16:27:28 nilsen
53 Adding AliITSDigitizer class to do merging and digitization . Based on the
54 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
55 file. The following files required minor changes. AliITS, added functions
56 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
57 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
58 the original Root Directory in function Compress1D. Now it uses gDirectory.
60 Revision 1.64 2001/11/19 16:17:02 nilsen
61 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
62 bugs found by Rene require more work to fix. Will be fixed soon.
64 Revision 1.63 2001/10/24 21:16:34 nilsen
65 Removed some dead code and improved comments/documntation.
67 Revision 1.62 2001/10/21 19:23:21 nilsen
68 Added function to allow to limit which detectors to digitize and reconstruct.
69 The default is All. This change makes no changes to any root file.
71 Revision 1.61 2001/10/11 15:26:07 mariana
72 Correct HitsToFastRecPoints
74 Revision 1.60 2001/10/04 22:38:10 nilsen
75 Changes made to support PreDigits (SDigits) plus other helpful changes.
77 Revision 1.59 2001/08/30 09:56:18 hristov
78 The operator[] is replaced by At() or AddAt() in case of TObjArray.
80 Revision 1.58 2001/07/26 15:05:29 hristov
81 Use global gRandom generator (M.Ivanov)
83 Revision 1.57 2001/07/24 14:26:11 mariana
84 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
86 Revision 1.56 2001/07/05 12:49:49 mariana
87 Temporary patches required by root.v3.01.05
89 Revision 1.55 2001/06/14 14:59:00 barbera
90 Tracking V1 decoupled from AliITS
92 Revision 1.54 2001/05/31 20:37:56 barbera
93 Bari/Salerno model set as defaault SPD simulation
95 Revision 1.53 2001/05/31 18:52:24 barbera
96 Bari model becomes the default
98 Revision 1.53 2001/05/30 07:52:24 hristov
99 TPC and CONTAINERS included in the search path
101 Revision 1.52 2001/05/30 06:04:58 hristov
102 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
104 Revision 1.51 2001/05/16 14:57:15 alibrary
105 New files for folders and Stack
107 Revision 1.50 2001/05/11 09:15:21 barbera
108 Corrected to make fast point creation working with PPR geometry
110 Revision 1.49 2001/05/11 07:37:49 hristov
111 Legacy lines commented
113 Revision 1.48 2001/05/10 18:14:25 barbera
116 Revision 1.47 2001/05/10 17:55:59 barbera
117 Modified to create rec points also for PPR geometries
119 Revision 1.46 2001/05/10 00:05:28 nilsen
120 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
121 should probably be cleaned up to only check to make sure that fITSgeom has
122 been properly defined.
124 Revision 1.45 2001/05/01 22:35:48 nilsen
125 Remove/commented a number of cout<< statements. and made change needed by
128 Revision 1.44 2001/04/26 22:44:01 nilsen
129 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
130 done properly in AliITSv???.cxx via SetDefaults.
132 Revision 1.43 2001/04/26 13:22:52 barbera
133 TMatrix and TVector elimininated to speed up the code
135 Revision 1.42 2001/04/25 21:55:12 barbera
136 Updated version to be compatible with actual verion of STEER and TPC
138 Revision 1.41 2001/04/21 15:16:51 barbera
139 Updated with the new SSD reconstruction code
141 Revision 1.40 2001/03/17 15:07:06 mariana
142 Update SDD response parameters
144 Revision 1.39 2001/03/12 17:45:32 hristov
145 Changes needed on Sun with CC 5.0
147 Revision 1.38 2001/03/07 14:04:51 barbera
148 Some vector dimensions increased to cope with full events
150 Revision 1.37 2001/03/07 12:36:35 barbera
151 A change added in the tracking part to manage delta rays
153 Revision 1.36 2001/03/02 19:44:11 barbera
154 modified to taking into account new version tracking v1
156 Revision 1.35 2001/02/28 18:16:46 mariana
157 Make the code compatible with the new AliRun
159 Revision 1.34 2001/02/11 15:51:39 mariana
160 Set protection in MakeBranch
162 Revision 1.33 2001/02/10 22:26:39 mariana
163 Move the initialization of the containers for raw clusters in MakeTreeC()
165 Revision 1.32 2001/02/08 23:55:31 nilsen
166 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
167 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
169 Revision 1.31 2001/02/02 23:57:28 nilsen
170 Added include file that are no londer included in AliITSgeom.h
172 Revision 1.30 2001/01/30 09:23:13 hristov
173 Streamers removed (R.Brun)
175 Revision 1.29 2001/01/26 20:01:09 hristov
176 Major upgrade of AliRoot code
178 Revision 1.28 2000/12/18 14:02:00 barbera
179 new version of the ITS tracking to take into account the new TPC track parametrization
181 Revision 1.27 2000/12/08 13:49:27 barbera
182 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
184 Revision 1.26 2000/11/27 13:12:13 barbera
185 New version containing the files for tracking
187 Revision 1.25 2000/11/12 22:38:05 barbera
188 Added header file for the SPD Bari model
190 Revision 1.24 2000/10/09 22:18:12 barbera
191 Bug fixes from MAriana to le AliITStest.C run correctly
193 Revision 1.23 2000/10/05 20:47:42 nilsen
194 fixed dependencies of include files. Tryed but failed to get a root automaticly
195 generates streamer function to work. Modified SetDefaults.
197 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
198 Needed to include stdlib.h
201 Revision 1.22 2000/10/04 19:45:52 barbera
202 Corrected by F. Carminati for v3.04
204 Revision 1.21 2000/10/02 21:28:08 fca
205 Removal of useless dependecies via forward declarations
207 Revision 1.20 2000/10/02 16:31:39 barbera
208 General code clean-up
210 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
211 General code clean-up (e.g., printf -> cout)
213 Revision 1.19 2000/09/22 12:13:25 nilsen
214 Patches and updates for fixes to this and other routines.
216 Revision 1.18 2000/07/12 05:32:20 fca
217 Correcting several syntax problem with static members
219 Revision 1.17 2000/07/10 16:07:18 fca
220 Release version of ITS code
222 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
223 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
225 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
226 //fixed FillModule. Removed fi(fabs(xl)<dx....
228 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
229 This is the version of the files after the merging done in December 1999.
230 See the ReadMe110100.txt file for details
232 Revision 1.9 1999/11/14 14:33:25 fca
233 Correct problems with distructors and pointers, thanks to I.Hrivnacova
235 Revision 1.8 1999/09/29 09:24:19 fca
236 Introduction of the Copyright and cvs Log
240 ///////////////////////////////////////////////////////////////////////////////
242 // An overview of the basic philosophy of the ITS code development
243 // and analysis is show in the figure below.
246 <img src="picts/ITS/ITS_Analysis_schema.gif">
249 <font size=+2 color=red>
250 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
251 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
257 // AliITS. Inner Traking System base class.
258 // This class contains the base procedures for the Inner Tracking System
262 <img src="picts/ITS/AliITS_Class_Diagram.gif">
265 <font size=+2 color=red>
266 <p>This show the class diagram of the different elements that are part of
274 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
277 // Modified and documented by Bjorn S. Nilsen
281 // Modified and documented by A. Bologna
284 // AliITS is the general base class for the ITS. Also see AliDetector for
285 // futher information.
287 ///////////////////////////////////////////////////////////////////////////////
288 #include <iostream.h>
296 #include <TClonesArray.h>
298 #include <TObjectTable.h>
304 #include "AliHeader.h"
307 #include "AliITSDetType.h"
308 #include "AliITSresponseSPD.h"
309 #include "AliITSresponseSDD.h"
310 #include "AliITSresponseSSD.h"
311 #include "AliITSsegmentationSPD.h"
312 #include "AliITSsegmentationSDD.h"
313 #include "AliITSsegmentationSSD.h"
314 #include "AliITSsimulationSPD.h"
315 #include "AliITSsimulationSDD.h"
316 #include "AliITSsimulationSSD.h"
317 #include "AliITSClusterFinderSPD.h"
318 #include "AliITSClusterFinderSDD.h"
319 #include "AliITSClusterFinderSSD.h"
320 #include "AliITShit.h"
321 #include "AliITSgeom.h"
322 #include "AliITSpList.h"
323 #include "AliITSdigit.h"
324 #include "AliITSmodule.h"
325 #include "AliITSRecPoint.h"
326 #include "AliITSRawCluster.h"
330 //______________________________________________________________________
331 AliITS::AliITS() : AliDetector() {
332 // Default initializer for ITS
333 // The default constructor of the AliITS class. In addition to
334 // creating the AliITS class it zeros the variables fIshunt (a member
335 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
336 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
345 fIshunt = 0; // not zeroed in AliDetector.
352 // SetDetectors(); // default to fOpt="All". This variable not written out.
358 fNDetTypes = kNTYPES;
374 SetMarkerColor(kRed);
376 //______________________________________________________________________
377 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
378 // The standard Constructor for the ITS class. In addition to
379 // creating the AliITS class, it allocates memory for the TClonesArrays
380 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
381 // (clusters). It also zeros the variables
382 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
383 // the pointers fIdSens and fIdName. To help in displaying hits via the
384 // ROOT macro display.C AliITS also sets the marker color to red. The
385 // variables passes with this constructor, const char *name and *title,
386 // are used by the constructor of AliDetector class. See AliDetector
387 // class for a description of these parameters and its constructor
390 // const char *name Detector name. Should always be "ITS"
391 // const char *title Detector title.
397 fIshunt = 0; // not zeroed in AliDetector
398 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
399 gAlice->AddHitList(fHits); // Not done in AliDetector.
404 SetDetectors(); // default to fOpt="All". This variable not written out.
410 fNDetTypes = kNTYPES;
411 fDetTypes = new TObjArray(fNDetTypes);
413 fSDigits = new TClonesArray("AliITSpListItem",1000);
416 fNdtype = new Int_t[fNDetTypes];
417 fDtype = new TObjArray(fNDetTypes);
419 fCtype = new TObjArray(fNDetTypes);
420 fNctype = new Int_t[fNDetTypes];
423 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
427 for(i=0;i<fNDetTypes;i++) {
428 fDetTypes->AddAt(new AliITSDetType(),i);
433 SetMarkerColor(kRed);
435 //______________________________________________________________________
437 // Default destructor for ITS.
438 // The default destructor of the AliITS class. In addition to deleting
439 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
440 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
441 // fITSpoints, fDetType and it's contents.
449 delete fHits; fHits=0;
450 delete fSDigits; fSDigits=0;
451 // delete fDigits; fDigits=0;
452 delete fRecPoints; fRecPoints=0;
453 if(fIdName!=0) delete[] fIdName; // Array of TStrings
454 if(fIdSens!=0) delete[] fIdSens;
456 this->ClearModules();
458 }// end if fITSmodules!=0
474 } // end if fDetTypes
476 if (fTreeC) delete fTreeC;
478 if (fITSgeom) delete fITSgeom;
480 //______________________________________________________________________
481 AliITS::AliITS(AliITS &source){
482 // Copy constructor. This is a function which is not allowed to be
483 // done to the ITS. It exits with an error.
485 // AliITS &source An AliITS class.
491 if(this==&source) return;
492 Error("Copy constructor",
493 "You are not allowed to make a copy of the AliITS");
496 //______________________________________________________________________
497 AliITS& AliITS::operator=(AliITS &source){
498 // Assignment operator. This is a function which is not allowed to be
499 // done to the ITS. It exits with an error.
501 // AliITS &source An AliITS class.
507 if(this==&source) return *this;
508 Error("operator=","You are not allowed to make a copy of the AliITS");
510 return *this; //fake return
512 //______________________________________________________________________
513 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
514 // Distance from mouse to ITS on the screen. Dummy routine
515 // A dummy routine used by the ROOT macro display.C to allow for the
516 // use of the mouse (pointing device) in the macro. In general this should
517 // never be called. If it is it returns the number 9999 for any value of
520 // Int_t Dummy screen coordinate.
521 // Int_t Dummy screen coordinate.
525 // Int_t Dummy = 9999 distance to ITS.
529 //______________________________________________________________________
531 // Initializer ITS after it has been built
532 // This routine initializes the AliITS class. It is intended to be
533 // called from the Init function in AliITSv?. Besides displaying a banner
534 // indicating that it has been called it initializes the array fIdSens
535 // and sets the default segmentation, response, digit and raw cluster
536 // classes therefore it should be called after a call to CreateGeometry.
547 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
549 //______________________________________________________________________
550 void AliITS::SetDefaults(){
551 // sets the default segmentation, response, digit and raw cluster classes.
559 if(fDebug) printf("%s: SetDefaults\n",ClassName());
561 AliITSDetType *iDetType;
565 if (!iDetType->GetSegmentationModel()) {
566 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
567 SetSegmentationModel(0,seg0);
569 if (!iDetType->GetResponseModel()) {
570 SetResponseModel(0,new AliITSresponseSPD());
572 // set digit and raw cluster classes to be used
574 const char *kData0=(iDetType->GetResponseModel())->DataType();
575 if (strstr(kData0,"real")) {
576 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
577 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
581 if (!iDetType->GetResponseModel()) {
582 SetResponseModel(1,new AliITSresponseSDD("simulated"));
584 AliITSresponse *resp1=iDetType->GetResponseModel();
585 if (!iDetType->GetSegmentationModel()) {
586 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
587 SetSegmentationModel(1,seg1);
589 const char *kData1=(iDetType->GetResponseModel())->DataType();
590 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
591 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
592 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
593 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
597 if (!iDetType->GetSegmentationModel()) {
598 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
599 SetSegmentationModel(2,seg2);
601 if (!iDetType->GetResponseModel()) {
602 SetResponseModel(2,new AliITSresponseSSD("simulated"));
604 const char *kData2=(iDetType->GetResponseModel())->DataType();
605 if (strstr(kData2,"real")) {
606 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
607 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
610 Warning("SetDefaults",
611 "Only the three basic detector types are initialized!");
614 //______________________________________________________________________
615 void AliITS::SetDefaultSimulation(){
616 // sets the default simulation.
624 AliITSDetType *iDetType;
625 AliITSsimulation *sim;
627 sim = iDetType->GetSimulationModel();
629 AliITSsegmentation *seg0=
630 (AliITSsegmentation*)iDetType->GetSegmentationModel();
631 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
632 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
633 SetSimulationModel(0,sim0);
634 }else{ // simulation exists, make sure it is set up properly.
635 ((AliITSsimulationSPD*)sim)->Init(
636 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
637 (AliITSresponseSPD*) iDetType->GetResponseModel());
638 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
639 // (AliITSresponse*)iDetType->GetResponseModel());
640 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
641 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
644 sim = iDetType->GetSimulationModel();
646 AliITSsegmentation *seg1=
647 (AliITSsegmentation*)iDetType->GetSegmentationModel();
648 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
649 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
650 SetSimulationModel(1,sim1);
651 }else{ // simulation exists, make sure it is set up properly.
652 ((AliITSsimulationSDD*)sim)->Init(
653 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
654 (AliITSresponseSDD*) iDetType->GetResponseModel());
655 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
656 // (AliITSresponse*)iDetType->GetResponseModel());
657 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
658 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
661 sim = iDetType->GetSimulationModel();
663 AliITSsegmentation *seg2=
664 (AliITSsegmentation*)iDetType->GetSegmentationModel();
665 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
666 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
667 SetSimulationModel(2,sim2);
668 }else{ // simulation exists, make sure it is set up properly.
669 ((AliITSsimulationSSD*)sim)->Init(
670 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
671 (AliITSresponseSSD*) iDetType->GetResponseModel());
672 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
673 // (AliITSresponse*)iDetType->GetResponseModel());
674 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
675 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
678 //______________________________________________________________________
679 void AliITS::SetDefaultClusterFinders(){
680 // Sets the default cluster finders. Used in finding RecPoints.
689 AliITSDetType *iDetType;
693 if (!iDetType->GetReconstructionModel()) {
694 AliITSsegmentation *seg0 =
695 (AliITSsegmentation*)iDetType->GetSegmentationModel();
696 TClonesArray *dig0=DigitsAddress(0);
697 TClonesArray *recp0=ClustersAddress(0);
698 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
700 SetReconstructionModel(0,rec0);
705 if (!iDetType->GetReconstructionModel()) {
706 AliITSsegmentation *seg1 =
707 (AliITSsegmentation*)iDetType->GetSegmentationModel();
708 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
709 TClonesArray *dig1=DigitsAddress(1);
710 TClonesArray *recp1=ClustersAddress(1);
711 AliITSClusterFinderSDD *rec1 =
712 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
713 SetReconstructionModel(1,rec1);
718 if (!iDetType->GetReconstructionModel()) {
719 AliITSsegmentation *seg2=
720 (AliITSsegmentation*)iDetType->GetSegmentationModel();
721 TClonesArray *dig2=DigitsAddress(2);
722 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
723 SetReconstructionModel(2,rec2);
726 //______________________________________________________________________
727 void AliITS::MakeBranch(Option_t* option, const char *file){
728 // Creates Tree branches for the ITS.
730 // Option_t *option String of Tree types S,D, and/or R.
731 // const char *file String of the file name where these branches
732 // are to be stored. If blank then these branches
733 // are written to the same tree as the Hits were
739 Bool_t cS = (strstr(option,"S")!=0);
740 Bool_t cD = (strstr(option,"D")!=0);
741 Bool_t cR = (strstr(option,"R")!=0);
742 Bool_t cRF = (strstr(option,"RF")!=0);
745 AliDetector::MakeBranch(option,file);
747 if(cS) MakeBranchS(file);
748 if(cD) MakeBranchD(file);
749 if(cR) MakeBranchR(file);
750 if(cRF) MakeBranchRF(file);
752 //______________________________________________________________________
753 void AliITS::SetTreeAddress(){
754 // Set branch address for the Trees.
761 TTree *treeS = gAlice->TreeS();
762 TTree *treeD = gAlice->TreeD();
763 TTree *treeR = gAlice->TreeR();
765 AliDetector::SetTreeAddress();
767 SetTreeAddressS(treeS);
768 SetTreeAddressD(treeD);
769 SetTreeAddressR(treeR);
771 //______________________________________________________________________
772 AliITSDetType* AliITS::DetType(Int_t id){
773 // Return pointer to id detector type.
775 // Int_t id detector id number.
779 // returned, a pointer to a AliITSDetType.
781 return ((AliITSDetType*) fDetTypes->At(id));
783 //______________________________________________________________________
784 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
785 // Set the response model for the id detector type.
787 // Int_t id detector id number.
788 // AliITSresponse* a pointer containing an instance of AliITSresponse
789 // to be stored/owned b y AliITSDetType.
795 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
797 //______________________________________________________________________
798 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
799 // Set the segmentation model for the id detector type.
801 // Int_t id detector id number.
802 // AliITSsegmentation* a pointer containing an instance of
803 // AliITSsegmentation to be stored/owned b y
810 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
812 //______________________________________________________________________
813 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
814 // Set the simulation model for the id detector type.
816 // Int_t id detector id number.
817 // AliITSresponse* a pointer containing an instance of AliITSresponse
818 // to be stored/owned b y AliITSDetType.
824 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
827 //______________________________________________________________________
828 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
829 // Set the cluster finder model for the id detector type.
831 // Int_t id detector id number.
832 // AliITSClusterFinder* a pointer containing an instance of
833 // AliITSClusterFinder to be stored/owned b y
840 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
842 //______________________________________________________________________
843 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
844 // Set the digit and cluster classes name to be used for the id detector
847 // Int_t id detector id number.
848 // const char *digit Digit class name for detector id.
849 // const char *cluster Cluster class name for detector id.
855 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
857 //______________________________________________________________________
858 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
860 // The function to add information to the AliITShit class. See the
861 // AliITShit class for a full description. This function allocates the
862 // necessary new space for the hit information and passes the variable
863 // track, and the pointers *vol and *hits to the AliITShit constructor
866 // Int_t track Track number which produced this hit.
867 // Int_t *vol Array of Integer Hit information. See AliITShit.h
868 // Float_t *hits Array of Floating Hit information. see AliITShit.h
874 TClonesArray &lhits = *fHits;
875 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
877 //______________________________________________________________________
878 void AliITS::InitModules(Int_t size,Int_t &nmodules){
879 // Initialize the modules array.
881 // Int_t size Size of array of the number of modules to be
882 // created. If size <=0 then the number of modules
883 // is gotten from AliITSgeom class kept in fITSgeom.
885 // Int_t &nmodules The number of modules existing.
890 fITSmodules->Delete();
892 } // end fir fITSmoudles
894 Int_t nl,indexMAX,index;
896 if(size<=0){ // default to using data stored in AliITSgeom
898 Error("InitModules","fITSgeom not defined");
900 } // end if fITSgeom==0
901 nl = fITSgeom->GetNlayers();
902 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
903 fITSgeom->GetNdetectors(nl))+1;
905 fITSmodules = new TObjArray(indexMAX);
906 for(index=0;index<indexMAX;index++){
907 fITSmodules->AddAt( new AliITSmodule(index),index);
910 fITSmodules = new TObjArray(size);
911 for(index=0;index<size;index++) {
912 fITSmodules->AddAt( new AliITSmodule(index),index);
918 //______________________________________________________________________
919 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
920 Option_t *option,Text_t *filename){
921 // fill the modules with the sorted by module hits; add hits from
922 // background if option=Add.
924 // Int_t evnt Event to be processed.
925 // Int_t bgrev Background Hit tree number.
926 // Int_t nmodules Not used.
927 // Option_t *option String indicating if merging hits or not. To
928 // merge hits set equal to "Add". Otherwise no
929 // background hits are considered.
930 // Test_t *filename File name containing the background hits..
935 static TTree *trH1; //Tree with background hits
936 // static TClonesArray *fHits2; //List of hits for one track only
937 static Bool_t first=kTRUE;
939 const char *addBgr = strstr(option,"Add");
943 file=new TFile(filename);
944 // fHits2 = new TClonesArray("AliITShit",1000 );
949 // Get Hits Tree header from file
950 // if(fHits2) fHits2->Clear();
951 if(trH1) delete trH1;
955 sprintf(treeName,"TreeH%d",bgrev);
956 trH1 = (TTree*)gDirectory->Get(treeName);
958 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
960 // Set branch addresses
964 sprintf(branchname,"%s",GetName());
965 if (trH1 && fHits2) {
966 branch = trH1->GetBranch(branchname);
967 if (branch) branch->SetAddress(&fHits2);
968 } // end if trH1 && fHits
972 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
974 TClonesArray *itsHits = this->Hits();
975 Int_t lay,lad,det,index;
978 TTree *iTH = gAlice->TreeH();
979 Int_t ntracks =(Int_t) iTH->GetEntries();
981 for(t=0; t<ntracks; t++){
984 Int_t nhits = itsHits->GetEntriesFast();
985 if (!nhits) continue;
986 for(h=0; h<nhits; h++){
987 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
988 itsHit->GetDetectorID(lay,lad,det);
989 // temporarily index=det-1 !!!
990 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
993 mod = this->GetModule(index);
994 mod->AddHit(itsHit,t,h);
995 } // end loop over hits
996 } // end loop over tracks
998 // open the file with background
1001 FillModules(trH1,10000000); // Default mask 10M.
1004 ntracks =(Int_t)trH1->GetEntries();
1006 for (track=0; track<ntracks; track++) {
1007 if (fHits2) fHits2->Clear();
1008 trH1->GetEvent(track);
1010 for(i=0;i<fHits2->GetEntriesFast();++i) {
1011 itsHit=(AliITShit*) (*fHits2)[i];
1012 itsHit->GetDetectorID(lay,lad,det);
1013 // temporarily index=det-1 !!!
1014 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1017 mod = this->GetModule(index);
1018 mod->AddHit(itsHit,track,i);
1019 } // end loop over hits
1020 } // end loop over tracks
1022 TTree *fAli=gAlice->TreeK();
1024 if (fAli) fileAli =fAli->GetCurrentFile();
1028 //______________________________________________________________________
1029 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1030 // fill the modules with the sorted by module hits;
1031 // can be called many times to do a merging
1033 // TTree *treeH The tree containing the hits to be copied into
1035 // Int_t mask The track number mask to indecate which file
1036 // this hits came from.
1042 Int_t lay,lad,det,index;
1043 AliITShit *itsHit=0;
1044 AliITSmodule *mod=0;
1045 char branchname[20];
1046 sprintf(branchname,"%s",GetName());
1047 TBranch *branch = treeH->GetBranch(branchname);
1049 Error("FillModules","%s branch in TreeH not found",branchname);
1052 branch->SetAddress(&fHits);
1053 Int_t nTracks =(Int_t) treeH->GetEntries();
1055 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1057 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1058 if (nBytes <= 0) continue;
1059 Int_t nHits = fHits->GetEntriesFast();
1060 for(h=0; h<nHits; h++){
1061 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1062 itsHit->GetDetectorID(lay,lad,det);
1064 index = fITSgeom->GetModuleIndex(lay,lad,det);
1066 index=det-1; // This should not be used.
1067 } // end if [You must have fITSgeom for this to work!]
1068 mod = GetModule(index);
1069 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1070 mod->AddHit(itsHit,iPrimTrack,h);
1071 } // end loop over hits
1072 } // end loop over tracks
1074 //______________________________________________________________________
1075 void AliITS::ClearModules(){
1076 // Clear the modules TObjArray.
1082 if(fITSmodules) fITSmodules->Delete();
1084 //______________________________________________________________________
1085 void AliITS::MakeBranchS(const char *fl){
1086 // Creates Tree Branch for the ITS summable digits.
1088 // cont char *fl File name where SDigits branch is to be written
1089 // to. If blank it write the SDigits to the same
1090 // file in which the Hits were found.
1095 Int_t buffersize = 4000;
1096 char branchname[30];
1098 // only one branch for SDigits.
1099 sprintf(branchname,"%s",GetName());
1100 if(fSDigits && gAlice->TreeS()){
1101 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1104 //______________________________________________________________________
1105 void AliITS::SetTreeAddressS(TTree *treeS){
1106 // Set branch address for the ITS summable digits Trees.
1108 // TTree *treeS Tree containing the SDigits.
1113 char branchname[30];
1117 sprintf(branchname,"%s",GetName());
1118 branch = treeS->GetBranch(branchname);
1119 if (branch) branch->SetAddress(&fSDigits);
1121 //______________________________________________________________________
1122 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1123 // Creates Tree branches for the ITS.
1125 // TTree *treeD Pointer to the Digits Tree.
1126 // cont char *file File name where Digits branch is to be written
1127 // to. If blank it write the SDigits to the same
1128 // file in which the Hits were found.
1133 Int_t buffersize = 4000;
1134 char branchname[30];
1136 sprintf(branchname,"%s",GetName());
1137 // one branch for digits per type of detector
1138 const char *det[3] = {"SPD","SDD","SSD"};
1142 for (i=0; i<kNTYPES ;i++) {
1143 DetType(i)->GetClassNames(digclass,clclass);
1145 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1146 else ResetDigits(i);
1148 for (i=0; i<kNTYPES ;i++) {
1149 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1150 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1151 if (fDtype && treeD) {
1152 MakeBranchInTree(treeD,
1153 branchname, &((*fDtype)[i]),buffersize,file);
1157 //______________________________________________________________________
1158 void AliITS::SetTreeAddressD(TTree *treeD){
1159 // Set branch address for the Trees.
1161 // TTree *treeD Tree containing the Digits.
1166 char branchname[30];
1167 const char *det[3] = {"SPD","SDD","SSD"};
1174 for (i=0; i<kNTYPES; i++) {
1175 DetType(i)->GetClassNames(digclass,clclass);
1177 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1178 else ResetDigits(i);
1179 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1180 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1182 branch = treeD->GetBranch(branchname);
1183 if (branch) branch->SetAddress(&((*fDtype)[i]));
1187 //______________________________________________________________________
1188 void AliITS::Hits2SDigits(){
1189 // Standard Hits to summable Digits function.
1195 // return; // Using Hits in place of the larger sDigits.
1196 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1197 // Do the Hits to Digits operation. Use Standard input values.
1198 // Event number from file, no background hit merging , use size from
1199 // AliITSgeom class, option="All", input from this file only.
1200 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1202 //______________________________________________________________________
1203 void AliITS::Hits2PreDigits(){
1204 // Standard Hits to summable Digits function.
1210 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1211 // Do the Hits to Digits operation. Use Standard input values.
1212 // Event number from file, no background hit merging , use size from
1213 // AliITSgeom class, option="All", input from this file only.
1214 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1216 //______________________________________________________________________
1217 void AliITS::SDigitsToDigits(Option_t *opt){
1218 // Standard Summable digits to Digits function.
1223 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1225 if(!GetITSgeom()) return; // need transformations to do digitization.
1226 AliITSgeom *geom = GetITSgeom();
1228 const char *all = strstr(opt,"All");
1229 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1231 if( !det[0] && !det[1] && !det[2] ) all = "All";
1233 static Bool_t setDef=kTRUE;
1234 if (setDef) SetDefaultSimulation();
1237 AliITSsimulation *sim = 0;
1238 AliITSDetType *iDetType = 0;
1239 TTree *trees = gAlice->TreeS();
1240 if( !(trees && this->GetSDigits()) ){
1241 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1244 sprintf( name, "%s", this->GetName() );
1245 TBranch *brchSDigits = trees->GetBranch( name );
1248 for(module=0;module<geom->GetIndexMax();module++){
1249 id = geom->GetModuleType(module);
1250 if (!all && !det[id]) continue;
1251 iDetType = DetType(id);
1252 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1254 Error("SDigit2Digits",
1255 "The simulation class was not instanciated!");
1258 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1260 // add summable digits to module
1261 this->GetSDigits()->Clear();
1262 brchSDigits->GetEvent(module);
1263 sim->AddSDigitsToModule(GetSDigits(),0);
1265 // Digitise current module sum(SDigits)->Digits
1266 sim->FinishSDigitiseModule();
1268 // fills all branches - wasted disk space
1269 gAlice->TreeD()->Fill();
1270 this->ResetDigits();
1273 gAlice->TreeD()->GetEntries();
1275 gAlice->TreeD()->AutoSave();
1277 gAlice->TreeD()->Reset();
1280 //______________________________________________________________________
1281 void AliITS::Hits2Digits(){
1282 // Standard Hits to Digits function.
1288 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1289 // Do the Hits to Digits operation. Use Standard input values.
1290 // Event number from file, no background hit merging , use size from
1291 // AliITSgeom class, option="All", input from this file only.
1292 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1294 //______________________________________________________________________
1295 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1296 Option_t *option, Option_t *opt,Text_t *filename){
1297 // keep galice.root for signal and name differently the file for
1298 // background when add! otherwise the track info for signal will be lost !
1299 // the condition below will disappear when the geom class will be
1300 // initialized for all versions - for the moment it is only for v5 !
1301 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1304 // Int_t evnt Event to be processed.
1305 // Int_t bgrev Background Hit tree number.
1306 // Int_t nmodules Not used.
1307 // Option_t *option String indicating if merging hits or not. To
1308 // merge hits set equal to "Add". Otherwise no
1309 // background hits are considered.
1310 // Test_t *filename File name containing the background hits..
1315 // return; // using Hits instead of the larger sdigits.
1317 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1319 //______________________________________________________________________
1320 void AliITS::HitsToPreDigits(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.
1328 // Int_t evnt Event to be processed.
1329 // Int_t bgrev Background Hit tree number.
1330 // Int_t nmodules Not used.
1331 // Option_t *option String indicating if merging hits or not. To
1332 // merge hits set equal to "Add". Otherwise no
1333 // background hits are considered.
1334 // Test_t *filename File name containing the background hits..
1340 if(!GetITSgeom()) return; // need transformations to do digitization.
1341 AliITSgeom *geom = GetITSgeom();
1343 const char *all = strstr(opt,"All");
1344 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1346 static Bool_t setDef=kTRUE;
1347 if (setDef) SetDefaultSimulation();
1351 InitModules(size,nmodules);
1352 FillModules(evNumber,bgrev,nmodules,option,filename);
1354 AliITSsimulation *sim = 0;
1355 AliITSDetType *iDetType = 0;
1356 AliITSmodule *mod = 0;
1358 for(module=0;module<geom->GetIndexMax();module++){
1359 id = geom->GetModuleType(module);
1360 if (!all && !det[id]) continue;
1361 iDetType = DetType(id);
1362 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1364 Error("HitsToSDigits",
1365 "The simulation class was not instanciated!");
1368 mod = (AliITSmodule *)fITSmodules->At(module);
1369 sim->SDigitiseModule(mod,module,evNumber);
1370 // fills all branches - wasted disk space
1371 gAlice->TreeS()->Fill();
1377 gAlice->TreeS()->GetEntries();
1378 gAlice->TreeS()->AutoSave();
1380 gAlice->TreeS()->Reset();
1382 //______________________________________________________________________
1383 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1384 Option_t *option, Option_t *opt,Text_t *filename){
1385 // Keep galice.root for signal and name differently the file for
1386 // background when add! otherwise the track info for signal will be lost !
1387 // the condition below will disappear when the geom class will be
1388 // initialized for all versions - for the moment it is only for v5 !
1389 // 7 is the SDD beam test version.
1391 // Int_t evnt Event to be processed.
1392 // Int_t bgrev Background Hit tree number.
1393 // Int_t nmodules Not used.
1394 // Option_t *option String indicating if merging hits or not. To
1395 // merge hits set equal to "Add". Otherwise no
1396 // background hits are considered.
1397 // Test_t *filename File name containing the background hits..
1403 if(!GetITSgeom()) return; // need transformations to do digitization.
1404 AliITSgeom *geom = GetITSgeom();
1406 const char *all = strstr(opt,"All");
1407 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1409 static Bool_t setDef=kTRUE;
1410 if (setDef) SetDefaultSimulation();
1414 InitModules(size,nmodules);
1415 FillModules(evNumber,bgrev,nmodules,option,filename);
1417 AliITSsimulation *sim = 0;
1418 AliITSDetType *iDetType = 0;
1419 AliITSmodule *mod = 0;
1421 for(module=0;module<geom->GetIndexMax();module++){
1422 id = geom->GetModuleType(module);
1423 if (!all && !det[id]) continue;
1424 iDetType = DetType(id);
1425 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1427 Error("HitsToDigits",
1428 "The simulation class was not instanciated!");
1431 mod = (AliITSmodule *)fITSmodules->At(module);
1432 sim->DigitiseModule(mod,module,evNumber);
1433 // fills all branches - wasted disk space
1434 gAlice->TreeD()->Fill();
1440 gAlice->TreeD()->GetEntries();
1441 gAlice->TreeD()->AutoSave();
1443 gAlice->TreeD()->Reset();
1445 //______________________________________________________________________
1446 void AliITS::ResetSDigits(){
1447 // Reset the Summable Digits array.
1453 if (fSDigits) fSDigits->Clear();
1456 //______________________________________________________________________
1457 void AliITS::ResetDigits(){
1458 // Reset number of digits and the digits array for the ITS detector.
1464 if (!fDtype) return;
1467 for (i=0;i<kNTYPES;i++ ) {
1468 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1469 if (fNdtype) fNdtype[i]=0;
1472 //______________________________________________________________________
1473 void AliITS::ResetDigits(Int_t i){
1474 // Reset number of digits and the digits array for this branch.
1480 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1481 if (fNdtype) fNdtype[i]=0;
1483 //______________________________________________________________________
1484 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1485 // Adds the a module full of summable digits to the summable digits tree.
1487 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1493 TClonesArray &lsdig = *fSDigits;
1494 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1496 //______________________________________________________________________
1497 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1498 // Add a real digit - as coming from data.
1500 // Int_t id Detector type number.
1501 // Int_t *digits Integer array containing the digits info. See
1508 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1509 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1511 //______________________________________________________________________
1512 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1513 // Add a simulated digit.
1515 // Int_t id Detector type number.
1516 // AliITSdigit *d Digit to be added to the Digits Tree. See
1523 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1527 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1530 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1533 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1537 //______________________________________________________________________
1538 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1539 Int_t *hits,Float_t *charges){
1540 // Add a simulated digit to the list.
1542 // Int_t id Detector type number.
1543 // Float_t phys Physics indicator. See AliITSdigits.h
1544 // Int_t *digits Integer array containing the digits info. See
1546 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1547 // containing the track numbers that contributed to
1549 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1550 // containing the hit numbers, from AliITSmodule, that
1551 // contributed to this digit.
1552 // Float_t *charge Floating point array of the signals contributed
1553 // to this digit by each track.
1559 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1562 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1565 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1569 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1573 //______________________________________________________________________
1574 void AliITS::MakeTreeC(Option_t *option){
1575 // Create a separate tree to store the clusters.
1577 // Option_t *option string which must contain "C" otherwise
1578 // no Cluster Tree is created.
1583 TDirectory *cwd = gDirectory;
1584 TFile *fileRecPoints = gAlice->GetTreeRFile();
1585 if(fileRecPoints)fileRecPoints->cd();
1586 const char *optC = strstr(option,"C");
1588 Int_t cureve = gAlice->GetEvNumber();
1589 sprintf(hname,"TreeC%d",cureve);
1591 const char *curname = fTreeC->GetName();
1592 char *exists = strstr(hname,curname);
1598 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1601 Int_t buffersize = 4000;
1602 char branchname[30];
1603 const char *det[3] = {"SPD","SDD","SSD"};
1607 // one branch for Clusters per type of detector
1609 for (i=0; i<kNTYPES ;i++) {
1610 AliITSDetType *iDetType=DetType(i);
1611 iDetType->GetClassNames(digclass,clclass);
1613 if(!ClustersAddress(i)){
1614 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1616 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1617 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1618 if (fCtype && fTreeC) {
1619 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1620 } // end if fCtype && fTreeC
1624 //______________________________________________________________________
1625 void AliITS::GetTreeC(Int_t event){
1626 // Get the clusters tree for this event and set the branch address.
1628 // Int_t event Event number for the cluster tree.
1634 char branchname[30];
1635 const char *det[3] = {"SPD","SDD","SSD"};
1642 sprintf(treeName,"TreeC%d",event);
1643 TFile *fileRecPoints = gAlice->GetTreeRFile();
1645 fTreeC = (TTree*)gDirectory->Get(treeName);
1648 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1657 for (i=0; i<kNTYPES; i++) {
1658 AliITSDetType *iDetType=DetType(i);
1659 iDetType->GetClassNames(digclass,clclass);
1661 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1662 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1663 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1665 branch = fTreeC->GetBranch(branchname);
1666 if (branch) branch->SetAddress(&((*fCtype)[i]));
1670 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1673 //______________________________________________________________________
1674 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1675 // Add a cluster to the list.
1677 // Int_t id Detector type number.
1678 // AliITSRawCluster *c Cluster class to be added to the tree of
1685 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1689 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1692 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1695 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1699 //______________________________________________________________________
1700 void AliITS::ResetClusters(){
1701 // Reset number of clusters and the clusters array for ITS.
1708 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1710 //______________________________________________________________________
1711 void AliITS::ResetClusters(Int_t i){
1712 // Reset number of clusters and the clusters array for this branch.
1714 // Int_t i Detector type number.
1720 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1721 if (fNctype) fNctype[i]=0;
1723 //______________________________________________________________________
1724 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1725 // Creates Tree branches for the ITS Reconstructed points.
1727 // cont char *file File name where RecPoints branch is to be written
1728 // to. If blank it write the SDigits to the same
1729 // file in which the Hits were found.
1734 Int_t buffsz = 4000;
1735 char branchname[30];
1737 // only one branch for rec points for all detector types
1738 Bool_t oFast= (strstr(opt,"Fast")!=0);
1740 sprintf(branchname,"%sRecPointsF",GetName());
1742 sprintf(branchname,"%sRecPoints",GetName());
1744 if (fRecPoints && gAlice->TreeR()) {
1745 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1748 //______________________________________________________________________
1749 void AliITS::SetTreeAddressR(TTree *treeR){
1750 // Set branch address for the Reconstructed points Trees.
1752 // TTree *treeR Tree containing the RecPoints.
1757 char branchname[30];
1761 sprintf(branchname,"%sRecPoints",GetName());
1762 branch = treeR->GetBranch(branchname);
1764 branch->SetAddress(&fRecPoints);
1767 sprintf(branchname,"%sRecPointsF",GetName());
1768 branch = treeR->GetBranch(branchname);
1770 branch->SetAddress(&fRecPoints);
1774 //______________________________________________________________________
1775 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1776 // Add a reconstructed space point to the list
1778 // const AliITSRecPoint &r RecPoint class to be added to the tree
1779 // of reconstructed points TreeR.
1785 TClonesArray &lrecp = *fRecPoints;
1786 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1788 //______________________________________________________________________
1789 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1790 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1791 // keep galice.root for signal and name differently the file for
1792 // background when add! otherwise the track info for signal will be lost !
1793 // the condition below will disappear when the geom class will be
1794 // initialized for all versions - for the moment it is only for v5 !
1796 // Int_t evnt Event to be processed.
1797 // Int_t bgrev Background Hit tree number.
1798 // Int_t size Size used by InitModules. See InitModules.
1799 // Option_t *opt0 Option passed to FillModules. See FillModules.
1800 // Option_t *opt1 String indicating if merging hits or not. To
1801 // merge hits set equal to "Add". Otherwise no
1802 // background hits are considered.
1803 // Test_t *flnm File name containing the background hits..
1809 if(!GetITSgeom()) return;
1810 AliITSgeom *geom = GetITSgeom();
1812 const char *all = strstr(opt1,"All");
1813 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1814 strstr(opt1,"SSD")};
1816 InitModules(size,nmodules);
1817 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1819 AliITSsimulation *sim = 0;
1820 AliITSDetType *iDetType = 0;
1821 AliITSmodule *mod = 0;
1824 //m.b. : this change is nothing but a nice way to make sure
1826 for(module=0;module<geom->GetIndexMax();module++){
1827 id = geom->GetModuleType(module);
1828 if (!all && !det[id]) continue;
1829 iDetType = DetType(id);
1830 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1832 Error("HitsToFastPoints",
1833 "The simulation class was not instanciated!");
1836 mod = (AliITSmodule *)fITSmodules->At(module);
1837 sim->CreateFastRecPoints(mod,module,gRandom);
1838 // gAlice->TreeR()->Fill();
1839 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1846 gAlice->TreeR()->AutoSave();
1848 gAlice->TreeR()->Reset();
1850 //______________________________________________________________________
1851 void AliITS::Digits2Reco(){
1852 // Find clusters and reconstruct space points.
1858 AliHeader *header=gAlice->GetHeader();
1859 // to Digits to RecPoints for event in file, all digits in file, and
1860 // all ITS detectors.
1861 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1863 //______________________________________________________________________
1864 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1865 // cluster finding and reconstruction of space points
1866 // the condition below will disappear when the geom class will be
1867 // initialized for all versions - for the moment it is only for v5 !
1868 // 7 is the SDD beam test version
1870 // Int_t evNumber Event number to be processed.
1871 // Int_t lastentry Offset for module when not all of the modules
1873 // Option_t *opt String indicating which ITS sub-detectors should
1874 // be processed. If ="All" then all of the ITS
1875 // sub detectors are processed.
1881 if(!GetITSgeom()) return;
1882 AliITSgeom *geom = GetITSgeom();
1884 const char *all = strstr(opt,"All");
1885 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1887 static Bool_t setRec=kTRUE;
1888 if (setRec) SetDefaultClusterFinders();
1891 TTree *treeC=TreeC();
1892 AliITSClusterFinder *rec = 0;
1893 AliITSDetType *iDetType = 0;
1894 Int_t id,module,first=0;
1895 for(module=0;module<geom->GetIndexMax();module++){
1896 id = geom->GetModuleType(module);
1897 if (!all && !det[id]) continue;
1898 if(det[id]) first = geom->GetStartDet(id);
1899 iDetType = DetType(id);
1900 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1901 TClonesArray *itsDigits = this->DigitsAddress(id);
1903 Error("DigitsToRecPoints",
1904 "The reconstruction class was not instanciated!");
1907 this->ResetDigits();
1908 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1909 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1910 Int_t ndigits = itsDigits->GetEntriesFast();
1911 if (ndigits) rec->FindRawClusters(module);
1912 gAlice->TreeR()->Fill();
1918 gAlice->TreeR()->GetEntries();
1919 treeC->GetEntries();
1920 gAlice->TreeR()->AutoSave();
1922 gAlice->TreeR()->Reset();
1927 //______________________________________________________________________
1928 void AliITS::ResetRecPoints(){
1929 // Reset number of rec points and the rec points array.
1935 if (fRecPoints) fRecPoints->Clear();