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::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 Compute the ttrig by fiting the TB rising edge. More...
 
 DTTTrigWriter (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob () override
 Write ttrig in the DB. More...
 
 ~DTTTrigWriter () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

bool debug
 
edm::ESHandle< DTGeometrydtGeom
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
double kFactor
 
TFile * theFile
 
DTTimeBoxFittertheFitter
 
std::string theRootInputFile
 
DTTtrigtTrig
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 29 of file DTTTrigWriter.h.

Constructor & Destructor Documentation

◆ DTTTrigWriter()

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

Constructor.

Definition at line 36 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, kFactor, muonDTDigis_cfi::pset, DTTimeBoxFitter::setFitSigma(), DTTimeBoxFitter::setVerbosity(), theFile, theFitter, theRootInputFile, and tTrig.

37  // get selected debug option
38  debug = pset.getUntrackedParameter<bool>("debug", false);
39 
40  // Open the root file which contains the histos
41  theRootInputFile = pset.getUntrackedParameter<string>("rootFileName");
42  theFile = new TFile(theRootInputFile.c_str(), "READ");
43  theFile->cd();
44  theFitter = new DTTimeBoxFitter();
45  if (debug)
47 
48  double sigmaFit = pset.getUntrackedParameter<double>("sigmaTTrigFit", 10.);
49  theFitter->setFitSigma(sigmaFit);
50 
51  // the kfactor to be uploaded in the ttrig DB
52  kFactor = pset.getUntrackedParameter<double>("kFactor", -0.7);
53 
54  // Create the object to be written to DB
55  tTrig = new DTTtrig();
56 
57  if (debug)
58  cout << "[DTTTrigWriter]Constructor called!" << endl;
59 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:62
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
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
Definition: DTTTrigWriter.h:69

◆ ~DTTTrigWriter()

DTTTrigWriter::~DTTTrigWriter ( )
override

Destructor.

Definition at line 62 of file DTTTrigWriter.cc.

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

62  {
63  if (debug)
64  cout << "[DTTTrigWriter]Destructor called!" << endl;
65  theFile->Close();
66  delete theFitter;
67 }
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:62
TFile * theFile
Definition: DTTTrigWriter.h:56

Member Function Documentation

◆ analyze()

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

Compute the ttrig by fiting the TB rising edge.

Implements edm::one::EDAnalyzerBase.

Definition at line 70 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, dtGeom, dtGeomToken_, options_cfi::eventSetup, DTTimeBoxFitter::fitTimeBox(), getTBoxName(), timingPdfMaker::histo, kFactor, DTTimeUnits::ns, DTTtrig::set(), DTGeometry::superLayers(), theFile, theFitter, and tTrig.

70  {
71  if (debug)
72  cout << "[DTTTrigWriter]Analyzer called!" << endl;
73 
74  // Get the DT Geometry
75  dtGeom = eventSetup.getHandle(dtGeomToken_);
76 
77  // Get all the sls from the setup
78  const vector<const DTSuperLayer*> superLayers = dtGeom->superLayers();
79 
80  // Loop over all SLs
81  for (auto sl = superLayers.begin(); sl != superLayers.end(); sl++) {
82  // Get the histo from file
83  DTSuperLayerId slId = (*sl)->id();
84  TH1F* histo = (TH1F*)theFile->Get((getTBoxName(slId)).c_str());
85  if (histo) { // Check that the histo exists
86  // Compute mean and sigma of the rising edge
87  pair<double, double> meanAndSigma = theFitter->fitTimeBox(histo);
88 
89  // Write them in DB object
90  tTrig->set(slId, meanAndSigma.first, meanAndSigma.second, kFactor, DTTimeUnits::ns);
91  if (debug) {
92  cout << " SL: " << slId << " mean = " << meanAndSigma.first << " sigma = " << meanAndSigma.second << endl;
93  }
94  }
95  }
96 }
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:172
TFile * theFile
Definition: DTTTrigWriter.h:56
edm::ESHandle< DTGeometry > dtGeom
Definition: DTTTrigWriter.h:68
std::string getTBoxName(const DTSuperLayerId &slId) const
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 edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
Definition: DTTTrigWriter.h:69
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86

◆ endJob()

void DTTTrigWriter::endJob ( void  )
overridevirtual

Write ttrig in the DB.

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 99 of file DTTTrigWriter.cc.

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

Referenced by o2olib.O2ORunMgr::executeJob().

99  {
100  if (debug)
101  cout << "[DTTTrigWriter]Writing ttrig object to DB!" << endl;
102 
103  // FIXME: to be read from cfg?
104  string tTrigRecord = "DTTtrigRcd";
105 
106  // Write the object to DB
107  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
108 }
static void writeToDB(std::string record, const T &payload)
DTTtrig * tTrig
Definition: DTTTrigWriter.h:65

◆ getTBoxName()

string DTTTrigWriter::getTBoxName ( const DTSuperLayerId slId) const
private

Definition at line 111 of file DTTTrigWriter.cc.

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

Referenced by analyze().

111  {
112  string histoName = "Ch_" + std::to_string(slId.wheel()) + "_" + std::to_string(slId.station()) + "_" +
113  std::to_string(slId.sector()) + "_SL" + std::to_string(slId.superlayer()) + "_hTimeBox";
114  return histoName;
115 }
int station() const
Return the station number.
Definition: DTChamberId.h:45
static std::string to_string(const XMLCh *ch)
int superlayer() const
Return the superlayer number (deprecated method name)
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:42
int sector() const
Definition: DTChamberId.h:52

Member Data Documentation

◆ debug

bool DTTTrigWriter::debug
private

◆ dtGeom

edm::ESHandle<DTGeometry> DTTTrigWriter::dtGeom
private

Definition at line 68 of file DTTTrigWriter.h.

Referenced by analyze().

◆ dtGeomToken_

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTTTrigWriter::dtGeomToken_
private

Definition at line 69 of file DTTTrigWriter.h.

Referenced by analyze().

◆ kFactor

double DTTTrigWriter::kFactor
private

Definition at line 53 of file DTTTrigWriter.h.

Referenced by analyze(), and DTTTrigWriter().

◆ theFile

TFile* DTTTrigWriter::theFile
private

Definition at line 56 of file DTTTrigWriter.h.

Referenced by analyze(), DTTTrigWriter(), and ~DTTTrigWriter().

◆ theFitter

DTTimeBoxFitter* DTTTrigWriter::theFitter
private

Definition at line 62 of file DTTTrigWriter.h.

Referenced by analyze(), DTTTrigWriter(), and ~DTTTrigWriter().

◆ theRootInputFile

std::string DTTTrigWriter::theRootInputFile
private

Definition at line 59 of file DTTTrigWriter.h.

Referenced by DTTTrigWriter().

◆ tTrig

DTTtrig* DTTTrigWriter::tTrig
private

Definition at line 65 of file DTTTrigWriter.h.

Referenced by analyze(), DTTTrigWriter(), and endJob().