3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ////////////////////////////////////////////////////////////////////////
9 // Manager class for set: ITS //
10 ////////////////////////////////////////////////////////////////////////
14 #include <TObjArray.h> // used in inline function GetModule.
15 #include <TBranch.h> // used in inline function SetHitsAddressBranch
17 #include "AliRunLoader.h"
18 #include "AliDetector.h"
20 #include "AliITSDetType.h"
23 #include "AliITSDetTypeSim.h"
24 #include "AliITSDetTypeRec.h"
31 class AliITSsimulation;
32 class AliITSClusterFinder;
34 class AliITSsegmentation;
38 class AliITSpListItem;
41 class AliITSRawCluster;
45 class AliRunDigitizer;
47 const Int_t kNTYPES=3;
49 class AliITS : public AliDetector {
52 //================= Standard Classes ===============================
53 AliITS(); // Default creator.
54 AliITS(const char *name, const char *title); // standard Creator
55 virtual ~AliITS(); // destructor
56 AliITS(const AliITS &source); // copy constructor. Not to be used!
57 AliITS& operator=(AliITS &source); // = operator. Not to be used!
58 virtual Int_t IsVersion() const {return 1;}
59 virtual Int_t DistancetoPrimitive(Int_t,Int_t) const{return 999;};
61 //===================== Simulation Geometry ========================
62 // get geometry version - detailed (major) or coarse (minor)
63 virtual Int_t GetMajorVersion() const {return -1;}
64 virtual Int_t GetMinorVersion() const {return -1;}
65 virtual void GetGeometryVersion(Int_t &a,Int_t &b)
66 {a = GetMajorVersion();b=GetMinorVersion();return;}
67 virtual void SetEUCLID(Bool_t euclid=kTRUE) {fEuclidOut = euclid;}
68 virtual Bool_t GetEUCLID()const {return fEuclidOut;}
69 //-------------------- Geometry Transformations --------------------
71 // ITS geometry functions
72 AliITSgeom *GetITSgeom() const {return fITSgeom;}
73 // Sets ITS geometry ! be very careful using this function.
74 void SetITSgeom(AliITSgeom *geom) {fITSgeom = geom;}
75 // return pointer to the array of modules
76 TObjArray *GetModules() const {return fITSmodules;}
77 // return pointer to a particular module
78 AliITSmodule *GetModule(Int_t index) {return (AliITSmodule *)
79 (fITSmodules->At(index));}
82 // ITS geometry functions
83 AliITSgeom* GetITSgeom()const{if(fDetTypeSim!=0)
84 return fDetTypeSim->GetITSgeom();else if(fDetTypeRec!=0)
85 return fDetTypeRec->GetITSgeom();else return 0;}
86 // ITS geometry functions From Simulation
87 AliITSgeom* GetITSgeomSim()const{if(fDetTypeSim!=0)
88 return fDetTypeSim->GetITSgeom();else return 0;}
89 // ITS geometry functions From Reconstruction
90 AliITSgeom* GetITSgeomRec()const{if(fDetTypeRec!=0)
91 return fDetTypeRec->GetITSgeom();else return 0;}
92 // Sets ITS geometry ! be very careful using this function.
93 void SetITSgeom(AliITSgeom *geom) {if(fDetTypeSim!=0)
94 fDetTypeSim->SetITSgeom(geom);if(fDetTypeRec!=0)
95 fDetTypeRec->SetITSgeom(geom);}
96 // Sets ITS geometry For Simulation ! be very careful using this function.
97 void SetITSgeomSim(AliITSgeom *geom) {if(fDetTypeSim!=0)
98 fDetTypeSim->SetITSgeom(geom);}
99 // Sets ITS geometry For Reconstruction! be very careful using this fun.
100 void SetITSgeomRec(AliITSgeom *geom) {if(fDetTypeRec!=0)
101 fDetTypeRec->SetITSgeom(geom);}
102 // return pointer to the array of modules
103 TObjArray *GetModules() const {return fDetTypeSim->GetModules();}
104 // return pointer to a particular module
105 AliITSmodule *GetModule(Int_t index){return fDetTypeSim->GetModule(index);}
108 //================ Necessary general Classes =======================
110 virtual AliLoader* MakeLoader(const char* topfoldername);
111 virtual void SetDefaults();
112 virtual void SetDefaultSimulation();
113 virtual void SetDefaultClusterFinders();
114 virtual void MakeBranch(Option_t *opt=" ");
115 virtual void SetTreeAddress();
117 // For a given branch from the treeH sets the TClonesArray address.
118 virtual void SetHitsAddressBranch(TBranch *b) {b->SetAddress(&fHits);}
119 // Return pointer to DetType #id
120 AliITSDetType *DetType(Int_t id){
121 return ((AliITSDetType*) fDetTypes->At(id));};
122 //Int_t NDetTypes() {return fNDetTypes;}
124 //---------- Configuration Methods (per detector type) -------------
125 // Determines which ITS subdetectors will be processed. Effects
126 // digitization, and Reconstruction only.
127 void SetDetectors(Option_t *opt="All"){fOpt = opt;}
128 // Returns the list of ITS subdetectors that will be processed.
129 Option_t* GetDetectors(){return fOpt;}
132 virtual void SetResponseModel(Int_t id, AliITSresponse *response){
133 ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);};
135 virtual void SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
136 ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);};
137 // Set simulation - temporary
138 virtual void SetSimulationModel(Int_t id, AliITSsimulation *sim){
139 ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);};
140 // Set simulation - temporary
141 virtual AliITSsimulation* GetSimulationModel(Int_t id){
142 return ((AliITSDetType*)(fDetTypes->At(id)))->GetSimulationModel();}
143 // Set reconstruction
144 virtual void SetReconstructionModel(Int_t id, AliITSClusterFinder *rec){
145 ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(rec);};
146 // Set class names for digit and rec point
147 virtual void SetClasses(Int_t id, const char *digit, const char *cluster){
148 ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);};
152 virtual void SetResponseModel(Int_t module, AliITSresponse *response){
153 fDetTypeSim->SetResponseModel(module,response);};
154 // Set segmentation for Simulation
155 virtual void SetSegmentationModelSim(Int_t id, AliITSsegmentation *seg){
156 fDetTypeSim->SetSegmentationModel(id,seg);};
157 // Set segmentation for Reconstruction
158 virtual void SetSegmentationModelRec(Int_t id, AliITSsegmentation *seg){
159 fDetTypeRec->SetSegmentationModel(id,seg);};
161 virtual void SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
162 SetSegmentationModelSim(id,seg);SetSegmentationModelRec(id,seg);};
164 virtual void SetSimulationModel(Int_t id, AliITSsimulation *sim){
165 fDetTypesSim->SetSimulationModel(sim);};
167 virtual AliITSsimulation* GetSimulationModel(Int_t id){
168 return fDetTypesSim->GetSimulationModel(id);}
170 virtual void SetCalibrationModel(Int_t module, AliITSCalibration *cal){
171 fDetTypeRec->SetCalibrationModel(module,cal);};
172 // Set reconstruction
173 virtual void SetReconstructionModel(Int_t id, AliITSClusterFinder *rec){
174 fDetTypesRec->SetReconstructionModel(id,rec);};
175 // Set Class name for Hits
176 virtual void SetHitClassName(){
177 fDetTypeSim->SetHitClassName(this->GetName());}
178 // Set Class name for SDigits
179 virtual void SetSDigitClassName(const char *sdigit){
180 fDetTypeSim->SetSDigitClassName(sdigit);}
181 // Set Class name for Digits for simulation
182 virtual void SetDigitClassNameSim(const char *digit){
183 fDetTypeSim->SetDigitClassName(digit);}///////// Array of names
184 // Set Class name for Digits for Reconstruction
185 virtual void SetDigitClassNameRec(const char *digit){
186 fDetTypeRec->SetDigitClassName(digit);}///////// Array of names
187 virtual void SetClusterClassName(const char *digit){
188 fDetTypeRec->SetClusterClassName(digit);}///////// Array of names
189 virtual void SetRecPointClassName(const char *digit){
190 fDetTypeRec->SetRecPointClassName(digit);}///////// Array of names
191 // Set class names for digit and rec point
192 virtual void SetClasses(Int_t id, const char *digit, const char *cluster){
193 SetDigitClassNameSim(digit);SetDigitClassNameRec(digit);
194 SetRecPointClassName(cluster);};
197 //=================== Hits =========================================
198 virtual void StepManager() {} // See Step Manager for specific geometry.
199 //------------ sort hits by module for Digitisation ----------------
200 virtual void FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
201 Option_t *opt, const char *filename);
203 virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
204 virtual void InitModules(Int_t size,Int_t &nmodules);
205 virtual void FillModules(TTree *treeH, Int_t mask = 0);
206 virtual void ClearModules(){if(fITSmodules) fITSmodules->Delete();};
209 virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits){
210 if(fDetTypeSim!=0)fDetTypeSim->AddHit(track,vol,hits);};
211 virtual void AddHit(AliITShit &hit){
212 if(fDetTypeSim!=0)fDetTypeSim->AddHit(hit);};
213 virtual void InitModules(Int_t size,Int_t &nmodules){if(fDetTypeSim!=0)
214 fDetTypeSim->InitModules(size,nmodules);};
215 virtual void FillModules(TTree *treeH, Int_t mask = 0){if(fDetTypeSim!=0)
216 fDetTypeSim->FillModules(treeH,mask);};
217 virtual void ClearModules(){if(fDetTypeSim!=0)
218 fDetTypeSim->ClearModules();};
221 //===================== Digitisation ===============================
223 void MakeBranchS(const char *file);
224 void SetTreeAddressS(TTree *treeS);
225 TClonesArray * GetSDigits() { return fSDigits; }
226 void MakeBranchInTreeD(TTree *treeD,const char *file=0);
227 void MakeBranchD(const char *file){
228 MakeBranchInTreeD(GetLoader()->TreeD(),file);}
229 void SetTreeAddressD(TTree *treeD);
232 void Hits2SDigits(); // Turn hits into SDigits
233 void Hits2PreDigits(){ // Turn hits into SDigits
234 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
235 0,-1," ",fOpt," ");};
236 AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const;
237 void SDigits2Digits(){SDigitsToDigits("All");} // Turn SDigits to Digits
238 void SDigitsToDigits(Option_t *opt="All"); // Turn SDigits to Digits
239 void Hits2Digits(); // Turn hits straight into Digits.
240 //------------------ Internal functions ----------------------------
241 // Standard Hits To SDigits function
242 void HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
243 Option_t *add, Option_t *det, const char *filename)
244 {HitsToPreDigits(evNumber,bgrev,size,add,det,filename);};
245 // Standard Hits To SDigits function
246 void HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
247 Option_t *add, Option_t *det, const char *filename);
248 // Standard Hits To Digits function
249 void HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
250 Option_t *add, Option_t *det, const char *filename);
253 // Turn hits into SDigits
254 void Hits2SDigits(){if(fDetTypeSim)fDetTypeSim->Hits2SDigits();};
255 AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const;
256 // Turn SDigits to Digits
257 void SDigits2Digits(){if(fDetTypeSim)fDetTypeSim->SDigits2Digits();}
258 // Turn hits straight into Digits.
259 void Hits2Digits(){if(fDetTypeSim)fDetTypeSim->Hits2Digits();};
261 // Resets the Summable digits.
263 void ResetSDigits(){if(fSDigits) fSDigits->Clear();fNSDigits = 0;};
264 void ResetDigits(); // depending on how the
265 void ResetDigits(Int_t branch); // tree will be filled only
266 void AddSumDigit(AliITSpListItem &sdig);
267 void AddRealDigit(Int_t branch, Int_t *digits);
268 void AddSimDigit(Int_t branch, AliITSdigit *d);
269 void AddSimDigit(Int_t branch,Float_t phys,Int_t* digits,
270 Int_t* tracks,Int_t *hits,Float_t* trkcharges);
272 // Return pointers to digits
274 TObjArray *Dtype() {return fDtype;}
275 Int_t *Ndtype() {return fNdtype;}
276 TClonesArray *DigitsAddress(Int_t id)
277 {return ((TClonesArray *) (*fDtype)[id]);}
280 TObjArray* GetDigitsSim(){if(fDetTypeSim!=0)
281 return fDetTypeSim->GetDigits();else return 0;}
282 TObjArray* GetDigitsRec(){if(fDetTypeRec!=0)
283 return fDetTypeRec->GetDigits();else return 0;}
284 TObjArray *Dtype() {if(fDetTypeSim!=0) return GetDigitsSim();
285 else if(fDetTypeRec!=0) return GetDigitsRec(); else return 0;}
286 Int_t* GetNDigitArraySim(){if(fDetTypeSim!=0)
287 fDetTypeSim->GetNDigitArray();}
288 Int_t* GetNDigitArrayRec(){if(fDetTypeRec!=0)
289 fDetTypeRec->GetNDigitArray();}
290 Int_t *Ndtype() {if(fDetTypeSim!=0) return GetNDigitArraySim();
291 else if(fDetTypeRec!=0) return GetNDigitArrayRec(); else return 0;}
292 TClonesArray *DigitsAddressSim(Int_t id){if(fDetTypeSim!=0)
293 return fDetTypeSim->GetDigitsAddress(id);else return 0;}
294 TClonesArray *DigitsAddressRec(Int_t id){if(fDetTypeRec!=0)
295 return fDetTypeRec->GetDigitsAddress(id);else return 0;}
296 TClonesArray *DigitsAddress(Int_t id){if(fDetTypeSim!=0)
297 return DigitsAddressSim(id);else if(fDetTypeRec!=0) DigitsAddressRec(id);
300 void SelectVertexer(TString sel=" "){fSelectedVertexer = sel;}
303 //===================== Raw Data IO ================================
304 // Write digits into raw data format
305 virtual void Digits2Raw();
307 //==================== Clusterization ==============================
308 // create separate tree for clusters - declustering refining
309 void MakeTreeC(Option_t *option="C");
310 void GetTreeC(Int_t event);
311 void AddCluster(Int_t branch, AliITSRawCluster *c);
312 // one of the methods in
313 void ResetClusters(){for(Int_t i=0;i<kNTYPES;i++ ) ResetClusters(i);};
314 void ResetClusters(Int_t branch); // the pair will be kept
316 // Return pointers to clusters
317 TObjArray *Ctype() {return fCtype;}
318 Int_t *Nctype() {return fNctype;}
319 TClonesArray *ClustersAddress(Int_t id)
320 {return ((TClonesArray *) (*fCtype)[id]);}
324 //===================== Raw Data IO ================================
325 // Write digits into raw data format
326 virtual void Digits2Raw(){if(fDetTypeSim)fDetTypeSim->Digits2Raw();};
328 //==================== Clusterization ==============================
329 // create separate tree for clusters - declustering refining
330 void MakeTreeC(Option_t *option="C"){fDetTypeRec->MakeTreeC();};
331 void GetTreeC(Int_t event){fDetTypeRec->GetTreeC(event);};
332 void AddCluster(Int_t branch, AliITSRawCluster *c){
333 fDetTypeRec->AddCluster(branch,c);};
334 // one of the methods in
335 void ResetClusters(){for(Int_t i=0;i<kNTYPES;i++ ) ResetClusters(i);};
336 void ResetClusters(Int_t branch){fDetTypeRec->ResetCluster(i);};
337 void MakeBranchC(){fDetTypeRec->MakeBranchC();};
338 // Return pointers to clusters
339 TObjArray *Ctype() {if(fDetTypeRec!=0)
340 return fDetTypeRec->GetClusterArray(); else return 0;}
341 Int_t *Nctype() {if(fDetTypeRec!=0)
342 return fDetTypeRec->GetNClusters(); else return 0;;}
343 TClonesArray *ClustersAddress(Int_t id){if(fDetTypeRec!=0)
344 return fDetTypeRec->GetClusterAddress(id]); else return 0;}
347 //=================== Reconstruction ===============================
349 void MakeBranchR(const char *file, Option_t *opt=" ");
350 void SetTreeAddressR(TTree *treeR);
351 void AddRecPoint(const AliITSRecPoint &p);
352 void ResetRecPoints(){if(fRecPoints) fRecPoints->Clear();fNRecPoints = 0;};
353 // Return pointer to rec points
354 TClonesArray *RecPoints() {return fRecPoints;}
357 void MakeBranchR(const char *file, Option_t *opt=" ");
358 void SetTreeAddressR(TTree *treeR){fDetTypeRec->SetTreeAddressR(treeR);};
359 void AddRecPoint(const AliITSRecPoint &p){fDetTypeRec->AddRecPoint(p);};
360 void ResetRecPoints(){if(fDetTypeRec) fDetTypeRec->ResetRecPoints();};
361 // Return pointer to rec points
362 TClonesArray* RecPoints() {if(fDetTypeRec!=0)
363 return fDetTypeRec->GetRecPoints();else return 0;}
365 void MakeBranchRF(const char *file){MakeBranchR(file,"Fast");}
366 void HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
367 Option_t *add, Option_t *det, const char *filename);
369 DigitsToRecPoints(fLoader->GetRunLoader()->GetEventNumber(),0,fOpt);};
370 void DigitsToRecPoints(Int_t evNumber,Int_t lastEntry,Option_t *det);
373 //================== Data Members ==================================
375 AliITSDetTypeSim *fDetTypeSim; //
376 AliITSDetTypeRec *fDetTypeRec; //
379 AliITSgeom *fITSgeom; // Pointer to ITS geometry
381 Bool_t fEuclidOut; // Flag to write geometry in euclid format
383 TObjArray *fITSmodules; //! Pointer to ITS modules
385 Option_t *fOpt; //! Detector option ="All" unless changed.
387 Int_t fIdN; // the number of layers
388 Int_t *fIdSens; //[fIdN] layer identifier
389 TString *fIdName; //[fIdN] layer identifier
391 Int_t fNDetTypes; // Number of detector types
392 TObjArray *fDetTypes; // List of detector types
394 TClonesArray *fSDigits; //! List of Summable digits.
395 Int_t fNSDigits; // Number of Summable Digits.
397 TObjArray *fDtype; //! List of digits
398 Int_t *fNdtype; //[fNDetTypes] Num. of digits per type of det.
400 TObjArray *fCtype; //! List of clusters
401 Int_t *fNctype; //[fNDetTypes] Num. of clust. per type of det.
403 TClonesArray *fRecPoints; //! List of reconstructed points
404 Int_t fNRecPoints; // Number of rec points
406 TString fSelectedVertexer; // Vertexer selected in CreateVertexer
408 ClassDef(AliITS,4) // Base class for ITS
411 ClassDef(AliITS,5) // Base class for ITS