]>
Commit | Line | Data |
---|---|---|
50837721 | 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$ */ | |
f0945e46 | 17 | |
71a2d3aa | 18 | /// \class AliMUONData |
f0945e46 | 19 | /// |
20 | /// Class containing MUON data: hits, digits, rawclusters, globaltrigger, localtrigger, etc .. | |
21 | /// The classe makes the lik between the MUON data lists and the event trees from loaders | |
22 | /// | |
c4ee792d | 23 | /// \author Gines Martinez, Subatech, September 2003 |
f0945e46 | 24 | /// |
9140dcef | 25 | |
6309cf6e | 26 | #include "AliMUONData.h" |
6b74d6d9 | 27 | #include "AliMUONDataIterator.h" |
c82862d3 | 28 | #include "AliMUONConstants.h" |
6309cf6e | 29 | #include "AliMUONDigit.h" |
c82862d3 | 30 | #include "AliMUONGlobalTrigger.h" |
6309cf6e | 31 | #include "AliMUONLocalTrigger.h" |
47dc4ee7 | 32 | #include "AliMUONRegionalTrigger.h" |
6b74d6d9 | 33 | #include "AliMUONTriggerCrateStore.h" |
34 | #include "AliMUONTriggerCircuit.h" | |
35 | #include "AliMUONGeometryTransformer.h" | |
6309cf6e | 36 | #include "AliMUONRawCluster.h" |
6b74d6d9 | 37 | |
f0945e46 | 38 | #include "AliRunLoader.h" |
6b74d6d9 | 39 | #include "AliStack.h" |
40 | #include "AliLog.h" | |
41 | ||
42 | #include <TString.h> | |
43 | #include <TParticle.h> | |
44 | #include <TNtuple.h> | |
45 | #include <Riostream.h> | |
46 | #include <TFile.h> | |
30178c30 | 47 | |
5398f946 | 48 | /// \cond CLASSIMP |
6309cf6e | 49 | ClassImp(AliMUONData) |
5398f946 | 50 | /// \endcond |
6309cf6e | 51 | |
52 | //_____________________________________________________________________________ | |
1017e5bf | 53 | AliMUONData::AliMUONData(): |
54 | TNamed(), | |
6b74d6d9 | 55 | fRunLoader(0x0), |
1017e5bf | 56 | fLoader(0x0), |
1017e5bf | 57 | fSDigits(0x0), |
8e322de6 | 58 | fDigits(0x0), |
1017e5bf | 59 | fGlobalTrigger(0x0), |
60 | fLocalTrigger(0x0), | |
47dc4ee7 | 61 | fRegionalTrigger(0x0), |
1017e5bf | 62 | fNSdigits(0x0), |
8e322de6 | 63 | fNdigits(0x0), |
1017e5bf | 64 | fNglobaltrigger(0), |
65 | fNlocaltrigger(0), | |
47dc4ee7 | 66 | fNregionaltrigger(0), |
f0945e46 | 67 | fSplitLevel(0), |
68 | fCurrentEvent(-1) | |
6309cf6e | 69 | { |
71a2d3aa | 70 | /// Default constructor |
6309cf6e | 71 | } |
72 | //_____________________________________________________________________________ | |
73 | AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title): | |
1017e5bf | 74 | TNamed(name,title), |
6b74d6d9 | 75 | fRunLoader(0x0), |
1017e5bf | 76 | fLoader(loader), |
1017e5bf | 77 | fSDigits(0x0), |
8e322de6 | 78 | fDigits(0x0), |
1017e5bf | 79 | fGlobalTrigger(0x0), |
80 | fLocalTrigger(0x0), | |
47dc4ee7 | 81 | fRegionalTrigger(0x0), |
1017e5bf | 82 | fNSdigits(0x0), |
8e322de6 | 83 | fNdigits(0x0), |
1017e5bf | 84 | fNglobaltrigger(0), |
85 | fNlocaltrigger(0), | |
47dc4ee7 | 86 | fNregionaltrigger(0), |
f0945e46 | 87 | fSplitLevel(0), |
88 | fCurrentEvent(-1) | |
6309cf6e | 89 | { |
5398f946 | 90 | /// Standard constructor |
6309cf6e | 91 | } |
e3ea1889 | 92 | |
6b74d6d9 | 93 | //_____________________________________________________________________________ |
8e322de6 | 94 | AliMUONData::AliMUONData(const char* galiceFile, const char* folderName): |
6b74d6d9 | 95 | TNamed("MUON", "MUON"), |
96 | fRunLoader(0x0), | |
97 | fLoader(0x0), | |
6b74d6d9 | 98 | fSDigits(0x0), |
8e322de6 | 99 | fDigits(0x0), |
6b74d6d9 | 100 | fGlobalTrigger(0x0), |
101 | fLocalTrigger(0x0), | |
102 | fRegionalTrigger(0x0), | |
6b74d6d9 | 103 | fNSdigits(0x0), |
8e322de6 | 104 | fNdigits(0x0), |
6b74d6d9 | 105 | fNglobaltrigger(0), |
106 | fNlocaltrigger(0), | |
107 | fNregionaltrigger(0), | |
6b74d6d9 | 108 | fSplitLevel(0), |
109 | fCurrentEvent(-1) | |
110 | { | |
111 | /// Constructor for loading data from gAlice file | |
112 | ||
8e322de6 | 113 | fRunLoader = AliRunLoader::Open(galiceFile, folderName, "READ"); |
6b74d6d9 | 114 | if (!fRunLoader) { |
115 | AliError(Form("Error opening %s file \n", galiceFile)); | |
116 | return; | |
117 | } | |
118 | ||
119 | fLoader = fRunLoader->GetLoader("MUONLoader"); | |
120 | if ( ! fLoader ) { | |
121 | AliError(Form("Could get MUONLoader")); | |
122 | return; | |
123 | } | |
124 | } | |
125 | ||
6309cf6e | 126 | //_____________________________________________________________________________ |
127 | AliMUONData::~AliMUONData() | |
128 | { | |
5398f946 | 129 | /// Destructor for AliMUONData |
c82862d3 | 130 | |
d1775029 | 131 | if (fSDigits) { |
132 | fSDigits->Delete(); | |
133 | delete fSDigits; | |
134 | } | |
8e322de6 | 135 | |
136 | if (fDigits) { | |
137 | fDigits->Delete(); | |
138 | delete fDigits; | |
6309cf6e | 139 | } |
140 | if (fGlobalTrigger){ | |
141 | fGlobalTrigger->Delete(); | |
142 | delete fGlobalTrigger; | |
143 | } | |
47dc4ee7 | 144 | if (fRegionalTrigger){ |
145 | fRegionalTrigger->Delete(); | |
146 | delete fRegionalTrigger; | |
147 | } | |
6309cf6e | 148 | if (fLocalTrigger){ |
149 | fLocalTrigger->Delete(); | |
150 | delete fLocalTrigger; | |
151 | } | |
6b74d6d9 | 152 | |
153 | if (fRunLoader) { | |
154 | fRunLoader->UnloadAll(); | |
155 | delete fRunLoader; | |
156 | } | |
6309cf6e | 157 | } |
8e322de6 | 158 | //_____________________________________________________________________________ |
159 | void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit) | |
47dc4ee7 | 160 | { |
8e322de6 | 161 | /// Add a MUON Sdigit to the list of SDigits of the detection plane id |
162 | ||
163 | TClonesArray &lSdigits = * SDigits(id) ; | |
164 | new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit); | |
47dc4ee7 | 165 | } |
6309cf6e | 166 | //_____________________________________________________________________________ |
61adb9bd | 167 | void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit) |
168 | { | |
5398f946 | 169 | /// Add a MUON digit to the list of Digits of the detection plane id |
170 | ||
61adb9bd | 171 | TClonesArray &ldigits = * Digits(id) ; |
172 | new(ldigits[fNdigits[id]++]) AliMUONDigit(digit); | |
173 | } | |
2cf44ef3 | 174 | |
6309cf6e | 175 | //_____________________________________________________________________________ |
61adb9bd | 176 | void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger ) |
177 | { | |
5398f946 | 178 | /// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !); |
179 | ||
61adb9bd | 180 | TClonesArray &globalTrigger = *fGlobalTrigger; |
181 | new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger); | |
182 | } | |
5398f946 | 183 | |
6309cf6e | 184 | //____________________________________________________________________________ |
47dc4ee7 | 185 | void AliMUONData::AddRegionalTrigger(const AliMUONRegionalTrigger& trigger) |
1391e633 | 186 | { |
47dc4ee7 | 187 | /// add a MUON regional Trigger to the list |
188 | TClonesArray ®ionalTrigger = *fRegionalTrigger; | |
189 | new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger); | |
61adb9bd | 190 | } |
191 | //____________________________________________________________________________ | |
61adb9bd | 192 | void AliMUONData::AddLocalTrigger(const AliMUONLocalTrigger& trigger) |
193 | { | |
5398f946 | 194 | /// add a MUON Local Trigger to the list |
195 | ||
61adb9bd | 196 | TClonesArray &localTrigger = *fLocalTrigger; |
197 | new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger); | |
198 | } | |
47dc4ee7 | 199 | |
1eccde20 | 200 | //____________________________________________________________________________ |
c82862d3 | 201 | TClonesArray* AliMUONData::SDigits(Int_t DetectionPlane) const |
d1775029 | 202 | { |
5398f946 | 203 | /// Getting List of SDigits |
204 | ||
d1775029 | 205 | if (fSDigits) |
206 | return ( (TClonesArray*) fSDigits->At(DetectionPlane) ); | |
207 | else | |
208 | return NULL; | |
209 | } | |
210 | //____________________________________________________________________________ | |
8e322de6 | 211 | TClonesArray* AliMUONData::Digits(Int_t DetectionPlane) const |
c1d45bdf | 212 | { |
8e322de6 | 213 | /// Getting List of Digits |
5398f946 | 214 | |
8e322de6 | 215 | if (fDigits) |
216 | return ( (TClonesArray*) fDigits->At(DetectionPlane) ); | |
217 | else | |
218 | return NULL; | |
c1d45bdf | 219 | } |
220 | //____________________________________________________________________________ | |
ce3e25a8 | 221 | Bool_t AliMUONData::IsDigitsBranchesInTree() |
222 | { | |
8e322de6 | 223 | /// Checking if there are Digits Branches In TreeD |
5398f946 | 224 | |
ce3e25a8 | 225 | if (TreeD()==0x0) { |
8c343c7c | 226 | AliError("No treeD in memory"); |
ce3e25a8 | 227 | return kFALSE; |
228 | } | |
229 | else { | |
230 | char branchname[30]; | |
231 | sprintf(branchname,"%sDigits1",GetName()); | |
232 | TBranch * branch = 0x0; | |
233 | branch = TreeD()->GetBranch(branchname); | |
234 | if (branch) return kTRUE; | |
235 | else return kFALSE; | |
236 | } | |
237 | } | |
238 | //____________________________________________________________________________ | |
ce3e25a8 | 239 | Bool_t AliMUONData::IsTriggerBranchesInTreeD() |
240 | { | |
8e322de6 | 241 | /// Checking if there are Trigger Branches In TreeD |
ce3e25a8 | 242 | if (TreeD()==0x0) { |
8c343c7c | 243 | AliError("No treeD in memory"); |
ce3e25a8 | 244 | return kFALSE; |
245 | } | |
246 | else { | |
247 | char branchname[30]; | |
248 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
249 | TBranch * branch = 0x0; | |
250 | branch = TreeD()->GetBranch(branchname); | |
251 | if (branch) return kTRUE; | |
252 | else return kFALSE; | |
253 | } | |
254 | } | |
255 | ||
276c44b7 | 256 | //____________________________________________________________________________ |
1a1cdff8 | 257 | void AliMUONData::Fill(Option_t* option) |
258 | { | |
5398f946 | 259 | /// Method to fill the trees |
8e322de6 | 260 | |
d1775029 | 261 | const char *cS = strstr(option,"S"); // SDigits branches in TreeS |
8e322de6 | 262 | const char *cD = strstr(option,"D"); // Digits branches in TreeD |
ce3e25a8 | 263 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD |
1a1cdff8 | 264 | |
265 | char branchname[30]; | |
266 | TBranch * branch = 0x0; | |
267 | ||
8e322de6 | 268 | // Filling TreeS |
269 | if ( TreeS() && cS) | |
f0945e46 | 270 | { |
8e322de6 | 271 | TreeS()->Fill(); |
272 | } | |
273 | ||
1a1cdff8 | 274 | // Filling TreeD |
ce3e25a8 | 275 | |
c82862d3 | 276 | if ( TreeD() && cD && cGLT ) |
277 | { | |
f0945e46 | 278 | // Writing digits and (global+local) trigger at once. |
c82862d3 | 279 | TreeD()->Fill(); |
280 | } | |
f0945e46 | 281 | else |
282 | { | |
283 | if ( TreeD() && cD ) | |
284 | { | |
285 | if ( IsTriggerBranchesInTreeD() ) | |
286 | { | |
287 | for (int i=0; i<AliMUONConstants::NCh(); i++) | |
288 | { | |
289 | sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
290 | branch = TreeD()->GetBranch(branchname); | |
291 | branch->Fill(); | |
292 | } | |
293 | } | |
294 | else | |
295 | { | |
296 | TreeD()->Fill(); | |
ce3e25a8 | 297 | } |
f0945e46 | 298 | } |
299 | ||
300 | if ( TreeD() && cGLT ) | |
301 | { | |
302 | if ( IsDigitsBranchesInTree() ) | |
303 | { | |
304 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
305 | branch = TreeD()->GetBranch(branchname); | |
306 | branch->Fill(); | |
47dc4ee7 | 307 | sprintf(branchname,"%sRegionalTrigger",GetName()); |
308 | branch = TreeD()->GetBranch(branchname); | |
309 | branch->Fill(); | |
f0945e46 | 310 | sprintf(branchname,"%sGlobalTrigger",GetName()); |
311 | branch = TreeD()->GetBranch(branchname); | |
312 | branch->Fill(); | |
47dc4ee7 | 313 | |
f0945e46 | 314 | } |
315 | else | |
316 | { | |
317 | TreeD()->Fill(); | |
318 | } | |
319 | } | |
320 | } // end of TreeD() handling. | |
1a1cdff8 | 321 | } |
c82862d3 | 322 | |
1a1cdff8 | 323 | //_____________________________________________________________________________ |
6309cf6e | 324 | void AliMUONData::MakeBranch(Option_t* option) |
325 | { | |
5398f946 | 326 | /// Create Tree branches for the MUON. |
327 | ||
6309cf6e | 328 | const Int_t kBufferSize = 4000; |
329 | char branchname[30]; | |
330 | ||
79fc84ff | 331 | //Setting Data Container |
332 | SetDataContainer(option); | |
333 | ||
d1775029 | 334 | const char *cS = strstr(option,"S"); // Digits branches in TreeS |
8e322de6 | 335 | const char *cD = strstr(option,"D"); // Digits branches in TreeD |
ce3e25a8 | 336 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD |
c82862d3 | 337 | |
6309cf6e | 338 | TBranch * branch = 0x0; |
339 | ||
8e322de6 | 340 | //Creating Branches for SDigits |
341 | if (TreeS() && cS ) { | |
342 | // one branch for Sdigits per chamber | |
343 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) { | |
344 | sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1); | |
345 | branch = 0x0; | |
346 | branch = TreeS()->GetBranch(branchname); | |
347 | if (branch) { | |
348 | AliInfo(Form("Branch %s is already in tree.",branchname)); | |
349 | return; | |
350 | } | |
351 | TClonesArray * sdigits = SDigits(iDetectionPlane); | |
352 | branch = TreeS()->Branch(branchname, &sdigits, kBufferSize,1); | |
353 | //Info("MakeBranch","Making Branch %s for sdigits in detection plane %d\n",branchname,iDetectionPlane+1); | |
6309cf6e | 354 | } |
8e322de6 | 355 | } |
356 | ||
6309cf6e | 357 | //Creating Branches for Digits |
c82862d3 | 358 | TTree* treeD = 0x0; |
359 | if ( cD || cGLT ) | |
360 | { | |
361 | treeD = TreeD(); | |
362 | } | |
363 | ||
364 | if ( treeD && cD ) | |
365 | { | |
6309cf6e | 366 | // one branch for digits per chamber |
c82862d3 | 367 | for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) |
368 | { | |
6309cf6e | 369 | sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1); |
c82862d3 | 370 | branch = treeD->GetBranch(branchname); |
371 | if (branch) | |
372 | { | |
f0945e46 | 373 | AliInfo(Form("Branch %s is already in tree.",branchname)); |
c82862d3 | 374 | return; |
6309cf6e | 375 | } |
1a1cdff8 | 376 | TClonesArray * digits = Digits(iDetectionPlane); |
c82862d3 | 377 | branch = treeD->Branch(branchname, &digits, kBufferSize,1); |
378 | } | |
6309cf6e | 379 | } |
c82862d3 | 380 | |
381 | if ( treeD && cGLT ) | |
382 | { | |
ce3e25a8 | 383 | // |
384 | // one branch for global trigger | |
385 | // | |
386 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
c82862d3 | 387 | branch = treeD->GetBranch(branchname); |
388 | if (branch) | |
389 | { | |
8c343c7c | 390 | AliInfo(Form("Branch GlobalTrigger is already in treeD.")); |
ce3e25a8 | 391 | return ; |
392 | } | |
c82862d3 | 393 | branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize); |
394 | ||
47dc4ee7 | 395 | // |
396 | // one branch for regional trigger | |
397 | // | |
398 | sprintf(branchname,"%sRegionalTrigger",GetName()); | |
399 | branch = 0x0; | |
47dc4ee7 | 400 | branch = treeD->GetBranch(branchname); |
401 | if (branch) | |
402 | { | |
403 | AliInfo(Form("Branch RegionalTrigger is already in treeD.")); | |
404 | return; | |
405 | } | |
406 | branch = treeD->Branch(branchname, &fRegionalTrigger, kBufferSize); | |
407 | ||
408 | ||
ce3e25a8 | 409 | // |
410 | // one branch for local trigger | |
411 | // | |
412 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
413 | branch = 0x0; | |
c82862d3 | 414 | branch = treeD->GetBranch(branchname); |
415 | if (branch) | |
416 | { | |
8c343c7c | 417 | AliInfo(Form("Branch LocalTrigger is already in treeD.")); |
ce3e25a8 | 418 | return; |
419 | } | |
c82862d3 | 420 | branch = treeD->Branch(branchname, &fLocalTrigger, kBufferSize); |
ce3e25a8 | 421 | } |
6309cf6e | 422 | } |
8e322de6 | 423 | |
1eccde20 | 424 | //____________________________________________________________________________ |
8e322de6 | 425 | TClonesArray* |
426 | AliMUONData::LocalTrigger() const | |
276c44b7 | 427 | { |
5398f946 | 428 | /// Getting local trigger |
429 | ||
f0945e46 | 430 | return fLocalTrigger; |
276c44b7 | 431 | } |
f0945e46 | 432 | |
1a46cb76 | 433 | //____________________________________________________________________________ |
434 | TClonesArray* | |
435 | AliMUONData::RegionalTrigger() const | |
436 | { | |
437 | /// Getting regional trigger | |
438 | ||
439 | return fRegionalTrigger; | |
440 | } | |
441 | ||
276c44b7 | 442 | //____________________________________________________________________________ |
f0945e46 | 443 | void |
444 | AliMUONData::GetDigits() const | |
276c44b7 | 445 | { |
5398f946 | 446 | /// Load the digits from TreeD for the current event. |
447 | ||
f0945e46 | 448 | Int_t event = fLoader->GetRunLoader()->GetEventNumber(); |
449 | if ( fCurrentEvent != event ) | |
450 | { | |
698b2e52 | 451 | if (fLoader->TreeD()) { |
452 | fLoader->TreeD()->GetEvent(0); | |
453 | fCurrentEvent = event; | |
454 | } | |
f0945e46 | 455 | } |
276c44b7 | 456 | } |
f0945e46 | 457 | |
458 | //____________________________________________________________________________ | |
459 | TClonesArray* | |
460 | AliMUONData::GlobalTrigger() const | |
461 | { | |
5398f946 | 462 | /// Return the global trigger |
463 | ||
f0945e46 | 464 | return fGlobalTrigger; |
465 | } | |
466 | ||
d1775029 | 467 | //____________________________________________________________________________ |
468 | void AliMUONData::ResetSDigits() | |
469 | { | |
5398f946 | 470 | /// Reset number of Sdigits and the Sdigits array for this detector |
471 | ||
d1775029 | 472 | if (fSDigits == 0x0) return; |
473 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) { | |
474 | if ((*fSDigits)[i]) ((TClonesArray*)fSDigits->At(i))->Clear(); | |
475 | if (fNSdigits) fNSdigits[i]=0; | |
476 | } | |
477 | } | |
8e322de6 | 478 | //____________________________________________________________________________ |
479 | void AliMUONData::ResetDigits() | |
6309cf6e | 480 | { |
8e322de6 | 481 | /// Reset number of digits and the digits array for this detector |
5398f946 | 482 | |
8e322de6 | 483 | if (fDigits == 0x0) return; |
484 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) { | |
485 | if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear("C"); | |
486 | if (fNdigits) fNdigits[i]=0; | |
487 | } | |
6309cf6e | 488 | } |
489 | //_______________________________________________________________________________ | |
490 | void AliMUONData::ResetTrigger() | |
491 | { | |
5398f946 | 492 | /// Reset Local and Global Trigger |
493 | ||
6309cf6e | 494 | fNglobaltrigger = 0; |
495 | if (fGlobalTrigger) fGlobalTrigger->Clear(); | |
47dc4ee7 | 496 | fNregionaltrigger = 0; |
497 | if (fRegionalTrigger) fRegionalTrigger->Clear(); | |
6309cf6e | 498 | fNlocaltrigger = 0; |
499 | if (fLocalTrigger) fLocalTrigger->Clear(); | |
47dc4ee7 | 500 | |
6309cf6e | 501 | } |
dcd2690d | 502 | //____________________________________________________________________________ |
79fc84ff | 503 | void AliMUONData::SetDataContainer(Option_t* option) |
504 | { | |
505 | /// Setting data containers of muon data | |
8e322de6 | 506 | |
79fc84ff | 507 | const char *cS = strstr(option,"S"); // SDigits |
8e322de6 | 508 | const char *cD = strstr(option,"D"); // Digits |
79fc84ff | 509 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger |
8e322de6 | 510 | |
79fc84ff | 511 | AliDebug(1,Form("option=%s",option)); |
79fc84ff | 512 | |
79fc84ff | 513 | // |
514 | // Container for Sdigits | |
515 | if (cS) { | |
516 | if (fSDigits == 0x0) { | |
517 | AliDebug(1,"Creating fSDigits TObjArray"); | |
518 | fSDigits = new TObjArray(AliMUONConstants::NCh()); | |
519 | fNSdigits= new Int_t[AliMUONConstants::NCh()]; | |
520 | for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) { | |
521 | TClonesArray* a = new TClonesArray("AliMUONDigit",10000); | |
522 | a->SetOwner(); | |
523 | fSDigits->AddAt(a,i); | |
524 | AliDebug(1,Form("fSDigits[%d]=%p",i,a)); | |
525 | fNSdigits[i]=0; | |
526 | } | |
527 | } | |
528 | else { | |
529 | AliDebug(1,Form("fSDigits already there = %p",fSDigits)); | |
530 | } | |
531 | ResetSDigits(); | |
8e322de6 | 532 | } |
533 | ||
79fc84ff | 534 | // |
8e322de6 | 535 | // ObjArray of ClonesArrays for Digits |
536 | if ( cD ) { | |
537 | if (fDigits == 0x0 ) { | |
538 | fDigits = new TObjArray(AliMUONConstants::NCh()); | |
539 | fNdigits= new Int_t[AliMUONConstants::NCh()]; | |
540 | for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) { | |
541 | TClonesArray * tca = new TClonesArray("AliMUONDigit",10000); | |
79fc84ff | 542 | tca->SetOwner(); |
8e322de6 | 543 | fDigits->AddAt(tca,i); |
544 | fNdigits[i]=0; | |
79fc84ff | 545 | } |
8e322de6 | 546 | } |
547 | else { | |
548 | AliDebug(1,Form("fDigits already there = %p",fDigits)); | |
79fc84ff | 549 | } |
8e322de6 | 550 | ResetDigits(); |
79fc84ff | 551 | } |
8e322de6 | 552 | |
553 | // | |
554 | // ClonesArrays for Trigger | |
555 | if ( cGLT ) { | |
79fc84ff | 556 | if (fLocalTrigger == 0x0) { |
557 | fLocalTrigger = new TClonesArray("AliMUONLocalTrigger",234); | |
558 | } | |
8e322de6 | 559 | if (fRegionalTrigger == 0x0) { |
79fc84ff | 560 | fRegionalTrigger = new TClonesArray("AliMUONRegionalTrigger",16); |
561 | } | |
562 | if (fGlobalTrigger== 0x0) { | |
563 | fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); | |
564 | } | |
8e322de6 | 565 | ResetTrigger(); |
79fc84ff | 566 | } |
79fc84ff | 567 | } |
568 | ||
569 | //____________________________________________________________________________ | |
ce3f5e87 | 570 | void AliMUONData::SetTreeAddress(Option_t* option) |
6309cf6e | 571 | { |
07547aa3 | 572 | /// Setting Addresses to the events trees |
573 | ||
79fc84ff | 574 | // Setting Data containers |
575 | SetDataContainer(option); | |
576 | ||
d1775029 | 577 | const char *cS = strstr(option,"S"); // SDigits branches in TreeS |
8e322de6 | 578 | const char *cD = strstr(option,"D"); // Digits branches in TreeD |
ce3e25a8 | 579 | const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD |
ce3f5e87 | 580 | |
6309cf6e | 581 | // Set branch address for the Hits, Digits, RawClusters, GlobalTrigger and LocalTrigger Tree. |
582 | char branchname[30]; | |
583 | TBranch * branch = 0x0; | |
c82862d3 | 584 | |
585 | AliDebug(1,Form("option=%s",option)); | |
8e322de6 | 586 | |
6309cf6e | 587 | // |
8e322de6 | 588 | // Branch address for Sdigit tree |
589 | if (TreeS() && fSDigits && cS) { | |
590 | AliDebug(1,"Setting branch addresses"); | |
591 | for (int i=0; i<AliMUONConstants::NCh(); i++) { | |
592 | sprintf(branchname,"%sSDigits%d",GetName(),i+1); | |
593 | if (fSDigits) { | |
594 | AliDebug(1,Form("TreeS=%p for ich=%d branchname=%s", | |
595 | TreeS(),i,branchname)); | |
596 | branch = TreeS()->GetBranch(branchname); | |
597 | TClonesArray * sdigits = SDigits(i); | |
598 | if (branch) branch->SetAddress( &sdigits ); | |
599 | else AliWarning(Form("(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i)); | |
600 | } | |
6309cf6e | 601 | } |
602 | } | |
8e322de6 | 603 | |
6309cf6e | 604 | // |
605 | // Branch address for digit tree | |
ce3f5e87 | 606 | if (TreeD() && fDigits && cD) { |
6309cf6e | 607 | for (int i=0; i<AliMUONConstants::NCh(); i++) { |
608 | sprintf(branchname,"%sDigits%d",GetName(),i+1); | |
d652f85c | 609 | if (fDigits) { |
c82862d3 | 610 | branch = TreeD()->GetBranch(branchname); |
611 | TClonesArray * digits = Digits(i); | |
612 | if (branch) { | |
613 | branch->SetAddress( &digits ); | |
614 | } | |
615 | else AliWarning(Form("(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i)); | |
d652f85c | 616 | } |
6309cf6e | 617 | } |
618 | } | |
ce3e25a8 | 619 | if ( TreeD() && fLocalTrigger && cGLT) { |
620 | sprintf(branchname,"%sLocalTrigger",GetName()); | |
621 | branch = TreeD()->GetBranch(branchname); | |
622 | if (branch) branch->SetAddress(&fLocalTrigger); | |
8c343c7c | 623 | else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName())); |
ce3e25a8 | 624 | } |
47dc4ee7 | 625 | if ( TreeD() && fRegionalTrigger && cGLT) { |
626 | sprintf(branchname,"%sRegionalTrigger",GetName()); | |
627 | branch = TreeD()->GetBranch(branchname); | |
628 | if (branch) branch->SetAddress(&fRegionalTrigger); | |
629 | else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeD.",GetName())); | |
630 | } | |
ce3e25a8 | 631 | if ( TreeD() && fGlobalTrigger && cGLT) { |
632 | sprintf(branchname,"%sGlobalTrigger",GetName()); | |
633 | branch = TreeD()->GetBranch(branchname); | |
634 | if (branch) branch->SetAddress(&fGlobalTrigger); | |
8c343c7c | 635 | else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeD.",GetName())); |
ce3e25a8 | 636 | } |
6309cf6e | 637 | } |
c82862d3 | 638 | |
6309cf6e | 639 | //_____________________________________________________________________________ |
c82862d3 | 640 | void |
641 | AliMUONData::Print(Option_t* opt) const | |
642 | { | |
5398f946 | 643 | /// Dump object on screen |
644 | ||
c82862d3 | 645 | TString options(opt); |
646 | options.ToUpper(); | |
647 | ||
648 | if ( options.Contains("D") ) | |
649 | { | |
650 | for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich) | |
651 | { | |
652 | TClonesArray* digits = Digits(ich); | |
653 | Int_t ndigits = digits->GetEntriesFast(); | |
654 | for ( Int_t id = 0; id < ndigits; ++id ) | |
655 | { | |
656 | AliMUONDigit* digit = | |
657 | static_cast<AliMUONDigit*>(digits->UncheckedAt(id)); | |
658 | digit->Print(); | |
659 | } | |
660 | } | |
661 | } | |
8e322de6 | 662 | |
c82862d3 | 663 | if ( options.Contains("S") ) |
664 | { | |
665 | for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich) | |
666 | { | |
667 | TClonesArray* digits = SDigits(ich); | |
668 | Int_t ndigits = digits->GetEntriesFast(); | |
669 | for ( Int_t id = 0; id < ndigits; ++id ) | |
670 | { | |
671 | AliMUONDigit* digit = | |
672 | static_cast<AliMUONDigit*>(digits->UncheckedAt(id)); | |
673 | digit->Print(); | |
674 | } | |
675 | } | |
6b74d6d9 | 676 | } |
6b74d6d9 | 677 | } |
678 | ||
679 | //_____________________________________________________________________________ | |
680 | void | |
681 | AliMUONData::DumpSDigits(Int_t event2Check, Option_t* opt) | |
682 | { | |
71a2d3aa | 683 | /// Dump SDigits |
684 | ||
6b74d6d9 | 685 | fLoader->LoadSDigits("READ"); |
686 | ||
687 | // Event loop | |
688 | Int_t nevents = fRunLoader->GetNumberOfEvents(); | |
689 | for (Int_t ievent=0; ievent<nevents; ievent++) { | |
690 | if (event2Check!=0) ievent=event2Check; | |
691 | printf(">>> Event %d \n",ievent); | |
692 | ||
693 | // Getting event ievent | |
694 | fRunLoader->GetEvent(ievent); | |
695 | SetTreeAddress("S"); | |
696 | GetSDigits(); | |
697 | ||
698 | // Loop on chambers | |
699 | Int_t nchambers = AliMUONConstants::NCh(); ; | |
700 | for (Int_t ichamber=0; ichamber<nchambers; ichamber++) { | |
701 | TClonesArray* digits = SDigits(ichamber); | |
702 | ||
703 | // Loop on Sdigits | |
704 | Int_t ndigits = (Int_t)digits->GetEntriesFast(); | |
705 | for (Int_t idigit=0; idigit<ndigits; idigit++) { | |
706 | AliMUONDigit* mDigit = static_cast<AliMUONDigit*>(digits->At(idigit)); | |
707 | mDigit->Print(opt); | |
708 | } | |
709 | } | |
710 | ResetSDigits(); | |
711 | if (event2Check!=0) ievent=nevents; | |
712 | } | |
713 | fLoader->UnloadSDigits(); | |
714 | } | |
6b74d6d9 | 715 | //_____________________________________________________________________________ |
716 | void | |
8e322de6 | 717 | AliMUONData::DumpDigits(Int_t event2Check, Option_t* opt) |
6b74d6d9 | 718 | { |
8e322de6 | 719 | /// Dump digits |
6b74d6d9 | 720 | |
8e322de6 | 721 | fLoader->LoadDigits("READ"); |
6b74d6d9 | 722 | |
8e322de6 | 723 | // Event loop |
724 | Int_t firstEvent = 0; | |
725 | Int_t lastEvent = fRunLoader->GetNumberOfEvents()-1; | |
726 | if ( event2Check != 0 ) { | |
727 | firstEvent = event2Check; | |
728 | lastEvent = event2Check; | |
729 | } | |
6b74d6d9 | 730 | |
8e322de6 | 731 | for ( Int_t ievent = firstEvent; ievent <= lastEvent; ++ievent ) { |
732 | printf(">>> Event %d \n",ievent); | |
6b74d6d9 | 733 | fRunLoader->GetEvent(ievent); |
6b74d6d9 | 734 | |
8e322de6 | 735 | AliMUONDataIterator it(this, "digit", AliMUONDataIterator::kTrackingChambers); |
736 | AliMUONDigit* digit; | |
737 | ||
738 | while ( ( digit = (AliMUONDigit*)it.Next() ) ) | |
739 | { | |
740 | digit->Print(opt); | |
741 | } | |
742 | } | |
743 | fLoader->UnloadDigits(); | |
6b74d6d9 | 744 | } |