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.69 2002/05/05 21:06:55 nilsen
19 Added GetSimulationMoel, and fixed up SetDefaultSimulation to do the
20 proper initilization when a simulation has already been defined.
22 Revision 1.68 2002/05/02 18:51:53 nilsen
24 Method MakeBranchR has now a second argument, with a default value:
25 Option_t *opt=" ". Opt="Fast" is to create a separate branch
26 for fast points in TreeR
27 New method MakeBranchRF: it a separate branch in TreeR for Fast Points
30 1) TTree->Write() replaced with TTree->AutoSave for TreeS, TreeD and
32 2) Changes in MakeBranchR to allow the creation of a special branch
35 Revision 1.67 2002/03/15 17:22:51 nilsen
36 Intoduced SDigits2Digits and SDigitsToDigits functions.
38 Revision 1.66 2001/11/28 01:35:45 nilsen
39 Using standard constructors instead of default constructors for Clusterfinder,
40 Response, and FastSimulator.
42 Revision 1.65 2001/11/27 16:27:28 nilsen
43 Adding AliITSDigitizer class to do merging and digitization . Based on the
44 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
45 file. The following files required minor changes. AliITS, added functions
46 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
47 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
48 the original Root Directory in function Compress1D. Now it uses gDirectory.
50 Revision 1.64 2001/11/19 16:17:02 nilsen
51 Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
52 bugs found by Rene require more work to fix. Will be fixed soon.
54 Revision 1.63 2001/10/24 21:16:34 nilsen
55 Removed some dead code and improved comments/documntation.
57 Revision 1.62 2001/10/21 19:23:21 nilsen
58 Added function to allow to limit which detectors to digitize and reconstruct.
59 The default is All. This change makes no changes to any root file.
61 Revision 1.61 2001/10/11 15:26:07 mariana
62 Correct HitsToFastRecPoints
64 Revision 1.60 2001/10/04 22:38:10 nilsen
65 Changes made to support PreDigits (SDigits) plus other helpful changes.
67 Revision 1.59 2001/08/30 09:56:18 hristov
68 The operator[] is replaced by At() or AddAt() in case of TObjArray.
70 Revision 1.58 2001/07/26 15:05:29 hristov
71 Use global gRandom generator (M.Ivanov)
73 Revision 1.57 2001/07/24 14:26:11 mariana
74 Introduce the function Digits2Reco() and write the defaults for simulation and reconstruction
76 Revision 1.56 2001/07/05 12:49:49 mariana
77 Temporary patches required by root.v3.01.05
79 Revision 1.55 2001/06/14 14:59:00 barbera
80 Tracking V1 decoupled from AliITS
82 Revision 1.54 2001/05/31 20:37:56 barbera
83 Bari/Salerno model set as defaault SPD simulation
85 Revision 1.53 2001/05/31 18:52:24 barbera
86 Bari model becomes the default
88 Revision 1.53 2001/05/30 07:52:24 hristov
89 TPC and CONTAINERS included in the search path
91 Revision 1.52 2001/05/30 06:04:58 hristov
92 Changes made to be consitant with changes in TPC tracking classes (B.Nilsen)
94 Revision 1.51 2001/05/16 14:57:15 alibrary
95 New files for folders and Stack
97 Revision 1.50 2001/05/11 09:15:21 barbera
98 Corrected to make fast point creation working with PPR geometry
100 Revision 1.49 2001/05/11 07:37:49 hristov
101 Legacy lines commented
103 Revision 1.48 2001/05/10 18:14:25 barbera
106 Revision 1.47 2001/05/10 17:55:59 barbera
107 Modified to create rec points also for PPR geometries
109 Revision 1.46 2001/05/10 00:05:28 nilsen
110 Allowed for HitsToDigits function to work with versions 5, 7, 8, and 9. This
111 should probably be cleaned up to only check to make sure that fITSgeom has
112 been properly defined.
114 Revision 1.45 2001/05/01 22:35:48 nilsen
115 Remove/commented a number of cout<< statements. and made change needed by
118 Revision 1.44 2001/04/26 22:44:01 nilsen
119 Removed dependence on layer 5/6 in AliITS::HitsToDigits. This will be
120 done properly in AliITSv???.cxx via SetDefaults.
122 Revision 1.43 2001/04/26 13:22:52 barbera
123 TMatrix and TVector elimininated to speed up the code
125 Revision 1.42 2001/04/25 21:55:12 barbera
126 Updated version to be compatible with actual verion of STEER and TPC
128 Revision 1.41 2001/04/21 15:16:51 barbera
129 Updated with the new SSD reconstruction code
131 Revision 1.40 2001/03/17 15:07:06 mariana
132 Update SDD response parameters
134 Revision 1.39 2001/03/12 17:45:32 hristov
135 Changes needed on Sun with CC 5.0
137 Revision 1.38 2001/03/07 14:04:51 barbera
138 Some vector dimensions increased to cope with full events
140 Revision 1.37 2001/03/07 12:36:35 barbera
141 A change added in the tracking part to manage delta rays
143 Revision 1.36 2001/03/02 19:44:11 barbera
144 modified to taking into account new version tracking v1
146 Revision 1.35 2001/02/28 18:16:46 mariana
147 Make the code compatible with the new AliRun
149 Revision 1.34 2001/02/11 15:51:39 mariana
150 Set protection in MakeBranch
152 Revision 1.33 2001/02/10 22:26:39 mariana
153 Move the initialization of the containers for raw clusters in MakeTreeC()
155 Revision 1.32 2001/02/08 23:55:31 nilsen
156 Removed fMajor/MinorVersion variables in favor of variables in derived classes.
157 Set arrays char *det[3] = {"SPD","SDD","SSD"} as const.
159 Revision 1.31 2001/02/02 23:57:28 nilsen
160 Added include file that are no londer included in AliITSgeom.h
162 Revision 1.30 2001/01/30 09:23:13 hristov
163 Streamers removed (R.Brun)
165 Revision 1.29 2001/01/26 20:01:09 hristov
166 Major upgrade of AliRoot code
168 Revision 1.28 2000/12/18 14:02:00 barbera
169 new version of the ITS tracking to take into account the new TPC track parametrization
171 Revision 1.27 2000/12/08 13:49:27 barbera
172 Hidden declaration in a for loop removed to be compliant with HP-UX compiler
174 Revision 1.26 2000/11/27 13:12:13 barbera
175 New version containing the files for tracking
177 Revision 1.25 2000/11/12 22:38:05 barbera
178 Added header file for the SPD Bari model
180 Revision 1.24 2000/10/09 22:18:12 barbera
181 Bug fixes from MAriana to le AliITStest.C run correctly
183 Revision 1.23 2000/10/05 20:47:42 nilsen
184 fixed dependencies of include files. Tryed but failed to get a root automaticly
185 generates streamer function to work. Modified SetDefaults.
187 Revision 1.9.2.15 2000/10/04 16:56:40 nilsen
188 Needed to include stdlib.h
191 Revision 1.22 2000/10/04 19:45:52 barbera
192 Corrected by F. Carminati for v3.04
194 Revision 1.21 2000/10/02 21:28:08 fca
195 Removal of useless dependecies via forward declarations
197 Revision 1.20 2000/10/02 16:31:39 barbera
198 General code clean-up
200 Revision 1.9.2.14 2000/10/02 15:43:51 barbera
201 General code clean-up (e.g., printf -> cout)
203 Revision 1.19 2000/09/22 12:13:25 nilsen
204 Patches and updates for fixes to this and other routines.
206 Revision 1.18 2000/07/12 05:32:20 fca
207 Correcting several syntax problem with static members
209 Revision 1.17 2000/07/10 16:07:18 fca
210 Release version of ITS code
212 Revision 1.9.2.3 2000/02/02 13:42:09 barbera
213 fixed AliITS.cxx for new AliRun structure. Added ITS hits list to list of hits which will have their track numbers updated
215 Revision 1.9.2.2 2000/01/23 03:03:13 nilsen
216 //fixed FillModule. Removed fi(fabs(xl)<dx....
218 Revision 1.9.2.1 2000/01/12 19:03:32 nilsen
219 This is the version of the files after the merging done in December 1999.
220 See the ReadMe110100.txt file for details
222 Revision 1.9 1999/11/14 14:33:25 fca
223 Correct problems with distructors and pointers, thanks to I.Hrivnacova
225 Revision 1.8 1999/09/29 09:24:19 fca
226 Introduction of the Copyright and cvs Log
230 ///////////////////////////////////////////////////////////////////////////////
232 // An overview of the basic philosophy of the ITS code development
233 // and analysis is show in the figure below.
236 <img src="picts/ITS/ITS_Analysis_schema.gif">
239 <font size=+2 color=red>
240 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
241 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
247 // AliITS. Inner Traking System base class.
248 // This class contains the base procedures for the Inner Tracking System
252 <img src="picts/ITS/AliITS_Class_Diagram.gif">
255 <font size=+2 color=red>
256 <p>This show the class diagram of the different elements that are part of
264 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
267 // Modified and documented by Bjorn S. Nilsen
271 // Modified and documented by A. Bologna
274 // AliITS is the general base class for the ITS. Also see AliDetector for
275 // futher information.
277 ///////////////////////////////////////////////////////////////////////////////
278 #include <iostream.h>
286 #include <TClonesArray.h>
288 #include <TObjectTable.h>
294 #include "AliHeader.h"
297 #include "AliITSDetType.h"
298 #include "AliITSresponseSPD.h"
299 #include "AliITSresponseSDD.h"
300 #include "AliITSresponseSSD.h"
301 #include "AliITSsegmentationSPD.h"
302 #include "AliITSsegmentationSDD.h"
303 #include "AliITSsegmentationSSD.h"
304 #include "AliITSsimulationSPD.h"
305 #include "AliITSsimulationSDD.h"
306 #include "AliITSsimulationSSD.h"
307 #include "AliITSClusterFinderSPD.h"
308 #include "AliITSClusterFinderSDD.h"
309 #include "AliITSClusterFinderSSD.h"
310 #include "AliITShit.h"
311 #include "AliITSgeom.h"
312 #include "AliITSpList.h"
313 #include "AliITSdigit.h"
314 #include "AliITSmodule.h"
315 #include "AliITSRecPoint.h"
316 #include "AliITSRawCluster.h"
320 //______________________________________________________________________
321 AliITS::AliITS() : AliDetector() {
322 // Default initializer for ITS
323 // The default constructor of the AliITS class. In addition to
324 // creating the AliITS class it zeros the variables fIshunt (a member
325 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
326 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
335 fIshunt = 0; // not zeroed in AliDetector.
342 // SetDetectors(); // default to fOpt="All". This variable not written out.
348 fNDetTypes = kNTYPES;
364 SetMarkerColor(kRed);
366 //______________________________________________________________________
367 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
368 // The standard Constructor for the ITS class. In addition to
369 // creating the AliITS class, it allocates memory for the TClonesArrays
370 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
371 // (clusters). It also zeros the variables
372 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
373 // the pointers fIdSens and fIdName. To help in displaying hits via the
374 // ROOT macro display.C AliITS also sets the marker color to red. The
375 // variables passes with this constructor, const char *name and *title,
376 // are used by the constructor of AliDetector class. See AliDetector
377 // class for a description of these parameters and its constructor
380 // const char *name Detector name. Should always be "ITS"
381 // const char *title Detector title.
387 fIshunt = 0; // not zeroed in AliDetector
388 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
389 gAlice->AddHitList(fHits); // Not done in AliDetector.
394 SetDetectors(); // default to fOpt="All". This variable not written out.
400 fNDetTypes = kNTYPES;
401 fDetTypes = new TObjArray(fNDetTypes);
403 fSDigits = new TClonesArray("AliITSpListItem",1000);
406 fNdtype = new Int_t[fNDetTypes];
407 fDtype = new TObjArray(fNDetTypes);
409 fCtype = new TObjArray(fNDetTypes);
410 fNctype = new Int_t[fNDetTypes];
413 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
417 for(i=0;i<fNDetTypes;i++) {
418 fDetTypes->AddAt(new AliITSDetType(),i);
423 SetMarkerColor(kRed);
425 //______________________________________________________________________
427 // Default destructor for ITS.
428 // The default destructor of the AliITS class. In addition to deleting
429 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
430 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
431 // fITSpoints, fDetType and it's contents.
443 if(fIdName!=0) delete[] fIdName; // Array of TStrings
444 if(fIdSens!=0) delete[] fIdSens;
446 this->ClearModules();
448 }// end if fITSmodules!=0
464 } // end if fDetTypes
466 if (fTreeC) delete fTreeC;
468 if (fITSgeom) delete fITSgeom;
470 //______________________________________________________________________
471 AliITS::AliITS(AliITS &source){
472 // Copy constructor. This is a function which is not allowed to be
473 // done to the ITS. It exits with an error.
475 // AliITS &source An AliITS class.
481 if(this==&source) return;
482 Error("Copy constructor",
483 "You are not allowed to make a copy of the AliITS");
486 //______________________________________________________________________
487 AliITS& AliITS::operator=(AliITS &source){
488 // Assignment operator. This is a function which is not allowed to be
489 // done to the ITS. It exits with an error.
491 // AliITS &source An AliITS class.
497 if(this==&source) return *this;
498 Error("operator=","You are not allowed to make a copy of the AliITS");
500 return *this; //fake return
502 //______________________________________________________________________
503 Int_t AliITS::DistancetoPrimitive(Int_t,Int_t){
504 // Distance from mouse to ITS on the screen. Dummy routine
505 // A dummy routine used by the ROOT macro display.C to allow for the
506 // use of the mouse (pointing device) in the macro. In general this should
507 // never be called. If it is it returns the number 9999 for any value of
510 // Int_t Dummy screen coordinate.
511 // Int_t Dummy screen coordinate.
515 // Int_t Dummy = 9999 distance to ITS.
519 //______________________________________________________________________
521 // Initializer ITS after it has been built
522 // This routine initializes the AliITS class. It is intended to be
523 // called from the Init function in AliITSv?. Besides displaying a banner
524 // indicating that it has been called it initializes the array fIdSens
525 // and sets the default segmentation, response, digit and raw cluster
526 // classes therefore it should be called after a call to CreateGeometry.
537 for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
539 //______________________________________________________________________
540 void AliITS::SetDefaults(){
541 // sets the default segmentation, response, digit and raw cluster classes.
549 if(fDebug) printf("%s: SetDefaults\n",ClassName());
551 AliITSDetType *iDetType;
555 if (!iDetType->GetSegmentationModel()) {
556 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
557 SetSegmentationModel(0,seg0);
559 if (!iDetType->GetResponseModel()) {
560 SetResponseModel(0,new AliITSresponseSPD());
562 // set digit and raw cluster classes to be used
564 const char *kData0=(iDetType->GetResponseModel())->DataType();
565 if (strstr(kData0,"real")) {
566 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
567 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
571 if (!iDetType->GetResponseModel()) {
572 SetResponseModel(1,new AliITSresponseSDD("simulated"));
574 AliITSresponse *resp1=iDetType->GetResponseModel();
575 if (!iDetType->GetSegmentationModel()) {
576 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
577 SetSegmentationModel(1,seg1);
579 const char *kData1=(iDetType->GetResponseModel())->DataType();
580 const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
581 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){
582 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
583 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
587 if (!iDetType->GetSegmentationModel()) {
588 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
589 SetSegmentationModel(2,seg2);
591 if (!iDetType->GetResponseModel()) {
592 SetResponseModel(2,new AliITSresponseSSD("simulated"));
594 const char *kData2=(iDetType->GetResponseModel())->DataType();
595 if (strstr(kData2,"real")) {
596 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
597 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
600 Warning("SetDefaults",
601 "Only the three basic detector types are initialized!");
604 //______________________________________________________________________
605 void AliITS::SetDefaultSimulation(){
606 // sets the default simulation.
614 AliITSDetType *iDetType;
615 AliITSsimulation *sim;
617 sim = iDetType->GetSimulationModel();
619 AliITSsegmentation *seg0=
620 (AliITSsegmentation*)iDetType->GetSegmentationModel();
621 AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
622 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
623 SetSimulationModel(0,sim0);
624 }else{ // simulation exists, make sure it is set up properly.
625 ((AliITSsimulationSPD*)sim)->Init(
626 (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
627 (AliITSresponseSPD*) iDetType->GetResponseModel());
628 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
629 // (AliITSresponse*)iDetType->GetResponseModel());
630 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
631 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
634 sim = iDetType->GetSimulationModel();
636 AliITSsegmentation *seg1=
637 (AliITSsegmentation*)iDetType->GetSegmentationModel();
638 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
639 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
640 SetSimulationModel(1,sim1);
641 }else{ // simulation exists, make sure it is set up properly.
642 ((AliITSsimulationSDD*)sim)->Init(
643 (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
644 (AliITSresponseSDD*) iDetType->GetResponseModel());
645 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
646 // (AliITSresponse*)iDetType->GetResponseModel());
647 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
648 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
651 sim = iDetType->GetSimulationModel();
653 AliITSsegmentation *seg2=
654 (AliITSsegmentation*)iDetType->GetSegmentationModel();
655 AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
656 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
657 SetSimulationModel(2,sim2);
658 }else{ // simulation exists, make sure it is set up properly.
659 ((AliITSsimulationSSD*)sim)->Init(
660 (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
661 (AliITSresponseSSD*) iDetType->GetResponseModel());
662 // if(sim->GetResponseModel()==0) sim->SetResponseModel(
663 // (AliITSresponse*)iDetType->GetResponseModel());
664 // if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
665 // (AliITSsegmentation*)iDetType->GetSegmentationModel());
668 //______________________________________________________________________
669 void AliITS::SetDefaultClusterFinders(){
670 // Sets the default cluster finders. Used in finding RecPoints.
679 AliITSDetType *iDetType;
683 if (!iDetType->GetReconstructionModel()) {
684 AliITSsegmentation *seg0 =
685 (AliITSsegmentation*)iDetType->GetSegmentationModel();
686 TClonesArray *dig0=DigitsAddress(0);
687 TClonesArray *recp0=ClustersAddress(0);
688 AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0,
690 SetReconstructionModel(0,rec0);
695 if (!iDetType->GetReconstructionModel()) {
696 AliITSsegmentation *seg1 =
697 (AliITSsegmentation*)iDetType->GetSegmentationModel();
698 AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
699 TClonesArray *dig1=DigitsAddress(1);
700 TClonesArray *recp1=ClustersAddress(1);
701 AliITSClusterFinderSDD *rec1 =
702 new AliITSClusterFinderSDD(seg1,res1,dig1,recp1);
703 SetReconstructionModel(1,rec1);
708 if (!iDetType->GetReconstructionModel()) {
709 AliITSsegmentation *seg2=
710 (AliITSsegmentation*)iDetType->GetSegmentationModel();
711 TClonesArray *dig2=DigitsAddress(2);
712 AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2);
713 SetReconstructionModel(2,rec2);
716 //______________________________________________________________________
717 void AliITS::MakeBranch(Option_t* option, const char *file){
718 // Creates Tree branches for the ITS.
720 // Option_t *option String of Tree types S,D, and/or R.
721 // const char *file String of the file name where these branches
722 // are to be stored. If blank then these branches
723 // are written to the same tree as the Hits were
729 Bool_t cS = (strstr(option,"S")!=0);
730 Bool_t cD = (strstr(option,"D")!=0);
731 Bool_t cR = (strstr(option,"R")!=0);
732 Bool_t cRF = (strstr(option,"RF")!=0);
735 AliDetector::MakeBranch(option,file);
737 if(cS) MakeBranchS(file);
738 if(cD) MakeBranchD(file);
739 if(cR) MakeBranchR(file);
740 if(cRF) MakeBranchRF(file);
742 //______________________________________________________________________
743 void AliITS::SetTreeAddress(){
744 // Set branch address for the Trees.
751 TTree *treeS = gAlice->TreeS();
752 TTree *treeD = gAlice->TreeD();
753 TTree *treeR = gAlice->TreeR();
755 AliDetector::SetTreeAddress();
757 SetTreeAddressS(treeS);
758 SetTreeAddressD(treeD);
759 SetTreeAddressR(treeR);
761 //______________________________________________________________________
762 AliITSDetType* AliITS::DetType(Int_t id){
763 // Return pointer to id detector type.
765 // Int_t id detector id number.
769 // returned, a pointer to a AliITSDetType.
771 return ((AliITSDetType*) fDetTypes->At(id));
773 //______________________________________________________________________
774 void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){
775 // Set the response model for the id detector type.
777 // Int_t id detector id number.
778 // AliITSresponse* a pointer containing an instance of AliITSresponse
779 // to be stored/owned b y AliITSDetType.
785 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);
787 //______________________________________________________________________
788 void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
789 // Set the segmentation model for the id detector type.
791 // Int_t id detector id number.
792 // AliITSsegmentation* a pointer containing an instance of
793 // AliITSsegmentation to be stored/owned b y
800 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);
802 //______________________________________________________________________
803 void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){
804 // Set the simulation model for the id detector type.
806 // Int_t id detector id number.
807 // AliITSresponse* a pointer containing an instance of AliITSresponse
808 // to be stored/owned b y AliITSDetType.
814 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);
817 //______________________________________________________________________
818 void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){
819 // Set the cluster finder model for the id detector type.
821 // Int_t id detector id number.
822 // AliITSClusterFinder* a pointer containing an instance of
823 // AliITSClusterFinder to be stored/owned b y
830 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst);
832 //______________________________________________________________________
833 void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){
834 // Set the digit and cluster classes name to be used for the id detector
837 // Int_t id detector id number.
838 // const char *digit Digit class name for detector id.
839 // const char *cluster Cluster class name for detector id.
845 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);
847 //______________________________________________________________________
848 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
850 // The function to add information to the AliITShit class. See the
851 // AliITShit class for a full description. This function allocates the
852 // necessary new space for the hit information and passes the variable
853 // track, and the pointers *vol and *hits to the AliITShit constructor
856 // Int_t track Track number which produced this hit.
857 // Int_t *vol Array of Integer Hit information. See AliITShit.h
858 // Float_t *hits Array of Floating Hit information. see AliITShit.h
864 TClonesArray &lhits = *fHits;
865 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
867 //______________________________________________________________________
868 void AliITS::InitModules(Int_t size,Int_t &nmodules){
869 // Initialize the modules array.
871 // Int_t size Size of array of the number of modules to be
872 // created. If size <=0 then the number of modules
873 // is gotten from AliITSgeom class kept in fITSgeom.
875 // Int_t &nmodules The number of modules existing.
880 fITSmodules->Delete();
882 } // end fir fITSmoudles
884 Int_t nl,indexMAX,index;
886 if(size<=0){ // default to using data stored in AliITSgeom
888 Error("InitModules","fITSgeom not defined");
890 } // end if fITSgeom==0
891 nl = fITSgeom->GetNlayers();
892 indexMAX = fITSgeom->GetModuleIndex(nl,fITSgeom->GetNladders(nl),
893 fITSgeom->GetNdetectors(nl))+1;
895 fITSmodules = new TObjArray(indexMAX);
896 for(index=0;index<indexMAX;index++){
897 fITSmodules->AddAt( new AliITSmodule(index),index);
900 fITSmodules = new TObjArray(size);
901 for(index=0;index<size;index++) {
902 fITSmodules->AddAt( new AliITSmodule(index),index);
908 //______________________________________________________________________
909 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
910 Option_t *option,Text_t *filename){
911 // fill the modules with the sorted by module hits; add hits from
912 // background if option=Add.
914 // Int_t evnt Event to be processed.
915 // Int_t bgrev Background Hit tree number.
916 // Int_t nmodules Not used.
917 // Option_t *option String indicating if merging hits or not. To
918 // merge hits set equal to "Add". Otherwise no
919 // background hits are considered.
920 // Test_t *filename File name containing the background hits..
925 static TTree *trH1; //Tree with background hits
926 static TClonesArray *fHits2; //List of hits for one track only
927 static Bool_t first=kTRUE;
929 const char *addBgr = strstr(option,"Add");
933 file=new TFile(filename);
934 fHits2 = new TClonesArray("AliITShit",1000 );
939 // Get Hits Tree header from file
940 if(fHits2) fHits2->Clear();
941 if(trH1) delete trH1;
945 sprintf(treeName,"TreeH%d",bgrev);
946 trH1 = (TTree*)gDirectory->Get(treeName);
948 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
950 // Set branch addresses
953 sprintf(branchname,"%s",GetName());
954 if (trH1 && fHits2) {
955 branch = trH1->GetBranch(branchname);
956 if (branch) branch->SetAddress(&fHits2);
957 } // end if trH1 && fHits
960 TClonesArray *itsHits = this->Hits();
961 Int_t lay,lad,det,index;
964 TTree *iTH = gAlice->TreeH();
965 Int_t ntracks =(Int_t) iTH->GetEntries();
967 for(t=0; t<ntracks; t++){
970 Int_t nhits = itsHits->GetEntriesFast();
971 if (!nhits) continue;
972 for(h=0; h<nhits; h++){
973 itsHit = (AliITShit *)itsHits->UncheckedAt(h);
974 itsHit->GetDetectorID(lay,lad,det);
975 // temporarily index=det-1 !!!
976 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
979 mod = this->GetModule(index);
980 mod->AddHit(itsHit,t,h);
981 } // end loop over hits
982 } // end loop over tracks
984 // open the file with background
988 ntracks =(Int_t)trH1->GetEntries();
990 for (track=0; track<ntracks; track++) {
991 if (fHits2) fHits2->Clear();
992 trH1->GetEvent(track);
994 for(i=0;i<fHits2->GetEntriesFast();++i) {
995 itsHit=(AliITShit*) (*fHits2)[i];
996 itsHit->GetDetectorID(lay,lad,det);
997 // temporarily index=det-1 !!!
998 if(fITSgeom) index = fITSgeom->GetModuleIndex(lay,lad,det);
1001 mod = this->GetModule(index);
1002 mod->AddHit(itsHit,track,i);
1003 } // end loop over hits
1004 } // end loop over tracks
1005 TTree *fAli=gAlice->TreeK();
1007 if (fAli) fileAli =fAli->GetCurrentFile();
1011 //______________________________________________________________________
1012 void AliITS::ClearModules(){
1013 // Clear the modules TObjArray.
1019 if(fITSmodules) fITSmodules->Delete();
1021 //______________________________________________________________________
1022 void AliITS::MakeBranchS(const char *fl){
1023 // Creates Tree Branch for the ITS summable digits.
1025 // cont char *fl File name where SDigits branch is to be written
1026 // to. If blank it write the SDigits to the same
1027 // file in which the Hits were found.
1032 Int_t buffersize = 4000;
1033 char branchname[30];
1035 // only one branch for SDigits.
1036 sprintf(branchname,"%s",GetName());
1037 if(fSDigits && gAlice->TreeS()){
1038 MakeBranchInTree(gAlice->TreeS(),branchname,&fSDigits,buffersize,fl);
1041 //______________________________________________________________________
1042 void AliITS::SetTreeAddressS(TTree *treeS){
1043 // Set branch address for the ITS summable digits Trees.
1045 // TTree *treeS Tree containing the SDigits.
1050 char branchname[30];
1054 sprintf(branchname,"%s",GetName());
1055 branch = treeS->GetBranch(branchname);
1056 if (branch) branch->SetAddress(&fSDigits);
1058 //______________________________________________________________________
1059 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
1060 // Creates Tree branches for the ITS.
1062 // TTree *treeD Pointer to the Digits Tree.
1063 // cont char *file File name where Digits branch is to be written
1064 // to. If blank it write the SDigits to the same
1065 // file in which the Hits were found.
1070 Int_t buffersize = 4000;
1071 char branchname[30];
1073 sprintf(branchname,"%s",GetName());
1074 // one branch for digits per type of detector
1075 const char *det[3] = {"SPD","SDD","SSD"};
1079 for (i=0; i<kNTYPES ;i++) {
1080 DetType(i)->GetClassNames(digclass,clclass);
1082 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1083 else ResetDigits(i);
1085 for (i=0; i<kNTYPES ;i++) {
1086 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1087 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1088 if (fDtype && treeD) {
1089 MakeBranchInTree(treeD,
1090 branchname, &((*fDtype)[i]),buffersize,file);
1094 //______________________________________________________________________
1095 void AliITS::SetTreeAddressD(TTree *treeD){
1096 // Set branch address for the Trees.
1098 // TTree *treeD Tree containing the Digits.
1103 char branchname[30];
1104 const char *det[3] = {"SPD","SDD","SSD"};
1111 for (i=0; i<kNTYPES; i++) {
1112 DetType(i)->GetClassNames(digclass,clclass);
1114 if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i);
1115 else ResetDigits(i);
1116 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
1117 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
1119 branch = treeD->GetBranch(branchname);
1120 if (branch) branch->SetAddress(&((*fDtype)[i]));
1124 //______________________________________________________________________
1125 void AliITS::Hits2SDigits(){
1126 // Standard Hits to summable Digits function.
1132 // return; // Using Hits in place of the larger sDigits.
1133 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1134 // Do the Hits to Digits operation. Use Standard input values.
1135 // Event number from file, no background hit merging , use size from
1136 // AliITSgeom class, option="All", input from this file only.
1137 HitsToSDigits(header->GetEvent(),0,-1," ",fOpt," ");
1139 //______________________________________________________________________
1140 void AliITS::Hits2PreDigits(){
1141 // Standard Hits to summable Digits function.
1147 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1148 // Do the Hits to Digits operation. Use Standard input values.
1149 // Event number from file, no background hit merging , use size from
1150 // AliITSgeom class, option="All", input from this file only.
1151 HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," ");
1153 //______________________________________________________________________
1154 void AliITS::SDigitsToDigits(Option_t *opt){
1155 // Standard Summable digits to Digits function.
1160 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1162 if(!GetITSgeom()) return; // need transformations to do digitization.
1163 AliITSgeom *geom = GetITSgeom();
1165 const char *all = strstr(opt,"All");
1166 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1168 if( !det[0] && !det[1] && !det[2] ) all = "All";
1170 static Bool_t setDef=kTRUE;
1171 if (setDef) SetDefaultSimulation();
1174 AliITSsimulation *sim = 0;
1175 AliITSDetType *iDetType = 0;
1176 TTree *trees = gAlice->TreeS();
1177 if( !(trees && this->GetSDigits()) ){
1178 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1181 sprintf( name, "%s", this->GetName() );
1182 TBranch *brchSDigits = trees->GetBranch( name );
1185 for(module=0;module<geom->GetIndexMax();module++){
1186 id = geom->GetModuleType(module);
1187 if (!all && !det[id]) continue;
1188 iDetType = DetType(id);
1189 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1191 Error("SDigit2Digits",
1192 "The simulation class was not instanciated!");
1195 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1197 // add summable digits to module
1198 this->GetSDigits()->Clear();
1199 brchSDigits->GetEvent(module);
1200 sim->AddSDigitsToModule(GetSDigits(),0);
1202 // Digitise current module sum(SDigits)->Digits
1203 sim->FinishSDigitiseModule();
1205 // fills all branches - wasted disk space
1206 gAlice->TreeD()->Fill();
1207 this->ResetDigits();
1210 gAlice->TreeD()->GetEntries();
1212 gAlice->TreeD()->AutoSave();
1214 gAlice->TreeD()->Reset();
1217 //______________________________________________________________________
1218 void AliITS::Hits2Digits(){
1219 // Standard Hits to Digits function.
1225 AliHeader *header=gAlice->GetHeader(); // Get event number from this file.
1226 // Do the Hits to Digits operation. Use Standard input values.
1227 // Event number from file, no background hit merging , use size from
1228 // AliITSgeom class, option="All", input from this file only.
1229 HitsToDigits(header->GetEvent(),0,-1," ",fOpt," ");
1231 //______________________________________________________________________
1232 void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1233 Option_t *option, Option_t *opt,Text_t *filename){
1234 // keep galice.root for signal and name differently the file for
1235 // background when add! otherwise the track info for signal will be lost !
1236 // the condition below will disappear when the geom class will be
1237 // initialized for all versions - for the moment it is only for v5 !
1238 // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable
1241 // Int_t evnt Event to be processed.
1242 // Int_t bgrev Background Hit tree number.
1243 // Int_t nmodules Not used.
1244 // Option_t *option String indicating if merging hits or not. To
1245 // merge hits set equal to "Add". Otherwise no
1246 // background hits are considered.
1247 // Test_t *filename File name containing the background hits..
1252 // return; // using Hits instead of the larger sdigits.
1254 HitsToPreDigits(evNumber,bgrev,size,option,opt,filename);
1256 //______________________________________________________________________
1257 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1258 Option_t *option, Option_t *opt,Text_t *filename){
1259 // Keep galice.root for signal and name differently the file for
1260 // background when add! otherwise the track info for signal will be lost !
1261 // the condition below will disappear when the geom class will be
1262 // initialized for all versions - for the moment it is only for v5 !
1263 // 7 is the SDD beam test version.
1265 // Int_t evnt Event to be processed.
1266 // Int_t bgrev Background Hit tree number.
1267 // Int_t nmodules Not used.
1268 // Option_t *option String indicating if merging hits or not. To
1269 // merge hits set equal to "Add". Otherwise no
1270 // background hits are considered.
1271 // Test_t *filename File name containing the background hits..
1277 if(!GetITSgeom()) return; // need transformations to do digitization.
1278 AliITSgeom *geom = GetITSgeom();
1280 const char *all = strstr(opt,"All");
1281 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1283 static Bool_t setDef=kTRUE;
1284 if (setDef) SetDefaultSimulation();
1288 InitModules(size,nmodules);
1289 FillModules(evNumber,bgrev,nmodules,option,filename);
1291 AliITSsimulation *sim = 0;
1292 AliITSDetType *iDetType = 0;
1293 AliITSmodule *mod = 0;
1295 for(module=0;module<geom->GetIndexMax();module++){
1296 id = geom->GetModuleType(module);
1297 if (!all && !det[id]) continue;
1298 iDetType = DetType(id);
1299 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1301 Error("HitsToSDigits",
1302 "The simulation class was not instanciated!");
1305 mod = (AliITSmodule *)fITSmodules->At(module);
1306 sim->SDigitiseModule(mod,module,evNumber);
1307 // fills all branches - wasted disk space
1308 gAlice->TreeS()->Fill();
1314 gAlice->TreeS()->GetEntries();
1315 gAlice->TreeS()->AutoSave();
1317 gAlice->TreeS()->Reset();
1319 //______________________________________________________________________
1320 void AliITS::HitsToDigits(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("HitsToDigits",
1365 "The simulation class was not instanciated!");
1368 mod = (AliITSmodule *)fITSmodules->At(module);
1369 sim->DigitiseModule(mod,module,evNumber);
1370 // fills all branches - wasted disk space
1371 gAlice->TreeD()->Fill();
1377 gAlice->TreeD()->GetEntries();
1378 gAlice->TreeD()->AutoSave();
1380 gAlice->TreeD()->Reset();
1382 //______________________________________________________________________
1383 void AliITS::ResetSDigits(){
1384 // Reset the Summable Digits array.
1390 if (fSDigits) fSDigits->Clear();
1393 //______________________________________________________________________
1394 void AliITS::ResetDigits(){
1395 // Reset number of digits and the digits array for the ITS detector.
1401 if (!fDtype) return;
1404 for (i=0;i<kNTYPES;i++ ) {
1405 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1406 if (fNdtype) fNdtype[i]=0;
1409 //______________________________________________________________________
1410 void AliITS::ResetDigits(Int_t i){
1411 // Reset number of digits and the digits array for this branch.
1417 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1418 if (fNdtype) fNdtype[i]=0;
1420 //______________________________________________________________________
1421 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1422 // Adds the a module full of summable digits to the summable digits tree.
1424 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1430 TClonesArray &lsdig = *fSDigits;
1431 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1433 //______________________________________________________________________
1434 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1435 // Add a real digit - as coming from data.
1437 // Int_t id Detector type number.
1438 // Int_t *digits Integer array containing the digits info. See
1445 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1446 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1448 //______________________________________________________________________
1449 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1450 // Add a simulated digit.
1452 // Int_t id Detector type number.
1453 // AliITSdigit *d Digit to be added to the Digits Tree. See
1460 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1464 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1467 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1470 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1474 //______________________________________________________________________
1475 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1476 Int_t *hits,Float_t *charges){
1477 // Add a simulated digit to the list.
1479 // Int_t id Detector type number.
1480 // Float_t phys Physics indicator. See AliITSdigits.h
1481 // Int_t *digits Integer array containing the digits info. See
1483 // Int_t *tracks Integer array [3] containing the track numbers that
1484 // contributed to this digit.
1485 // Int_t *hits Integer array [3] containing the hit numbers that
1486 // contributed to this digit.
1487 // Float_t *charge Floating point array of the signals contributed
1488 // to this digit by each track.
1494 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1497 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1500 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1504 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1508 //______________________________________________________________________
1509 void AliITS::MakeTreeC(Option_t *option){
1510 // Create a separate tree to store the clusters.
1512 // Option_t *option string which must contain "C" otherwise
1513 // no Cluster Tree is created.
1518 TDirectory *cwd = gDirectory;
1519 TFile *fileRecPoints = gAlice->GetTreeRFile();
1520 if(fileRecPoints)fileRecPoints->cd();
1521 const char *optC = strstr(option,"C");
1522 if (optC && !fTreeC) fTreeC = new TTree("TC","Clusters in ITS");
1525 Int_t buffersize = 4000;
1526 char branchname[30];
1527 const char *det[3] = {"SPD","SDD","SSD"};
1531 // one branch for Clusters per type of detector
1533 for (i=0; i<kNTYPES ;i++) {
1534 AliITSDetType *iDetType=DetType(i);
1535 iDetType->GetClassNames(digclass,clclass);
1537 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1538 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1539 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1540 if (fCtype && fTreeC) {
1541 TreeC()->Branch(branchname,&((*fCtype)[i]), buffersize);
1542 } // end if fCtype && fTreeC
1546 //______________________________________________________________________
1547 void AliITS::GetTreeC(Int_t event){
1548 // Get the clusters tree for this event and set the branch address.
1550 // Int_t event Event number for the cluster tree.
1556 char branchname[30];
1557 const char *det[3] = {"SPD","SDD","SSD"};
1564 sprintf(treeName,"TreeC%d",event);
1565 TFile *fileRecPoints = gAlice->GetTreeRFile();
1567 fTreeC = (TTree*)gDirectory->Get(treeName);
1570 fTreeC = (TTree*)fileRecPoints->Get(treeName);
1579 for (i=0; i<kNTYPES; i++) {
1580 AliITSDetType *iDetType=DetType(i);
1581 iDetType->GetClassNames(digclass,clclass);
1583 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1584 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1585 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1587 branch = fTreeC->GetBranch(branchname);
1588 if (branch) branch->SetAddress(&((*fCtype)[i]));
1592 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1595 //______________________________________________________________________
1596 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1597 // Add a cluster to the list.
1599 // Int_t id Detector type number.
1600 // AliITSRawCluster *c Cluster class to be added to the tree of
1607 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1611 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1614 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1617 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1621 //______________________________________________________________________
1622 void AliITS::ResetClusters(){
1623 // Reset number of clusters and the clusters array for ITS.
1630 for (i=0;i<kNTYPES;i++ ) ResetClusters(i);
1632 //______________________________________________________________________
1633 void AliITS::ResetClusters(Int_t i){
1634 // Reset number of clusters and the clusters array for this branch.
1636 // Int_t i Detector type number.
1642 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1643 if (fNctype) fNctype[i]=0;
1645 //______________________________________________________________________
1646 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1647 // Creates Tree branches for the ITS Reconstructed points.
1649 // cont char *file File name where RecPoints branch is to be written
1650 // to. If blank it write the SDigits to the same
1651 // file in which the Hits were found.
1656 Int_t buffsz = 4000;
1657 char branchname[30];
1659 // only one branch for rec points for all detector types
1660 Bool_t oFast= (strstr(opt,"Fast")!=0);
1662 sprintf(branchname,"%sRecPointsF",GetName());
1664 sprintf(branchname,"%sRecPoints",GetName());
1666 if (fRecPoints && gAlice->TreeR()) {
1667 MakeBranchInTree(gAlice->TreeR(),branchname,&fRecPoints,buffsz,file);
1670 //______________________________________________________________________
1671 void AliITS::SetTreeAddressR(TTree *treeR){
1672 // Set branch address for the Reconstructed points Trees.
1674 // TTree *treeR Tree containing the RecPoints.
1679 char branchname[30];
1683 sprintf(branchname,"%sRecPoints",GetName());
1684 branch = treeR->GetBranch(branchname);
1686 branch->SetAddress(&fRecPoints);
1689 sprintf(branchname,"%sRecPointsF",GetName());
1690 branch = treeR->GetBranch(branchname);
1692 branch->SetAddress(&fRecPoints);
1696 //______________________________________________________________________
1697 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1698 // Add a reconstructed space point to the list
1700 // const AliITSRecPoint &r RecPoint class to be added to the tree
1701 // of reconstructed points TreeR.
1707 TClonesArray &lrecp = *fRecPoints;
1708 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1710 //______________________________________________________________________
1711 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1712 Option_t *opt0,Option_t *opt1,Text_t *flnm){
1713 // keep galice.root for signal and name differently the file for
1714 // background when add! otherwise the track info for signal will be lost !
1715 // the condition below will disappear when the geom class will be
1716 // initialized for all versions - for the moment it is only for v5 !
1718 // Int_t evnt Event to be processed.
1719 // Int_t bgrev Background Hit tree number.
1720 // Int_t size Size used by InitModules. See InitModules.
1721 // Option_t *opt0 Option passed to FillModules. See FillModules.
1722 // Option_t *opt1 String indicating if merging hits or not. To
1723 // merge hits set equal to "Add". Otherwise no
1724 // background hits are considered.
1725 // Test_t *flnm File name containing the background hits..
1731 if(!GetITSgeom()) return;
1732 AliITSgeom *geom = GetITSgeom();
1734 const char *all = strstr(opt1,"All");
1735 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1736 strstr(opt1,"SSD")};
1738 InitModules(size,nmodules);
1739 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1741 AliITSsimulation *sim = 0;
1742 AliITSDetType *iDetType = 0;
1743 AliITSmodule *mod = 0;
1746 //m.b. : this change is nothing but a nice way to make sure
1748 for(module=0;module<geom->GetIndexMax();module++){
1749 id = geom->GetModuleType(module);
1750 if (!all && !det[id]) continue;
1751 iDetType = DetType(id);
1752 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1754 Error("HitsToFastPoints",
1755 "The simulation class was not instanciated!");
1758 mod = (AliITSmodule *)fITSmodules->At(module);
1759 sim->CreateFastRecPoints(mod,module,gRandom);
1760 // gAlice->TreeR()->Fill();
1761 TBranch *br=gAlice->TreeR()->GetBranch("ITSRecPointsF");
1768 gAlice->TreeR()->AutoSave();
1770 gAlice->TreeR()->Reset();
1772 //______________________________________________________________________
1773 void AliITS::Digits2Reco(){
1774 // Find clusters and reconstruct space points.
1780 AliHeader *header=gAlice->GetHeader();
1781 // to Digits to RecPoints for event in file, all digits in file, and
1782 // all ITS detectors.
1783 DigitsToRecPoints(header->GetEvent(),0,fOpt);
1785 //______________________________________________________________________
1786 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1787 // cluster finding and reconstruction of space points
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 !
1790 // 7 is the SDD beam test version
1792 // Int_t evNumber Event number to be processed.
1793 // Int_t lastentry Offset for module when not all of the modules
1795 // Option_t *opt String indicating which ITS sub-detectors should
1796 // be processed. If ="All" then all of the ITS
1797 // sub detectors are processed.
1803 if(!GetITSgeom()) return;
1804 AliITSgeom *geom = GetITSgeom();
1806 const char *all = strstr(opt,"All");
1807 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1809 static Bool_t setRec=kTRUE;
1810 if (setRec) SetDefaultClusterFinders();
1813 TTree *treeC=TreeC();
1814 AliITSClusterFinder *rec = 0;
1815 AliITSDetType *iDetType = 0;
1816 Int_t id,module,first=0;
1817 for(module=0;module<geom->GetIndexMax();module++){
1818 id = geom->GetModuleType(module);
1819 if (!all && !det[id]) continue;
1820 if(det[id]) first = geom->GetStartDet(id);
1821 iDetType = DetType(id);
1822 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1823 TClonesArray *itsDigits = this->DigitsAddress(id);
1825 Error("DigitsToRecPoints",
1826 "The reconstruction class was not instanciated!");
1829 this->ResetDigits();
1830 if (all) gAlice->TreeD()->GetEvent(lastentry+module);
1831 else gAlice->TreeD()->GetEvent(lastentry+(module-first));
1832 Int_t ndigits = itsDigits->GetEntriesFast();
1833 if (ndigits) rec->FindRawClusters(module);
1834 gAlice->TreeR()->Fill();
1840 gAlice->TreeR()->GetEntries();
1841 treeC->GetEntries();
1842 gAlice->TreeR()->AutoSave();
1844 gAlice->TreeR()->Reset();
1849 //______________________________________________________________________
1850 void AliITS::ResetRecPoints(){
1851 // Reset number of rec points and the rec points array.
1857 if (fRecPoints) fRecPoints->Clear();