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 Member Functions | Private Attributes
SelectReplacementCandidates Class Reference

#include <SelectReplacementCandidates.h>

Inheritance diagram for SelectReplacementCandidates:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iConfig)
 
 SelectReplacementCandidates (const edm::ParameterSet &iSetup)
 
 ~SelectReplacementCandidates ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

int determineMuonsToUse (const edm::Event &iEvent, const edm::EventSetup &iConfig, reco::Muon *muon1, reco::Muon *muon2)
 
int determineMuonsToUse_old (const edm::Event &iEvent, const edm::EventSetup &iConfig, reco::Muon *muon1, reco::Muon *muon2)
 
void getRawIDsAdvanced (const edm::Event &iEvent, const edm::EventSetup &iConfig, std::vector< uint32_t > *L, reco::Muon *muon, bool includeHCAL)
 
template<typename T >
void ProductNotFound (const edm::Event &iEvent, edm::InputTag inputTag)
 
void transformMuMu2TauTau (reco::Muon *muon1, reco::Muon *muon2)
 transform muon into tau More...
 

Private Attributes

edm::InputTag muonInputTag_
 
TrackAssociatorParameters parameters_
 
double targetParticleMass_
 
int targetParticlePdgID_
 
TrackDetectorAssociator trackAssociator_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 26 of file SelectReplacementCandidates.h.

Constructor & Destructor Documentation

SelectReplacementCandidates::SelectReplacementCandidates ( const edm::ParameterSet iSetup)

Definition at line 4 of file SelectReplacementCandidates.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), TrackAssociatorParameters::loadParameters(), muonInputTag_, Parameters::parameters, parameters_, targetParticleMass_, targetParticlePdgID_, trackAssociator_, and TrackDetectorAssociator::useDefaultPropagator().

5 {
6  using namespace edm;
7  using namespace std;
8  produces< vector<uint32_t> >();
9  produces< vector<uint32_t> >("assocHitsWithHCAL");
10  produces< std::vector<reco::Muon> >();
11 
12  targetParticleMass_=iConfig.getUntrackedParameter<double>("targetParticlesMass",1.77690);
13  targetParticlePdgID_=iConfig.getUntrackedParameter<int>("targetParticlesPdgID",15);
14 
15  muonInputTag_ = iConfig.getParameter<edm::InputTag>("muonInputTag");
16  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
18 
20 }
dictionary parameters
Definition: Parameters.py:2
TrackDetectorAssociator trackAssociator_
void useDefaultPropagator()
use the default propagator
TrackAssociatorParameters parameters_
void loadParameters(const edm::ParameterSet &)
SelectReplacementCandidates::~SelectReplacementCandidates ( )

Definition at line 22 of file SelectReplacementCandidates.cc.

23 {
24 
25 }

Member Function Documentation

void SelectReplacementCandidates::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 60 of file SelectReplacementCandidates.cc.

61 {
62 
63 }
int SelectReplacementCandidates::determineMuonsToUse ( const edm::Event iEvent,
const edm::EventSetup iConfig,
reco::Muon muon1,
reco::Muon muon2 
)
private

Definition at line 71 of file SelectReplacementCandidates.cc.

References gather_cfg::cout, deltaR(), edm::Event::getByLabel(), edm::Event::getManyByType(), i, muonInputTag_, patZpeak::muons, p4, dt_dqm_sourceclient_common_cff::reco, edm::View< T >::size(), and detailsBasic3DVector::z.

Referenced by produce().

