CMS 3D CMS Logo

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

#include <DTVDriftSegmentCalibration.h>

Inheritance diagram for DTVDriftSegmentCalibration:
edm::EDAnalyzer edm::EDConsumerBase

Classes

class  DTVDriftSegmentCalibration
 

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
 
 ~DTVDriftSegmentCalibration () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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

TFile * rootFile_
 
DTSegmentSelector select_
 
std::string theCalibChamber_
 
edm::InputTag theRecHits4DLabel_
 
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
 
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
 

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

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

Author
A. Vilela Pereira

Definition at line 22 of file DTVDriftSegmentCalibration.h.

Member Typedef Documentation

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

Definition at line 35 of file DTVDriftSegmentCalibration.h.

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

Definition at line 36 of file DTVDriftSegmentCalibration.h.

Constructor & Destructor Documentation

Definition at line 34 of file DTVDriftSegmentCalibration.cc.

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

34  :
35  select_(pset),
36  theRecHits4DLabel_(pset.getParameter<InputTag>("recHits4DLabel")),
37  //writeVDriftDB_(pset.getUntrackedParameter<bool>("writeVDriftDB", false)),
38  theCalibChamber_(pset.getUntrackedParameter<string>("calibChamber", "All")) {
39 
40  LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Constructor called!";
41 
42  // the root file which will contain the histos
43  string rootFileName = pset.getUntrackedParameter<string>("rootFileName","DTVDriftHistos.root");
44  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
45  rootFile_->cd();
46 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTVDriftSegmentCalibration::~DTVDriftSegmentCalibration ( )
override

Definition at line 54 of file DTVDriftSegmentCalibration.cc.

References rootFile_.

54  {
55  rootFile_->Close();
56  LogVerbatim("Calibration") << "[DTVDriftSegmentCalibration] Destructor called!";
57 }

Member Function Documentation

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

Definition at line 59 of file DTVDriftSegmentCalibration.cc.

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

59  {
60  rootFile_->cd();
61 
62  // Get the DT Geometry
63  ESHandle<DTGeometry> dtGeom;
64  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
65 
66  // Get the rechit collection from the event
68  event.getByLabel(theRecHits4DLabel_, all4DSegments);
69 
70  DTChamberId chosenChamberId;
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  // Loop over segments by chamber
80  DTRecSegment4DCollection::id_iterator chamberIdIt;
81  for(chamberIdIt = all4DSegments->id_begin(); chamberIdIt != all4DSegments->id_end(); ++chamberIdIt){
82 
83  // Calibrate just the chosen chamber/s
84  if((theCalibChamber_ != "All") && ((*chamberIdIt) != chosenChamberId)) continue;
85 
86  // Book histos
87  if(theVDriftHistoMapTH1F_.find(*chamberIdIt) == theVDriftHistoMapTH1F_.end()){
88  LogTrace("Calibration") << " Booking histos for Chamber: " << *chamberIdIt;
89  bookHistos(*chamberIdIt);
90  }
91 
92  // Get the chamber from the setup
93  const DTChamber* chamber = dtGeom->chamber(*chamberIdIt);
94  // Get the range for the corresponding ChamberId
95  DTRecSegment4DCollection::range range = all4DSegments->get((*chamberIdIt));
96  // Loop over the rechits of this DetUnit
97  for(DTRecSegment4DCollection::const_iterator segment = range.first;
98  segment != range.second; ++segment){
99 
100 
101  LogTrace("Calibration") << "Segment local pos (in chamber RF): " << (*segment).localPosition()
102  << "\nSegment global pos: " << chamber->toGlobal((*segment).localPosition());
103 
104  if( !select_(*segment, event, eventSetup) ) continue;
105 
106  // Fill v-drift values
107  if( (*segment).hasPhi() ) {
108  //if( segment->phiSegment()->ist0Valid() ){
109  double segmentVDrift = segment->phiSegment()->vDrift();
110  if( segmentVDrift != 0.00 ){
111  (theVDriftHistoMapTH1F_[*chamberIdIt])[0]->Fill(segmentVDrift);
112  (theVDriftHistoMapTH2F_[*chamberIdIt])[0]->Fill(segment->localPosition().x(),segmentVDrift);
113  (theVDriftHistoMapTH2F_[*chamberIdIt])[1]->Fill(segment->localPosition().y(),segmentVDrift);
114  }
115  }
116  // Probably not meaningful
117  if( (*segment).hasZed() ){
118  //if( segment->zSegment()->ist0Valid() ){
119  double segmentVDrift = segment->zSegment()->vDrift();
120  if( segmentVDrift != 0.00 ){
121  (theVDriftHistoMapTH1F_[*chamberIdIt])[1]->Fill(segmentVDrift);
122  }
123  }
124  } // DTRecSegment4DCollection::const_iterator segment
125  } // DTRecSegment4DCollection::id_iterator chamberIdIt
126 } // DTVDriftSegmentCalibration::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:99
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
void DTVDriftSegmentCalibration::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 48 of file DTVDriftSegmentCalibration.cc.

48  {
49  TH1::SetDefaultSumw2(true);
50 }
void DTVDriftSegmentCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
override

Definition at line 52 of file DTVDriftSegmentCalibration.cc.

52 {}
void DTVDriftSegmentCalibration::bookHistos ( DTChamberId  chId)
private

Definition at line 149 of file DTVDriftSegmentCalibration.cc.

References DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, theVDriftHistoMapTH1F_, theVDriftHistoMapTH2F_, DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

Referenced by analyze().

149  {
150 
151  // Compose the chamber name
152  stringstream wheel; wheel << chId.wheel();
153  stringstream station; station << chId.station();
154  stringstream sector; sector << chId.sector();
155 
156  string chHistoName =
157  "_W" + wheel.str() +
158  "_St" + station.str() +
159  "_Sec" + sector.str();
160 
161  vector<TH1F*> histosTH1F;
162  histosTH1F.push_back(new TH1F(("hRPhiVDriftCorr" + chHistoName).c_str(), "v-drift corr. from Phi segments", 200, -0.4, 0.4));
163  if(chId.station() != 4) histosTH1F.push_back(new TH1F(("hRZVDriftCorr" + chHistoName).c_str(), "v-drift corr. from Z segments", 200, -0.4, 0.4));
164 
165  vector<TH2F*> histosTH2F;
166  histosTH2F.push_back(new TH2F(("hRPhiVDriftCorrVsSegmPosX" + chHistoName).c_str(), "v-drift corr. vs. segment x position", 250, -125., 125., 200, -0.4, 0.4));
167  histosTH2F.push_back(new TH2F(("hRPhiVDriftCorrVsSegmPosY" + chHistoName).c_str(), "v-drift corr. vs. segment y position", 250, -125., 125., 200, -0.4, 0.4));
168  //if(chId.station() != 4) ...
169 
170  theVDriftHistoMapTH1F_[chId] = histosTH1F;
171  theVDriftHistoMapTH2F_[chId] = histosTH2F;
172 }
ChamberHistosMapTH1F theVDriftHistoMapTH1F_
ChamberHistosMapTH2F theVDriftHistoMapTH2F_
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 DTVDriftSegmentCalibration::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 128 of file DTVDriftSegmentCalibration.cc.

References rootFile_, theVDriftHistoMapTH1F_, and theVDriftHistoMapTH2F_.

Referenced by o2olib.O2ORunMgr::executeJob().

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

Member Data Documentation

TFile* DTVDriftSegmentCalibration::rootFile_
private
DTSegmentSelector DTVDriftSegmentCalibration::select_
private

Definition at line 39 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

std::string DTVDriftSegmentCalibration::theCalibChamber_
private

Definition at line 43 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

edm::InputTag DTVDriftSegmentCalibration::theRecHits4DLabel_
private

Definition at line 41 of file DTVDriftSegmentCalibration.h.

Referenced by analyze().

ChamberHistosMapTH1F DTVDriftSegmentCalibration::theVDriftHistoMapTH1F_
private

Definition at line 46 of file DTVDriftSegmentCalibration.h.

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

ChamberHistosMapTH2F DTVDriftSegmentCalibration::theVDriftHistoMapTH2F_
private

Definition at line 47 of file DTVDriftSegmentCalibration.h.

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