1 #include "AliITSdigit.h"
2 #include "AliITSLoader.h"
3 #include "AliRunLoader.h"
6 ///////////////////////////////////////////////////////////////////////////
8 // it manages the I/O for:
9 // raw clusters, primary vertices
11 // and tracks propagated to the origin
12 //////////////////////////////////////////////////////////////////////////
13 const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
14 const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
15 const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
16 const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
17 const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
18 ClassImp(AliITSLoader)
20 /**********************************************************************/
21 AliITSLoader::AliITSLoader():AliLoader(){
22 // Default constructor
26 /*********************************************************************/
27 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
28 AliLoader(name,topfoldername){
30 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
31 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
33 fDataLoaders->Add(rawClustersDataLoader);
34 rawClustersDataLoader->SetEventFolder(fEventFolder);
35 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
37 AliDataLoader* backTracksDataLoader = new AliDataLoader(
38 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
39 "Back Propagated Tracks");
40 fDataLoaders->Add(backTracksDataLoader);
41 backTracksDataLoader->SetEventFolder(fEventFolder);
42 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
44 AliDataLoader* vertexDataLoader = new AliDataLoader(
45 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
46 "Primary Vertices","O");
47 fDataLoaders->Add(vertexDataLoader);
48 vertexDataLoader->SetEventFolder(fEventFolder);
49 vertexDataLoader->SetFolder(GetDetectorDataFolder());
51 AliDataLoader* v0DataLoader = new AliDataLoader(
52 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
53 fDataLoaders->Add(v0DataLoader);
54 v0DataLoader->SetEventFolder(fEventFolder);
55 v0DataLoader->SetFolder(GetDetectorDataFolder());
57 AliDataLoader* cascadeDataLoader = new AliDataLoader(
58 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
60 fDataLoaders->Add(cascadeDataLoader);
61 cascadeDataLoader->SetEventFolder(fEventFolder);
62 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
66 /**********************************************************************/
67 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
68 AliLoader(name,topfolder) {
70 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
71 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
73 fDataLoaders->Add(rawClustersDataLoader);
74 rawClustersDataLoader->SetEventFolder(fEventFolder);
75 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
77 AliDataLoader* backTracksDataLoader = new AliDataLoader(
78 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
79 "Back Propagated Tracks");
80 fDataLoaders->Add(backTracksDataLoader);
81 backTracksDataLoader->SetEventFolder(fEventFolder);
82 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
84 AliDataLoader* vertexDataLoader = new AliDataLoader(
85 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
86 "Primary Vertices","O");
87 fDataLoaders->Add(vertexDataLoader);
88 vertexDataLoader->SetEventFolder(fEventFolder);
89 vertexDataLoader->SetFolder(GetDetectorDataFolder());
91 AliDataLoader* v0DataLoader = new AliDataLoader(
92 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
93 fDataLoaders->Add(v0DataLoader);
94 v0DataLoader->SetEventFolder(fEventFolder);
95 v0DataLoader->SetFolder(GetDetectorDataFolder());
97 AliDataLoader* cascadeDataLoader = new AliDataLoader(
98 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
100 fDataLoaders->Add(cascadeDataLoader);
101 cascadeDataLoader->SetEventFolder(fEventFolder);
102 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
107 //______________________________________________________________________
108 AliITSLoader::AliITSLoader(const AliITSLoader &ob) : AliLoader(ob) {
110 // Copies are not allowed. The method is protected to avoid misuse.
111 Error("AliITSLoader","Copy constructor not allowed\n");
114 //______________________________________________________________________
115 AliITSLoader& AliITSLoader::operator=(const AliITSLoader& /* ob */){
116 // Assignment operator
117 // Assignment is not allowed. The method is protected to avoid misuse.
118 Error("= operator","Assignment operator not allowed\n");
122 /**********************************************************************/
123 AliITSLoader::~AliITSLoader(){
125 AliDataLoader* dl = 0;
127 dl = GetRawClLoader();
128 fDataLoaders->Remove(dl);
131 dl = GetBackTracksDataLoader();
132 fDataLoaders->Remove(dl);
135 dl = GetVertexDataLoader();
136 fDataLoaders->Remove(dl);
139 dl = GetV0DataLoader();
140 fDataLoaders->Remove(dl);
143 dl = GetCascadeDataLoader();
144 fDataLoaders->Remove(dl);
145 if(fITSpid)delete fITSpid;
146 if(fGeom)delete fGeom;
150 //----------------------------------------------------------------------
151 AliITS* AliITSLoader::GetITS(){
152 // Returns the pointer to the ITS, kept on the file. A short cut metthod
158 // Returns a pointer to the ITS, if not found returns 0.
162 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
163 GetDetectorName().Data()));
170 ar = rl->GetAliRun();
172 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
175 //----------------------------------------------------------------------
176 void AliITSLoader::SetupDigits(AliITS *its){
177 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
179 // AliITS *its Pointer to the ITS
185 its->SetTreeAddressD(TreeD());
188 //----------------------------------------------------------------------
189 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
190 const Char_t **digclass){
191 // Sets up digPerDet to store ITS Digits.
193 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
194 // Int_t n The size of the TObjArray and digclass array
195 // Char_t **digclass Array of digit class names
197 // TObjArray *digPerDet Setup and linked to the tree of digits
201 TClonesArray *cl = 0;
205 const Char_t *det[3] = {"SPD","SDD","SSD"};
208 Error("SetUpDigits","TObject Array digPerDet does not exist");
211 m = digPerDet->GetSize();
213 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
214 " at least that of n=%d",digPerDet,n);
217 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
223 if(digPerDet->At(i)==0){ // set up TClones Array
224 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
225 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
226 else sprintf(branch,"ITSDigits%d",i+1);
227 br = td->GetBranch(branch);
228 br->SetAddress(&((*digPerDet)[i]));
229 continue; // do next one.
231 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
232 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
233 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
234 "zeroed or filled with TClonesArrays",i,digPerDet);
237 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
238 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
239 "derived from AliITSdigit",i,digPerDet->At(i));
242 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
243 else sprintf(branch,"ITSDigits%d",i+1);
244 br = td->GetBranch(branch);
245 br->SetAddress(&((*digPerDet)[i]));
249 //---------------------------------------------------------------------
250 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
252 // Gets the digit for for a specific detector type and module.
253 // To be used in conjustion with Setupdigits(AliITS *its).
255 // TObjArray *digPereDet Pointer to the Array of digits
256 // Int_t module Module number
257 // Int_t digit Digit number
261 // returns the pointer to the digit. if zero then last digit for that
265 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
266 digPerDet,module,digit);
272 //---------------------------------------------------------------------
273 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
274 // Gets the digit for for a specific detector type and module.
275 // To be used in conjustion with Setupdigits(AliITS *its).
277 // AliITS *its Pointer to the ITS
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
285 //AliITSDetType *idtype;
286 AliITSgeom *geom = its->GetITSgeom();
287 Int_t idet = geom->GetModuleType(module);
288 TClonesArray *digits;
291 TreeD()->GetEvent(module);
292 digits = its->DigitsAddress(idet);
293 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
294 return (AliITSdigit*) digits->At(digit);
299 //----------------------------------------------------------------------
300 void AliITSLoader::MakeTree(Option_t *opt){
301 // invokes AliLoader::MakeTree + specific ITS tree(s)
302 // Valid options: H,S,D,R,T and C (C=raw clusters)
303 AliLoader::MakeTree(opt);
304 const char *oC = strstr(opt,"C");
305 if (oC) MakeRawClustersContainer();
307 const char *oB = strstr(opt,"B");
308 if (oB) MakeBackTracksContainer();
310 const char *oV0 = strstr(opt,"V0");
311 if (oV0) MakeV0Container();
313 const char *oX = strstr(opt,"X");
314 if (oX) MakeCascadeContainer();
317 //----------------------------------------------------------------------
318 AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
319 // retrieves the ITS geometry from file
320 if(fGeom && !force)return fGeom;
325 AliRunLoader *runLoader = GetRunLoader();
326 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
327 if (!runLoader->GetAliRun()) {
328 Error("GetITSgeom", "couldn't get AliRun object");
332 TDirectory *curdir = gDirectory;
333 runLoader->CdGAFile();
334 fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
337 Error("GetITSgeom","no ITS geometry available");
340 AliWarning("AliITSgeom object has been fetched from galice.root file");
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