#include <MuonTruth.h>
Definition at line 23 of file MuonTruth.h.
Definition at line 26 of file MuonTruth.h.
Definition at line 28 of file MuonTruth.h.
typedef std::pair<uint32_t, EncodedEventId> MuonTruth::SimHitIdpr |
Definition at line 29 of file MuonTruth.h.
Definition at line 27 of file MuonTruth.h.
MuonTruth::MuonTruth | ( | const edm::Event & | event, |
const edm::EventSetup & | setup, | ||
const edm::ParameterSet & | conf | ||
) |
Definition at line 8 of file MuonTruth.cc.
References MixCollection< T >::begin(), crossingframe, cscBadChambers, cscgeom, CSCsimHitsTag, CSCsimHitsXFTag, edm::EventSetup::get(), edm::InputTag::label(), linksTag, LogTrace, edm::ESHandle< T >::product(), edm::Handle< T >::product(), theDigiSimLinks, theSimHitMap, theWireDigiSimLinks, and wireLinksTag.
: theDigiSimLinks(0), theWireDigiSimLinks(0), linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")), wireLinksTag(conf.getParameter<edm::InputTag>("CSCwireLinksTag")), // CrossingFrame used or not ? crossingframe(conf.getParameter<bool>("crossingframe")), CSCsimHitsTag(conf.getParameter<edm::InputTag>("CSCsimHitsTag")), CSCsimHitsXFTag(conf.getParameter<edm::InputTag>("CSCsimHitsXFTag")) { edm::Handle<DigiSimLinks> digiSimLinks; LogTrace("MuonTruth") <<"getting CSC Strip DigiSimLink collection - "<<linksTag; event.getByLabel(linksTag, digiSimLinks); theDigiSimLinks = digiSimLinks.product(); edm::Handle<DigiSimLinks> wireDigiSimLinks; LogTrace("MuonTruth") <<"getting CSC Wire DigiSimLink collection - "<<wireLinksTag; event.getByLabel(wireLinksTag, wireDigiSimLinks); theWireDigiSimLinks = wireDigiSimLinks.product(); // get CSC Geometry to use CSCLayer methods edm::ESHandle<CSCGeometry> mugeom; setup.get<MuonGeometryRecord>().get( mugeom ); cscgeom = &*mugeom; // get CSC Bad Chambers (ME4/2) edm::ESHandle<CSCBadChambers> badChambers; setup.get<CSCBadChambersRcd>().get(badChambers); cscBadChambers = badChambers.product(); theSimHitMap.clear(); if (crossingframe) { edm::Handle<CrossingFrame<PSimHit> > cf; LogTrace("MuonTruth") <<"getting CrossingFrame<PSimHit> collection - "<<CSCsimHitsXFTag; event.getByLabel(CSCsimHitsXFTag, cf); std::auto_ptr<MixCollection<PSimHit> > CSCsimhits( new MixCollection<PSimHit>(cf.product()) ); LogTrace("MuonTruth") <<"... size = "<<CSCsimhits->size(); for(MixCollection<PSimHit>::MixItr hitItr = CSCsimhits->begin(); hitItr != CSCsimhits->end(); ++hitItr) { theSimHitMap[hitItr->detUnitId()].push_back(*hitItr); } } else if (!CSCsimHitsTag.label().empty()){ edm::Handle<edm::PSimHitContainer> CSCsimhits; LogTrace("MuonTruth") <<"getting PSimHit collection - "<<CSCsimHitsTag; event.getByLabel(CSCsimHitsTag, CSCsimhits); LogTrace("MuonTruth") <<"... size = "<<CSCsimhits->size(); for(edm::PSimHitContainer::const_iterator hitItr = CSCsimhits->begin(); hitItr != CSCsimhits->end(); ++hitItr) { theSimHitMap[hitItr->detUnitId()].push_back(*hitItr); } } }
void MuonTruth::addChannel | ( | const LayerLinks & | layerLinks, |
int | channel, | ||
float | weight = 1. |
||
) | [private] |
Definition at line 290 of file MuonTruth.cc.
References edm::DetSet< T >::begin(), DeDxDiscriminatorTools::charge(), edm::DetSet< T >::end(), theChargeMap, theTotalCharge, and CommonMethods::weight().
Referenced by analyze().
{ LayerLinks::const_iterator linkItr = layerLinks.begin(), lastLayerLink = layerLinks.end(); for ( ; linkItr != lastLayerLink; ++linkItr) { int linkChannel = linkItr->channel(); if(linkChannel == channel) { float charge = linkItr->fraction() * weight; theTotalCharge += charge; // see if it's in the map SimHitIdpr truthId(linkItr->SimTrackId(),linkItr->eventId()); std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.find(truthId); if(chargeMapItr == theChargeMap.end()) { theChargeMap[truthId] = charge; } else { theChargeMap[truthId] += charge; } } } }
void MuonTruth::analyze | ( | const CSCWireDigi & | wireDigi, |
int | rawDetIdCorrespondingToCSCLayer | ||
) |
Definition at line 272 of file MuonTruth.cc.
References addChannel(), edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), CSCWireDigi::getWireGroup(), theChargeMap, theDetId, theDigiSimLinks, theTotalCharge, and theWireDigiSimLinks.
{ theDetId = rawDetIdCorrespondingToCSCLayer; theChargeMap.clear(); theTotalCharge = 0.; WireDigiSimLinks::const_iterator layerLinks = theWireDigiSimLinks->find(theDetId); if(layerLinks != theDigiSimLinks->end()) { // In the simulation digis, the channel labels for wires and strips must be distinct, therefore: int wireDigiInSimulation = wireDigi.getWireGroup() + 100; // addChannel(*layerLinks, wireDigiInSimulation, 1.); } }
void MuonTruth::analyze | ( | const CSCRecHit2D & | recHit | ) |
Definition at line 231 of file MuonTruth.cc.
References CSCRecHit2D::adcs(), addChannel(), CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), DetId::rawId(), theChargeMap, theDetId, theDigiSimLinks, theTotalCharge, and CommonMethods::weight().
Referenced by CSCTruthTest::analyze().
{ theChargeMap.clear(); theTotalCharge = 0.; theDetId = recHit.geographicalId().rawId(); int nchannels = recHit.channels().size(); CSCRecHit2D::ADCContainer adcContainer = recHit.adcs(); const CSCLayerGeometry * laygeom = cscgeom->layer(recHit.cscDetId())->geometry(); for(int idigi = 0; idigi < nchannels; ++idigi) { // strip and readout channel numbers may differ in ME1/1A int istrip = recHit.channels()[idigi]; int channel = laygeom->channel(istrip); float weight = adcContainer[idigi]; DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(theDetId); if(layerLinks != theDigiSimLinks->end()) { addChannel(*layerLinks, channel, weight); } } }
void MuonTruth::analyze | ( | const CSCStripDigi & | stripDigi, |
int | rawDetIdCorrespondingToCSCLayer | ||
) |
Definition at line 258 of file MuonTruth.cc.
References addChannel(), edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), CSCStripDigi::getStrip(), theChargeMap, theDetId, theDigiSimLinks, and theTotalCharge.
{ theDetId = rawDetIdCorrespondingToCSCLayer; theChargeMap.clear(); theTotalCharge = 0.; DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(theDetId); if(layerLinks != theDigiSimLinks->end()) { addChannel(*layerLinks, stripDigi.getStrip(), 1.); } }
std::vector< MuonTruth::SimHitIdpr > MuonTruth::associateCSCHitId | ( | const CSCRecHit2D * | cscrechit | ) |
Definition at line 121 of file MuonTruth.cc.
References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), spr::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), link(), DetId::rawId(), theDetId, and theDigiSimLinks.
Referenced by MuonAssociatorByHits::getMatchedIds().
{ std::vector<SimHitIdpr> simtrackids; theDetId = cscrechit->geographicalId().rawId(); int nchannels = cscrechit->channels().size(); const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry(); DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(theDetId); if (layerLinks != theDigiSimLinks->end()) { for(int idigi = 0; idigi < nchannels; ++idigi) { // strip and readout channel numbers may differ in ME1/1A int istrip = cscrechit->channels()[idigi]; int channel = laygeom->channel(istrip); for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) { int ch = static_cast<int>(link->channel()); if (ch == channel) { SimHitIdpr currentId(link->SimTrackId(), link->eventId()); if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end()) simtrackids.push_back(currentId); } } } } else edm::LogWarning("MuonTruth") <<"*** WARNING in MuonTruth::associateCSCHitId - CSC layer "<<theDetId<<" has no DigiSimLinks !"<<std::endl; return simtrackids; }
std::vector< MuonTruth::SimHitIdpr > MuonTruth::associateHitId | ( | const TrackingRecHit & | hit | ) |
Definition at line 154 of file MuonTruth.cc.
References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), spr::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), link(), DetId::rawId(), theDetId, and theDigiSimLinks.
{ std::vector<SimHitIdpr> simtrackids; const TrackingRecHit * hitp = &hit; const CSCRecHit2D * cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp); if (cscrechit) { theDetId = cscrechit->geographicalId().rawId(); int nchannels = cscrechit->channels().size(); const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry(); DigiSimLinks::const_iterator layerLinks = theDigiSimLinks->find(theDetId); if (layerLinks != theDigiSimLinks->end()) { for(int idigi = 0; idigi < nchannels; ++idigi) { // strip and readout channel numbers may differ in ME1/1A int istrip = cscrechit->channels()[idigi]; int channel = laygeom->channel(istrip); for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) { int ch = static_cast<int>(link->channel()); if (ch == channel) { SimHitIdpr currentId(link->SimTrackId(), link->eventId()); if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end()) simtrackids.push_back(currentId); } } } } else edm::LogWarning("MuonTruth") <<"*** WARNING in MuonTruth::associateHitId - CSC layer "<<theDetId<<" has no DigiSimLinks !"<<std::endl; } else edm::LogWarning("MuonTruth")<<"*** WARNING in MuonTruth::associateHitId, null dynamic_cast !"; return simtrackids; }
std::vector< PSimHit > MuonTruth::hitsFromSimTrack | ( | MuonTruth::SimHitIdpr | truthId | ) | [private] |
Definition at line 195 of file MuonTruth.cc.
References query::result, theDetId, and theSimHitMap.
Referenced by particleType(), and simHits().
{ std::vector<PSimHit> result; edm::PSimHitContainer hits; if (theSimHitMap.find(theDetId) != theSimHitMap.end()) hits = theSimHitMap[theDetId]; edm::PSimHitContainer::const_iterator hitItr = hits.begin(), lastHit = hits.end(); for( ; hitItr != lastHit; ++hitItr) { unsigned int hitTrack = hitItr->trackId(); EncodedEventId hitEvId = hitItr->eventId(); if(hitTrack == truthId.first && hitEvId == truthId.second) { result.push_back(*hitItr); } } return result; }
float MuonTruth::muonFraction | ( | ) |
analyze() must be called before any of the following
Definition at line 72 of file MuonTruth.cc.
References abs, particleType(), theChargeMap, and theTotalCharge.
Referenced by CSCTruthTest::analyze().
{ if(theChargeMap.size() == 0) return 0.; float muonCharge = 0.; for(std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.begin(); chargeMapItr != theChargeMap.end(); ++chargeMapItr) { if( abs(particleType(chargeMapItr->first)) == 13) { muonCharge += chargeMapItr->second; } } return muonCharge / theTotalCharge; }
std::vector< PSimHit > MuonTruth::muonHits | ( | ) |
Definition at line 104 of file MuonTruth.cc.
References abs, query::result, and simHits().
int MuonTruth::particleType | ( | MuonTruth::SimHitIdpr | truthId | ) | [private] |
Definition at line 219 of file MuonTruth.cc.
References hitsFromSimTrack(), and query::result.
Referenced by muonFraction().
{ int result = 0; std::vector<PSimHit> hits = hitsFromSimTrack(truthId); if(!hits.empty()) { result = hits[0].particleType(); } return result; }
std::vector< PSimHit > MuonTruth::simHits | ( | ) |
Definition at line 90 of file MuonTruth.cc.
References hitsFromSimTrack(), query::result, and theChargeMap.
Referenced by muonHits().
{ std::vector<PSimHit> result; for(std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.begin(); chargeMapItr != theChargeMap.end(); ++chargeMapItr) { std::vector<PSimHit> trackHits = hitsFromSimTrack(chargeMapItr->first); result.insert(result.end(), trackHits.begin(), trackHits.end()); } return result; }
bool MuonTruth::crossingframe [private] |
Definition at line 67 of file MuonTruth.h.
Referenced by MuonTruth().
Definition at line 46 of file MuonTruth.h.
Referenced by MuonAssociatorByHits::associateSimToRecoIndices(), and MuonTruth().
const CSCGeometry* MuonTruth::cscgeom [private] |
Definition at line 73 of file MuonTruth.h.
Referenced by analyze(), associateCSCHitId(), associateHitId(), and MuonTruth().
edm::InputTag MuonTruth::CSCsimHitsTag [private] |
Definition at line 68 of file MuonTruth.h.
Referenced by MuonTruth().
edm::InputTag MuonTruth::CSCsimHitsXFTag [private] |
Definition at line 69 of file MuonTruth.h.
Referenced by MuonTruth().
edm::InputTag MuonTruth::linksTag [private] |
Definition at line 64 of file MuonTruth.h.
Referenced by MuonTruth().
std::map<SimHitIdpr, float> MuonTruth::theChargeMap [private] |
Definition at line 56 of file MuonTruth.h.
Referenced by addChannel(), analyze(), muonFraction(), and simHits().
unsigned int MuonTruth::theDetId [private] |
Definition at line 59 of file MuonTruth.h.
Referenced by analyze(), associateCSCHitId(), associateHitId(), and hitsFromSimTrack().
const DigiSimLinks* MuonTruth::theDigiSimLinks [private] |
Definition at line 61 of file MuonTruth.h.
Referenced by analyze(), associateCSCHitId(), associateHitId(), and MuonTruth().
std::map<unsigned int, edm::PSimHitContainer> MuonTruth::theSimHitMap [private] |
Definition at line 71 of file MuonTruth.h.
Referenced by hitsFromSimTrack(), and MuonTruth().
float MuonTruth::theTotalCharge [private] |
Definition at line 57 of file MuonTruth.h.
Referenced by addChannel(), analyze(), and muonFraction().
const DigiSimLinks* MuonTruth::theWireDigiSimLinks [private] |
Definition at line 62 of file MuonTruth.h.
Referenced by analyze(), and MuonTruth().
edm::InputTag MuonTruth::wireLinksTag [private] |
Definition at line 65 of file MuonTruth.h.
Referenced by MuonTruth().