40 #include "TLorentzVector.h"
54 theElecTriggerPathToPass = parameters.
getParameter<
string>(
"elecTriggerPathToPass");
55 theMuonTriggerPathToPass = parameters.
getParameter<
string>(
"muonTriggerPathToPass");
63 isValidHltConfig_ =
false;
73 logTraceName =
"EwkAnalyzer";
75 LogTrace(logTraceName)<<
"Parameters initialization";
77 theDbe->setCurrentFolder(
"Physics/EwkDQM");
79 const float pi = 3.14159265;
82 h_vertex_number = theDbe->book1D(
"h_vertex_number",
"Number of event vertices in collection", 10,-0.5, 9.5 );
83 h_vertex_chi2 = theDbe->book1D(
"h_vertex_chi2" ,
"Event Vertex #chi^{2}/n.d.o.f." , 20, 0.0, 2.0 );
84 h_vertex_numTrks = theDbe->book1D(
"h_vertex_numTrks",
"Event Vertex, number of tracks" , 20, -0.5, 59.5 );
85 h_vertex_sumTrks = theDbe->book1D(
"h_vertex_sumTrks",
"Event Vertex, sum of track pt" , 20, 0.0, 100.0 );
86 h_vertex_d0 = theDbe->book1D(
"h_vertex_d0" ,
"Event Vertex d0" , 20, 0.0, 0.05);
87 h_mumu_invMass = theDbe->book1D(
"h_mumu_invMass",
"#mu#mu Invariant Mass;InvMass (GeV)" , 20, 40.0, 140.0 );
88 h_ee_invMass = theDbe->book1D(
"h_ee_invMass",
"ee Invariant Mass;InvMass (Gev)" , 20, 40.0, 140.0 );
89 h_jet_et = theDbe->book1D(
"h_jet_et",
"Jet with highest E_{T} (from "+theCaloJetCollectionLabel.label()+
");E_{T}(1^{st} jet) (GeV)", 20, 0., 200.0);
90 h_jet2_et = theDbe->book1D(
"h_jet2_et",
"Jet with 2^{nd} highest E_{T} (from "+theCaloJetCollectionLabel.label()+
");E_{T}(2^{nd} jet) (GeV)", 20, 0., 200.0);
91 h_jet_count = theDbe->book1D(
"h_jet_count",
"Number of "+theCaloJetCollectionLabel.label()+
" (E_{T} > 15 GeV);Number of Jets", 8, -0.5, 7.5);
92 h_e1_et = theDbe->book1D(
"h_e1_et",
"E_{T} of Leading Electron;E_{T} (GeV)" , 20, 0.0 , 100.0);
93 h_e2_et = theDbe->book1D(
"h_e2_et",
"E_{T} of Second Electron;E_{T} (GeV)" , 20, 0.0 , 100.0);
94 h_e1_eta = theDbe->book1D(
"h_e1_eta",
"#eta of Leading Electron;#eta" , 20, -4.0 , 4.0);
95 h_e2_eta = theDbe->book1D(
"h_e2_eta",
"#eta of Second Electron;#eta" , 20, -4.0 , 4.0);
96 h_e1_phi = theDbe->book1D(
"h_e1_phi",
"#phi of Leading Electron;#phi" , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
97 h_e2_phi = theDbe->book1D(
"h_e2_phi",
"#phi of Second Electron;#phi" , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
98 h_m1_pt = theDbe->book1D(
"h_m1_pt",
"p_{T} of Leading Muon;p_{T}(1^{st} #mu) (GeV)", 20, 0.0 , 100.0);
99 h_m2_pt = theDbe->book1D(
"h_m2_pt",
"p_{T} of Second Muon;p_{T}(2^{nd} #mu) (GeV)" , 20, 0.0 , 100.0);
100 h_m1_eta = theDbe->book1D(
"h_m1_eta",
"#eta of Leading Muon;#eta(1^{st} #mu)" , 20, -4.0 , 4.0);
101 h_m2_eta = theDbe->book1D(
"h_m2_eta",
"#eta of Second Muon;#eta(2^{nd} #mu)" , 20, -4.0 , 4.0);
102 h_m1_phi = theDbe->book1D(
"h_m1_phi",
"#phi of Leading Muon;#phi(1^{st} #mu)" , 20, (-1.-1./10.)*pi, (1.+1./10.)*pi);
103 h_m2_phi = theDbe->book1D(
"h_m2_phi",
"#phi of Second Muon;#phi(2^{nd} #mu)" , 20, (-1.-1./10.)*pi, (1.+1./10.)*pi);
107 h_met = theDbe->book1D(
"h_met",
"Missing E_{T}; GeV" , 20, 0.0 , 100);
108 h_met_phi = theDbe->book1D(
"h_met_phi",
"Missing E_{T} #phi;#phi(MET)" , 22, (-1.-1./10.)*pi, (1.+1./10.)*pi );
109 h_e_invWMass = theDbe->book1D(
"h_e_invWMass",
"W-> e #nu Transverse Mass;M_{T} (GeV)" , 20, 0.0, 140.0);
110 h_m_invWMass = theDbe->book1D(
"h_m_invWMass",
"W-> #mu #nu Transverse Mass;M_{T} (GeV)" , 20, 0.0, 140.0);
121 bool isConfigChanged =
false;
124 const std::string hltProcessName( theTriggerResultsCollection.process() );
125 isValidHltConfig_ = hltConfigProvider_.init( theRun, theSetup, hltProcessName, isConfigChanged );
133 if( ! isValidHltConfig_ )
return;
136 LogTrace(logTraceName)<<
"Analysis of event # ";
139 iEvent.
getByLabel(theTriggerResultsCollection, HLTresults);
140 if ( !HLTresults.
isValid() )
return;
144 bool passed_electron_HLT =
true;
145 bool passed_muon_HLT =
true;
153 iEvent.
getByLabel(
"offlinePrimaryVertices", vertexHandle);
154 if ( !vertexHandle.
isValid() )
return;
156 int vertex_number = vertexCollection.size();
157 VertexCollection::const_iterator
v = vertexCollection.begin();
158 double vertex_chi2 = v->normalizedChi2();
159 double vertex_d0 =
sqrt(v->x()*v->x()+v->y()*v->y());
161 double vertex_numTrks = v->tracksSize();
162 double vertex_sumTrks = 0.0;
163 for (
Vertex::trackRef_iterator vertex_curTrack = v->tracks_begin(); vertex_curTrack!=v->tracks_end(); vertex_curTrack++) {
164 vertex_sumTrks += (*vertex_curTrack)->pt();
170 iEvent.
getByLabel(theCaloMETCollectionLabel, caloMETCollection);
171 if ( !caloMETCollection.
isValid() )
return;
172 float missing_et = caloMETCollection->begin()->et();
173 float met_phi = caloMETCollection->begin()->phi();
179 iEvent.
getByLabel(theElectronCollectionLabel, electronCollection);
180 if ( !electronCollection.
isValid() )
return;
183 float electron_et = -8.0;
184 float electron_eta = -8.0;
185 float electron_phi = -8.0;
186 float electron2_et = -9.0;
187 float electron2_eta = -9.0;
188 float electron2_phi = -9.0;
189 float ee_invMass = -9.0;
190 TLorentzVector e1, e2;
193 if( passed_electron_HLT ) {
195 for (reco::GsfElectronCollection::const_iterator recoElectron=electronCollection->begin(); recoElectron!=electronCollection->end(); recoElectron++){
198 if ( recoElectron->et() < 20 || fabs(recoElectron->eta())>2.5 )
continue;
201 if ( recoElectron->deltaPhiSuperClusterTrackAtVtx() > 0.58 ||
202 recoElectron->deltaEtaSuperClusterTrackAtVtx() > 0.01 ||
203 recoElectron->sigmaIetaIeta() > 0.027 )
continue;
205 if (recoElectron->et() > electron_et){
206 electron2_et = electron_et;
207 electron2_eta = electron_eta;
208 electron2_phi = electron_phi;
209 electron_et = recoElectron->et();
210 electron_eta = recoElectron->eta();
211 electron_phi = recoElectron->phi();
212 e1 = TLorentzVector(recoElectron->momentum().x(),recoElectron->momentum().y(),recoElectron->momentum().z(),recoElectron->p());
213 }
else if (recoElectron->et() > electron2_et) {
214 electron2_et = recoElectron->et();
215 electron2_eta = recoElectron->eta();
216 electron2_phi = recoElectron->phi();
217 e2 = TLorentzVector(recoElectron->momentum().x(),recoElectron->momentum().y(),recoElectron->momentum().z(),recoElectron->p());
220 if (electron2_et>0.0) {
221 TLorentzVector pair=e1+e2;
222 ee_invMass = pair.M();
232 iEvent.
getByLabel(theMuonCollectionLabel,muonCollection);
233 if ( !muonCollection.
isValid() )
return;
236 float mm_invMass = -9.0;
237 float muon_pt = -9.0;
238 float muon_eta = -9.0;
239 float muon_phi = -9.0;
240 float muon2_pt = -9.0;
241 float muon2_eta = -9.0;
242 float muon2_phi = -9.0;
243 TLorentzVector m1, m2;
245 if( passed_muon_HLT ) {
246 for (reco::MuonCollection::const_iterator recoMuon=muonCollection->begin(); recoMuon!=muonCollection->end(); recoMuon++){
249 if ( recoMuon->pt() < 20 || !recoMuon->isGlobalMuon() )
continue;
251 if ( recoMuon->globalTrack()->normalizedChi2() > 10 )
continue;
253 if (recoMuon->pt() > muon_pt){
255 muon2_eta = muon_eta;
256 muon2_phi = muon_phi;
257 muon_pt = recoMuon->pt();
258 muon_eta = recoMuon->eta();
259 muon_phi = recoMuon->phi();
260 m1 = TLorentzVector(recoMuon->momentum().x(),recoMuon->momentum().y(),recoMuon->momentum().z(),recoMuon->p());
261 }
else if (recoMuon->pt() > muon2_pt) {
262 muon2_pt = recoMuon->pt();
263 muon2_eta = recoMuon->eta();
264 muon2_phi = recoMuon->phi();
265 m2 = TLorentzVector(recoMuon->momentum().x(),recoMuon->momentum().y(),recoMuon->momentum().z(),recoMuon->p());
270 TLorentzVector pair=m1+m2;
271 mm_invMass = pair.M();
279 iEvent.
getByLabel (theCaloJetCollectionLabel,caloJetCollection);
280 if ( !caloJetCollection.
isValid() )
return;
283 float jet_eta = -8.0;
284 float jet_phi = -8.0;
286 float jet2_et = -9.0;
287 float jet2_eta = -9.0;
288 float jet2_phi = -9.0;
289 for (CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin(); i_calojet != caloJetCollection->end(); i_calojet++) {
291 float jet_current_et = i_calojet->et();
294 if ( electron_et>0.0 && fabs(i_calojet->eta()-electron_eta ) < 0.2 &&
calcDeltaPhi(i_calojet->phi(), electron_phi ) < 0.2)
continue;
295 if ( electron2_et>0.0&& fabs(i_calojet->eta()-electron2_eta) < 0.2 &&
calcDeltaPhi(i_calojet->phi(), electron2_phi) < 0.2)
continue;
298 if (jet_current_et < 15)
continue;
301 if (jet_current_et > jet_et) {
305 jet_et = i_calojet->et();
306 jet_eta = i_calojet->eta();
307 jet_phi = i_calojet->phi();
308 }
else if (jet_current_et > jet2_et) {
309 jet2_et = i_calojet->et();
310 jet2_eta = i_calojet->eta();
311 jet2_phi = i_calojet->phi();
322 bool fill_e1 =
false;
323 bool fill_e2 =
false;
324 bool fill_m1 =
false;
325 bool fill_m2 =
false;
326 bool fill_met =
false;
329 if (ee_invMass>0.0) {
330 h_ee_invMass ->Fill(ee_invMass);
336 if (mm_invMass > 0.0) {
337 h_mumu_invMass->Fill(mm_invMass);
343 if (electron_et>0.0&&missing_et>20.0) {
344 float dphiW = fabs(met_phi-electron_phi);
345 float W_mt_e =
sqrt(2*missing_et*electron_et*(1-
cos(dphiW)));
346 h_e_invWMass ->Fill(W_mt_e);
352 if (muon_pt>0.0&&missing_et>20.0) {
353 float dphiW = fabs(met_phi-muon_phi);
354 float W_mt_m =
sqrt(2*missing_et*muon_pt*(1-
cos(dphiW)));
355 h_m_invWMass ->Fill(W_mt_m);
361 h_jet_et ->Fill(jet_et);
362 h_jet_count->Fill(jet_count);
365 if (fill_e1 || fill_m1) {
366 h_vertex_number->Fill(vertex_number);
367 h_vertex_chi2->Fill(vertex_chi2);
368 h_vertex_d0 ->Fill(vertex_d0);
369 h_vertex_numTrks->Fill(vertex_numTrks);
370 h_vertex_sumTrks->Fill(vertex_sumTrks);
374 h_e1_et ->Fill(electron_et);
375 h_e1_eta ->Fill(electron_eta);
376 h_e1_phi ->Fill(electron_phi);
379 h_e2_et ->Fill(electron2_et);
380 h_e2_eta ->Fill(electron2_eta);
381 h_e2_phi ->Fill(electron2_phi);
384 h_m1_pt ->Fill(muon_pt);
385 h_m1_eta ->Fill(muon_eta);
386 h_m1_phi ->Fill(muon_phi);
389 h_m2_pt ->Fill(muon2_pt);
390 h_m2_eta ->Fill(muon2_eta);
391 h_m2_phi ->Fill(muon2_phi);
394 h_met ->Fill(missing_et);
395 h_met_phi ->Fill(met_phi);
409 if (deltaPhi < 0) deltaPhi = -
deltaPhi;
411 if (deltaPhi > 3.1415926) {
412 deltaPhi = 2 * 3.1415926 -
deltaPhi;
void beginRun(const edm::Run &, const edm::EventSetup &)
T getParameter(std::string const &) const
double calcDeltaPhi(double phi1, double phi2)
EwkDQM(const edm::ParameterSet &)
Constructor.
double deltaPhi(float phi1, float phi2)
void endJob(void)
Save the histos.
std::vector< Vertex > VertexCollection
collection of Vertex objects
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
Cos< T >::type cos(const T &t)
void beginJob()
Inizialize parameters for histo binning.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual ~EwkDQM()
Destructor.
T const * product() const
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
double calcDeltaPhi(double phi1, double phi2)