CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonCaloDistanceProducer Class Reference

#include <MuonCaloDistanceProducer.h>

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

Public Member Functions

 MuonCaloDistanceProducer (const edm::ParameterSet &)
 
 ~MuonCaloDistanceProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< uint32_t, float > detIdToFloatMap
 

Private Member Functions

void fillDistanceMap (edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag srcSelectedMuons_
 
TrackDetectorAssociator trackAssociator_
 
TrackAssociatorParameters trackAssociatorParameters_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Compute distance traversed by muon through calorimeter cells.

NOTE: The output of this class is used as input for MuonCaloCleanerByDistance.

Author
Tomasz Maciej Frueboes; Christian Veelken, LLR
Version
Revision:
1.3
Id:
MuonCaloDistanceProducer.h,v 1.3 2013/01/30 10:10:49 aburgmei Exp

Definition at line 30 of file MuonCaloDistanceProducer.h.

Member Typedef Documentation

typedef std::map<uint32_t, float> MuonCaloDistanceProducer::detIdToFloatMap
private

Definition at line 39 of file MuonCaloDistanceProducer.h.

Constructor & Destructor Documentation

MuonCaloDistanceProducer::MuonCaloDistanceProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 24 of file MuonCaloDistanceProducer.cc.

References edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), trackAssociator_, trackAssociatorParameters_, and TrackDetectorAssociator::useDefaultPropagator().

25  : srcSelectedMuons_(cfg.getParameter<edm::InputTag>("selectedMuons"))
26 {
27  // maps of detId to distance traversed by muon through detector volume
28  produces<reco::CandidateCollection>("muons");
29  produces<detIdToFloatMap>("distancesMuPlus");
30  produces<detIdToFloatMap>("distancesMuMinus");
31  produces<detIdToFloatMap>("depositsMuPlus");
32  produces<detIdToFloatMap>("depositsMuMinus");
33 
34  edm::ParameterSet cfgTrackAssociator = cfg.getParameter<edm::ParameterSet>("trackAssociator");
35  trackAssociatorParameters_.loadParameters(cfgTrackAssociator);
37 }
T getParameter(std::string const &) const
void useDefaultPropagator()
use the default propagator
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssociatorParameters_
void loadParameters(const edm::ParameterSet &)
MuonCaloDistanceProducer::~MuonCaloDistanceProducer ( )

Definition at line 39 of file MuonCaloDistanceProducer.cc.

40 {
41 // nothing to be done yet...
42 }

Member Function Documentation

void MuonCaloDistanceProducer::fillDistanceMap ( edm::Event evt,
const edm::EventSetup es,
const reco::Candidate muon,
detIdToFloatMap distanceMap,
detIdToFloatMap depositMap 
)
private

Definition at line 74 of file MuonCaloDistanceProducer.cc.

References TrackDetMatchInfo::crossedEcalIds, TrackDetMatchInfo::crossedEcalRecHits, TrackDetMatchInfo::crossedHcalIds, TrackDetMatchInfo::crossedHcalRecHits, TrackDetMatchInfo::crossedHOIds, TrackDetMatchInfo::crossedHORecHits, TrackDetMatchInfo::crossedPreshowerIds, CaloRecHit::detid(), CaloRecHit::energy(), edm::EventSetup::get(), TrackDetectorAssociator::getCachedTrajector(), CachedTrajectory::getEcalTrajectory(), CaloSubdetectorGeometry::getGeometry(), CachedTrajectory::getHcalTrajectory(), CachedTrajectory::getHOTrajectory(), CachedTrajectory::getPreshowerTrajectory(), getTrackDetMatchInfo(), CaloCellGeometry::inside(), point, DetId::rawId(), mathSSE::sqrt(), trackAssociator_, trackAssociatorParameters_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

