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) 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file DTTTrigWriter.h.

Constructor & Destructor Documentation

◆ DTTTrigWriter()

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

Constructor.

Definition at line 36 of file DTTTrigWriter.cc.

36  {
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 }

References gather_cfg::cout, debug, dttriganalyzer_cfi::kFactor, muonDTDigis_cfi::pset, interactiveExample::theFile, and dttriganalyzer_cfi::tTrig.

◆ ~DTTTrigWriter()

DTTTrigWriter::~DTTTrigWriter ( )
override

Destructor.

Definition at line 62 of file DTTTrigWriter.cc.

62  {
63  if (debug)
64  cout << "[DTTTrigWriter]Destructor called!" << endl;
65  theFile->Close();
66  delete theFitter;
67 }

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

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

Definition at line 70 of file DTTTrigWriter.cc.

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

References gather_cfg::cout, debug, edm::EventSetup::get(), get, timingPdfMaker::histo, dttriganalyzer_cfi::kFactor, DTTimeUnits::ns, DTGeometry::superLayers(), interactiveExample::theFile, and dttriganalyzer_cfi::tTrig.

◆ endJob()

void DTTTrigWriter::endJob ( void  )
overridevirtual

Write ttrig in the DB.

Reimplemented from edm::EDAnalyzer.

Definition at line 100 of file DTTTrigWriter.cc.

100  {
101  if (debug)
102  cout << "[DTTTrigWriter]Writing ttrig object to DB!" << endl;
103 
104  // FIXME: to be read from cfg?
105  string tTrigRecord = "DTTtrigRcd";
106 
107  // Write the object to DB
108  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
109 }

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

Referenced by o2olib.O2ORunMgr::executeJob().

◆ getTBoxName()

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

Definition at line 112 of file DTTTrigWriter.cc.

112  {
113  string histoName = "Ch_" + std::to_string(slId.wheel()) + "_" + std::to_string(slId.station()) + "_" +
114  std::to_string(slId.sector()) + "_SL" + std::to_string(slId.superlayer()) + "_hTimeBox";
115  return histoName;
116 }

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

Member Data Documentation

◆ debug

bool DTTTrigWriter::debug
private

◆ kFactor

double DTTTrigWriter::kFactor
private

Definition at line 50 of file DTTTrigWriter.h.

◆ theFile

TFile* DTTTrigWriter::theFile
private

Definition at line 53 of file DTTTrigWriter.h.

◆ theFitter

DTTimeBoxFitter* DTTTrigWriter::theFitter
private

Definition at line 59 of file DTTTrigWriter.h.

◆ theRootInputFile

std::string DTTTrigWriter::theRootInputFile
private

Definition at line 56 of file DTTTrigWriter.h.

◆ tTrig

DTTtrig* DTTTrigWriter::tTrig
private

Definition at line 62 of file DTTTrigWriter.h.

DTSuperLayerId
Definition: DTSuperLayerId.h:12
DTTtrig
Definition: DTTtrig.h:68
DTTimeBoxFitter::setFitSigma
void setFitSigma(double sigma)
Definition: DTTimeBoxFitter.h:46
gather_cfg.cout
cout
Definition: gather_cfg.py:144
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
DTSuperLayerId::superlayer
int superlayer() const
Return the superlayer number (deprecated method name)
Definition: DTSuperLayerId.h:42
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
edm::ESHandle< DTGeometry >
DTTTrigWriter::tTrig
DTTtrig * tTrig
Definition: DTTTrigWriter.h:62
DTTimeBoxFitter::setVerbosity
void setVerbosity(unsigned int lvl)
Set the verbosity of the output: 0 = silent, 1 = info, 2 = debug.
Definition: DTTimeBoxFitter.h:38
DTGeometry::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86
DTTtrig::set
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:172
DTTTrigWriter::debug
bool debug
Definition: DTTTrigWriter.h:48
get
#define get
DTTTrigWriter::theFitter
DTTimeBoxFitter * theFitter
Definition: DTTTrigWriter.h:59
DTTimeBoxFitter::fitTimeBox
std::pair< double, double > fitTimeBox(TH1F *hTimeBox)
Fit the rising edge of the time box returning mean value and sigma (first and second respectively)
Definition: DTTimeBoxFitter.cc:36
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTTimeBoxFitter
Definition: DTTimeBoxFitter.h:17
DTTTrigWriter::getTBoxName
std::string getTBoxName(const DTSuperLayerId &slId) const
Definition: DTTTrigWriter.cc:112
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
DTTTrigWriter::kFactor
double kFactor
Definition: DTTTrigWriter.h:50
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTTTrigWriter::theRootInputFile
std::string theRootInputFile
Definition: DTTTrigWriter.h:56
DTCalibDBUtils::writeToDB
static void writeToDB(std::string record, T *payload)
Definition: DTCalibDBUtils.h:28
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
DTTTrigWriter::theFile
TFile * theFile
Definition: DTTTrigWriter.h:53