CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DTVDriftWriter Class Reference

#include <DTVDriftWriter.h>

Inheritance diagram for DTVDriftWriter:
edm::EDAnalyzer

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 
 DTVDriftWriter (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob ()
 
virtual ~DTVDriftWriter ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

bool debug
 
edm::ParameterSet theCalibFilePar
 
TFile * theFile
 
DTMeanTimerFittertheFitter
 
std::string theGranularity
 
DTMtimetheMTime
 
std::string theRootInputFile
 
std::string theVDriftOutputFile
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 32 of file DTVDriftWriter.h.

Constructor & Destructor Documentation

DTVDriftWriter::DTVDriftWriter ( const edm::ParameterSet pset)

Constructor.

Definition at line 41 of file DTVDriftWriter.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), and interactiveExample::theFile.

41  {
42  // get selected debug option
43  debug = pset.getUntrackedParameter<bool>("debug", "false");
44 
45  // Open the root file which contains the histos
46  theRootInputFile = pset.getUntrackedParameter<string>("rootFileName");
47  theFile = new TFile(theRootInputFile.c_str(), "READ");
48 
49  theFitter = new DTMeanTimerFitter(theFile);
50  if(debug)
51  theFitter->setVerbosity(1);
52 
53  // the text file which will contain the histos
54  theVDriftOutputFile = pset.getUntrackedParameter<string>("vDriftFileName");
55 
56  // get parameter set for DTCalibrationMap constructor
57  theCalibFilePar = pset.getUntrackedParameter<ParameterSet>("calibFileConfig");
58 
59  // the granularity to be used for calib constants evaluation
60  theGranularity = pset.getUntrackedParameter<string>("calibGranularity","bySL");
61 
62  theMTime = new DTMtime();
63 
64  if(debug)
65  cout << "[DTVDriftWriter]Constructor called!" << endl;
66 }
DTMeanTimerFitter * theFitter
T getUntrackedParameter(std::string const &, T const &) const
std::string theGranularity
DTMtime * theMTime
edm::ParameterSet theCalibFilePar
std::string theRootInputFile
tuple cout
Definition: gather_cfg.py:41
std::string theVDriftOutputFile
DTVDriftWriter::~DTVDriftWriter ( )
virtual

Destructor.

Definition at line 69 of file DTVDriftWriter.cc.

References gather_cfg::cout, debug, and interactiveExample::theFile.

69  {
70  if(debug)
71  cout << "[DTVDriftWriter]Destructor called!" << endl;
72  theFile->Close();
73  delete theFitter;
74 }
DTMeanTimerFitter * theFitter
tuple cout
Definition: gather_cfg.py:41

Member Function Documentation

void DTVDriftWriter::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 76 of file DTVDriftWriter.cc.

References DTCalibrationMap::addCell(), DTVelocityUnits::cm_per_ns, gather_cfg::cout, debug, edm::EventSetup::get(), DTCalibrationMap::getConsts(), DTCalibrationMap::getKey(), MultiGaussianStateTransform::N, DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superLayer(), DTChamberId::wheel(), and DTCalibrationMap::writeConsts().

