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