CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
embeddingAuxFunctions.cc File Reference
#include "TauAnalysis/MCEmbeddingTools/interface/embeddingAuxFunctions.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"
#include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
#include "DataFormats/Common/interface/RefToPtr.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "DataFormats/MuonDetId/interface/DTChamberId.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "DataFormats/Common/interface/Handle.h"
#include <iostream>
#include <iomanip>
#include <TGraph.h>

Go to the source code of this file.

Functions

void compGenMuonP4afterRad (const reco::GenParticle *mother, reco::Candidate::LorentzVector &muonP4_afterRad)
 
void compGenParticleP4afterRad (const reco::GenParticle *mother, reco::Candidate::LorentzVector &particleP4_afterRad, int absPdgId)
 
void compGenTauP4afterRad (const reco::GenParticle *mother, reco::Candidate::LorentzVector &tauP4_afterRad)
 
const reco::GenParticlefindGenParticleForMCEmbedding (const reco::Candidate::LorentzVector &direction, const reco::GenParticleCollection &genParticles, double dRmax, int status, const std::vector< int > *pdgIds, bool pdgIdStrict)
 
void findMuons (const edm::Event &evt, const edm::InputTag &src, reco::Candidate::LorentzVector &genMuonPlusP4, bool &genMuonPlus_found, reco::Candidate::LorentzVector &genMuonMinusP4, bool &genMuonMinus_found)
 
double getDeDxForPbWO4 (double p)
 
std::vector
< reco::CandidateBaseRef
getSelMuons (const edm::Event &evt, const edm::InputTag &srcSelMuons)
 
reco::CandidateBaseRef getTheMuMinus (const std::vector< reco::CandidateBaseRef > &selMuons)
 
reco::CandidateBaseRef getTheMuPlus (const std::vector< reco::CandidateBaseRef > &selMuons)
 
TrackDetMatchInfo getTrackDetMatchInfo (const edm::Event &evt, const edm::EventSetup &es, TrackDetectorAssociator &trackAssociator, const TrackAssociatorParameters &trackAssociatorParameters, const reco::Candidate *muon)
 
bool matchMuonDetId (uint32_t rawDetId1, uint32_t rawDetId2)
 
void printMuonDetId (const edm::EventSetup &es, uint32_t rawDetId)
 
void repairBarcodes (HepMC::GenEvent *genEvt)
 

Function Documentation

void compGenMuonP4afterRad ( const reco::GenParticle mother,
reco::Candidate::LorentzVector muonP4_afterRad 
)

Definition at line 285 of file embeddingAuxFunctions.cc.

References compGenParticleP4afterRad().

Referenced by GenMuonRadCorrAnalyzer::analyze().

286 {
287  return compGenParticleP4afterRad(mother, muonP4_afterRad, 13);
288 }
void compGenParticleP4afterRad(const reco::GenParticle *mother, reco::Candidate::LorentzVector &particleP4_afterRad, int absPdgId)
void compGenParticleP4afterRad ( const reco::GenParticle mother,
reco::Candidate::LorentzVector particleP4_afterRad,
int  absPdgId 
)

Definition at line 271 of file embeddingAuxFunctions.cc.

References funct::abs(), reco::CompositeRefCandidateT< D >::daughterRef(), reco::LeafCandidate::energy(), reco::Candidate::get(), reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::LeafCandidate::p4(), and reco::LeafCandidate::pdgId().

Referenced by compGenMuonP4afterRad(), and compGenTauP4afterRad().

272 {
273  unsigned numDaughters = mother->numberOfDaughters();
274  for ( unsigned iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
275  const reco::GenParticle* daughter = mother->daughterRef(iDaughter).get();
276 
277  compGenParticleP4afterRad(daughter, particleP4_afterRad, absPdgId);
278  }
279 
280  if ( abs(mother->pdgId()) == absPdgId ) {
281  if ( mother->energy() < particleP4_afterRad.energy() ) particleP4_afterRad = mother->p4();
282  }
283 }
virtual int pdgId() const
PDG identifier.
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
void compGenParticleP4afterRad(const reco::GenParticle *mother, reco::Candidate::LorentzVector &particleP4_afterRad, int absPdgId)
virtual double energy() const
energy
virtual size_t numberOfDaughters() const
number of daughters
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T get() const
get a component
Definition: Candidate.h:217
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
void compGenTauP4afterRad ( const reco::GenParticle mother,
reco::Candidate::LorentzVector tauP4_afterRad 
)

