22 #include <boost/foreach.hpp>
25 : srcSelectedMuons_(cfg.getParameter<edm::
InputTag>(
"selectedMuons"))
28 produces<reco::CandidateCollection>(
"muons");
29 produces<detIdToFloatMap>(
"distancesMuPlus");
30 produces<detIdToFloatMap>(
"distancesMuMinus");
31 produces<detIdToFloatMap>(
"depositsMuPlus");
32 produces<detIdToFloatMap>(
"depositsMuMinus");
64 evt.
put(muons,
"muons");
67 evt.
put(distanceMuPlus,
"distancesMuPlus");
68 evt.
put(distanceMuMinus,
"distancesMuMinus");
71 evt.
put(depositMuPlus,
"depositsMuPlus");
72 evt.
put(depositMuMinus,
"depositsMuMinus");
88 typedef std::map<std::string, const std::vector<DetId>*> CaloToDetIdMap;
89 CaloToDetIdMap caloToDetIdMap;
92 caloToDetIdMap[
"ho"] = &(trackDetMatchInfo.
crossedHOIds);
98 for ( CaloToDetIdMap::const_iterator caloToDetIdEntry = caloToDetIdMap.begin();
99 caloToDetIdEntry != caloToDetIdMap.end(); ++caloToDetIdEntry ) {
100 std::vector<SteppingHelixStateInfo>::const_iterator itHelixState_first, itHelixState_last;
101 if ( caloToDetIdEntry->first ==
"ecal" ) {
104 }
else if ( caloToDetIdEntry->first ==
"hcal" ) {
107 }
else if ( caloToDetIdEntry->first ==
"ho" ) {
110 }
else if ( caloToDetIdEntry->first ==
"es" ) {
116 std::vector<GlobalPoint> trajectory;
117 for ( std::vector<SteppingHelixStateInfo>::const_iterator helixState = itHelixState_first;
118 helixState != itHelixState_last; ++helixState ) {
119 trajectory.push_back(helixState->position());
123 for ( std::vector<DetId>::const_iterator detId = caloToDetIdEntry->second->begin();
124 detId != caloToDetIdEntry->second->end(); ++detId ) {
125 if ( detId->rawId() == 0 )
continue;
130 bool previousPoint_initialized;
131 float distanceWithinDetId = 0;
132 for ( std::vector<GlobalPoint>::const_iterator
point = trajectory.begin();
134 if ( previousPoint_initialized ) {
135 float dx =
point->x() - previousPoint.
x();
136 float dy =
point->y() - previousPoint.
y();
137 float dz =
point->z() - previousPoint.
z();
138 float distanceBetweenPoints =
sqrt(dx*dx + dy*dy + dz*dz);
140 int numStepsWithinDetId = 0;
141 for (
int iStep = 0; iStep <= numSteps; ++iStep ){
142 float stepX = previousPoint.
x() + iStep*dx/numSteps;
143 float stepY = previousPoint.
y() + iStep*dy/numSteps;
144 float stepZ = previousPoint.
z() + iStep*dz/numSteps;
146 bool isWithinDetId = caloCellGeo->
inside(stepPoint);
147 if ( isWithinDetId ) ++numStepsWithinDetId;
149 distanceWithinDetId += (numStepsWithinDetId/float(numSteps + 1))*distanceBetweenPoints;
151 previousPoint = (*point);
152 previousPoint_initialized =
true;
154 distanceMap[detId->rawId()] = distanceWithinDetId;
std::vector< DetId > crossedPreshowerIds
T getParameter(std::string const &) const
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
std::vector< const HBHERecHit * > crossedHcalRecHits
const std::vector< SteppingHelixStateInfo > & getHOTrajectory() const
const DetId & detid() const
const std::vector< SteppingHelixStateInfo > & getHcalTrajectory() const
#define DEFINE_FWK_MODULE(type)
std::vector< DetId > crossedEcalIds
void useDefaultPropagator()
use the default propagator
const DetId & detid() const
std::map< uint32_t, float > detIdToFloatMap
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
bool isNonnull() const
Checks for non-null.
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< DetId > crossedHcalIds
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.
uint32_t rawId() const
get the raw id
virtual void produce(edm::Event &, const edm::EventSetup &)
void fillDistanceMap(edm::Event &, const edm::EventSetup &, const reco::Candidate *, detIdToFloatMap &, detIdToFloatMap &)
const std::vector< SteppingHelixStateInfo > & getEcalTrajectory() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
~MuonCaloDistanceProducer()
std::vector< DetId > crossedHOIds
bool inside(const GlobalPoint &point) const
Returns true if the specified point is inside this cell.
TrackDetectorAssociator trackAssociator_
std::vector< const HORecHit * > crossedHORecHits
MuonCaloDistanceProducer(const edm::ParameterSet &)
TrackAssociatorParameters trackAssociatorParameters_
edm::InputTag srcSelectedMuons_
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
*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