CMS 3D CMS Logo

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

#include <DTResolutionAnalysisTask.h>

Inheritance diagram for DTResolutionAnalysisTask:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
 To reset the MEs. More...
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 BookHistograms. More...
 
void dqmBeginRun (const edm::Run &, const edm::EventSetup &) override
 BeginRun. More...
 
 DTResolutionAnalysisTask (const edm::ParameterSet &pset)
 Constructor. More...
 
 ~DTResolutionAnalysisTask () override
 Destructor. More...
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Private Member Functions

void bookHistos (DQMStore::IBooker &ibooker, DTSuperLayerId slId)
 
void fillHistos (DTSuperLayerId slId, float distExtr, float residual)
 

Private Attributes

edm::ESHandle< DTGeometrydtGeom
 
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL
 
int prescaleFactor
 
edm::EDGetTokenT< DTRecSegment4DCollectionrecHits4DToken_
 
int resetCycle
 
u_int32_t thePhiHitsCut
 
u_int32_t theZHitsCut
 
std::string topHistoFolder
 

Detailed Description

Definition at line 34 of file DTResolutionAnalysisTask.h.

Constructor & Destructor Documentation

DTResolutionAnalysisTask::DTResolutionAnalysisTask ( const edm::ParameterSet pset)

Constructor.

Definition at line 35 of file DTResolutionAnalysisTask.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and nanoDQM_cff::prescaleFactor.

35  {
36 
37  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask] Constructor called!" << endl;
38 
39  // the name of the 4D rec hits collection
40  recHits4DToken_ = consumes<DTRecSegment4DCollection>(
41  edm::InputTag(pset.getParameter<string>("recHits4DLabel")));
42 
43  prescaleFactor = pset.getUntrackedParameter<int>("diagnosticPrescale", 1);
44  resetCycle = pset.getUntrackedParameter<int>("ResetCycle", -1);
45  // top folder for the histograms in DQMStore
46  topHistoFolder = pset.getUntrackedParameter<string>("topHistoFolder","DT/02-Segments");
47 
48  thePhiHitsCut = pset.getUntrackedParameter<u_int32_t>("phiHitsCut",8);
49  theZHitsCut = pset.getUntrackedParameter<u_int32_t>("zHitsCut",4);
50 
51 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > recHits4DToken_
DTResolutionAnalysisTask::~DTResolutionAnalysisTask ( )
override

Destructor.

Definition at line 54 of file DTResolutionAnalysisTask.cc.

54  {
55 
56  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask] Destructor called!" << endl;
57 
58 }

Member Function Documentation

void DTResolutionAnalysisTask::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 105 of file DTResolutionAnalysisTask.cc.

