CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
DTCalibrationMap Class Reference

#include <DTCalibrationMap.h>

Public Types

typedef std::vector< float > CalibConsts
 
typedef std::map< Key, CalibConsts >::const_iterator const_iterator
 
typedef DTWireId Key
 

Public Member Functions

void addCell (Key wireId, const CalibConsts &calibConst)
 
void cleanTheConsts ()
 
 DTCalibrationMap (const edm::ParameterSet &pset)
 Constructor. More...
 
const CalibConstsgetConsts (DTWireId wireId) const
 
float getField (DTWireId wireId, int field) const
 
Key getKey (DTWireId wireId) const
 
const_iterator keyAndConsts_begin () const
 
const_iterator keyAndConsts_end () const
 
float kFactor (DTWireId wireId) const
 Return the kfactor for a particular wire. More...
 
float meanVDrift (DTWireId wireId) const
 Return the mean drift velocity for a particular wire (cm/ns) More...
 
float sigma_meanVDrift (DTWireId wireId) const
 Return the sigma of the mean drift velocity for a particular wire (cm/ns) More...
 
float sigma_tTrig (DTWireId wireId) const
 Return the sigma of the t_trig (ns) for a particular wire. More...
 
float tTrig (DTWireId wireId) const
 Return the t_trig (ns) for a particular wire. More...
 
void writeConsts (const std::string &outputFileName) const
 
virtual ~DTCalibrationMap ()
 Destructor. More...
 

Private Types

enum  CalibGranularity { byChamber, bySL, byLayer, byWire }
 

Private Member Functions

bool checkGranularity (Key aKey) const
 
void readConsts (const std::string &inputFileName)
 

Private Attributes

std::string calibConstFileName
 
std::string calibConstGranularity
 
unsigned int nFields
 
CalibGranularity theGranularity
 
std::map< Key, CalibConststheMap
 

Detailed Description

Allow saving and retrieving of calibration constants to/from txt file. This was originally provided for backward compatibility with the ORCA MuBarDigiParameters file. Can be used to save an arbitrary number of constants with the needed granularity and to retrieve them back using the wireId. Current field allocation: fields for each key are allocated to: –First block: legacy descriptors– [0] ttrig [1] sigma_ttrig (obsolete) [2] kfactor (obsolete) [3] vdrift
[4] sigma_vdrift (obsolete, was formerly hacked to include reoslution) [5] t0 [6] t0rms [7] noisy or dead flag [8-9] left for future usage –Second block (optional): free fields [10] Encoded information of free fields: (1000*version)+(100*type)+(number of fields); type is: ttrig=0, vdrift=1, uncertainties=3 [11-end] free fields

Author
G. Cerminara - INFN Torino

Definition at line 37 of file DTCalibrationMap.h.

Member Typedef Documentation

◆ CalibConsts

typedef std::vector<float> DTCalibrationMap::CalibConsts

Definition at line 62 of file DTCalibrationMap.h.

◆ const_iterator

Definition at line 64 of file DTCalibrationMap.h.

◆ Key

Definition at line 63 of file DTCalibrationMap.h.

Member Enumeration Documentation

◆ CalibGranularity

Enumerator
byChamber 
bySL 
byLayer 
byWire 

Definition at line 93 of file DTCalibrationMap.h.

Constructor & Destructor Documentation

◆ DTCalibrationMap()

DTCalibrationMap::DTCalibrationMap ( const edm::ParameterSet pset)

Constructor.

Definition at line 23 of file DTCalibrationMap.cc.

23  {
24  nFields = pset.getUntrackedParameter<int>("nFields", 5);
25  calibConstFileName = pset.getUntrackedParameter<string>("calibConstFileName", "dummy.txt");
26  calibConstGranularity = pset.getUntrackedParameter<string>("calibConstGranularity", "bySL");
27 
28  // Initialize correctly the enum which specify the granularity for the calibration
29  if (calibConstGranularity == "byWire") {
31  } else if (calibConstGranularity == "byLayer") {
33  } else if (calibConstGranularity == "bySL") {
35  } else {
37  if (!(calibConstGranularity == "byChamber")) {
38  cout << "[DTCalibrationMap]###Warning: Check parameter calibConstGranularity: " << calibConstGranularity
39  << " options not available!" << endl;
40  }
41  }
43 }

