CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripHitEfficiencyWorker Class Reference
Inheritance diagram for SiStripHitEfficiencyWorker:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Classes

struct  EffME1
 
struct  EffTkMap
 

Public Member Functions

 SiStripHitEfficiencyWorker (const edm::ParameterSet &conf)
 
 ~SiStripHitEfficiencyWorker () override=default
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr
< DQMEDAnalyzerGlobalCache
initializeGlobalCache (edm::ParameterSet const &)
 

Private Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob ()
 
void bookHistograms (DQMStore::IBooker &booker, const edm::Run &run, const edm::EventSetup &setup) override
 
void endJob ()
 
void fillForTraj (const TrajectoryAtInvalidHit &tm, const TrackerTopology *tTopo, const TrackerGeometry *tkgeom, const StripClusterParameterEstimator &stripCPE, const SiStripQuality &stripQuality, const DetIdCollection &fedErrorIds, const edm::Handle< edm::DetSetVector< SiStripRawDigi >> &commonModeDigis, const edmNew::DetSetVector< SiStripCluster > &theClusters, int bunchCrossing, float instLumi, float PU, bool highPurity)
 

Private Attributes

bool addCommonMode_
 
bool addLumi_
 
std::set< uint32_t > badModules_
 
int bunchX_
 
const edm::ESGetToken
< Chi2MeasurementEstimatorBase,
TrackingComponentsRecord
chi2EstimatorToken_
 
unsigned int clusterMatchingMethod_
 
const edm::EDGetTokenT
< edmNew::DetSetVector
< SiStripCluster > > 
clusters_token_
 
float clusterTracjDist_
 
const edm::EDGetTokenT
< reco::TrackCollection
combinatorialTracks_token_
 
const edm::EDGetTokenT
< edm::DetSetVector
< SiStripRawDigi > > 
commonModeToken_
 
bool cutOnTracks_
 
bool DEBUG_
 
const edm::EDGetTokenT
< DetIdCollection
digis_token_
 
int events
 
int EventTrackCKF
 
EffME1 h_allLayer
 
MonitorElementh_bx
 
EffME1 h_goodLayer
 
std::vector< MonitorElement * > h_hotcold
 
MonitorElementh_instLumi
 
EffME1 h_layer
 
std::vector< EffME1h_layer_vsBx
 
std::vector< EffME1h_layer_vsCM
 
std::vector< EffME1h_layer_vsLumi
 
std::vector< EffME1h_layer_vsPU
 
EffTkMap h_module
 
MonitorElementh_PU
 
std::vector< MonitorElement * > h_resolution
 
unsigned int layers_
 
const edm::ESGetToken
< MagneticField,
IdealMagneticFieldRecord
magFieldToken_
 
const edm::ESGetToken
< MeasurementTracker,
CkfComponentsRecord
measTrackerToken_
 
unsigned int nTEClayers_
 
const edm::ESGetToken
< Propagator,
TrackingComponentsRecord
propagatorToken_
 
float resXSig_
 
const edm::EDGetTokenT
< LumiScalersCollection
scalerToken_
 
bool showRings_
 
bool showTOB6TEC9_
 
const edm::ESGetToken
< StripClusterParameterEstimator,
TkStripCPERecord
stripCPEToken_
 
const edm::ESGetToken
< SiStripQuality,
SiStripQualityRcd
stripQualityToken_
 
float stripsApvEdge_
 
const edm::ESGetToken
< TkDetMap, TrackerTopologyRcd
tkDetMapToken_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tkGeomToken_
 
const edm::EDGetTokenT
< MeasurementTrackerEvent
trackerEvent_token_
 
unsigned int trackMultiplicityCut_
 
const edm::EDGetTokenT
< std::vector< Trajectory > > 
trajectories_token_
 
const edm::EDGetTokenT
< TrajTrackAssociationCollection
trajTrackAsso_token_
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 
bool useAllHitsFromTracksWithMissingHits_
 
bool useFirstMeas_
 
bool useLastMeas_
 
bool useOnlyHighPurityTracks_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 60 of file SiStripHitEfficiencyWorker.cc.

Constructor & Destructor Documentation

SiStripHitEfficiencyWorker::SiStripHitEfficiencyWorker ( const edm::ParameterSet conf)
explicit

Definition at line 179 of file SiStripHitEfficiencyWorker.cc.