References relativeConstraints::chamber, popcon2dropbox::copy(), funct::cos(), edm::HandleBase::isValid(), DTWireId::layerId(), DTRecSegment2D::specificRecHits(), DTLayer::specificTopology(), DTSuperLayerId::superlayer(), DTChamber::superLayer(), DTLayerId::superlayerId(), GeomDet::toGlobal(), GeomDet::toLocal(), DTWireId::wire(), DTTopology::wirePosition(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

105  {
106 
107  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask] Analyze #Run: " << event.id().run()
108  << " #Event: " << event.id().event() << endl;
109 
110 
111  // Get the 4D segment collection from the event
113  event.getByToken(recHits4DToken_, all4DSegments);
114 
115  // check the validity of the collection
116  if(!all4DSegments.isValid()) return;
117 
118  // Loop over all chambers containing a segment
119  DTRecSegment4DCollection::id_iterator chamberId;
120  for (chamberId = all4DSegments->id_begin();
121  chamberId != all4DSegments->id_end();
122  ++chamberId) {
123  // Get the range for the corresponding ChamerId
124  DTRecSegment4DCollection::range range = all4DSegments->get(*chamberId);
125 
126  // Get the chamber
127  const DTChamber* chamber = dtGeom->chamber(*chamberId);
128 
129  // Loop over the rechits of this ChamerId
130  for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
131  segment4D!=range.second;
132  ++segment4D) {
133 
134  // If Statio != 4 skip RecHits with dimension != 4
135  // For the Station 4 consider 2D RecHits
136  if((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
137  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask]***Warning: RecSegment dimension is not 4 but "
138  << (*segment4D).dimension() << "!" << endl;
139  continue;
140  } else if((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
141  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask]***Warning: RecSegment dimension is not 2 but "
142  << (*segment4D).dimension() << "!" << endl;
143  continue;
144  }
145 
146 
147  // Get all 1D RecHits at step 3 within the 4D segment
148  vector<DTRecHit1D> recHits1D_S3;
149 
150 
151  // Get 1D RecHits at Step 3 and select only events with
152  // 8 hits in phi and 4 hits in theta (if any)
153 
154  if((*segment4D).hasPhi()) { // has phi component
155  const DTChamberRecSegment2D* phiSeg = (*segment4D).phiSegment();
156  vector<DTRecHit1D> phiRecHits = phiSeg->specificRecHits();
157 
158  if(phiRecHits.size() < thePhiHitsCut) {
159  continue;
160  }
161  copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
162  } else {
163 
164  }
165 
166  if((*segment4D).hasZed()) {
167  const DTSLRecSegment2D* zSeg = (*segment4D).zSegment();
168  vector<DTRecHit1D> zRecHits = zSeg->specificRecHits();
169  if(zRecHits.size() < theZHitsCut) {
170 
171  continue;
172  }
173  copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
174  }
175 
176  // Loop over 1D RecHit inside 4D segment
177  for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
178  recHit1D != recHits1D_S3.end();
179  recHit1D++) {
180  const DTWireId wireId = (*recHit1D).wireId();
181 
182  // Get the layer and the wire position
183  const DTLayer* layer = chamber->superLayer(wireId.superlayerId())->layer(wireId.layerId());
184  float wireX = layer->specificTopology().wirePosition(wireId.wire());
185 
186  // Distance of the 1D rechit from the wire
187  float distRecHitToWire = fabs(wireX - (*recHit1D).localPosition().x());
188 
189  // Extrapolate the segment to the z of the wire
190 
191  // Get wire position in chamber RF
192  LocalPoint wirePosInLay(wireX,(*recHit1D).localPosition().y(),(*recHit1D).localPosition().z());
193  GlobalPoint wirePosGlob = layer->toGlobal(wirePosInLay);
194  LocalPoint wirePosInChamber = chamber->toLocal(wirePosGlob);
195 
196  // Segment position at Wire z in chamber local frame
197  LocalPoint segPosAtZWire = (*segment4D).localPosition()
198  + (*segment4D).localDirection()*wirePosInChamber.z()/cos((*segment4D).localDirection().theta());
199 
200  // Compute the distance of the segment from the wire
201  int sl = wireId.superlayer();
202 
203  double distSegmToWire = -1;
204  if(sl == 1 || sl == 3) {
205  // RPhi SL
206  distSegmToWire = fabs(wirePosInChamber.x() - segPosAtZWire.x());
207  } else if(sl == 2) {
208  // RZ SL
209  distSegmToWire = fabs(wirePosInChamber.y() - segPosAtZWire.y());
210  }
211 
212  if(distSegmToWire > 2.1)
213  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << " Warning: dist segment-wire: " << distSegmToWire << endl;
214 
215  double residual = distRecHitToWire - distSegmToWire;
216  // FIXME: Fill the histos
217  fillHistos(wireId.superlayerId(), distSegmToWire, residual);
218 
219  }// End of loop over 1D RecHit inside 4D segment
220  }// End of loop over the rechits of this ChamerId
221  }
222  // -----------------------------------------------------------------------------
223 }
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:65
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
def copy(args, dbName)
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
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::EDGetTokenT< DTRecSegment4DCollection > recHits4DToken_
bool isValid() const
Definition: HandleBase.h:74
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
int wire() const
Return the wire number.
Definition: DTWireId.h:56
int superlayer() const
Return the superlayer number (deprecated method name)
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
void fillHistos(DTSuperLayerId slId, float distExtr, float residual)
T x() const
Definition: PV3DBase.h:62
edm::ESHandle< DTGeometry > dtGeom
void DTResolutionAnalysisTask::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
override

To reset the MEs.

Definition at line 88 of file DTResolutionAnalysisTask.cc.

References trackerHits::histo, mps_fire::i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), genParticles_cff::map, and findQualityFiles::size.

89  {
90 
91  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionTask]: Begin of LS transition"<<endl;
92 
93  if(resetCycle != -1 && lumiSeg.id().luminosityBlock() % resetCycle == 0) {
94  for(map<DTSuperLayerId, vector<MonitorElement*> > ::const_iterator histo = histosPerSL.begin();
95  histo != histosPerSL.end();
96  histo++) {
97  int size = (*histo).second.size();
98  for(int i=0; i<size; i++){
99  (*histo).second[i]->Reset();
100  }
101  }
102  }
103 }
size
Write out results.
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL
void DTResolutionAnalysisTask::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &   
)
override

