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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 27 of file DTTTrigWriter.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 39 of file DTTTrigWriter.cc.

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

39  {
40  // get selected debug option
41  debug = pset.getUntrackedParameter<bool>("debug",false);
42 
43  // Open the root file which contains the histos
44  theRootInputFile = pset.getUntrackedParameter<string>("rootFileName");
45  theFile = new TFile(theRootInputFile.c_str(), "READ");
46  theFile->cd();
47  theFitter = new DTTimeBoxFitter();
48  if(debug)
50 
51  double sigmaFit = pset.getUntrackedParameter<double>("sigmaTTrigFit",10.);
52  theFitter->setFitSigma(sigmaFit);
53 
54  // the kfactor to be uploaded in the ttrig DB
55  kFactor = pset.getUntrackedParameter<double>("kFactor",-0.7);
56 
57  // Create the object to be written to DB
58  tTrig = new DTTtrig();
59 
60  if(debug)
61  cout << "[DTTTrigWriter]Constructor called!" << endl;
62 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:62
T getUntrackedParameter(std::string const &, T const &) const
std::string theRootInputFile
Definition: DTTTrigWriter.h:59
void setVerbosity(unsigned int lvl)
Set the verbosity of the output: 0 = silent, 1 = info, 2 = debug.
TFile * theFile
Definition: DTTTrigWriter.h:56
void setFitSigma(double sigma)
DTTtrig * tTrig
Definition: DTTTrigWriter.h:65
tuple cout
Definition: gather_cfg.py:121
DTTTrigWriter::~DTTTrigWriter ( )
virtual

Destructor.

Definition at line 67 of file DTTTrigWriter.cc.

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

67  {
68  if(debug)
69  cout << "[DTTTrigWriter]Destructor called!" << endl;
70  theFile->Close();
71  delete theFitter;
72 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:62
TFile * theFile
Definition: DTTTrigWriter.h:56
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 77 of file DTTTrigWriter.cc.

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

77  {
78  if(debug)
79  cout << "[DTTTrigWriter]Analyzer called!" << endl;
80 
81  // Get the DT Geometry
82  ESHandle<DTGeometry> dtGeom;
83  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
84 
85  // Get all the sls from the setup
86  const vector<const DTSuperLayer*> superLayers = dtGeom->superLayers();
87 
88  // Loop over all SLs
89  for(auto sl = superLayers.begin();
90  sl != superLayers.end(); sl++) {
91 
92  // Get the histo from file
93  DTSuperLayerId slId = (*sl)->id();
94  TH1F* histo = (TH1F*)theFile->Get((getTBoxName(slId)).c_str());
95  if(histo) { // Check that the histo exists
96  // Compute mean and sigma of the rising edge
97  pair<double, double> meanAndSigma = theFitter->fitTimeBox(histo);
98 
99  // Write them in DB object
100  tTrig->set(slId,
101  meanAndSigma.first,
102  meanAndSigma.second,
103  kFactor,
105  if(debug) {
106  cout << " SL: " << slId
107  << " mean = " << meanAndSigma.first
108  << " sigma = " << meanAndSigma.second << endl;
109  }
110  }
111  }
112 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:62
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:248
TFile * theFile
Definition: DTTTrigWriter.h:56
std::string getTBoxName(const DTSuperLayerId &slId) const
const T & get() const
Definition: EventSetup.h:56
DTTtrig * tTrig
Definition: DTTTrigWriter.h:65
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 117 of file DTTTrigWriter.cc.

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

117  {
118  if(debug)
119  cout << "[DTTTrigWriter]Writing ttrig object to DB!" << endl;
120 
121  // FIXME: to be read from cfg?
122  string tTrigRecord = "DTTtrigRcd";
123 
124  // Write the object to DB
125  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
126 
127 }
DTTtrig * tTrig
Definition: DTTTrigWriter.h:65
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 132 of file DTTTrigWriter.cc.

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

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

Member Data Documentation

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

Definition at line 53 of file DTTTrigWriter.h.

TFile* DTTTrigWriter::theFile
private

Definition at line 56 of file DTTTrigWriter.h.

DTTimeBoxFitter* DTTTrigWriter::theFitter
private

Definition at line 62 of file DTTTrigWriter.h.

std::string DTTTrigWriter::theRootInputFile
private

Definition at line 59 of file DTTTrigWriter.h.

DTTtrig* DTTTrigWriter::tTrig
private

Definition at line 65 of file DTTTrigWriter.h.