180  : scalerToken_(consumes<LumiScalersCollection>(conf.getParameter<edm::InputTag>("lumiScalers"))),
183  consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("combinatorialTracks"))),
184  trajectories_token_(consumes<std::vector<Trajectory>>(conf.getParameter<edm::InputTag>("trajectories"))),
185  trajTrackAsso_token_(consumes<TrajTrackAssociationCollection>(conf.getParameter<edm::InputTag>("trajectories"))),
187  consumes<edmNew::DetSetVector<SiStripCluster>>(conf.getParameter<edm::InputTag>("siStripClusters"))),
188  digis_token_(consumes<DetIdCollection>(conf.getParameter<edm::InputTag>("siStripDigis"))),
189  trackerEvent_token_(consumes<MeasurementTrackerEvent>(conf.getParameter<edm::InputTag>("trackerEvent"))),
192  stripCPEToken_(esConsumes(edm::ESInputTag{"", "StripCPEfromTrackAngle"})),
197  propagatorToken_(esConsumes(edm::ESInputTag{"", "PropagatorWithMaterial"})),
198  tkDetMapToken_(esConsumes<edm::Transition::BeginRun>()),
199  layers_(conf.getParameter<int>("Layer")),
200  DEBUG_(conf.getUntrackedParameter<bool>("Debug", false)),
201  addLumi_(conf.getUntrackedParameter<bool>("addLumi", false)),
202  addCommonMode_(conf.getUntrackedParameter<bool>("addCommonMode", false)),
203  cutOnTracks_(conf.getParameter<bool>("cutOnTracks")),
204  trackMultiplicityCut_(conf.getParameter<unsigned int>("trackMultiplicity")),
205  useFirstMeas_(conf.getParameter<bool>("useFirstMeas")),
206  useLastMeas_(conf.getParameter<bool>("useLastMeas")),
207  useAllHitsFromTracksWithMissingHits_(conf.getParameter<bool>("useAllHitsFromTracksWithMissingHits")),
208  clusterMatchingMethod_(conf.getParameter<int>("ClusterMatchingMethod")),
209  resXSig_(conf.getParameter<double>("ResXSig")),
210  clusterTracjDist_(conf.getParameter<double>("ClusterTrajDist")),
211  stripsApvEdge_(conf.getParameter<double>("StripsApvEdge")),
212  useOnlyHighPurityTracks_(conf.getParameter<bool>("UseOnlyHighPurityTracks")),
213  bunchX_(conf.getUntrackedParameter<int>("BunchCrossing", 0)),
214  showRings_(conf.getUntrackedParameter<bool>("ShowRings", false)),
215  showTOB6TEC9_(conf.getUntrackedParameter<bool>("ShowTOB6TEC9", false)) {
216  nTEClayers_ = (showRings_ ? 7 : 9); // number of rings or wheels
217 
218  const std::string badModulesFile = conf.getUntrackedParameter<std::string>("BadModulesFile", "");
219  if (!badModulesFile.empty()) {
220  std::ifstream badModules_file(badModulesFile);
221  uint32_t badmodule_detid;
222  int mods, fiber1, fiber2, fiber3;
223  if (badModules_file.is_open()) {
225  while (getline(badModules_file, line)) {
226  if (badModules_file.eof())
227  continue;
228  std::stringstream ss(line);
229  ss >> badmodule_detid >> mods >> fiber1 >> fiber2 >> fiber3;
230  if (badmodule_detid != 0 && mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
231  badModules_.insert(badmodule_detid);
232  }
233  badModules_file.close();
234  }
235  }
236  if (!badModules_.empty())
237  LogDebug("SiStripHitEfficiencyWorker") << "Remove additionnal bad modules from the analysis: ";
238  for (const auto badMod : badModules_) {
239  LogDebug("SiStripHitEfficiencyWorker") << " " << badMod;
240  }
241 }
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measTrackerToken_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
const edm::EDGetTokenT< DetIdCollection > digis_token_
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > stripCPEToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2EstimatorToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
tuple mods
Definition: mps_splice.py:43
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
#define LogDebug(id)
SiStripHitEfficiencyWorker::~SiStripHitEfficiencyWorker ( )
overridedefault

Member Function Documentation

void SiStripHitEfficiencyWorker::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprivatevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 321 of file SiStripHitEfficiencyWorker.cc.

References addCommonMode_, addLumi_, anyDirection, SplitLinear::begin, edm::EventBase::bunchCrossing(), chi2EstimatorToken_, clusters_token_, combinatorialTracks_token_, commonModeToken_, cutOnTracks_, digis_token_, dataset::end, events, EventTrackCKF, dqm::impl::MonitorElement::Fill(), fillForTraj(), edm::Event::getByToken(), edm::EventSetup::getData(), h_bx, h_instLumi, h_PU, LogDebug, magField, magFieldToken_, measTrackerToken_, combine::missing, HLT_FULL_cff::propagator, propagatorToken_, relval_steps::PU, scalerToken_, stripCPEToken_, stripQualityToken_, SiStripSubdetector::TEC, tkGeomToken_, createJobs::tmp, trackerEvent_token_, trackMultiplicityCut_, trajectories_token_, trajTrackAsso_token_, tTopoToken_, useAllHitsFromTracksWithMissingHits_, useFirstMeas_, and useLastMeas_.

321  {
322  const auto tTopo = &es.getData(tTopoToken_);
323 
324  // bool DEBUG_ = false;
325 
326  LogDebug("SiStripHitEfficiencyWorker") << "beginning analyze from HitEff";
327 
328  // Step A: Get Inputs
329 
330  // Luminosity informations
332  float instLumi = 0;
333  float PU = 0;
334  if (addLumi_) {
335  e.getByToken(scalerToken_, lumiScalers);
336  if (lumiScalers->begin() != lumiScalers->end()) {
337  instLumi = lumiScalers->begin()->instantLumi();
338  PU = lumiScalers->begin()->pileup();
339  }
340  }
341  h_bx->Fill(e.bunchCrossing());
342  h_instLumi->Fill(instLumi);
343  h_PU->Fill(PU);
344 
346  if (addCommonMode_)
347  e.getByToken(commonModeToken_, commonModeDigis);
348 
351 
352  edm::Handle<std::vector<Trajectory>> TrajectoryCollectionCKF;
353  e.getByToken(trajectories_token_, TrajectoryCollectionCKF);
354 
355  edm::Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
356  e.getByToken(trajTrackAsso_token_, trajTrackAssociationHandle);
357 
359  e.getByToken(clusters_token_, theClusters);
360 
361  edm::Handle<DetIdCollection> fedErrorIds;
362  e.getByToken(digis_token_, fedErrorIds);
363 
364  edm::Handle<MeasurementTrackerEvent> measurementTrackerEvent;
365  e.getByToken(trackerEvent_token_, measurementTrackerEvent);
366 
367  const auto tkgeom = &es.getData(tkGeomToken_);
368  const auto& stripcpe = es.getData(stripCPEToken_);
369  const auto& stripQuality = es.getData(stripQualityToken_);
370  const auto& magField = es.getData(magFieldToken_);
371  const auto& measTracker = es.getData(measTrackerToken_);
372  const auto& chi2Estimator = es.getData(chi2EstimatorToken_);
373  const auto& prop = es.getData(propagatorToken_);
374 
375  ++events;
376 
377  // Tracking
378  LogDebug("SiStripHitEfficiencyWorker") << "number ckf tracks found = " << tracksCKF->size();
379  if (!tracksCKF->empty()) {
380  if (cutOnTracks_ && (tracksCKF->size() >= trackMultiplicityCut_))
381  return;
382  if (cutOnTracks_)
383  LogDebug("SiStripHitEfficiencyWorker")
384  << "starting checking good event with < " << trackMultiplicityCut_ << " tracks";
385 
386  ++EventTrackCKF;
387 
388  // actually should do a loop over all the tracks in the event here
389 
390  // Looping over traj-track associations to be able to get traj & track informations
391  for (const auto& trajTrack : *trajTrackAssociationHandle) {
392  // for each track, fill some variables such as number of hits and momentum
393 
394  const bool highPurity = trajTrack.val->quality(reco::TrackBase::TrackQuality::highPurity);
395  auto TMeas = trajTrack.key->measurements();
396 
397  const bool hasMissingHits = std::any_of(std::begin(TMeas), std::end(TMeas), [](const auto& tm) {
398  return tm.recHit()->getType() == TrackingRecHit::Type::missing;
399  });
400 
401  // Loop on each measurement and take it into consideration
402  //--------------------------------------------------------
403  for (auto itm = TMeas.cbegin(); itm != TMeas.cend(); ++itm) {
404  const auto theInHit = (*itm).recHit();
405 
406  LogDebug("SiStripHitEfficiencyWorker") << "theInHit is valid = " << theInHit->isValid();
407 
408  unsigned int iidd = theInHit->geographicalId().rawId();
409 
410  unsigned int TKlayers = ::checkLayer(iidd, tTopo);
411  LogDebug("SiStripHitEfficiencyWorker") << "TKlayer from trajectory: " << TKlayers << " from module = " << iidd
412  << " matched/stereo/rphi = " << ((iidd & 0x3) == 0) << "/"
413  << ((iidd & 0x3) == 1) << "/" << ((iidd & 0x3) == 2);
414 
415  // Test first and last points of the trajectory
416  // the list of measurements starts from outer layers !!! This could change -> should add a check
417  if ((!useFirstMeas_ && (itm == (TMeas.end() - 1))) || (!useLastMeas_ && (itm == (TMeas.begin()))) ||
418  // In case of missing hit in the track, check whether to use the other hits or not.
419  (!useAllHitsFromTracksWithMissingHits_ && hasMissingHits &&
420  theInHit->getType() != TrackingRecHit::Type::missing))
421  continue;
422  // If Trajectory measurement from TOB 6 or TEC 9, skip it because it's always valid they are filled later
423  if (TKlayers == 10 || TKlayers == 22) {
424  LogDebug("SiStripHitEfficiencyWorker") << "skipping original TM for TOB 6 or TEC 9";
425  continue;
426  }
427 
428  std::vector<TrajectoryAtInvalidHit> TMs;
429 
430  // Make AnalyticalPropagat // TODO where to save these?or to use in TAVH constructor
432 
433  // for double sided layers check both sensors--if no hit was found on either sensor surface,
434  // the trajectory measurements only have one invalid hit entry on the matched surface
435  // so get the TrajectoryAtInvalidHit for both surfaces and include them in the study
436  if (::isDoubleSided(iidd, tTopo) && ((iidd & 0x3) == 0)) {
437  // do hit eff check twice--once for each sensor
438  //add a TM for each surface
439  TMs.emplace_back(*itm, tTopo, tkgeom, propagator, 1);
440  TMs.emplace_back(*itm, tTopo, tkgeom, propagator, 2);
441  } else if (::isDoubleSided(iidd, tTopo) && (!::check2DPartner(iidd, TMeas))) {
442  // if only one hit was found the trajectory measurement is on that sensor surface, and the other surface from
443  // the matched layer should be added to the study as well
444  TMs.emplace_back(*itm, tTopo, tkgeom, propagator, 1);
445  TMs.emplace_back(*itm, tTopo, tkgeom, propagator, 2);
446  LogDebug("SiStripHitEfficiencyWorker") << " found a hit with a missing partner";
447  } else {
448  //only add one TM for the single surface and the other will be added in the next iteration
449  TMs.emplace_back(*itm, tTopo, tkgeom, propagator);
450  }
451 
453  //Now check for tracks at TOB6 and TEC9
454 
455  // to make sure we only propagate on the last TOB5 hit check the next entry isn't also in TOB5
456  // to avoid bias, make sure the TOB5 hit is valid (an invalid hit on TOB5 could only exist with a valid hit on TOB6)
457  const auto nextId = (itm + 1 != TMeas.end()) ? (itm + 1)->recHit()->geographicalId() : DetId{}; // null if last
458 
459  if (TKlayers == 9 && theInHit->isValid() && !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 9))) {
460  // if ( TKlayers==9 && itm==TMeas.rbegin()) {
461  // if ( TKlayers==9 && (itm==TMeas.back()) ) { // to check for only the last entry in the trajectory for propagation
462  const DetLayer* tob6 = measTracker.geometricSearchTracker()->tobLayers().back();
463  const LayerMeasurements theLayerMeasurements{measTracker, *measurementTrackerEvent};
464  const TrajectoryStateOnSurface tsosTOB5 = itm->updatedState();
465  const auto tmp = theLayerMeasurements.measurements(*tob6, tsosTOB5, prop, chi2Estimator);
466 
467  if (!tmp.empty()) {
468  LogDebug("SiStripHitEfficiencyWorker") << "size of TM from propagation = " << tmp.size();
469 
470  // take the last of the TMs, which is always an invalid hit
471  // if no detId is available, ie detId==0, then no compatible layer was crossed
472  // otherwise, use that TM for the efficiency measurement
473  const auto& tob6TM = tmp.back();
474  const auto& tob6Hit = tob6TM.recHit();
475  if (tob6Hit->geographicalId().rawId() != 0) {
476  LogDebug("SiStripHitEfficiencyWorker") << "tob6 hit actually being added to TM vector";
477  TMs.emplace_back(tob6TM, tTopo, tkgeom, propagator);
478  }
479  }
480  }
481 
482  // same for TEC8
483  if (TKlayers == 21 && theInHit->isValid() &&
484  !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 21))) {
485  const DetLayer* tec9pos = measTracker.geometricSearchTracker()->posTecLayers().back();
486  const DetLayer* tec9neg = measTracker.geometricSearchTracker()->negTecLayers().back();
487 
488  const LayerMeasurements theLayerMeasurements{measTracker, *measurementTrackerEvent};
489  const TrajectoryStateOnSurface tsosTEC9 = itm->updatedState();
490 
491  // check if track on positive or negative z
492  if (!(iidd == SiStripSubdetector::TEC))
493  LogDebug("SiStripHitEfficiencyWorker") << "there is a problem with TEC 9 extrapolation";
494 
495  //LogDebug("SiStripHitEfficiencyWorker") << " tec9 id = " << iidd << " and side = " << tTopo->tecSide(iidd) ;
496  std::vector<TrajectoryMeasurement> tmp;
497  if (tTopo->tecSide(iidd) == 1) {
498  tmp = theLayerMeasurements.measurements(*tec9neg, tsosTEC9, prop, chi2Estimator);
499  //LogDebug("SiStripHitEfficiencyWorker") << "on negative side" ;
500  }
501  if (tTopo->tecSide(iidd) == 2) {
502  tmp = theLayerMeasurements.measurements(*tec9pos, tsosTEC9, prop, chi2Estimator);
503  //LogDebug("SiStripHitEfficiencyWorker") << "on positive side" ;
504  }
505 
506  if (!tmp.empty()) {
507  // take the last of the TMs, which is always an invalid hit
508  // if no detId is available, ie detId==0, then no compatible layer was crossed
509  // otherwise, use that TM for the efficiency measurement
510  const auto& tec9TM = tmp.back();
511  const auto& tec9Hit = tec9TM.recHit();
512 
513  const unsigned int tec9id = tec9Hit->geographicalId().rawId();
514  LogDebug("SiStripHitEfficiencyWorker")
515  << "tec9id = " << tec9id << " is Double sided = " << ::isDoubleSided(tec9id, tTopo)
516  << " and 0x3 = " << (tec9id & 0x3);
517 
518  if (tec9Hit->geographicalId().rawId() != 0) {
519  LogDebug("SiStripHitEfficiencyWorker") << "tec9 hit actually being added to TM vector";
520  // in tec the hit can be single or doubled sided. whenever the invalid hit at the end of vector of TMs is
521  // double sided it is always on the matched surface, so we need to split it into the true sensor surfaces
522  if (::isDoubleSided(tec9id, tTopo)) {
523  TMs.emplace_back(tec9TM, tTopo, tkgeom, propagator, 1);
524  TMs.emplace_back(tec9TM, tTopo, tkgeom, propagator, 2);
525  } else
526  TMs.emplace_back(tec9TM, tTopo, tkgeom, propagator);
527  }
528  } //else LogDebug("SiStripHitEfficiencyWorker") << "tec9 tmp empty" ;
529  }
530 
531  for (const auto& tm : TMs) {
532  fillForTraj(tm,
533  tTopo,
534  tkgeom,
535  stripcpe,
536  stripQuality,
537  *fedErrorIds,
538  commonModeDigis,
539  *theClusters,
540  e.bunchCrossing(),
541  instLumi,
542  PU,
543  highPurity);
544  }
545  LogDebug("SiStripHitEfficiencyWorker") << "After looping over TrajAtValidHit list";
546  }
547  LogDebug("SiStripHitEfficiencyWorker") << "end TMeasurement loop";
548  }
549  LogDebug("SiStripHitEfficiencyWorker") << "end of trajectories loop";
550  }
551 }
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measTrackerToken_
dictionary missing
Definition: combine.py:5
tuple propagator
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const auto & magField
int bunchCrossing() const
Definition: EventBase.h:64
const edm::EDGetTokenT< DetIdCollection > digis_token_
dictionary PU
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
void Fill(long long x)
void fillForTraj(const TrajectoryAtInvalidHit &tm, const TrackerTopology *tTopo, const TrackerGeometry *tkgeom, const StripClusterParameterEstimator &stripCPE, const SiStripQuality &stripQuality, const DetIdCollection &fedErrorIds, const edm::Handle< edm::DetSetVector< SiStripRawDigi >> &commonModeDigis, const edmNew::DetSetVector< SiStripCluster > &theClusters, int bunchCrossing, float instLumi, float PU, bool highPurity)
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > stripCPEToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2EstimatorToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Definition: DetId.h:17
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
string end
Definition: dataset.py:937
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
tmp
align.sh
Definition: createJobs.py:716
#define LogDebug(id)
void SiStripHitEfficiencyWorker::beginJob ( )
private

