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