References gather_cfg::cout, and muonDTDigis_cfi::pset.

◆ ~DTCalibrationMap()

DTCalibrationMap::~DTCalibrationMap ( )
virtual

Destructor.

Definition at line 45 of file DTCalibrationMap.cc.

45 {}

Member Function Documentation

◆ addCell()

void DTCalibrationMap::addCell ( Key  wireId,
const CalibConsts calibConst 
)

Definition at line 160 of file DTCalibrationMap.cc.

160  {
161  if (!checkGranularity(theKey))
162  throw cms::Exception("addCell") << "DTCalibrationMap:" << endl
163  << "The added key is not compatible with the selected granularity" << endl;
164 
165  theMap[theKey] = calibConst;
166 }

References Exception.

Referenced by DTVDriftCalibration::endJob().

◆ checkGranularity()

bool DTCalibrationMap::checkGranularity ( Key  aKey) const
private

Definition at line 180 of file DTCalibrationMap.cc.

180  {
181  bool ret = true;
182 
183  // Check that the key is consistent with the given granularity
184  if (theGranularity == byChamber) {
185  if (aKey.superlayer() || aKey.layer() || aKey.wire()) {
186  ret = false;
187  }
188  } else if (theGranularity == bySL) {
189  if (aKey.layer() || aKey.wire()) {
190  ret = false;
191  }
192  } else if (theGranularity == byLayer) {
193  if (aKey.wire()) {
194  ret = false;
195  }
196  } else if (theGranularity == byWire) {
197  if (aKey.wire() == 0) {
198  ret = false;
199  }
200  }
201  return ret;
202 }

References DTLayerId::layer(), runTheMatrix::ret, DTSuperLayerId::superlayer(), and DTWireId::wire().

◆ cleanTheConsts()

void DTCalibrationMap::cleanTheConsts ( )
inline

Definition at line 67 of file DTCalibrationMap.h.

67 { theMap.clear(); }

References theMap.

◆ getConsts()

const DTCalibrationMap::CalibConsts * DTCalibrationMap::getConsts ( DTWireId  wireId) const

Definition at line 77 of file DTCalibrationMap.cc.

77  {
78  // Create a cache
79  static pair<Key, CalibConsts> cache;
80 
81  // Get the key
82  Key theKey = getKey(wireId);
83 
84  // Check if the result is already cached
85  if (theKey == cache.first) {
86  return &(cache.second);
87  }
88 
89  // Look for the given key into the map
90  map<Key, CalibConsts>::const_iterator res = theMap.find(theKey);
91  if (res != theMap.end()) {
92  cache = (*res);
93  return &((*res).second);
94  } else {
95  return nullptr;
96  }
97 }

References utilities::cache().

Referenced by DTVDriftCalibration::endJob().

◆ getField()

float DTCalibrationMap::getField ( DTWireId  wireId,
int  field 
) const

Definition at line 101 of file DTCalibrationMap.cc.

101  {
102  const CalibConsts* cals = getConsts(wireId);
103  if (cals == nullptr) {
104  throw cms::Exception("NoCalibConsts") << "DTCalibrationMap:" << endl
105  << "No parameters for wire: " << wireId << endl
106  << "Check the " << calibConstFileName << " file!" << endl;
107  } else {
108  return (*(cals))[field];
109  }
110 }

References Exception.

◆ getKey()

DTCalibrationMap::Key DTCalibrationMap::getKey ( DTWireId  wireId) const

Definition at line 64 of file DTCalibrationMap.cc.