Definition at line 243 of file SiStripHitEfficiencyWorker.cc.

References events, and EventTrackCKF.

243  {
244  // TODO convert to counters, or simply remove?
245  events = 0;
246  EventTrackCKF = 0;
247 }
void SiStripHitEfficiencyWorker::bookHistograms ( DQMStore::IBooker booker,
const edm::Run run,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements DQMEDAnalyzer.

Definition at line 249 of file SiStripHitEfficiencyWorker.cc.

References addCommonMode_, dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), edm::EventSetup::getData(), h_allLayer, h_bx, h_goodLayer, h_hotcold, h_instLumi, h_layer, h_layer_vsBx, h_layer_vsCM, h_layer_vsLumi, h_layer_vsPU, h_module, h_PU, h_resolution, phase1PixelTopology::layer, phase1PixelTopology::layerName, nTEClayers_, fed_dqm_sourceclient-live_cfg::path, dqm::impl::MonitorElement::setAxisTitle(), dqm::implementation::NavigatorBase::setCurrentFolder(), showRings_, AlCaHLTBitMon_QueryRunRegistry::string, tkDetMapToken_, and HLT_FULL_cff::yMax.

251  {
252  const std::string path = "AlCaReco/SiStripHitEfficiency"; // TODO make this configurable
253  booker.setCurrentFolder(path);
254  h_bx = booker.book1D("bx", "bx", 3600, 0, 3600);
255  h_instLumi = booker.book1D("instLumi", "inst. lumi.", 250, 0, 25000);
256  h_PU = booker.book1D("PU", "PU", 200, 0, 200);
257 
258  h_goodLayer = EffME1(booker.book1D("goodlayer_total", "goodlayer_total", 35, 0., 35.),
259  booker.book1D("goodlayer_found", "goodlayer_found", 35, 0., 35.));
260  h_allLayer = EffME1(booker.book1D("alllayer_total", "alllayer_total", 35, 0., 35.),
261  booker.book1D("alllayer_found", "alllayer_found", 35, 0., 35.));
262 
263  h_layer = EffME1(booker.book1D("layer_found", "layer_found", 23, 0., 23.),
264  booker.book1D("layer_total", "layer_total", 23, 0., 23.));
265  for (int layer = 0; layer != 23; ++layer) {
266  const auto lyrName = ::layerName(layer, showRings_, nTEClayers_);
267  auto ihres = booker.book1D(Form("resol_layer_%i", layer), lyrName, 125, -125., 125.);
268  ihres->setAxisTitle("trajX-clusX [strip unit]");
269  h_resolution.push_back(ihres);
270  h_layer_vsLumi.push_back(EffME1(booker.book1D(Form("layertotal_vsLumi_layer_%i", layer), lyrName, 100, 0, 25000),
271  booker.book1D(Form("layerfound_vsLumi_layer_%i", layer), lyrName, 100, 0, 25000)));
272  h_layer_vsPU.push_back(EffME1(booker.book1D(Form("layertotal_vsPU_layer_%i", layer), lyrName, 45, 0, 90),
273  booker.book1D(Form("layerfound_vsPU_layer_%i", layer), lyrName, 45, 0, 90)));
274  if (addCommonMode_) {
275  h_layer_vsCM.push_back(EffME1(booker.book1D(Form("layertotal_vsCM_layer_%i", layer), lyrName, 20, 0, 400),
276  booker.book1D(Form("layerfound_vsCM_layer_%i", layer), lyrName, 20, 0, 400)));
277  }
278  h_layer_vsBx.push_back(
279  EffME1(booker.book1D(Form("totalVsBx_layer%i", layer), Form("layer %i", layer), 3565, 0, 3565),
280  booker.book1D(Form("foundVsBx_layer%i", layer), Form("layer %i", layer), 3565, 0, 3565)));
281  if (layer < 10) {
282  const bool isTIB = layer < 4;
283  const auto partition = (isTIB ? "TIB" : "TOB");
284  const auto yMax = (isTIB ? 100 : 120);
285  auto ihhotcold = booker.book2D(
286  Form("%s%i", partition, (isTIB ? layer + 1 : layer - 3)), partition, 100, -1, 361, 100, -yMax, yMax);
287  ihhotcold->setAxisTitle("Phi", 1);
288  ihhotcold->setBinLabel(1, "360", 1);
289  ihhotcold->setBinLabel(50, "180", 1);
290  ihhotcold->setBinLabel(100, "0", 1);
291  ihhotcold->setAxisTitle("Global Z", 2);
292  ihhotcold->setOption("colz");
293  h_hotcold.push_back(ihhotcold);
294  } else {
295  const bool isTID = layer < 13;
296  const auto partitions =
297  (isTID ? std::vector<std::string>{"TID-", "TID+"} : std::vector<std::string>{"TEC-", "TEC+"});
298  const auto axMax = (isTID ? 100 : 120);
299  for (const auto& part : partitions) {
300  auto ihhotcold = booker.book2D(
301  Form("%s%i", part.c_str(), (isTID ? layer - 9 : layer - 12)), part, 100, -axMax, axMax, 100, -axMax, axMax);
302  ihhotcold->setAxisTitle("Global Y", 1);
303  ihhotcold->setBinLabel(1, "+Y", 1);
304  ihhotcold->setBinLabel(50, "0", 1);
305  ihhotcold->setBinLabel(100, "-Y", 1);
306  ihhotcold->setAxisTitle("Global X", 2);
307  ihhotcold->setBinLabel(1, "-X", 2);
308  ihhotcold->setBinLabel(50, "0", 2);
309  ihhotcold->setBinLabel(100, "+X", 2);
310  ihhotcold->setOption("colz");
311  h_hotcold.push_back(ihhotcold);
312  }
313  }
314  }
315 
316  const TkDetMap* tkDetMap = &setup.getData(tkDetMapToken_);
317  h_module = EffTkMap(std::make_unique<TkHistoMap>(tkDetMap, booker, path, "perModule_total", 0, false, true),
318  std::make_unique<TkHistoMap>(tkDetMap, booker, path, "perModule_found", 0, false, true));
319 }
constexpr char const * layerName[numberOfLayers]
std::vector< MonitorElement * > h_resolution
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::vector< MonitorElement * > h_hotcold
constexpr std::array< uint8_t, layerIndexSize > layer
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
part
Definition: HCALResponse.h:20
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:212
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void SiStripHitEfficiencyWorker::endJob ( void  )
private

