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.71 2002/05/13 14:27:56 hristov
19 TreeC created once per event (M.Masera)
21 Revision 1.70 2002/05/10 22:28:30 nilsen
22 Changes by Massimo Masera to allow the TTree of clusters to be written to a
23 file otherthan the one with digits in it.
25 Revision 1.69 2002/05/05 21:06:55 nilsen
26 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
27 proper initilization when a simulation has already been defined.
29 Revision 1.68 2002/05/02 18:51:53 nilsen
31 Method MakeBranchR has now a second argument, with a default value:
32 Option_t *opt=" ". Opt="Fast" is to create a separate branch
33 for fast points in TreeR
34 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
37 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
39 2) Changes in MakeBranchR to allow the creation of a special branch
42 Revision 1.67 2002/03/15 17:22:51 nilsen
43 Intoduced SDigits2Digits and SDigitsToDigits functions.
45 Revision 1.66 2001/11/28 01:35:45 nilsen
46 Using standard constructors instead of default constructors for Clusterfinder,
47 Response, and FastSimulator.
49 Revision 1.65 2001/11/27 16:27:28 nilsen
50 Adding AliITSDigitizer class to do merging and digitization . Based on the
51 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
52 file. The following files required minor changes. AliITS, added functions
53 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
54 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
55 the original Root Directory in function Compress1D. Now it uses gDirectory.
57 Revision 1.64 2001/11/19 16:17:02 nilsen
58 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
59 bugs found by Rene require more work to fix. Will be fixed soon.
61 Revision 1.63 2001/10/24 21:16:34 nilsen
62 Removed some dead code and improved comments/documntation.
64 Revision 1.62 2001/10/21 19:23:21 nilsen
65 Added function to allow to limit which detectors to digitize and reconstruct.
66 The default is All. This change makes no changes to any root file.
68 Revision 1.61 2001/10/11 15:26:07 mariana
69 Correct HitsToFastRecPoints
71 Revision 1.60 2001/10/04 22:38:10 nilsen
72 Changes made to support PreDigits (SDigits) plus other helpful changes.
74 Revision 1.59 2001/08/30 09:56:18 hristov
75 The operator[] is replaced by At() or AddAt() in case of TObjArray.
77 Revision 1.58 2001/07/26 15:05:29 hristov
78 Use global gRandom generator (M.Ivanov)
80 Revision 1.57 2001/07/24 14:26:11 mariana
81 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
83 Revision 1.56 2001/07/05 12:49:49 mariana
84 Temporary patches required by root.v3.01.05
86 Revision 1.55 2001/06/14 14:59:00 barbera
87 Tracking V1 decoupled from AliITS
89 Revision 1.54 2001/05/31 20:37:56 barbera
90 Bari/Salerno model set as defaault SPD simulation
92 Revision 1.53 2001/05/31 18:52:24 barbera
93 Bari model becomes the default
95 Revision 1.53 2001/05/30 07:52:24 hristov
96 TPC and CONTAINERS included in the search path
98 Revision 1.52 2001/05/30 06:04:58 hristov
99 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
101 Revision 1.51 2001/05/16 14:57:15 alibrary
102 New files for folders and Stack
104 Revision 1.50 2001/05/11 09:15:21 barbera
105 Corrected to make fast point creation working with PPR geometry
107 Revision 1.49 2001/05/11 07:37:49 hristov
108 Legacy lines commented
110 Revision 1.48 2001/05/10 18:14:25 barbera
113 Revision 1.47 2001/05/10 17:55:59 barbera
114 Modified to create rec points also for PPR geometries
116 Revision 1.46 2001/05/10 00:05:28 nilsen
117 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
118 should probably be cleaned up to only check to make sure that fITSgeom has
119 been properly defined.
121 Revision 1.45 2001/05/01 22:35:48 nilsen
122 Remove/commented a number of cout<< statements. and made change needed by
125 Revision 1.44 2001/04/26 22:44:01 nilsen
126 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
127 done properly in AliITSv???.cxx via SetDefaults.
129 Revision 1.43 2001/04/26 13:22:52 barbera
130 TMatrix and TVector elimininated to speed up the code
132 Revision 1.42 2001/04/25 21:55:12 barbera
133 Updated version to be compatible with actual verion of STEER and TPC
135 Revision 1.41 2001/04/21 15:16:51 barbera
136 Updated with the new SSD reconstruction code
138 Revision 1.40 2001/03/17 15:07:06 mariana
139 Update SDD response parameters
141 Revision 1.39 2001/03/12 17:45:32 hristov
142 Changes needed on Sun with CC 5.0
144 Revision 1.38 2001/03/07 14:04:51 barbera
145 Some vector dimensions increased to cope with full events
147 Revision 1.37 2001/03/07 12:36:35 barbera
148 A change added in the tracking part to manage delta rays
150 Revision 1.36 2001/03/02 19:44:11 barbera
151 modified to taking into account new version tracking v1
153 Revision 1.35 2001/02/28 18:16:46 mariana
154 Make the code compatible with the new AliRun
156 Revision 1.34 2001/02/11 15:51:39 mariana
157 Set protection in MakeBranch
159 Revision 1.33 2001/02/10 22:26:39 mariana
160 Move the initialization of the containers for raw clusters in MakeTreeC()
162 Revision 1.32 2001/02/08 23:55:31 nilsen
163 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
164 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
166 Revision 1.31 2001/02/02 23:57:28 nilsen
167 Added include file that are no londer included in AliITSgeom.h
169 Revision 1.30 2001/01/30 09:23:13 hristov
170 Streamers removed (R.Brun)
172 Revision 1.29 2001/01/26 20:01:09 hristov
173 Major upgrade of AliRoot code
175 Revision 1.28 2000/12/18 14:02:00 barbera
176 new version of the ITS tracking to take into account the new TPC track parametrization
178 Revision 1.27 2000/12/08 13:49:27 barbera
179 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
181 Revision 1.26 2000/11/27 13:12:13 barbera
182 New version containing the files for tracking
184 Revision 1.25 2000/11/12 22:38:05 barbera
185 Added header file for the SPD Bari model
187 Revision 1.24 2000/10/09 22:18:12 barbera
188 Bug fixes from MAriana to le AliITStest.C run correctly
190 Revision 1.23 2000/10/05 20:47:42 nilsen
191 fixed dependencies of include files. Tryed but failed to get a root automaticly
192 generates streamer function to work. Modified SetDefaults.
194 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
195 Needed to include stdlib.h
198 Revision 1.22 2000/10/04 19:45:52 barbera
199 Corrected by F. Carminati for v3.04
201 Revision 1.21 2000/10/02 21:28:08 fca
202 Removal of useless dependecies via forward declarations
204 Revision 1.20 2000/10/02 16:31:39 barbera
205 General code clean-up
207 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
208 General code clean-up (e.g., printf -> cout)
210 Revision 1.19 2000/09/22 12:13:25 nilsen
211 Patches and updates for fixes to this and other routines.
213 Revision 1.18 2000/07/12 05:32:20 fca
214 Correcting several syntax problem with static members
216 Revision 1.17 2000/07/10 16:07:18 fca
217 Release version of ITS code
219 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
220 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
222 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
223 //fixed FillModule. Removed fi(fabs(xl)<dx....
225 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
226 This is the version of the files after the merging done in December 1999.
227 See the ReadMe110100.txt file for details
229 Revision 1.9 1999/11/14 14:33:25 fca
230 Correct problems with distructors and pointers, thanks to I.Hrivnacova
232 Revision 1.8 1999/09/29 09:24:19 fca
233 Introduction of the Copyright and cvs Log
237 ///////////////////////////////////////////////////////////////////////////////
239 // An overview of the basic philosophy of the ITS code development
240 // and analysis is show in the figure below.
243 <img src="picts/ITS/ITS_Analysis_schema.gif">
246 <font size=+2 color=red>
247 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
248 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
254 // AliITS. Inner Traking System base class.
255 // This class contains the base procedures for the Inner Tracking System
259 <img src="picts/ITS/AliITS_Class_Diagram.gif">
262 <font size=+2 color=red>
263 <p>This show the class diagram of the different elements that are part of
271 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
274 // Modified and documented by Bjorn S. Nilsen
278 // Modified and documented by A. Bologna
281 // AliITS is the general base class for the ITS. Also see AliDetector for
282 // futher information.
284 ///////////////////////////////////////////////////////////////////////////////
285 #include <iostream.h>
293 #include <TClonesArray.h>
295 #include <TObjectTable.h>
301 #include "AliHeader.h"
304 #include "AliITSDetType.h"
305 #include "AliITSresponseSPD.h"
306 #include "AliITSresponseSDD.h"
307 #include "AliITSresponseSSD.h"
308 #include "AliITSsegmentationSPD.h"
309 #include "AliITSsegmentationSDD.h"
310 #include "AliITSsegmentationSSD.h"
311 #include "AliITSsimulationSPD.h"
312 #include "AliITSsimulationSDD.h"
313 #include "AliITSsimulationSSD.h"
314 #include "AliITSClusterFinderSPD.h"
315 #include "AliITSClusterFinderSDD.h"
316 #include "AliITSClusterFinderSSD.h"
317 #include "AliITShit.h"
318 #include "AliITSgeom.h"
319 #include "AliITSpList.h"
320 #include "AliITSdigit.h"
321 #include "AliITSmodule.h"
322 #include "AliITSRecPoint.h"
323 #include "AliITSRawCluster.h"
327 //______________________________________________________________________
328 AliITS::AliITS() : AliDetector() {
329 // Default initializer for ITS
330 // The default constructor of the AliITS class. In addition to
331 // creating the AliITS class it zeros the variables fIshunt (a member
332 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
333 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
342 fIshunt = 0; // not zeroed in AliDetector.
349 // SetDetectors(); // default to fOpt="All". This variable not written out.
355 fNDetTypes = kNTYPES;
371 SetMarkerColor(kRed);
373 //______________________________________________________________________
374 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
375 // The standard Constructor for the ITS class. In addition to
376 // creating the AliITS class, it allocates memory for the TClonesArrays
377 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
378 // (clusters). It also zeros the variables
379 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
380 // the pointers fIdSens and fIdName. To help in displaying hits via the
381 // ROOT macro display.C AliITS also sets the marker color to red. The
382 // variables passes with this constructor, const char *name and *title,
383 // are used by the constructor of AliDetector class. See AliDetector
384 // class for a description of these parameters and its constructor
387 // const char *name Detector name. Should always be "ITS"
388 // const char *title Detector title.
394 fIshunt = 0; // not zeroed in AliDetector
395 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
396 gAlice->AddHitList(fHits); // Not done in AliDetector.
401 SetDetectors(); // default to fOpt="All". This variable not written out.
407 fNDetTypes = kNTYPES;
408 fDetTypes = new TObjArray(fNDetTypes);
410 fSDigits = new TClonesArray("AliITSpListItem",1000);
413 fNdtype = new Int_t[fNDetTypes];
414 fDtype = new TObjArray(fNDetTypes);
416 fCtype = new TObjArray(fNDetTypes);
417 fNctype = new Int_t[fNDetTypes];
420 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
424 for(i=0;i<fNDetTypes;i++) {
425 fDetTypes->AddAt(new AliITSDetType(),i);
430 SetMarkerColor(kRed);
432 //______________________________________________________________________
434 // Default destructor for ITS.
435 // The default destructor of the AliITS class. In addition to deleting
436 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
437 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
438 // fITSpoints, fDetType and it's contents.
446 delete fHits; fHits=0;
447 delete fSDigits; fSDigits=0;
448 // delete fDigits; fDigits=0;
449 delete fRecPoints; fRecPoints=0;
450 if(fIdName!=0) delete[] fIdName; // Array of TStrings
451 if(fIdSens!=0) delete[] fIdSens;
453 this->ClearModules();
455 }// end if fITSmodules!=0
471 } // end if fDetTypes
473 if (fTreeC) delete fTreeC;
475 if (fITSgeom) delete fITSgeom;
477 //______________________________________________________________________
478 AliITS::AliITS(AliITS &source){
479 // Copy constructor. This is a function which is not allowed to be
480 // done to the ITS. It exits with an error.
482 // AliITS &source An AliITS class.
488 if(this==&source) return;
489 Error("Copy constructor",
490 "You are not allowed to make a copy of the AliITS");
493 //______________________________________________________________________
494 AliITS& AliITS::operator=(AliITS &source){
495 // Assignment operator. This is a function which is not allowed to be
496 // done to the ITS. It exits with an error.
498 // AliITS &source An AliITS class.
504 if(this==&source) return *this;
505 Error("operator=","You are not allowed to make a copy of the AliITS");
507 return *this; //fake return
509 //______________________________________________________________________
510 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
511 // Distance from mouse to ITS on the screen. Dummy routine
512 // A dummy routine used by the ROOT macro display.C to allow for the
513 // use of the mouse (pointing device) in the macro. In general this should
514 // never be called. If it is it returns the number 9999 for any value of
517 // Int_t Dummy screen coordinate.
518 // Int_t Dummy screen coordinate.
522 // Int_t Dummy = 9999 distance to ITS.
526 //______________________________________________________________________
528 // Initializer ITS after it has been built
529 // This routine initializes the AliITS class. It is intended to be
530 // called from the Init function in AliITSv?. Besides displaying a banner
531 // indicating that it has been called it initializes the array fIdSens
532 // and sets the default segmentation, response, digit and raw cluster
533 // classes therefore it should be called after a call to CreateGeometry.
544 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
546 //______________________________________________________________________
547 void AliITS::SetDefaults(){
548 // sets the default segmentation, response, digit and raw cluster classes.
556 if(fDebug) printf("%s: SetDefaults\n",ClassName());
558 AliITSDetType *iDetType;
562 if (!iDetType->GetSegmentationModel()) {
563 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
564 SetSegmentationModel(0,seg0);
566 if (!iDetType->GetResponseModel()) {
567 SetResponseModel(0,new AliITSresponseSPD());
569 // set digit and raw cluster classes to be used
571 const char *kData0=(iDetType->GetResponseModel())->DataType();
572 if (strstr(kData0,"real")) {
573 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
574 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
578 if (!iDetType->GetResponseModel()) {
579 SetResponseModel(1,new AliITSresponseSDD("simulated"));
581 AliITSresponse *resp1=iDetType->GetResponseModel();
582 if (!iDetType->GetSegmentationModel()) {
583 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
584 SetSegmentationModel(1,seg1);
586 const char *kData1=(iDetType->GetResponseModel())->DataType();
587 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
588 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
589 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
590 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
594 if (!iDetType->GetSegmentationModel()) {
595 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
596 SetSegmentationModel(2,seg2);
598 if (!iDetType->GetResponseModel()) {
599 SetResponseModel(2,new AliITSresponseSSD("simulated"));
601 const char *kData2=(iDetType->GetResponseModel())->DataType();
602 if (strstr(kData2,"real")) {
603 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
604 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
607 Warning("SetDefaults",
608 "Only the three basic detector types are initialized!");
611 //______________________________________________________________________
612 void AliITS::SetDefaultSimulation(){
613 // sets the default simulation.
621 AliITSDetType *iDetType;
622 AliITSsimulation *sim;
624 sim = iDetType->GetSimulationModel();
626 AliITSsegmentation *seg0=
627 (AliITSsegmentation*)iDetType->GetSegmentationModel();
628 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
629 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
630 SetSimulationModel(0,sim0);
631 }else{ // simulation exists, make sure it is set up properly.
632 ((AliITSsimulationSPD*)sim)->Init(
633 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
634 (AliITSresponseSPD*) iDetType->GetResponseModel());
635 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
636 // (AliITSresponse*)iDetType->GetResponseModel());
637 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
638 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
641 sim = iDetType->GetSimulationModel();
643 AliITSsegmentation *seg1=
644 (AliITSsegmentation*)iDetType->GetSegmentationModel();
645 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
646 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
647 SetSimulationModel(1,sim1);
648 }else{ // simulation exists, make sure it is set up properly.
649 ((AliITSsimulationSDD*)sim)->Init(
650 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
651 (AliITSresponseSDD*) iDetType->GetResponseModel());
652 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
653 // (AliITSresponse*)iDetType->GetResponseModel());
654 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
655 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
658 sim = iDetType->GetSimulationModel();
660 AliITSsegmentation *seg2=
661 (AliITSsegmentation*)iDetType->GetSegmentationModel();
662 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
663 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
664 SetSimulationModel(2,sim2);
665 }else{ // simulation exists, make sure it is set up properly.
666 ((AliITSsimulationSSD*)sim)->Init(
667 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
668 (AliITSresponseSSD*) iDetType->GetResponseModel());
669 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
670 // (AliITSresponse*)iDetType->GetResponseModel());
671 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
672 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
675 //______________________________________________________________________
676 void AliITS::SetDefaultClusterFinders(){
677 // Sets the default cluster finders. Used in finding RecPoints.
686 AliITSDetType *iDetType;
690 if (!iDetType->GetReconstructionModel()) {
691 AliITSsegmentation *seg0 =
692 (AliITSsegmentation*)iDetType->GetSegmentationModel();
693 TClonesArray *dig0=DigitsAddress(0);
694 TClonesArray *recp0=ClustersAddress(0);
695 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
697 SetReconstructionModel(0,rec0);
702 if (!iDetType->GetReconstructionModel()) {
703 AliITSsegmentation *seg1 =
704 (AliITSsegmentation*)iDetType->GetSegmentationModel();
705 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
706 TClonesArray *dig1=DigitsAddress(1);
707 TClonesArray *recp1=ClustersAddress(1);
708 AliITSClusterFinderSDD *rec1 =
709 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
710 SetReconstructionModel(1,rec1);
715 if (!iDetType->GetReconstructionModel()) {
716 AliITSsegmentation *seg2=
717 (AliITSsegmentation*)iDetType->GetSegmentationModel();
718 TClonesArray *dig2=DigitsAddress(2);
719 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
720 SetReconstructionModel(2,rec2);
723 //______________________________________________________________________
724 void AliITS::MakeBranch(Option_t* option, const char *file){
725 // Creates Tree branches for the ITS.
727 // Option_t *option String of Tree types S,D, and/or R.
728 // const char *file String of the file name where these branches
729 // are to be stored. If blank then these branches
730 // are written to the same tree as the Hits were
736 Bool_t cS = (strstr(option,"S")!=0);
737 Bool_t cD = (strstr(option,"D")!=0);
738 Bool_t cR = (strstr(option,"R")!=0);
739 Bool_t cRF = (strstr(option,"RF")!=0);
742 AliDetector::MakeBranch(option,file);
744 if(cS) MakeBranchS(file);
745 if(cD) MakeBranchD(file);
746 if(cR) MakeBranchR(file);
747 if(cRF) MakeBranchRF(file);
749 //______________________________________________________________________
750 void AliITS::SetTreeAddress(){
751 // Set branch address for the Trees.
758 TTree *treeS = gAlice->TreeS();
759 TTree *treeD = gAlice->TreeD();
760 TTree *treeR = gAlice->TreeR();
762 AliDetector::SetTreeAddress();
764 SetTreeAddressS(treeS);
765 SetTreeAddressD(treeD);
766 SetTreeAddressR(treeR);
768 //______________________________________________________________________
769 AliITSDetType* AliITS::DetType(Int_t id){
770 // Return pointer to id detector type.
772 // Int_t id detector id number.
776 // returned, a pointer to a AliITSDetType.
778 return ((AliITSDetType*) fDetTypes->At(id));
780 //______________________________________________________________________
781 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
782 // Set the response model for the id detector type.
784 // Int_t id detector id number.
785 // AliITSresponse* a pointer containing an instance of AliITSresponse
786 // to be stored/owned b y AliITSDetType.
792 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
794 //______________________________________________________________________
795 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
796 // Set the segmentation model for the id detector type.
798 // Int_t id detector id number.
799 // AliITSsegmentation* a pointer containing an instance of
800 // AliITSsegmentation to be stored/owned b y
807 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
809 //______________________________________________________________________
810 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
811 // Set the simulation model for the id detector type.
813 // Int_t id detector id number.
814 // AliITSresponse* a pointer containing an instance of AliITSresponse
815 // to be stored/owned b y AliITSDetType.
821 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
824 //______________________________________________________________________
825 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
826 // Set the cluster finder model for the id detector type.
828 // Int_t id detector id number.
829 // AliITSClusterFinder* a pointer containing an instance of
830 // AliITSClusterFinder to be stored/owned b y
837 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
839 //______________________________________________________________________
840 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
841 // Set the digit and cluster classes name to be used for the id detector
844 // Int_t id detector id number.
845 // const char *digit Digit class name for detector id.
846 // const char *cluster Cluster class name for detector id.
852 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
854 //______________________________________________________________________
855 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
857 // The function to add information to the AliITShit class. See the
858 // AliITShit class for a full description. This function allocates the
859 // necessary new space for the hit information and passes the variable
860 // track, and the pointers *vol and *hits to the AliITShit constructor
863 // Int_t track Track number which produced this hit.
864 // Int_t *vol Array of Integer Hit information. See AliITShit.h
865 // Float_t *hits Array of Floating Hit information. see AliITShit.h
871 TClonesArray &lhits = *fHits;
872 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
874 //______________________________________________________________________
875 void AliITS::InitModules(Int_t size,Int_t &nmodules){
876 // Initialize the modules array.
878 // Int_t size Size of array of the number of modules to be
879 // created. If size <=0 then the number of modules
880 // is gotten from AliITSgeom class kept in fITSgeom.
882 // Int_t &nmodules The number of modules existing.
887 fITSmodules->Delete();
889 } // end fir fITSmoudles
891 Int_t nl,indexMAX,index;
893 if(size<=0){ // default to using data stored in AliITSgeom
895 Error("InitModules","fITSgeom not defined");
897 } // end if fITSgeom==0
898 nl = fITSgeom->GetNlayers();
899 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
900 fITSgeom->GetNdetectors(nl))+1;
902 fITSmodules = new TObjArray(indexMAX);
903 for(index=0;index<indexMAX;index++){
904 fITSmodules->AddAt( new AliITSmodule(index),index);
907 fITSmodules = new TObjArray(size);
908 for(index=0;index<size;index++) {
909 fITSmodules->AddAt( new AliITSmodule(index),index);
915 //______________________________________________________________________
916 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
917 Option_t *option,Text_t *filename){
918 // fill the modules with the sorted by module hits; add hits from
919 // background if option=Add.
921 // Int_t evnt Event to be processed.
922 // Int_t bgrev Background Hit tree number.
923 // Int_t nmodules Not used.
924 // Option_t *option String indicating if merging hits or not. To
925 // merge hits set equal to "Add". Otherwise no
926 // background hits are considered.
927 // Test_t *filename File name containing the background hits..
932 static TTree *trH1; //Tree with background hits
933 // static TClonesArray *fHits2; //List of hits for one track only
934 static Bool_t first=kTRUE;
936 const char *addBgr = strstr(option,"Add");
940 file=new TFile(filename);
941 // fHits2 = new TClonesArray("AliITShit",1000 );
946 // Get Hits Tree header from file
947 // if(fHits2) fHits2->Clear();
948 if(trH1) delete trH1;
952 sprintf(treeName,"TreeH%d",bgrev);
953 trH1 = (TTree*)gDirectory->Get(treeName);
955 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
957 // Set branch addresses
961 sprintf(branchname,"%s",GetName());
962 if (trH1 && fHits2) {
963 branch = trH1->GetBranch(branchname);
964 if (branch) branch->SetAddress(&fHits2);
965 } // end if trH1 && fHits
969 FillModules(gAlice->TreeH(),0); // fill from this file's tree.
971 TClonesArray *itsHits = this->Hits();
972 Int_t lay,lad,det,index;
975 TTree *iTH = gAlice->TreeH();
976 Int_t ntracks =(Int_t) iTH->GetEntries();
978 for(t=0; t<ntracks; t++){
981 Int_t nhits = itsHits->GetEntriesFast();
982 if (!nhits) continue;
983 for(h=0; h<nhits; h++){
984 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
985 itsHit->GetDetectorID(lay,lad,det);
986 // temporarily index=det-1 !!!
987 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
990 mod = this->GetModule(index);
991 mod->AddHit(itsHit,t,h);
992 } // end loop over hits
993 } // end loop over tracks
995 // open the file with background
998 FillModules(trH1,10000000); // Default mask 10M.
1001 ntracks =(Int_t)trH1->GetEntries();
1003 for (track=0; track<ntracks; track++) {
1004 if (fHits2) fHits2->Clear();
1005 trH1->GetEvent(track);
1007 for(i=0;i<fHits2->GetEntriesFast();++i) {
1008 itsHit=(AliITShit*) (*fHits2)[i];
1009 itsHit->GetDetectorID(lay,lad,det);
1010 // temporarily index=det-1 !!!
1011 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1014 mod = this->GetModule(index);
1015 mod->AddHit(itsHit,track,i);
1016 } // end loop over hits
1017 } // end loop over tracks
1019 TTree *fAli=gAlice->TreeK();
1021 if (fAli) fileAli =fAli->GetCurrentFile();
1025 //______________________________________________________________________
1026 void AliITS::FillModules(TTree *treeH, Int_t mask) {
1027 // fill the modules with the sorted by module hits;
1028 // can be called many times to do a merging
1030 // TTree *treeH The tree containing the hits to be copied into
1032 // Int_t mask The track number mask to indecate which file
1033 // this hits came from.
1039 Int_t lay,lad,det,index;
1040 AliITShit *itsHit=0;
1041 AliITSmodule *mod=0;
1042 char branchname[20];
1043 sprintf(branchname,"%s",GetName());
1044 TBranch *branch = treeH->GetBranch(branchname);
1046 Error("FillModules","%s branch in TreeH not found",branchname);
1049 branch->SetAddress(&fHits);
1050 Int_t nTracks =(Int_t) treeH->GetEntries();
1052 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
1054 Int_t nBytes = treeH->GetEvent(iPrimTrack);
1055 if (nBytes <= 0) continue;
1056 Int_t nHits = fHits->GetEntriesFast();
1057 for(h=0; h<nHits; h++){
1058 itsHit = (AliITShit *)fHits->UncheckedAt(h);
1059 itsHit->GetDetectorID(lay,lad,det);
1061 index = fITSgeom->GetModuleIndex(lay,lad,det);
1063 index=det-1; // This should not be used.
1064 } // end if [You must have fITSgeom for this to work!]
1065 mod = GetModule(index);
1066 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
1067 mod->AddHit(itsHit,iPrimTrack,h);
1068 } // end loop over hits
1069 } // end loop over tracks
1071 //______________________________________________________________________
1072 void AliITS::ClearModules(){
1073 // Clear the modules TObjArray.
1079 if(fITSmodules) fITSmodules->Delete();
1081 //______________________________________________________________________
1082 void AliITS::MakeBranchS(const char *fl){
1083 // Creates Tree Branch for the ITS summable digits.
1085 // cont char *fl File name where SDigits branch is to be written
1086 // to. If blank it write the SDigits to the same
1087 // file in which the Hits were found.
1092 Int_t buffersize = 4000;
1093 char branchname[30];
1095 // only one branch for SDigits.
1096 sprintf(branchname,"%s",GetName());
1097 if(fSDigits && gAlice->TreeS()){
1098 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1101 //______________________________________________________________________
1102 void AliITS::SetTreeAddressS(TTree *treeS){
1103 // Set branch address for the ITS summable digits Trees.
1105 // TTree *treeS Tree containing the SDigits.
1110 char branchname[30];
1114 sprintf(branchname,"%s",GetName());
1115 branch = treeS->GetBranch(branchname);
1116 if (branch) branch->SetAddress(&fSDigits);
1118 //______________________________________________________________________
1119 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1120 // Creates Tree branches for the ITS.
1122 // TTree *treeD Pointer to the Digits Tree.
1123 // cont char *file File name where Digits branch is to be written
1124 // to. If blank it write the SDigits to the same
1125 // file in which the Hits were found.
1130 Int_t buffersize = 4000;
1131 char branchname[30];
1133 sprintf(branchname,"%s",GetName());
1134 // one branch for digits per type of detector
1135 const char *det[3] = {"SPD","SDD","SSD"};
1139 for (i=0; i<kNTYPES ;i++) {
1140 DetType(i)->GetClassNames(digclass,clclass);
1142 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1143 else ResetDigits(i);
1145 for (i=0; i<kNTYPES ;i++) {
1146 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1147 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1148 if (fDtype && treeD) {
1149 MakeBranchInTree(treeD,
1150 branchname, &((*fDtype)[i]),buffersize,file);
1154 //______________________________________________________________________
1155 void AliITS::SetTreeAddressD(TTree *treeD){
1156 // Set branch address for the Trees.
1158 // TTree *treeD Tree containing the Digits.
1163 char branchname[30];
1164 const char *det[3] = {"SPD","SDD","SSD"};
1171 for (i=0; i<kNTYPES; i++) {
1172 DetType(i)->GetClassNames(digclass,clclass);
1174 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1175 else ResetDigits(i);
1176 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1177 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1179 branch = treeD->GetBranch(branchname);
1180 if (branch) branch->SetAddress(&((*fDtype)[i]));
1184 //______________________________________________________________________
1185 void AliITS::Hits2SDigits(){
1186 // Standard Hits to summable Digits function.
1192 // return; // Using Hits in place of the larger sDigits.
1193 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1194 // Do the Hits to Digits operation. Use Standard input values.
1195 // Event number from file, no background hit merging , use size from
1196 // AliITSgeom class, option="All", input from this file only.
1197 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1199 //______________________________________________________________________
1200 void AliITS::Hits2PreDigits(){
1201 // Standard Hits to summable Digits function.
1207 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1208 // Do the Hits to Digits operation. Use Standard input values.
1209 // Event number from file, no background hit merging , use size from
1210 // AliITSgeom class, option="All", input from this file only.
1211 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1213 //______________________________________________________________________
1214 void AliITS::SDigitsToDigits(Option_t *opt){
1215 // Standard Summable digits to Digits function.
1220 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1222 if(!GetITSgeom()) return; // need transformations to do digitization.
1223 AliITSgeom *geom = GetITSgeom();
1225 const char *all = strstr(opt,"All");
1226 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1228 if( !det[0] && !det[1] && !det[2] ) all = "All";
1230 static Bool_t setDef=kTRUE;
1231 if (setDef) SetDefaultSimulation();
1234 AliITSsimulation *sim = 0;
1235 AliITSDetType *iDetType = 0;
1236 TTree *trees = gAlice->TreeS();
1237 if( !(trees && this->GetSDigits()) ){
1238 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1241 sprintf( name, "%s", this->GetName() );
1242 TBranch *brchSDigits = trees->GetBranch( name );
1245 for(module=0;module<geom->GetIndexMax();module++){
1246 id = geom->GetModuleType(module);
1247 if (!all && !det[id]) continue;
1248 iDetType = DetType(id);
1249 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1251 Error("SDigit2Digits",
1252 "The simulation class was not instanciated!");
1255 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1257 // add summable digits to module
1258 this->GetSDigits()->Clear();
1259 brchSDigits->GetEvent(module);
1260 sim->AddSDigitsToModule(GetSDigits(),0);
1262 // Digitise current module sum(SDigits)->Digits
1263 sim->FinishSDigitiseModule();
1265 // fills all branches - wasted disk space
1266 gAlice->TreeD()->Fill();
1267 this->ResetDigits();
1270 gAlice->TreeD()->GetEntries();
1272 gAlice->TreeD()->AutoSave();
1274 gAlice->TreeD()->Reset();
1277 //______________________________________________________________________
1278 void AliITS::Hits2Digits(){
1279 // Standard Hits to Digits function.
1285 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1286 // Do the Hits to Digits operation. Use Standard input values.
1287 // Event number from file, no background hit merging , use size from
1288 // AliITSgeom class, option="All", input from this file only.
1289 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1291 //______________________________________________________________________
1292 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1293 Option_t *option, Option_t *opt,Text_t *filename){
1294 // keep galice.root for signal and name differently the file for
1295 // background when add! otherwise the track info for signal will be lost !
1296 // the condition below will disappear when the geom class will be
1297 // initialized for all versions - for the moment it is only for v5 !
1298 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1301 // Int_t evnt Event to be processed.
1302 // Int_t bgrev Background Hit tree number.
1303 // Int_t nmodules Not used.
1304 // Option_t *option String indicating if merging hits or not. To
1305 // merge hits set equal to "Add". Otherwise no
1306 // background hits are considered.
1307 // Test_t *filename File name containing the background hits..
1312 // return; // using Hits instead of the larger sdigits.
1314 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1316 //______________________________________________________________________
1317 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1318 Option_t *option, Option_t *opt,Text_t *filename){
1319 // Keep galice.root for signal and name differently the file for
1320 // background when add! otherwise the track info for signal will be lost !
1321 // the condition below will disappear when the geom class will be
1322 // initialized for all versions - for the moment it is only for v5 !
1323 // 7 is the SDD beam test version.
1325 // Int_t evnt Event to be processed.
1326 // Int_t bgrev Background Hit tree number.
1327 // Int_t nmodules Not used.
1328 // Option_t *option String indicating if merging hits or not. To
1329 // merge hits set equal to "Add". Otherwise no
1330 // background hits are considered.
1331 // Test_t *filename File name containing the background hits..
1337 if(!GetITSgeom()) return; // need transformations to do digitization.
1338 AliITSgeom *geom = GetITSgeom();
1340 const char *all = strstr(opt,"All");
1341 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1343 static Bool_t setDef=kTRUE;
1344 if (setDef) SetDefaultSimulation();
1348 InitModules(size,nmodules);
1349 FillModules(evNumber,bgrev,nmodules,option,filename);
1351 AliITSsimulation *sim = 0;
1352 AliITSDetType *iDetType = 0;
1353 AliITSmodule *mod = 0;
1355 for(module=0;module<geom->GetIndexMax();module++){
1356 id = geom->GetModuleType(module);
1357 if (!all && !det[id]) continue;
1358 iDetType = DetType(id);
1359 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1361 Error("HitsToSDigits",
1362 "The simulation class was not instanciated!");
1365 mod = (AliITSmodule *)fITSmodules->At(module);
1366 sim->SDigitiseModule(mod,module,evNumber);
1367 // fills all branches - wasted disk space
1368 gAlice->TreeS()->Fill();
1374 gAlice->TreeS()->GetEntries();
1375 gAlice->TreeS()->AutoSave();
1377 gAlice->TreeS()->Reset();
1379 //______________________________________________________________________
1380 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1381 Option_t *option, Option_t *opt,Text_t *filename){
1382 // Keep galice.root for signal and name differently the file for
1383 // background when add! otherwise the track info for signal will be lost !
1384 // the condition below will disappear when the geom class will be
1385 // initialized for all versions - for the moment it is only for v5 !
1386 // 7 is the SDD beam test version.
1388 // Int_t evnt Event to be processed.
1389 // Int_t bgrev Background Hit tree number.
1390 // Int_t nmodules Not used.
1391 // Option_t *option String indicating if merging hits or not. To
1392 // merge hits set equal to "Add". Otherwise no
1393 // background hits are considered.
1394 // Test_t *filename File name containing the background hits..
1400 if(!GetITSgeom()) return; // need transformations to do digitization.
1401 AliITSgeom *geom = GetITSgeom();
1403 const char *all = strstr(opt,"All");
1404 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1406 static Bool_t setDef=kTRUE;
1407 if (setDef) SetDefaultSimulation();
1411 InitModules(size,nmodules);
1412 FillModules(evNumber,bgrev,nmodules,option,filename);
1414 AliITSsimulation *sim = 0;
1415 AliITSDetType *iDetType = 0;
1416 AliITSmodule *mod = 0;
1418 for(module=0;module<geom->GetIndexMax();module++){
1419 id = geom->GetModuleType(module);
1420 if (!all && !det[id]) continue;
1421 iDetType = DetType(id);
1422 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1424 Error("HitsToDigits",
1425 "The simulation class was not instanciated!");
1428 mod = (AliITSmodule *)fITSmodules->At(module);
1429 sim->DigitiseModule(mod,module,evNumber);
1430 // fills all branches - wasted disk space
1431 gAlice->TreeD()->Fill();
1437 gAlice->TreeD()->GetEntries();
1438 gAlice->TreeD()->AutoSave();
1440 gAlice->TreeD()->Reset();
1442 //______________________________________________________________________
1443 void AliITS::ResetSDigits(){
1444 // Reset the Summable Digits array.
1450 if (fSDigits) fSDigits->Clear();
1453 //______________________________________________________________________
1454 void AliITS::ResetDigits(){
1455 // Reset number of digits and the digits array for the ITS detector.
1461 if (!fDtype) return;
1464 for (i=0;i<kNTYPES;i++ ) {
1465 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1466 if (fNdtype) fNdtype[i]=0;
1469 //______________________________________________________________________
1470 void AliITS::ResetDigits(Int_t i){
1471 // Reset number of digits and the digits array for this branch.
1477 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1478 if (fNdtype) fNdtype[i]=0;
1480 //______________________________________________________________________
1481 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1482 // Adds the a module full of summable digits to the summable digits tree.
1484 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1490 TClonesArray &lsdig = *fSDigits;
1491 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1493 //______________________________________________________________________
1494 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1495 // Add a real digit - as coming from data.
1497 // Int_t id Detector type number.
1498 // Int_t *digits Integer array containing the digits info. See
1505 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1506 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1508 //______________________________________________________________________
1509 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1510 // Add a simulated digit.
1512 // Int_t id Detector type number.
1513 // AliITSdigit *d Digit to be added to the Digits Tree. See
1520 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1524 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1527 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1530 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1534 //______________________________________________________________________
1535 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1536 Int_t *hits,Float_t *charges){
1537 // Add a simulated digit to the list.
1539 // Int_t id Detector type number.
1540 // Float_t phys Physics indicator. See AliITSdigits.h
1541 // Int_t *digits Integer array containing the digits info. See
1543 // Int_t *tracks Integer array [3] containing the track numbers that
1544 // contributed to this digit.
1545 // Int_t *hits Integer array [3] containing the hit numbers that
1546 // contributed to this digit.
1547 // Float_t *charge Floating point array of the signals contributed
1548 // to this digit by each track.
1554 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1557 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1560 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1564 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1568 //______________________________________________________________________
1569 void AliITS::MakeTreeC(Option_t *option){
1570 // Create a separate tree to store the clusters.
1572 // Option_t *option string which must contain "C" otherwise
1573 // no Cluster Tree is created.
1578 TDirectory *cwd = gDirectory;
1579 TFile *fileRecPoints = gAlice->GetTreeRFile();
1580 if(fileRecPoints)fileRecPoints->cd();
1581 const char *optC = strstr(option,"C");
1583 Int_t cureve = gAlice->GetEvNumber();
1584 sprintf(hname,"TreeC%d",cureve);
1586 const char *curname = fTreeC->GetName();
1587 char *exists = strstr(hname,curname);
1593 if (optC && !fTreeC) fTreeC = new TTree(hname,"Clusters in ITS");
1596 Int_t buffersize = 4000;
1597 char branchname[30];
1598 const char *det[3] = {"SPD","SDD","SSD"};
1602 // one branch for Clusters per type of detector
1604 for (i=0; i<kNTYPES ;i++) {
1605 AliITSDetType *iDetType=DetType(i);
1606 iDetType->GetClassNames(digclass,clclass);
1608 if(!ClustersAddress(i)){
1609 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1611 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1612 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1613 if (fCtype && fTreeC) {
1614 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1615 } // end if fCtype && fTreeC
1619 //______________________________________________________________________
1620 void AliITS::GetTreeC(Int_t event){
1621 // Get the clusters tree for this event and set the branch address.
1623 // Int_t event Event number for the cluster tree.
1629 char branchname[30];
1630 const char *det[3] = {"SPD","SDD","SSD"};
1637 sprintf(treeName,"TreeC%d",event);
1638 TFile *fileRecPoints = gAlice->GetTreeRFile();
1640 fTreeC = (TTree*)gDirectory->Get(treeName);
1643 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1652 for (i=0; i<kNTYPES; i++) {
1653 AliITSDetType *iDetType=DetType(i);
1654 iDetType->GetClassNames(digclass,clclass);
1656 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1657 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1658 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1660 branch = fTreeC->GetBranch(branchname);
1661 if (branch) branch->SetAddress(&((*fCtype)[i]));
1665 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1668 //______________________________________________________________________
1669 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1670 // Add a cluster to the list.
1672 // Int_t id Detector type number.
1673 // AliITSRawCluster *c Cluster class to be added to the tree of
1680 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1684 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1687 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1690 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1694 //______________________________________________________________________
1695 void AliITS::ResetClusters(){
1696 // Reset number of clusters and the clusters array for ITS.
1703 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1705 //______________________________________________________________________
1706 void AliITS::ResetClusters(Int_t i){
1707 // Reset number of clusters and the clusters array for this branch.
1709 // Int_t i Detector type number.
1715 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1716 if (fNctype) fNctype[i]=0;
1718 //______________________________________________________________________
1719 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1720 // Creates Tree branches for the ITS Reconstructed points.
1722 // cont char *file File name where RecPoints branch is to be written
1723 // to. If blank it write the SDigits to the same
1724 // file in which the Hits were found.
1729 Int_t buffsz = 4000;
1730 char branchname[30];
1732 // only one branch for rec points for all detector types
1733 Bool_t oFast= (strstr(opt,"Fast")!=0);
1735 sprintf(branchname,"%sRecPointsF",GetName());
1737 sprintf(branchname,"%sRecPoints",GetName());
1739 if (fRecPoints && gAlice->TreeR()) {
1740 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1743 //______________________________________________________________________
1744 void AliITS::SetTreeAddressR(TTree *treeR){
1745 // Set branch address for the Reconstructed points Trees.
1747 // TTree *treeR Tree containing the RecPoints.
1752 char branchname[30];
1756 sprintf(branchname,"%sRecPoints",GetName());
1757 branch = treeR->GetBranch(branchname);
1759 branch->SetAddress(&fRecPoints);
1762 sprintf(branchname,"%sRecPointsF",GetName());
1763 branch = treeR->GetBranch(branchname);
1765 branch->SetAddress(&fRecPoints);
1769 //______________________________________________________________________
1770 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1771 // Add a reconstructed space point to the list
1773 // const AliITSRecPoint &r RecPoint class to be added to the tree
1774 // of reconstructed points TreeR.
1780 TClonesArray &lrecp = *fRecPoints;
1781 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1783 //______________________________________________________________________
1784 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1785 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1786 // keep galice.root for signal and name differently the file for
1787 // background when add! otherwise the track info for signal will be lost !
1788 // the condition below will disappear when the geom class will be
1789 // initialized for all versions - for the moment it is only for v5 !
1791 // Int_t evnt Event to be processed.
1792 // Int_t bgrev Background Hit tree number.
1793 // Int_t size Size used by InitModules. See InitModules.
1794 // Option_t *opt0 Option passed to FillModules. See FillModules.
1795 // Option_t *opt1 String indicating if merging hits or not. To
1796 // merge hits set equal to "Add". Otherwise no
1797 // background hits are considered.
1798 // Test_t *flnm File name containing the background hits..
1804 if(!GetITSgeom()) return;
1805 AliITSgeom *geom = GetITSgeom();
1807 const char *all = strstr(opt1,"All");
1808 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1809 strstr(opt1,"SSD")};
1811 InitModules(size,nmodules);
1812 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1814 AliITSsimulation *sim = 0;
1815 AliITSDetType *iDetType = 0;
1816 AliITSmodule *mod = 0;
1819 //m.b. : this change is nothing but a nice way to make sure
1821 for(module=0;module<geom->GetIndexMax();module++){
1822 id = geom->GetModuleType(module);
1823 if (!all && !det[id]) continue;
1824 iDetType = DetType(id);
1825 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1827 Error("HitsToFastPoints",
1828 "The simulation class was not instanciated!");
1831 mod = (AliITSmodule *)fITSmodules->At(module);
1832 sim->CreateFastRecPoints(mod,module,gRandom);
1833 // gAlice->TreeR()->Fill();
1834 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1841 gAlice->TreeR()->AutoSave();
1843 gAlice->TreeR()->Reset();
1845 //______________________________________________________________________
1846 void AliITS::Digits2Reco(){
1847 // Find clusters and reconstruct space points.
1853 AliHeader *header=gAlice->GetHeader();
1854 // to Digits to RecPoints for event in file, all digits in file, and
1855 // all ITS detectors.
1856 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1858 //______________________________________________________________________
1859 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1860 // cluster finding and reconstruction of space points
1861 // the condition below will disappear when the geom class will be
1862 // initialized for all versions - for the moment it is only for v5 !
1863 // 7 is the SDD beam test version
1865 // Int_t evNumber Event number to be processed.
1866 // Int_t lastentry Offset for module when not all of the modules
1868 // Option_t *opt String indicating which ITS sub-detectors should
1869 // be processed. If ="All" then all of the ITS
1870 // sub detectors are processed.
1876 if(!GetITSgeom()) return;
1877 AliITSgeom *geom = GetITSgeom();
1879 const char *all = strstr(opt,"All");
1880 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1882 static Bool_t setRec=kTRUE;
1883 if (setRec) SetDefaultClusterFinders();
1886 TTree *treeC=TreeC();
1887 AliITSClusterFinder *rec = 0;
1888 AliITSDetType *iDetType = 0;
1889 Int_t id,module,first=0;
1890 for(module=0;module<geom->GetIndexMax();module++){
1891 id = geom->GetModuleType(module);
1892 if (!all && !det[id]) continue;
1893 if(det[id]) first = geom->GetStartDet(id);
1894 iDetType = DetType(id);
1895 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1896 TClonesArray *itsDigits = this->DigitsAddress(id);
1898 Error("DigitsToRecPoints",
1899 "The reconstruction class was not instanciated!");
1902 this->ResetDigits();
1903 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1904 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1905 Int_t ndigits = itsDigits->GetEntriesFast();
1906 if (ndigits) rec->FindRawClusters(module);
1907 gAlice->TreeR()->Fill();
1913 gAlice->TreeR()->GetEntries();
1914 treeC->GetEntries();
1915 gAlice->TreeR()->AutoSave();
1917 gAlice->TreeR()->Reset();
1922 //______________________________________________________________________
1923 void AliITS::ResetRecPoints(){
1924 // Reset number of rec points and the rec points array.
1930 if (fRecPoints) fRecPoints->Clear();