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 "AliITSInitGeometry.h"
28 ///////////////////////////////////////////////////////////////////////////
30 // it manages the I/O for:
31 // raw clusters, primary vertices
33 // and tracks propagated to the origin
34 //////////////////////////////////////////////////////////////////////////
35 const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
36 const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
37 const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
38 const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
39 const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
40 ClassImp(AliITSLoader)
42 /**********************************************************************/
43 AliITSLoader::AliITSLoader():AliLoader(),
46 // Default constructor
48 /*********************************************************************/
49 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
50 AliLoader(name,topfoldername),
54 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
55 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
57 fDataLoaders->Add(rawClustersDataLoader);
58 rawClustersDataLoader->SetEventFolder(fEventFolder);
59 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
61 AliDataLoader* backTracksDataLoader = new AliDataLoader(
62 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
63 "Back Propagated Tracks");
64 fDataLoaders->Add(backTracksDataLoader);
65 backTracksDataLoader->SetEventFolder(fEventFolder);
66 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
68 AliDataLoader* vertexDataLoader = new AliDataLoader(
69 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
70 "Primary Vertices","O");
71 fDataLoaders->Add(vertexDataLoader);
72 vertexDataLoader->SetEventFolder(fEventFolder);
73 vertexDataLoader->SetFolder(GetDetectorDataFolder());
75 AliDataLoader* v0DataLoader = new AliDataLoader(
76 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
77 fDataLoaders->Add(v0DataLoader);
78 v0DataLoader->SetEventFolder(fEventFolder);
79 v0DataLoader->SetFolder(GetDetectorDataFolder());
81 AliDataLoader* cascadeDataLoader = new AliDataLoader(
82 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
84 fDataLoaders->Add(cascadeDataLoader);
85 cascadeDataLoader->SetEventFolder(fEventFolder);
86 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
88 /**********************************************************************/
89 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
90 AliLoader(name,topfolder),
94 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
95 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
97 fDataLoaders->Add(rawClustersDataLoader);
98 rawClustersDataLoader->SetEventFolder(fEventFolder);
99 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
101 AliDataLoader* backTracksDataLoader = new AliDataLoader(
102 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
103 "Back Propagated Tracks");
104 fDataLoaders->Add(backTracksDataLoader);
105 backTracksDataLoader->SetEventFolder(fEventFolder);
106 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
108 AliDataLoader* vertexDataLoader = new AliDataLoader(
109 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
110 "Primary Vertices","O");
111 fDataLoaders->Add(vertexDataLoader);
112 vertexDataLoader->SetEventFolder(fEventFolder);
113 vertexDataLoader->SetFolder(GetDetectorDataFolder());
115 AliDataLoader* v0DataLoader = new AliDataLoader(
116 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
117 fDataLoaders->Add(v0DataLoader);
118 v0DataLoader->SetEventFolder(fEventFolder);
119 v0DataLoader->SetFolder(GetDetectorDataFolder());
121 AliDataLoader* cascadeDataLoader = new AliDataLoader(
122 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
124 fDataLoaders->Add(cascadeDataLoader);
125 cascadeDataLoader->SetEventFolder(fEventFolder);
126 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
130 /**********************************************************************/
131 AliITSLoader::~AliITSLoader(){
133 AliDataLoader* dl = 0;
135 dl = GetRawClLoader();
136 fDataLoaders->Remove(dl);
139 dl = GetBackTracksDataLoader();
140 fDataLoaders->Remove(dl);
143 dl = GetVertexDataLoader();
144 fDataLoaders->Remove(dl);
147 dl = GetV0DataLoader();
148 fDataLoaders->Remove(dl);
151 dl = GetCascadeDataLoader();
152 fDataLoaders->Remove(dl);
154 if(fGeom)delete fGeom;
158 //----------------------------------------------------------------------
159 AliITS* AliITSLoader::GetITS(){
160 // Returns the pointer to the ITS, kept on the file. A short cut metthod
166 // Returns a pointer to the ITS, if not found returns 0.
170 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
171 GetDetectorName().Data()));
178 ar = rl->GetAliRun();
180 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
183 //----------------------------------------------------------------------
184 void AliITSLoader::SetupDigits(AliITS *its){
185 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
187 // AliITS *its Pointer to the ITS
193 its->SetTreeAddressD(TreeD());
196 //----------------------------------------------------------------------
197 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
198 const Char_t **digclass){
199 // Sets up digPerDet to store ITS Digits.
201 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
202 // Int_t n The size of the TObjArray and digclass array
203 // Char_t **digclass Array of digit class names
205 // TObjArray *digPerDet Setup and linked to the tree of digits
209 TClonesArray *cl = 0;
213 const Char_t *det[3] = {"SPD","SDD","SSD"};
216 Error("SetUpDigits","TObject Array digPerDet does not exist");
219 m = digPerDet->GetSize();
221 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
222 " at least that of n=%d",digPerDet,n);
225 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
231 if(digPerDet->At(i)==0){ // set up TClones Array
232 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
233 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
234 else sprintf(branch,"ITSDigits%d",i+1);
235 br = td->GetBranch(branch);
236 br->SetAddress(&((*digPerDet)[i]));
237 continue; // do next one.
239 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
240 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
241 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
242 "zeroed or filled with TClonesArrays",i,digPerDet);
245 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
246 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
247 "derived from AliITSdigit",i,digPerDet->At(i));
250 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
251 else sprintf(branch,"ITSDigits%d",i+1);
252 br = td->GetBranch(branch);
253 br->SetAddress(&((*digPerDet)[i]));
257 //---------------------------------------------------------------------
258 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
260 // Gets the digit for for a specific detector type and module.
261 // To be used in conjustion with Setupdigits(AliITS *its).
263 // TObjArray *digPereDet Pointer to the Array of digits
264 // Int_t module Module number
265 // Int_t digit Digit number
269 // returns the pointer to the digit. if zero then last digit for that
273 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
274 digPerDet,module,digit);
280 //---------------------------------------------------------------------
281 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
282 // Gets the digit for for a specific detector type and module.
283 // To be used in conjustion with Setupdigits(AliITS *its).
285 // AliITS *its Pointer to the ITS
286 // Int_t module Module number
287 // Int_t digit Digit number
291 // returns the pointer to the digit. if zero then last digit for that
293 //AliITSDetType *idtype;
294 AliITSgeom *geom = its->GetITSgeom();
295 Int_t idet = geom->GetModuleType(module);
296 TClonesArray *digits;
299 TreeD()->GetEvent(module);
300 digits = its->DigitsAddress(idet);
301 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
302 return (AliITSdigit*) digits->At(digit);
307 //----------------------------------------------------------------------
308 void AliITSLoader::MakeTree(Option_t *opt){
309 // invokes AliLoader::MakeTree + specific ITS tree(s)
310 // Valid options: H,S,D,R,T and C (C=raw clusters)
311 AliLoader::MakeTree(opt);
312 const char *oC = strstr(opt,"C");
313 if (oC) MakeRawClustersContainer();
315 const char *oB = strstr(opt,"B");
316 if (oB) MakeBackTracksContainer();
318 const char *oV0 = strstr(opt,"V0");
319 if (oV0) MakeV0Container();
321 const char *oX = strstr(opt,"X");
322 if (oX) MakeCascadeContainer();
325 //----------------------------------------------------------------------
326 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
327 // retrieves the ITS geometry from file
328 if(fGeom && !force)return fGeom;
334 AliError("gGeoManager is a null pointer - ITS geometry not built");
337 AliITSInitGeometry initgeom;
338 fGeom = initgeom.CreateAliITSgeom();
339 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
340 AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
343 //______________________________________________________________________
344 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
345 // Replaces the AliITSgeom object read from file with the one
348 // AliITSgeom *geom The AliITSgeom object to replace the one
349 // read from the file
355 if(fGeom==geom) return; // Same do nothing