64  {
65  if (theGranularity == byChamber) {
66  return Key(wireId.chamberId(), 0, 0, 0);
67  } else if (theGranularity == bySL) {
68  return Key(wireId.superlayerId(), 0, 0);
69  } else if (theGranularity == byLayer) {
70  return Key(wireId.layerId(), 0);
71  } else {
72  return Key(wireId);
73  }
74 }

References DTSuperLayerId::chamberId(), DTWireId::layerId(), and DTLayerId::superlayerId().

Referenced by DTVDriftCalibration::endJob(), MatrixToProcess.MatrixToProcess::getConfig(), MatrixToProcess.MatrixToProcess::getProcess(), MatrixToProcess.MatrixToProcess::identityTest(), and MatrixToProcess.MatrixToProcess::load().

◆ keyAndConsts_begin()

const_iterator DTCalibrationMap::keyAndConsts_begin ( ) const
inline

Definition at line 86 of file DTCalibrationMap.h.

86 { return theMap.begin(); }

References theMap.

◆ keyAndConsts_end()

const_iterator DTCalibrationMap::keyAndConsts_end ( ) const
inline

Definition at line 88 of file DTCalibrationMap.h.

88 { return theMap.end(); }

References theMap.

◆ kFactor()

float DTCalibrationMap::kFactor ( DTWireId  wireId) const

Return the kfactor for a particular wire.

Definition at line 54 of file DTCalibrationMap.cc.

54 { return getField(wireId, 2); }

References CaloRecHitAuxSetter::getField().

◆ meanVDrift()

float DTCalibrationMap::meanVDrift ( DTWireId  wireId) const

Return the mean drift velocity for a particular wire (cm/ns)

Definition at line 57 of file DTCalibrationMap.cc.

57 { return getField(wireId, 3); }

References CaloRecHitAuxSetter::getField().

◆ readConsts()

void DTCalibrationMap::readConsts ( const std::string &  inputFileName)
private

Definition at line 113 of file DTCalibrationMap.cc.

113  {
114  ifstream file(inputFileName.c_str());
115  // Check if the file exists
116  if (!file) {
117  cout << "[DTCalibrationMap]***Warning: File: " << inputFileName << " not found in current directory!!!" << endl;
118  }
119 
120  string line;
121 
122  // The numbers to be read to build the key
123  int wheel_id = 0;
124  int station_id = 0;
125  int sector_id = 0;
126  int superlayer_id = 0;
127  int layer_id = 0;
128  int wire_id = 0;
129 
130  // Read all the lines
131  while (getline(file, line)) {
132  if (line.empty() || line[0] == '#')
133  continue; // Skip comments and empty lines
134  stringstream linestr;
135  linestr << line;
136 
137  pair<Key, CalibConsts> wireCalib;
138 
139  linestr >> wheel_id >> station_id >> sector_id >> superlayer_id >> layer_id >> wire_id;
140 
141  // Build the key
142  wireCalib.first = Key(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id);
143 
144  if (!checkGranularity(wireCalib.first))
145  cout << "[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the selected granularity!"
146  << endl;
147 
148  // Read the calibration constants
149  copy(istream_iterator<float>(linestr), istream_iterator<float>(), back_inserter(wireCalib.second));
150 
151  if (wireCalib.second.size() < nFields) {
152  cout << "[DTCalibrationMap]***Warning: the CalibConstFile is not consistent with the number of fields!" << endl;
153  }
154 
155  theMap.insert(wireCalib);
156  }
157 }

References filterCSVwithJSON::copy, gather_cfg::cout, FrontierConditions_GlobalTag_cff::file, InefficientDoubleROC::inputFileName, and mps_splice::line.

◆ sigma_meanVDrift()

float DTCalibrationMap::sigma_meanVDrift ( DTWireId  wireId) const

Return the sigma of the mean drift velocity for a particular wire (cm/ns)

Definition at line 60 of file DTCalibrationMap.cc.

60 { return getField(wireId, 4); }

References CaloRecHitAuxSetter::getField().

◆ sigma_tTrig()

float DTCalibrationMap::sigma_tTrig ( DTWireId  wireId) const

