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
 
std::string theRecHits4DLabel
 
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)
 
- 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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTResolutionAnalysisTask::~DTResolutionAnalysisTask ( )
virtual

Destructor.

Definition at line 53 of file DTResolutionAnalysisTask.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 111 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().

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

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

86  {
87 
88  edm::LogVerbatim ("DTDQM|DTMonitorModule|DTResolutionAnalysisTask") << "[DTResolutionTask]: Begin of LS transition"<<endl;
89 
90  if(resetCycle != -1 && lumiSeg.id().luminosityBlock() % resetCycle == 0) {
91  for(map<DTSuperLayerId, vector<MonitorElement*> > ::const_iterator histo = histosPerSL.begin();
92  histo != histosPerSL.end();
93  histo++) {
94  int size = (*histo).second.size();
95  for(int i=0; i<size; i++){
96  (*histo).second[i]->Reset();
97  }
98  }
99  }
100 }
int i
Definition: DBlmapReader.cc:9
tuple histo
Definition: trackerHits.py:12
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 59 of file DTResolutionAnalysisTask.cc.

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

59  {
60 
61  // Get the DQM needed services
63  // theDbe->setCurrentFolder("DT/02-Segments");
64 
65  // Get the DT Geometry
66  setup.get<MuonGeometryRecord>().get(dtGeom);
67 
68  // Book the histograms
69  vector<DTChamber*> chambers = dtGeom->chambers();
70  for(vector<DTChamber*>::const_iterator chamber = chambers.begin();
71  chamber != chambers.end(); ++chamber) { // Loop over all chambers
72  DTChamberId dtChId = (*chamber)->id();
73  for(int sl = 1; sl <= 3; ++sl) { // Loop over SLs
74  if(dtChId.station() == 4 && sl == 2) continue;
75  const DTSuperLayerId dtSLId(dtChId,sl);
76  bookHistos(dtSLId);
77  }
78  }
79 
80 }
static char chambers[TOTALCHAMBERS][20]
Definition: ReadPGInfo.cc:243
const T & get() const
Definition: EventSetup.h:55
int station() const
Return the station number.
Definition: DTChamberId.h:53
void bookHistos(DTSuperLayerId slId)
edm::ESHandle< DTGeometry > dtGeom
void DTResolutionAnalysisTask::bookHistos ( DTSuperLayerId  slId)
private

Definition at line 244 of file DTResolutionAnalysisTask.cc.

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

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

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 103 of file DTResolutionAnalysisTask.cc.

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

Definition at line 279 of file DTResolutionAnalysisTask.cc.

References mergeVDriftHistosByStation::histos.

281  {
282  vector<MonitorElement *> histos = histosPerSL[slId];
283  histos[0]->Fill(residual);
284  //FIXME: 2D plot removed to reduce the # of ME
285  // histos[1]->Fill(distExtr, residual);
286 
287 }
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 73 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.

std::string DTResolutionAnalysisTask::theRecHits4DLabel
private

Definition at line 64 of file DTResolutionAnalysisTask.h.

std::string DTResolutionAnalysisTask::topHistoFolder
private

Definition at line 76 of file DTResolutionAnalysisTask.h.