CMS 3D CMS Logo

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

#include <MuonTruth.h>

Public Types

typedef edm::DetSetVector
< StripDigiSimLink
DigiSimLinks
 
typedef edm::DetSet
< StripDigiSimLink
LayerLinks
 
typedef std::pair< uint32_t,
EncodedEventId
SimHitIdpr
 
typedef edm::DetSetVector
< StripDigiSimLink
WireDigiSimLinks
 

Public Member Functions

void analyze (const CSCRecHit2D &recHit)
 
void analyze (const CSCStripDigi &stripDigi, int rawDetIdCorrespondingToCSCLayer)
 
void analyze (const CSCWireDigi &wireDigi, int rawDetIdCorrespondingToCSCLayer)
 
std::vector< SimHitIdprassociateCSCHitId (const CSCRecHit2D *)
 
std::vector< SimHitIdprassociateHitId (const TrackingRecHit &)
 
void initEvent (const edm::Event &, const edm::EventSetup &)
 
float muonFraction ()
 analyze() must be called before any of the following More...
 
std::vector< PSimHitmuonHits ()
 
 MuonTruth (const edm::Event &, const edm::EventSetup &, const edm::ParameterSet &)
 
 MuonTruth (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
std::vector< PSimHitsimHits ()
 

Public Attributes

const CSCBadChamberscscBadChambers
 

Private Member Functions

void addChannel (const LayerLinks &layerLinks, int channel, float weight=1.)
 
std::vector< PSimHithitsFromSimTrack (SimHitIdpr truthId)
 
int particleType (SimHitIdpr truthId)
 

Private Attributes

bool crossingframe
 
const CSCGeometrycscgeom
 
edm::InputTag CSCsimHitsTag
 
edm::InputTag CSCsimHitsXFTag
 
edm::InputTag linksTag
 
std::map< SimHitIdpr, float > theChargeMap
 
unsigned int theDetId
 
const DigiSimLinkstheDigiSimLinks
 
std::map< unsigned int,
edm::PSimHitContainer
theSimHitMap
 
float theTotalCharge
 
const DigiSimLinkstheWireDigiSimLinks
 
edm::InputTag wireLinksTag
 

Detailed Description

Definition at line 24 of file MuonTruth.h.

Member Typedef Documentation

Definition at line 27 of file MuonTruth.h.

Definition at line 29 of file MuonTruth.h.

typedef std::pair<uint32_t, EncodedEventId> MuonTruth::SimHitIdpr

Definition at line 30 of file MuonTruth.h.

Definition at line 28 of file MuonTruth.h.

Constructor & Destructor Documentation

MuonTruth::MuonTruth ( const edm::Event event,
const edm::EventSetup setup,
const edm::ParameterSet conf 
)

Definition at line 8 of file MuonTruth.cc.

References initEvent().

8  :
11  linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")),
12  wireLinksTag(conf.getParameter<edm::InputTag>("CSCwireLinksTag")),
13  // CrossingFrame used or not ?
14  crossingframe(conf.getParameter<bool>("crossingframe")),
15  CSCsimHitsTag(conf.getParameter<edm::InputTag>("CSCsimHitsTag")),
16  CSCsimHitsXFTag(conf.getParameter<edm::InputTag>("CSCsimHitsXFTag"))
17 
18 {
19  initEvent(event,setup);
20 }
T getParameter(std::string const &) const
edm::InputTag CSCsimHitsTag
Definition: MuonTruth.h:73
edm::InputTag linksTag
Definition: MuonTruth.h:69
edm::InputTag CSCsimHitsXFTag
Definition: MuonTruth.h:74
edm::InputTag wireLinksTag
Definition: MuonTruth.h:70
const DigiSimLinks * theWireDigiSimLinks
Definition: MuonTruth.h:67
bool crossingframe
Definition: MuonTruth.h:72
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
void initEvent(const edm::Event &, const edm::EventSetup &)
Definition: MuonTruth.cc:43
MuonTruth::MuonTruth ( const edm::ParameterSet conf,
edm::ConsumesCollector &&  iC 
)

Definition at line 22 of file MuonTruth.cc.

References crossingframe, CSCsimHitsTag, CSCsimHitsXFTag, edm::InputTag::label(), linksTag, and wireLinksTag.

22  :
23  theDigiSimLinks(0),
25  linksTag(conf.getParameter<edm::InputTag>("CSClinksTag")),
26  wireLinksTag(conf.getParameter<edm::InputTag>("CSCwireLinksTag")),
27  // CrossingFrame used or not ?
28  crossingframe(conf.getParameter<bool>("crossingframe")),
29  CSCsimHitsTag(conf.getParameter<edm::InputTag>("CSCsimHitsTag")),
30  CSCsimHitsXFTag(conf.getParameter<edm::InputTag>("CSCsimHitsXFTag"))
31 
32 {
35  if ( crossingframe ) {
37  } else if (!CSCsimHitsTag.label().empty()){
39  }
40 
41 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::InputTag CSCsimHitsTag
Definition: MuonTruth.h:73
edm::InputTag linksTag
Definition: MuonTruth.h:69
edm::InputTag CSCsimHitsXFTag
Definition: MuonTruth.h:74
edm::InputTag wireLinksTag
Definition: MuonTruth.h:70
const DigiSimLinks * theWireDigiSimLinks
Definition: MuonTruth.h:67
bool crossingframe
Definition: MuonTruth.h:72
std::string const & label() const
Definition: InputTag.h:42
edm::DetSetVector< StripDigiSimLink > DigiSimLinks
Definition: MuonTruth.h:27
std::vector< PSimHit > PSimHitContainer
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66

Member Function Documentation

void MuonTruth::addChannel ( const LayerLinks layerLinks,
int  channel,
float  weight = 1. 
)
private

Definition at line 315 of file MuonTruth.cc.

References edm::DetSet< T >::begin(), DeDxDiscriminatorTools::charge(), edm::DetSet< T >::end(), theChargeMap, theTotalCharge, and histoStyle::weight.

Referenced by analyze().

316 {
317  LayerLinks::const_iterator linkItr = layerLinks.begin(),
318  lastLayerLink = layerLinks.end();
319 
320  for ( ; linkItr != lastLayerLink; ++linkItr)
321  {
322  int linkChannel = linkItr->channel();
323  if(linkChannel == channel)
324  {
325  float charge = linkItr->fraction() * weight;
327  // see if it's in the map
328  SimHitIdpr truthId(linkItr->SimTrackId(),linkItr->eventId());
329  std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.find(truthId);
330  if(chargeMapItr == theChargeMap.end())
331  {
332  theChargeMap[truthId] = charge;
333  }
334  else
335  {
336  theChargeMap[truthId] += charge;
337  }
338  }
339  }
340 }
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
double charge(const std::vector< uint8_t > &Ampls)
float theTotalCharge
Definition: MuonTruth.h:62
std::pair< uint32_t, EncodedEventId > SimHitIdpr
int weight
Definition: histoStyle.py:50
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
void MuonTruth::analyze ( const CSCRecHit2D recHit)

Definition at line 257 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(), CSCRecHit2D::nStrips(), DetId::rawId(), theChargeMap, theDetId, theDigiSimLinks, theTotalCharge, and histoStyle::weight.

Referenced by CSCTruthTest::analyze().

258 {
259  theChargeMap.clear();
260  theTotalCharge = 0.;
261  theDetId = recHit.geographicalId().rawId();
262 
263  int nchannels = recHit.nStrips();
264  const CSCLayerGeometry * laygeom = cscgeom->layer(recHit.cscDetId())->geometry();
265 
266  for(int idigi = 0; idigi < nchannels; ++idigi)
267  {
268  // strip and readout channel numbers may differ in ME1/1A
269  int istrip = recHit.channels(idigi);
270  int channel = laygeom->channel(istrip);
271  float weight = recHit.adcs(idigi,0);//DL: I think this is wrong before and after...seems to assume one time binadcContainer[idigi];
272 
274 
275  if(layerLinks != theDigiSimLinks->end())
276  {
277  addChannel(*layerLinks, channel, weight);
278  }
279  }
280 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:292
const CSCGeometry * cscgeom
Definition: MuonTruth.h:78
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
unsigned int theDetId
Definition: MuonTruth.h:64
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
float adcs(unsigned int strip, unsigned int timebin) const
Map of strip ADCs for strips comprising the rechit.
Definition: CSCRecHit2D.h:68
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
int channel(int strip) const
float theTotalCharge
Definition: MuonTruth.h:62
ESHandle< TrackerGeometry > geometry
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:124
DetId geographicalId() const
int weight
Definition: histoStyle.py:50
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void addChannel(const LayerLinks &layerLinks, int channel, float weight=1.)
Definition: MuonTruth.cc:315
void MuonTruth::analyze ( const CSCStripDigi stripDigi,
int  rawDetIdCorrespondingToCSCLayer 
)

Definition at line 283 of file MuonTruth.cc.

References addChannel(), edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), CSCStripDigi::getStrip(), theChargeMap, theDetId, theDigiSimLinks, and theTotalCharge.

284 {
285  theDetId = rawDetIdCorrespondingToCSCLayer;
286  theChargeMap.clear();
287  theTotalCharge = 0.;
288 
290  if(layerLinks != theDigiSimLinks->end())
291  {
292  addChannel(*layerLinks, stripDigi.getStrip(), 1.);
293  }
294 }
iterator find(det_id_type id)
Definition: DetSetVector.h:292
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
int getStrip() const
Definition: CSCStripDigi.h:51
unsigned int theDetId
Definition: MuonTruth.h:64
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
float theTotalCharge
Definition: MuonTruth.h:62
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void addChannel(const LayerLinks &layerLinks, int channel, float weight=1.)
Definition: MuonTruth.cc:315
void MuonTruth::analyze ( const CSCWireDigi wireDigi,
int  rawDetIdCorrespondingToCSCLayer 
)

Definition at line 297 of file MuonTruth.cc.

References addChannel(), edm::DetSetVector< T >::end(), edm::DetSetVector< T >::find(), CSCWireDigi::getWireGroup(), theChargeMap, theDetId, theDigiSimLinks, theTotalCharge, and theWireDigiSimLinks.

298 {
299  theDetId = rawDetIdCorrespondingToCSCLayer;
300  theChargeMap.clear();
301  theTotalCharge = 0.;
302 
304 
305  if(layerLinks != theDigiSimLinks->end())
306  {
307  // In the simulation digis, the channel labels for wires and strips must be distinct, therefore:
308  int wireDigiInSimulation = wireDigi.getWireGroup() + 100;
309  //
310  addChannel(*layerLinks, wireDigiInSimulation, 1.);
311  }
312 }
iterator find(det_id_type id)
Definition: DetSetVector.h:292
const DigiSimLinks * theWireDigiSimLinks
Definition: MuonTruth.h:67
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
unsigned int theDetId
Definition: MuonTruth.h:64
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
float theTotalCharge
Definition: MuonTruth.h:62
int getWireGroup() const
default
Definition: CSCWireDigi.h:24
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void addChannel(const LayerLinks &layerLinks, int channel, float weight=1.)
Definition: MuonTruth.cc:315
std::vector< MuonTruth::SimHitIdpr > MuonTruth::associateCSCHitId ( const CSCRecHit2D cscrechit)

Definition at line 147 of file MuonTruth.cc.

References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), spr::find(), edm::DetSetVector< T >::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), link(), CSCRecHit2D::nStrips(), DetId::rawId(), theDetId, and theDigiSimLinks.

