CMS 3D CMS Logo

DTCalibrationMap Class Reference

Allow saving and retrieving of calibration constants to/from txt file. More...

#include <CalibMuon/DTCalibration/plugins/DTCalibrationMap.h>

List of all members.

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.
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 meanVDrift (DTWireId wireId) const
 Return the mean drift velocity for a particular wire (cm/ns).
float sigma_meanVDrift (DTWireId wireId) const
 Return the sigma of the mean drift velocity for a particular wire (cm/ns).
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.
void writeConsts (const std::string &outputFileName) const
virtual ~DTCalibrationMap ()
 Destructor.

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 is mainly 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. The first 4 fields for each key are allocated to ttri, sigma_ttrig, vdrift and sigma_vdrift.

Date
2007/07/11 12:20:59
Revision
1.1
Author:
G. Cerminara - INFN Torino

Definition at line 29 of file DTCalibrationMap.h.


Member Typedef Documentation

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

Definition at line 51 of file DTCalibrationMap.h.

typedef std::map<Key, CalibConsts>::const_iterator DTCalibrationMap::const_iterator

Definition at line 53 of file DTCalibrationMap.h.

typedef DTWireId DTCalibrationMap::Key

Definition at line 52 of file DTCalibrationMap.h.


Member Enumeration Documentation

enum DTCalibrationMap::CalibGranularity [private]

Enumerator:
byChamber 
bySL 
byLayer 
byWire 

Definition at line 92 of file DTCalibrationMap.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 25 of file DTCalibrationMap.cc.

References byChamber, byLayer, bySL, byWire, calibConstFileName, calibConstGranularity, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::ParameterSet::getUntrackedParameter(), nFields, readConsts(), and theGranularity.

00025                                                            {
00026   nFields =  pset.getUntrackedParameter<int>("nFields", 4);
00027   calibConstFileName = pset.getUntrackedParameter<string>("calibConstFileName", "dummy.txt");
00028   calibConstGranularity = pset.getUntrackedParameter<string>("calibConstGranularity","bySL");
00029 
00030   // Initialize correctly the enum which specify the granularity for the calibration
00031   if(calibConstGranularity == "byWire") {
00032     theGranularity = byWire;
00033   } else if(calibConstGranularity == "byLayer"){
00034     theGranularity = byLayer;
00035   } else if(calibConstGranularity == "bySL") {
00036     theGranularity = bySL;
00037   } else {
00038     theGranularity = byChamber;
00039     if(!(calibConstGranularity == "byChamber")) {
00040       cout << "[DTCalibrationMap]###Warning: Check parameter calibConstGranularity: "
00041            << calibConstGranularity << " options not available!" << endl;
00042     }
00043   }
00044   readConsts(calibConstFileName);
00045 }

DTCalibrationMap::~DTCalibrationMap (  )  [virtual]

Destructor.

Definition at line 49 of file DTCalibrationMap.cc.

00049 {}


Member Function Documentation

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

Definition at line 198 of file DTCalibrationMap.cc.

References checkGranularity(), Exception, and theMap.

Referenced by DTVDriftWriter::analyze(), and DTVDriftCalibration::endJob().

00198                                                                         {
00199   if(!checkGranularity(theKey))
00200     throw cms::Exception("addCell") << "DTCalibrationMap:" << endl
00201                                     << "The added key is not compatible with the selected granularity"
00202                                     << endl;
00203 
00204   theMap[theKey] = calibConst;
00205 }

bool DTCalibrationMap::checkGranularity ( Key  aKey  )  const [private]

Definition at line 227 of file DTCalibrationMap.cc.

References byChamber, byLayer, bySL, byWire, DTLayerId::layer(), DTSuperLayerId::superlayer(), theGranularity, and DTWireId::wire().

Referenced by addCell().

00227                                                       {
00228   bool ret = true;
00229 
00230   // Check that the key is consistent with the given granularity
00231   if(theGranularity == byChamber) {
00232     if(aKey.superlayer() || aKey.layer() || aKey.wire()) {
00233       ret = false;
00234     }
00235   } else if(theGranularity == bySL) {
00236     if(aKey.layer() || aKey.wire()) {
00237       ret = false;
00238     }
00239   } else if(theGranularity == byLayer) {
00240     if(aKey.wire()) {
00241       ret = false;
00242     }
00243   } else if(theGranularity == byWire) {
00244     if(aKey.wire() == 0) {
00245       ret = false;
00246     }
00247   } 
00248   return ret;
00249 }

void DTCalibrationMap::cleanTheConsts (  )  [inline]

Definition at line 56 of file DTCalibrationMap.h.

References theMap.

