1 #include "AliITSdigit.h"
2 #include "AliITSLoader.h"
3 #include "AliRunLoader.h"
5 ///////////////////////////////////////////////////////////////////////////
7 // it manages the I/O for:
8 // raw clusters, primary vertices
10 // and tracks propagated to the origin
11 //////////////////////////////////////////////////////////////////////////
12 const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
13 const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
14 const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
15 const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
16 const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
17 ClassImp(AliITSLoader)
19 /**********************************************************************/
20 AliITSLoader::AliITSLoader():AliLoader(){
21 // Default constructor
24 /*********************************************************************/
25 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
26 AliLoader(name,topfoldername){
28 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
29 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
31 fDataLoaders->Add(rawClustersDataLoader);
32 rawClustersDataLoader->SetEventFolder(fEventFolder);
33 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
35 AliDataLoader* backTracksDataLoader = new AliDataLoader(
36 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
37 "Back Propagated Tracks");
38 fDataLoaders->Add(backTracksDataLoader);
39 backTracksDataLoader->SetEventFolder(fEventFolder);
40 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
42 AliDataLoader* vertexDataLoader = new AliDataLoader(
43 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
44 "Primary Vertices","O");
45 fDataLoaders->Add(vertexDataLoader);
46 vertexDataLoader->SetEventFolder(fEventFolder);
47 vertexDataLoader->SetFolder(GetDetectorDataFolder());
49 AliDataLoader* v0DataLoader = new AliDataLoader(
50 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
51 fDataLoaders->Add(v0DataLoader);
52 v0DataLoader->SetEventFolder(fEventFolder);
53 v0DataLoader->SetFolder(GetDetectorDataFolder());
55 AliDataLoader* cascadeDataLoader = new AliDataLoader(
56 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
58 fDataLoaders->Add(cascadeDataLoader);
59 cascadeDataLoader->SetEventFolder(fEventFolder);
60 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
63 /**********************************************************************/
64 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
65 AliLoader(name,topfolder) {
67 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
68 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
70 fDataLoaders->Add(rawClustersDataLoader);
71 rawClustersDataLoader->SetEventFolder(fEventFolder);
72 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
74 AliDataLoader* backTracksDataLoader = new AliDataLoader(
75 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
76 "Back Propagated Tracks");
77 fDataLoaders->Add(backTracksDataLoader);
78 backTracksDataLoader->SetEventFolder(fEventFolder);
79 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
81 AliDataLoader* vertexDataLoader = new AliDataLoader(
82 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
83 "Primary Vertices","O");
84 fDataLoaders->Add(vertexDataLoader);
85 vertexDataLoader->SetEventFolder(fEventFolder);
86 vertexDataLoader->SetFolder(GetDetectorDataFolder());
88 AliDataLoader* v0DataLoader = new AliDataLoader(
89 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
90 fDataLoaders->Add(v0DataLoader);
91 v0DataLoader->SetEventFolder(fEventFolder);
92 v0DataLoader->SetFolder(GetDetectorDataFolder());
94 AliDataLoader* cascadeDataLoader = new AliDataLoader(
95 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
97 fDataLoaders->Add(cascadeDataLoader);
98 cascadeDataLoader->SetEventFolder(fEventFolder);
99 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
103 //______________________________________________________________________
104 AliITSLoader::AliITSLoader(const AliITSLoader &ob) : AliLoader(ob) {
106 // Copies are not allowed. The method is protected to avoid misuse.
107 Error("AliITSLoader","Copy constructor not allowed\n");
110 //______________________________________________________________________
111 AliITSLoader& AliITSLoader::operator=(const AliITSLoader& /* ob */){
112 // Assignment operator
113 // Assignment is not allowed. The method is protected to avoid misuse.
114 Error("= operator","Assignment operator not allowed\n");
118 /**********************************************************************/
119 AliITSLoader::~AliITSLoader(){
121 AliDataLoader* dl = 0;
123 dl = GetRawClLoader();
124 fDataLoaders->Remove(dl);
127 dl = GetBackTracksDataLoader();
128 fDataLoaders->Remove(dl);
131 dl = GetVertexDataLoader();
132 fDataLoaders->Remove(dl);
135 dl = GetV0DataLoader();
136 fDataLoaders->Remove(dl);
139 dl = GetCascadeDataLoader();
140 fDataLoaders->Remove(dl);
141 if(fITSpid)delete fITSpid;
144 //----------------------------------------------------------------------
145 AliITS* AliITSLoader::GetITS(){
146 // Returns the pointer to the ITS, kept on the file. A short cut metthod
152 // Returns a pointer to the ITS, if not found returns 0.
156 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
157 GetDetectorName().Data()));
164 ar = rl->GetAliRun();
166 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
169 //----------------------------------------------------------------------
170 void AliITSLoader::SetupDigits(AliITS *its){
171 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
173 // AliITS *its Pointer to the ITS
179 its->SetTreeAddressD(TreeD());
182 //----------------------------------------------------------------------
183 void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
184 const Char_t **digclass){
185 // Sets up digPerDet to store ITS Digits.
187 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
188 // Int_t n The size of the TObjArray and digclass array
189 // Char_t **digclass Array of digit class names
191 // TObjArray *digPerDet Setup and linked to the tree of digits
195 TClonesArray *cl = 0;
199 const Char_t *det[3] = {"SPD","SDD","SSD"};
202 Error("SetUpDigits","TObject Array digPerDet does not exist");
205 m = digPerDet->GetSize();
207 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
208 " at least that of n=%d",digPerDet,n);
211 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
217 if(digPerDet->At(i)==0){ // set up TClones Array
218 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
219 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
220 else sprintf(branch,"ITSDigits%d",i+1);
221 br = td->GetBranch(branch);
222 br->SetAddress(&((*digPerDet)[i]));
223 continue; // do next one.
225 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
226 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
227 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
228 "zeroed or filled with TClonesArrays",i,digPerDet);
231 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
232 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
233 "derived from AliITSdigit",i,digPerDet->At(i));
236 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
237 else sprintf(branch,"ITSDigits%d",i+1);
238 br = td->GetBranch(branch);
239 br->SetAddress(&((*digPerDet)[i]));
243 //---------------------------------------------------------------------
244 AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
246 // Gets the digit for for a specific detector type and module.
247 // To be used in conjustion with Setupdigits(AliITS *its).
249 // TObjArray *digPereDet Pointer to the Array of digits
250 // Int_t module Module number
251 // Int_t digit Digit number
255 // returns the pointer to the digit. if zero then last digit for that
259 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
260 digPerDet,module,digit);
266 //---------------------------------------------------------------------
267 AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
268 // Gets the digit for for a specific detector type and module.
269 // To be used in conjustion with Setupdigits(AliITS *its).
271 // AliITS *its Pointer to the ITS
272 // Int_t module Module number
273 // Int_t digit Digit number
277 // returns the pointer to the digit. if zero then last digit for that
279 //AliITSDetType *idtype;
280 AliITSgeom *geom = its->GetITSgeom();
281 Int_t idet = geom->GetModuleType(module);
282 TClonesArray *digits;
285 TreeD()->GetEvent(module);
286 digits = its->DigitsAddress(idet);
287 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
288 return (AliITSdigit*) digits->At(digit);
293 //----------------------------------------------------------------------
294 void AliITSLoader::MakeTree(Option_t *opt){
295 // invokes AliLoader::MakeTree + specific ITS tree(s)
296 // Valid options: H,S,D,R,T and C (C=raw clusters)
297 AliLoader::MakeTree(opt);
298 const char *oC = strstr(opt,"C");
299 if (oC) MakeRawClustersContainer();
301 const char *oB = strstr(opt,"B");
302 if (oB) MakeBackTracksContainer();
304 const char *oV0 = strstr(opt,"V0");
305 if (oV0) MakeV0Container();
307 const char *oX = strstr(opt,"X");
308 if (oX) MakeCascadeContainer();
311 //----------------------------------------------------------------------
312 AliITSgeom* AliITSLoader::GetITSgeom() {
313 // retrieves the ITS geometry from file
314 AliRunLoader *runLoader = GetRunLoader();
315 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
316 if (!runLoader->GetAliRun()) {
317 Error("GetITSgeom", "couldn't get AliRun object");
321 runLoader->CdGAFile();
322 AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
324 Error("GetITSgeom","no ITS geometry available");