CMS 3D CMS Logo

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::EDAnalyzer 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
 
 ~DTTTrigOffsetCalibration () override
 
- 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::vector< ModuleDescription const * > &modules, 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
 
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

std::string dbLabel_
 
bool doTTrigCorrection_
 
TFile * rootFile_
 
DTSegmentSelectorselect_
 
std::string theCalibChamber_
 
edm::InputTag theRecHits4DLabel_
 
ChamberHistosMap theT0SegHistoMap_
 
const DTTtrigtTrigMap_
 

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

No description available.

Author
A. Vilela Pereira

Definition at line 27 of file DTTTrigOffsetCalibration.h.

Member Typedef Documentation

◆ ChamberHistosMap

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

Definition at line 39 of file DTTTrigOffsetCalibration.h.

Constructor & Destructor Documentation

◆ DTTTrigOffsetCalibration()

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

Definition at line 37 of file DTTTrigOffsetCalibration.cc.

38  : theRecHits4DLabel_(pset.getParameter<InputTag>("recHits4DLabel")),
39  doTTrigCorrection_(pset.getUntrackedParameter<bool>("doT0SegCorrection", false)),
40  theCalibChamber_(pset.getUntrackedParameter<string>("calibChamber", "All")),
41  dbLabel_(pset.getUntrackedParameter<string>("dbLabel", "")) {
42  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Constructor called!";
43 
45  select_ = new DTSegmentSelector(pset, collector);
46 
47  // the root file which will contain the histos
48  string rootFileName = pset.getUntrackedParameter<string>("rootFileName", "DTT0SegHistos.root");
49  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
50  rootFile_->cd();
51 }

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

◆ ~DTTTrigOffsetCalibration()

DTTTrigOffsetCalibration::~DTTTrigOffsetCalibration ( )
override

Definition at line 62 of file DTTTrigOffsetCalibration.cc.

62  {
63  rootFile_->Close();
64  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Destructor called!";
65 }

References rootFile_.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 67 of file DTTTrigOffsetCalibration.cc.

67  {
68  rootFile_->cd();
69  DTChamberId chosenChamberId;
70 
71  if (theCalibChamber_ != "All") {
72  stringstream linestr;
73  int selWheel, selStation, selSector;
74  linestr << theCalibChamber_;
75  linestr >> selWheel >> selStation >> selSector;
76  chosenChamberId = DTChamberId(selWheel, selStation, selSector);
77  LogVerbatim("Calibration") << " chosen chamber " << chosenChamberId << endl;
78  }
79 
80  // Get the DT Geometry
81  ESHandle<DTGeometry> dtGeom;
82  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
83 
84  // Get the rechit collection from the event
86  event.getByLabel(theRecHits4DLabel_, all4DSegments);
87 
88  // Loop over segments by chamber
90  for (chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt) {
91  // Get the chamber from the setup
92  const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
93  LogTrace("Calibration") << "Chamber Id: " << *chamberIdIt;
94 
95  // Book histos
96  if (theT0SegHistoMap_.find(*chamberIdIt) == theT0SegHistoMap_.end()) {
97  bookHistos(*chamberIdIt);
98  }
99 
100  // Calibrate just the chosen chamber/s
101  if ((theCalibChamber_ != "All") && ((*chamberIdIt) != chosenChamberId))
102  continue;
103 
104  // Get the range for the corresponding ChamberId
105  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
106 
107  // Loop over the rechits of this DetUnit
108  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; ++segment) {
109  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
110  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
111 
112  if (!(*select_)(*segment, event, eventSetup))
113  continue;
114 
115  // Fill t0-seg values
116  if ((*segment).hasPhi()) {
117  //if( segment->phiSegment()->ist0Valid() ){
118  if ((segment->phiSegment()->t0()) != 0.00) {
119  (theT0SegHistoMap_[*chamberIdIt])[0]->Fill(segment->phiSegment()->t0());
120  }
121  }
122  if ((*segment).hasZed()) {
123  //if( segment->zSegment()->ist0Valid() ){
124  if ((segment->zSegment()->t0()) != 0.00) {
125  (theT0SegHistoMap_[*chamberIdIt])[1]->Fill(segment->zSegment()->t0());
126  }
127  }
128  } // DTRecSegment4DCollection::const_iterator segment
129  } // DTRecSegment4DCollection::id_iterator chamberIdIt
130 } // DTTTrigOffsetCalibration::analyze

References bookHistos(), relativeConstraints::chamber, DTGeometry::chamber(), edmPickEvents::event, HcalObjRepresent::Fill(), edm::EventSetup::get(), get, LogTrace, FastTimerService_cff::range, rootFile_, select_, theCalibChamber_, theRecHits4DLabel_, and theT0SegHistoMap_.

◆ beginRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file DTTTrigOffsetCalibration.cc.

53  {
54  if (doTTrigCorrection_) {
57  tTrigMap_ = &*tTrig;
58  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration]: TTrig version: " << tTrig->version() << endl;
59  }
60 }