75 {
77 
78  BOOST_FOREACH(const EcalRecHit * rh, trackDetMatchInfo.crossedEcalRecHits)
79  depositMap[rh->detid().rawId()]+=rh->energy();
80 
81  BOOST_FOREACH(const HBHERecHit * rh, trackDetMatchInfo.crossedHcalRecHits)
82  depositMap[rh->detid().rawId()]+=rh->energy();
83 
84  BOOST_FOREACH(const HORecHit * rh, trackDetMatchInfo.crossedHORecHits)
85  depositMap[rh->detid().rawId()]+=rh->energy();
86 
87  typedef std::map<std::string, const std::vector<DetId>*> CaloToDetIdMap;
88  CaloToDetIdMap caloToDetIdMap;
89  caloToDetIdMap["ecal"] = &(trackDetMatchInfo.crossedEcalIds);
90  caloToDetIdMap["hcal"] = &(trackDetMatchInfo.crossedHcalIds);
91  caloToDetIdMap["ho"] = &(trackDetMatchInfo.crossedHOIds);
92  caloToDetIdMap["es"] = &(trackDetMatchInfo.crossedPreshowerIds);
93 
94  edm::ESHandle<CaloGeometry> caloGeo;
95  es.get<CaloGeometryRecord>().get(caloGeo);
96 
97  for ( CaloToDetIdMap::const_iterator caloToDetIdEntry = caloToDetIdMap.begin();
98  caloToDetIdEntry != caloToDetIdMap.end(); ++caloToDetIdEntry ) {
99  std::vector<SteppingHelixStateInfo>::const_iterator itHelixState_first, itHelixState_last;
100  if ( caloToDetIdEntry->first == "ecal" ) {
101  itHelixState_first = trackAssociator_.getCachedTrajector().getEcalTrajectory().begin();
102  itHelixState_last = trackAssociator_.getCachedTrajector().getEcalTrajectory().end();
103  } else if ( caloToDetIdEntry->first == "hcal" ) {
104  itHelixState_first = trackAssociator_.getCachedTrajector().getHcalTrajectory().begin();
105  itHelixState_last = trackAssociator_.getCachedTrajector().getHcalTrajectory().end();
106  } else if ( caloToDetIdEntry->first == "ho" ) {
107  itHelixState_first = trackAssociator_.getCachedTrajector().getHOTrajectory().begin();
108  itHelixState_last = trackAssociator_.getCachedTrajector().getHOTrajectory().end();
109  } else if ( caloToDetIdEntry->first == "es" ) {
110  itHelixState_first = trackAssociator_.getCachedTrajector().getPreshowerTrajectory().begin();
111  itHelixState_last = trackAssociator_.getCachedTrajector().getPreshowerTrajectory().end();
112  } else assert(0);
113 
114  // copy trajectory points
115  std::vector<GlobalPoint> trajectory;
116  for ( std::vector<SteppingHelixStateInfo>::const_iterator helixState = itHelixState_first;
117  helixState != itHelixState_last; ++helixState ) {
118  trajectory.push_back(helixState->position());
119  }
120 
121  // iterate over crossed detIds
122  for ( std::vector<DetId>::const_iterator detId = caloToDetIdEntry->second->begin();
123  detId != caloToDetIdEntry->second->end(); ++detId ) {
124  if ( detId->rawId() == 0 ) continue;
125 
126  const CaloSubdetectorGeometry* subDetGeo = caloGeo->getSubdetectorGeometry(*detId);
127  const CaloCellGeometry* caloCellGeo = subDetGeo->getGeometry(*detId);
128  GlobalPoint previousPoint;
129  bool previousPoint_initialized;
130  float distanceWithinDetId = 0;
131  for ( std::vector<GlobalPoint>::const_iterator point = trajectory.begin();
132  point != trajectory.end(); ++point ) {
133  if ( previousPoint_initialized ) {
134  float dx = point->x() - previousPoint.x();
135  float dy = point->y() - previousPoint.y();
136  float dz = point->z() - previousPoint.z();
137  float distanceBetweenPoints = sqrt(dx*dx + dy*dy + dz*dz);
138  int numSteps = 100;
139  int numStepsWithinDetId = 0;
140  for ( int iStep = 0; iStep <= numSteps; ++iStep ){
141  float stepX = previousPoint.x() + iStep*dx/numSteps;
142  float stepY = previousPoint.y() + iStep*dy/numSteps;
143  float stepZ = previousPoint.z() + iStep*dz/numSteps;
144  GlobalPoint stepPoint(stepX, stepY, stepZ);
145  bool isWithinDetId = caloCellGeo->inside(stepPoint);
146  if ( isWithinDetId ) ++numStepsWithinDetId;
147  }
148  distanceWithinDetId += (numStepsWithinDetId/float(numSteps + 1))*distanceBetweenPoints;
149  }
150  previousPoint = (*point);
151  previousPoint_initialized = true;
152  }
153  distanceMap[detId->rawId()] = distanceWithinDetId;
154  }
155  }
156 }
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
T y() const
Definition: PV3DBase.h:63
TrackDetMatchInfo getTrackDetMatchInfo(const edm::Event &, const edm::EventSetup &, TrackDetectorAssociator &, const TrackAssociatorParameters &, const reco::Candidate *)
const std::vector< SteppingHelixStateInfo > & getPreshowerTrajectory() const
const CachedTrajectory & getCachedTrajector() const
trajector information
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
#define end
Definition: vmac.h:37
Definition: DetId.h:18
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
string const
Definition: compareJSON.py:14
#define begin
Definition: vmac.h:30
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssociatorParameters_
T x() const
Definition: PV3DBase.h:62
T get(const Candidate &c)
Definition: component.h:55
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void MuonCaloDistanceProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 44 of file MuonCaloDistanceProducer.cc.