Definition at line 905 of file SiStripHitEfficiencyWorker.cc.

References events, EventTrackCKF, and LogDebug.

Referenced by o2olib.O2ORunMgr::executeJob().

905  {
906  LogDebug("SiStripHitEfficiencyWorker") << " Events Analysed " << events;
907  LogDebug("SiStripHitEfficiencyWorker") << " Number Of Tracked events " << EventTrackCKF;
908 }
#define LogDebug(id)
void SiStripHitEfficiencyWorker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 910 of file SiStripHitEfficiencyWorker.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

910  {
912  desc.add<bool>("UseOnlyHighPurityTracks", true);
913  desc.add<bool>("cutOnTracks", false);
914  desc.add<bool>("useAllHitsFromTracksWithMissingHits", false);
915  desc.add<bool>("useFirstMeas", false);
916  desc.add<bool>("useLastMeas", false);
917  desc.add<double>("ClusterTrajDist", 64.0);
918  desc.add<double>("ResXSig", -1);
919  desc.add<double>("StripsApvEdge", 10.0);
920  desc.add<edm::InputTag>("combinatorialTracks", edm::InputTag{"generalTracks"});
921  desc.add<edm::InputTag>("commonMode", edm::InputTag{"siStripDigis", "CommonMode"});
922  desc.add<edm::InputTag>("lumiScalers", edm::InputTag{"scalersRawToDigi"});
923  desc.add<edm::InputTag>("siStripClusters", edm::InputTag{"siStripClusters"});
924  desc.add<edm::InputTag>("siStripDigis", edm::InputTag{"siStripDigis"});
925  desc.add<edm::InputTag>("trackerEvent", edm::InputTag{"MeasurementTrackerEvent"});
926  desc.add<edm::InputTag>("trajectories", edm::InputTag{"generalTracks"});
927  desc.add<int>("ClusterMatchingMethod", 0);
928  desc.add<int>("Layer", 0);
929  desc.add<unsigned int>("trackMultiplicity", 100);
930  desc.addUntracked<bool>("Debug", false);
931  desc.addUntracked<bool>("ShowRings", false);
932  desc.addUntracked<bool>("ShowTOB6TEC9", false);
933  desc.addUntracked<bool>("addCommonMode", false);
934  desc.addUntracked<bool>("addLumi", true);
935  desc.addUntracked<int>("BunchCrossing", 0);
936  desc.addUntracked<std::string>("BadModulesFile", "");
937  descriptions.addWithDefaultLabel(desc);
938 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void SiStripHitEfficiencyWorker::fillForTraj ( const TrajectoryAtInvalidHit tm,
const TrackerTopology tTopo,
const TrackerGeometry tkgeom,
const StripClusterParameterEstimator stripCPE,
const SiStripQuality stripQuality,
const DetIdCollection fedErrorIds,
const edm::Handle< edm::DetSetVector< SiStripRawDigi >> &  commonModeDigis,
const edmNew::DetSetVector< SiStripCluster > &  theClusters,
int  bunchCrossing,
float  instLumi,
float  PU,
bool  highPurity 
)
private

Definition at line 553 of file SiStripHitEfficiencyWorker.cc.

References funct::abs(), addCommonMode_, addLumi_, badModules_, Surface::bounds(), bunchX_, clusterMatchingMethod_, clusterTracjDist_, edmNew::DetSetVector< T >::empty(), edmNew::DetSetVector< T >::end(), SiStripHitEfficiencyWorker::EffME1::fill(), SiStripHitEfficiencyWorker::EffTkMap::fill(), edmNew::DetSetVector< T >::find(), SiStripQuality::getBadApvs(), TrajectoryAtInvalidHit::globalX(), TrajectoryAtInvalidHit::globalY(), TrajectoryAtInvalidHit::globalZ(), h_allLayer, h_goodLayer, h_hotcold, h_layer_vsBx, h_layer_vsCM, h_layer_vsLumi, h_layer_vsPU, h_module, h_resolution, TrackerGeometry::idToDetUnit(), cuy::ii, phase1PixelTopology::layer, layers_, TrajectoryAtInvalidHit::localErrorX(), TrajectoryAtInvalidHit::localErrorY(), StripClusterParameterEstimator::localParameters(), TrajectoryAtInvalidHit::localX(), TrajectoryAtInvalidHit::localY(), LogDebug, TrajectoryAtInvalidHit::monodet_id(), StripTopology::nstrips(), TrapezoidalPlaneBounds::parameters(), resXSig_, showRings_, showTOB6TEC9_, edm::EDCollection< T >::size(), edmNew::DetSetVector< T >::size(), StripGeomDetUnit::specificTopology(), mathSSE::sqrt(), sistrip::STRIPS_PER_APV, stripsApvEdge_, GeomDet::surface(), useOnlyHighPurityTracks_, Bounds::width(), and TrajectoryAtInvalidHit::withinAcceptance().

Referenced by analyze().

564  {
565  // --> Get trajectory from combinatedStat& e
566  const auto iidd = tm.monodet_id();
567  LogDebug("SiStripHitEfficiencyWorker") << "setting iidd = " << iidd << " before checking efficiency and ";
568 
569  const auto xloc = tm.localX();
570  const auto yloc = tm.localY();
571 
572  const auto xErr = tm.localErrorX();
573  const auto yErr = tm.localErrorY();
574 
575  int TrajStrip = -1;
576 
577  // reget layer from iidd here, to account for TOB 6 and TEC 9 TKlayers being off
578  const auto TKlayers = ::checkLayer(iidd, tTopo);
579 
580  const bool withinAcceptance =
581  tm.withinAcceptance() && (!::isInBondingExclusionZone(iidd, TKlayers, yloc, yErr, tTopo));
582 
583  if ( // (TKlayers > 0) && // FIXME confirm this
584  ((layers_ == TKlayers) || (layers_ == 0))) { // Look at the layer not used to reconstruct the track
585  LogDebug("SiStripHitEfficiencyWorker") << "Looking at layer under study";
586  unsigned int ModIsBad = 2;
587  unsigned int SiStripQualBad = 0;
588  float commonMode = -100;
589 
590  // RPhi RecHit Efficiency
591 
592  if (!theClusters.empty()) {
593  LogDebug("SiStripHitEfficiencyWorker") << "Checking clusters with size = " << theClusters.size();
594  std::vector<::ClusterInfo> VCluster_info; //fill with X residual, X residual pull, local X
595  const auto idsv = theClusters.find(iidd);
596  if (idsv != theClusters.end()) {
597  //if (DEBUG_) LogDebug("SiStripHitEfficiencyWorker") << "the ID from the dsv = " << dsv.id() ;
598  LogDebug("SiStripHitEfficiencyWorker")
599  << "found (ClusterId == iidd) with ClusterId = " << idsv->id() << " and iidd = " << iidd;
600  const auto stripdet = dynamic_cast<const StripGeomDetUnit*>(tkgeom->idToDetUnit(DetId(iidd)));
601  const StripTopology& Topo = stripdet->specificTopology();
602 
603  float hbedge = 0.0;
604  float htedge = 0.0;
605  float hapoth = 0.0;
606  float uylfac = 0.0;
607  float uxlden = 0.0;
608  if (TKlayers >= 11) {
609  const BoundPlane& plane = stripdet->surface();
610  const TrapezoidalPlaneBounds* trapezoidalBounds(
611  dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
612  std::array<const float, 4> const& parameterTrap = (*trapezoidalBounds).parameters(); // el bueno aqui
613  hbedge = parameterTrap[0];
614  htedge = parameterTrap[1];
615  hapoth = parameterTrap[3];
616  uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
617  uxlden = 1 + yloc * uylfac;
618  }
619 
620  // Need to know position of trajectory in strip number for selecting the right APV later
621  if (TrajStrip == -1) {
622  int nstrips = Topo.nstrips();
623  float pitch = stripdet->surface().bounds().width() / nstrips;
624  TrajStrip = xloc / pitch + nstrips / 2.0;
625  // Need additionnal corrections for endcap
626  if (TKlayers >= 11) {
627  const float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
628  hapoth); // radialy extrapolated x loc position at middle
629  TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
630  }
631  //LogDebug("SiStripHitEfficiency")<<" Layer "<<TKlayers<<" TrajStrip: "<<nstrips<<" "<<pitch<<" "<<TrajStrip;;
632  }
633 
634  for (const auto& clus : *idsv) {
636  float res = (parameters.first.x() - xloc);
637  float sigma = ::checkConsistency(parameters, xloc, xErr);
638  // The consistency is probably more accurately measured with the Chi2MeasurementEstimator. To use it
639  // you need a TransientTrackingRecHit instead of the cluster
640  //theEstimator= new Chi2MeasurementEstimator(30);
641  //const Chi2MeasurementEstimator *theEstimator(100);
642  //theEstimator->estimate(tm.tsos(), TransientTrackingRecHit);
643 
644  if (TKlayers >= 11) {
645  res = parameters.first.x() - xloc / uxlden; // radialy extrapolated x loc position at middle
646  sigma = abs(res) / sqrt(parameters.second.xx() + xErr * xErr / uxlden / uxlden +
647  yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
648  }
649 
650  VCluster_info.emplace_back(res, sigma, parameters.first.x());
651 
652  LogDebug("SiStripHitEfficiencyWorker") << "Have ID match. residual = " << res << " res sigma = " << sigma;
653  //LogDebug("SiStripHitEfficiencyWorker")
654  // << "trajectory measurement compatability estimate = " << (*itm).estimate() ;
655  LogDebug("SiStripHitEfficiencyWorker")
656  << "hit position = " << parameters.first.x() << " hit error = " << sqrt(parameters.second.xx())
657  << " trajectory position = " << xloc << " traj error = " << xErr;
658  }
659  }
660  ::ClusterInfo finalCluster{1000.0, 1000.0, 0.0};
661  if (!VCluster_info.empty()) {
662  LogDebug("SiStripHitEfficiencyWorker") << "found clusters > 0";
663  if (VCluster_info.size() > 1) {
664  //get the smallest one
665  for (const auto& res : VCluster_info) {
666  if (std::abs(res.xResidualPull) < std::abs(finalCluster.xResidualPull)) {
667  finalCluster = res;
668  }
669  LogDebug("SiStripHitEfficiencyWorker")
670  << "iresidual = " << res.xResidual << " isigma = " << res.xResidualPull
671  << " and FinalRes = " << finalCluster.xResidual;
672  }
673  } else {
674  finalCluster = VCluster_info[0];
675  }
676  VCluster_info.clear();
677  }
678 
679  LogDebug("SiStripHitEfficiencyWorker") << "Final residual in X = " << finalCluster.xResidual << "+-"
680  << (finalCluster.xResidual / finalCluster.xResidualPull);
681  LogDebug("SiStripHitEfficiencyWorker")
682  << "Checking location of trajectory: abs(yloc) = " << abs(yloc) << " abs(xloc) = " << abs(xloc);
683 
684  //
685  // fill ntuple varibles
686 
687  //if ( stripQuality->IsModuleBad(iidd) )
688  if (stripQuality.getBadApvs(iidd) != 0) {
689  SiStripQualBad = 1;
690  LogDebug("SiStripHitEfficiencyWorker") << "strip is bad from SiStripQuality";
691  } else {
692  SiStripQualBad = 0;
693  LogDebug("SiStripHitEfficiencyWorker") << "strip is good from SiStripQuality";
694  }
695 
696  //check for FED-detected errors and include those in SiStripQualBad
697  for (unsigned int ii = 0; ii < fedErrorIds.size(); ii++) {
698  if (iidd == fedErrorIds[ii].rawId())
699  SiStripQualBad = 1;
700  }
701 
702  // CM of APV crossed by traj
703  if (addCommonMode_)
704  if (commonModeDigis.isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
705  const auto digiframe = commonModeDigis->find(iidd);
706  if (digiframe != commonModeDigis->end())
707  if ((unsigned)TrajStrip / sistrip::STRIPS_PER_APV < digiframe->data.size())
708  commonMode = digiframe->data.at(TrajStrip / sistrip::STRIPS_PER_APV).adc();
709  }
710 
711  LogDebug("SiStripHitEfficiencyWorker") << "before check good";
712 
713  if (finalCluster.xResidualPull < 999.0) { //could make requirement on track/hit consistency, but for
714  //now take anything with a hit on the module
715  LogDebug("SiStripHitEfficiencyWorker")
716  << "hit being counted as good " << finalCluster.xResidual << " FinalRecHit " << iidd << " TKlayers "
717  << TKlayers << " xloc " << xloc << " yloc " << yloc << " module " << iidd
718  << " matched/stereo/rphi = " << ((iidd & 0x3) == 0) << "/" << ((iidd & 0x3) == 1) << "/"
719  << ((iidd & 0x3) == 2);
720  ModIsBad = 0;
721  } else {
722  LogDebug("SiStripHitEfficiencyWorker")
723  << "hit being counted as bad ######### Invalid RPhi FinalResX " << finalCluster.xResidual
724  << " FinalRecHit " << iidd << " TKlayers " << TKlayers << " xloc " << xloc << " yloc " << yloc
725  << " module " << iidd << " matched/stereo/rphi = " << ((iidd & 0x3) == 0) << "/" << ((iidd & 0x3) == 1)
726  << "/" << ((iidd & 0x3) == 2);
727  ModIsBad = 1;
728  LogDebug("SiStripHitEfficiencyWorker")
729  << " RPhi Error " << sqrt(xErr * xErr + yErr * yErr) << " ErrorX " << xErr << " yErr " << yErr;
730  }
731 
732  LogDebug("SiStripHitEfficiencyWorker")
733  << "To avoid them staying unused: ModIsBad=" << ModIsBad << ", SiStripQualBad=" << SiStripQualBad
734  << ", commonMode=" << commonMode << ", highPurity=" << highPurity
735  << ", withinAcceptance=" << withinAcceptance;
736 
737  unsigned int layer = TKlayers;
738  if (showRings_ && layer > 10) { // use rings instead of wheels
739  if (layer < 14) { // TID
740  layer = 10 + ((iidd >> 9) & 0x3); // 3 disks and also 3 rings -> use the same container
741  } else { // TEC
742  layer = 13 + ((iidd >> 5) & 0x7);
743  }
744  }
745  unsigned int layerWithSide = layer;
746  if (layer > 10 && layer < 14) {
747  const auto side = (iidd >> 13) & 0x3; // TID
748  if (side == 2)
749  layerWithSide = layer + 3;
750  } else if (layer > 13) {
751  const auto side = (iidd >> 18) & 0x3; // TEC
752  if (side == 1) {
753  layerWithSide = layer + 3;
754  } else if (side == 2) {
755  layerWithSide = layer + 3 + (showRings_ ? 7 : 9);
756  }
757  }
758 
759  if ((bunchX_ > 0 && bunchX_ != bunchCrossing) || (!withinAcceptance) ||
760  (useOnlyHighPurityTracks_ && !highPurity) || (!showTOB6TEC9_ && (TKlayers == 10 || TKlayers == 22)) ||
761  (badModules_.end() != badModules_.find(iidd)))
762  return;
763 
764  const bool badquality = (SiStripQualBad == 1);
765 
766  //Now that we have a good event, we need to look at if we expected it or not, and the location
767  //if we didn't
768  //Fill the missing hit information first
769  bool badflag = false; // true for hits that are expected but not found
770  if (resXSig_ < 0) {
771  if (ModIsBad == 1)
772  badflag = true; // isBad set to false in the tree when resxsig<999.0
773  } else {
774  if (ModIsBad == 1 || finalCluster.xResidualPull > resXSig_)
775  badflag = true;
776  }
777 
778  // Conversion of positions in strip unit
779  int nstrips = -9;
780  float Pitch = -9.0;
781  const StripGeomDetUnit* stripdet = nullptr;
782  if (finalCluster.xResidualPull ==
783  1000.0) { // special treatment, no GeomDetUnit associated in some cases when no cluster found
784  Pitch = 0.0205; // maximum
785  nstrips = 768; // maximum
786  } else {
787  stripdet = dynamic_cast<const StripGeomDetUnit*>(tkgeom->idToDetUnit(iidd));
788  const StripTopology& Topo = stripdet->specificTopology();
789  nstrips = Topo.nstrips();
790  Pitch = stripdet->surface().bounds().width() / Topo.nstrips();
791  }
792  double stripTrajMid = xloc / Pitch + nstrips / 2.0;
793  double stripCluster = finalCluster.xLocal / Pitch + nstrips / 2.0;
794  // For trapezoidal modules: extrapolation of x trajectory position to the y middle of the module
795  // for correct comparison with cluster position
796  if (stripdet && layer >= 11) {
797  const auto& trapezoidalBounds = dynamic_cast<const TrapezoidalPlaneBounds&>(stripdet->surface().bounds());
798  std::array<const float, 4> const& parameters = trapezoidalBounds.parameters();
799  const float hbedge = parameters[0];
800  const float htedge = parameters[1];
801  const float hapoth = parameters[3];
802  const float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
803  hapoth); // radialy extrapolated x loc position at middle
804  stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
805  }
806 
807  if ((!badquality) && (layer < h_resolution.size())) {
808  h_resolution[layer]->Fill(finalCluster.xResidualPull != 1000.0 ? stripTrajMid - stripCluster : 1000);
809  }
810 
811  // New matching methods
812  if (clusterMatchingMethod_ >= 1) {
813  badflag = false;
814  if (finalCluster.xResidualPull == 1000.0) {
815  LogDebug("SiStripHitEfficiencyWorker") << "Marking bad for resxsig=1000";
816  badflag = true;
817  } else {
819  // check the distance between cluster and trajectory position
820  if (std::abs(stripCluster - stripTrajMid) > clusterTracjDist_) {
821  LogDebug("SiStripHitEfficiencyWorker") << "Marking bad for cluster-to-traj distance";
822  badflag = true;
823  }
824  }
826  // cluster and traj have to be in the same APV (don't take edges into accounts)
827  const int tapv = (int)stripTrajMid / sistrip::STRIPS_PER_APV;
828  const int capv = (int)stripCluster / sistrip::STRIPS_PER_APV;
829  float stripInAPV = stripTrajMid - tapv * sistrip::STRIPS_PER_APV;
830  if (stripInAPV < stripsApvEdge_ || stripInAPV > sistrip::STRIPS_PER_APV - stripsApvEdge_) {
831  LogDebug("SiStripHitEfficiencyWorker") << "Too close to the edge: " << stripInAPV;
832  return;
833  }
834  if (tapv != capv) {
835  LogDebug("SiStripHitEfficiencyWorker") << "Marking bad for tapv!=capv";
836  badflag = true;
837  }
838  }
839  }
840  }
841  if (!badquality) {
842  LogDebug("SiStripHitEfficiencyWorker")
843  << "Filling measurement for " << iidd << " in layer " << layer << " histograms with bx=" << bunchCrossing
844  << ", lumi=" << instLumi << ", PU=" << PU << "; bad flag=" << badflag;
845 
846  // hot/cold maps of hits that are expected but not found
847  if (badflag) {
848  if (layer > 0 && layer <= 10) {
849  // 1-4: TIB, 4-10: TOB
850  h_hotcold[layer - 1]->Fill(360. - ::calcPhi(tm.globalX(), tm.globalY()), tm.globalZ(), 1.);
851  } else if (layer > 10 && layer <= 13) {
852  // 11-13: TID, above: TEC
853  const int side = layer > 13 ? (iidd >> 13) & 0x3 : (iidd >> 18) & 0x3;
854  h_hotcold[2 * layer - 13 + side]->Fill(-tm.globalY(), tm.globalX(), 1.);
855  }
856  }
857 
858  h_layer_vsBx[layer].fill(bunchCrossing, !badflag);
859  if (addLumi_) {
860  h_layer_vsLumi[layer].fill(instLumi, !badflag);
861  h_layer_vsPU[layer].fill(PU, !badflag);
862  }
863  if (addCommonMode_) {
864  h_layer_vsCM[layer].fill(commonMode, !badflag);
865  }
866  h_goodLayer.fill(layerWithSide, !badflag);
867 
868  // efficiency with bad modules excluded
869  if (TKlayers) {
870  h_module.fill(iidd, !badflag);
871  }
872  }
873  // efficiency without bad modules excluded
874  h_allLayer.fill(layerWithSide, !badflag);
875 
876  /* Used in SiStripHitEffFromCalibTree:
877  * run -> "run" -> run // e.id().run()
878  * event -> "event" -> evt // e.id().event()
879  * ModIsBad -> "ModIsBad" -> isBad
880  * SiStripQualBad -> "SiStripQualBad"" -> quality
881  * Id -> "Id" -> id // iidd
882  * withinAcceptance -> "withinAcceptance" -> accept
883  * whatlayer -> "layer" -> layer_wheel // Tklayers
884  * highPurity -> "highPurity" -> highPurity
885  * TrajGlbX -> "TrajGlbX" -> x // tm.globalX()
886  * TrajGlbY -> "TrajGlbY" -> y // tm.globalY()
887  * TrajGlbZ -> "TrajGlbZ" -> z // tm.globalZ()
888  * ResXSig -> "ResXSig" -> resxsig // finalCluster.xResidualPull;
889  * TrajLocX -> "TrajLocX" -> TrajLocX // xloc
890  * TrajLocY -> "TrajLocY" -> TrajLocY // yloc
891  * ClusterLocX -> "ClusterLocX" -> ClusterLocX // finalCluster.xLocal
892  * bunchx -> "bunchx" -> bx // e.bunchCrossing()
893  * instLumi -> "instLumi" -> instLumi ## if addLumi_
894  * PU -> "PU" -> PU ## if addLumi_
895  * commonMode -> "commonMode" -> CM ## if addCommonMode_ / _useCM
896  */
897  LogDebug("SiStripHitEfficiencyWorker") << "after good location check";
898  }
899  LogDebug("SiStripHitEfficiencyWorker") << "after list of clusters";
900  }
901  LogDebug("SiStripHitEfficiencyWorker") << "After layers=TKLayers if with TKlayers=" << TKlayers
902  << ", layers=" << layers_;
903 }
std::pair< LocalPoint, LocalError > LocalValues
size_type size() const
Definition: EDCollection.h:82
virtual int nstrips() const =0
void fill(double x, bool found, float weight=1.)
const_iterator end(bool update=false) const
iterator find(det_id_type id)
Definition: DetSetVector.h:264
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
std::vector< MonitorElement * > h_resolution
unsigned int monodet_id() const
virtual const std::array< const float, 4 > parameters() const
std::vector< MonitorElement * > h_hotcold
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const
const Bounds & bounds() const
Definition: Surface.h:87
dictionary PU
int ii
Definition: cuy.py:589
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
constexpr std::array< uint8_t, layerIndexSize > layer
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:70
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
Definition: DetId.h:17
const_iterator find(id_type i, bool update=false) const
size_type size() const
static const uint16_t STRIPS_PER_APV
void fill(uint32_t id, bool found, float weight=1.)
short getBadApvs(uint32_t detid) const
virtual float width() const =0
#define LogDebug(id)

