]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitStoreV1Iterator.cxx
AliMUONDigitCalibrator
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitStoreV1Iterator.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 //-----------------------------------------------------------------------------
19 /// \class AliMUONDigitStoreV1Iterator
20 ///
21 /// Implementation of TIteraor for AliMUONVDigitStoreV1
22 /// Reuses the AliMUONTOTCAStoreIterator iterator
23 ///
24 /// \author Laurent Aphecetche, Subatech
25 //-----------------------------------------------------------------------------
26
27 #include "AliMUONDigitStoreV1Iterator.h"
28
29 #include "AliMpDEManager.h"
30 #include "AliMUONVDigit.h"
31 #include "TObjArray.h"
32
33 /// \cond CLASSIMP
34 ClassImp(AliMUONDigitStoreV1Iterator)
35 /// \endcond
36
37 //_____________________________________________________________________________
38 AliMUONDigitStoreV1Iterator::AliMUONDigitStoreV1Iterator(TObjArray* a,
39                                                          Int_t firstDetElemId,
40                                                          Int_t lastDetElemId,
41                                                          Int_t cathode)
42 : AliMUONTOTCAStoreIterator(a,AliMpDEManager::GetChamberId(firstDetElemId),
43                             AliMpDEManager::GetChamberId(lastDetElemId)),
44 fArray(a),
45 fFirstDetElemId(firstDetElemId),
46 fLastDetElemId(lastDetElemId),
47 fCathode(cathode)
48 {
49   /// ctor
50 }
51
52 //_____________________________________________________________________________
53 AliMUONDigitStoreV1Iterator::AliMUONDigitStoreV1Iterator(const AliMUONDigitStoreV1Iterator& rhs)
54 : AliMUONTOTCAStoreIterator(rhs),
55   fArray(rhs.fArray),
56   fFirstDetElemId(rhs.fFirstDetElemId),
57   fLastDetElemId(rhs.fLastDetElemId),
58   fCathode(rhs.fCathode)
59 {
60     /// copy ctor
61 }
62
63 //_____________________________________________________________________________
64 TIterator& 
65 AliMUONDigitStoreV1Iterator::operator=(const TIterator& rhs)
66 {
67   /// overriden assignment operator (imposed by Root's definition of TIterator ?)
68   if ( this != &rhs && rhs.IsA() == AliMUONDigitStoreV1Iterator::Class()) 
69   {
70     const AliMUONDigitStoreV1Iterator& rhs1 = 
71     static_cast<const AliMUONDigitStoreV1Iterator&>(rhs);
72     
73     fArray = rhs1.fArray;
74     fFirstDetElemId = rhs1.fFirstDetElemId;
75     fLastDetElemId = rhs1.fLastDetElemId;
76     fCathode = rhs1.fCathode;
77   }
78   return *this;
79 }
80
81 //_____________________________________________________________________________
82 AliMUONDigitStoreV1Iterator& 
83 AliMUONDigitStoreV1Iterator::operator=(const AliMUONDigitStoreV1Iterator& rhs)
84 {
85   /// assignement operator
86   if ( this != &rhs ) 
87   {
88     fArray = rhs.fArray;
89     fFirstDetElemId = rhs.fFirstDetElemId;
90     fLastDetElemId = rhs.fLastDetElemId;
91     fCathode = rhs.fCathode;
92   }
93   return *this;
94 }
95
96 //_____________________________________________________________________________
97 AliMUONDigitStoreV1Iterator::~AliMUONDigitStoreV1Iterator()
98 {
99   /// dtor
100 }
101
102 //_____________________________________________________________________________
103 const TCollection* 
104 AliMUONDigitStoreV1Iterator::GetCollection() const
105 {
106   /// Return the TObjArray we're iterating upon
107   return fArray;
108 }
109
110 //_____________________________________________________________________________
111 TObject*
112 AliMUONDigitStoreV1Iterator::Next()
113 {
114   /// Return the next digit (with its DE in [fFirstDetElemId,fLastDetElemId],
115   /// and its cathode == fCathode (or any cathode if fCathode==2)
116   /// in the store.
117   
118   TObject* object = 0x0;
119   
120   while ( (object = static_cast<AliMUONVDigit*>(AliMUONTOTCAStoreIterator::Next()) ) )
121   {  
122     AliMUONVDigit* digit = static_cast<AliMUONVDigit*>(object);
123
124     if ( digit->DetElemId() >= fFirstDetElemId &&
125          digit->DetElemId() <= fLastDetElemId ) 
126     {
127       if ( fCathode == 2 || digit->Cathode() == fCathode ) 
128       {
129         return digit;
130       }
131     }
132   }
133   
134   return 0x0;
135 }