Definition at line 290 of file embeddingAuxFunctions.cc.

References compGenParticleP4afterRad().

291 {
292  return compGenParticleP4afterRad(mother, tauP4_afterRad, 15);
293 }
void compGenParticleP4afterRad(const reco::GenParticle *mother, reco::Candidate::LorentzVector &particleP4_afterRad, int absPdgId)
const reco::GenParticle* findGenParticleForMCEmbedding ( const reco::Candidate::LorentzVector direction,
const reco::GenParticleCollection genParticles,
double  dRmax,
int  status,
const std::vector< int > *  pdgIds,
bool  pdgIdStrict 
)

Definition at line 215 of file embeddingAuxFunctions.cc.

References deltar::bestMatch(), reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::energy(), benchmark_cfg::pdgId, and ntuplemaker::status.

Referenced by GenMuonRadCorrAnalyzer::analyze().

218 {
219  //---------------------------------------------------------------------------
220  // NOTE: this function has been copied from TauAnalysis/CandidateTools/src/candidateAuxFunctions.cc
221  // in order to avoid a package dependency of TauAnalysis/MCEmbedding on TauAnalysis/CandidateTools
222  //---------------------------------------------------------------------------
223 
224  bool bestMatchMatchesPdgId = false;
225  const reco::GenParticle* bestMatch = 0;
226 
227  for ( reco::GenParticleCollection::const_iterator genParticle = genParticles.begin();
228  genParticle != genParticles.end(); ++genParticle ) {
229  bool matchesPdgId = false;
230  if ( pdgIds ) {
231  for ( std::vector<int>::const_iterator pdgId = pdgIds->begin(); pdgId != pdgIds->end(); ++pdgId ) {
232  if ( genParticle->pdgId() == (*pdgId) ) {
233  matchesPdgId = true;
234  break;
235  }
236  }
237  }
238 
239  // If we require strict PDG id checking, skip it if it doesn't match
240  if ( pdgIds && !matchesPdgId && pdgIdStrict ) continue;
241 
242  // Check if status matches - if not, skip it.
243  bool statusMatch = (status == -1 || genParticle->status() == status);
244  if ( !statusMatch ) continue;
245 
246  double dR = reco::deltaR(direction, genParticle->p4());
247  if ( dR > dRmax ) continue;
248 
249  // Check if higher than current best match
250  bool higherEnergyThanBestMatch = (bestMatch) ?
251  (genParticle->energy() > bestMatch->energy()) : true;
252 
253  // Check if old bestMatch was not a prefered ID and the new one is.
254  if ( bestMatchMatchesPdgId ) {
255  // If the old one matches, only use the new one if it is a better
256  // energy match
257  if ( matchesPdgId && higherEnergyThanBestMatch ) bestMatch = &(*genParticle);
258  } else {
259  // The old one doesn't match the prefferred list if it is either
260  // a better energy match or better pdgId match
261  if ( higherEnergyThanBestMatch || matchesPdgId ) {
262  bestMatch = &(*genParticle);
263  if ( matchesPdgId ) bestMatchMatchesPdgId = true;
264  }
265  }
266  }
267 
268  return bestMatch;
269 }
def bestMatch
Definition: deltar.py:136
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
virtual double energy() const
energy
tuple status
Definition: ntuplemaker.py:245
void findMuons ( const edm::Event evt,
const edm::InputTag src,
reco::Candidate::LorentzVector genMuonPlusP4,
bool &  genMuonPlus_found,
reco::Candidate::LorentzVector genMuonMinusP4,
bool &  genMuonMinus_found 
)

Definition at line 295 of file embeddingAuxFunctions.cc.

References edm::Event::getByLabel(), customizeTrackingMonitorSeedNumber::idx, digitizers_cfi::muon, and patZpeak::muons.

Referenced by MCEmbeddingValidationAnalyzer::analyze(), and MuonRadiationCorrWeightProducer::produce().

