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 "AliMUONTrackerRawDataMaker.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 "AliCDBManager.h"
31 #include "AliCDBStorage.h"
32 #include "AliRawEventHeaderBase.h"
33 #include "AliRawReader.h"
34 #include <Riostream.h>
36 ///\class AliMUONTrackerRawDataMaker
38 /// Creator of AliMUONVTrackerData from AliRawReader
40 ///\author Laurent Aphecetche, Subatech
43 ClassImp(AliMUONTrackerRawDataMaker)
46 Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
48 //_____________________________________________________________________________
49 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
51 : AliMUONVTrackerDataMaker(),
53 fAccumulatedData(0x0),
54 fOneEventData(new AliMUON2DMap(true)),
56 fSource("unspecified"),
59 fDigitCalibrator(0x0),
60 fCalibrationData(0x0),
65 reader->NextEvent(); // to be sure to get run number available
67 Int_t runNumber = reader->GetRunNumber();
71 Bool_t calibrate = ( fCDBPath.Length() > 0 );
77 name = Form("%s(%d)",(calibrate ? "CAL" : "RAW"),fgkCounter);
81 name = Form("%s%d",(calibrate ? "CAL" : "RAW"),runNumber);
84 fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
85 fAccumulatedData->SetDimensionName(0,(calibrate ? "Calibrated charge" : "Raw charge"));
87 reader->RewindEvents();
89 fDigitMaker = new AliMUONDigitMaker;
90 fDigitStore = new AliMUONDigitStoreV2R;
94 fCalibrationData = new AliMUONCalibrationData(runNumber);
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
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).
103 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
105 if ( storage->GetURI() != fCDBPath.Data() )
107 AliCDBManager::Instance()->SetDefaultStorage(fCDBPath.Data());
110 fCalibrationData->Pedestals();
111 fCalibrationData->Gains();
112 fCalibrationData->Neighbours();
113 fCalibrationData->HV();
115 if ( storage->GetURI() != fCDBPath.Data() )
117 AliCDBManager::Instance()->SetDefaultStorage(storage);
120 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
124 //_____________________________________________________________________________
125 AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
128 delete fOneEventData;
129 if ( fIsOwner ) delete fAccumulatedData;
132 delete fCalibrationData;
134 delete fDigitCalibrator;
137 //_____________________________________________________________________________
139 AliMUONTrackerRawDataMaker::NextEvent()
143 if ( !IsRunning() ) return kTRUE;
145 Bool_t ok = fRawReader->NextEvent();
152 Int_t eventType = fRawReader->GetType();
154 if (eventType != AliRawEventHeaderBase::kPhysicsEvent )
156 return kTRUE; // for the moment
159 fDigitMaker->Raw2Digits(fRawReader,fDigitStore);
161 if ( fDigitCalibrator )
163 fDigitCalibrator->Calibrate(*fDigitStore);
168 fAccumulatedData->Add(*fOneEventData);
173 //_____________________________________________________________________________
175 AliMUONTrackerRawDataMaker::ConvertDigits()
177 /// Convert digitstore into fOneEventData
179 TIter next(fDigitStore->CreateIterator());
180 AliMUONVDigit* digit;
182 fOneEventData->Clear();
184 while ( ( digit = static_cast<AliMUONVDigit*>(next())) )
186 Double_t value = ( digit->IsCalibrated() ? digit->Charge() : digit->ADC() );
190 Int_t detElemId = digit->DetElemId();
191 Int_t manuId = digit->ManuId();
193 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId));
196 param = new AliMUONCalibParamND(1,64,detElemId,manuId,
197 AliMUONVCalibParam::InvalidFloatValue());
198 fOneEventData->Add(param);
201 param->SetValueAsDouble(digit->ManuChannel(),0,value);
206 //_____________________________________________________________________________
208 AliMUONTrackerRawDataMaker::Print(Option_t*) const
212 cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
217 //_____________________________________________________________________________
219 AliMUONTrackerRawDataMaker::Rewind()
222 fRawReader->RewindEvents();