]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDataInterface.cxx
Managed the 234 local boards inside the class & simplified the code
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.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$ */
17
18 #include <TError.h>
19 #include <TParticle.h>
20
21 #include "AliRunLoader.h"
22 #include "AliLoader.h"
23
24 #include "AliMUONDataInterface.h"
25 #include "AliMUONLocalTrigger.h"
26 #include "AliMUONGlobalTrigger.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONDigit.h"
29 #include "AliMUONRawCluster.h"
30 #include "AliMUONTrack.h"
31 #include "AliLog.h"
32
33 #include <Riostream.h>
34
35 #include "AliMUONVDigitStore.h"
36 #include "AliMUONVTriggerStore.h"
37 #include "AliMUONVClusterStore.h"
38 #include "AliMUONVTrackStore.h"
39 #include "AliMUONVTriggerTrackStore.h"
40 #include "AliMUONDataManager.h"
41 #include "AliLog.h"
42 #include <TList.h>
43
44 ///
45 /// \class AliMUONDataInterface
46 ///
47 /// An easy to use interface to the MUON data data stored in
48 /// TreeS, TreeD, TreeR and TreeT.
49 ///
50 /// For MC related information (i.e. TreeH, TreeK, TreeTR), see
51 /// AliMUONMCDataInterface.
52 ///
53 ///
54 /// This interface in not necessarily the fastest way to fetch the data but
55 /// it is the easiest.
56 ///
57 /// \author Laurent Aphecetche, Subatech
58
59 /// \cond CLASSIMP
60 ClassImp(AliMUONDataInterface)
61 /// \endcond
62
63 //______________________________________________________________________________
64 AliMUONDataInterface::AliMUONDataInterface(const char* filename)
65         : TObject(), 
66 fDataManager(new AliMUONDataManager(filename))
67 {
68   /// ctor
69   /// @param filename should be the full path to a valid galice.root file
70   
71   if (!IsValid())
72   {
73     AliError("Improper initialization. Object will be unuseable");
74   }
75 }
76
77 //______________________________________________________________________________
78 AliMUONDataInterface::~AliMUONDataInterface()
79 {
80   /// dtor
81   delete fDataManager;
82 }
83
84 //______________________________________________________________________________
85 AliMUONVClusterStore*
86 AliMUONDataInterface::ClusterStore(Int_t event) const
87 {
88   /// Return the cluster store for a given event
89   if (!IsValid()) return 0x0;
90   return dynamic_cast<AliMUONVClusterStore*>(fDataManager->ReadConnectable(event,"R","Cluster"));
91
92 }
93
94 //______________________________________________________________________________
95 void
96 AliMUONDataInterface::DumpRecPoints(Int_t event, Bool_t sorted) const
97 {
98   /// Dump the recpoints for a given event, sorted if so required
99   DumpIt("R","Cluster",event,sorted);
100 }
101
102 //______________________________________________________________________________
103 AliMUONVDigitStore*
104 AliMUONDataInterface::DigitStore(Int_t event) const
105 {
106   /// Return the digit store for a given event
107   if (!IsValid()) return 0x0;
108   return dynamic_cast<AliMUONVDigitStore*>(fDataManager->ReadConnectable(event,"D","Digit"));
109 }
110
111 //______________________________________________________________________________
112 TList* 
113 AliMUONDataInterface::DigitStoreAsList(Int_t event) const
114 {
115   /// Return the digitStore as a TList
116   AliMUONVDigitStore* digitStore = DigitStore(event);
117   
118   TIter next(digitStore->CreateIterator());
119
120   TList* list = new TList;
121   list->SetOwner(kTRUE);
122   TObject* object;
123   
124   while ( ( object = next() ) ) 
125   {
126     list->Add(object->Clone());
127   }
128   
129   delete digitStore;
130   return list;
131 }
132
133 //______________________________________________________________________________
134 void
135 AliMUONDataInterface::DumpIt(const char* treeLetter, const char* what, 
136                              Int_t event, Bool_t sorted) const
137 {
138   /// Generic dump method used by the other DumpXXX methods
139   AliMUONVStore* store = fDataManager->ReadConnectable(event,treeLetter,what);
140   if (!store)
141   {
142     AliError(Form("Could not read %s from tree%s",what,treeLetter));
143     return;
144   }
145   
146   if ( sorted ) 
147   {
148     TList list;
149     list.SetOwner(kFALSE);
150     TIter next(store->CreateIterator());
151     TObject* object;
152   
153     while ( ( object = next() ) ) 
154     {
155       list.Add(object);
156     }
157
158     list.Sort();
159   
160     list.Print();
161   }
162   else
163   {
164     store->Print();
165   }
166   
167   delete store;
168 }
169
170 //______________________________________________________________________________
171 void
172 AliMUONDataInterface::DumpDigits(Int_t event, Bool_t sorted) const
173 {
174   /// Dump digits of a given event, sorted if so required
175   DumpIt("D","Digit",event,sorted);
176 }
177
178 //______________________________________________________________________________
179 Bool_t
180 AliMUONDataInterface::IsValid() const
181 {
182   /// Whether we were properly initialized from a valid galice.root file
183   return fDataManager->IsValid();
184 }
185
186 //______________________________________________________________________________
187 Int_t
188 AliMUONDataInterface::NumberOfEvents() const
189 {
190   /// Number of events in the current galice.root file we're attached to 
191   if (!IsValid()) return 0;
192   return fDataManager->NumberOfEvents();
193 }
194
195 //______________________________________________________________________________
196 AliMUONVDigitStore*
197 AliMUONDataInterface::SDigitStore(Int_t event) const
198 {
199   /// Return the SDigit store for a given event
200   if (!IsValid()) return 0x0;
201   return dynamic_cast<AliMUONVDigitStore*>(fDataManager->ReadConnectable(event,"S","SDigit"));
202 }
203
204 //______________________________________________________________________________
205 void
206 AliMUONDataInterface::DumpSDigits(Int_t event, Bool_t sorted) const
207 {
208   /// Dump sdigits for a given event, sorted if so required
209   DumpIt("S","Digit",event,sorted);
210 }
211
212
213 //______________________________________________________________________________
214 AliMUONVTrackStore* 
215 AliMUONDataInterface::TrackStore(Int_t event) const
216 {
217   /// Return the track store for a given event
218   if (!IsValid()) return 0x0;
219   return dynamic_cast<AliMUONVTrackStore*>(fDataManager->ReadConnectable(event,"T","Track"));
220 }
221
222 //______________________________________________________________________________
223 void
224 AliMUONDataInterface::DumpTracks(Int_t event, Bool_t sorted) const
225 {
226   /// Dump tracks for a given event, sorted if so required
227   DumpIt("T","Track",event,sorted);
228 }
229
230 //______________________________________________________________________________
231 AliMUONVTriggerStore* 
232 AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter) const
233 {
234   /// Return the trigger store for a given event, from a given tree (D or R)
235   if (!IsValid()) return 0x0;
236   return dynamic_cast<AliMUONVTriggerStore*>(fDataManager->ReadConnectable(event,treeLetter,"Trigger"));  
237 }
238
239 //______________________________________________________________________________
240 void
241 AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter) const
242 {
243   /// Dump trigger for a given event, from a given tree, sorted if possible
244   DumpIt(treeLetter,"Trigger",event,kFALSE);
245 }
246
247 //______________________________________________________________________________
248 AliMUONVTriggerTrackStore* 
249 AliMUONDataInterface::TriggerTrackStore(Int_t event) const
250 {
251   /// Return trigger track store for a given event
252   if (!IsValid()) return 0x0;
253   return dynamic_cast<AliMUONVTriggerTrackStore*>(fDataManager->ReadConnectable(event,"T","TriggerTrack"));  
254 }
255
256 //______________________________________________________________________________
257 void
258 AliMUONDataInterface::DumpTriggerTracks(Int_t event, Bool_t sorted) const
259 {
260   /// Dump trigger tracks for a given event
261   DumpIt("T","Trigger",event,sorted);
262 }
263
264 //______________________________________________________________________________
265 //______________________________________________________________________________
266 //______________________________________________________________________________
267 //______________________________________________________________________________
268
269 void AliMUONDataInterface::Reset()
270 {
271 /// \deprecated Method is going to be removed
272
273   AliFatal("Deprecated");
274 }
275
276 Bool_t AliMUONDataInterface::UseCurrentRunLoader()
277 {
278 /// \deprecated Method is going to be removed
279
280   AliFatal("Deprecated");
281   return kFALSE;
282 }
283   
284 Int_t AliMUONDataInterface::NumberOfEvents(TString , TString )
285 {
286 /// \deprecated Method is going to be removed
287
288   AliFatal("Deprecated");
289   return 0;
290 }
291
292
293 Int_t AliMUONDataInterface::NumberOfParticles(TString , TString , Int_t )
294 {
295 /// \deprecated Method is going to be removed
296
297   AliFatal("Deprecated");
298   return 0;
299 }
300
301
302 TParticle* AliMUONDataInterface::Particle(
303                 TString , TString , Int_t , Int_t 
304         )
305 {
306 /// \deprecated Method is going to be removed
307
308   AliFatal("Deprecated");
309   return 0;
310 }
311
312
313 Int_t AliMUONDataInterface::NumberOfTracks(TString , TString , Int_t )
314 {
315 /// \deprecated Method is going to be removed
316
317   AliFatal("Deprecated");
318   return 0;
319 }
320
321
322 Int_t AliMUONDataInterface::NumberOfHits(
323                 TString , TString , Int_t , Int_t 
324         )
325 {
326 /// \deprecated Method is going to be removed
327
328   AliFatal("Deprecated");
329   return 0;
330 }
331
332
333 AliMUONHit* AliMUONDataInterface::Hit(
334                 TString , TString , Int_t ,
335                 Int_t , Int_t 
336         )
337 {
338 /// \deprecated Method is going to be removed
339
340   AliFatal("Deprecated");
341   return 0;
342 }
343
344
345 Int_t AliMUONDataInterface::NumberOfSDigits(
346                 TString , TString , Int_t ,
347                 Int_t , Int_t 
348         )
349 {
350 /// \deprecated Method is going to be removed
351
352   AliFatal("Deprecated");
353   return 0;
354 }
355
356
357 AliMUONDigit* AliMUONDataInterface::SDigit(
358                 TString , TString , Int_t ,
359                 Int_t , Int_t , Int_t 
360         )
361 {
362 /// \deprecated Method is going to be removed
363
364   AliFatal("Deprecated");
365   return 0;
366 }
367
368
369 Int_t AliMUONDataInterface::NumberOfDigits(
370                 TString , TString , Int_t ,
371                 Int_t , Int_t 
372         )
373 {
374 /// \deprecated Method is going to be removed
375
376   AliFatal("Deprecated");
377   return 0;
378 }
379
380
381 AliMUONDigit* AliMUONDataInterface::Digit(
382                 TString , TString , Int_t ,
383                 Int_t , Int_t , Int_t 
384         )
385 {
386 /// \deprecated Method is going to be removed
387
388   AliFatal("Deprecated");
389   return 0;
390 }
391
392
393 Int_t AliMUONDataInterface::NumberOfRawClusters(
394                 TString , TString , Int_t , Int_t 
395         )
396 {
397 /// \deprecated Method is going to be removed
398
399   AliFatal("Deprecated");
400   return 0;
401 }
402
403
404 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
405                 TString , TString , Int_t ,
406                 Int_t , Int_t 
407         )
408 {
409 /// \deprecated Method is going to be removed
410
411   AliFatal("Deprecated");
412   return 0;
413 }
414
415
416 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString , TString , Int_t )
417 {
418 /// \deprecated Method is going to be removed
419
420   AliFatal("Deprecated");
421   return 0;
422 }
423
424
425 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
426                 TString , TString , Int_t , Int_t 
427         )
428 {
429 /// \deprecated Method is going to be removed
430
431   AliFatal("Deprecated");
432   return 0;
433 }
434
435 Bool_t AliMUONDataInterface::SetFile(TString , TString )
436 {
437 /// \deprecated Method is going to be removed
438
439   AliFatal("Deprecated");
440   return 0;
441 }
442
443
444 Bool_t AliMUONDataInterface::GetEvent(Int_t )
445 {
446 /// \deprecated Method is going to be removed
447
448   AliFatal("Deprecated");
449   return 0;
450 }
451
452 Int_t AliMUONDataInterface::NumberOfParticles()
453 {
454 /// \deprecated Method is going to be removed
455
456   AliFatal("Deprecated");
457   return 0;
458 }
459
460
461 TParticle* AliMUONDataInterface::Particle(Int_t )
462 {
463 /// \deprecated Method is going to be removed
464
465   AliFatal("Deprecated");
466   return 0;
467 }
468
469
470 Int_t AliMUONDataInterface::NumberOfTracks()
471 {
472 /// \deprecated Method is going to be removed
473
474   AliFatal("Deprecated");
475   return 0;
476 }
477
478
479 Int_t AliMUONDataInterface::NumberOfHits(Int_t )
480 {
481 /// \deprecated Method is going to be removed
482
483   AliFatal("Deprecated");
484   return 0;
485 }
486
487
488 AliMUONHit* 
489 AliMUONDataInterface::Hit(Int_t , Int_t )
490 {
491 /// \deprecated Method is going to be removed
492
493   AliFatal("Deprecated");
494   return 0;
495 }
496
497
498 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t , Int_t )
499 {
500 /// \deprecated Method is going to be removed
501
502   AliFatal("Deprecated");
503   return 0;
504 }
505
506
507 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t , Int_t , Int_t )
508 {
509 /// \deprecated Method is going to be removed
510
511   AliFatal("Deprecated");
512   return 0;
513
514 }
515
516
517 Int_t AliMUONDataInterface::NumberOfDigits(Int_t , Int_t )
518 {
519 /// \deprecated Method is going to be removed
520
521   AliFatal("Deprecated");
522   return 0;
523
524 }
525
526
527 AliMUONDigit* AliMUONDataInterface::Digit(Int_t , Int_t , Int_t )
528 {
529 /// \deprecated Method is going to be removed
530
531   AliFatal("Deprecated");
532   return 0;
533 }
534
535
536 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t )
537 {
538 /// \deprecated Method is going to be removed
539
540   AliFatal("Deprecated");
541   return 0;
542 }
543
544
545 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t , Int_t )
546 {
547 /// \deprecated Method is going to be removed
548
549   AliFatal("Deprecated");
550   return 0;
551 }
552
553
554 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
555 {
556 /// \deprecated Method is going to be removed
557
558   AliFatal("Deprecated");
559   return 0;
560 }
561
562
563 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t )
564 {
565 /// \deprecated Method is going to be removed
566
567   AliFatal("Deprecated");
568   return 0;
569 }
570
571 Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
572 {
573 /// \deprecated Method is going to be removed
574
575   AliFatal("Deprecated");
576   return 0;
577 }
578
579 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t )
580 {
581 /// \deprecated Method is going to be removed
582
583   AliFatal("Deprecated");
584   return 0;
585 }
586
587 Int_t AliMUONDataInterface::NumberOfRecTracks()
588 {
589 /// \deprecated Method is going to be removed
590
591   AliFatal("Deprecated");
592   return 0;
593 }
594
595 AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t )
596 {
597 /// \deprecated Method is going to be removed
598
599   AliFatal("Deprecated");
600   return 0;
601 }