CMS 3D CMS Logo

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
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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(), DTAnalyzerDetailed_cfi::kFactor, 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
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

Member Function Documentation

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

Compute the ttrig by fiting the TB rising edge.

Definition at line 77 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, edm::EventSetup::get(), trackerHits::histo, DTAnalyzerDetailed_cfi::kFactor, DTTimeUnits::ns, DTGeometry::superLayers(), 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:55
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) ...
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:89
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().

Referenced by o2olib.O2ORunMgr::executeJob().

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
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.