CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
DTTTrigOffsetCalibration Class Reference

#include <DTTTrigOffsetCalibration.h>

Inheritance diagram for DTTTrigOffsetCalibration:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 DTTTrigOffsetCalibration (const edm::ParameterSet &pset)
 
void endJob () override
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 ~DTTTrigOffsetCalibration () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 Types

typedef std::map< DTChamberId, std::vector< TH1F * > > ChamberHistosMap
 

Private Member Functions

void bookHistos (DTChamberId)
 

Private Attributes

bool doTTrigCorrection_
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
TFile * rootFile_
 
DTSegmentSelectorselect_
 
std::string theCalibChamber_
 
edm::InputTag theRecHits4DLabel_
 
ChamberHistosMap theT0SegHistoMap_
 
const DTTtrigtTrigMap_
 
const edm::ESGetToken< DTTtrig, DTTtrigRcdttrigToken_
 

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

No description available.

Author
A. Vilela Pereira

Definition at line 30 of file DTTTrigOffsetCalibration.h.

Member Typedef Documentation

◆ ChamberHistosMap

typedef std::map<DTChamberId, std::vector<TH1F*> > DTTTrigOffsetCalibration::ChamberHistosMap
private

Definition at line 43 of file DTTTrigOffsetCalibration.h.

Constructor & Destructor Documentation

◆ DTTTrigOffsetCalibration()

DTTTrigOffsetCalibration::DTTTrigOffsetCalibration ( const edm::ParameterSet pset)

Definition at line 37 of file DTTTrigOffsetCalibration.cc.

References edm::BeginRun, edm::EDConsumerBase::consumesCollector(), muonDTDigis_cfi::pset, rootFile_, CSCSkim_cfi::rootFileName, and select_.

38  : theRecHits4DLabel_(pset.getParameter<InputTag>("recHits4DLabel")),
39  doTTrigCorrection_(pset.getUntrackedParameter<bool>("doT0SegCorrection", false)),
40  theCalibChamber_(pset.getUntrackedParameter<string>("calibChamber", "All")),
42  esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")))),
44  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Constructor called!";
45 
47  select_ = new DTSegmentSelector(pset, collector);
48 
49  // the root file which will contain the histos
50  string rootFileName = pset.getUntrackedParameter<string>("rootFileName", "DTT0SegHistos.root");
51  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
52  rootFile_->cd();
53 }
Log< level::Info, true > LogVerbatim
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_

◆ ~DTTTrigOffsetCalibration()

DTTTrigOffsetCalibration::~DTTTrigOffsetCalibration ( )
override

Definition at line 64 of file DTTTrigOffsetCalibration.cc.

References rootFile_.