Member Data Documentation

bool SiStripHitEfficiencyWorker::addCommonMode_
private

Definition at line 111 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), bookHistograms(), and fillForTraj().

bool SiStripHitEfficiencyWorker::addLumi_
private

Definition at line 110 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), and fillForTraj().

std::set<uint32_t> SiStripHitEfficiencyWorker::badModules_
private

Definition at line 128 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

int SiStripHitEfficiencyWorker::bunchX_
private

Definition at line 122 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::ESGetToken<Chi2MeasurementEstimatorBase, TrackingComponentsRecord> SiStripHitEfficiencyWorker::chi2EstimatorToken_
private

Definition at line 103 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

unsigned int SiStripHitEfficiencyWorker::clusterMatchingMethod_
private

Definition at line 117 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > SiStripHitEfficiencyWorker::clusters_token_
private

Definition at line 92 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

float SiStripHitEfficiencyWorker::clusterTracjDist_
private

Definition at line 119 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::EDGetTokenT<reco::TrackCollection> SiStripHitEfficiencyWorker::combinatorialTracks_token_
private

Definition at line 89 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripHitEfficiencyWorker::commonModeToken_
private

Definition at line 88 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::cutOnTracks_
private

Definition at line 112 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::DEBUG_
private

Definition at line 109 of file SiStripHitEfficiencyWorker.cc.

