CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
DTVDriftSegmentCalibration Class Reference

#include <DTVDriftSegmentCalibration.h>

Inheritance diagram for DTVDriftSegmentCalibration:
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 beginJob () override
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 DTVDriftSegmentCalibration (const edm::ParameterSet &pset)
 
void endJob () override
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 ~DTVDriftSegmentCalibration () 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
 
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 Types

typedef std::map< DTChamberId, std::vector< TH1F * > > ChamberHistosMapTH1F
 
typedef std::map< DTChamberId, std::vector< TH2F * > > ChamberHistosMapTH2F
 

Private Member Functions

void bookHistos (DTChamberId)
 

Private Attributes

const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
TFile * rootFile_
 
DTSegmentSelectorselect_
 
const std::string theCalibChamber_
 
const edm::EDGetTokenT< DTRecSegment4DCollectiontheRecHits4DToken_
 
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
 
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
 

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

Produces histograms from v-drift computation in segment fit to be used for v-drift calibration

Author
A. Vilela Pereira

Definition at line 25 of file DTVDriftSegmentCalibration.h.

Member Typedef Documentation

◆ ChamberHistosMapTH1F

typedef std::map<DTChamberId, std::vector<TH1F*> > DTVDriftSegmentCalibration::ChamberHistosMapTH1F
private

Definition at line 39 of file DTVDriftSegmentCalibration.h.

◆ ChamberHistosMapTH2F

typedef std::map<DTChamberId, std::vector<TH2F*> > DTVDriftSegmentCalibration::ChamberHistosMapTH2F
private

Definition at line 40 of file DTVDriftSegmentCalibration.h.

Constructor & Destructor Documentation

◆ DTVDriftSegmentCalibration()

DTVDriftSegmentCalibration::DTVDriftSegmentCalibration ( const edm::ParameterSet pset)

Definition at line 32 of file DTVDriftSegmentCalibration.cc.

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

33  : theRecHits4DToken_(consumes<DTRecSegment4DCollection>(pset.getParameter<InputTag>("recHits4DLabel"))),
34  //writeVDriftDB_(pset.getUntrackedParameter<bool>("writeVDriftDB", false)),
35  theCalibChamber_(pset.getUntrackedParameter<string>("calibChamber", "All")),
37  LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Constructor called!";
38 
40  select_ = new DTSegmentSelector(pset, collector);
41  // the root file which will contain the histos
42  string rootFileName = pset.getUntrackedParameter<string>("rootFileName", "DTVDriftHistos.root");
43  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
44  rootFile_->cd();
45 }
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_

◆ ~DTVDriftSegmentCalibration()

DTVDriftSegmentCalibration::~DTVDriftSegmentCalibration ( )
override

Definition at line 51 of file DTVDriftSegmentCalibration.cc.

References rootFile_.

51  {
52  rootFile_->Close();
53  LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Destructor called!";
54 }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 56 of file DTVDriftSegmentCalibration.cc.

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

56  {
57  rootFile_->cd();
58 
59  // Get the DT Geometry
60  ESHandle<DTGeometry> dtGeom;
61  dtGeom = eventSetup.getHandle(dtGeomToken_);
62 
63  // Get the rechit collection from the event
64  const Handle<DTRecSegment4DCollection>& all4DSegments = event.getHandle(theRecHits4DToken_);
65 
66  DTChamberId chosenChamberId;
67  if (theCalibChamber_ != "All") {
68  stringstream linestr;
69  int selWheel, selStation, selSector;
70  linestr << theCalibChamber_;
71  linestr >> selWheel >> selStation >> selSector;
72  chosenChamberId = DTChamberId(selWheel, selStation, selSector);
73  LogVerbatim("Calibration") << " Chosen chamber: " << chosenChamberId << endl;
74  }
75  // Loop over segments by chamber
77  for (chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt) {
78  // Calibrate just the chosen chamber/s
79  if ((theCalibChamber_ != "All") && ((*chamberIdIt) != chosenChamberId))
80  continue;
81 
82  // Book histos
83  if (theVDriftHistoMapTH1F_.find(*chamberIdIt) == theVDriftHistoMapTH1F_.end()) {
84  LogTrace("Calibration") << " Booking histos for Chamber: " << *chamberIdIt;
85  bookHistos(*chamberIdIt);
86  }
87 
88  // Get the chamber from the setup
89  const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
90  // Get the range for the corresponding ChamberId
91  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
92  // Loop over the rechits of this DetUnit
93  for (DTRecSegment4DCollection::const_iterator segment = range.first; segment != range.second; ++segment) {
94  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
95  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
96 
97  if (!(*select_)(*segment, event, eventSetup))
98  continue;
99 
100  // Fill v-drift values
101  if ((*segment).hasPhi()) {
102  //if( segment->phiSegment()->ist0Valid() ){
103  double segmentVDrift = segment->phiSegment()->vDrift();
104  if (segmentVDrift != 0.00) {
105  (theVDriftHistoMapTH1F_[*chamberIdIt])[0]->Fill(segmentVDrift);
106  (theVDriftHistoMapTH2F_[*chamberIdIt])[0]->Fill(segment->localPosition().x(), segmentVDrift);
107  (theVDriftHistoMapTH2F_[*chamberIdIt])[1]->Fill(segment->localPosition().y(), segmentVDrift);
108  }
109  }
110  // Probably not meaningful
111  if ((*segment).hasZed()) {
112  //if( segment->zSegment()->ist0Valid() ){
113  double segmentVDrift = segment->zSegment()->vDrift();
114  if (segmentVDrift != 0.00) {
115  (theVDriftHistoMapTH1F_[*chamberIdIt])[1]->Fill(segmentVDrift);
116  }
117  }
118  } // DTRecSegment4DCollection::const_iterator segment
119  } // DTRecSegment4DCollection::id_iterator chamberIdIt
120 } // DTVDriftSegmentCalibration::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::EDGetTokenT< DTRecSegment4DCollection > theRecHits4DToken_
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90