72 {
73  using namespace edm;
74  using namespace reco;
75  using namespace std;
76 
78  if (!iEvent.getByLabel("dimuonsGlobal", zCandidate_handle))
79  {
80  std::cout << "Could not find product: " << "dimuonsGlobal" << "\n";
81  std::vector< edm::Handle< edm::RefToBaseVector<reco::Candidate> > > allHandles;
82  iEvent.getManyByType(allHandles);
83  std::vector< edm::Handle< edm::RefToBaseVector<reco::Candidate> > >::iterator it;
84  for (it = allHandles.begin(); it != allHandles.end(); it++)
85  {
86  std::cout << "available product: " << (*it).provenance()->moduleLabel() << ", " << (*it).provenance()->productInstanceName() << ", " << (*it).provenance()->processName();
87  }
88 
89  std::cout << "Objekt nicht gefunden: dimuonsGloal\n";
90  return -1;
91  }
92 // std::cout << zCandidate_handle->size() << " Kandidaten gefunden!\n";
93 
94  unsigned int nMuons = zCandidate_handle->size();
95  if (nMuons==0)
96  return -1;
97 
98  for (edm::RefToBaseVector<reco::Candidate>::const_iterator z = zCandidate_handle->begin(); z!=zCandidate_handle->end(); ++z)
99  {
100  reco::Particle::LorentzVector muon1p4 = z->get()->daughter(0)->p4();
101  reco::Particle::LorentzVector muon2p4 = z->get()->daughter(1)->p4();
102 
103  edm::Handle<edm::View<reco::Muon> > trackCollection;
104  iEvent.getByLabel(muonInputTag_, trackCollection);
105  const edm::View<reco::Muon>& muons = * trackCollection;
106 
107  bool found1=false, found2=false;
108  for (unsigned int i=0;i<muons.size() && !(found1 && found2);i++)
109  {
110  if (deltaR(muon1p4,muons[i].p4())<0.1)
111  {
112  *muon1 = muons[i];
113  found1=true;
114  }
115  if (deltaR(muon2p4,muons[i].p4())<0.1)
116  {
117  *muon2 = muons[i];
118  found2=true;
119  }
120  }
121 
122  break;
123  }
124  return 0;
125 }
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:408
int i
Definition: DBlmapReader.cc:9
double double double z
double p4[4]
Definition: TauolaWrapper.h:92
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
size_type size() const
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:121
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
int SelectReplacementCandidates::determineMuonsToUse_old ( const edm::Event iEvent,
const edm::EventSetup iConfig,
reco::Muon muon1,
reco::Muon muon2 
)
private

Definition at line 128 of file SelectReplacementCandidates.cc.

References gather_cfg::cout, edm::Event::getByLabel(), muonInputTag_, patZpeak::muons, and dt_dqm_sourceclient_common_cff::reco.

129 {
130  using namespace edm;
131  using namespace reco;
132  using namespace std;
133 
134  Handle<MuonCollection> muonHandle;
135  if (!iEvent.getByLabel(muonInputTag_,muonHandle))
136  ProductNotFound<reco::MuonCollection>(iEvent, muonInputTag_);
137 
138  edm::Handle<edm::View<reco::Muon> > trackCollection;
139  iEvent.getByLabel(muonInputTag_, trackCollection);
140  const edm::View<reco::Muon>& muons = * trackCollection;
141 
142  unsigned int nMuons = muons.size();
143  if (nMuons<2)
144  return -1;
145 
146  *muon1 = muons[0];
147  *muon2 = muons[1];
148  std::cout << muons[0].p4() << "\n";
149  std::cout << muons[1].p4() << "\n";
150 
151  return 0;
152 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:121
void SelectReplacementCandidates::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 65 of file SelectReplacementCandidates.cc.

66 {
67 
68 }
void SelectReplacementCandidates::getRawIDsAdvanced ( const edm::Event iEvent,
const edm::EventSetup iConfig,
std::vector< uint32_t > *  L,
reco::Muon muon,
bool  includeHCAL 
)
private

Definition at line 154 of file SelectReplacementCandidates.cc.

References TrackDetectorAssociator::associate(), reco::Muon::bestTrackRef(), gather_cfg::cout, TrackDetMatchInfo::ecalRecHits, edm::RefToBase< T >::get(), TrackDetMatchInfo::hcalRecHits, i, info, edm::RefToBase< T >::isNonnull(), parameters_, dt_dqm_sourceclient_common_cff::reco, and trackAssociator_.

Referenced by produce().

155 {
156  using namespace edm;
157  using namespace reco;
158  using namespace std;
159 
160  if (muon->bestTrackRef().isNonnull())
161  {
162  TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iConfig, *(muon->bestTrackRef().get()), parameters_);
163  if (includeHCAL)
164  {
165  for(std::vector<const EcalRecHit*>::const_iterator hit = info.ecalRecHits.begin(); hit != info.ecalRecHits.end(); ++hit)
166  L->push_back((*hit)->detid().rawId());
167 
168  for(std::vector<const HBHERecHit*>::const_iterator hit = info.hcalRecHits.begin(); hit != info.hcalRecHits.end(); ++hit)
169  L->push_back((*hit)->detid().rawId());
170  }
171  int recs = (muon->bestTrackRef().get())->recHitsSize();
172  for (int i=0; i<recs; i++)
173  L->push_back(((muon->bestTrackRef().get())->recHit(i).get())->geographicalId().rawId());
174  }
175  else
176  std::cout << "ERROR: Muon has no bestTrackRef!!\n";
177 
178  std::cout << " with " << L->size() << " muon hits found\n";
179 // return L;
180 }
int i
Definition: DBlmapReader.cc:9
TrackDetectorAssociator trackAssociator_
std::vector< const EcalRecHit * > ecalRecHits
hits in the cone
std::vector< const HBHERecHit * > hcalRecHits
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
tuple cout
Definition: gather_cfg.py:121
TrackAssociatorParameters parameters_
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:279
value_type const * get() const
Definition: RefToBase.h:212
virtual TrackBaseRef bestTrackRef() const
best track RefToBase
Definition: Muon.h:63
void SelectReplacementCandidates::produce ( edm::Event iEvent,
const edm::EventSetup iConfig 
)
virtual