const edm::EDGetTokenT<DetIdCollection> SiStripHitEfficiencyWorker::digis_token_
private

Definition at line 93 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

int SiStripHitEfficiencyWorker::events
private
int SiStripHitEfficiencyWorker::EventTrackCKF
private

Definition at line 131 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), beginJob(), and endJob().

EffME1 SiStripHitEfficiencyWorker::h_allLayer
private

Definition at line 163 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

MonitorElement* SiStripHitEfficiencyWorker::h_bx
private

Definition at line 161 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), and bookHistograms().

EffME1 SiStripHitEfficiencyWorker::h_goodLayer
private

Definition at line 162 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

std::vector<MonitorElement*> SiStripHitEfficiencyWorker::h_hotcold
private

Definition at line 170 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

MonitorElement * SiStripHitEfficiencyWorker::h_instLumi
private

Definition at line 161 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), and bookHistograms().

EffME1 SiStripHitEfficiencyWorker::h_layer
private

Definition at line 164 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms().

std::vector<EffME1> SiStripHitEfficiencyWorker::h_layer_vsBx
private

Definition at line 167 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

std::vector<EffME1> SiStripHitEfficiencyWorker::h_layer_vsCM
private

Definition at line 169 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

std::vector<EffME1> SiStripHitEfficiencyWorker::h_layer_vsLumi
private