76  {
77  if(debug)
78  cout << "[DTVDriftWriter]Analyzer called!" << endl;
79 
80  // Instantiate a DTCalibrationMap object
81  DTCalibrationMap calibValuesFile(theCalibFilePar);
82 
83  // Get the DT Geometry
84  ESHandle<DTGeometry> dtGeom;
85  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
86 
87  if(theGranularity == "bySL") {
88  // Get all the sls from the setup
89  const vector<DTSuperLayer*> superLayers = dtGeom->superLayers();
90 
91  // Loop over all SLs
92  for(vector<DTSuperLayer*>::const_iterator slCell = superLayers.begin();
93  slCell != superLayers.end(); slCell++) {
94 
95  DTSuperLayerId slId = (*slCell)->id();
96  // evaluate v_drift and sigma from the TMax histograms
97  DTWireId wireId(slId, 0, 0);
98  vector<float> newConstants;
99  TString N=(((((TString) "TMax"+(long) wireId.wheel()) +(long) wireId.station())
100  +(long) wireId.sector())+(long) wireId.superLayer());
101  vector<float> vDriftAndReso = theFitter->evaluateVDriftAndReso(N);
102 
103  // Don't write the constants for the SL if the vdrift was not computed
104  if(vDriftAndReso.front() == -1)
105  continue;
106 
107  const DTCalibrationMap::CalibConsts* oldConstants = calibValuesFile.getConsts(wireId);
108 
109  if(oldConstants != 0) {
110  newConstants.push_back((*oldConstants)[0]);
111  newConstants.push_back((*oldConstants)[1]);
112  newConstants.push_back((*oldConstants)[2]);
113  } else {
114  newConstants.push_back(-1);
115  newConstants.push_back(-1);
116  newConstants.push_back(-1);
117  }
118  for(int ivd=0; ivd<=5;ivd++) {
119  // 0=vdrift, 1=reso, 2=(3deltat0-2deltat0), 3=(2deltat0-1deltat0),
120  // 4=(1deltat0-0deltat0), 5=deltat0 from hists with max entries,
121  newConstants.push_back(vDriftAndReso[ivd]);
122  }
123  calibValuesFile.addCell(calibValuesFile.getKey(wireId), newConstants);
124 
125  // vdrift is cm/ns , resolution is cm
126  theMTime->set(slId,
127  vDriftAndReso[0],
128  vDriftAndReso[1],
130  if(debug) {
131  cout << " SL: " << slId
132  << " vDrift = " << vDriftAndReso[0]
133  << " reso = " << vDriftAndReso[1] << endl;
134  }
135  }
136  }
137  // to be implemented: granularity different from bySL
138 
139  // if(theGranularity == "byChamber") {
140  // const vector<DTChamber*> chambers = dMap.chambers();
141 
142  // // Loop over all chambers
143  // for(vector<MuBarChamber*>::const_iterator chamber = chambers.begin();
144  // chamber != chambers.end(); chamber ++) {
145  // MuBarChamberId chamber_id = (*chamber)->id();
146  // MuBarDigiParameters::Key wire_id(chamber_id, 0, 0, 0);
147  // vector<float> newConstants;
148  // vector<float> vDriftAndReso = evaluateVDriftAndReso(wire_id, f);
149  // const CalibConsts* oldConstants = digiParams.getConsts(wire_id);
150  // if(oldConstants !=0) {
151  // newConstants = *oldConstants;
152  // newConstants.push_back(vDriftAndReso[0]);
153  // newConstants.push_back(vDriftAndReso[1]);
154  // newConstants.push_back(vDriftAndReso[2]);
155  // newConstants.push_back(vDriftAndReso[3]);
156  // } else {
157  // newConstants.push_back(-1);
158  // newConstants.push_back(-1);
159  // newConstants.push_back(vDriftAndReso[0]);
160  // newConstants.push_back(vDriftAndReso[1]);
161  // newConstants.push_back(vDriftAndReso[2]);
162  // newConstants.push_back(vDriftAndReso[3]);
163  // }
164  // digiParams.addCell(wire_id, newConstants);
165  // }
166  // }
167  //write values to a table
168  calibValuesFile.writeConsts(theVDriftOutputFile);
169 }
DTMeanTimerFitter * theFitter
std::string theGranularity
DTMtime * theMTime
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:266
edm::ParameterSet theCalibFilePar
std::vector< float > evaluateVDriftAndReso(TString N)
Fit the TMax histos and evaluate VDrift and resolution.
std::vector< float > CalibConsts
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:41
std::string theVDriftOutputFile
void DTVDriftWriter::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 173 of file DTVDriftWriter.cc.

References gather_cfg::cout, debug, and record.

173  {
174 
175  if(debug)
176  cout << "[DTVDriftWriter]Writing vdrift object to DB!" << endl;
177 
178  // Write the MeanTimer object to DB
179  string record = "DTMtimeRcd";
180  DTCalibDBUtils::writeToDB<DTMtime>(record, theMTime);
181 }
DTMtime * theMTime
JetCorrectorParameters::Record record
Definition: classes.h:11
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

bool DTVDriftWriter::debug
private

Definition at line 49 of file DTVDriftWriter.h.

edm::ParameterSet DTVDriftWriter::theCalibFilePar
private

Definition at line 61 of file DTVDriftWriter.h.

TFile* DTVDriftWriter::theFile
private

Definition at line 52 of file DTVDriftWriter.h.

DTMeanTimerFitter* DTVDriftWriter::theFitter
private

Definition at line 67 of file DTVDriftWriter.h.

std::string DTVDriftWriter::theGranularity
private

Definition at line 64 of file DTVDriftWriter.h.

DTMtime* DTVDriftWriter::theMTime
private

Definition at line 70 of file DTVDriftWriter.h.

std::string DTVDriftWriter::theRootInputFile
private

Definition at line 55 of file DTVDriftWriter.h.

std::string DTVDriftWriter::theVDriftOutputFile
private

Definition at line 58 of file DTVDriftWriter.h.