29 if (calibConstGranularity ==
"byWire") {
30 theGranularity = byWire;
31 }
else if (calibConstGranularity ==
"byLayer") {
33 }
else if (calibConstGranularity ==
"bySL") {
34 theGranularity = bySL;
36 theGranularity = byChamber;
37 if (!(calibConstGranularity ==
"byChamber")) {
38 cout <<
"[DTCalibrationMap]###Warning: Check parameter calibConstGranularity: " << calibConstGranularity
39 <<
" options not available!" << endl;
42 readConsts(calibConstFileName);
65 if (theGranularity == byChamber) {
67 }
else if (theGranularity == bySL) {
69 }
else if (theGranularity ==
byLayer) {
79 static pair<Key, CalibConsts>
cache;
82 Key theKey = getKey(wireId);
85 if (theKey == cache.first) {
86 return &(cache.second);
90 map<Key, CalibConsts>::const_iterator res = theMap.find(theKey);
91 if (res != theMap.end()) {
93 return &((*res).second);
103 if (cals ==
nullptr) {
104 throw cms::Exception(
"NoCalibConsts") <<
"DTCalibrationMap:" << endl
105 <<
"No parameters for wire: " << wireId << endl
106 <<
"Check the " << calibConstFileName <<
" file!" << endl;
108 return (*(cals))[field];
114 ifstream
file(inputFileName.c_str());
117 cout <<
"[DTCalibrationMap]***Warning: File: " << inputFileName <<
" not found in current directory!!!" << endl;
126 int superlayer_id = 0;
131 while (getline(
file, line)) {
132 if (line.empty() || line[0] ==
'#')
134 stringstream linestr;
137 pair<Key, CalibConsts> wireCalib;
139 linestr >> wheel_id >> station_id >> sector_id >> superlayer_id >> layer_id >> wire_id;
142 wireCalib.first =
Key(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id);
144 if (!checkGranularity(wireCalib.first))
145 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the selected granularity!"
149 copy(istream_iterator<float>(linestr), istream_iterator<float>(), back_inserter(wireCalib.second));
151 if (wireCalib.second.size() < nFields) {
152 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the number of fields!" << endl;
155 theMap.insert(wireCalib);
161 if (!checkGranularity(theKey))
163 <<
"The added key is not compatible with the selected granularity" << endl;
165 theMap[theKey] = calibConst;
170 ofstream
out(outputFileName.c_str());
171 for (map<Key, CalibConsts>::const_iterator iter = theMap.begin(); iter != theMap.end(); ++iter) {
172 out << (*iter).first.wheel() <<
' ' << (*iter).first.station() <<
' ' << (*iter).first.sector() <<
' '
173 << (*iter).first.superlayer() <<
' ' << (*iter).first.layer() <<
' ' << (*iter).first.wire() <<
' ';
174 copy((*iter).second.begin(), (*iter).second.end(), ostream_iterator<float>(
out,
" "));
184 if (theGranularity == byChamber) {
188 }
else if (theGranularity == bySL) {
192 }
else if (theGranularity ==
byLayer) {
196 }
else if (theGranularity == byWire) {
197 if (aKey.
wire() == 0) {
T getUntrackedParameter(std::string const &, T const &) const
tuple ret
prodAgent to be discontinued
Key getKey(DTWireId wireId) const
void writeConsts(const std::string &outputFileName) const
DTCalibrationMap(const edm::ParameterSet &pset)
Constructor.
DTChamberId chamberId() const
Return the corresponding ChamberId.
float kFactor(DTWireId wireId) const
Return the kfactor for a particular wire.
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
float meanVDrift(DTWireId wireId) const
Return the mean drift velocity for a particular wire (cm/ns)
float getField(DTWireId wireId, int field) const
std::vector< float > CalibConsts
bool checkGranularity(Key aKey) const
virtual ~DTCalibrationMap()
Destructor.
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
void addCell(Key wireId, const CalibConsts &calibConst)
float sigma_tTrig(DTWireId wireId) const
Return the sigma of the t_trig (ns) for a particular wire.
float tTrig(DTWireId wireId) const
Return the t_trig (ns) for a particular wire.
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
float sigma_meanVDrift(DTWireId wireId) const
Return the sigma of the mean drift velocity for a particular wire (cm/ns)
const CalibConsts * getConsts(DTWireId wireId) const
DTLayerId layerId() const
Return the corresponding LayerId.
void readConsts(const std::string &inputFileName)