Implements edm::EDProducer.

Definition at line 27 of file SelectReplacementCandidates.cc.

References gather_cfg::cout, determineMuonsToUse(), getRawIDsAdvanced(), patZpeak::muons, edm::Event::put(), and transformMuMu2TauTau().

28 {
29  using namespace std;
30  using namespace edm;
31  reco::Muon muon1, muon2;
32 
33  // determine the muons to be used
34  // these can be reconstructed muons or muons from a HepMC::Event
35  if (determineMuonsToUse(iEvent, iSetup, &muon1, &muon2)!=0)
36  return;
37 
38  vector<uint32_t> hits ;
39  getRawIDsAdvanced(iEvent, iSetup, &hits, &muon1, false);
40  getRawIDsAdvanced(iEvent, iSetup, &hits, &muon2, false);
41  std::auto_ptr< vector<uint32_t> > selectedHitsAutoPtr(new vector<uint32_t>(hits) );
42  iEvent.put( selectedHitsAutoPtr );
43 
44  vector<uint32_t> assoc_hits_withHCAL;
45  getRawIDsAdvanced(iEvent, iSetup, &assoc_hits_withHCAL, &muon1, true);
46  getRawIDsAdvanced(iEvent, iSetup, &assoc_hits_withHCAL, &muon2, true);
47  std::cout << "found in total " << assoc_hits_withHCAL.size() << " cells with associated hits with hcal\n";
48  std::auto_ptr< vector<uint32_t> > selectedAssocHitsWithHCALAutoPtr(new vector<uint32_t>(assoc_hits_withHCAL) );
49  iEvent.put( selectedAssocHitsWithHCALAutoPtr, "assocHitsWithHCAL");
50 
51  std::vector<reco::Muon> muons;
52  transformMuMu2TauTau(&muon1, &muon2);
53  muons.push_back(muon1);
54  muons.push_back(muon2);
55  std::auto_ptr< std::vector<reco::Muon> > selectedMuonsPtr(new std::vector<reco::Muon>(muons) );
56  iEvent.put( selectedMuonsPtr );
57 
58 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
int determineMuonsToUse(const edm::Event &iEvent, const edm::EventSetup &iConfig, reco::Muon *muon1, reco::Muon *muon2)
void getRawIDsAdvanced(const edm::Event &iEvent, const edm::EventSetup &iConfig, std::vector< uint32_t > *L, reco::Muon *muon, bool includeHCAL)
void transformMuMu2TauTau(reco::Muon *muon1, reco::Muon *muon2)
transform muon into tau
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:121
template<typename T >
void SelectReplacementCandidates::ProductNotFound ( const edm::Event iEvent,
edm::InputTag  inputTag 
)
private

Definition at line 183 of file SelectReplacementCandidates.cc.

References gather_cfg::cout, and edm::Event::getManyByType().

184 {
185  std::cout << "--- TauHitSelector ------------------------------------\n";
186  std::cout << "Could not find product with:\n"<< inputTag << "\n";
187  std::vector< edm::Handle< T > > allHandles;
188  iEvent.getManyByType(allHandles);
189  typename std::vector< edm::Handle< T > >::iterator it;
190  for (it = allHandles.begin(); it != allHandles.end(); it++)
191  {
192  std::cout << "module label: " << (*it).provenance()->moduleLabel() << "\n";
193  std::cout << "productInstanceName: " << (*it).provenance()->productInstanceName() << "\n";
194  std::cout << "processName: " << (*it).provenance()->processName() << "\n\n";
195  }
196  std::cout << "-------------------------------------------------------\n";
197  return;
198 }
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:408
tuple cout
Definition: gather_cfg.py:121
void SelectReplacementCandidates::transformMuMu2TauTau ( reco::Muon muon1,
reco::Muon muon2 
)
private

transform muon into tau

Definition at line 202 of file SelectReplacementCandidates.cc.

References abs, scaleCards::mass, reco::LeafCandidate::p4(), reco::LeafCandidate::pdgId(), dt_dqm_sourceclient_common_cff::reco, reco::LeafCandidate::setP4(), reco::LeafCandidate::setPdgId(), reco::LeafCandidate::setStatus(), mathSSE::sqrt(), targetParticleMass_, and targetParticlePdgID_.

Referenced by produce().

203 {
204  using namespace edm;
205  using namespace reco;
206  using namespace std;
207 
208  reco::Particle::LorentzVector muon1_momentum = muon1->p4();
209  reco::Particle::LorentzVector muon2_momentum = muon2->p4();
210  reco::Particle::LorentzVector z_momentum = muon1_momentum + muon2_momentum;
211 
212  ROOT::Math::Boost booster(z_momentum.BoostToCM());
213  ROOT::Math::Boost invbooster(booster.Inverse());
214 
215  reco::Particle::LorentzVector Zb = booster(z_momentum);
216 
217  reco::Particle::LorentzVector muon1b = booster(muon1_momentum);
218  reco::Particle::LorentzVector muon2b = booster(muon2_momentum);
219 
220  double tau_mass2 = targetParticleMass_*targetParticleMass_;
221 
222  double muonxb_mom2 = muon1b.x()*muon1b.x() + muon1b.y()*muon1b.y() + muon1b.z() * muon1b.z();
223  double tauxb_mom2 = 0.25 * Zb.t() * Zb.t() - tau_mass2;
224 
225  float scaling1 = sqrt(tauxb_mom2 / muonxb_mom2);
226  float scaling2 = scaling1;
227 
228  float tauEnergy= Zb.t() / 2.;
229 
230  if (tauEnergy*tauEnergy<tau_mass2)
231  return;
232 
233  reco::Particle::LorentzVector tau1b_mom = reco::Particle::LorentzVector(scaling1*muon1b.x(),scaling1*muon1b.y(),scaling1*muon1b.z(),tauEnergy);
234  reco::Particle::LorentzVector tau2b_mom = reco::Particle::LorentzVector(scaling2*muon2b.x(),scaling2*muon2b.y(),scaling2*muon2b.z(),tauEnergy);
235 
236  // some checks
237  // the following test guarantees a deviation
238  // of less than 0.1% for phi and theta for the
239  // original muons and the placed taus
240  // (in the centre-of-mass system of the z boson)
241  assert((muon1b.phi()-tau1b_mom.phi())/muon1b.phi()<0.001);
242  assert((muon2b.phi()-tau2b_mom.phi())/muon2b.phi()<0.001);
243  assert((muon1b.theta()-tau1b_mom.theta())/muon1b.theta()<0.001);
244  assert((muon2b.theta()-tau2b_mom.theta())/muon2b.theta()<0.001);
245 
246  reco::Particle::LorentzVector tau1_mom = (invbooster(tau1b_mom));
247  reco::Particle::LorentzVector tau2_mom = (invbooster(tau2b_mom));
248 
249  // some additional checks
250  // the following tests guarantee a deviation of less
251  // than 0.1% for the following values of the original
252  // muons and the placed taus
253  // invariant mass
254  // transverse momentum
255  assert(((muon1_momentum+muon1_momentum).mass()-(tau1_mom+tau2_mom).mass())/(muon1_momentum+muon1_momentum).mass()<0.001);
256  assert(((muon1_momentum+muon2_momentum).pt()-(tau1_mom+tau2_mom).pt())/(muon1_momentum+muon1_momentum).pt()<0.001);
257 
258  muon1->setP4(tau1_mom);
259  muon2->setP4(tau2_mom);
260 
261  muon1->setPdgId(targetParticlePdgID_*muon1->pdgId()/abs(muon1->pdgId()));
262  muon2->setPdgId(targetParticlePdgID_*muon2->pdgId()/abs(muon2->pdgId()));
263 
264  muon1->setStatus(1);
265  muon2->setStatus(1);
266 
267  return;
268 }
virtual int pdgId() const
PDG identifier.
virtual void setStatus(int status)
set status word
#define abs(x)
Definition: mlp_lapack.h:159
virtual void setP4(const LorentzVector &p4)
set 4-momentum
T sqrt(T t)
Definition: SSEVec.h:46
tuple mass
Definition: scaleCards.py:27
virtual void setPdgId(int pdgId)
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25

Member Data Documentation

edm::InputTag SelectReplacementCandidates::muonInputTag_
private
TrackAssociatorParameters SelectReplacementCandidates::parameters_
private
double SelectReplacementCandidates::targetParticleMass_
private
int SelectReplacementCandidates::targetParticlePdgID_
private
TrackDetectorAssociator SelectReplacementCandidates::trackAssociator_
private

Definition at line 44 of file SelectReplacementCandidates.h.

Referenced by getRawIDsAdvanced(), and SelectReplacementCandidates().