CMS 3D CMS Logo

DTChamberEfficiency.cc
Go to the documentation of this file.
1 /******* \class DTEffAnalyzer *******
2  *
3  * Description:
4  *
5  * detailed description
6  *
7  * \author : Mario Pelliccioni, pellicci@cern.ch
8  * $date : 20/11/2008 16:50:57 CET $
9  *
10  * Modification:
11  *
12  *********************************/
13 
14 #include "DTChamberEfficiency.h"
15 
17 
21 
24 
27 
29 
31 
33 
38 
43 
44 #include <cmath>
45 
46 using namespace std;
47 using namespace edm;
48 
50  // Get the debug parameter for verbose output
51  debug = pSet.getUntrackedParameter<bool>("debug", false);
52 
53  LogVerbatim("DTDQM|DTMonitorModule|DTChamberEfficiency") << "DTChamberEfficiency: constructor called";
54 
55  // service parameters
56  ParameterSet serviceParameters = pSet.getParameter<ParameterSet>("ServiceParameters");
57  theService = new MuonServiceProxy(serviceParameters, consumesCollector());
58 
59  theTracksLabel_ = pSet.getParameter<InputTag>("TrackCollection");
60  theTracksToken_ = consumes<reco::TrackCollection>(theTracksLabel_);
61 
62  theMaxChi2 = static_cast<unsigned int>(pSet.getParameter<double>("theMaxChi2"));
63  theNSigma = pSet.getParameter<double>("theNSigma");
64  theMinNrec = static_cast<int>(pSet.getParameter<double>("theMinNrec"));
65 
66  labelRPCRecHits = pSet.getParameter<InputTag>("theRPCRecHits");
67 
68  thedt4DSegments = pSet.getParameter<InputTag>("dt4DSegments");
69  thecscSegments = pSet.getParameter<InputTag>("cscSegments");
70 
71  edm::ConsumesCollector iC = consumesCollector();
72 
73  theMeasurementExtractor = new MuonDetLayerMeasurements(
74  thedt4DSegments, thecscSegments, labelRPCRecHits, InputTag(), InputTag(), iC, true, false, false, false);
75 
76  theNavigationType = pSet.getParameter<string>("NavigationType");
77 
78  theEstimator = new Chi2MeasurementEstimator(theMaxChi2, theNSigma);
79 }
80 
82  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency") << "DTChamberEfficiency: destructor called";
83 
84  // free memory
85  delete theService;
86  delete theMeasurementExtractor;
87  delete theEstimator;
88 }
89 
91 
93  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency") << "DTChamberEfficiency: booking histos";
94 
95  // Create the monitor elements
96  ibooker.setCurrentFolder("DT/05-ChamberEff/Task");
97 
98  for (int wheel = -2; wheel <= 2; wheel++) {
99  vector<MonitorElement*> histos;
100 
101  stringstream wheel_str;
102  wheel_str << wheel;
103 
104  histos.push_back(ibooker.book2D(
105  "hCountSectVsChamb_All_W" + wheel_str.str(), "Countings for wheel " + wheel_str.str(), 14, 1., 15., 4, 1., 5.));
106 
107  histos.push_back(ibooker.book2D(
108  "hCountSectVsChamb_Qual_W" + wheel_str.str(), "Countings for wheel " + wheel_str.str(), 14, 1., 15., 4, 1., 5.));
109 
110  histos.push_back(ibooker.book2D(
111  "hExtrapSectVsChamb_W" + wheel_str.str(), "Extrapolations for wheel " + wheel_str.str(), 14, 1., 15., 4, 1., 5.));
112 
113  histosPerW.push_back(histos);
114  }
115 
116  return;
117 }
118 
119 void DTChamberEfficiency::analyze(const Event& event, const EventSetup& eventSetup) {
120  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency")
121  << "--- [DTChamberEfficiency] Event analysed #Run: " << event.id().run() << " #Event: " << event.id().event()
122  << endl;
123 
124  theService->update(eventSetup);
125  theMeasurementExtractor->setEvent(event);
126 
127  //Read tracks from event
129  event.getByToken(theTracksToken_, tracks);
130 
131  if (tracks.isValid()) { // check the validity of the collection
132 
133  const edm::ESHandle<GlobalTrackingGeometry>& globalTrackingGeometry = theService->trackingGeometry();
134  const MagneticField* magneticField = theService->magneticField().product();
135 
136  //loop over the muons
137  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
138  reco::TransientTrack trans_track(*track, magneticField, globalTrackingGeometry);
139  const int recHitsize = (int)trans_track.recHitsSize();
140  if (recHitsize < theMinNrec)
141  continue;
142 
143  // printout the DT rechits used by the track
144  if (debug) {
145  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency") << "--- New track" << endl;
146  set<DTChamberId> chAlrUsed;
147  for (trackingRecHit_iterator rHit = trans_track.recHitsBegin(); rHit != trans_track.recHitsEnd(); ++rHit) {
148  DetId rHitid = (*rHit)->geographicalId();
149  if (!(rHitid.det() == DetId::Muon && rHitid.subdetId() == MuonSubdetId::DT))
150  continue;
151  DTChamberId wId(rHitid.rawId());
152  if (chAlrUsed.find(wId) != chAlrUsed.end())
153  continue;
154  chAlrUsed.insert(wId);
155  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency") << " " << wId << endl;
156  }
157  }
158 
159  // Get the layer on which the seed relies
160  DetId id = trans_track.track().innerDetId();
161  const DetLayer* initialLayer = theService->detLayerGeometry()->idToLayer(id);
162 
163  TrajectoryStateOnSurface init_fs = trans_track.innermostMeasurementState();
164  const FreeTrajectoryState* init_fs_free = init_fs.freeState();
165 
166  //get the list of compatible layers
167  vector<const DetLayer*> layer_list =
168  compatibleLayers(*theService->muonNavigationSchool(), initialLayer, *init_fs_free, alongMomentum);
169  vector<const DetLayer*> layer_list_2 =
170  compatibleLayers(*theService->muonNavigationSchool(), initialLayer, *init_fs_free, oppositeToMomentum);
171 
172  layer_list.insert(layer_list.end(), layer_list_2.begin(), layer_list_2.end());
173 
174  set<DTChamberId> alreadyCheckedCh;
175 
176  //loop over the list of compatible layers
177  for (int i = 0; i < (int)layer_list.size(); i++) {
178  //propagate the track to the i-th layer
179  TrajectoryStateOnSurface tsos = propagator()->propagate(init_fs, layer_list.at(i)->surface());
180  if (!tsos.isValid())
181  continue;
182 
183  //determine the chambers kinematically compatible with the track on the i-th layer
184  vector<DetWithState> dss = layer_list.at(i)->compatibleDets(tsos, *propagator(), *theEstimator);
185 
186  if (dss.empty())
187  continue;
188 
189  // get the first det (it's the most compatible)
190  const DetWithState detWithState = dss.front();
191  const DetId idDetLay = detWithState.first->geographicalId();
192 
193  // check if this is a DT and the track has the needed quality
194  if (!chamberSelection(idDetLay, trans_track))
195  continue;
196 
197  DTChamberId DTid = (DTChamberId)idDetLay;
198 
199  // check if the chamber has already been counted
200  if (alreadyCheckedCh.find(DTid) != alreadyCheckedCh.end())
201  continue;
202  alreadyCheckedCh.insert(DTid);
203 
204  // get the compatible measurements
205  MeasurementContainer detMeasurements_initial = theMeasurementExtractor->measurements(
206  layer_list.at(i), detWithState.first, detWithState.second, *theEstimator, event);
207  LogTrace("DTDQM|DTMonitorModule|DTChamberEfficiency")
208  << " chamber: " << DTid << " has: " << detMeasurements_initial.size() << " comp. meas." << endl;
209 
210  //we want to be more picky about the quality of the segments:
211  //exclude the segments with less than 12 hits
212  MeasurementContainer detMeasurements = segQualityCut(detMeasurements_initial);
213 
214  // get the histos for this chamber
215  vector<MonitorElement*> histos = histosPerW[DTid.wheel() + 2];
216  // fill them
217  if (!detMeasurements_initial.empty())
218  histos[0]->Fill(DTid.sector(), DTid.station(), 1.);
219  if (!detMeasurements.empty())
220  histos[1]->Fill(DTid.sector(), DTid.station(), 1.);
221  histos[2]->Fill(DTid.sector(), DTid.station(), 1.);
222  }
223  }
224  } else {
225  LogInfo("DTDQM|DTMonitorModule|DTChamberEfficiency")
226  << "[DTChamberEfficiency] Collection: " << theTracksLabel_ << " is not valid!" << endl;
227  }
228  return;
229 }
230 
231 bool DTChamberEfficiency::chamberSelection(const DetId& idDetLay, reco::TransientTrack& trans_track) const {
232  //check that we have a muon and that is a DT detector
233  if (!(idDetLay.det() == DetId::Muon && idDetLay.subdetId() == MuonSubdetId::DT))
234  return false;
235 
236  if (trans_track.recHitsSize() == 2)
237  if (trans_track.recHit(0)->geographicalId() == idDetLay || trans_track.recHit(1)->geographicalId() == idDetLay)
238  return false;
239 
240  return true;
241 }
242 
245 
246  for (MeasurementContainer::const_iterator mescont_Itr = seg_list.begin(); mescont_Itr != seg_list.end();
247  ++mescont_Itr) {
248  //get the rechits of the segment
249  TransientTrackingRecHit::ConstRecHitContainer recHit_list = mescont_Itr->recHit()->transientHits();
250 
251  //loop over the rechits and get the number of hits
252  int nhit_seg(0);
253  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator recList_Itr = recHit_list.begin();
254  recList_Itr != recHit_list.end();
255  ++recList_Itr) {
256  nhit_seg += (int)(*recList_Itr)->transientHits().size();
257  }
258 
259  DTChamberId tmpId = (DTChamberId)mescont_Itr->recHit()->hit()->geographicalId();
260 
261  if (tmpId.station() < 4 && nhit_seg >= 12)
262  result.push_back(*mescont_Itr);
263  if (tmpId.station() == 4 && nhit_seg >= 8)
264  result.push_back(*mescont_Itr);
265  }
266 
267  return result;
268 }
269 
270 vector<const DetLayer*> DTChamberEfficiency::compatibleLayers(const NavigationSchool& navigationSchool,
271  const DetLayer* initialLayer,
272  const FreeTrajectoryState& fts,
273  PropagationDirection propDir) {
274  vector<const DetLayer*> detLayers;
275 
276  if (theNavigationType == "Standard") {
277  // ask for compatible layers
278  detLayers = navigationSchool.compatibleLayers(*initialLayer, fts, propDir);
279  // I have to fit by hand the first layer until the seedTSOS is defined on the first rechit layer
280  // In fact the first layer is not returned by initialLayer->compatibleLayers.
281 
282  detLayers.insert(detLayers.begin(), initialLayer);
283 
284  } else if (theNavigationType == "Direct") {
285  DirectMuonNavigation navigation(ESHandle<MuonDetLayerGeometry>(&*theService->detLayerGeometry()));
286  detLayers = navigation.compatibleLayers(fts, propDir);
287  } else
288  LogError("DTDQM|DTMonitorModule|DTChamberEfficiency") << "No Properly Navigation Selected!!" << endl;
289 
290  return detLayers;
291 }
292 
294  return theService->propagator("SteppingHelixPropagatorAny");
295 }
296 
297 // Local Variables:
298 // show-trailing-whitespace: t
299 // truncate-lines: t
300 // End:
DTChamberEfficiency::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DTChamberEfficiency.cc:92
Chi2MeasurementEstimator.h
dtChamberEfficiency_cfi.theMaxChi2
theMaxChi2
Definition: dtChamberEfficiency_cfi.py:10
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
DTChamberEfficiency::chamberSelection
bool chamberSelection(const DetId &idDetLay, reco::TransientTrack &trans_track) const
Definition: DTChamberEfficiency.cc:231
FreeTrajectoryState.h
MessageLogger.h
SteppingHelixPropagator.h
DetLayer
Definition: DetLayer.h:21
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
edm::Run
Definition: Run.h:45
MuonDetLayerMeasurements
Definition: MuonDetLayerMeasurements.h:41
edm
HLT enums.
Definition: AlignableModifier.h:19
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
edm::LogInfo
Definition: MessageLogger.h:254
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
oppositeToMomentum
Definition: PropagationDirection.h:4
TransientTrackingRecHit.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
NavigationSchool
Definition: NavigationSchool.h:18
TransientTrack.h
reco::TransientTrack::recHitsBegin
trackingRecHit_iterator recHitsBegin() const
first iterator to RecHits
Definition: TransientTrack.h:126
edm::Handle< reco::TrackCollection >
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:15
dtChamberEfficiency_cfi.theMinNrec
theMinNrec
Definition: dtChamberEfficiency_cfi.py:12
DirectMuonNavigation
Definition: DirectMuonNavigation.h:20
MeasurementContainer
std::vector< TrajectoryMeasurement > MeasurementContainer
Definition: RPCRecHitFilter.h:55
DetId
Definition: DetId.h:17
DTChamberEfficiency::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: DTChamberEfficiency.cc:119
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
debug
#define debug
Definition: HDRShower.cc:19
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
DTChamberEfficiency::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DTChamberEfficiency.cc:90
createJobs.theNSigma
theNSigma
Definition: createJobs.py:313
DTChamberEfficiency::DTChamberEfficiency
DTChamberEfficiency(const edm::ParameterSet &pset)
Definition: DTChamberEfficiency.cc:49
reco::TransientTrack::recHitsEnd
trackingRecHit_iterator recHitsEnd() const
last iterator to RecHits
Definition: TransientTrack.h:128
Chi2MeasurementEstimator_cfi.Chi2MeasurementEstimator
Chi2MeasurementEstimator
Definition: Chi2MeasurementEstimator_cfi.py:5
edm::ESHandle< GlobalTrackingGeometry >
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
reco::TransientTrack::recHitsSize
size_t recHitsSize() const
number of RecHits
Definition: TransientTrack.h:132
RefToBase.h
DTChamberEfficiency::~DTChamberEfficiency
~DTChamberEfficiency() override
Definition: DTChamberEfficiency.cc:81
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
reco::TransientTrack::recHit
TrackingRecHitRef recHit(size_t i) const
get n-th recHit
Definition: TransientTrack.h:130
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DirectMuonNavigation::compatibleLayers
std::vector< const DetLayer * > compatibleLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
Definition: DirectMuonNavigation.cc:30
edm::LogVerbatim
Definition: MessageLogger.h:297
reco::Track::innerDetId
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
DTChamberEfficiency::propagator
edm::ESHandle< Propagator > propagator() const
Definition: DTChamberEfficiency.cc:293
DTRecSegment4D.h
DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: RPCRecHitFilter.h:58
TransientTrackRecord.h
NavigationSchool::compatibleLayers
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&... args) const
Returns all layers compatible.
Definition: NavigationSchool.h:41
MuonSubdetId.h
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
combine.histos
histos
Definition: combine.py:4
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DTChamberEfficiency.h
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
reco::TransientTrack
Definition: TransientTrack.h:19
reco::TransientTrack::track
const Track & track() const
Definition: TransientTrack.h:117
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
DetId.h
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
MuonServiceProxy.h
DetLayer.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
mps_fire.result
result
Definition: mps_fire.py:303
DetId::Muon
Definition: DetId.h:26
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
event
Definition: event.py:1
GlobalTrackingGeometry.h
edm::Event
Definition: Event.h:73
MagneticField
Definition: MagneticField.h:19
DTChamberEfficiency::segQualityCut
MeasurementContainer segQualityCut(const MeasurementContainer &seg_list) const
Definition: DTChamberEfficiency.cc:243
event
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of "!*" before the partial wildcard feature was incorporated). The per-event "cost" of each negative criterion with multiple relevant triggers is about the same as ! *was in the past
DirectMuonNavigation.h
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
alongMomentum
Definition: PropagationDirection.h:4
DTChamberEfficiency::compatibleLayers
std::vector< const DetLayer * > compatibleLayers(const NavigationSchool &navigationSchool, const DetLayer *initialLayer, const FreeTrajectoryState &fts, PropagationDirection propDir)
Definition: DTChamberEfficiency.cc:270
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
reco::TransientTrack::innermostMeasurementState
TrajectoryStateOnSurface innermostMeasurementState() const
Definition: TransientTrack.h:88