1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONTrackerCalibratedDataMaker.h"
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"
36 #include <Riostream.h>
38 ///\class AliMUONTrackerCalibratedDataMaker
40 /// Creator of AliMUONVTrackerData from AliRawReader
42 ///\author Laurent Aphecetche, Subatech
45 ClassImp(AliMUONTrackerCalibratedDataMaker)
48 Int_t AliMUONTrackerCalibratedDataMaker::fgkCounter(0);
50 //_____________________________________________________________________________
51 AliMUONTrackerCalibratedDataMaker::AliMUONTrackerCalibratedDataMaker(AliRawReader* reader,
53 const char* calibMode,
57 : AliMUONVTrackerDataMaker(),
59 fAccumulatedData(0x0),
60 fOneEventData(new AliMUON2DMap(true)),
61 fSource("unspecified"),
64 fDigitCalibrator(0x0),
65 fCalibrationData(0x0),
76 reader->NextEvent(); // to be sure to get run number available
77 runNumber = reader->GetRunNumber();
82 Bool_t calibrate = ( fCDBPath.Length() > 0 );
84 TString basename("RAW");
88 TString scalib(calibMode);
90 if ( scalib == "GAIN" ) basename = "CALC";
91 if ( scalib == "NOGAIN" ) basename = "CALZ";
92 if ( scalib == "GAINCONSTANTCAPA" ) basename = "CALG";
97 name = Form("%s%s(%d)",
98 (histogram ? "H" : ""),
104 name = Form("%s%s%d",
105 (histogram ? "H" : ""),
110 fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
111 fAccumulatedData->SetDimensionName(0,(calibrate ? "Calibrated charge" : "Raw charge"));
114 fAccumulatedData->MakeHistogramForDimension(0,kTRUE,xmin,xmax);
115 AliInfo(Form("Will histogram between %e and %e",xmin,xmax));
118 if (fRawReader) fRawReader->RewindEvents();
120 fDigitMaker = new AliMUONDigitMaker;
121 fDigitMaker->SetMakeTriggerDigits(kFALSE);
122 fDigitStore = new AliMUONDigitStoreV2R;
126 fCalibrationData = new AliMUONCalibrationData(runNumber);
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
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).
135 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
137 if ( storage->GetURI() != fCDBPath.Data() )
139 AliCDBManager::Instance()->SetDefaultStorage(fCDBPath.Data());
142 fCalibrationData->Pedestals();
143 fCalibrationData->Gains();
144 fCalibrationData->Neighbours();
145 fCalibrationData->HV();
146 fCalibrationData->Capacitances();
148 if ( storage->GetURI() != fCDBPath.Data() )
150 AliCDBManager::Instance()->SetDefaultStorage(storage);
153 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode);
157 //_____________________________________________________________________________
158 AliMUONTrackerCalibratedDataMaker::~AliMUONTrackerCalibratedDataMaker()
161 delete fOneEventData;
162 delete fAccumulatedData;
165 delete fCalibrationData;
167 delete fDigitCalibrator;
170 //_____________________________________________________________________________
172 AliMUONTrackerCalibratedDataMaker::Merge(TCollection*)
175 AliError("Not implemented yet");
179 //_____________________________________________________________________________
181 AliMUONTrackerCalibratedDataMaker::NextEvent()
185 AliCodeTimerAuto("");
187 static Int_t nphysics(0);
188 static Int_t ngood(0);
190 if ( !IsRunning() ) return kTRUE;
192 Bool_t ok = fRawReader->NextEvent();
196 fDigitMaker->Print();
200 Int_t eventType = fRawReader->GetType();
204 if (eventType != AliRawEventHeaderBase::kPhysicsEvent )
206 return kTRUE; // for the moment
211 Int_t rv = fDigitMaker->Raw2Digits(fRawReader,fDigitStore);
213 if ( ( rv & AliMUONDigitMaker::kTrackerBAD ) != 0 ) return kTRUE;
215 if ( fDigitCalibrator )
217 fDigitCalibrator->Calibrate(*fDigitStore);
220 Bool_t dok = ConvertDigits();
225 fAccumulatedData->Add(*fOneEventData);
228 AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
233 //_____________________________________________________________________________
235 AliMUONTrackerCalibratedDataMaker::ConvertDigits()
237 /// Convert digitstore into fOneEventData
239 AliCodeTimerAuto("");
241 TIter next(fDigitStore->CreateIterator());
242 AliMUONVDigit* digit;
244 fOneEventData->Clear();
246 while ( ( digit = static_cast<AliMUONVDigit*>(next())) )
248 Double_t value = ( digit->IsCalibrated() ? digit->Charge() : digit->ADC() );
252 Int_t detElemId = digit->DetElemId();
253 Int_t manuId = digit->ManuId();
255 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId));
258 param = new AliMUONCalibParamND(1,64,detElemId,manuId,
259 AliMUONVCalibParam::InvalidFloatValue());
260 fOneEventData->Add(param);
263 param->SetValueAsDouble(digit->ManuChannel(),0,value);
270 //_____________________________________________________________________________
272 AliMUONTrackerCalibratedDataMaker::Print(Option_t*) const
276 cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
281 //_____________________________________________________________________________
283 AliMUONTrackerCalibratedDataMaker::Rewind()
286 fRawReader->RewindEvents();