298 {
299  //std::cout << "<findMuons>:" << std::endl;
300  //std::cout << " src = " << src << std::endl;
301  typedef std::vector<reco::Particle> ParticleCollection;
303  evt.getByLabel(src, muons);
304  int idx = 0;
305  for ( ParticleCollection::const_iterator muon = muons->begin();
306  muon != muons->end(); ++muon ) {
307  //std::cout << "muon #" << idx << ": Pt = " << muon->pt() << ", eta = " << muon->eta() << ", phi = " << muon->phi() << std::endl;
308  if ( muon->charge() > +0.5 ) {
309  genMuonPlusP4 = muon->p4();
310  genMuonPlus_found = true;
311  }
312  if ( muon->charge() < -0.5 ) {
313  genMuonMinusP4 = muon->p4();
314  genMuonMinus_found = true;
315  }
316  ++idx;
317  }
318 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple muons
Definition: patZpeak.py:38
std::vector< reco::Particle > ParticleCollection
double getDeDxForPbWO4 ( double  p)

Definition at line 320 of file embeddingAuxFunctions.cc.

References NULL.

Referenced by MuonCaloCleanerByDistance::fillEnergyDepositMap(), and L1ExtraMEtMixerPlugin::produce().

321 {
322  static TGraph* dedxGraphPbWO4 = NULL;
323 
324  static const double E[] = { 1.0, 1.40, 2.0, 3.0, 4.0, 8.0, 10.0,
325  14.0, 20.0, 30.0, 40.0, 80.0, 100.0,
326  140.0, 169.0, 200.0, 300.0, 400.0, 800.0, 1000.0,
327  1400.0, 2000.0, 3000.0, 4000.0, 8000.0 };
328  static const double DEDX[] = { 1.385, 1.440, 1.500, 1.569, 1.618, 1.743, 1.788,
329  1.862, 1.957, 2.101, 2.239, 2.778, 3.052,
330  3.603, 4.018, 4.456, 5.876, 7.333, 13.283, 16.320,
331  22.382, 31.625, 47.007, 62.559, 125.149 }; // in units of MeV
332  static const unsigned int N_ENTRIES = sizeof(E)/sizeof(E[0]);
333 
334  if ( !dedxGraphPbWO4 ) dedxGraphPbWO4 = new TGraph(N_ENTRIES, E, DEDX);
335 
336  return dedxGraphPbWO4->Eval(p)*1.e-3; // convert to GeV
337 }
#define NULL
Definition: scimark2.h:8
std::vector<reco::CandidateBaseRef> getSelMuons ( const edm::Event ,
const edm::InputTag  
)

Define methods to retrieve "the" (= highest Pt) muons of positive and negative charge from the event.

Author
Christian Veelken, LLR
Version
Revision:
1.9
Id:
embeddingAuxFunctions.h,v 1.9 2013/02/05 20:01:19 veelken Exp

Definition at line 31 of file embeddingAuxFunctions.cc.

References reco::CompositeCandidate::daughter(), edm::hlt::Exception, edm::Event::getByLabel(), reco::Candidate::hasMasterClone(), customizeTrackingMonitorSeedNumber::idx, edm::RefToBase< T >::isNull(), edm::InputTag::label(), reco::Candidate::masterClone(), reco::CompositeCandidate::numberOfDaughters(), and python.multivaluedict::sort().

Referenced by GenMuonRadCorrAnalyzer::analyze(), EmbeddingKineReweightNtupleProducer::analyze(), MCEmbeddingValidationAnalyzer::analyze(), MuonRadiationFilter::filter(), PFMuonCaloCleaner::produce(), MuonCaloDistanceProducer::produce(), MuonDetCleaner::produce(), ZmumuEvtSelEffCorrWeightProducer::produce(), MuonPFCandidateCleaner::produce(), MCParticleReplacer::produce(), MuonCaloCleanerByDistance::produce(), MuonCaloCleanerAllCrossed::produce(), and MuonTrackCleanerBase::produceTracks().

32 {
33  std::vector<reco::CandidateBaseRef> selMuons;
34 
36  if ( evt.getByLabel(srcSelMuons, combCandidatesHandle) ) {
37  if ( combCandidatesHandle->size() >= 1 ) {
38  const reco::CompositeCandidate& combCandidate = combCandidatesHandle->at(0); // TF: use only the first combined candidate
39  for ( size_t idx = 0; idx < combCandidate.numberOfDaughters(); ++idx ) {
40  const reco::Candidate* daughter = combCandidate.daughter(idx);
41  reco::CandidateBaseRef selMuon;
42  if ( daughter->hasMasterClone() ) {
43  selMuon = daughter->masterClone();
44  }
45  if ( selMuon.isNull() )
46  throw cms::Exception("Configuration")
47  << "Collection 'selectedMuons' = " << srcSelMuons.label() << " of CompositeCandidates does not refer to daughters of valid type !!\n";
48  selMuons.push_back(selMuon);
49  }
50  }
51  } else {
53  edm::Handle<CandidateView> selMuonsHandle;
54  if ( evt.getByLabel(srcSelMuons, selMuonsHandle) ) {
55  for ( size_t idx = 0; idx < selMuonsHandle->size(); ++idx ) {
56  selMuons.push_back(reco::CandidateBaseRef(selMuonsHandle->refAt(idx)));
57  }
58  } else {
59  throw cms::Exception("Configuration")
60  << "Invalid input collection 'selectedMuons' = " << srcSelMuons.label() << " !!\n";
61  }
62  }
63 
64  // sort collection of selected muons by decreasing Pt
65  std::sort(selMuons.begin(), selMuons.end(), higherPt);
66 
67  return selMuons;
68 }
virtual size_type numberOfDaughters() const
number of daughters
edm::View< reco::Candidate > CandidateView
virtual bool hasMasterClone() const =0
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool isNull() const
Checks for null.
Definition: RefToBase.h:270
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
std::string const & label() const
Definition: InputTag.h:42
virtual const CandidateBaseRef & masterClone() const =0
reco::CandidateBaseRef getTheMuMinus ( const std::vector< reco::CandidateBaseRef > &  selMuons)

Definition at line 86 of file embeddingAuxFunctions.cc.

Referenced by EmbeddingKineReweightNtupleProducer::analyze(), MuonRadiationFilter::filter(), PFMuonCaloCleaner::produce(), MuonCaloDistanceProducer::produce(), ZmumuEvtSelEffCorrWeightProducer::produce(), MuonDetCleaner::produce(), MuonPFCandidateCleaner::produce(), MCParticleReplacer::produce(), MuonCaloCleanerByDistance::produce(), MuonCaloCleanerAllCrossed::produce(), and MuonTrackCleanerBase::produceTracks().

87 {
88 //--- return highest Pt muon of negative charge
89 //
90 // NOTE: function assumes that collection of muons passed as function argument is sorted by decreasing Pt
91 // (= as returned by 'getSelMuons' function)
92 
93  for ( std::vector<reco::CandidateBaseRef>::const_iterator selMuon = selMuons.begin();
94  selMuon != selMuons.end(); ++selMuon ) {
95  if ( (*selMuon)->charge() < -0.5 ) return (*selMuon);
96  }
97 
98  // no muon of negative charge found
99  return reco::CandidateBaseRef();
100 }
edm::RefToBase< Candidate > CandidateBaseRef
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:31
reco::CandidateBaseRef getTheMuPlus ( const std::vector< reco::CandidateBaseRef > &  selMuons)

Definition at line 70 of file embeddingAuxFunctions.cc.

Referenced by EmbeddingKineReweightNtupleProducer::analyze(), MuonRadiationFilter::filter(), PFMuonCaloCleaner::produce(), MuonCaloDistanceProducer::produce(), ZmumuEvtSelEffCorrWeightProducer::produce(), MuonDetCleaner::produce(), MuonPFCandidateCleaner::produce(), MCParticleReplacer::produce(), MuonCaloCleanerByDistance::produce(), MuonCaloCleanerAllCrossed::produce(), and MuonTrackCleanerBase::produceTracks().

71 {
72 //--- return highest Pt muon of positive charge
73 //
74 // NOTE: function assumes that collection of muons passed as function argument is sorted by decreasing Pt
75 // (= as returned by 'getSelMuons' function)
76 
77  for ( std::vector<reco::CandidateBaseRef>::const_iterator selMuon = selMuons.begin();
78  selMuon != selMuons.end(); ++selMuon ) {
79  if ( (*selMuon)->charge() > +0.5 ) return (*selMuon);
80  }
81 
82  // no muon of positive charge found
83  return reco::CandidateBaseRef();
84 }
edm::RefToBase< Candidate > CandidateBaseRef
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:31
TrackDetMatchInfo getTrackDetMatchInfo ( const edm::Event evt,
const edm::EventSetup es,
TrackDetectorAssociator trackAssociator,
const TrackAssociatorParameters trackAssociatorParameters,
const reco::Candidate muon 
)

Definition at line 102 of file embeddingAuxFunctions.cc.

References TrackDetectorAssociator::associate(), reco::Candidate::charge(), reco::Muon::globalTrack(), edm::Ref< C, T, F >::isNonnull(), digitizers_cfi::muon, reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), and reco::Candidate::vertex().

