1 #include <utl/ErrorLogger.h>
2 #include <utl/UTMPoint.h>
3 #include <fwk/CentralConfig.h>
6 #include <mevt/MEvent.h>
7 #include <mevt/Counter.h>
8 #include <mevt/Module.h>
9 #include <utl/Branch.h>
10 #include <utl/ConfigUtils.h>
16 using namespace MdADCCalibrationAG;
18 namespace MdADCCalibrationAG {
26 LoadConfig(config,
"useOfflineCalibration", fUseOfflineCalibration, 0);
27 LoadConfig(config,
"useOnlineCalibration", fUseOnlineCalibration, 1);
30 if (fUseOfflineCalibration) {
34 const int counterId = det::VManager::FindComponent<unsigned int>(
"counterId", attibutes);
35 const int moduleId = det::VManager::FindComponent<unsigned int>(
"moduleId", attibutes);
36 const int globalModuleId = counterId*1000 + moduleId;
37 const double calibration =
b.Get<
double>();
38 fModuleOfflineCalibrationLG[globalModuleId] = calibration;
44 const int counterId = det::VManager::FindComponent<unsigned int>(
"counterId", attibutes);
45 const int moduleId = det::VManager::FindComponent<unsigned int>(
"moduleId", attibutes);
46 const int globalModuleId = counterId*1000 + moduleId;
47 const double calibration =
b.Get<
double>();
48 fModuleOfflineCalibrationHG[globalModuleId] = calibration;
54 const int counterId = det::VManager::FindComponent<unsigned int>(
"counterId", attibutes);
55 const int moduleId = det::VManager::FindComponent<unsigned int>(
"moduleId", attibutes);
56 const int globalModuleId = counterId*1000 + moduleId;
57 const double resolution =
b.Get<
double>();
58 fModuleOfflineResolutionLG[globalModuleId] = resolution;
64 const int counterId = det::VManager::FindComponent<unsigned int>(
"counterId", attibutes);
65 const int moduleId = det::VManager::FindComponent<unsigned int>(
"moduleId", attibutes);
66 const int globalModuleId = counterId*1000 + moduleId;
67 const double resolution =
b.Get<
double>();
68 fModuleOfflineResolutionHG[globalModuleId] = resolution;
80 WARNING(
"\n+++++++++\nEvent without MEvent: nothing to be done. Skipping to next event.\n++++++++++\n");
85 std::ostringstream os;
92 const int counterId = counter.
GetId();
96 os <<
"Skipping the rejected counter " << counterId <<
" .";
102 os <<
"Processing counter " << counterId;
110 const int moduleId = module.
GetId();
113 os <<
"Processing module " << moduleId;
119 os <<
"Module " << module.
GetId() <<
" of counter " << counterId;
126 LoadModuleCalibration(counter, module);
135 MdADCCalibration::Finish()
145 double calibrationA = 0.0;
146 double calibrationB = 0.0;
147 double resolutionA = 0.0;
148 double resolutionB = 0.0;
151 if(fUseOnlineCalibration)
153 GetOnlineCalibration(calibrationA, resolutionA, calibrationB, resolutionB, module);
156 if (calibrationA == 0.0 && fUseOfflineCalibration)
158 GetOfflineCalibration(calibrationA, resolutionA, calibrationB, resolutionB, counter, module);
172 std::ostringstream os;
174 os <<
"Mean charge muon ADC LG " << calibrationA <<
", StdDev = " << resolutionA
175 <<
"Mean charge muon ADC HG " << calibrationB <<
", StdDev = " << resolutionB;
179 void MdADCCalibration::GetOfflineCalibration(
double& calibrationA,
double& resolutionA,
double& calibrationB,
double& resolutionB,
mevt::Counter& counter,
mevt::Module& module)
181 std::ostringstream os;
182 const int globalModuleId = counter.
GetId()*1000 + module.
GetId();
183 if(fModuleOfflineCalibrationLG.find(globalModuleId) != fModuleOfflineCalibrationLG.end())
185 calibrationA = fModuleOfflineCalibrationLG[globalModuleId];
188 calibrationA = fModuleOfflineCalibrationLG[0];
190 os <<
"Module " << module.
GetId() <<
" of counter " << counter.
GetId();
191 os <<
" uses global calibration";
195 if(fModuleOfflineResolutionLG.find(globalModuleId) != fModuleOfflineResolutionLG.end())
197 resolutionA = fModuleOfflineResolutionLG[globalModuleId];
200 resolutionA = fModuleOfflineResolutionLG[0];
203 if(fModuleOfflineCalibrationHG.find(globalModuleId) != fModuleOfflineCalibrationHG.end())
205 calibrationB = fModuleOfflineCalibrationHG[globalModuleId];
208 calibrationB = fModuleOfflineCalibrationHG[0];
211 if(fModuleOfflineResolutionHG.find(globalModuleId) != fModuleOfflineResolutionHG.end())
213 resolutionB = fModuleOfflineResolutionHG[globalModuleId];
216 resolutionB = fModuleOfflineResolutionHG[0];
220 void MdADCCalibration::GetOnlineCalibration(
double& calibrationA,
double& resolutionA,
double& calibrationB,
double& resolutionB,
mevt::Module& module)
223 if(module.
GetId()>0){
Module level reconstruction data. This class contains all data required by the muon reconstruction...
CounterConstIterator CountersBegin() const
void SetMeanChargeMuonHG(const double charge)
void SetStdDevChargeMuonHG(const double charge)
Counter level event data.
std::map< std::string, std::string > AttributeMap
std::string GetRejectionReason() const
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
bool IsRejected() const
Check if the counter is rejected.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
void SetMeanChargeMuonLG(const double charge)
Class representing a document branch.
void SetStdDevChargeMuonLG(const double charge)
#define DEBUGLOG(message)
Macro for logging debugging messages.
#define WARNING(message)
Macro for logging warning messages.
InternalModuleCollection::ComponentIterator ModuleIterator
ModuleConstIterator ModulesBegin() const
ResultFlag
Flag returned by module methods to the RunController.
int GetId() const
The id of the counter.
ModuleConstIterator ModulesEnd() const
InternalCounterCollection::ComponentIterator CounterIterator
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
ModuleRecData & GetRecData()
void LoadConfig(const utl::Branch &b, const std::string &tag, T1 &var, const T2 &defaultValue)
Helper method to load a particular configuration parameter.
CounterConstIterator CountersEnd() const
Branch GetFirstChild() const
Get first child of this Branch.
Root of the Muon event hierarchy.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)