Moving the functions used to initialize TF1 and TF2 to the pivate part of the class
[u/mrichter/AliRoot.git] / ITS / AliITSLoader.cxx
CommitLineData
aacedc3e 1#include "AliITS.h"
2#include "AliITSgeom.h"
3#include "AliITSdigit.h"
4#include "AliRun.h"
5#include "AliDetector.h"
88cb7938 6#include "AliITSLoader.h"
88cb7938 7
aacedc3e 8///////////////////////////////////////////////////////////////////////////
eeac5f9f 9// Loader for ITS
10// it manages the I/O for:
11// raw clusters, primary vertices
12// V0 and cascade
13// and tracks propagated to the origin
aacedc3e 14//////////////////////////////////////////////////////////////////////////
88cb7938 15const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
16const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
17const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
566abf75 18const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
19const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
88cb7938 20
21ClassImp(AliITSLoader)
22
aacedc3e 23/**********************************************************************/
eeac5f9f 24 AliITSLoader::AliITSLoader():AliLoader(){
25 // Default constructor
aacedc3e 26}
27/*********************************************************************/
28AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
29AliLoader(name,topfoldername){
30 //ctor
31 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
32 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
33 "Raw Clusters");
34 fDataLoaders->Add(rawClustersDataLoader);
35 rawClustersDataLoader->SetEventFolder(fEventFolder);
36 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
37
38 AliDataLoader* backTracksDataLoader = new AliDataLoader(
39 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
40 "Back Propagated Tracks");
41 fDataLoaders->Add(backTracksDataLoader);
42 backTracksDataLoader->SetEventFolder(fEventFolder);
43 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 44
aacedc3e 45 AliDataLoader* vertexDataLoader = new AliDataLoader(
46 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
47 "Primary Vertices","O");
48 fDataLoaders->Add(vertexDataLoader);
49 vertexDataLoader->SetEventFolder(fEventFolder);
50 vertexDataLoader->SetFolder(GetDetectorDataFolder());
51
52 AliDataLoader* v0DataLoader = new AliDataLoader(
53 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
54 fDataLoaders->Add(v0DataLoader);
55 v0DataLoader->SetEventFolder(fEventFolder);
56 v0DataLoader->SetFolder(GetDetectorDataFolder());
57
58 AliDataLoader* cascadeDataLoader = new AliDataLoader(
59 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
60 "Cascades");
61 fDataLoaders->Add(cascadeDataLoader);
62 cascadeDataLoader->SetEventFolder(fEventFolder);
63 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 64}
aacedc3e 65/**********************************************************************/
66AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
67AliLoader(name,topfolder) {
68 //ctor
69 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
70 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
71 "Raw Clusters");
72 fDataLoaders->Add(rawClustersDataLoader);
73 rawClustersDataLoader->SetEventFolder(fEventFolder);
74 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 75
aacedc3e 76 AliDataLoader* backTracksDataLoader = new AliDataLoader(
77 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
78 "Back Propagated Tracks");
79 fDataLoaders->Add(backTracksDataLoader);
80 backTracksDataLoader->SetEventFolder(fEventFolder);
81 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
82
83 AliDataLoader* vertexDataLoader = new AliDataLoader(
84 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
85 "Primary Vertices","O");
86 fDataLoaders->Add(vertexDataLoader);
87 vertexDataLoader->SetEventFolder(fEventFolder);
88 vertexDataLoader->SetFolder(GetDetectorDataFolder());
89
90 AliDataLoader* v0DataLoader = new AliDataLoader(
91 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
92 fDataLoaders->Add(v0DataLoader);
93 v0DataLoader->SetEventFolder(fEventFolder);
94 v0DataLoader->SetFolder(GetDetectorDataFolder());
95
96 AliDataLoader* cascadeDataLoader = new AliDataLoader(
97 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
98 "Cascades");
99 fDataLoaders->Add(cascadeDataLoader);
100 cascadeDataLoader->SetEventFolder(fEventFolder);
101 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
88cb7938 102}
aacedc3e 103/**********************************************************************/
104AliITSLoader::~AliITSLoader(){
105 //destructor
106 AliDataLoader* dl = 0;
107 UnloadRawClusters();
108 dl = GetRawClLoader();
109 fDataLoaders->Remove(dl);
88cb7938 110
aacedc3e 111 UnloadBackTracks();
112 dl = GetBackTracksDataLoader();
113 fDataLoaders->Remove(dl);
114
115 UnloadVertices();
116 dl = GetVertexDataLoader();
117 fDataLoaders->Remove(dl);
118
119 UnloadV0s();
120 dl = GetV0DataLoader();
121 fDataLoaders->Remove(dl);
122
123 UnloadCascades();
124 dl = GetCascadeDataLoader();
125 fDataLoaders->Remove(dl);
88cb7938 126}
aacedc3e 127//----------------------------------------------------------------------
128AliITS* AliITSLoader::GetITS(){
129 // Returns the pointer to the ITS, kept on the file. A short cut metthod
130 // Inputs:
131 // none.
132 // Outputs:
133 // none.
134 // Returns:
135 // Returns a pointer to the ITS, if not found returns 0.
136 AliITS *its;
566abf75 137
aacedc3e 138 if(gAlice){
139 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
140 GetDetectorName().Data()));
141 if(its) return its;
142 } // end if gAlice
143 AliRunLoader *rl=0;
144 rl = GetRunLoader();
145 if(!rl) return 0;
146 AliRun *ar=0;
147 ar = rl->GetAliRun();
148 if(!ar) return 0;
149 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
150 return its;
88cb7938 151}
aacedc3e 152//----------------------------------------------------------------------
153void AliITSLoader::SetupDigits(AliITS *its){
154 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
155 // Inputs:
156 // AliITS *its Pointer to the ITS
157 // Outputs:
158 // none.
159 // Return:
160 // none.
88cb7938 161
aacedc3e 162 its->SetTreeAddressD(TreeD());
163}
164//----------------------------------------------------------------------
165void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
166 const Char_t **digclass){
167 // Sets up digPerDet to store ITS Digits.
168 // Inputs:
169 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
170 // Int_t n The size of the TObjArray and digclass array
171 // Char_t **digclass Array of digit class names
172 // Outputs:
173 // TObjArray *digPerDet Setup and linked to the tree of digits
174 // Return:
175 // none.
176 Int_t i,m;
177 TClonesArray *cl = 0;
178 TTree *td = 0;
179 TBranch *br = 0;
180 Char_t branch[13];
181 const Char_t *det[3] = {"SPD","SDD","SSD"};
182
183 if(!digPerDet){
184 Error("SetUpDigits","TObject Array digPerDet does not exist");
185 return;
186 } // end if
187 m = digPerDet->GetSize();
188 if(m<n){
189 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
190 " at least that of n=%d",digPerDet,n);
191 } // end if
192 if(m<3){
193 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
194 digPerDet);
195 return;
196 } // end if
197 td = TreeD();
198 for(i=0;i<n;i++){
199 if(digPerDet->At(i)==0){ // set up TClones Array
200 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
201 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
202 else sprintf(branch,"ITSDigits%d",i+1);
203 br = td->GetBranch(branch);
204 br->SetAddress(&((*digPerDet)[i]));
205 continue; // do next one.
206 } // end if
207 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
208 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
209 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
210 "zeroed or filled with TClonesArrays",i,digPerDet);
211 return;
212 } // end if
213 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
214 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
215 "derived from AliITSdigit",i,digPerDet->At(i));
216 } // end if
217 cl->Clear();
218 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
219 else sprintf(branch,"ITSDigits%d",i+1);
220 br = td->GetBranch(branch);
221 br->SetAddress(&((*digPerDet)[i]));
222 continue;
223 } // end for i
224}
225//---------------------------------------------------------------------
226AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
227 Int_t digit){
228 // Gets the digit for for a specific detector type and module.
229 // To be used in conjustion with Setupdigits(AliITS *its).
230 // Inputs:
231 // TObjArray *digPereDet Pointer to the Array of digits
232 // Int_t module Module number
233 // Int_t digit Digit number
234 // Outputs:
235 // none.
236 // Return:
237 // returns the pointer to the digit. if zero then last digit for that
238 // module.
239
240 if(digPerDet==0){
241 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
242 digPerDet,module,digit);
243 return 0;
244 } // end if
245 return 0;
246}
247//---------------------------------------------------------------------
248AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
249 // Gets the digit for for a specific detector type and module.
250 // To be used in conjustion with Setupdigits(AliITS *its).
251 // Inputs:
252 // AliITS *its Pointer to the ITS
253 // Int_t module Module number
254 // Int_t digit Digit number
255 // Outputs:
256 // none.
257 // Return:
258 // returns the pointer to the digit. if zero then last digit for that
259 // module.
260 //AliITSDetType *idtype;
261 AliITSgeom *geom = its->GetITSgeom();
262 Int_t idet = geom->GetModuleType(module);
263 TClonesArray *digits;
264
265 its->ResetDigits();
266 TreeD()->GetEvent(module);
267 digits = its->DigitsAddress(idet);
268 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
269 return (AliITSdigit*) digits->At(digit);
270 } // end if
271 return 0;
272}
273//----------------------------------------------------------------------
88cb7938 274void AliITSLoader::MakeTree(Option_t *opt){
aacedc3e 275 // invokes AliLoader::MakeTree + specific ITS tree(s)
276 // Valid options: H,S,D,R,T and C (C=raw clusters)
277 AliLoader::MakeTree(opt);
278 const char *oC = strstr(opt,"C");
279 if (oC) MakeRawClustersContainer();
280
281 const char *oB = strstr(opt,"B");
282 if (oB) MakeBackTracksContainer();
283
284 const char *oV0 = strstr(opt,"V0");
285 if (oV0) MakeV0Container();
286
287 const char *oX = strstr(opt,"X");
288 if (oX) MakeCascadeContainer();
88cb7938 289}