Referenced by MuonCaloDistanceProducer::fillDistanceMap(), and MuonCaloCleanerAllCrossed::fillEnergyDepositMap().

105 {
106  TrackDetMatchInfo trackDetMatchInfo;
107  const reco::Muon* recoMuon = dynamic_cast<const reco::Muon*>(muon);
108  if ( recoMuon && recoMuon->globalTrack().isNonnull() ) {
109  trackDetMatchInfo = trackAssociator.associate(evt, es, *recoMuon->globalTrack(), trackAssociatorParameters);
110  } else {
111  GlobalVector muonP3(muon->px(), muon->py(), muon->pz());
112  GlobalPoint muonVtx(muon->vertex().x(), muon->vertex().y(), muon->vertex().z());
113  trackDetMatchInfo = trackAssociator.associate(evt, es, muonP3, muonVtx, muon->charge(), trackAssociatorParameters);
114  }
115  return trackDetMatchInfo;
116 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual double pz() const =0
z coordinate of momentum vector
virtual const Point & vertex() const =0
vertex position
virtual int charge() const =0
electric charge
virtual double py() const =0
y coordinate of momentum vector
virtual double px() const =0
x coordinate of momentum vector
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
bool matchMuonDetId ( uint32_t  rawDetId1,
uint32_t  rawDetId2 
)

Definition at line 164 of file embeddingAuxFunctions.cc.

References CSCDetId::chamber(), MuonSubdetId::CSC, DetId::det(), MuonSubdetId::DT, CSCDetId::endcap(), DetId::Muon, RPCDetId::region(), RPCDetId::ring(), CSCDetId::ring(), MuonSubdetId::RPC, DTChamberId::sector(), RPCDetId::sector(), DTChamberId::station(), RPCDetId::station(), CSCDetId::station(), DetId::subdetId(), and DTChamberId::wheel().

165 {
166  DetId detId1(rawDetId1);
167  DetId detId2(rawDetId2);
168  if ( detId1.det() == DetId::Muon && detId1.subdetId() == MuonSubdetId::CSC &&
169  detId2.det() == DetId::Muon && detId2.subdetId() == MuonSubdetId::CSC ) {
170  CSCDetId cscDetId1(detId1);
171  CSCDetId cscDetId2(detId2);
172  if ( cscDetId1.endcap() == cscDetId2.endcap() &&
173  cscDetId1.station() == cscDetId2.station() &&
174  cscDetId1.ring() == cscDetId2.ring() &&
175  cscDetId1.chamber() == cscDetId2.chamber() ) return true;
176  } else if ( detId1.det() == DetId::Muon && detId1.subdetId() == MuonSubdetId::RPC &&
177  detId2.det() == DetId::Muon && detId2.subdetId() == MuonSubdetId::RPC ) {
178  RPCDetId rpcDetId1(detId1);
179  RPCDetId rpcDetId2(detId2);
180  if ( rpcDetId1.region() == rpcDetId2.region() &&
181  rpcDetId1.ring() == rpcDetId2.ring() &&
182  rpcDetId1.station() == rpcDetId2.station() &&
183  rpcDetId1.sector() == rpcDetId2.sector() ) return true;
184  } else if ( detId1.det() == DetId::Muon && detId1.subdetId() == MuonSubdetId::DT &&
185  detId2.det() == DetId::Muon && detId2.subdetId() == MuonSubdetId::DT ) {
186  DTChamberId dtDetId1(detId1);
187  DTChamberId dtDetId2(detId2);
188  if ( dtDetId1.wheel() == dtDetId2.wheel() &&
189  dtDetId1.station() == dtDetId2.station() &&
190  dtDetId1.sector() == dtDetId2.sector() ) return true;
191  }
192  return false;
193 }
static const int CSC
Definition: MuonSubdetId.h:13
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
static const int DT
Definition: MuonSubdetId.h:12
void printMuonDetId ( const edm::EventSetup es,
uint32_t  rawDetId 
)

Definition at line 118 of file embeddingAuxFunctions.cc.

References CSCDetId::chamber(), gather_cfg::cout, MuonSubdetId::CSC, DetId::det(), MuonSubdetId::DT, CSCDetId::endcap(), PV3DBase< T, PVType, FrameType >::eta(), edm::EventSetup::get(), CSCDetId::layer(), RPCDetId::layer(), DetId::Muon, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GeomDet::position(), RPCDetId::region(), RPCDetId::ring(), CSCDetId::ring(), RPCDetId::roll(), MuonSubdetId::RPC, DTChamberId::sector(), RPCDetId::sector(), DTChamberId::station(), RPCDetId::station(), CSCDetId::station(), DetId::subdetId(), RPCDetId::subsector(), and DTChamberId::wheel().

Referenced by MuonDetRecHitMixer< T1, T2 >::printHitMapRH().

119 {
120  DetId detId(rawDetId);
121  std::cout << "detId = " << rawDetId << std::endl;
122  const GeomDet* geo = 0;
123  if ( detId.det() == DetId::Muon && detId.subdetId() == MuonSubdetId::CSC ) {
124  CSCDetId cscDetId(detId);
125  std::cout << " CSC:"
126  << " endcap = " << cscDetId.endcap() << ","
127  << " station = " << cscDetId.station() << ","
128  << " ring = " << cscDetId.ring() << ","
129  << " chamber = " << cscDetId.chamber() << ","
130  << " layer = " << cscDetId.layer() << std::endl;
131  edm::ESHandle<CSCGeometry> cscGeometry;
132  es.get<MuonGeometryRecord>().get(cscGeometry);
133  geo = cscGeometry->idToDet(detId);
134  } else if ( detId.det() == DetId::Muon && detId.subdetId() == MuonSubdetId::RPC ) {
135  RPCDetId rpcDetId(detId);
136  std::cout << " RPC:"
137  << " region = " << rpcDetId.region() << ","
138  << " ring = " << rpcDetId.ring() << ","
139  << " station = " << rpcDetId.station() << ","
140  << " sector = " << rpcDetId.sector() << ","
141  << " layer = " << rpcDetId.layer() << ","
142  << " subsector = " << rpcDetId.subsector() << ","
143  << " roll = " << rpcDetId.roll() << std::endl;
144  edm::ESHandle<RPCGeometry> rpcGeometry;
145  es.get<MuonGeometryRecord>().get(rpcGeometry);
146  geo = rpcGeometry->idToDet(detId);
147  } else if ( detId.det() == DetId::Muon && detId.subdetId() == MuonSubdetId::DT ) {
148  DTChamberId dtDetId(detId);
149  std::cout << " DT (chamber):"
150  << " wheel = " << dtDetId.wheel() << ","
151  << " station = " << dtDetId.station() << ","
152  << " sector = " << dtDetId.sector() << std::endl;
153  edm::ESHandle<DTGeometry> dtGeometry;
154  es.get<MuonGeometryRecord>().get(dtGeometry);
155  geo = dtGeometry->idToDet(detId);
156  } else {
157  std::cout << " WARNING: detId refers to unknown detector !!" << std::endl;
158  }
159  if ( geo ) {
160  std::cout << "(position: eta = " << geo->position().eta() << ", phi = " << geo->position().phi() << ", r = " << geo->position().perp() << ")" << std::endl;
161  }
162 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
static const int CSC
Definition: MuonSubdetId.h:13
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:46
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
T eta() const
Definition: PV3DBase.h:76
static const int RPC
Definition: MuonSubdetId.h:14
tuple cout
Definition: gather_cfg.py:121
static const int DT
Definition: MuonSubdetId.h:12
void repairBarcodes ( HepMC::GenEvent *  genEvt)

Definition at line 195 of file embeddingAuxFunctions.cc.

References getDQMSummary::iter, and HLT_25ns14e33_v1_cff::vertices.

Referenced by ParticleReplacerZtautau::cleanEvent(), GenMuonRadiationAlgorithm::compFSR(), and ParticleReplacerZtautau::produce().

196 {
197  // AB: Note that we cannot do the barcode re-assignment "inline" without first
198  // creating a copy of the vertex and particle collections, because otherwise
199  // changing a barcode might invalidate the iterator which is used for
200  // iterating over the collection.
201  const std::vector<HepMC::GenVertex*> vertices(genEvt->vertices_begin(), genEvt->vertices_end());
202  const std::vector<HepMC::GenParticle*> particles(genEvt->particles_begin(), genEvt->particles_end());
203 
204  int next_genVtx_barcode = 1;
205  for(std::vector<HepMC::GenVertex*>::const_iterator iter = vertices.begin(); iter != vertices.end(); ++iter, ++next_genVtx_barcode)
206  while(!(*iter)->suggest_barcode(-next_genVtx_barcode))
207  ++next_genVtx_barcode;
208 
209  int next_genParticle_barcode = 1;
210  for(std::vector<HepMC::GenParticle*>::const_iterator iter = particles.begin(); iter != particles.end(); ++iter, ++next_genParticle_barcode)
211  while(!(*iter)->suggest_barcode(next_genParticle_barcode))
212  ++next_genParticle_barcode;
213 }