31 if(calibConstGranularity ==
"byWire") {
32 theGranularity = byWire;
33 }
else if(calibConstGranularity ==
"byLayer"){
35 }
else if(calibConstGranularity ==
"bySL") {
36 theGranularity = bySL;
38 theGranularity = byChamber;
39 if(!(calibConstGranularity ==
"byChamber")) {
40 cout <<
"[DTCalibrationMap]###Warning: Check parameter calibConstGranularity: "
41 << calibConstGranularity <<
" options not available!" << endl;
44 readConsts(calibConstFileName);
55 return getField(wireId, 0);
62 return getField(wireId, 1);
69 return getField(wireId, 2);
76 return getField(wireId, 3);
83 return getField(wireId, 4);
91 if (theGranularity == byChamber){
93 }
else if (theGranularity == bySL) {
95 }
else if (theGranularity ==
byLayer) {
107 static pair<Key, CalibConsts> cache;
110 Key theKey = getKey(wireId);
113 if ( theKey == cache.first ) {
114 return &(cache.second);
118 map<Key, CalibConsts>::const_iterator res = theMap.find(theKey);
119 if (res != theMap.end()) {
121 return &((*res).second);
134 throw cms::Exception(
"NoCalibConsts") <<
"DTCalibrationMap:" << endl
135 <<
"No parameters for wire: " << wireId << endl
136 <<
"Check the " << calibConstFileName <<
" file!" << endl;
138 return (*(cals))[field];
147 ifstream
file(inputFileName.c_str());
150 cout <<
"[DTCalibrationMap]***Warning: File: " << inputFileName
151 <<
" not found in current directory!!!" << endl;
160 int superlayer_id = 0;
165 while (getline(
file,line)) {
166 if( line ==
"" || line[0] ==
'#' )
continue;
167 stringstream linestr;
170 pair<Key, CalibConsts> wireCalib;
180 wireCalib.first =
Key( wheel_id,
187 if(!checkGranularity(wireCalib.first))
188 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the selected granularity!" << endl;
192 copy(istream_iterator<float>(linestr),
193 istream_iterator<float>(),
194 back_inserter(wireCalib.second));
196 if(wireCalib.second.size() != nFields){
197 cout <<
"[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the number of fields!" << endl;
200 theMap.insert(wireCalib);
206 if(!checkGranularity(theKey))
208 <<
"The added key is not compatible with the selected granularity"
211 theMap[theKey] = calibConst;
216 ofstream
out(outputFileName.c_str());
217 for(map<Key,CalibConsts>::const_iterator iter = theMap.begin();
218 iter != theMap.end() ; iter++) {
220 out << (*iter).first.wheel() <<
' '
221 << (*iter).first.station() <<
' '
222 << (*iter).first.sector() <<
' '
223 << (*iter).first.superlayer() <<
' '
224 << (*iter).first.layer() <<
' '
225 << (*iter).first.wire() <<
' ';
226 copy((*iter).second.begin(), (*iter).second.end(),
227 ostream_iterator<float>(
out,
" "));
238 if(theGranularity == byChamber) {
242 }
else if(theGranularity == bySL) {
246 }
else if(theGranularity ==
byLayer) {
250 }
else if(theGranularity == byWire) {
251 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.
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)