Referenced by MuonAssociatorByHits::getMatchedIds().

147  {
148  std::vector<SimHitIdpr> simtrackids;
149 
150  theDetId = cscrechit->geographicalId().rawId();
151  int nchannels = cscrechit->nStrips();
152  const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
153 
155 
156  if (layerLinks != theDigiSimLinks->end()) {
157 
158  for(int idigi = 0; idigi < nchannels; ++idigi) {
159  // strip and readout channel numbers may differ in ME1/1A
160  int istrip = cscrechit->channels(idigi);
161  int channel = laygeom->channel(istrip);
162 
163  for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) {
164  int ch = static_cast<int>(link->channel());
165  if (ch == channel) {
166  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
167  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
168  simtrackids.push_back(currentId);
169  }
170  }
171  }
172 
173  } else edm::LogWarning("MuonTruth")
174  <<"*** WARNING in MuonTruth::associateCSCHitId - CSC layer "<<theDetId<<" has no DigiSimLinks !"<<std::endl;
175 
176  return simtrackids;
177 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:292
const CSCGeometry * cscgeom
Definition: MuonTruth.h:78
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
unsigned int theDetId
Definition: MuonTruth.h:64
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
int channel(int strip) const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
ESHandle< TrackerGeometry > geometry
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:124
DetId geographicalId() const
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
std::vector< MuonTruth::SimHitIdpr > MuonTruth::associateHitId ( const TrackingRecHit hit)