Definition at line 166 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

std::vector<EffME1> SiStripHitEfficiencyWorker::h_layer_vsPU
private

Definition at line 168 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

EffTkMap SiStripHitEfficiencyWorker::h_module
private

Definition at line 172 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

MonitorElement * SiStripHitEfficiencyWorker::h_PU
private

Definition at line 161 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze(), and bookHistograms().

std::vector<MonitorElement*> SiStripHitEfficiencyWorker::h_resolution
private

Definition at line 165 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

unsigned int SiStripHitEfficiencyWorker::layers_
private

Definition at line 108 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SiStripHitEfficiencyWorker::magFieldToken_
private

Definition at line 101 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::ESGetToken<MeasurementTracker, CkfComponentsRecord> SiStripHitEfficiencyWorker::measTrackerToken_
private

Definition at line 102 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

unsigned int SiStripHitEfficiencyWorker::nTEClayers_
private

Definition at line 125 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms().

const edm::ESGetToken<Propagator, TrackingComponentsRecord> SiStripHitEfficiencyWorker::propagatorToken_
private

Definition at line 104 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

float SiStripHitEfficiencyWorker::resXSig_
private

Definition at line 118 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::EDGetTokenT<LumiScalersCollection> SiStripHitEfficiencyWorker::scalerToken_
private