References dbLabel_, doTTrigCorrection_, get, singleTopDQM_cfi::setup, dttriganalyzer_cfi::tTrig, and tTrigMap_.

◆ bookHistos()

void DTTTrigOffsetCalibration::bookHistos ( DTChamberId  chId)
private

Definition at line 184 of file DTTTrigOffsetCalibration.cc.

184  {
185  LogTrace("Calibration") << " Booking histos for Chamber: " << chId;
186 
187  // Compose the chamber name
188  std::string wheel = std::to_string(chId.wheel());
189  std::string station = std::to_string(chId.station());
190  std::string sector = std::to_string(chId.sector());
191 
192  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
193 
194  vector<TH1F*> histos;
195  // Note the order matters
196  histos.push_back(new TH1F(("hRPhiSegT0" + chHistoName).c_str(), "t0 from Phi segments", 500, -60., 60.));
197  if (chId.station() != 4)
198  histos.push_back(new TH1F(("hRZSegT0" + chHistoName).c_str(), "t0 from Z segments", 500, -60., 60.));
199 
200  theT0SegHistoMap_[chId] = histos;
201 }

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

Referenced by analyze().

◆ endJob()

void DTTTrigOffsetCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 132 of file DTTTrigOffsetCalibration.cc.

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

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

Member Data Documentation

◆ dbLabel_

std::string DTTTrigOffsetCalibration::dbLabel_
private

Definition at line 47 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun().

◆ doTTrigCorrection_

bool DTTTrigOffsetCalibration::doTTrigCorrection_
private

Definition at line 45 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().

◆ rootFile_

TFile* DTTTrigOffsetCalibration::rootFile_
private

◆ select_

DTSegmentSelector* DTTTrigOffsetCalibration::select_
private

Definition at line 42 of file DTTTrigOffsetCalibration.h.

Referenced by analyze(), and DTTTrigOffsetCalibration().

◆ theCalibChamber_

std::string DTTTrigOffsetCalibration::theCalibChamber_
private

Definition at line 46 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

◆ theRecHits4DLabel_

edm::InputTag DTTTrigOffsetCalibration::theRecHits4DLabel_
private

Definition at line 44 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

◆ theT0SegHistoMap_

ChamberHistosMap DTTTrigOffsetCalibration::theT0SegHistoMap_
private

Definition at line 51 of file DTTTrigOffsetCalibration.h.

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

◆ tTrigMap_

const DTTtrig* DTTTrigOffsetCalibration::tTrigMap_
private

Definition at line 50 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().

DTSuperLayerId
Definition: DTSuperLayerId.h:12
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DTTtrig
Definition: DTTtrig.h:68
DTTTrigOffsetCalibration::dbLabel_
std::string dbLabel_
Definition: DTTTrigOffsetCalibration.h:47
DTTTrigOffsetCalibration::theCalibChamber_
std::string theCalibChamber_
Definition: DTTTrigOffsetCalibration.h:46
DTTtrigRcd
Definition: DTTtrigRcd.h:5
relativeConstraints.station
station
Definition: relativeConstraints.py:67
dttriganalyzer_cfi.tTrig
tTrig
Definition: dttriganalyzer_cfi.py:11
DTChamber
Definition: DTChamber.h:24
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:46
DTTTrigOffsetCalibration::theRecHits4DLabel_
edm::InputTag theRecHits4DLabel_
Definition: DTTTrigOffsetCalibration.h:44
edm::Handle< DTRecSegment4DCollection >
edm::RangeMap::id_iterator
identifier iterator
Definition: RangeMap.h:130
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTGeometry::chamber
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
edm::ESHandle< DTGeometry >
DTTtrig::get
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
DTTTrigOffsetCalibration::rootFile_
TFile * rootFile_
Definition: DTTTrigOffsetCalibration.h:49
DTSegmentSelector
Definition: DTSegmentSelector.h:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
edmPickEvents.event
event
Definition: edmPickEvents.py:273
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
get
#define get
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
combine.histos
histos
Definition: combine.py:4
DTTTrigOffsetCalibration::bookHistos
void bookHistos(DTChamberId)
Definition: DTTTrigOffsetCalibration.cc:184
DTTTrigOffsetCalibration::theT0SegHistoMap_
ChamberHistosMap theT0SegHistoMap_
Definition: DTTTrigOffsetCalibration.h:51
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
dttriganalyzer_cfi.kFactor
kFactor
Definition: dttriganalyzer_cfi.py:7
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
DTTTrigOffsetCalibration::doTTrigCorrection_
bool doTTrigCorrection_
Definition: DTTTrigOffsetCalibration.h:45
CSCSkim_cfi.rootFileName
rootFileName
Definition: CSCSkim_cfi.py:9
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
DTTTrigOffsetCalibration::select_
DTSegmentSelector * select_
Definition: DTTTrigOffsetCalibration.h:42
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
DTTTrigOffsetCalibration::tTrigMap_
const DTTtrig * tTrigMap_
Definition: DTTTrigOffsetCalibration.h:50
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
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