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