Return the sigma of the t_trig (ns) for a particular wire.

Definition at line 51 of file DTCalibrationMap.cc.

51 { return getField(wireId, 1); }

References CaloRecHitAuxSetter::getField().

◆ tTrig()

float DTCalibrationMap::tTrig ( DTWireId  wireId) const

Return the t_trig (ns) for a particular wire.

Definition at line 48 of file DTCalibrationMap.cc.

48 { return getField(wireId, 0); }

References CaloRecHitAuxSetter::getField().

◆ writeConsts()

void DTCalibrationMap::writeConsts ( const std::string &  outputFileName) const

Definition at line 169 of file DTCalibrationMap.cc.

169  {
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, " "));
175  out << endl;
176  }
177 }

References filterCSVwithJSON::copy, MillePedeFileConverter_cfg::out, and reco_skim_cfg_mod::outputFileName.

Referenced by DTVDriftCalibration::endJob().

Member Data Documentation

◆ calibConstFileName

std::string DTCalibrationMap::calibConstFileName
private

Definition at line 106 of file DTCalibrationMap.h.

◆ calibConstGranularity

std::string DTCalibrationMap::calibConstGranularity
private

Definition at line 109 of file DTCalibrationMap.h.

◆ nFields

unsigned int DTCalibrationMap::nFields
private

Definition at line 103 of file DTCalibrationMap.h.

◆ theGranularity

CalibGranularity DTCalibrationMap::theGranularity
private

Definition at line 94 of file DTCalibrationMap.h.

◆ theMap

std::map<Key, CalibConsts> DTCalibrationMap::theMap
private

Definition at line 112 of file DTCalibrationMap.h.

Referenced by cleanTheConsts(), keyAndConsts_begin(), and keyAndConsts_end().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
DTCalibrationMap::getField
float getField(DTWireId wireId, int field) const
Definition: DTCalibrationMap.cc:101
DTCalibrationMap::theMap
std::map< Key, CalibConsts > theMap
Definition: DTCalibrationMap.h:112
DTCalibrationMap::calibConstGranularity
std::string calibConstGranularity
Definition: DTCalibrationMap.h:109
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DTCalibrationMap::calibConstFileName
std::string calibConstFileName
Definition: DTCalibrationMap.h:106
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTCalibrationMap::byChamber
Definition: DTCalibrationMap.h:93
DTCalibrationMap::theGranularity
CalibGranularity theGranularity
Definition: DTCalibrationMap.h:94
DTCalibrationMap::nFields
unsigned int nFields
Definition: DTCalibrationMap.h:103
DTCalibrationMap::Key
DTWireId Key
Definition: DTCalibrationMap.h:63
DTCalibrationMap::byWire
Definition: DTCalibrationMap.h:93
Key
Definition: GoldenPattern.h:15
DTCalibrationMap::CalibConsts
std::vector< float > CalibConsts
Definition: DTCalibrationMap.h:62
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
DTCalibrationMap::getKey
Key getKey(DTWireId wireId) const
Definition: DTCalibrationMap.cc:64
reco_skim_cfg_mod.outputFileName
outputFileName
Definition: reco_skim_cfg_mod.py:15
utilities.cache
def cache(function)
Definition: utilities.py:3
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
DTCalibrationMap::byLayer
Definition: DTCalibrationMap.h:93
res
Definition: Electron.h:6
DTCalibrationMap::bySL
Definition: DTCalibrationMap.h:93
DTCalibrationMap::getConsts
const CalibConsts * getConsts(DTWireId wireId) const
Definition: DTCalibrationMap.cc:77
Exception
Definition: hltDiff.cc:246
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
DTWireId::layerId
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
DTCalibrationMap::checkGranularity
bool checkGranularity(Key aKey) const
Definition: DTCalibrationMap.cc:180
mps_splice.line
line
Definition: mps_splice.py:76
DTCalibrationMap::readConsts
void readConsts(const std::string &inputFileName)
Definition: DTCalibrationMap.cc:113
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27