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 /**********************************************************************/
90 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
91 AliLoader(name,topfolder),
95 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
96 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
98 fDataLoaders->Add(rawClustersDataLoader);
99 rawClustersDataLoader->SetEventFolder(fEventFolder);
100 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
102 AliDataLoader* backTracksDataLoader = new AliDataLoader(
103 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
104 "Back Propagated Tracks");
105 fDataLoaders->Add(backTracksDataLoader);
106 backTracksDataLoader->SetEventFolder(fEventFolder);
107 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
109 AliDataLoader* vertexDataLoader = new AliDataLoader(
110 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
111 "Primary Vertices","O");
112 fDataLoaders->Add(vertexDataLoader);
113 vertexDataLoader->SetEventFolder(fEventFolder);
114 vertexDataLoader->SetFolder(GetDetectorDataFolder());
116 AliDataLoader* v0DataLoader = new AliDataLoader(
117 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
118 fDataLoaders->Add(v0DataLoader);
119 v0DataLoader->SetEventFolder(fEventFolder);
120 v0DataLoader->SetFolder(GetDetectorDataFolder());
122 AliDataLoader* cascadeDataLoader = new AliDataLoader(
123 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
125 fDataLoaders->Add(cascadeDataLoader);
126 cascadeDataLoader->SetEventFolder(fEventFolder);
127 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
131 /**********************************************************************/
132 AliITSLoader::~AliITSLoader(){
134 AliDataLoader* dl = 0;
136 dl = GetRawClLoader();
137 fDataLoaders->Remove(dl);
140 dl = GetBackTracksDataLoader();
141 fDataLoaders->Remove(dl);
144 dl = GetVertexDataLoader();
145 fDataLoaders->Remove(dl);
148 dl = GetV0DataLoader();
149 fDataLoaders->Remove(dl);
152 dl = GetCascadeDataLoader();
153 fDataLoaders->Remove(dl);
155 if(fGeom)delete fGeom;
159 //----------------------------------------------------------------------
160 AliITS* AliITSLoader::GetITS(){
161 // Returns the pointer to the ITS, kept on the file. A short cut metthod
167 // Returns a pointer to the ITS, if not found returns 0.
171 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
172 GetDetectorName().Data()));
179 ar = rl->GetAliRun();
181 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
184 //----------------------------------------------------------------------
185 void AliITSLoader::SetupDigits(AliITS *its){
186 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
188 // AliITS *its Pointer to the ITS
194 its->SetTreeAddressD(TreeD());
197 //----------------------------------------------------------------------
198 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
199 const Char_t **digclass){
200 // Sets up digPerDet to store ITS Digits.
202 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
203 // Int_t n The size of the TObjArray and digclass array
204 // Char_t **digclass Array of digit class names
206 // TObjArray *digPerDet Setup and linked to the tree of digits
210 TClonesArray *cl = 0;
214 const Char_t *det[3] = {"SPD","SDD","SSD"};
217 Error("SetUpDigits","TObject Array digPerDet does not exist");
220 m = digPerDet->GetSize();
222 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
223 " at least that of n=%d",digPerDet,n);
226 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
232 if(digPerDet->At(i)==0){ // set up TClones Array
233 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
234 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
235 else sprintf(branch,"ITSDigits%d",i+1);
236 br = td->GetBranch(branch);
237 br->SetAddress(&((*digPerDet)[i]));
238 continue; // do next one.
240 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
241 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
242 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
243 "zeroed or filled with TClonesArrays",i,digPerDet);
246 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
247 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
248 "derived from AliITSdigit",i,digPerDet->At(i));
251 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
252 else sprintf(branch,"ITSDigits%d",i+1);
253 br = td->GetBranch(branch);
254 br->SetAddress(&((*digPerDet)[i]));
258 //---------------------------------------------------------------------
259 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
261 // Gets the digit for for a specific detector type and module.
262 // To be used in conjustion with Setupdigits(AliITS *its).
264 // TObjArray *digPereDet Pointer to the Array of digits
265 // Int_t module Module number
266 // Int_t digit Digit number
270 // returns the pointer to the digit. if zero then last digit for that
274 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
275 digPerDet,module,digit);
281 //---------------------------------------------------------------------
282 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
283 // Gets the digit for for a specific detector type and module.
284 // To be used in conjustion with Setupdigits(AliITS *its).
286 // AliITS *its Pointer to the ITS
287 // Int_t module Module number
288 // Int_t digit Digit number
292 // returns the pointer to the digit. if zero then last digit for that
294 //AliITSDetType *idtype;
295 AliITSgeom *geom = its->GetITSgeom();
296 Int_t idet = geom->GetModuleType(module);
297 TClonesArray *digits;
300 TreeD()->GetEvent(module);
301 digits = its->DigitsAddress(idet);
302 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
303 return (AliITSdigit*) digits->At(digit);
308 //----------------------------------------------------------------------
309 void AliITSLoader::MakeTree(Option_t *opt){
310 // invokes AliLoader::MakeTree + specific ITS tree(s)
311 // Valid options: H,S,D,R,T and C (C=raw clusters)
312 AliLoader::MakeTree(opt);
313 const char *oC = strstr(opt,"C");
314 if (oC) MakeRawClustersContainer();
316 const char *oB = strstr(opt,"B");
317 if (oB) MakeBackTracksContainer();
319 const char *oV0 = strstr(opt,"V0");
320 if (oV0) MakeV0Container();
322 const char *oX = strstr(opt,"X");
323 if (oX) MakeCascadeContainer();
326 //----------------------------------------------------------------------
327 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
328 // retrieves the ITS geometry from file
329 if(fGeom && !force)return fGeom;
335 AliError("gGeoManager is a null pointer - ITS geometry not built");
338 AliITSInitGeometry initgeom;
339 fGeom = initgeom.CreateAliITSgeom();
340 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
341 AliDebug(1,Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
344 //______________________________________________________________________
345 void AliITSLoader::SetITSgeom(AliITSgeom *geom){
346 // Replaces the AliITSgeom object read from file with the one
349 // AliITSgeom *geom The AliITSgeom object to replace the one
350 // read from the file
356 if(fGeom==geom) return; // Same do nothing