References fillDistanceMap(), getSelMuons(), getTheMuMinus(), getTheMuPlus(), edm::RefToBase< T >::isNonnull(), patZpeak::muons, edm::Event::put(), and srcSelectedMuons_.

45 {
46  std::auto_ptr<detIdToFloatMap> distanceMuPlus(new detIdToFloatMap());
47  std::auto_ptr<detIdToFloatMap> distanceMuMinus(new detIdToFloatMap());
48  std::auto_ptr<detIdToFloatMap> depositMuPlus(new detIdToFloatMap());
49  std::auto_ptr<detIdToFloatMap> depositMuMinus(new detIdToFloatMap());
50 
51  std::vector<reco::CandidateBaseRef> selMuons = getSelMuons(evt, srcSelectedMuons_);
52  const reco::CandidateBaseRef muPlus = getTheMuPlus(selMuons);
53  const reco::CandidateBaseRef muMinus = getTheMuMinus(selMuons);
54 
55  if ( muPlus.isNonnull() ) fillDistanceMap(evt, es, &(*muPlus), *distanceMuPlus, *depositMuPlus);
56  if ( muMinus.isNonnull() ) fillDistanceMap(evt, es, &(*muMinus), *distanceMuMinus, *depositMuMinus);
57 
58  std::auto_ptr<reco::CandidateCollection> muons(new reco::CandidateCollection);
59  if ( muPlus.isNonnull() ) muons->push_back(new reco::ShallowCloneCandidate(muPlus));
60  if ( muMinus.isNonnull() ) muons->push_back(new reco::ShallowCloneCandidate(muMinus));
61 
62  // References to the muons themselves
63  evt.put(muons, "muons");
64 
65  // maps of detId to distance traversed by muon through calorimeter cell
66  evt.put(distanceMuPlus, "distancesMuPlus");
67  evt.put(distanceMuMinus, "distancesMuMinus");
68 
69  // maps of detId to energy deposited in calorimeter cell
70  evt.put(depositMuPlus, "depositsMuPlus");
71  evt.put(depositMuMinus, "depositsMuMinus");
72 }
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
std::map< uint32_t, float > detIdToFloatMap
void fillDistanceMap(edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
tuple muons
Definition: patZpeak.py:38
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:279

Member Data Documentation

edm::InputTag MuonCaloDistanceProducer::srcSelectedMuons_
private

Definition at line 42 of file MuonCaloDistanceProducer.h.

Referenced by produce().

TrackDetectorAssociator MuonCaloDistanceProducer::trackAssociator_
private

Definition at line 44 of file MuonCaloDistanceProducer.h.

Referenced by fillDistanceMap(), and MuonCaloDistanceProducer().

TrackAssociatorParameters MuonCaloDistanceProducer::trackAssociatorParameters_
private

Definition at line 45 of file MuonCaloDistanceProducer.h.

Referenced by fillDistanceMap(), and MuonCaloDistanceProducer().