CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AlignmentMuonHIPTrajectorySelector Class Reference

#include <Alignment/CommonAlignmentProducer/plugins/AlignmentMuonHIPTrajectorySelector.cc>

Inheritance diagram for AlignmentMuonHIPTrajectorySelector:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlignmentMuonHIPTrajectorySelector (const edm::ParameterSet &)
 
 ~AlignmentMuonHIPTrajectorySelector () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool m_hists
 
edm::InputTag m_input
 
double m_maxMuonResidual
 
double m_maxTrackerForwardRedChi2
 
double m_minPt
 
int m_minTrackerDOF
 
TH1F * m_pt
 
TH1F * m_resid_after
 
TH1F * m_resid_before
 
TH1F * m_tracker_dof
 
TH1F * m_tracker_forwardredchi2
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 55 of file AlignmentMuonHIPTrajectorySelector.cc.

Constructor & Destructor Documentation

AlignmentMuonHIPTrajectorySelector::AlignmentMuonHIPTrajectorySelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 87 of file AlignmentMuonHIPTrajectorySelector.cc.

References m_hists, m_pt, m_resid_after, m_resid_before, m_tracker_dof, m_tracker_forwardredchi2, and TFileService::make().

88  : m_input(iConfig.getParameter<edm::InputTag>("input"))
89  , m_minPt(iConfig.getParameter<double>("minPt"))
90  , m_maxTrackerForwardRedChi2(iConfig.getParameter<double>("maxTrackerForwardRedChi2"))
91  , m_minTrackerDOF(iConfig.getParameter<int>("minTrackerDOF"))
92  , m_maxMuonResidual(iConfig.getParameter<double>("maxMuonResidual"))
93  , m_hists(iConfig.getParameter<bool>("hists"))
94  , m_pt(nullptr), m_tracker_forwardredchi2(nullptr), m_tracker_dof(nullptr)
95 {
96  produces<TrajTrackAssociationCollection>();
97 
98  if (m_hists) {
100  m_pt = fs->make<TH1F>("pt", "Transverse momentum (GeV)", 100, 0., 100.);
101  m_tracker_forwardredchi2 = fs->make<TH1F>("trackerForwardRedChi2", "forward-biased reduced chi2 in tracker", 100, 0., 5.);
102  m_tracker_dof = fs->make<TH1F>("trackerDOF", "DOF in tracker", 61, -0.5, 60.5);
103  m_resid_before = fs->make<TH1F>("residBefore", "muon residuals before cut (cm)", 100, -20, 20);
104  m_resid_after = fs->make<TH1F>("residAfter", "muon residuals after cut (cm)", 100, -20, 20);
105  }
106 }
T getParameter(std::string const &) const
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
AlignmentMuonHIPTrajectorySelector::~AlignmentMuonHIPTrajectorySelector ( )
override

Definition at line 109 of file AlignmentMuonHIPTrajectorySelector.cc.

109 {}

Member Function Documentation

void AlignmentMuonHIPTrajectorySelector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 118 of file AlignmentMuonHIPTrajectorySelector.cc.

