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 **************************************************************************/
16 /* $Id: AliITSULoader.cxx $ */
18 #include <TClonesArray.h>
20 #include <TGeoManager.h>
23 #include "AliITSdigit.h"
24 #include "AliITSULoader.h"
25 #include "AliRunLoader.h"
26 #include "AliObjectLoader.h"
29 ///////////////////////////////////////////////////////////////////////////
30 // Loader for ITS Upgrade
31 // it manages the I/O for:
32 // raw clusters, primary vertices
34 // and tracks propagated to the origin
35 //////////////////////////////////////////////////////////////////////////
36 ClassImp(AliITSULoader)
38 /**********************************************************************/
39 AliITSULoader::AliITSULoader()
42 // Default constructor
45 /*********************************************************************/
46 AliITSULoader::AliITSULoader(const Char_t *name,const Char_t *topfoldername)
47 : AliLoader(name,topfoldername)
50 TString rawContainerName = "TreeC";
51 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
52 fDetectorName + ".RawCl.root",rawContainerName,
54 fDataLoaders->Add(rawClustersDataLoader);
55 rawClustersDataLoader->SetEventFolder(fEventFolder);
56 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
58 TString backTracksContainerName= "TreeB";
59 AliDataLoader* backTracksDataLoader = new AliDataLoader(
60 fDetectorName + ".BackTracks.root",backTracksContainerName,
61 "Back Propagated Tracks");
62 fDataLoaders->Add(backTracksDataLoader);
63 backTracksDataLoader->SetEventFolder(fEventFolder);
64 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
65 TString verticesContainerName="Vertex";
66 AliDataLoader* vertexDataLoader = new AliDataLoader(
67 fDetectorName + ".Vertex.root",verticesContainerName,
68 "Primary Vertices","O");
69 fDataLoaders->Add(vertexDataLoader);
70 vertexDataLoader->SetEventFolder(fEventFolder);
71 vertexDataLoader->SetFolder(GetDetectorDataFolder());
72 TString v0ContainerName="V0";
73 AliDataLoader* v0DataLoader = new AliDataLoader(
74 fDetectorName + ".V0s.root",v0ContainerName,"V0 Vertices");
75 fDataLoaders->Add(v0DataLoader);
76 v0DataLoader->SetEventFolder(fEventFolder);
77 v0DataLoader->SetFolder(GetDetectorDataFolder());
78 TString cascadeContainerName="Cascade";
79 AliDataLoader* cascadeDataLoader = new AliDataLoader(
80 fDetectorName + ".Cascades.root",cascadeContainerName,
82 fDataLoaders->Add(cascadeDataLoader);
83 cascadeDataLoader->SetEventFolder(fEventFolder);
84 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
86 /**********************************************************************/
87 AliITSULoader::AliITSULoader(const Char_t *name,TFolder *topfolder)
88 : AliLoader(name,topfolder)
91 TString rawContainerName="TreeC";
92 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
93 fDetectorName + ".RawCl.root",rawContainerName,
95 fDataLoaders->Add(rawClustersDataLoader);
96 rawClustersDataLoader->SetEventFolder(fEventFolder);
97 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
98 TString backTracksContainerName="TreeB";
99 AliDataLoader* backTracksDataLoader = new AliDataLoader(
100 fDetectorName + ".BackTracks.root",backTracksContainerName,
101 "Back Propagated Tracks");
102 fDataLoaders->Add(backTracksDataLoader);
103 backTracksDataLoader->SetEventFolder(fEventFolder);
104 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
105 TString verticesContainerName="Vertex";
106 AliDataLoader* vertexDataLoader = new AliDataLoader(
107 fDetectorName + ".Vertex.root",verticesContainerName,
108 "Primary Vertices","O");
109 fDataLoaders->Add(vertexDataLoader);
110 vertexDataLoader->SetEventFolder(fEventFolder);
111 vertexDataLoader->SetFolder(GetDetectorDataFolder());
112 TString v0ContainerName="V0";
113 AliDataLoader* v0DataLoader = new AliDataLoader(
114 fDetectorName + ".V0.root",v0ContainerName,"V0 Vertices");
115 fDataLoaders->Add(v0DataLoader);
116 v0DataLoader->SetEventFolder(fEventFolder);
117 v0DataLoader->SetFolder(GetDetectorDataFolder());
118 TString cascadeContainerName="Cascade";
119 AliDataLoader* cascadeDataLoader = new AliDataLoader(
120 fDetectorName + ".Cascade.root",cascadeContainerName,
122 fDataLoaders->Add(cascadeDataLoader);
123 cascadeDataLoader->SetEventFolder(fEventFolder);
124 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
128 /**********************************************************************/
129 AliITSULoader::~AliITSULoader(){
132 AliDataLoader *dl = GetRawClLoader();
133 fDataLoaders->Remove(dl);
136 dl = GetBackTracksDataLoader();
137 fDataLoaders->Remove(dl);
140 dl = GetVertexDataLoader();
141 fDataLoaders->Remove(dl);
144 dl = GetV0DataLoader();
145 fDataLoaders->Remove(dl);
148 dl = GetCascadeDataLoader();
149 fDataLoaders->Remove(dl);
153 //----------------------------------------------------------------------
154 AliITS* AliITSULoader::GetITS(){
155 // Returns the pointer to the ITS, kept on the file. A short cut metthod
161 // Returns a pointer to the ITS, if not found returns 0.
165 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
166 GetDetectorName().Data()));
173 ar = rl->GetAliRun();
175 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
178 //----------------------------------------------------------------------
179 void AliITSULoader::SetupDigits(AliITS *its){
180 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
182 // AliITS *its Pointer to the ITS
188 its->SetTreeAddressD(TreeD());
191 //----------------------------------------------------------------------
192 void AliITSULoader::SetupDigits(TObjArray *digPerDet,Int_t n,
193 const Char_t **digclass){
194 // Sets up digPerDet to store ITS Digits.
196 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
197 // Int_t n The size of the TObjArray and digclass array
198 // Char_t **digclass Array of digit class names
200 // TObjArray *digPerDet Setup and linked to the tree of digits
204 TClonesArray *cl = 0;
208 const Char_t *det[3] = {"SPD","SDD","SSD"};
211 Error("SetUpDigits","TObject Array digPerDet does not exist");
214 m = digPerDet->GetSize();
216 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
217 " at least that of n=%d",digPerDet,n);
220 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
226 if(digPerDet->At(i)==0){ // set up TClones Array
227 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
228 if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
229 else snprintf(branch,13,"ITSDigits%d",i+1);
230 br = td->GetBranch(branch);
231 br->SetAddress(&((*digPerDet)[i]));
232 continue; // do next one.
234 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
235 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
236 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
237 "zeroed or filled with TClonesArrays",i,digPerDet);
240 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
241 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
242 "derived from AliITSdigit",i,digPerDet->At(i));
245 if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
246 else snprintf(branch,13,"ITSDigits%d",i+1);
247 br = td->GetBranch(branch);
248 br->SetAddress(&((*digPerDet)[i]));
252 //---------------------------------------------------------------------
253 AliITSdigit * AliITSULoader::GetDigit(TObjArray *digPerDet,Int_t chip,
255 // Gets the digit for for a specific detector type and chip.
256 // To be used in conjustion with Setupdigits(AliITS *its).
258 // TObjArray *digPereDet Pointer to the Array of digits
259 // Int_t chip Chip number
260 // Int_t digit Digit number
264 // returns the pointer to the digit. if zero then last digit for that
268 Error("GetDigit","digPerDet=%p, chip=%d, digit=%d",
269 digPerDet,chip,digit);
274 //----------------------------------------------------------------------
275 void AliITSULoader::MakeTree(Option_t *opt){
276 // invokes AliLoader::MakeTree + specific ITS tree(s)
277 // Valid options: H,S,D,R,T and C (C=raw clusters)
278 AliLoader::MakeTree(opt);
279 const char *oC = strstr(opt,"C");
280 if (oC) MakeRawClustersContainer();
282 const char *oB = strstr(opt,"B");
283 if (oB) MakeBackTracksContainer();
285 const char *oV0 = strstr(opt,"V0");
286 if (oV0) MakeV0Container();
288 const char *oX = strstr(opt,"X");
289 if (oX) MakeCascadeContainer();