]>
Commit | Line | Data |
---|---|---|
13985652 | 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$ */ | |
48b32e42 | 17 | |
48b32e42 | 18 | #include "AliMUONDataInterface.h" |
e9bef706 | 19 | #include "AliMUONGeometryTransformer.h" |
e8636ba0 | 20 | #include "AliMUONVDigit.h" |
2060b217 | 21 | #include "AliMUONVCluster.h" |
e8636ba0 | 22 | #include "AliMUONLocalTrigger.h" |
23 | #include "AliMUONRegionalTrigger.h" | |
24 | #include "AliMUONGlobalTrigger.h" | |
e9bef706 | 25 | #include "AliMUONTriggerCircuit.h" |
a202c2d2 | 26 | #include "AliMUONVClusterStore.h" |
e9bef706 | 27 | #include "AliMUONVDigitStore.h" |
e9bef706 | 28 | #include "AliMUONVTriggerStore.h" |
c074480f | 29 | #include "AliMpCDB.h" |
e9bef706 | 30 | |
e8636ba0 | 31 | #include "AliMpIntPair.h" |
32 | #include "AliMpDEManager.h" | |
33 | #include "AliMpConstants.h" | |
a55f49a0 | 34 | #include "AliMpCDB.h" |
e8636ba0 | 35 | |
e9bef706 | 36 | #include "AliLoader.h" |
37 | #include "AliLog.h" | |
e9bef706 | 38 | #include "AliRunLoader.h" |
aa73f8fb | 39 | #include "AliHeader.h" |
40 | #include "AliCDBManager.h" | |
e9bef706 | 41 | |
42 | #include <TError.h> | |
43 | #include <TParticle.h> | |
44 | #include <Riostream.h> | |
45 | #include <TFile.h> | |
a202c2d2 | 46 | #include <TList.h> |
e9bef706 | 47 | #include <TNtuple.h> |
48 | #include <TSystem.h> | |
e8636ba0 | 49 | #include <TIterator.h> |
50 | #include <cstdlib> | |
51 | #include <cassert> | |
6d149c9e | 52 | |
3d1463c8 | 53 | //----------------------------------------------------------------------------- |
85fec35d | 54 | /// \class AliMUONDataInterface |
55 | /// | |
a202c2d2 | 56 | /// An easy to use interface to the MUON data data stored in |
61fed964 | 57 | /// TreeS, TreeD and TreeR. |
a202c2d2 | 58 | /// |
59 | /// For MC related information (i.e. TreeH, TreeK, TreeTR), see | |
60 | /// AliMUONMCDataInterface. | |
61 | /// | |
85fec35d | 62 | /// |
63 | /// This interface in not necessarily the fastest way to fetch the data but | |
64 | /// it is the easiest. | |
85fec35d | 65 | /// |
e8636ba0 | 66 | /// \author Laurent Aphecetche, Subatech & Artur Szostak <artursz@iafrica.com> (University of Cape Town) |
3d1463c8 | 67 | //----------------------------------------------------------------------------- |
13985652 | 68 | |
69 | /// \cond CLASSIMP | |
70 | ClassImp(AliMUONDataInterface) | |
71 | /// \endcond | |
48b32e42 | 72 | |
e9bef706 | 73 | |
74 | Int_t AliMUONDataInterface::fgInstanceCounter(0); | |
75 | ||
a202c2d2 | 76 | //______________________________________________________________________________ |
77 | AliMUONDataInterface::AliMUONDataInterface(const char* filename) | |
e9bef706 | 78 | : TObject(), |
79 | fLoader(0x0), | |
80 | fDigitStore(0x0), | |
81 | fTriggerStore(0x0), | |
82 | fClusterStore(0x0), | |
e9bef706 | 83 | fCurrentEvent(-1), |
e8636ba0 | 84 | fIsValid(kFALSE), |
85 | fCurrentIteratorType(kNoIterator), | |
86 | fCurrentIndex(-1), | |
87 | fDataX(-1), | |
88 | fDataY(-1), | |
89 | fIterator(0x0) | |
48b32e42 | 90 | { |
a202c2d2 | 91 | /// ctor |
92 | /// @param filename should be the full path to a valid galice.root file | |
93 | ||
e9bef706 | 94 | ++fgInstanceCounter; |
95 | ||
96 | Open(filename); | |
a55f49a0 | 97 | |
98 | // Load mapping | |
99 | if ( ! AliMpCDB::LoadDDLStore() ) { | |
100 | AliFatal("Could not access mapping from OCDB !"); | |
101 | } | |
925e6570 | 102 | } |
48b32e42 | 103 | |
a202c2d2 | 104 | //______________________________________________________________________________ |
48b32e42 | 105 | AliMUONDataInterface::~AliMUONDataInterface() |
106 | { | |
a202c2d2 | 107 | /// dtor |
e8636ba0 | 108 | ResetStores(); |
109 | if ( fLoader != 0x0 ) | |
e9bef706 | 110 | { |
111 | delete fLoader->GetRunLoader(); | |
112 | } | |
113 | --fgInstanceCounter; | |
a202c2d2 | 114 | } |
48b32e42 | 115 | |
e8636ba0 | 116 | //______________________________________________________________________________ |
117 | AliMUONVDigitStore* | |
118 | AliMUONDataInterface::DigitStore(Int_t event) | |
119 | { | |
120 | /// Return digitStore for a given event. | |
121 | /// Return 0x0 if event not found. | |
122 | /// Returned pointer should not be deleted | |
123 | ||
124 | if (not IsValid()) return 0x0; | |
125 | if (event == fCurrentEvent and fDigitStore != 0x0) return fDigitStore; | |
126 | ||
127 | ResetStores(); | |
128 | if (not LoadEvent(event)) return 0x0; | |
129 | ||
130 | fLoader->LoadDigits(); | |
131 | ||
132 | TTree* treeD = fLoader->TreeD(); | |
133 | if (treeD == 0x0) | |
134 | { | |
135 | AliError("Could not get treeD"); | |
136 | return 0x0; | |
137 | } | |
138 | ||
139 | fDigitStore = AliMUONVDigitStore::Create(*treeD); | |
140 | if ( fDigitStore != 0x0 ) | |
141 | { | |
142 | fDigitStore->Clear(); | |
143 | fDigitStore->Connect(*treeD); | |
144 | treeD->GetEvent(0); | |
145 | } | |
146 | ||
147 | fLoader->UnloadDigits(); | |
148 | ||
149 | return fDigitStore; | |
150 | } | |
151 | ||
a202c2d2 | 152 | //______________________________________________________________________________ |
153 | AliMUONVClusterStore* | |
e9bef706 | 154 | AliMUONDataInterface::ClusterStore(Int_t event) |
a202c2d2 | 155 | { |
e9bef706 | 156 | /// Return clusterStore for a given event. |
157 | /// Return 0x0 if event not found. | |
158 | /// Returned pointer should not be deleted | |
159 | ||
e8636ba0 | 160 | if (not IsValid()) return 0x0; |
161 | if (event == fCurrentEvent and fClusterStore != 0x0) return fClusterStore; | |
162 | ||
163 | ResetStores(); | |
164 | if (not LoadEvent(event)) return 0x0; | |
e9bef706 | 165 | |
166 | fLoader->LoadRecPoints(); | |
167 | ||
168 | TTree* treeR = fLoader->TreeR(); | |
e8636ba0 | 169 | if (treeR == 0x0) |
e9bef706 | 170 | { |
171 | AliError("Could not get treeR"); | |
172 | return 0x0; | |
173 | } | |
174 | ||
e8636ba0 | 175 | fClusterStore = AliMUONVClusterStore::Create(*treeR); |
176 | if ( fClusterStore != 0x0 ) | |
e9bef706 | 177 | { |
178 | fClusterStore->Clear(); | |
179 | fClusterStore->Connect(*treeR); | |
180 | treeR->GetEvent(0); | |
181 | } | |
182 | ||
183 | fLoader->UnloadRecPoints(); | |
184 | ||
185 | return fClusterStore; | |
186 | } | |
3455463a | 187 | |
e8636ba0 | 188 | //_____________________________________________________________________________ |
189 | AliMUONVTriggerStore* | |
190 | AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter) | |
191 | { | |
192 | /// Return the triggerStore for a given event. | |
193 | /// Return 0x0 if event not found. | |
194 | /// Returned pointer should not be deleted | |
195 | /// treeLetter can be R or D to tell from which tree to read the information | |
196 | ||
197 | if (not IsValid()) return 0x0; | |
198 | if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore; | |
199 | ||
200 | ResetStores(); | |
201 | if (not LoadEvent(event)) return 0x0; | |
202 | ||
203 | TTree* tree(0x0); | |
204 | ||
205 | TString stree(treeLetter); | |
206 | stree.ToUpper(); | |
207 | ||
208 | if ( stree == "D" ) | |
209 | { | |
210 | fLoader->LoadDigits(); | |
211 | tree = fLoader->TreeD(); | |
212 | } | |
213 | else if ( stree == "R" ) | |
214 | { | |
215 | fLoader->LoadRecPoints(); | |
216 | tree = fLoader->TreeR(); | |
217 | } | |
218 | ||
219 | if ( tree == 0x0 ) | |
220 | { | |
221 | AliError(Form("Could not get tree%s",treeLetter)); | |
222 | return 0x0; | |
223 | } | |
224 | ||
225 | fTriggerStore = AliMUONVTriggerStore::Create(*tree); | |
226 | if ( fTriggerStore != 0x0 ) | |
227 | { | |
228 | fTriggerStore->Clear(); | |
229 | fTriggerStore->Connect(*tree); | |
230 | tree->GetEvent(0); | |
231 | } | |
232 | ||
233 | if ( stree == "D" ) | |
234 | { | |
235 | fLoader->UnloadDigits(); | |
236 | } | |
237 | else if ( stree == "R" ) | |
238 | { | |
239 | fLoader->UnloadRecPoints(); | |
240 | } | |
241 | ||
242 | return fTriggerStore; | |
925e6570 | 243 | } |
48b32e42 | 244 | |
a202c2d2 | 245 | //______________________________________________________________________________ |
246 | void | |
e9bef706 | 247 | AliMUONDataInterface::DumpDigits(Int_t event, Bool_t sorted) |
48b32e42 | 248 | { |
e9bef706 | 249 | /// Dump the digits for a given event, sorted if so required |
250 | DigitStore(event); | |
e8636ba0 | 251 | if ( fDigitStore != 0x0 ) |
e9bef706 | 252 | { |
253 | if ( sorted ) | |
254 | { | |
255 | DumpSorted(*fDigitStore); | |
256 | } | |
257 | else | |
258 | { | |
259 | fDigitStore->Print(); | |
260 | } | |
261 | } | |
925e6570 | 262 | } |
48b32e42 | 263 | |
a202c2d2 | 264 | //______________________________________________________________________________ |
e9bef706 | 265 | void |
266 | AliMUONDataInterface::DumpRecPoints(Int_t event, Bool_t sorted) | |
6d149c9e | 267 | { |
e9bef706 | 268 | /// Dump the recpoints for a given event, sorted if so required |
269 | ClusterStore(event); | |
e8636ba0 | 270 | if ( fClusterStore != 0x0 ) |
e9bef706 | 271 | { |
272 | if ( sorted ) | |
273 | { | |
274 | DumpSorted(*fClusterStore); | |
275 | } | |
276 | else | |
277 | { | |
278 | fClusterStore->Print(); | |
279 | } | |
280 | } | |
6d149c9e | 281 | } |
282 | ||
e9bef706 | 283 | //_____________________________________________________________________________ |
284 | void | |
285 | AliMUONDataInterface::DumpSorted(const AliMUONVStore& store) const | |
6d149c9e | 286 | { |
e9bef706 | 287 | /// Dump the given store, in sorted order |
a202c2d2 | 288 | |
e9bef706 | 289 | TIter next(store.CreateIterator()); |
a202c2d2 | 290 | TObject* object; |
e9bef706 | 291 | TList list; |
292 | list.SetOwner(kFALSE); | |
a202c2d2 | 293 | |
e9bef706 | 294 | while ( ( object = next() ) ) |
a202c2d2 | 295 | { |
e9bef706 | 296 | list.Add(object); |
a202c2d2 | 297 | } |
298 | ||
e9bef706 | 299 | list.Sort(); |
300 | ||
301 | list.Print(); | |
a202c2d2 | 302 | } |
303 | ||
e9bef706 | 304 | //_____________________________________________________________________________ |
305 | void | |
306 | AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter) | |
307 | { | |
308 | /// Dump trigger for a given event from a given tree (if event>=0) | |
309 | /// or loop over all events and build a trigger ntuple if event<0 | |
310 | /// treeLetter can be R or D to tell from which tree to read the information | |
a202c2d2 | 311 | |
e9bef706 | 312 | if ( event < 0 ) |
313 | { | |
314 | NtupleTrigger(treeLetter); | |
a202c2d2 | 315 | } |
316 | else | |
317 | { | |
e9bef706 | 318 | TriggerStore(event,treeLetter); |
a202c2d2 | 319 | |
e8636ba0 | 320 | if ( fTriggerStore != 0x0 ) |
e9bef706 | 321 | { |
322 | fTriggerStore->Print(); | |
323 | } | |
324 | } | |
a202c2d2 | 325 | } |
6d149c9e | 326 | |
e9bef706 | 327 | //_____________________________________________________________________________ |
a202c2d2 | 328 | void |
e9bef706 | 329 | AliMUONDataInterface::NtupleTrigger(const char* treeLetter) |
48b32e42 | 330 | { |
e9bef706 | 331 | //// Loop over events to build trigger ntuples |
332 | /// | |
333 | ||
334 | TString sTreeLetter(treeLetter); | |
335 | sTreeLetter.ToUpper(); | |
336 | ||
337 | if ( sTreeLetter != "R" && sTreeLetter != "D" ) | |
338 | { | |
339 | AliError(Form("Cannot handle tree%s. Use D or R",treeLetter)); | |
340 | return; | |
341 | } | |
342 | ||
343 | // book ntuples | |
344 | TNtuple tupleGlo("TgtupleGlo","Global Trigger Ntuple", | |
345 | "ev:slpt:shpt:uplpt:uphpt:lplpt:lplpt"); | |
346 | TNtuple tupleLoc("TgtupleLoc","Local Trigger Ntuple", | |
347 | "ev:LoCircuit:LoStripX:LoDev:StripY:LoLpt:LoHpt:y11:y21:x11"); | |
348 | ||
349 | // initialize counters | |
350 | Int_t sLowpt=0; | |
351 | Int_t sHighpt=0; | |
352 | Int_t uSLowpt=0; | |
353 | Int_t uSHighpt=0; | |
354 | Int_t lSLowpt=0; | |
355 | Int_t lSHighpt=0; | |
356 | ||
d3acfadf | 357 | AliMUONGeometryTransformer transformer; |
ef4cb4f1 | 358 | transformer.LoadGeometryData(Form("%s/geometry.root", |
e9bef706 | 359 | gSystem->DirName(fLoader->GetRunLoader()->GetFileName()))); |
a55f49a0 | 360 | AliMUONTriggerCircuit triggerCircuit(&transformer); |
e9bef706 | 361 | |
362 | // select output file name from selected Tree | |
363 | Char_t fileNameOut[30]; | |
364 | if (sTreeLetter == "D") | |
365 | { | |
366 | AliInfo(Form("reading from Digits\n")); | |
367 | sprintf(fileNameOut,"TriggerCheckFromDigits.root"); | |
368 | } | |
369 | else if (sTreeLetter == "R") | |
370 | { | |
371 | AliInfo(Form("reading from RecPoints\n")); | |
372 | sprintf(fileNameOut,"TriggerCheckFromRP.root"); | |
373 | } | |
374 | ||
375 | // loop on events | |
376 | Int_t nevents = NumberOfEvents(); | |
377 | ||
378 | for (Int_t ievent=0; ievent<nevents; ++ievent) | |
379 | { | |
380 | if (ievent%100==0) AliInfo(Form("Processing event %d\n",ievent)); | |
381 | ||
8af099d3 | 382 | AliMUONVTriggerStore* triggerStore = TriggerStore(ievent,treeLetter); |
e9bef706 | 383 | |
384 | if (!triggerStore) | |
385 | { | |
386 | AliError(Form("Could not read %s from tree%s","Trigger",treeLetter)); | |
387 | return; | |
388 | } | |
389 | ||
390 | // get global trigger info | |
391 | AliMUONGlobalTrigger* gloTrg = triggerStore->Global(); | |
392 | sLowpt+=gloTrg->SingleLpt(); | |
393 | sHighpt+=gloTrg->SingleHpt(); | |
394 | uSLowpt+=gloTrg->PairUnlikeLpt(); | |
395 | uSHighpt+=gloTrg->PairUnlikeHpt(); | |
396 | lSLowpt+=gloTrg->PairLikeLpt(); | |
397 | lSHighpt+=gloTrg->PairLikeHpt(); | |
398 | ||
399 | // loop on local triggers | |
400 | TIter next(triggerStore->CreateIterator()); | |
401 | AliMUONLocalTrigger* locTrg(0x0); | |
402 | while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) ) | |
403 | { | |
d72d7b9e | 404 | Bool_t xTrig=locTrg->IsTrigX(); |
405 | Bool_t yTrig=locTrg->IsTrigY(); | |
e9bef706 | 406 | |
407 | if (xTrig && yTrig) | |
408 | { // fill ntuple if trigger in X and Y | |
409 | tupleLoc.Fill(ievent,locTrg->LoCircuit(), | |
410 | locTrg->LoStripX(), | |
411 | locTrg->LoDev(), | |
412 | locTrg->LoStripY(), | |
413 | locTrg->LoLpt(), | |
414 | locTrg->LoHpt(), | |
415 | triggerCircuit.GetY11Pos(locTrg->LoCircuit(),locTrg->LoStripX()), | |
416 | triggerCircuit.GetY21Pos(locTrg->LoCircuit(),locTrg->LoStripX()+locTrg->LoDev()+1), | |
417 | triggerCircuit.GetX11Pos(locTrg->LoCircuit(),locTrg->LoStripY())); | |
418 | } | |
419 | tupleGlo.Fill(ievent,gloTrg->SingleLpt(),gloTrg->SingleHpt(), | |
420 | gloTrg->PairUnlikeLpt(),gloTrg->PairUnlikeHpt(), | |
421 | gloTrg->PairLikeLpt(),gloTrg->PairLikeHpt()); | |
422 | } // end of loop on local triggers | |
423 | } // end of loop on events | |
424 | ||
425 | // print info and store ntuples | |
426 | printf("\n"); | |
427 | printf("=============================================\n"); | |
428 | printf("================ SUMMARY ==================\n"); | |
429 | printf("\n"); | |
430 | printf("Total number of events processed %d \n",nevents); | |
431 | printf("\n"); | |
432 | printf(" Global Trigger output Low pt High pt\n"); | |
433 | printf(" number of Single :\t"); | |
434 | printf("%i\t%i\t",sLowpt,sHighpt); | |
435 | printf("\n"); | |
436 | printf(" number of UnlikeSign pair :\t"); | |
437 | printf("%i\t%i\t",uSLowpt,uSHighpt); | |
438 | printf("\n"); | |
439 | printf(" number of LikeSign pair :\t"); | |
440 | printf("%i\t%i\t",lSLowpt,lSHighpt); | |
441 | printf("\n"); | |
442 | printf("=============================================\n"); | |
443 | fflush(stdout); | |
444 | ||
445 | TFile myFile(fileNameOut, "RECREATE"); | |
446 | tupleGlo.Write(); | |
447 | tupleLoc.Write(); | |
448 | myFile.Close(); | |
925e6570 | 449 | } |
48b32e42 | 450 | |
e9bef706 | 451 | //_____________________________________________________________________________ |
e8636ba0 | 452 | Bool_t |
e9bef706 | 453 | AliMUONDataInterface::LoadEvent(Int_t event) |
48b32e42 | 454 | { |
e9bef706 | 455 | /// Load event if different from the current one. |
e8636ba0 | 456 | /// Returns kFALSE on error and kTRUE if the event was loaded. |
457 | ||
458 | assert( IsValid() ); | |
459 | ||
460 | AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader())); | |
461 | if (fLoader->GetRunLoader()->GetEvent(event) == 0) | |
e9bef706 | 462 | { |
463 | fCurrentEvent = event; | |
e8636ba0 | 464 | return kTRUE; |
e9bef706 | 465 | } |
e8636ba0 | 466 | else |
467 | return kFALSE; | |
925e6570 | 468 | } |
48b32e42 | 469 | |
a202c2d2 | 470 | //______________________________________________________________________________ |
e9bef706 | 471 | Int_t |
472 | AliMUONDataInterface::NumberOfEvents() const | |
a202c2d2 | 473 | { |
e9bef706 | 474 | /// Number of events in the current galice.root file we're attached to |
e8636ba0 | 475 | if (not IsValid()) return -1; |
e9bef706 | 476 | return fLoader->GetRunLoader()->GetNumberOfEvents(); |
a202c2d2 | 477 | } |
48b32e42 | 478 | |
e9bef706 | 479 | //_____________________________________________________________________________ |
a202c2d2 | 480 | void |
e9bef706 | 481 | AliMUONDataInterface::Open(const char* filename) |
48b32e42 | 482 | { |
e9bef706 | 483 | /// Connect to a given galice.root file |
484 | ||
e8636ba0 | 485 | ResetStores(); |
e9bef706 | 486 | |
487 | fCurrentEvent=-1; | |
488 | ||
e8636ba0 | 489 | if ( fLoader != 0x0 ) |
e9bef706 | 490 | { |
491 | delete fLoader->GetRunLoader(); | |
492 | } | |
493 | ||
494 | fLoader = 0x0; | |
495 | ||
496 | fIsValid = kTRUE; | |
497 | ||
498 | TString foldername(Form("%s-%d",ClassName(),fgInstanceCounter)); | |
499 | ||
e8636ba0 | 500 | while (AliRunLoader::GetRunLoader(foldername) != 0x0) |
e9bef706 | 501 | { |
502 | delete AliRunLoader::GetRunLoader(foldername); | |
503 | } | |
504 | ||
505 | AliRunLoader* runLoader = AliRunLoader::Open(filename,foldername); | |
e8636ba0 | 506 | if (runLoader == 0x0) |
e9bef706 | 507 | { |
508 | AliError(Form("Cannot open file %s",filename)); | |
509 | fIsValid = kFALSE; | |
510 | } | |
aa73f8fb | 511 | |
512 | runLoader->LoadHeader(); | |
513 | if ( ! runLoader->GetHeader() ) { | |
514 | AliError("Cannot load header."); | |
515 | fIsValid = kFALSE; | |
516 | } | |
517 | else { | |
518 | Int_t runNumber = runLoader->GetHeader()->GetRun(); | |
519 | AliCDBManager::Instance()->SetRun(runNumber); | |
520 | } | |
521 | runLoader->UnloadHeader(); | |
522 | ||
e9bef706 | 523 | fLoader = runLoader->GetDetectorLoader("MUON"); |
e8636ba0 | 524 | if (fLoader == 0x0) |
e9bef706 | 525 | { |
526 | AliError("Cannot get AliMUONLoader"); | |
527 | fIsValid = kFALSE; | |
528 | } | |
529 | ||
e8636ba0 | 530 | if (not IsValid()) |
e9bef706 | 531 | { |
532 | AliError(Form("Could not access %s filename. Object is unuseable",filename)); | |
533 | } | |
925e6570 | 534 | } |
48b32e42 | 535 | |
e9bef706 | 536 | //_____________________________________________________________________________ |
e8636ba0 | 537 | Bool_t AliMUONDataInterface::GetEvent(Int_t event) |
48b32e42 | 538 | { |
e8636ba0 | 539 | /// Loads all reconstructed data for the given event. |
540 | ||
541 | if (DigitStore(event) == 0x0) return kFALSE; | |
542 | if (ClusterStore(event) == 0x0) return kFALSE; | |
e8636ba0 | 543 | if (TriggerStore(event) == 0x0) return kFALSE; |
e8636ba0 | 544 | return kTRUE; |
925e6570 | 545 | } |
48b32e42 | 546 | |
e8636ba0 | 547 | //_____________________________________________________________________________ |
548 | Int_t AliMUONDataInterface::NumberOfDigits(Int_t detElemId) | |
48b32e42 | 549 | { |
e8636ba0 | 550 | /// Returns the number of digits to be found on a given detector element. |
551 | /// @param detElemId The detector element ID number to search on. | |
a202c2d2 | 552 | |
e8636ba0 | 553 | TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId); |
554 | return CountObjects(iter); | |
925e6570 | 555 | } |
48b32e42 | 556 | |
e8636ba0 | 557 | //_____________________________________________________________________________ |
558 | AliMUONVDigit* AliMUONDataInterface::Digit(Int_t detElemId, Int_t index) | |
48b32e42 | 559 | { |
e8636ba0 | 560 | /// Returns the a pointer to the index'th digit on the specified detector element. |
561 | /// @param detElemId The detector element ID number to search on. | |
562 | /// @param index The index number of the digit to fetch in the range [0 .. N-1], | |
563 | /// where N = NumberOfDigits(detElemId) | |
a202c2d2 | 564 | |
e8636ba0 | 565 | TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId); |
566 | return static_cast<AliMUONVDigit*>( FetchObject(iter, index) ); | |
925e6570 | 567 | } |
48b32e42 | 568 | |
e8636ba0 | 569 | //_____________________________________________________________________________ |
570 | Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode) | |
48b32e42 | 571 | { |
e8636ba0 | 572 | /// Returns the number of digits to be found on a specific chamber and cathode. |
573 | /// @param chamber The chamber number in the range [0 .. 13]. | |
574 | /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and | |
575 | /// 1 is the non-bending plane. | |
48b32e42 | 576 | |
e8636ba0 | 577 | TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode); |
578 | return CountObjects(iter); | |
925e6570 | 579 | } |
48b32e42 | 580 | |
e8636ba0 | 581 | //_____________________________________________________________________________ |
582 | AliMUONVDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index) | |
48b32e42 | 583 | { |
e8636ba0 | 584 | /// Returns the a pointer to the index'th digit on the specified chamber and cathode. |
585 | /// @param chamber The chamber number in the range [0 .. 13]. | |
586 | /// @param cathode The cathode in the range [0 .. 1], where 0 is the bending and | |
587 | /// 1 is the non-bending plane. | |
588 | /// @param index The index number of the digit to fetch in the range [0 .. N-1], | |
589 | /// where N = NumberOfDigits(chamber, cathode) | |
590 | ||
591 | TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode); | |
592 | return static_cast<AliMUONVDigit*>( FetchObject(iter, index) ); | |
925e6570 | 593 | } |
48b32e42 | 594 | |
e8636ba0 | 595 | //_____________________________________________________________________________ |
596 | Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber) | |
48b32e42 | 597 | { |
e8636ba0 | 598 | /// Returns the number of reconstructed raw clusters on the specified chamber. |
599 | /// @param chamber The chamber number in the range [0 .. 13]. | |
a202c2d2 | 600 | |
e8636ba0 | 601 | TIterator* iter = GetIterator(kRawClusterIterator, chamber); |
602 | return CountObjects(iter); | |
925e6570 | 603 | } |
48b32e42 | 604 | |
e8636ba0 | 605 | //_____________________________________________________________________________ |
2060b217 | 606 | AliMUONVCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index) |
48b32e42 | 607 | { |
e8636ba0 | 608 | /// Returns a pointer to the index'th raw cluster on the specified chamber. |
609 | /// @param chamber The chamber number in the range [0 .. 13]. | |
610 | /// @param index The index number of the raw cluster to fetch in the range [0 .. N-1], | |
611 | /// where N = NumberOfRawClusters(chamber) | |
a202c2d2 | 612 | |
e8636ba0 | 613 | TIterator* iter = GetIterator(kRawClusterIterator, chamber); |
2060b217 | 614 | return static_cast<AliMUONVCluster*>( FetchObject(iter, index) ); |
925e6570 | 615 | } |
48b32e42 | 616 | |
e8636ba0 | 617 | //_____________________________________________________________________________ |
618 | Int_t AliMUONDataInterface::NumberOfLocalTriggers() | |
48b32e42 | 619 | { |
e8636ba0 | 620 | /// Returns the number of reconstructed local trigger objects. |
a202c2d2 | 621 | |
e8636ba0 | 622 | TIterator* iter = GetIterator(kLocalTriggerIterator); |
623 | return CountObjects(iter); | |
925e6570 | 624 | } |
48b32e42 | 625 | |
e8636ba0 | 626 | //_____________________________________________________________________________ |
627 | AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t index) | |
48b32e42 | 628 | { |
e8636ba0 | 629 | /// Returns a pointer to the index'th local trigger object. |
630 | /// @param index The index number of the local trigger object to fetch in the range [0 .. N-1], | |
631 | /// where N = NumberOfLocalTriggers() | |
a202c2d2 | 632 | |
e8636ba0 | 633 | TIterator* iter = GetIterator(kLocalTriggerIterator); |
634 | return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) ); | |
925e6570 | 635 | } |
48b32e42 | 636 | |
e8636ba0 | 637 | //_____________________________________________________________________________ |
638 | Int_t AliMUONDataInterface::NumberOfRegionalTriggers() | |
48b32e42 | 639 | { |
e8636ba0 | 640 | /// Returns the number of regional trigger objects reconstructed. |
a202c2d2 | 641 | |
e8636ba0 | 642 | TIterator* iter = GetIterator(kRegionalTriggerIterator); |
643 | return CountObjects(iter); | |
925e6570 | 644 | } |
48b32e42 | 645 | |
e8636ba0 | 646 | //_____________________________________________________________________________ |
647 | AliMUONRegionalTrigger* AliMUONDataInterface::RegionalTrigger(Int_t index) | |
48b32e42 | 648 | { |
e8636ba0 | 649 | /// Returns a pointer to the index'th regional trigger object. |
650 | /// @param index The index number of the regional trigger object to fetch in the range [0 .. N-1], | |
651 | /// where N = NumberOfRegionalTriggers() | |
a202c2d2 | 652 | |
e8636ba0 | 653 | TIterator* iter = GetIterator(kRegionalTriggerIterator); |
654 | return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) ); | |
925e6570 | 655 | } |
48b32e42 | 656 | |
e8636ba0 | 657 | //_____________________________________________________________________________ |
658 | AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger() | |
48b32e42 | 659 | { |
e8636ba0 | 660 | /// Returns a pointer to the reconstructed global trigger object for the event. |
a202c2d2 | 661 | |
e8636ba0 | 662 | AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent); |
663 | if (store == 0x0) return 0x0; | |
664 | return store->Global(); | |
925e6570 | 665 | } |
48b32e42 | 666 | |
e8636ba0 | 667 | //_____________________________________________________________________________ |
668 | void AliMUONDataInterface::ResetStores() | |
48b32e42 | 669 | { |
e8636ba0 | 670 | /// Deletes all the store objects that have been created and resets the pointers to 0x0. |
671 | /// The temporary iterator object is automatically reset. See ResetIterator for more details. | |
a202c2d2 | 672 | |
e8636ba0 | 673 | ResetIterator(); |
674 | if (fDigitStore != 0x0) | |
675 | { | |
676 | delete fDigitStore; | |
677 | fDigitStore = 0x0; | |
678 | } | |
679 | if (fTriggerStore != 0x0) | |
680 | { | |
681 | delete fTriggerStore; | |
682 | fTriggerStore = 0x0; | |
683 | } | |
684 | if (fClusterStore != 0x0) | |
685 | { | |
686 | delete fClusterStore; | |
687 | fClusterStore = 0x0; | |
688 | } | |
925e6570 | 689 | } |
554b38a6 | 690 | |
e8636ba0 | 691 | //_____________________________________________________________________________ |
692 | TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y) | |
554b38a6 | 693 | { |
e8636ba0 | 694 | /// Creates an appropriate iterator object and returns it. |
695 | /// If the iterator has already been created then that one is returned otherwise | |
696 | /// a new object is created. | |
697 | /// Depending on the value of 'type' the semantics of parameters x and y can change. | |
698 | /// @param type The type of iterator to create. | |
699 | /// @param x This is the detector element ID if type == kDigitIteratorByDetectorElement | |
700 | /// If type equals kDigitIteratorByChamberAndCathode or kRawClusterIterator | |
701 | /// then this is the chamber number. In all other cases this parameter is | |
702 | /// ignored. | |
703 | /// @param y If type == kDigitIteratorByChamberAndCathode then this parameter is the | |
704 | /// cathode number. In all other cases this parameter is | |
705 | /// ignored. | |
706 | ||
707 | if (type == fCurrentIteratorType and fDataX == x and fDataY == y) | |
708 | return fIterator; | |
709 | ||
710 | if (fCurrentEvent == -1) | |
711 | { | |
712 | AliError("No event was selected. Try first using GetEvent()."); | |
713 | return 0x0; | |
714 | } | |
715 | ||
716 | ResetIterator(); | |
717 | ||
718 | switch (type) | |
719 | { | |
720 | case kDigitIteratorByDetectorElement: | |
721 | { | |
722 | Int_t detElem = x; | |
723 | AliMUONVDigitStore* store = DigitStore(fCurrentEvent); | |
724 | if (store == 0x0) return 0x0; | |
e8636ba0 | 725 | fIterator = store->CreateIterator(detElem, detElem, 2); |
726 | if (fIterator == 0x0) return 0x0; | |
727 | fCurrentIteratorType = kDigitIteratorByDetectorElement; | |
728 | fDataX = detElem; | |
729 | return fIterator; | |
730 | } | |
731 | ||
732 | case kDigitIteratorByChamberAndCathode: | |
733 | { | |
734 | Int_t chamber = x; | |
735 | Int_t cathode = y; | |
736 | if (chamber < 0 or AliMpConstants::NofChambers() <= chamber) | |
737 | { | |
738 | AliError(Form( | |
739 | "Must have give a chamber value in the range [0..%d], but got a value of: %d", | |
740 | AliMpConstants::NofChambers() - 1, | |
741 | chamber | |
742 | )); | |
743 | return 0x0; | |
744 | } | |
745 | if (cathode < 0 or 1 < cathode) | |
746 | { | |
747 | AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode)); | |
748 | return 0x0; | |
749 | } | |
750 | ||
751 | AliMUONVDigitStore* store = DigitStore(fCurrentEvent); | |
752 | if (store == 0x0) return 0x0; | |
e8636ba0 | 753 | AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber); |
754 | fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode); | |
755 | if (fIterator == 0x0) return 0x0; | |
756 | fCurrentIteratorType = kDigitIteratorByChamberAndCathode; | |
757 | fDataX = chamber; | |
758 | fDataY = cathode; | |
759 | return fIterator; | |
760 | } | |
761 | ||
762 | case kRawClusterIterator: | |
763 | { | |
764 | Int_t chamber = x; | |
765 | AliMUONVClusterStore* store = ClusterStore(fCurrentEvent); | |
766 | if (store == 0x0) return 0x0; | |
767 | fIterator = store->CreateChamberIterator(chamber, chamber); | |
768 | if (fIterator == 0x0) return 0x0; | |
769 | fCurrentIteratorType = kRawClusterIterator; | |
770 | fDataX = chamber; | |
771 | return fIterator; | |
772 | } | |
773 | ||
e8636ba0 | 774 | case kLocalTriggerIterator: |
775 | { | |
776 | AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent); | |
777 | if (store == 0x0) return 0x0; | |
778 | fIterator = store->CreateLocalIterator(); | |
779 | if (fIterator == 0x0) return 0x0; | |
780 | fCurrentIteratorType = kLocalTriggerIterator; | |
781 | return fIterator; | |
782 | } | |
783 | ||
784 | case kRegionalTriggerIterator: | |
785 | { | |
786 | AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent); | |
787 | if (store == 0x0) return 0x0; | |
788 | fIterator = store->CreateRegionalIterator(); | |
789 | if (fIterator == 0x0) return 0x0; | |
790 | fCurrentIteratorType = kRegionalTriggerIterator; | |
791 | return fIterator; | |
792 | } | |
793 | ||
e8636ba0 | 794 | default: |
795 | return 0x0; | |
796 | } | |
554b38a6 | 797 | } |
798 | ||
e8636ba0 | 799 | //_____________________________________________________________________________ |
800 | void AliMUONDataInterface::ResetIterator() | |
554b38a6 | 801 | { |
e8636ba0 | 802 | /// The temporary iterator object is deleted if it exists and the pointer reset to 0x0. |
803 | /// The iterator type and temporary data indicating the state of the iterator are | |
804 | /// also reset. | |
805 | ||
806 | if (fIterator != 0x0) delete fIterator; | |
807 | fCurrentIteratorType = kNoIterator; | |
808 | fCurrentIndex = fDataX = fDataY = -1; | |
809 | fIterator = 0x0; | |
554b38a6 | 810 | } |
811 | ||
e8636ba0 | 812 | //_____________________________________________________________________________ |
813 | Int_t AliMUONDataInterface::CountObjects(TIterator* iter) | |
554b38a6 | 814 | { |
e8636ba0 | 815 | /// Counts the number of objects in the iterator and resets it. |
816 | /// @return The number of objects in 'iter'. | |
817 | ||
818 | if (iter == 0x0) return -1; | |
819 | Int_t count = 0; | |
820 | iter->Reset(); | |
821 | while ( iter->Next() != 0x0 ) count++; | |
822 | iter->Reset(); | |
823 | fCurrentIndex = -1; | |
824 | return count; | |
554b38a6 | 825 | } |
826 | ||
e8636ba0 | 827 | //_____________________________________________________________________________ |
828 | TObject* AliMUONDataInterface::FetchObject(TIterator* iter, Int_t index) | |
554b38a6 | 829 | { |
e8636ba0 | 830 | /// Fetches the index'th object from the iterator counting the first object |
831 | /// returned by iterator after it is reset as index == 0. The next object | |
832 | /// has index == 1 and so on where the last object returned by the iterator | |
833 | /// has index == N-1 where N = CountObjects(iter) | |
834 | /// This method will only reset the iterator if index is smaller than | |
835 | /// fCurrentIndex, which is used to track the iteration progress and is | |
836 | /// updated when a new object if returned by this method. | |
837 | /// @param iter The iterator to fetch an object from. | |
838 | /// @param index The index number of the object to fetch in the range [0 .. N-1] | |
839 | /// where N = CountObjects(iter) | |
840 | ||
841 | if (index < 0) | |
842 | { | |
843 | AliError(Form("Index is out of bounds. Got a value of %d.", index)); | |
844 | return 0x0; | |
845 | } | |
a202c2d2 | 846 | |
e8636ba0 | 847 | if (iter == 0x0) return 0x0; |
848 | if (index <= fCurrentIndex) | |
849 | { | |
850 | iter->Reset(); | |
851 | fCurrentIndex = -1; | |
852 | } | |
853 | ||
854 | TObject* object = 0x0; | |
855 | while (fCurrentIndex < index) | |
856 | { | |
857 | object = iter->Next(); | |
858 | if (object == 0x0) | |
859 | { | |
860 | AliError(Form("Index is out of bounds. Got a value of %d.", index)); | |
861 | iter->Reset(); | |
862 | fCurrentIndex = -1; | |
863 | return 0x0; | |
864 | } | |
865 | fCurrentIndex++; | |
866 | } | |
867 | return object; | |
554b38a6 | 868 | } |