64  {
65  rootFile_->Close();
66  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Destructor called!";
67 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 69 of file DTTTrigOffsetCalibration.cc.

References bookHistos(), relativeConstraints::chamber, DTGeometry::chamber(), dtGeomToken_, edmPickEvents::event, options_cfi::eventSetup, HcalObjRepresent::Fill(), LogTrace, FastTimerService_cff::range, rootFile_, select_, theCalibChamber_, theRecHits4DLabel_, and theT0SegHistoMap_.

69  {
70  rootFile_->cd();
71  DTChamberId chosenChamberId;
72 
73  if (theCalibChamber_ != "All") {
74  stringstream linestr;
75  int selWheel, selStation, selSector;
76  linestr << theCalibChamber_;
77  linestr >> selWheel >> selStation >> selSector;
78  chosenChamberId = DTChamberId(selWheel, selStation, selSector);
79  LogVerbatim("Calibration") << " chosen chamber " << chosenChamberId << endl;
80  }
81 
82  // Get the DT Geometry
83  ESHandle<DTGeometry> dtGeom;
84  dtGeom = eventSetup.getHandle(dtGeomToken_);
85 
86  // Get the rechit collection from the event
88  event.getByLabel(theRecHits4DLabel_, all4DSegments);
89 
90  // Loop over segments by chamber
92  for (chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt) {
93  // Get the chamber from the setup
94  const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
95  LogTrace("Calibration") << "Chamber Id: " << *chamberIdIt;
96 
97  // Book histos
98  if (theT0SegHistoMap_.find(*chamberIdIt) == theT0SegHistoMap_.end()) {
99  bookHistos(*chamberIdIt);
100  }
101 
102  // Calibrate just the chosen chamber/s
103  if ((theCalibChamber_ != "All") && ((*chamberIdIt) != chosenChamberId))
104  continue;
105 
106  // Get the range for the corresponding ChamberId
107  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
108 
109  // Loop over the rechits of this DetUnit
110  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; ++segment) {
111  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
112  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
113 
114  if (!(*select_)(*segment, event, eventSetup))
115  continue;
116 
117  // Fill t0-seg values
118  if ((*segment).hasPhi()) {
119  //if( segment->phiSegment()->ist0Valid() ){
120  if ((segment->phiSegment()->t0()) != 0.00) {
121  (theT0SegHistoMap_[*chamberIdIt])[0]->Fill(segment->phiSegment()->t0());
122  }
123  }
124  if ((*segment).hasZed()) {
125  //if( segment->zSegment()->ist0Valid() ){
126  if ((segment->zSegment()->t0()) != 0.00) {
127  (theT0SegHistoMap_[*chamberIdIt])[1]->Fill(segment->zSegment()->t0());
128  }
129  }
130  } // DTRecSegment4DCollection::const_iterator segment
131  } // DTRecSegment4DCollection::id_iterator chamberIdIt
132 } // DTTTrigOffsetCalibration::analyze
Log< level::Info, true > LogVerbatim
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
identifier iterator
Definition: RangeMap.h:130
#define LogTrace(id)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90

◆ beginRun()

void DTTTrigOffsetCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
override

Definition at line 55 of file DTTTrigOffsetCalibration.cc.

References doTTrigCorrection_, singleTopDQM_cfi::setup, dttriganalyzer_cfi::tTrig, tTrigMap_, and ttrigToken_.

55  {
56  if (doTTrigCorrection_) {
58  tTrig = setup.getHandle(ttrigToken_);
59  tTrigMap_ = &setup.getData(ttrigToken_);
60  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration]: TTrig version: " << tTrig->version() << endl;
61  }
62 }
Log< level::Info, true > LogVerbatim
const edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_

◆ bookHistos()

void DTTTrigOffsetCalibration::bookHistos ( DTChamberId  chId)
private

Definition at line 186 of file DTTTrigOffsetCalibration.cc.