References TrajectoryMeasurement::backwardPredictedState(), edm::AssociationMap< Tag >::begin(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, MuonSubdetId::CSC, DEFINE_FWK_MODULE, MuonSubdetId::DT, edm::AssociationMap< Tag >::end(), TrajectoryMeasurement::forwardPredictedState(), edm::Event::getByLabel(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), m_hists, m_input, m_maxMuonResidual, m_minPt, m_minTrackerDOF, m_pt, m_resid_after, m_resid_before, m_tracker_dof, m_tracker_forwardredchi2, eostools::move(), DetId::Muon, LocalTrajectoryError::positionError(), edm::Event::put(), TrajectoryMeasurement::recHit(), DetId::Tracker, PV3DBase< T, PVType, FrameType >::x(), hit::x, LocalError::xx(), LocalError::xy(), PV3DBase< T, PVType, FrameType >::y(), hit::y, and LocalError::yy().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

119 {
120  // input
121  edm::Handle<TrajTrackAssociationCollection> originalTrajTrackMap;
122  iEvent.getByLabel(m_input, originalTrajTrackMap);
123 
124  // output
125  auto newTrajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
126 
127  TrajectoryStateCombiner tsoscomb;
128 
129  for (TrajTrackAssociationCollection::const_iterator iPair = originalTrajTrackMap->begin(); iPair != originalTrajTrackMap->end(); ++iPair) {
130  if (m_hists) {
131  m_pt->Fill((*(*iPair).val).pt());
132  }
133 
134  if ((*(*iPair).val).pt() > m_minPt) {
135 
136  std::vector<TrajectoryMeasurement> measurements = (*(*iPair).key).measurements();
137 
138  bool has_bad_residual = false;
139 
140  double tracker_forwardchi2 = 0.;
141  double tracker_dof = 0.;
142  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
143  const TrajectoryMeasurement meas = *im;
144  auto hit = &(*meas.recHit());
145  const DetId id = hit->geographicalId();
146 
147  if (hit->isValid() && id.det() == DetId::Tracker) {
148  if (hit->dimension() == 1) {
149  double residual = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
150  double error2 = meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();
151 
152  tracker_forwardchi2 += residual * residual / error2;
153  tracker_dof += 1.;
154  }
155  else if (hit->dimension() == 2) {
156  double residualx = meas.forwardPredictedState().localPosition().x() - hit->localPosition().x();
157  double residualy = meas.forwardPredictedState().localPosition().y() - hit->localPosition().y();
158  double errorxx2 = meas.forwardPredictedState().localError().positionError().xx() + hit->localPositionError().xx();
159  double errorxy2 = meas.forwardPredictedState().localError().positionError().xy() + hit->localPositionError().xy();
160  double erroryy2 = meas.forwardPredictedState().localError().positionError().yy() + hit->localPositionError().yy();
161 
162  tracker_forwardchi2 += (residualx * residualx + residualy * residualy) / (errorxx2 + 2.*errorxy2 + erroryy2);
163  tracker_dof += 2.;
164  }
165  } // end if a tracker hit
166 
167  if (hit->isValid() && id.det() == DetId::Muon && (id.subdetId() == MuonSubdetId::DT || id.subdetId() == MuonSubdetId::CSC)) {
168  TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
169  double residual = tsosc.localPosition().x() - hit->localPosition().x();
170  m_resid_before->Fill(residual);
171  if (fabs(residual) > m_maxMuonResidual) {
172  has_bad_residual = true;
173  }
174  } // end if a muon hit
175 
176  }
177  tracker_dof -= 5.;
178  double tracker_forwardredchi2 = tracker_forwardchi2 / tracker_dof;
179 
180  if (m_hists) {
181  m_tracker_forwardredchi2->Fill(tracker_forwardredchi2);
182  m_tracker_dof->Fill(tracker_dof);
183 
184  for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
185  const TrajectoryMeasurement meas = *im;
186  auto hit = &(*meas.recHit());
187  const DetId id = hit->geographicalId();
188 
189  if (!has_bad_residual) {
190  if (hit->isValid() && id.det() == DetId::Muon && (id.subdetId() == MuonSubdetId::DT || id.subdetId() == MuonSubdetId::CSC)) {
191  TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
192  double residual = tsosc.localPosition().x() - hit->localPosition().x();
193  m_resid_after->Fill(residual);
194  }
195  } // end if residuals pass cut
196  } // end second loop over hits
197  } // end if filling histograms
198 
199  if (tracker_forwardredchi2 < m_maxTrackerForwardRedChi2 && tracker_dof >= m_minTrackerDOF && !has_bad_residual) {
200  newTrajTrackMap->insert((*iPair).key, (*iPair).val);
201  } // end if passes tracker cuts
202  } // end if passes pT cut
203  } // end loop over original trajTrackMap
204 
205  // put it in the Event
206  iEvent.put(std::move(newTrajTrackMap));
207 }
float xx() const
Definition: LocalError.h:24
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
ConstRecHitPointer const & recHit() const
const_iterator end() const
last iterator over the map (read only)
T y() const
Definition: PV3DBase.h:63
LocalError positionError() const
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
const LocalTrajectoryError & localError() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: DetId.h:18
const_iterator begin() const
first iterator over the map (read only)
static constexpr int DT
Definition: MuonSubdetId.h:12
static constexpr int CSC
Definition: MuonSubdetId.h:13
T x() const
Definition: PV3DBase.h:62
def move(src, dest)
Definition: eostools.py:510
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)

Member Data Documentation

bool AlignmentMuonHIPTrajectorySelector::m_hists
private
edm::InputTag AlignmentMuonHIPTrajectorySelector::m_input
private

Definition at line 64 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

double AlignmentMuonHIPTrajectorySelector::m_maxMuonResidual
private

Definition at line 68 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

double AlignmentMuonHIPTrajectorySelector::m_maxTrackerForwardRedChi2
private

Definition at line 66 of file AlignmentMuonHIPTrajectorySelector.cc.

double AlignmentMuonHIPTrajectorySelector::m_minPt
private

Definition at line 65 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

int AlignmentMuonHIPTrajectorySelector::m_minTrackerDOF
private

Definition at line 67 of file AlignmentMuonHIPTrajectorySelector.cc.

Referenced by produce().

TH1F* AlignmentMuonHIPTrajectorySelector::m_pt
private
TH1F * AlignmentMuonHIPTrajectorySelector::m_resid_after
private
TH1F* AlignmentMuonHIPTrajectorySelector::m_resid_before
private
TH1F * AlignmentMuonHIPTrajectorySelector::m_tracker_dof
private
TH1F * AlignmentMuonHIPTrajectorySelector::m_tracker_forwardredchi2
private