CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTResolutionAnalysisTask Class Reference

#include <DTResolutionAnalysisTask.h>

Inheritance diagram for DTResolutionAnalysisTask:
edm::EDAnalyzer

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup)
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 To reset the MEs. More...
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 BeginRun. More...
 
 DTResolutionAnalysisTask (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob ()
 Endjob. More...
 
virtual ~DTResolutionAnalysisTask ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

void bookHistos (DTSuperLayerId slId)
 
void fillHistos (DTSuperLayerId slId, float distExtr, float residual)
 

Private Attributes

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

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
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 32 of file DTResolutionAnalysisTask.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 38 of file DTResolutionAnalysisTask.cc.

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

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

Destructor.

Definition at line 56 of file DTResolutionAnalysisTask.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 114 of file DTResolutionAnalysisTask.cc.

References filterCSVwithJSON::copy, funct::cos(), edm::HandleBase::isValid(), DTWireId::layerId(), DTRecSegment2D::specificRecHits(), DTLayer::specificTopology(), DTChamber::superLayer(), DTSuperLayerId::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().

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

To reset the MEs.

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file DTResolutionAnalysisTask.cc.

References interpolateCardsSimple::histo, i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), python.multivaluedict::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 }
int i
Definition: DBlmapReader.cc:9
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL
tuple size
Write out results.
void DTResolutionAnalysisTask::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file DTResolutionAnalysisTask.cc.

References bookHistos(), chambers, edm::EventSetup::get(), cppFunctionSkipper::operator, and DTChamberId::station().

62  {
63 
64  // Get the DQM needed services
66  // theDbe->setCurrentFolder("DT/02-Segments");
67 
68  // Get the DT Geometry
69  setup.get<MuonGeometryRecord>().get(dtGeom);
70 
71  // Book the histograms
72  vector<DTChamber*> chambers = dtGeom->chambers();
73  for(vector<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(dtSLId);
80  }
81  }
82 
83 }
const T & get() const
Definition: EventSetup.h:55
int station() const
Return the station number.
Definition: DTChamberId.h:53
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
void bookHistos(DTSuperLayerId slId)
edm::ESHandle< DTGeometry > dtGeom
void DTResolutionAnalysisTask::bookHistos ( DTSuperLayerId  slId)
private

Definition at line 247 of file DTResolutionAnalysisTask.cc.

References mergeVDriftHistosByStation::histos, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), and DTChamberId::wheel().

247  {
248 
249  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << " Booking histos for SL: " << slId << endl;
250 
251  // Compose the chamber name
252  stringstream wheel; wheel << slId.wheel();
253  stringstream station; station << slId.station();
254  stringstream sector; sector << slId.sector();
255  stringstream superLayer; superLayer << slId.superlayer();
256 
257 
258  string slHistoName =
259  "_W" + wheel.str() +
260  "_St" + station.str() +
261  "_Sec" + sector.str() +
262  "_SL" + superLayer.str();
263 
264  theDbe->setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str() +
265  "/Sector" + sector.str() +
266  "/Station" + station.str());
267  // Create the monitor elements
268  vector<MonitorElement *> histos;
269  // Note hte order matters
270  histos.push_back(theDbe->book1D("hResDist"+slHistoName,
271  "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
272  200, -0.4, 0.4));
273  //FIXME: 2D plot removed to reduce the # of ME
274 // histos.push_back(theDbe->book2D("hResDistVsDist"+slHistoName,
275 // "Residuals on the distance (cm) from wire (rec_hit - segm_extr) vs distance (cm)",
276 // 100, 0, 2.5, 200, -0.4, 0.4));
277  histosPerSL[slId] = histos;
278 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL
int superlayer() const
Return the superlayer number (deprecated method name)
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 setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void DTResolutionAnalysisTask::endJob ( void  )
virtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 106 of file DTResolutionAnalysisTask.cc.

106  {
107 
108  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionAnalysisTask] endjob called!"<<endl;
109 
110 }
void DTResolutionAnalysisTask::fillHistos ( DTSuperLayerId  slId,
float  distExtr,
float  residual 
)
private

Definition at line 282 of file DTResolutionAnalysisTask.cc.

References mergeVDriftHistosByStation::histos.

284  {
285  vector<MonitorElement *> histos = histosPerSL[slId];
286  histos[0]->Fill(residual);
287  //FIXME: 2D plot removed to reduce the # of ME
288  // histos[1]->Fill(distExtr, residual);
289 
290 }
std::map< DTSuperLayerId, std::vector< MonitorElement * > > histosPerSL

Member Data Documentation

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

Definition at line 58 of file DTResolutionAnalysisTask.h.

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

Definition at line 76 of file DTResolutionAnalysisTask.h.

int DTResolutionAnalysisTask::prescaleFactor
private

Definition at line 60 of file DTResolutionAnalysisTask.h.

int DTResolutionAnalysisTask::resetCycle
private

Definition at line 61 of file DTResolutionAnalysisTask.h.

DQMStore* DTResolutionAnalysisTask::theDbe
private

Definition at line 56 of file DTResolutionAnalysisTask.h.

u_int32_t DTResolutionAnalysisTask::thePhiHitsCut
private

Definition at line 63 of file DTResolutionAnalysisTask.h.

std::string DTResolutionAnalysisTask::theRecHits4DLabel
private

Definition at line 67 of file DTResolutionAnalysisTask.h.

u_int32_t DTResolutionAnalysisTask::theZHitsCut
private

Definition at line 64 of file DTResolutionAnalysisTask.h.

std::string DTResolutionAnalysisTask::topHistoFolder
private

Definition at line 79 of file DTResolutionAnalysisTask.h.