Definition at line 180 of file MuonTruth.cc.

References CSCLayerGeometry::channel(), CSCRecHit2D::channels(), CSCRecHit2D::cscDetId(), cscgeom, edm::DetSetVector< T >::end(), spr::find(), edm::DetSetVector< T >::find(), TrackingRecHit::geographicalId(), geometry, CSCGeometry::layer(), link(), CSCRecHit2D::nStrips(), DetId::rawId(), theDetId, and theDigiSimLinks.

181 {
182  std::vector<SimHitIdpr> simtrackids;
183 
184  const TrackingRecHit * hitp = &hit;
185  const CSCRecHit2D * cscrechit = dynamic_cast<const CSCRecHit2D *>(hitp);
186 
187  if (cscrechit) {
188 
189  theDetId = cscrechit->geographicalId().rawId();
190  int nchannels = cscrechit->nStrips();
191  const CSCLayerGeometry * laygeom = cscgeom->layer(cscrechit->cscDetId())->geometry();
192 
194 
195  if (layerLinks != theDigiSimLinks->end()) {
196 
197  for(int idigi = 0; idigi < nchannels; ++idigi) {
198  // strip and readout channel numbers may differ in ME1/1A
199  int istrip = cscrechit->channels(idigi);
200  int channel = laygeom->channel(istrip);
201 
202  for (LayerLinks::const_iterator link=layerLinks->begin(); link!=layerLinks->end(); ++link) {
203  int ch = static_cast<int>(link->channel());
204  if (ch == channel) {
205  SimHitIdpr currentId(link->SimTrackId(), link->eventId());
206  if (find(simtrackids.begin(), simtrackids.end(), currentId) == simtrackids.end())
207  simtrackids.push_back(currentId);
208  }
209  }
210  }
211 
212  } else edm::LogWarning("MuonTruth")
213  <<"*** WARNING in MuonTruth::associateHitId - CSC layer "<<theDetId<<" has no DigiSimLinks !"<<std::endl;
214 
215  } else edm::LogWarning("MuonTruth")<<"*** WARNING in MuonTruth::associateHitId, null dynamic_cast !";
216 
217  return simtrackids;
218 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
iterator find(det_id_type id)
Definition: DetSetVector.h:292
const CSCGeometry * cscgeom
Definition: MuonTruth.h:78
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
Definition: CSCRecHit2D.h:55
unsigned int theDetId
Definition: MuonTruth.h:64
unsigned int nStrips() const
Definition: CSCRecHit2D.h:56
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:363
int channel(int strip) const
std::pair< uint32_t, EncodedEventId > SimHitIdpr
ESHandle< TrackerGeometry > geometry
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to given DetId.
Definition: CSCGeometry.cc:124
DetId geographicalId() const
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
std::vector< PSimHit > MuonTruth::hitsFromSimTrack ( MuonTruth::SimHitIdpr  truthId)
private

Definition at line 221 of file MuonTruth.cc.

References query::result, theDetId, and theSimHitMap.

Referenced by particleType(), and simHits().

222 {
223  std::vector<PSimHit> result;
225 
226  if (theSimHitMap.find(theDetId) != theSimHitMap.end())
227  hits = theSimHitMap[theDetId];
228 
229  edm::PSimHitContainer::const_iterator hitItr = hits.begin(), lastHit = hits.end();
230 
231  for( ; hitItr != lastHit; ++hitItr)
232  {
233  unsigned int hitTrack = hitItr->trackId();
234  EncodedEventId hitEvId = hitItr->eventId();
235 
236  if(hitTrack == truthId.first && hitEvId == truthId.second)
237  {
238  result.push_back(*hitItr);
239  }
240  }
241  return result;
242 }
std::map< unsigned int, edm::PSimHitContainer > theSimHitMap
Definition: MuonTruth.h:76
unsigned int theDetId
Definition: MuonTruth.h:64
tuple result
Definition: query.py:137
std::vector< PSimHit > PSimHitContainer
void MuonTruth::initEvent ( const edm::Event event,
const edm::EventSetup setup 
)

Definition at line 43 of file MuonTruth.cc.

References crossingframe, cscBadChambers, cscgeom, CSCsimHitsTag, CSCsimHitsXFTag, edm::EventSetup::get(), edm::InputTag::label(), linksTag, LogTrace, edm::Handle< T >::product(), edm::ESHandle< class >::product(), theDigiSimLinks, theSimHitMap, theWireDigiSimLinks, and wireLinksTag.

Referenced by MuonTruth().

43  {
44 
45  edm::Handle<DigiSimLinks> digiSimLinks;
46  LogTrace("MuonTruth") <<"getting CSC Strip DigiSimLink collection - "<<linksTag;
47  event.getByLabel(linksTag, digiSimLinks);
48  theDigiSimLinks = digiSimLinks.product();
49 
50  edm::Handle<DigiSimLinks> wireDigiSimLinks;
51  LogTrace("MuonTruth") <<"getting CSC Wire DigiSimLink collection - "<<wireLinksTag;
52  event.getByLabel(wireLinksTag, wireDigiSimLinks);
53  theWireDigiSimLinks = wireDigiSimLinks.product();
54 
55  // get CSC Geometry to use CSCLayer methods
57  setup.get<MuonGeometryRecord>().get( mugeom );
58  cscgeom = &*mugeom;
59 
60  // get CSC Bad Chambers (ME4/2)
62  setup.get<CSCBadChambersRcd>().get(badChambers);
63  cscBadChambers = badChambers.product();
64 
65  theSimHitMap.clear();
66 
67  if (crossingframe) {
68 
70  LogTrace("MuonTruth") <<"getting CrossingFrame<PSimHit> collection - "<<CSCsimHitsXFTag;
71  event.getByLabel(CSCsimHitsXFTag, cf);
72 
73  std::auto_ptr<MixCollection<PSimHit> >
74  CSCsimhits( new MixCollection<PSimHit>(cf.product()) );
75  LogTrace("MuonTruth") <<"... size = "<<CSCsimhits->size();
76 
77  for(MixCollection<PSimHit>::MixItr hitItr = CSCsimhits->begin();
78  hitItr != CSCsimhits->end(); ++hitItr)
79  {
80  theSimHitMap[hitItr->detUnitId()].push_back(*hitItr);
81  }
82 
83  } else if (!CSCsimHitsTag.label().empty()){
84 
86  LogTrace("MuonTruth") <<"getting PSimHit collection - "<<CSCsimHitsTag;
87  event.getByLabel(CSCsimHitsTag, CSCsimhits);
88  LogTrace("MuonTruth") <<"... size = "<<CSCsimhits->size();
89 
90  for(edm::PSimHitContainer::const_iterator hitItr = CSCsimhits->begin();
91  hitItr != CSCsimhits->end(); ++hitItr)
92  {
93  theSimHitMap[hitItr->detUnitId()].push_back(*hitItr);
94  }
95  }
96 }
std::map< unsigned int, edm::PSimHitContainer > theSimHitMap
Definition: MuonTruth.h:76
edm::InputTag CSCsimHitsTag
Definition: MuonTruth.h:73
edm::InputTag linksTag
Definition: MuonTruth.h:69
edm::InputTag CSCsimHitsXFTag
Definition: MuonTruth.h:74
edm::InputTag wireLinksTag
Definition: MuonTruth.h:70
const DigiSimLinks * theWireDigiSimLinks
Definition: MuonTruth.h:67
const CSCGeometry * cscgeom
Definition: MuonTruth.h:78
bool crossingframe
Definition: MuonTruth.h:72
const CSCBadChambers * cscBadChambers
Definition: MuonTruth.h:51
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
const DigiSimLinks * theDigiSimLinks
Definition: MuonTruth.h:66
float MuonTruth::muonFraction ( )

analyze() must be called before any of the following

Definition at line 98 of file MuonTruth.cc.

References funct::abs(), particleType(), theChargeMap, and theTotalCharge.

Referenced by CSCTruthTest::analyze().

99 {
100  if(theChargeMap.size() == 0) return 0.;
101 
102  float muonCharge = 0.;
103  for(std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.begin();
104  chargeMapItr != theChargeMap.end(); ++chargeMapItr)
105  {
106  if( abs(particleType(chargeMapItr->first)) == 13)
107  {
108  muonCharge += chargeMapItr->second;
109  }
110  }
111 
112  return muonCharge / theTotalCharge;
113 }
int particleType(SimHitIdpr truthId)
Definition: MuonTruth.cc:245
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float theTotalCharge
Definition: MuonTruth.h:62
std::vector< PSimHit > MuonTruth::muonHits ( )

Definition at line 130 of file MuonTruth.cc.

References funct::abs(), query::result, and simHits().

131 {
132  std::vector<PSimHit> result;
133  std::vector<PSimHit> allHits = simHits();
134  std::vector<PSimHit>::const_iterator hitItr = allHits.begin(), lastHit = allHits.end();
135 
136  for( ; hitItr != lastHit; ++hitItr)
137  {
138  if(abs((*hitItr).particleType()) == 13)
139  {
140  result.push_back(*hitItr);
141  }
142  }
143  return result;
144 }
std::vector< PSimHit > simHits()
Definition: MuonTruth.cc:116
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int MuonTruth::particleType ( MuonTruth::SimHitIdpr  truthId)
private

Definition at line 245 of file MuonTruth.cc.

References hitsFromSimTrack(), and query::result.

Referenced by muonFraction().

246 {
247  int result = 0;
248  std::vector<PSimHit> hits = hitsFromSimTrack(truthId);
249  if(!hits.empty())
250  {
251  result = hits[0].particleType();
252  }
253  return result;
254 }
std::vector< PSimHit > hitsFromSimTrack(SimHitIdpr truthId)
Definition: MuonTruth.cc:221
tuple result
Definition: query.py:137
std::vector< PSimHit > MuonTruth::simHits ( )

Definition at line 116 of file MuonTruth.cc.

References hitsFromSimTrack(), query::result, and theChargeMap.

Referenced by muonHits().

117 {
118  std::vector<PSimHit> result;
119  for(std::map<SimHitIdpr, float>::const_iterator chargeMapItr = theChargeMap.begin();
120  chargeMapItr != theChargeMap.end(); ++chargeMapItr)
121  {
122  std::vector<PSimHit> trackHits = hitsFromSimTrack(chargeMapItr->first);
123  result.insert(result.end(), trackHits.begin(), trackHits.end());
124  }
125 
126  return result;
127 }
std::map< SimHitIdpr, float > theChargeMap
Definition: MuonTruth.h:61
std::vector< PSimHit > hitsFromSimTrack(SimHitIdpr truthId)
Definition: MuonTruth.cc:221
tuple result
Definition: query.py:137

Member Data Documentation

bool MuonTruth::crossingframe
private

Definition at line 72 of file MuonTruth.h.

Referenced by initEvent(), and MuonTruth().

const CSCBadChambers* MuonTruth::cscBadChambers

Definition at line 51 of file MuonTruth.h.

Referenced by initEvent().

const CSCGeometry* MuonTruth::cscgeom
private

Definition at line 78 of file MuonTruth.h.

Referenced by analyze(), associateCSCHitId(), associateHitId(), and initEvent().

edm::InputTag MuonTruth::CSCsimHitsTag
private

Definition at line 73 of file MuonTruth.h.

Referenced by initEvent(), and MuonTruth().

edm::InputTag MuonTruth::CSCsimHitsXFTag
private

Definition at line 74 of file MuonTruth.h.

Referenced by initEvent(), and MuonTruth().

edm::InputTag MuonTruth::linksTag
private

Definition at line 69 of file MuonTruth.h.

Referenced by initEvent(), and MuonTruth().

std::map<SimHitIdpr, float> MuonTruth::theChargeMap
private

Definition at line 61 of file MuonTruth.h.

Referenced by addChannel(), analyze(), muonFraction(), and simHits().

unsigned int MuonTruth::theDetId
private

Definition at line 64 of file MuonTruth.h.

Referenced by analyze(), associateCSCHitId(), associateHitId(), and hitsFromSimTrack().

const DigiSimLinks* MuonTruth::theDigiSimLinks
private

Definition at line 66 of file MuonTruth.h.

Referenced by analyze(), associateCSCHitId(), associateHitId(), and initEvent().

std::map<unsigned int, edm::PSimHitContainer> MuonTruth::theSimHitMap
private

Definition at line 76 of file MuonTruth.h.

Referenced by hitsFromSimTrack(), and initEvent().

float MuonTruth::theTotalCharge
private

Definition at line 62 of file MuonTruth.h.

Referenced by addChannel(), analyze(), and muonFraction().

const DigiSimLinks* MuonTruth::theWireDigiSimLinks
private

Definition at line 67 of file MuonTruth.h.

Referenced by analyze(), and initEvent().

edm::InputTag MuonTruth::wireLinksTag
private

Definition at line 70 of file MuonTruth.h.

Referenced by initEvent(), and MuonTruth().