BookHistograms.

Definition at line 67 of file DTResolutionAnalysisTask.cc.

References bookHistos(), relativeConstraints::chamber, chambers, and DTChamberId::station().

69  {
70 
71  // Book the histograms
72  vector<const DTChamber*> chambers = dtGeom->chambers();
73  for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
74  chamber != chambers.end(); ++chamber) { // Loop over all chambers
75  DTChamberId dtChId = (*chamber)->id();
76  for(int sl = 1; sl <= 3; ++sl) { // Loop over SLs
77  if(dtChId.station() == 4 && sl == 2) continue;
78  const DTSuperLayerId dtSLId(dtChId,sl);
79  bookHistos(ibooker,dtSLId);
80  }
81  }
82 
83 }
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:102
void bookHistos(DQMStore::IBooker &ibooker, DTSuperLayerId slId)
int station() const
Return the station number.
Definition: DTChamberId.h:51
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
edm::ESHandle< DTGeometry > dtGeom
void DTResolutionAnalysisTask::bookHistos ( DQMStore::IBooker ibooker,
DTSuperLayerId  slId 
)
private

Definition at line 227 of file DTResolutionAnalysisTask.cc.

References DQMStore::IBooker::book1D(), plotFactory::histos, DTChamberId::sector(), DQMStore::IBooker::setCurrentFolder(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

227  {
228 
229  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << " Booking histos for SL: " << slId << endl;
230 
231  // Compose the chamber name
232  stringstream wheel; wheel << slId.wheel();
233  stringstream station; station << slId.station();
234  stringstream sector; sector << slId.sector();
235  stringstream superLayer; superLayer << slId.superlayer();
236 
237 
238  string slHistoName =
239  "_W" + wheel.str() +
240  "_St" + station.str() +
241  "_Sec" + sector.str() +
242  "_SL" + superLayer.str();
243 
244  ibooker.setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str() +
245  "/Sector" + sector.str() +
246  "/Station" + station.str());
247  // Create the monitor elements
248  vector<MonitorElement *> histos;
249  // Note the order matters
250  histos.push_back(ibooker.book1D("hResDist"+slHistoName,
251  "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
252  200, -0.4, 0.4));
253  histosPerSL[slId] = histos;
254 }
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL
int superlayer() const
Return the superlayer number (deprecated method name)
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 DTResolutionAnalysisTask::dqmBeginRun ( const edm::Run run,
const edm::EventSetup setup 
)
override

BeginRun.

Definition at line 60 of file DTResolutionAnalysisTask.cc.

References edm::EventSetup::get().

60  {
61 
62  // Get the DT Geometry
63  setup.get<MuonGeometryRecord>().get(dtGeom);
64 
65 }
T get() const
Definition: EventSetup.h:62
edm::ESHandle< DTGeometry > dtGeom
void DTResolutionAnalysisTask::fillHistos ( DTSuperLayerId  slId,
float  distExtr,
float  residual 
)
private

Definition at line 258 of file DTResolutionAnalysisTask.cc.

References plotFactory::histos.

260  {
261  vector<MonitorElement *> histos = histosPerSL[slId];
262  histos[0]->Fill(residual);
263 }
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL

Member Data Documentation

edm::ESHandle<DTGeometry> DTResolutionAnalysisTask::dtGeom
private

Definition at line 59 of file DTResolutionAnalysisTask.h.

std::map<DTSuperLayerId, std::vector<MonitorElement*> > DTResolutionAnalysisTask::histosPerSL
private

Definition at line 77 of file DTResolutionAnalysisTask.h.

int DTResolutionAnalysisTask::prescaleFactor
private

Definition at line 61 of file DTResolutionAnalysisTask.h.

edm::EDGetTokenT<DTRecSegment4DCollection> DTResolutionAnalysisTask::recHits4DToken_
private

Definition at line 68 of file DTResolutionAnalysisTask.h.

int DTResolutionAnalysisTask::resetCycle
private

Definition at line 62 of file DTResolutionAnalysisTask.h.

u_int32_t DTResolutionAnalysisTask::thePhiHitsCut
private

Definition at line 64 of file DTResolutionAnalysisTask.h.

u_int32_t DTResolutionAnalysisTask::theZHitsCut
private

Definition at line 65 of file DTResolutionAnalysisTask.h.

std::string DTResolutionAnalysisTask::topHistoFolder
private

Definition at line 80 of file DTResolutionAnalysisTask.h.