References combine::histos, LogTrace, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, theT0SegHistoMap_, cond::impl::to_string(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by analyze().

186  {
187  LogTrace("Calibration") << " Booking histos for Chamber: " << chId;
188 
189  // Compose the chamber name
192  std::string sector = std::to_string(chId.sector());
193 
194  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
195 
196  vector<TH1F*> histos;
197  // Note the order matters
198  histos.push_back(new TH1F(("hRPhiSegT0" + chHistoName).c_str(), "t0 from Phi segments", 500, -60., 60.));
199  if (chId.station() != 4)
200  histos.push_back(new TH1F(("hRZSegT0" + chHistoName).c_str(), "t0 from Z segments", 500, -60., 60.));
201 
202  theT0SegHistoMap_[chId] = histos;
203 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::string to_string(const V &value)
Definition: OMSAccess.h:71
#define LogTrace(id)
histos
Definition: combine.py:4
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49

◆ endJob()

void DTTTrigOffsetCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 134 of file DTTTrigOffsetCalibration.cc.

References doTTrigCorrection_, DTTtrig::get(), dttriganalyzer_cfi::kFactor, DTTimeUnits::ns, rootFile_, DTChamberId::station(), theT0SegHistoMap_, dttriganalyzer_cfi::tTrig, tTrigMap_, and DTCalibDBUtils::writeToDB().

Referenced by o2olib.O2ORunMgr::executeJob().

134  {
135  rootFile_->cd();
136 
137  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Writing histos to file!" << endl;
138 
139  for (ChamberHistosMap::const_iterator itChHistos = theT0SegHistoMap_.begin(); itChHistos != theT0SegHistoMap_.end();
140  ++itChHistos) {
141  for (vector<TH1F*>::const_iterator itHist = (*itChHistos).second.begin(); itHist != (*itChHistos).second.end();
142  ++itHist)
143  (*itHist)->Write();
144  }
145 
146  if (doTTrigCorrection_) {
147  // Create the object to be written to DB
148  DTTtrig* tTrig = new DTTtrig();
149 
150  for (ChamberHistosMap::const_iterator itChHistos = theT0SegHistoMap_.begin(); itChHistos != theT0SegHistoMap_.end();
151  ++itChHistos) {
152  DTChamberId chId = itChHistos->first;
153  // Get SuperLayerId's for each ChamberId
154  vector<DTSuperLayerId> slIds;
155  slIds.push_back(DTSuperLayerId(chId, 1));
156  slIds.push_back(DTSuperLayerId(chId, 3));
157  if (chId.station() != 4)
158  slIds.push_back(DTSuperLayerId(chId, 2));
159 
160  for (vector<DTSuperLayerId>::const_iterator itSl = slIds.begin(); itSl != slIds.end(); ++itSl) {
161  // Get old values from DB
162  float ttrigMean = 0;
163  float ttrigSigma = 0;
164  float kFactor = 0;
165  tTrigMap_->get(*itSl, ttrigMean, ttrigSigma, kFactor, DTTimeUnits::ns);
166  //FIXME: verify if values make sense
167  // Set new values
168  float ttrigMeanNew = ttrigMean;
169  float ttrigSigmaNew = ttrigSigma;
170  float t0SegMean =
171  (itSl->superLayer() != 2) ? itChHistos->second[0]->GetMean() : itChHistos->second[1]->GetMean();
172 
173  float kFactorNew = (kFactor * ttrigSigma + t0SegMean) / ttrigSigma;
174 
175  tTrig->set(*itSl, ttrigMeanNew, ttrigSigmaNew, kFactorNew, DTTimeUnits::ns);
176  }
177  }
178  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Writing ttrig object to DB!" << endl;
179  // Write the object to DB
180  string tTrigRecord = "DTTtrigRcd";
181  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
182  }
183 }
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
Definition: DTChamberId.h:42
static void writeToDB(std::string record, const T &payload)
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59

◆ endRun()

void DTTTrigOffsetCalibration::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
inlineoverride

Definition at line 39 of file DTTTrigOffsetCalibration.h.

39 {};

Member Data Documentation

◆ doTTrigCorrection_

bool DTTTrigOffsetCalibration::doTTrigCorrection_
private

Definition at line 49 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().

◆ dtGeomToken_

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

Definition at line 57 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

◆ rootFile_

TFile* DTTTrigOffsetCalibration::rootFile_
private

◆ select_

DTSegmentSelector* DTTTrigOffsetCalibration::select_
private

Definition at line 46 of file DTTTrigOffsetCalibration.h.

Referenced by analyze(), and DTTTrigOffsetCalibration().

◆ theCalibChamber_

std::string DTTTrigOffsetCalibration::theCalibChamber_
private

Definition at line 50 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

◆ theRecHits4DLabel_

edm::InputTag DTTTrigOffsetCalibration::theRecHits4DLabel_
private

Definition at line 48 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

◆ theT0SegHistoMap_

ChamberHistosMap DTTTrigOffsetCalibration::theT0SegHistoMap_
private

Definition at line 54 of file DTTTrigOffsetCalibration.h.

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

◆ tTrigMap_

const DTTtrig* DTTTrigOffsetCalibration::tTrigMap_
private

Definition at line 53 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().

◆ ttrigToken_

const edm::ESGetToken<DTTtrig, DTTtrigRcd> DTTTrigOffsetCalibration::ttrigToken_
private

Definition at line 56 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun().