CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
void beginJob ()
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 
 DTVDriftSegmentCalibration (const edm::ParameterSet &pset)
 
void endJob ()
 
virtual ~DTVDriftSegmentCalibration ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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

Date:
2010/11/19 14:02:08
Revision:
1.2
Author
A. Vilela Pereira

Definition at line 24 of file DTVDriftSegmentCalibration.h.

Member Typedef Documentation

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

Definition at line 37 of file DTVDriftSegmentCalibration.h.

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

Definition at line 38 of file DTVDriftSegmentCalibration.h.

Constructor & Destructor Documentation

Definition at line 36 of file DTVDriftSegmentCalibration.cc.

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

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

Definition at line 56 of file DTVDriftSegmentCalibration.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 61 of file DTVDriftSegmentCalibration.cc.

References bookHistos(), DTChamberId, HcalObjRepresent::Fill(), edm::EventSetup::get(), LogTrace, and GeomDet::toGlobal().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file DTVDriftSegmentCalibration.cc.

50  {
51  TH1::SetDefaultSumw2(true);
52 }
void DTVDriftSegmentCalibration::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file DTVDriftSegmentCalibration.cc.

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

Definition at line 151 of file DTVDriftSegmentCalibration.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 130 of file DTVDriftSegmentCalibration.cc.

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

Member Data Documentation

TFile* DTVDriftSegmentCalibration::rootFile_
private

Definition at line 47 of file DTVDriftSegmentCalibration.h.

Referenced by DTVDriftSegmentCalibration().

DTSegmentSelector DTVDriftSegmentCalibration::select_
private

Definition at line 41 of file DTVDriftSegmentCalibration.h.

std::string DTVDriftSegmentCalibration::theCalibChamber_
private

Definition at line 45 of file DTVDriftSegmentCalibration.h.

edm::InputTag DTVDriftSegmentCalibration::theRecHits4DLabel_
private

Definition at line 43 of file DTVDriftSegmentCalibration.h.

ChamberHistosMapTH1F DTVDriftSegmentCalibration::theVDriftHistoMapTH1F_
private

Definition at line 48 of file DTVDriftSegmentCalibration.h.

ChamberHistosMapTH2F DTVDriftSegmentCalibration::theVDriftHistoMapTH2F_
private

Definition at line 49 of file DTVDriftSegmentCalibration.h.