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(),
46 // Default constructor
48 /*********************************************************************/
49 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
50 AliLoader(name,topfoldername),
53 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
54 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
56 fDataLoaders->Add(rawClustersDataLoader);
57 rawClustersDataLoader->SetEventFolder(fEventFolder);
58 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
60 AliDataLoader* backTracksDataLoader = new AliDataLoader(
61 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
62 "Back Propagated Tracks");
63 fDataLoaders->Add(backTracksDataLoader);
64 backTracksDataLoader->SetEventFolder(fEventFolder);
65 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
67 AliDataLoader* vertexDataLoader = new AliDataLoader(
68 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
69 "Primary Vertices","O");
70 fDataLoaders->Add(vertexDataLoader);
71 vertexDataLoader->SetEventFolder(fEventFolder);
72 vertexDataLoader->SetFolder(GetDetectorDataFolder());
74 AliDataLoader* v0DataLoader = new AliDataLoader(
75 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
76 fDataLoaders->Add(v0DataLoader);
77 v0DataLoader->SetEventFolder(fEventFolder);
78 v0DataLoader->SetFolder(GetDetectorDataFolder());
80 AliDataLoader* cascadeDataLoader = new AliDataLoader(
81 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
83 fDataLoaders->Add(cascadeDataLoader);
84 cascadeDataLoader->SetEventFolder(fEventFolder);
85 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
87 /**********************************************************************/
88 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
89 AliLoader(name,topfolder),
92 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
93 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
95 fDataLoaders->Add(rawClustersDataLoader);
96 rawClustersDataLoader->SetEventFolder(fEventFolder);
97 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
99 AliDataLoader* backTracksDataLoader = new AliDataLoader(
100 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
101 "Back Propagated Tracks");
102 fDataLoaders->Add(backTracksDataLoader);
103 backTracksDataLoader->SetEventFolder(fEventFolder);
104 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
106 AliDataLoader* vertexDataLoader = new AliDataLoader(
107 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
108 "Primary Vertices","O");
109 fDataLoaders->Add(vertexDataLoader);
110 vertexDataLoader->SetEventFolder(fEventFolder);
111 vertexDataLoader->SetFolder(GetDetectorDataFolder());
113 AliDataLoader* v0DataLoader = new AliDataLoader(
114 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
115 fDataLoaders->Add(v0DataLoader);
116 v0DataLoader->SetEventFolder(fEventFolder);
117 v0DataLoader->SetFolder(GetDetectorDataFolder());
119 AliDataLoader* cascadeDataLoader = new AliDataLoader(
120 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
122 fDataLoaders->Add(cascadeDataLoader);
123 cascadeDataLoader->SetEventFolder(fEventFolder);
124 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
128 /**********************************************************************/
129 AliITSLoader::~AliITSLoader(){
131 AliDataLoader* dl = 0;
133 dl = GetRawClLoader();
134 fDataLoaders->Remove(dl);
137 dl = GetBackTracksDataLoader();
138 fDataLoaders->Remove(dl);
141 dl = GetVertexDataLoader();
142 fDataLoaders->Remove(dl);
145 dl = GetV0DataLoader();
146 fDataLoaders->Remove(dl);
149 dl = GetCascadeDataLoader();
150 fDataLoaders->Remove(dl);
152 if(fGeom)delete fGeom;
156 //----------------------------------------------------------------------
157 AliITS* AliITSLoader::GetITS(){
158 // Returns the pointer to the ITS, kept on the file. A short cut metthod
164 // Returns a pointer to the ITS, if not found returns 0.
168 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
169 GetDetectorName().Data()));
176 ar = rl->GetAliRun();
178 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
181 //----------------------------------------------------------------------
182 void AliITSLoader::SetupDigits(AliITS *its){
183 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
185 // AliITS *its Pointer to the ITS
191 its->SetTreeAddressD(TreeD());
194 //----------------------------------------------------------------------
195 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
196 const Char_t **digclass){
197 // Sets up digPerDet to store ITS Digits.
199 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
200 // Int_t n The size of the TObjArray and digclass array
201 // Char_t **digclass Array of digit class names
203 // TObjArray *digPerDet Setup and linked to the tree of digits
207 TClonesArray *cl = 0;
211 const Char_t *det[3] = {"SPD","SDD","SSD"};
214 Error("SetUpDigits","TObject Array digPerDet does not exist");
217 m = digPerDet->GetSize();
219 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
220 " at least that of n=%d",digPerDet,n);
223 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
229 if(digPerDet->At(i)==0){ // set up TClones Array
230 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
231 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
232 else sprintf(branch,"ITSDigits%d",i+1);
233 br = td->GetBranch(branch);
234 br->SetAddress(&((*digPerDet)[i]));
235 continue; // do next one.
237 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
238 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
239 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
240 "zeroed or filled with TClonesArrays",i,digPerDet);
243 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
244 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
245 "derived from AliITSdigit",i,digPerDet->At(i));
248 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
249 else sprintf(branch,"ITSDigits%d",i+1);
250 br = td->GetBranch(branch);
251 br->SetAddress(&((*digPerDet)[i]));
255 //---------------------------------------------------------------------
256 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
258 // Gets the digit for for a specific detector type and module.
259 // To be used in conjustion with Setupdigits(AliITS *its).
261 // TObjArray *digPereDet Pointer to the Array of digits
262 // Int_t module Module number
263 // Int_t digit Digit number
267 // returns the pointer to the digit. if zero then last digit for that
271 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
272 digPerDet,module,digit);
278 //---------------------------------------------------------------------
279 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
280 // Gets the digit for for a specific detector type and module.
281 // To be used in conjustion with Setupdigits(AliITS *its).
283 // AliITS *its Pointer to the ITS
284 // Int_t module Module number
285 // Int_t digit Digit number
289 // returns the pointer to the digit. if zero then last digit for that
291 //AliITSDetType *idtype;
292 AliITSgeom *geom = its->GetITSgeom();
293 Int_t idet = geom->GetModuleType(module);
294 TClonesArray *digits;
297 TreeD()->GetEvent(module);
298 digits = its->DigitsAddress(idet);
299 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
300 return (AliITSdigit*) digits->At(digit);
305 //----------------------------------------------------------------------
306 void AliITSLoader::MakeTree(Option_t *opt){
307 // invokes AliLoader::MakeTree + specific ITS tree(s)
308 // Valid options: H,S,D,R,T and C (C=raw clusters)
309 AliLoader::MakeTree(opt);
310 const char *oC = strstr(opt,"C");
311 if (oC) MakeRawClustersContainer();
313 const char *oB = strstr(opt,"B");
314 if (oB) MakeBackTracksContainer();
316 const char *oV0 = strstr(opt,"V0");
317 if (oV0) MakeV0Container();
319 const char *oX = strstr(opt,"X");
320 if (oX) MakeCascadeContainer();
323 //----------------------------------------------------------------------
324 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
325 // retrieves the ITS geometry from file
326 if(fGeom && !force)return fGeom;
332 AliError("gGeoManager is a null pointer - ITS geometry not built");
335 AliITSInitGeometry initgeom;
336 fGeom = initgeom.CreateAliITSgeom();
337 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
338 AliDebug(1,Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
341 //______________________________________________________________________
342 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
343 // Replaces the AliITSgeom object read from file with the one
346 // AliITSgeom *geom The AliITSgeom object to replace the one
347 // read from the file
353 if(fGeom==geom) return; // Same do nothing