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 Member Functions | Private Attributes
DTTTrigWriter Class Reference

#include <DTTTrigWriter.h>

Inheritance diagram for DTTTrigWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 Compute the ttrig by fiting the TB rising edge. More...
 
 DTTTrigWriter (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob ()
 Write ttrig in the DB. More...
 
virtual ~DTTTrigWriter ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

std::string getTBoxName (const DTSuperLayerId &slId) const
 

Private Attributes

bool debug
 
double kFactor
 
TFile * theFile
 
DTTimeBoxFittertheFitter
 
std::string theRootInputFile
 
DTTtrigtTrig
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file DTTTrigWriter.h.

Constructor & Destructor Documentation

DTTTrigWriter::DTTTrigWriter ( const edm::ParameterSet pset)

Constructor.

Definition at line 41 of file DTTTrigWriter.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  theFile->cd();
49  theFitter = new DTTimeBoxFitter();
50  if(debug)
52 
53  double sigmaFit = pset.getUntrackedParameter<double>("sigmaTTrigFit",10.);
54  theFitter->setFitSigma(sigmaFit);
55 
56  // the kfactor to be uploaded in the ttrig DB
57  kFactor = pset.getUntrackedParameter<double>("kFactor",-0.7);
58 
59  // Create the object to be written to DB
60  tTrig = new DTTtrig();
61 
62  if(debug)
63  cout << "[DTTTrigWriter]Constructor called!" << endl;
64 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:64
T getUntrackedParameter(std::string const &, T const &) const
std::string theRootInputFile
Definition: DTTTrigWriter.h:61
void setVerbosity(unsigned int lvl)
Set the verbosity of the output: 0 = silent, 1 = info, 2 = debug.
TFile * theFile
Definition: DTTTrigWriter.h:58
void setFitSigma(double sigma)
DTTtrig * tTrig
Definition: DTTTrigWriter.h:67
tuple cout
Definition: gather_cfg.py:121
DTTTrigWriter::~DTTTrigWriter ( )
virtual

Destructor.

Definition at line 69 of file DTTTrigWriter.cc.

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

69  {
70  if(debug)
71  cout << "[DTTTrigWriter]Destructor called!" << endl;
72  theFile->Close();
73  delete theFitter;
74 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:64
TFile * theFile
Definition: DTTTrigWriter.h:58
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

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

Compute the ttrig by fiting the TB rising edge.

Implements edm::EDAnalyzer.

Definition at line 79 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, edm::EventSetup::get(), timingPdfMaker::histo, DTTimeUnits::ns, and interactiveExample::theFile.

79  {
80  if(debug)
81  cout << "[DTTTrigWriter]Analyzer called!" << endl;
82 
83  // Get the DT Geometry
84  ESHandle<DTGeometry> dtGeom;
85  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
86 
87  // Get all the sls from the setup
88  const vector<DTSuperLayer*> superLayers = dtGeom->superLayers();
89 
90  // Loop over all SLs
91  for(vector<DTSuperLayer*>::const_iterator sl = superLayers.begin();
92  sl != superLayers.end(); sl++) {
93 
94  // Get the histo from file
95  DTSuperLayerId slId = (*sl)->id();
96  TH1F* histo = (TH1F*)theFile->Get((getTBoxName(slId)).c_str());
97  if(histo) { // Check that the histo exists
98  // Compute mean and sigma of the rising edge
99  pair<double, double> meanAndSigma = theFitter->fitTimeBox(histo);
100 
101  // Write them in DB object
102  tTrig->set(slId,
103  meanAndSigma.first,
104  meanAndSigma.second,
105  kFactor,
107  if(debug) {
108  cout << " SL: " << slId
109  << " mean = " << meanAndSigma.first
110  << " sigma = " << meanAndSigma.second << endl;
111  }
112  }
113  }
114 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:64
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:262
TFile * theFile
Definition: DTTTrigWriter.h:58
std::string getTBoxName(const DTSuperLayerId &slId) const
const T & get() const
Definition: EventSetup.h:55
DTTtrig * tTrig
Definition: DTTTrigWriter.h:67
std::pair< double, double > fitTimeBox(TH1F *hTimeBox)
Fit the rising edge of the time box returning mean value and sigma (first and second respectively) ...
tuple cout
Definition: gather_cfg.py:121
void DTTTrigWriter::endJob ( void  )
virtual

Write ttrig in the DB.

Reimplemented from edm::EDAnalyzer.

Definition at line 119 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, and DTCalibDBUtils::writeToDB().

119  {
120  if(debug)
121  cout << "[DTTTrigWriter]Writing ttrig object to DB!" << endl;
122 
123  // FIXME: to be read from cfg?
124  string tTrigRecord = "DTTtrigRcd";
125 
126  // Write the object to DB
127  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
128 
129 }
DTTtrig * tTrig
Definition: DTTTrigWriter.h:67
tuple cout
Definition: gather_cfg.py:121
static void writeToDB(std::string record, T *payload)
string DTTTrigWriter::getTBoxName ( const DTSuperLayerId slId) const
private

Definition at line 134 of file DTTTrigWriter.cc.

References DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), and DTChamberId::wheel().

134  {
135  string histoName;
136  stringstream theStream;
137  theStream << "Ch_" << slId.wheel() << "_" << slId.station() << "_" << slId.sector()
138  << "_SL" << slId.superlayer() << "_hTimeBox";
139  theStream >> histoName;
140  return histoName;
141 }
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47

Member Data Documentation

bool DTTTrigWriter::debug
private
double DTTTrigWriter::kFactor
private

Definition at line 55 of file DTTTrigWriter.h.

TFile* DTTTrigWriter::theFile
private

Definition at line 58 of file DTTTrigWriter.h.

DTTimeBoxFitter* DTTTrigWriter::theFitter
private

Definition at line 64 of file DTTTrigWriter.h.

std::string DTTTrigWriter::theRootInputFile
private

Definition at line 61 of file DTTTrigWriter.h.

DTTtrig* DTTTrigWriter::tTrig
private

Definition at line 67 of file DTTTrigWriter.h.