00056                         {
00057     theMap.clear();
00058   }

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

Definition at line 98 of file DTCalibrationMap.cc.

References getKey(), res, and theMap.

Referenced by DTVDriftWriter::analyze(), DTVDriftCalibration::endJob(), and getField().

00098                                                                                     {
00099   // Create a cache
00100   static pair<Key, CalibConsts> cache;
00101 
00102   // Get the key
00103   Key theKey = getKey(wireId);
00104 
00105   // Check if the result is already cached
00106   if ( theKey == cache.first ) {
00107     return &(cache.second);
00108   }
00109 
00110   // Look for the given key into the map
00111   map<Key, CalibConsts>::const_iterator res = theMap.find(theKey);
00112   if (res != theMap.end()) {
00113     cache = (*res);
00114     return &((*res).second);
00115   } else {
00116     return 0;
00117   }
00118 }

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

Definition at line 124 of file DTCalibrationMap.cc.

References calibConstFileName, lat::endl(), Exception, and getConsts().

Referenced by meanVDrift(), sigma_meanVDrift(), sigma_tTrig(), and tTrig().

00124                                                                  {
00125   const CalibConsts* cals = getConsts(wireId);
00126   if (cals == 0) {
00127     throw cms::Exception("NoCalibConsts") << "DTCalibrationMap:" << endl
00128                                                 << "No parameters for wire: " << wireId << endl
00129                                                 << "Check the " << calibConstFileName << " file!" << endl;
00130   } else {
00131     return (*(cals))[field];
00132   }
00133 }

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

Definition at line 83 of file DTCalibrationMap.cc.

References byChamber, byLayer, bySL, DTSuperLayerId::chamberId(), DTWireId::layerId(), DTLayerId::superlayerId(), and theGranularity.

Referenced by DTVDriftWriter::analyze(), DTVDriftCalibration::endJob(), and getConsts().

00083                                                                   {
00084   if (theGranularity == byChamber){
00085     return Key(wireId.chamberId(), 0, 0, 0);
00086   } else if (theGranularity == bySL) {
00087     return Key(wireId.superlayerId(), 0, 0); 
00088   } else if (theGranularity == byLayer) {
00089     return Key(wireId.layerId(), 0);  
00090   } else {
00091     return Key(wireId);
00092   }
00093 }

const_iterator DTCalibrationMap::keyAndConsts_begin (  )  const [inline]

Definition at line 78 of file DTCalibrationMap.h.

References theMap.

00078                                             {
00079     return theMap.begin();
00080   }

const_iterator DTCalibrationMap::keyAndConsts_end (  )  const [inline]

Definition at line 82 of file DTCalibrationMap.h.

References theMap.

00082                                           {
00083     return theMap.end();
00084   }

float DTCalibrationMap::meanVDrift ( DTWireId  wireId  )  const

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

Definition at line 68 of file DTCalibrationMap.cc.

References getField().

00068                                                         {
00069  return getField(wireId, 2);
00070 }

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

Referenced by DTCalibrationMap().

float DTCalibrationMap::sigma_meanVDrift ( DTWireId  wireId  )  const

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

Definition at line 75 of file DTCalibrationMap.cc.

References getField().

00075                                                               {
00076  return getField(wireId, 3);
00077 }

float DTCalibrationMap::sigma_tTrig ( DTWireId  wireId  )  const

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

Definition at line 61 of file DTCalibrationMap.cc.

References getField().

00061                                                          {
00062  return getField(wireId, 1);
00063 }

float DTCalibrationMap::tTrig ( DTWireId  wireId  )  const

Return the t_trig (ns) for a particular wire.

Definition at line 54 of file DTCalibrationMap.cc.

References getField().

00054                                                    {
00055  return getField(wireId, 0);
00056 }

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

Referenced by DTVDriftWriter::analyze(), and DTVDriftCalibration::endJob().


Member Data Documentation

std::string DTCalibrationMap::calibConstFileName [private]

Definition at line 108 of file DTCalibrationMap.h.

Referenced by DTCalibrationMap(), and getField().

std::string DTCalibrationMap::calibConstGranularity [private]

Definition at line 111 of file DTCalibrationMap.h.

Referenced by DTCalibrationMap().

unsigned int DTCalibrationMap::nFields [private]

Definition at line 105 of file DTCalibrationMap.h.

Referenced by DTCalibrationMap().

CalibGranularity DTCalibrationMap::theGranularity [private]

Definition at line 93 of file DTCalibrationMap.h.

Referenced by checkGranularity(), DTCalibrationMap(), and getKey().

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

Definition at line 114 of file DTCalibrationMap.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:18:45 2009 for CMSSW by  doxygen 1.5.4