test
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 edm::EDConsumerBase

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
edm::EDGetTokenT
< DTRecSegment4DCollection
recHits4DToken_
 
int resetCycle
 
DQMStoretheDbe
 
u_int32_t thePhiHitsCut
 
u_int32_t theZHitsCut
 
std::string topHistoFolder
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- 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

Definition at line 32 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 dtDQMClient_cfg::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 ( )
virtual

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

Implements edm::EDAnalyzer.

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

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

To reset the MEs.

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file DTResolutionAnalysisTask.cc.

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

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

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

60  {
61 
62  // Get the DQM needed services
64  // theDbe->setCurrentFolder("DT/02-Segments");
65 
66  // Get the DT Geometry
67  setup.get<MuonGeometryRecord>().get(dtGeom);
68 
69  // Book the histograms
70  vector<const DTChamber*> chambers = dtGeom->chambers();
71  for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
72  chamber != chambers.end(); ++chamber) { // Loop over all chambers
73  DTChamberId dtChId = (*chamber)->id();
74  for(int sl = 1; sl <= 3; ++sl) { // Loop over SLs
75  if(dtChId.station() == 4 && sl == 2) continue;
76  const DTSuperLayerId dtSLId(dtChId,sl);
77  bookHistos(dtSLId);
78  }
79  }
80 
81 }
const T & get() const
Definition: EventSetup.h:55
int station() const
Return the station number.
Definition: DTChamberId.h:51
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 245 of file DTResolutionAnalysisTask.cc.

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

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

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 104 of file DTResolutionAnalysisTask.cc.

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

Definition at line 280 of file DTResolutionAnalysisTask.cc.

References mergeVDriftHistosByStation::histos.

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

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

Definition at line 67 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.

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.