29 if(calibConstGranularity ==
"byWire") {
30 theGranularity = byWire;
31 }
else if(calibConstGranularity ==
"byLayer"){
32 theGranularity = byLayer;
33 }
else if(calibConstGranularity ==
"bySL") {
34 theGranularity = bySL;
36 theGranularity = byChamber;
37 if(!(calibConstGranularity ==
"byChamber")) {
38 cout <<
"[DTCalibrationMap]###Warning: Check parameter calibConstGranularity: " 39 << calibConstGranularity <<
" options not available!" << endl;
42 readConsts(calibConstFileName);
89 if (theGranularity == byChamber){
91 }
else if (theGranularity == bySL) {
93 }
else if (theGranularity == byLayer) {
105 static pair<Key, CalibConsts>
cache;
108 Key theKey = getKey(wireId);
111 if ( theKey == cache.first ) {
112 return &(cache.second);
116 map<Key, CalibConsts>::const_iterator
res = theMap.find(theKey);
117 if (res != theMap.end()) {
119 return &((*res).second);
131 if (cals ==
nullptr) {
132 throw cms::Exception(
"NoCalibConsts") <<
"DTCalibrationMap:" << endl
133 <<
"No parameters for wire: " << wireId << endl
134 <<
"Check the " << calibConstFileName <<
" file!" << endl;
136 return (*(cals))[field];
145 ifstream
file(inputFileName.c_str());
148 cout <<
"[DTCalibrationMap]***Warning: File: " << inputFileName
149 <<
" not found in current directory!!!" << endl;
158 int superlayer_id = 0;
163 while (getline(
file,line)) {
164 if( line ==
"" || line[0] ==
'#' )
continue;
165 stringstream linestr;
168 pair<Key, CalibConsts> wireCalib;
178 wireCalib.first =
Key( wheel_id,
185 if(!checkGranularity(wireCalib.first))
186 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the selected granularity!" << endl;
190 copy(istream_iterator<float>(linestr),
191 istream_iterator<float>(),
192 back_inserter(wireCalib.second));
194 if(wireCalib.second.size() < nFields){
195 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the number of fields!" << endl;
198 theMap.insert(wireCalib);
204 if(!checkGranularity(theKey))
206 <<
"The added key is not compatible with the selected granularity" 209 theMap[theKey] = calibConst;
214 ofstream
out(outputFileName.c_str());
215 for(map<Key,CalibConsts>::const_iterator iter = theMap.begin();
216 iter != theMap.end() ; ++iter) {
218 out << (*iter).first.wheel() <<
' ' 219 << (*iter).first.station() <<
' ' 220 << (*iter).first.sector() <<
' ' 221 << (*iter).first.superlayer() <<
' ' 222 << (*iter).first.layer() <<
' ' 223 << (*iter).first.wire() <<
' ';
224 copy((*iter).second.begin(), (*iter).second.end(),
225 ostream_iterator<float>(
out,
" "));
236 if(theGranularity == byChamber) {
240 }
else if(theGranularity == bySL) {
244 }
else if(theGranularity == byLayer) {
248 }
else if(theGranularity == byWire) {
249 if(aKey.
wire() == 0) {
T getUntrackedParameter(std::string const &, T const &) const
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)