]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSULoader.cxx
Moving required CMake version from 2.8.4 to 2.8.8
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSULoader.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id: AliITSULoader.cxx $ */
17
18 #include <TClonesArray.h>
19 #include <TClass.h>
20 #include <TGeoManager.h>
21 #include <TTree.h>
22
23 #include "AliITSdigit.h"
24 #include "AliITSULoader.h"
25 #include "AliRunLoader.h"
26 #include "AliObjectLoader.h"
27 #include "AliLog.h"
28
29 ///////////////////////////////////////////////////////////////////////////
30 // Loader for ITS Upgrade
31 // it manages the I/O for:
32 // raw clusters, primary vertices
33 // V0 and cascade
34 // and tracks propagated to the origin
35 //////////////////////////////////////////////////////////////////////////
36 ClassImp(AliITSULoader)
37
38 /**********************************************************************/
39 AliITSULoader::AliITSULoader()
40 :AliLoader()
41 {
42   // Default constructor
43 }
44
45 /*********************************************************************/
46 AliITSULoader::AliITSULoader(const Char_t *name,const Char_t *topfoldername)
47 : AliLoader(name,topfoldername)
48 {
49   //Constructor   
50   TString rawContainerName = "TreeC";
51     AliDataLoader* rawClustersDataLoader = new AliDataLoader(
52         fDetectorName + ".RawCl.root",rawContainerName,
53         "Raw Clusters");
54     fDataLoaders->Add(rawClustersDataLoader);
55     rawClustersDataLoader->SetEventFolder(fEventFolder);
56     rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
57
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,
81         "Cascades");
82     fDataLoaders->Add(cascadeDataLoader);
83     cascadeDataLoader->SetEventFolder(fEventFolder);
84     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
85 }
86 /**********************************************************************/
87 AliITSULoader::AliITSULoader(const Char_t *name,TFolder *topfolder)
88 : AliLoader(name,topfolder)
89 {
90   //ctor  
91    TString rawContainerName="TreeC";
92     AliDataLoader*  rawClustersDataLoader = new AliDataLoader(
93         fDetectorName + ".RawCl.root",rawContainerName,
94         "Raw Clusters"); 
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,
121         "Cascades");
122     fDataLoaders->Add(cascadeDataLoader);
123     cascadeDataLoader->SetEventFolder(fEventFolder);
124     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
125 }
126
127
128 /**********************************************************************/
129 AliITSULoader::~AliITSULoader(){
130     //destructor
131     UnloadRawClusters();
132     AliDataLoader *dl = GetRawClLoader();
133     fDataLoaders->Remove(dl);
134
135     UnloadBackTracks();
136     dl = GetBackTracksDataLoader();
137     fDataLoaders->Remove(dl);
138
139     UnloadVertices();
140     dl = GetVertexDataLoader();
141     fDataLoaders->Remove(dl);
142
143     UnloadV0s();
144     dl = GetV0DataLoader();
145     fDataLoaders->Remove(dl);
146
147     UnloadCascades();
148     dl = GetCascadeDataLoader();
149     fDataLoaders->Remove(dl);
150   
151 }
152 /*
153 //----------------------------------------------------------------------
154 AliITS* AliITSULoader::GetITS(){
155     // Returns the pointer to the ITS, kept on the file. A short cut metthod
156     // Inputs:
157     //    none.
158     // Outputs:
159     //    none.
160     // Returns:
161     //    Returns a pointer to the ITS, if not found returns 0.
162     AliITS *its;
163
164     if(gAlice){
165         its = dynamic_cast<AliITS*> (gAlice->GetDetector(
166             GetDetectorName().Data()));
167         if(its) return its;
168     } // end if gAlice
169     AliRunLoader *rl=0;
170     rl = GetRunLoader();
171     if(!rl) return 0;
172     AliRun *ar=0;
173     ar = rl->GetAliRun();
174     if(!ar) return 0;
175     its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
176     return its;
177 }
178 //----------------------------------------------------------------------
179 void AliITSULoader::SetupDigits(AliITS *its){
180     // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
181     // Inputs:
182     //    AliITS *its  Pointer to the ITS
183     // Outputs:
184     //    none.
185     // Return:
186     //    none.
187
188     its->SetTreeAddressD(TreeD());
189 }
190 */
191 //----------------------------------------------------------------------
192 void AliITSULoader::SetupDigits(TObjArray *digPerDet,Int_t n,
193                                   const Char_t **digclass){
194     // Sets up digPerDet to store ITS Digits.
195     // Inputs:
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
199     // Outputs:
200     //    TObjArray *digPerDet   Setup and linked to the tree of digits
201     // Return:
202     //    none.
203     Int_t i,m;
204     TClonesArray *cl = 0;
205     TTree *td = 0;
206     TBranch *br = 0;
207     Char_t branch[14];
208     const Char_t *det[3] = {"SPD","SDD","SSD"};
209
210     if(!digPerDet){
211         Error("SetUpDigits","TObject Array digPerDet does not exist");
212         return;
213     } // end if
214     m = digPerDet->GetSize();
215     if(m<n){
216         Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
217               " at least that of n=%d",digPerDet,n);
218     } // end if
219     if(m<3){
220         Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
221               digPerDet);
222         return;
223     } // end if
224     td = TreeD();
225     for(i=0;i<n;i++){
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.
233         } // end if
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);
238             return;
239         } // end if
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));
243         } // end if
244         cl->Clear();
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]));
249         continue;
250     } // end for i
251 }
252 //---------------------------------------------------------------------
253 AliITSdigit * AliITSULoader::GetDigit(TObjArray *digPerDet,Int_t chip,
254                                         Int_t digit){
255     // Gets the digit for for a specific detector type and chip.
256     // To be used in conjustion with Setupdigits(AliITS *its).
257     // Inputs:
258     //   TObjArray *digPereDet    Pointer to the Array of digits
259     //   Int_t      chip        Chip number
260     //   Int_t      digit         Digit number
261     // Outputs:
262     //   none.
263     // Return:
264     //   returns the pointer to the digit. if zero then last digit for that
265     //   chip.
266
267     if(digPerDet==0){
268         Error("GetDigit","digPerDet=%p, chip=%d, digit=%d",
269               digPerDet,chip,digit);
270         return 0;
271     } // end if
272     return 0;
273 }
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();
281
282     const char *oB = strstr(opt,"B");
283     if (oB) MakeBackTracksContainer();
284
285     const char *oV0 = strstr(opt,"V0");
286     if (oV0) MakeV0Container();
287
288     const char *oX = strstr(opt,"X");
289     if (oX) MakeCascadeContainer();
290 }