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"
35 #include <Riostream.h>
37 ///\class AliMUONTrackerRawDataMaker
39 /// Creator of AliMUONVTrackerData from AliRawReader
41 ///\author Laurent Aphecetche, Subatech
44 ClassImp(AliMUONTrackerRawDataMaker)
47 Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
49 //_____________________________________________________________________________
50 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
52 : AliMUONVTrackerDataMaker(),
54 fAccumulatedData(0x0),
55 fOneEventData(new AliMUON2DMap(true)),
57 fSource("unspecified"),
60 fDigitCalibrator(0x0),
61 fCalibrationData(0x0),
67 reader->NextEvent(); // to be sure to get run number available
69 Int_t runNumber = reader->GetRunNumber();
73 Bool_t calibrate = ( fCDBPath.Length() > 0 );
79 name = Form("%s(%d)",(calibrate ? "CAL" : "RAW"),fgkCounter);
83 name = Form("%s%d",(calibrate ? "CAL" : "RAW"),runNumber);
86 fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
87 fAccumulatedData->SetDimensionName(0,(calibrate ? "Calibrated charge" : "Raw charge"));
89 reader->RewindEvents();
91 fDigitMaker = new AliMUONDigitMaker;
92 fDigitMaker->SetMakeTriggerDigits(kFALSE);
93 fDigitStore = new AliMUONDigitStoreV2R;
97 fCalibrationData = new AliMUONCalibrationData(runNumber);
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
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).
106 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
108 if ( storage->GetURI() != fCDBPath.Data() )
110 AliCDBManager::Instance()->SetDefaultStorage(fCDBPath.Data());
113 fCalibrationData->Pedestals();
114 fCalibrationData->Gains();
115 fCalibrationData->Neighbours();
116 fCalibrationData->HV();
118 if ( storage->GetURI() != fCDBPath.Data() )
120 AliCDBManager::Instance()->SetDefaultStorage(storage);
123 fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
127 //_____________________________________________________________________________
128 AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
131 delete fOneEventData;
132 if ( fIsOwner ) delete fAccumulatedData;
135 delete fCalibrationData;
137 delete fDigitCalibrator;
140 //_____________________________________________________________________________
142 AliMUONTrackerRawDataMaker::NextEvent()
146 static Int_t nphysics(0);
147 static Int_t ngood(0);
149 if ( !IsRunning() ) return kTRUE;
151 Bool_t ok = fRawReader->NextEvent();
155 fDigitMaker->Print();
159 Int_t eventType = fRawReader->GetType();
163 if (eventType != AliRawEventHeaderBase::kPhysicsEvent )
165 return kTRUE; // for the moment
170 Int_t rv = fDigitMaker->Raw2Digits(fRawReader,fDigitStore);
172 if ( ( rv & AliMUONDigitMaker::kTrackerBAD ) != 0 ) return kTRUE;
174 if ( fDigitCalibrator )
176 fDigitCalibrator->Calibrate(*fDigitStore);
179 Bool_t dok = ConvertDigits();
184 fAccumulatedData->Add(*fOneEventData);
187 AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
192 //_____________________________________________________________________________
194 AliMUONTrackerRawDataMaker::ConvertDigits()
196 /// Convert digitstore into fOneEventData
198 TIter next(fDigitStore->CreateIterator());
199 AliMUONVDigit* digit;
201 fOneEventData->Clear();
203 while ( ( digit = static_cast<AliMUONVDigit*>(next())) )
205 Double_t value = ( digit->IsCalibrated() ? digit->Charge() : digit->ADC() );
209 Int_t detElemId = digit->DetElemId();
210 Int_t manuId = digit->ManuId();
212 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId));
215 param = new AliMUONCalibParamND(1,64,detElemId,manuId,
216 AliMUONVCalibParam::InvalidFloatValue());
217 fOneEventData->Add(param);
220 param->SetValueAsDouble(digit->ManuChannel(),0,value);
227 //_____________________________________________________________________________
229 AliMUONTrackerRawDataMaker::Print(Option_t*) const
233 cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
238 //_____________________________________________________________________________
240 AliMUONTrackerRawDataMaker::Rewind()
243 fRawReader->RewindEvents();