CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZMuMuMuonUserData.cc
Go to the documentation of this file.
9 
15 
19 
20 #include <vector>
21 
22 using namespace edm;
23 using namespace std;
24 using namespace reco;
25 using namespace isodeposit;
26 //using namespace pat;
27 
29 public:
31 private:
32  void produce( edm::Event &, const edm::EventSetup & );
33 
34  InputTag src_,beamSpot_, primaryVertices_;
35  double alpha_, beta_;
36  double ptThreshold_, etEcalThreshold_, etHcalThreshold_ ,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_;
37  string hltPath_;
38  template<typename T>
39  vector<double> isolation(const T & t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta);
40 };
41 
42 template<typename T>
43 vector<double> ZMuMuMuonUserData::isolation(const T & t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta) {
44 
45  vector<double> iso;
46  const pat::IsoDeposit * trkIso = t.isoDeposit(pat::TrackIso);
47  const pat::IsoDeposit * ecalIso = t.isoDeposit(pat::EcalIso);
48  const pat::IsoDeposit * hcalIso = t.isoDeposit(pat::HcalIso);
49 
50  Direction dir = Direction(t.eta(), t.phi());
51 
53  vetosTrk.push_back(new ConeVeto( dir, dRVetoTrk ));
54  vetosTrk.push_back(new ThresholdVeto( ptThreshold ));
55 
56  pat::IsoDeposit::AbsVetos vetosEcal;
57  vetosEcal.push_back(new ConeVeto( dir, 0.));
58  vetosEcal.push_back(new ThresholdVeto( etEcalThreshold ));
59 
60  pat::IsoDeposit::AbsVetos vetosHcal;
61  vetosHcal.push_back(new ConeVeto( dir, 0. ));
62  vetosHcal.push_back(new ThresholdVeto( etHcalThreshold ));
63 
64  double isovalueTrk = (trkIso->sumWithin(dRTrk,vetosTrk));
65  double isovalueEcal = (ecalIso->sumWithin(dREcal,vetosEcal));
66  double isovalueHcal = (hcalIso->sumWithin(dRHcal,vetosHcal));
67 
68  iso.push_back(isovalueTrk);
69  //cout<<"isoTrk"<<isovalueTrk<<" "<<t.trackIso()<<endl;
70  iso.push_back(isovalueEcal);
71  //cout<<"isoEcal"<<isovalueEcal<<" "<<t.ecalIso()<<endl;
72  iso.push_back(isovalueHcal);
73  //cout<<"isoHcal"<<isovalueHcal<<" "<<t.hcalIso()<<endl;
74  //double isovalueTrk = t.trackIso();
75  //double isovalueEcal = t.ecalIso();
76  //double isovalueHcal = t.hcalIso();
77 
78  //double iso = isovalueTrk + isovalueEcal + isovalueHcal;
79  double combIso = alpha*( ((1+beta)/2*isovalueEcal) + ((1-beta)/2*isovalueHcal) ) + ((1-alpha)*isovalueTrk);
80  iso.push_back(combIso);
81  //cout<<"combIso"<<iso[3]<<endl;
82 
83  double relIso = combIso /= t.pt();
84  iso.push_back(relIso);
85  //cout<<"relIso"<<iso[4]<<endl;
86  return iso;
87 }
88 
90  src_( cfg.getParameter<InputTag>( "src" ) ),
91  beamSpot_(cfg.getParameter<InputTag>( "beamSpot" ) ),
92  primaryVertices_(cfg.getParameter<InputTag>( "primaryVertices" ) ),
93  alpha_(cfg.getParameter<double>("alpha") ),
94  beta_(cfg.getParameter<double>("beta") ),
95  ptThreshold_(cfg.getParameter<double >("ptThreshold") ),
96  etEcalThreshold_(cfg.getParameter<double >("etEcalThreshold") ),
97  etHcalThreshold_(cfg.getParameter<double >("etHcalThreshold") ),
98  dRVetoTrk_(cfg.getParameter<double >("dRVetoTrk") ),
99  dRTrk_(cfg.getParameter<double >("dRTrk") ),
100  dREcal_(cfg.getParameter<double >("dREcal") ),
101  dRHcal_(cfg.getParameter<double >("dRHcal") ),
102  hltPath_(cfg.getParameter<std::string >("hltPath") ){
103  produces<std::vector<pat::Muon> >();
104 }
105 
108  evt.getByLabel(src_,muons);
109 
110  Handle<BeamSpot> beamSpotHandle;
111  evt.getByLabel(beamSpot_, beamSpotHandle);
112 
113  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
114  evt.getByLabel(primaryVertices_, primaryVertices);
115 
116  auto_ptr<vector<pat::Muon> > muonColl( new vector<pat::Muon> (*muons) );
117  for (unsigned int i = 0; i< muonColl->size();++i){
118  pat::Muon & m = (*muonColl)[i];
119  //pat::Muon *mu = new pat::Muon(m);
121  m.setIsolation(pat::User1Iso, iso[0]);
122  //cout<<"muon User1Iso "<<iso[0]<<endl;
123  m.setIsolation(pat::User2Iso, iso[1]);
124  //cout<<"iso2 "<<iso[1]<<endl;
125  m.setIsolation(pat::User3Iso, iso[2]);
126  //cout<<"iso3 "<<iso[2]<<endl;
127  m.setIsolation(pat::User4Iso, iso[3]);
128  //cout<<"iso4 "<<iso[3]<<endl;
129  m.setIsolation(pat::User5Iso, iso[4]);
130  //cout<<"iso5 "<<iso[4]<<endl;
131  float zDauMuEnergyEm = m.calEnergy().em;
132  float zDauMuEnergyHad = m.calEnergy().had;
133  TrackRef muGlbRef = m.globalTrack();
134  TrackRef muTrkRef = m.innerTrack();
135  TrackRef muSaRef = m.outerTrack();
136  float zDaudxyFromBS = -1;
137  float zDaudzFromBS = -1;
138  float zDaudxyFromPV = -1;
139  float zDaudzFromPV = -1;
140  int zDauNofMuChambers = m.numberOfChambers();
141  int zDauNofMuMatches = m.numberOfMatches();
142  // for the following variables looking at global/trk and sta at the same time
143  float zDauChi2 = -1;
144  float zDauTrkChi2 = -1;
145  float zDauSaChi2 = -1;
146  float zDauNofMuonHits = -1;
147  float zDauSaNofMuonHits = -1;
148  float zDauNofStripHits = -1;
149  float zDauTrkNofStripHits = -1;
150  float zDauNofPixelHits = -1;
151  float zDauTrkNofPixelHits = -1;
152 
153 
154 
155 
156  if (muGlbRef.isNonnull() && m.isGlobalMuon() == true){
157  zDaudxyFromBS = muGlbRef->dxy(beamSpotHandle->position());
158  zDaudzFromBS = muGlbRef->dz(beamSpotHandle->position());
159  zDaudxyFromPV = muGlbRef->dxy(primaryVertices->begin()->position() );
160  zDaudzFromPV = muGlbRef->dz(primaryVertices->begin()->position() );
161  zDauChi2 = muGlbRef->normalizedChi2();
162  zDauTrkChi2 = muTrkRef->normalizedChi2();
163  zDauSaChi2 = muSaRef->normalizedChi2();
164  zDauNofMuonHits = muGlbRef->hitPattern().numberOfValidMuonHits();
165  zDauSaNofMuonHits = muSaRef->hitPattern().numberOfValidMuonHits();
166  zDauNofStripHits = muGlbRef->hitPattern().numberOfValidStripHits();
167  zDauTrkNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
168  zDauNofPixelHits = muGlbRef->hitPattern().numberOfValidPixelHits();
169  zDauTrkNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
170  }
171  else if (muSaRef.isNonnull() && m.isStandAloneMuon() == true){
172  zDaudxyFromBS = muSaRef->dxy(beamSpotHandle->position());
173  zDaudzFromBS = muSaRef->dz(beamSpotHandle->position());
174  zDaudxyFromPV = muSaRef->dxy(primaryVertices->begin()->position() );
175  zDaudzFromPV = muSaRef->dz(primaryVertices->begin()->position() );
176  zDauSaChi2 = muSaRef->normalizedChi2();
177  zDauSaNofMuonHits = muSaRef->hitPattern().numberOfValidMuonHits();
178 
179  }
180  else if (muTrkRef.isNonnull() && m.isTrackerMuon() == true){
181  zDaudxyFromBS = muTrkRef->dxy(beamSpotHandle->position());
182  zDaudzFromBS = muTrkRef->dz(beamSpotHandle->position());
183  zDaudxyFromPV = muTrkRef->dxy(primaryVertices->begin()->position() );
184  zDaudzFromPV = muTrkRef->dz(primaryVertices->begin()->position() );
185  zDauTrkChi2 = muTrkRef->normalizedChi2();
186  zDauTrkNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
187  zDauTrkNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
188 
189  }
190 
192  float muHLTBit;
193  int dimTrig = muHLTMatches.size();
194  if(dimTrig !=0 ){
195  muHLTBit = 1;
196  } else {
197  muHLTBit = 0;
198  }
199  m.addUserFloat("zDau_dxyFromBS", zDaudxyFromBS);
200  m.addUserFloat("zDau_dzFromBS", zDaudzFromBS);
201  m.addUserFloat("zDau_dxyFromPV", zDaudxyFromPV);
202  m.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
203  m.addUserFloat("zDau_HLTBit",muHLTBit);
204  m.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
205  m.addUserFloat("zDau_Chi2", zDauChi2);
206  m.addUserFloat("zDau_TrkChi2", zDauTrkChi2);
207  m.addUserFloat("zDau_SaChi2", zDauSaChi2);
208  m.addUserFloat("zDau_NofMuonHits" , zDauNofMuonHits );
209  m.addUserFloat("zDau_SaNofMuonHits" , zDauSaNofMuonHits );
210  m.addUserFloat("zDau_NofStripHits" , zDauNofStripHits );
211  m.addUserFloat("zDau_TrkNofStripHits" , zDauTrkNofStripHits );
212  m.addUserFloat("zDau_NofPixelHits" , zDauNofPixelHits );
213  m.addUserFloat("zDau_TrkNofPixelHits" , zDauTrkNofPixelHits );
214  m.addUserFloat("zDau_NofMuChambers" , zDauNofMuChambers );
215  m.addUserFloat("zDau_NofMuMatches" , zDauNofMuMatches );
216  m.addUserFloat("zDau_MuEnergyEm", zDauMuEnergyEm );
217  m.addUserFloat("zDau_MuEnergyHad", zDauMuEnergyHad );
218  }
219 
220  evt.put( muonColl);
221 }
222 
224 
226 
const double beta
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:74
vector< double > isolation(const T &t, double ptThreshold, double etEcalThreshold, double etHcalThreshold, double dRVetoTrk, double dRTrk, double dREcal, double dRHcal, double alpha, double beta)
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:100
void produce(edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isTrackerMuon() const
Definition: Muon.h:220
bool isGlobalMuon() const
Definition: Muon.h:219
std::vector< TriggerObjectStandAlone > TriggerObjectStandAloneCollection
Collection of TriggerObjectStandAlone.
bool isStandAloneMuon() const
Definition: Muon.h:221
reco::TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.h:78
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:138
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
void addUserFloat(const std::string &label, float data)
Set user-defined float.
Definition: PATObject.h:763
const TriggerObjectStandAloneCollection triggerObjectMatchesByPath(const std::string &namePath, const bool pathLastFilterAccepted=false, const bool pathL3FilterAccepted=true) const
Definition: PATObject.h:594
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:82
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
Definition: Muon.cc:60
MuonEnergy calEnergy() const
get energy deposition information
Definition: Muon.h:112
int numberOfChambers() const
Definition: Muon.h:185
ZMuMuMuonUserData(const edm::ParameterSet &)
tuple muons
Definition: patZpeak.py:38
dbl *** dir
Definition: mlp_gen.cc:35
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:51
long double T
Analysis-level muon class.
Definition: Muon.h:51