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 #include <TClonesArray.h>
20 #include <TGeoManager.h>
22 #include "AliITSdigit.h"
23 #include "AliITSLoader.h"
24 #include "AliRunLoader.h"
25 #include "AliObjectLoader.h"
26 #include "AliITSInitGeometry.h"
29 ///////////////////////////////////////////////////////////////////////////
31 // it manages the I/O for:
32 // raw clusters, primary vertices
34 // and tracks propagated to the origin
35 //////////////////////////////////////////////////////////////////////////
36 const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
37 const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
38 const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
39 const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
40 const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
41 ClassImp(AliITSLoader)
43 /**********************************************************************/
44 AliITSLoader::AliITSLoader():AliLoader(),
47 // Default constructor
49 /*********************************************************************/
50 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
51 AliLoader(name,topfoldername),
55 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
56 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
58 fDataLoaders->Add(rawClustersDataLoader);
59 rawClustersDataLoader->SetEventFolder(fEventFolder);
60 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
62 AliDataLoader* backTracksDataLoader = new AliDataLoader(
63 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
64 "Back Propagated Tracks");
65 fDataLoaders->Add(backTracksDataLoader);
66 backTracksDataLoader->SetEventFolder(fEventFolder);
67 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
69 AliDataLoader* vertexDataLoader = new AliDataLoader(
70 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
71 "Primary Vertices","O");
72 fDataLoaders->Add(vertexDataLoader);
73 vertexDataLoader->SetEventFolder(fEventFolder);
74 vertexDataLoader->SetFolder(GetDetectorDataFolder());
76 AliDataLoader* v0DataLoader = new AliDataLoader(
77 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
78 fDataLoaders->Add(v0DataLoader);
79 v0DataLoader->SetEventFolder(fEventFolder);
80 v0DataLoader->SetFolder(GetDetectorDataFolder());
82 AliDataLoader* cascadeDataLoader = new AliDataLoader(
83 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
85 fDataLoaders->Add(cascadeDataLoader);
86 cascadeDataLoader->SetEventFolder(fEventFolder);
87 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
89 // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo)
90 AliDataLoader* dl = GetDigitsDataLoader();
91 AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl);
92 dl->AddBaseLoader(foLoader);
95 /**********************************************************************/
96 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
97 AliLoader(name,topfolder),
101 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
102 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
104 fDataLoaders->Add(rawClustersDataLoader);
105 rawClustersDataLoader->SetEventFolder(fEventFolder);
106 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
108 AliDataLoader* backTracksDataLoader = new AliDataLoader(
109 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
110 "Back Propagated Tracks");
111 fDataLoaders->Add(backTracksDataLoader);
112 backTracksDataLoader->SetEventFolder(fEventFolder);
113 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
115 AliDataLoader* vertexDataLoader = new AliDataLoader(
116 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
117 "Primary Vertices","O");
118 fDataLoaders->Add(vertexDataLoader);
119 vertexDataLoader->SetEventFolder(fEventFolder);
120 vertexDataLoader->SetFolder(GetDetectorDataFolder());
122 AliDataLoader* v0DataLoader = new AliDataLoader(
123 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
124 fDataLoaders->Add(v0DataLoader);
125 v0DataLoader->SetEventFolder(fEventFolder);
126 v0DataLoader->SetFolder(GetDetectorDataFolder());
128 AliDataLoader* cascadeDataLoader = new AliDataLoader(
129 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
131 fDataLoaders->Add(cascadeDataLoader);
132 cascadeDataLoader->SetEventFolder(fEventFolder);
133 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
135 // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo)
136 AliDataLoader* dl = GetDigitsDataLoader();
137 AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl);
138 dl->AddBaseLoader(foLoader);
144 /**********************************************************************/
145 AliITSLoader::~AliITSLoader(){
147 AliDataLoader* dl = 0;
149 dl = GetRawClLoader();
150 fDataLoaders->Remove(dl);
153 dl = GetBackTracksDataLoader();
154 fDataLoaders->Remove(dl);
157 dl = GetVertexDataLoader();
158 fDataLoaders->Remove(dl);
161 dl = GetV0DataLoader();
162 fDataLoaders->Remove(dl);
165 dl = GetCascadeDataLoader();
166 fDataLoaders->Remove(dl);
168 if(fGeom)delete fGeom;
172 //----------------------------------------------------------------------
173 AliITS* AliITSLoader::GetITS(){
174 // Returns the pointer to the ITS, kept on the file. A short cut metthod
180 // Returns a pointer to the ITS, if not found returns 0.
184 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
185 GetDetectorName().Data()));
192 ar = rl->GetAliRun();
194 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
197 //----------------------------------------------------------------------
198 void AliITSLoader::SetupDigits(AliITS *its){
199 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
201 // AliITS *its Pointer to the ITS
207 its->SetTreeAddressD(TreeD());
210 //----------------------------------------------------------------------
211 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
212 const Char_t **digclass){
213 // Sets up digPerDet to store ITS Digits.
215 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
216 // Int_t n The size of the TObjArray and digclass array
217 // Char_t **digclass Array of digit class names
219 // TObjArray *digPerDet Setup and linked to the tree of digits
223 TClonesArray *cl = 0;
227 const Char_t *det[3] = {"SPD","SDD","SSD"};
230 Error("SetUpDigits","TObject Array digPerDet does not exist");
233 m = digPerDet->GetSize();
235 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
236 " at least that of n=%d",digPerDet,n);
239 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
245 if(digPerDet->At(i)==0){ // set up TClones Array
246 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
247 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
248 else sprintf(branch,"ITSDigits%d",i+1);
249 br = td->GetBranch(branch);
250 br->SetAddress(&((*digPerDet)[i]));
251 continue; // do next one.
253 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
254 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
255 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
256 "zeroed or filled with TClonesArrays",i,digPerDet);
259 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
260 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
261 "derived from AliITSdigit",i,digPerDet->At(i));
264 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
265 else sprintf(branch,"ITSDigits%d",i+1);
266 br = td->GetBranch(branch);
267 br->SetAddress(&((*digPerDet)[i]));
271 //---------------------------------------------------------------------
272 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
274 // Gets the digit for for a specific detector type and module.
275 // To be used in conjustion with Setupdigits(AliITS *its).
277 // TObjArray *digPereDet Pointer to the Array of digits
278 // Int_t module Module number
279 // Int_t digit Digit number
283 // returns the pointer to the digit. if zero then last digit for that
287 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
288 digPerDet,module,digit);
294 //---------------------------------------------------------------------
295 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
296 // Gets the digit for for a specific detector type and module.
297 // To be used in conjustion with Setupdigits(AliITS *its).
299 // AliITS *its Pointer to the ITS
300 // Int_t module Module number
301 // Int_t digit Digit number
305 // returns the pointer to the digit. if zero then last digit for that
307 //AliITSDetType *idtype;
308 AliITSgeom *geom = its->GetITSgeom();
309 Int_t idet = geom->GetModuleType(module);
310 TClonesArray *digits;
313 TreeD()->GetEvent(module);
314 digits = its->DigitsAddress(idet);
315 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
316 return (AliITSdigit*) digits->At(digit);
321 //----------------------------------------------------------------------
322 void AliITSLoader::MakeTree(Option_t *opt){
323 // invokes AliLoader::MakeTree + specific ITS tree(s)
324 // Valid options: H,S,D,R,T and C (C=raw clusters)
325 AliLoader::MakeTree(opt);
326 const char *oC = strstr(opt,"C");
327 if (oC) MakeRawClustersContainer();
329 const char *oB = strstr(opt,"B");
330 if (oB) MakeBackTracksContainer();
332 const char *oV0 = strstr(opt,"V0");
333 if (oV0) MakeV0Container();
335 const char *oX = strstr(opt,"X");
336 if (oX) MakeCascadeContainer();
339 //----------------------------------------------------------------------
340 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
341 // retrieves the ITS geometry from file
342 if(fGeom && !force)return fGeom;
348 AliError("gGeoManager is a null pointer - ITS geometry not built");
351 AliITSInitGeometry initgeom;
352 fGeom = initgeom.CreateAliITSgeom();
353 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
354 AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
357 //______________________________________________________________________
358 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
359 // Replaces the AliITSgeom object read from file with the one
362 // AliITSgeom *geom The AliITSgeom object to replace the one
363 // read from the file
369 if(fGeom==geom) return; // Same do nothing
376 //______________________________________________________________________
377 AliBaseLoader* AliITSLoader::GetFOSignalsLoader() {
378 // return pointer to FO signals base loader
379 AliDataLoader* dl = GetDigitsDataLoader();
381 AliError("Data loader is NULL.");
384 return dl->GetBaseLoader("AliITSFOSignalsSPD");