]>
Commit | Line | Data |
---|---|---|
0145e89a | 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 "AliMUONTrackerRawDataMaker.h" | |
19 | ||
20 | #include "AliMUON2DMap.h" | |
21 | #include "AliMUONCalibParamND.h" | |
22 | #include "AliMUONCalibrationData.h" | |
23 | #include "AliMUONDigitCalibrator.h" | |
24 | #include "AliMUONDigitMaker.h" | |
25 | #include "AliMUONDigitStoreV2R.h" | |
26 | #include "AliMUONTrackerData.h" | |
27 | #include "AliMUONVDigit.h" | |
28 | #include "AliMUONVDigitStore.h" | |
29 | #include "AliMpDDLStore.h" | |
30 | #include "AliCDBManager.h" | |
31 | #include "AliCDBStorage.h" | |
32 | #include "AliRawEventHeaderBase.h" | |
33 | #include "AliRawReader.h" | |
34 | #include <Riostream.h> | |
35 | ||
36 | ///\class AliMUONTrackerRawDataMaker | |
37 | /// | |
38 | /// Creator of AliMUONVTrackerData from AliRawReader | |
39 | /// | |
40 | ///\author Laurent Aphecetche, Subatech | |
41 | ||
42 | ///\cond CLASSIMP | |
43 | ClassImp(AliMUONTrackerRawDataMaker) | |
44 | ///\endcond | |
45 | ||
46 | Int_t AliMUONTrackerRawDataMaker::fgkCounter(0); | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, | |
50 | const char* cdbpath) | |
51 | : AliMUONVTrackerDataMaker(), | |
52 | fRawReader(reader), | |
53 | fAccumulatedData(0x0), | |
54 | fOneEventData(new AliMUON2DMap(true)), | |
55 | fIsOwner(kTRUE), | |
56 | fSource("unspecified"), | |
57 | fIsRunning(kFALSE), | |
58 | fDigitMaker(0x0), | |
59 | fDigitCalibrator(0x0), | |
60 | fCalibrationData(0x0), | |
61 | fDigitStore(0x0), | |
62 | fCDBPath(cdbpath) | |
63 | { | |
64 | /// Ctor | |
65 | reader->NextEvent(); // to be sure to get run number available | |
66 | ||
67 | Int_t runNumber = reader->GetRunNumber(); | |
68 | ||
69 | ++fgkCounter; | |
70 | ||
71 | Bool_t calibrate = ( fCDBPath.Length() > 0 ); | |
72 | ||
73 | TString name; | |
74 | ||
75 | if (!runNumber) | |
76 | { | |
77 | name = Form("%s(%d)",(calibrate ? "CAL" : "RAW"),fgkCounter); | |
78 | } | |
79 | else | |
80 | { | |
81 | name = Form("%s%d",(calibrate ? "CAL" : "RAW"),runNumber); | |
82 | } | |
83 | ||
84 | fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1); | |
85 | fAccumulatedData->SetDimensionName(0,(calibrate ? "Calibrated charge" : "Raw charge")); | |
86 | ||
87 | reader->RewindEvents(); | |
88 | ||
89 | fDigitMaker = new AliMUONDigitMaker; | |
90 | fDigitStore = new AliMUONDigitStoreV2R; | |
91 | ||
92 | if ( calibrate ) | |
93 | { | |
94 | fCalibrationData = new AliMUONCalibrationData(runNumber); | |
95 | ||
96 | // force the reading of calibration NOW | |
97 | // FIXME: not really elegant and error prone (as we have the list of calib data twice, | |
98 | // once here and once in the digitcalibrator class, hence the change of them getting | |
99 | // out of sync) | |
100 | // But with the current CDBManager implementation, I don't know how to solve | |
101 | // this better (e.g. to avoid clearing cache messages and so on). | |
102 | ||
103 | AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage(); | |
104 | ||
105 | if ( storage->GetURI() != fCDBPath.Data() ) | |
106 | { | |
107 | AliCDBManager::Instance()->SetDefaultStorage(fCDBPath.Data()); | |
108 | } | |
109 | ||
110 | fCalibrationData->Pedestals(); | |
111 | fCalibrationData->Gains(); | |
112 | fCalibrationData->Neighbours(); | |
113 | fCalibrationData->HV(); | |
114 | ||
115 | if ( storage->GetURI() != fCDBPath.Data() ) | |
116 | { | |
117 | AliCDBManager::Instance()->SetDefaultStorage(storage); | |
118 | } | |
119 | ||
120 | fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData); | |
121 | } | |
122 | } | |
123 | ||
124 | //_____________________________________________________________________________ | |
125 | AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker() | |
126 | { | |
127 | /// dtor | |
128 | delete fOneEventData; | |
129 | if ( fIsOwner ) delete fAccumulatedData; | |
130 | delete fRawReader; | |
131 | delete fDigitStore; | |
132 | delete fCalibrationData; | |
133 | delete fDigitMaker; | |
134 | delete fDigitCalibrator; | |
135 | } | |
136 | ||
137 | //_____________________________________________________________________________ | |
138 | Bool_t | |
139 | AliMUONTrackerRawDataMaker::NextEvent() | |
140 | { | |
141 | /// Read next event | |
142 | ||
143 | if ( !IsRunning() ) return kTRUE; | |
144 | ||
145 | Bool_t ok = fRawReader->NextEvent(); | |
146 | ||
147 | if (!ok) | |
148 | { | |
149 | return kFALSE; | |
150 | } | |
151 | ||
152 | Int_t eventType = fRawReader->GetType(); | |
153 | ||
154 | if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) | |
155 | { | |
156 | return kTRUE; // for the moment | |
157 | } | |
158 | ||
159 | fDigitMaker->Raw2Digits(fRawReader,fDigitStore); | |
160 | ||
161 | if ( fDigitCalibrator ) | |
162 | { | |
163 | fDigitCalibrator->Calibrate(*fDigitStore); | |
164 | } | |
165 | ||
166 | ConvertDigits(); | |
167 | ||
168 | fAccumulatedData->Add(*fOneEventData); | |
169 | ||
170 | return kTRUE; | |
171 | } | |
172 | ||
173 | //_____________________________________________________________________________ | |
174 | void | |
175 | AliMUONTrackerRawDataMaker::ConvertDigits() | |
176 | { | |
177 | /// Convert digitstore into fOneEventData | |
178 | ||
179 | TIter next(fDigitStore->CreateIterator()); | |
180 | AliMUONVDigit* digit; | |
181 | ||
182 | fOneEventData->Clear(); | |
183 | ||
184 | while ( ( digit = static_cast<AliMUONVDigit*>(next())) ) | |
185 | { | |
186 | Double_t value = ( digit->IsCalibrated() ? digit->Charge() : digit->ADC() ); | |
187 | ||
188 | if ( value > 0 ) | |
189 | { | |
190 | Int_t detElemId = digit->DetElemId(); | |
191 | Int_t manuId = digit->ManuId(); | |
192 | ||
193 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId)); | |
194 | if (!param) | |
195 | { | |
196 | param = new AliMUONCalibParamND(1,64,detElemId,manuId, | |
197 | AliMUONVCalibParam::InvalidFloatValue()); | |
198 | fOneEventData->Add(param); | |
199 | } | |
200 | ||
201 | param->SetValueAsDouble(digit->ManuChannel(),0,value); | |
202 | } | |
203 | } | |
204 | } | |
205 | ||
206 | //_____________________________________________________________________________ | |
207 | void | |
208 | AliMUONTrackerRawDataMaker::Print(Option_t*) const | |
209 | { | |
210 | /// Printout | |
211 | ||
212 | cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO") | |
213 | << endl; | |
214 | ||
215 | } | |
216 | ||
217 | //_____________________________________________________________________________ | |
218 | void | |
219 | AliMUONTrackerRawDataMaker::Rewind() | |
220 | { | |
221 | /// Rewind events | |
222 | fRawReader->RewindEvents(); | |
223 | } |