Definition at line 87 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::showRings_
private

Definition at line 123 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms(), and fillForTraj().

bool SiStripHitEfficiencyWorker::showTOB6TEC9_
private

Definition at line 124 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> SiStripHitEfficiencyWorker::stripCPEToken_
private

Definition at line 99 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::ESGetToken<SiStripQuality, SiStripQualityRcd> SiStripHitEfficiencyWorker::stripQualityToken_
private

Definition at line 100 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

float SiStripHitEfficiencyWorker::stripsApvEdge_
private

Definition at line 120 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().

const edm::ESGetToken<TkDetMap, TrackerTopologyRcd> SiStripHitEfficiencyWorker::tkDetMapToken_
private

Definition at line 105 of file SiStripHitEfficiencyWorker.cc.

Referenced by bookHistograms().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripHitEfficiencyWorker::tkGeomToken_
private

Definition at line 98 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::EDGetTokenT<MeasurementTrackerEvent> SiStripHitEfficiencyWorker::trackerEvent_token_
private

Definition at line 94 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

unsigned int SiStripHitEfficiencyWorker::trackMultiplicityCut_
private

Definition at line 113 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::EDGetTokenT<std::vector<Trajectory> > SiStripHitEfficiencyWorker::trajectories_token_
private

Definition at line 90 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::EDGetTokenT<TrajTrackAssociationCollection> SiStripHitEfficiencyWorker::trajTrackAsso_token_
private

Definition at line 91 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripHitEfficiencyWorker::tTopoToken_
private

Definition at line 97 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::useAllHitsFromTracksWithMissingHits_
private

Definition at line 116 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::useFirstMeas_
private

Definition at line 114 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::useLastMeas_
private

Definition at line 115 of file SiStripHitEfficiencyWorker.cc.

Referenced by analyze().

bool SiStripHitEfficiencyWorker::useOnlyHighPurityTracks_
private

Definition at line 121 of file SiStripHitEfficiencyWorker.cc.

Referenced by fillForTraj().