◆ beginJob()

void DTVDriftSegmentCalibration::beginJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 47 of file DTVDriftSegmentCalibration.cc.

47 { TH1::SetDefaultSumw2(true); }

◆ beginRun()

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

Definition at line 49 of file DTVDriftSegmentCalibration.cc.

49 {}

◆ bookHistos()

void DTVDriftSegmentCalibration::bookHistos ( DTChamberId  chId)
private

Definition at line 147 of file DTVDriftSegmentCalibration.cc.

References nano_mu_digi_cff::sector, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, theVDriftHistoMapTH1F_, theVDriftHistoMapTH2F_, to_string(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by analyze().

147  {
148  // Compose the chamber name
152 
153  string chHistoName = "_W" + wheel + "_St" + station + "_Sec" + sector;
154 
155  vector<TH1F*> histosTH1F;
156  histosTH1F.push_back(
157  new TH1F(("hRPhiVDriftCorr" + chHistoName).c_str(), "v-drift corr. from Phi segments", 200, -0.4, 0.4));
158  if (chId.station() != 4)
159  histosTH1F.push_back(
160  new TH1F(("hRZVDriftCorr" + chHistoName).c_str(), "v-drift corr. from Z segments", 200, -0.4, 0.4));
161 
162  vector<TH2F*> histosTH2F;
163  histosTH2F.push_back(new TH2F(("hRPhiVDriftCorrVsSegmPosX" + chHistoName).c_str(),
164  "v-drift corr. vs. segment x position",
165  250,
166  -125.,
167  125.,
168  200,
169  -0.4,
170  0.4));
171  histosTH2F.push_back(new TH2F(("hRPhiVDriftCorrVsSegmPosY" + chHistoName).c_str(),
172  "v-drift corr. vs. segment y position",
173  250,
174  -125.,
175  125.,
176  200,
177  -0.4,
178  0.4));
179  //if(chId.station() != 4) ...
180 
181  theVDriftHistoMapTH1F_[chId] = histosTH1F;
182  theVDriftHistoMapTH2F_[chId] = histosTH2F;
183 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
static std::string to_string(const XMLCh *ch)
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49

◆ endJob()

void DTVDriftSegmentCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 122 of file DTVDriftSegmentCalibration.cc.

References rootFile_, theVDriftHistoMapTH1F_, and theVDriftHistoMapTH2F_.

Referenced by o2olib.O2ORunMgr::executeJob().

122  {
123  rootFile_->cd();
124 
125  LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Writing histos to file!" << endl;
126 
127  for (ChamberHistosMapTH1F::const_iterator itChHistos = theVDriftHistoMapTH1F_.begin();
128  itChHistos != theVDriftHistoMapTH1F_.end();
129  ++itChHistos) {
130  vector<TH1F*>::const_iterator itHistTH1F = (*itChHistos).second.begin();
131  vector<TH1F*>::const_iterator itHistTH1F_end = (*itChHistos).second.end();
132  for (; itHistTH1F != itHistTH1F_end; ++itHistTH1F)
133  (*itHistTH1F)->Write();
134 
135  vector<TH2F*>::const_iterator itHistTH2F = theVDriftHistoMapTH2F_[(*itChHistos).first].begin();
136  vector<TH2F*>::const_iterator itHistTH2F_end = theVDriftHistoMapTH2F_[(*itChHistos).first].end();
137  for (; itHistTH2F != itHistTH2F_end; ++itHistTH2F)
138  (*itHistTH2F)->Write();
139  }
140 
141  /*if(writeVDriftDB_){
142  // ...
143  }*/
144 }
Log< level::Info, true > LogVerbatim
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
ChamberHistosMapTH2F theVDriftHistoMapTH2F_

◆ endRun()

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

Definition at line 35 of file DTVDriftSegmentCalibration.h.

35 {};

Member Data Documentation

◆ dtGeomToken_

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

Definition at line 53 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

◆ rootFile_

TFile* DTVDriftSegmentCalibration::rootFile_
private

◆ select_

DTSegmentSelector* DTVDriftSegmentCalibration::select_
private

Definition at line 43 of file DTVDriftSegmentCalibration.h.

Referenced by analyze(), and DTVDriftSegmentCalibration().

◆ theCalibChamber_

const std::string DTVDriftSegmentCalibration::theCalibChamber_
private

Definition at line 47 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

◆ theRecHits4DToken_

const edm::EDGetTokenT<DTRecSegment4DCollection> DTVDriftSegmentCalibration::theRecHits4DToken_
private

Definition at line 45 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

◆ theVDriftHistoMapTH1F_

ChamberHistosMapTH1F DTVDriftSegmentCalibration::theVDriftHistoMapTH1F_
private

Definition at line 50 of file DTVDriftSegmentCalibration.h.

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

◆ theVDriftHistoMapTH2F_

ChamberHistosMapTH2F DTVDriftSegmentCalibration::theVDriftHistoMapTH2F_
private

Definition at line 51 of file DTVDriftSegmentCalibration.h.

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