CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTVDriftWriter.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * $Date: 2010/11/19 14:02:08 $
6  * $Revision: 1.11 $
7  * Author of original version: M. Giunta
8  * \author A. Vilela Pereira
9  */
10 
11 #include "DTVDriftWriter.h"
12 
17 
21 
24 
28 
29 #include <string>
30 #include <vector>
31 
32 using namespace std;
33 using namespace edm;
34 
36  granularity_( pset.getUntrackedParameter<string>("calibGranularity","bySL") ) {
37 
38  LogVerbatim("Calibration") << "[DTVDriftWriter]Constructor called!";
39 
40  if(granularity_ != "bySL")
41  throw cms::Exception("Configuration") << "[DTVDriftWriter] Check parameter calibGranularity: " << granularity_ << " option not available.";
42 
43  // Get the concrete algo from the factory
44  string algoName = pset.getParameter<string>("vDriftAlgo");
45  ParameterSet algoPSet = pset.getParameter<ParameterSet>("vDriftAlgoConfig");
46  vDriftAlgo_ = DTVDriftPluginFactory::get()->create(algoName,algoPSet);
47 }
48 
50  LogVerbatim("Calibration") << "[DTVDriftWriter]Destructor called!";
51  delete vDriftAlgo_;
52 }
53 
55  // Get the map of ttrig from the Setup
56  ESHandle<DTMtime> mTime;
57  setup.get<DTMtimeRcd>().get(mTime);
58  mTimeMap_ = &*mTime;
59 
60  // Get geometry from Event Setup
61  setup.get<MuonGeometryRecord>().get(dtGeom_);
62  // Pass EventSetup to concrete implementation
63  vDriftAlgo_->setES(setup);
64 }
65 
67  // Create the object to be written to DB
68  DTMtime* mTimeNewMap = new DTMtime();
69 
70  if(granularity_ == "bySL") {
71  // Get all the sls from the geometry
72  const vector<DTSuperLayer*>& superLayers = dtGeom_->superLayers();
73  vector<DTSuperLayer*>::const_iterator sl = superLayers.begin();
74  vector<DTSuperLayer*>::const_iterator sl_end = superLayers.end();
75  for(; sl != sl_end; ++sl){
76  DTSuperLayerId slId = (*sl)->id();
77  // Get original value from DB
78  float vDrift = 0., resolution = 0.;
79  // vdrift is cm/ns , resolution is cm
81 
82  // Compute vDrift
83  try{
84  DTVDriftData vDriftData = vDriftAlgo_->compute(slId);
85  float vDriftNew = vDriftData.vdrift;
86  float resolutionNew = vDriftData.resolution;
87  // vdrift is cm/ns , resolution is cm
88  mTimeNewMap->set(slId,
89  vDriftNew,
90  resolutionNew,
92  LogVerbatim("Calibration") << "vDrift for: " << slId
93  << " Mean " << vDriftNew
94  << " Resolution " << resolutionNew;
95  } catch(cms::Exception& e){
96  LogError("Calibration") << e.explainSelf();
97  // Go back to original value in case of error
98  if(!status){
99  mTimeNewMap->set(slId,
100  vDrift,
101  resolution,
103  LogVerbatim("Calibration") << "Keep original vDrift for: " << slId
104  << " Mean " << vDrift
105  << " Resolution " << resolution;
106  }
107  }
108  } // End of loop on superlayers
109  }
110 
111  // Write the vDrift object to DB
112  LogVerbatim("Calibration") << "[DTVDriftWriter]Writing vdrift object to DB!";
113  string record = "DTMtimeRcd";
114  DTCalibDBUtils::writeToDB<DTMtime>(record, mTimeNewMap);
115 }
T getParameter(std::string const &) const
edm::ESHandle< DTGeometry > dtGeom_
JetCorrectorParameters::Record record
Definition: classes.h:11
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:266
virtual std::string explainSelf() const
Definition: Exception.cc:146
virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup)
DTVDriftBaseAlgo * vDriftAlgo_
virtual ~DTVDriftWriter()
virtual void endJob()
DTVDriftWriter(const edm::ParameterSet &pset)
const T & get() const
Definition: EventSetup.h:55
virtual void setES(const edm::EventSetup &setup)=0
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:86
const DTMtime * mTimeMap_
tuple status
Definition: ntuplemaker.py:245
virtual DTVDriftData compute(const DTSuperLayerId &)=0
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:33
std::string granularity_