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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

No description available.

Author
A. Vilela Pereira

Definition at line 27 of file DTTTrigOffsetCalibration.h.

Member Typedef Documentation

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

Definition at line 39 of file DTTTrigOffsetCalibration.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file DTTTrigOffsetCalibration.cc.

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::getUntrackedParameter(), rootFile_, DTAnalyzerDetailed_cfi::rootFileName, and select_.

37  :
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 
43  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration] Constructor called!";
44 
46  select_ = new DTSegmentSelector(pset,collector);
47 
48  // the root file which will contain the histos
49  string rootFileName = pset.getUntrackedParameter<string>("rootFileName","DTT0SegHistos.root");
50  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
51  rootFile_->cd();
52 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
DTTTrigOffsetCalibration::~DTTTrigOffsetCalibration ( )
override

Definition at line 63 of file DTTTrigOffsetCalibration.cc.

References rootFile_.

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

Member Function Documentation

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

Definition at line 68 of file DTTTrigOffsetCalibration.cc.

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

68  {
69  rootFile_->cd();
70  DTChamberId chosenChamberId;
71 
72  if(theCalibChamber_ != "All") {
73  stringstream linestr;
74  int selWheel, selStation, selSector;
75  linestr << theCalibChamber_;
76  linestr >> selWheel >> selStation >> selSector;
77  chosenChamberId = DTChamberId(selWheel, selStation, selSector);
78  LogVerbatim("Calibration") << " chosen chamber " << chosenChamberId << endl;
79  }
80 
81  // Get the DT Geometry
82  ESHandle<DTGeometry> dtGeom;
83  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
84 
85  // Get the rechit collection from the event
87  event.getByLabel(theRecHits4DLabel_, all4DSegments);
88 
89  // Loop over segments by chamber
91  for(chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt){
92 
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)) continue;
104 
105  // Get the range for the corresponding ChamberId
106  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
107 
108  // Loop over the rechits of this DetUnit
109  for(DTRecSegment4DCollection::const_iterator segment = range.first;
110  segment != range.second; ++segment){
111 
112  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
113  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
114 
115  if( !(*select_)(*segment, event, eventSetup) ) 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
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:117
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
identifier iterator
Definition: RangeMap.h:135
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#define LogTrace(id)
T get() const
Definition: EventSetup.h:71
void DTTTrigOffsetCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
override

Definition at line 54 of file DTTTrigOffsetCalibration.cc.

References dbLabel_, doTTrigCorrection_, edm::EventSetup::get(), tTrigMap_, and DTTtrig::version().

54  {
56  ESHandle<DTTtrig> tTrig;
57  setup.get<DTTtrigRcd>().get(dbLabel_,tTrig);
58  tTrigMap_ = &*tTrig;
59  LogVerbatim("Calibration") << "[DTTTrigOffsetCalibration]: TTrig version: " << tTrig->version() << endl;
60  }
61 }
const std::string & version() const
access version
Definition: DTTtrig.cc:231
T get() const
Definition: EventSetup.h:71
void DTTTrigOffsetCalibration::bookHistos ( DTChamberId  chId)
private

Definition at line 181 of file DTTTrigOffsetCalibration.cc.

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

Referenced by analyze().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 134 of file DTTTrigOffsetCalibration.cc.

References doTTrigCorrection_, DTTtrig::get(), DTAnalyzerDetailed_cfi::kFactor, DTTimeUnits::ns, rootFile_, DTTtrig::set(), DTChamberId::station(), theT0SegHistoMap_, 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(); ++itChHistos){
140  for(vector<TH1F*>::const_iterator itHist = (*itChHistos).second.begin();
141  itHist != (*itChHistos).second.end(); ++itHist) (*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(); ++itChHistos){
149  DTChamberId chId = itChHistos->first;
150  // Get SuperLayerId's for each ChamberId
151  vector<DTSuperLayerId> slIds;
152  slIds.push_back(DTSuperLayerId(chId,1));
153  slIds.push_back(DTSuperLayerId(chId,3));
154  if(chId.station() != 4) slIds.push_back(DTSuperLayerId(chId,2));
155 
156  for(vector<DTSuperLayerId>::const_iterator itSl = slIds.begin(); itSl != slIds.end(); ++itSl){
157  // Get old values from DB
158  float ttrigMean = 0;
159  float ttrigSigma = 0;
160  float kFactor = 0;
161  tTrigMap_->get(*itSl,ttrigMean,ttrigSigma,kFactor,DTTimeUnits::ns);
162  //FIXME: verify if values make sense
163  // Set new values
164  float ttrigMeanNew = ttrigMean;
165  float ttrigSigmaNew = ttrigSigma;
166  float t0SegMean = (itSl->superLayer() != 2)?itChHistos->second[0]->GetMean():itChHistos->second[1]->GetMean();
167 
168  float kFactorNew = (kFactor*ttrigSigma+t0SegMean)/ttrigSigma;
169 
170  tTrig->set(*itSl,ttrigMeanNew,ttrigSigmaNew,kFactorNew,DTTimeUnits::ns);
171  }
172  }
173  LogVerbatim("Calibration")<< "[DTTTrigOffsetCalibration] Writing ttrig object to DB!" << endl;
174  // Write the object to DB
175  string tTrigRecord = "DTTtrigRcd";
176  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);
177  }
178 }
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:248
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:85
int station() const
Return the station number.
Definition: DTChamberId.h:51
static void writeToDB(std::string record, T *payload)

Member Data Documentation

std::string DTTTrigOffsetCalibration::dbLabel_
private

Definition at line 47 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun().

bool DTTTrigOffsetCalibration::doTTrigCorrection_
private

Definition at line 45 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().

TFile* DTTTrigOffsetCalibration::rootFile_
private
DTSegmentSelector* DTTTrigOffsetCalibration::select_
private

Definition at line 42 of file DTTTrigOffsetCalibration.h.

Referenced by analyze(), and DTTTrigOffsetCalibration().

std::string DTTTrigOffsetCalibration::theCalibChamber_
private

Definition at line 46 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

edm::InputTag DTTTrigOffsetCalibration::theRecHits4DLabel_
private

Definition at line 44 of file DTTTrigOffsetCalibration.h.

Referenced by analyze().

ChamberHistosMap DTTTrigOffsetCalibration::theT0SegHistoMap_
private

Definition at line 51 of file DTTTrigOffsetCalibration.h.

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

const DTTtrig* DTTTrigOffsetCalibration::tTrigMap_
private

Definition at line 50 of file DTTTrigOffsetCalibration.h.

Referenced by beginRun(), and endJob().