56 highPtJetExpr_ = highptjetparms.
getParameter<std::vector<std::string> >(
"hltPaths");
57 lowPtJetExpr_ = lowptjetparms .getParameter<std::vector<std::string> >(
"hltPaths");
58 highMETExpr_ = highmetparms .getParameter<std::vector<std::string> >(
"hltPaths");
60 muonExpr_ = muonparms .getParameter<std::vector<std::string> >(
"hltPaths");
61 elecExpr_ = eleparms .getParameter<std::vector<std::string> >(
"hltPaths");
62 minbiasExpr_ = minbiasparms .getParameter<std::vector<std::string> >(
"hltPaths");
69 delete _HighPtJetEventFlag;
70 delete _LowPtJetEventFlag;
71 delete _MinBiasEventFlag;
72 delete _HighMETEventFlag;
75 delete _MuonEventFlag;
85 HLTPathsJetMBByName_ =
parameters.getParameter<std::vector<std::string > >(
"HLTPathsJetMB");
91 _techTrigsAND = theCleaningParameters.getParameter<std::vector<unsigned > >(
"techTrigsAND");
92 _techTrigsOR = theCleaningParameters.getParameter<std::vector<unsigned > >(
"techTrigsOR");
93 _techTrigsNOT = theCleaningParameters.getParameter<std::vector<unsigned > >(
"techTrigsNOT");
95 _doHLTPhysicsOn = theCleaningParameters.getParameter<
bool>(
"doHLTPhysicsOn");
96 _hlt_PhysDec = theCleaningParameters.getParameter<std::string>(
"HLT_PhysDec");
98 _tightBHFiltering = theCleaningParameters.getParameter<
bool>(
"tightBHFiltering");
99 _tightJetIDFiltering = theCleaningParameters.getParameter<
int>(
"tightJetIDFiltering");
107 _doPVCheck = theCleaningParameters.getParameter<
bool>(
"doPrimaryVertexCheck");
108 vertexTag = theCleaningParameters.getParameter<
edm::InputTag>(
"vertexLabel");
111 _nvtx_min = theCleaningParameters.getParameter<
int>(
"nvtx_min");
112 _nvtxtrks_min = theCleaningParameters.getParameter<
int>(
"nvtxtrks_min");
113 _vtxndof_min = theCleaningParameters.getParameter<
int>(
"vtxndof_min");
114 _vtxchi2_max = theCleaningParameters.getParameter<
double>(
"vtxchi2_max");
115 _vtxz_max = theCleaningParameters.getParameter<
double>(
"vtxz_max");
120 _source =
parameters.getParameter<std::string>(
"Source");
122 if (theMETCollectionLabel.label() ==
"tcMet" ) {
136 _verbose =
parameters.getParameter<
int>(
"verbose");
137 _etThreshold =
parameters.getParameter<
double>(
"etThreshold");
138 _allhist =
parameters.getParameter<
bool>(
"allHist");
139 _allSelection =
parameters.getParameter<
bool>(
"allSelection");
140 _cleanupSelection =
parameters.getParameter<
bool>(
"cleanupSelection");
142 _FolderName =
parameters.getUntrackedParameter<std::string>(
"FolderName");
144 _highPtJetThreshold =
parameters.getParameter<
double>(
"HighPtJetThreshold");
145 _lowPtJetThreshold =
parameters.getParameter<
double>(
"LowPtJetThreshold");
146 _highMETThreshold =
parameters.getParameter<
double>(
"HighMETThreshold");
154 std::string
DirName = _FolderName+_source;
157 hmetME = dbe->
book1D(
"metReco",
"metReco", 4, 1, 5);
162 _FolderNames.push_back(
"All");
163 _FolderNames.push_back(
"BasicCleanup");
164 _FolderNames.push_back(
"ExtraCleanup");
165 _FolderNames.push_back(
"HcalNoiseFilter");
166 _FolderNames.push_back(
"JetIDMinimal");
167 _FolderNames.push_back(
"JetIDLoose");
168 _FolderNames.push_back(
"JetIDTight");
169 _FolderNames.push_back(
"BeamHaloIDTightPass");
170 _FolderNames.push_back(
"BeamHaloIDLoosePass");
171 _FolderNames.push_back(
"Triggers");
172 _FolderNames.push_back(
"PV");
174 for (std::vector<std::string>::const_iterator ic = _FolderNames.begin();
175 ic != _FolderNames.end(); ic++){
176 if (*ic==
"All") bookMESet(DirName+
"/"+*ic);
177 if (_cleanupSelection){
178 if (*ic==
"BasicCleanup") bookMESet(DirName+
"/"+*ic);
179 if (*ic==
"ExtraCleanup") bookMESet(DirName+
"/"+*ic);
182 if (*ic==
"HcalNoiseFilter") bookMESet(DirName+
"/"+*ic);
183 if (*ic==
"JetIDMinimal") bookMESet(DirName+
"/"+*ic);
184 if (*ic==
"JetIDLoose") bookMESet(DirName+
"/"+*ic);
185 if (*ic==
"JetIDTight") bookMESet(DirName+
"/"+*ic);
186 if (*ic==
"BeamHaloIDTightPass") bookMESet(DirName+
"/"+*ic);
187 if (*ic==
"BeamHaloIDLoosePass") bookMESet(DirName+
"/"+*ic);
188 if (*ic==
"Triggers") bookMESet(DirName+
"/"+*ic);
189 if (*ic==
"PV") bookMESet(DirName+
"/"+*ic);
206 bool bLumiSecPlot=
false;
207 if (DirName.find(
"All")!=std::string::npos) bLumiSecPlot=
true;
209 bookMonitorElement(DirName,bLumiSecPlot);
211 if ( _HighPtJetEventFlag->on() ) {
212 bookMonitorElement(DirName+
"/"+
"HighPtJet",
false);
213 hTriggerName_HighPtJet = _dbe->bookString(
"triggerName_HighPtJet", highPtJetExpr_[0]);
216 if ( _LowPtJetEventFlag->on() ) {
217 bookMonitorElement(DirName+
"/"+
"LowPtJet",
false);
218 hTriggerName_LowPtJet = _dbe->bookString(
"triggerName_LowPtJet", lowPtJetExpr_[0]);
221 if ( _MinBiasEventFlag->on() ) {
222 bookMonitorElement(DirName+
"/"+
"MinBias",
false);
223 hTriggerName_MinBias = _dbe->bookString(
"triggerName_MinBias", minbiasExpr_[0]);
224 if (_verbose)
std::cout <<
"_MinBiasEventFlag is on, folder created\n";
227 if ( _HighMETEventFlag->on() ) {
228 bookMonitorElement(DirName+
"/"+
"HighMET",
false);
229 hTriggerName_HighMET = _dbe->bookString(
"triggerName_HighMET", highMETExpr_[0]);
237 if ( _EleEventFlag->on() ) {
238 bookMonitorElement(DirName+
"/"+
"Ele",
false);
239 hTriggerName_Ele = _dbe->bookString(
"triggerName_Ele", elecExpr_[0]);
240 if (_verbose)
std::cout <<
"_EleEventFlag is on, folder created\n";
243 if ( _MuonEventFlag->on() ) {
244 bookMonitorElement(DirName+
"/"+
"Muon",
false);
245 hTriggerName_Muon = _dbe->bookString(
"triggerName_Muon", muonExpr_[0]);
246 if (_verbose)
std::cout <<
"_MuonEventFlag is on, folder created\n";
253 if (_verbose)
std::cout <<
"bookMonitorElement " << DirName << std::endl;
255 _dbe->setCurrentFolder(DirName);
258 hMEx = _dbe->book1D(
"METTask_MEx",
"METTask_MEx", 200, -500, 500);
259 hMEy = _dbe->book1D(
"METTask_MEy",
"METTask_MEy", 200, -500, 500);
260 hMET = _dbe->book1D(
"METTask_MET",
"METTask_MET", 200, 0, 1000);
261 hSumET = _dbe->book1D(
"METTask_SumET",
"METTask_SumET", 400, 0, 4000);
262 hMETSig = _dbe->book1D(
"METTask_METSig",
"METTask_METSig", 51, 0, 51);
263 hMETPhi = _dbe->book1D(
"METTask_METPhi",
"METTask_METPhi", 60, -3.2, 3.2);
264 hMET_logx = _dbe->book1D(
"METTask_MET_logx",
"METTask_MET_logx", 40, -1, 7);
265 hSumET_logx = _dbe->book1D(
"METTask_SumET_logx",
"METTask_SumET_logx", 40, -1, 7);
267 hMEx ->setAxisTitle(
"MEx [GeV]", 1);
268 hMEy ->setAxisTitle(
"MEy [GeV]", 1);
269 hMET ->setAxisTitle(
"MET [GeV]", 1);
270 hSumET ->setAxisTitle(
"SumET [GeV]", 1);
271 hMETSig ->setAxisTitle(
"CaloMETSig", 1);
272 hMETPhi ->setAxisTitle(
"METPhi [rad]", 1);
273 hMET_logx ->setAxisTitle(
"log(MET) [GeV]", 1);
274 hSumET_logx->setAxisTitle(
"log(SumET) [GeV]", 1);
279 hMExLS = _dbe->book2D(
"METTask_MEx_LS",
"METTask_MEx_LS",200,-200,200,50,0.,500.);
280 hMExLS->setAxisTitle(
"MEx [GeV]",1);
281 hMExLS->setAxisTitle(
"Lumi Section",2);
282 hMEyLS = _dbe->book2D(
"METTask_MEy_LS",
"METTask_MEy_LS",200,-200,200,50,0.,500.);
283 hMEyLS->setAxisTitle(
"MEy [GeV]",1);
284 hMEyLS->setAxisTitle(
"Lumi Section",2);
288 if (theMETCollectionLabel.label() ==
"tcMet" ) {
289 htrkPt = _dbe->book1D(
"METTask_trackPt",
"METTask_trackPt", 50, 0, 500);
290 htrkEta = _dbe->book1D(
"METTask_trackEta",
"METTask_trackEta", 60, -3.0, 3.0);
291 htrkNhits = _dbe->book1D(
"METTask_trackNhits",
"METTask_trackNhits", 50, 0, 50);
292 htrkChi2 = _dbe->book1D(
"METTask_trackNormalizedChi2",
"METTask_trackNormalizedChi2", 20, 0, 20);
293 htrkD0 = _dbe->book1D(
"METTask_trackD0",
"METTask_trackd0", 50, -1, 1);
294 helePt = _dbe->book1D(
"METTask_electronPt",
"METTask_electronPt", 50, 0, 500);
295 heleEta = _dbe->book1D(
"METTask_electronEta",
"METTask_electronEta", 60, -3.0, 3.0);
296 heleHoE = _dbe->book1D(
"METTask_electronHoverE",
"METTask_electronHoverE", 25, 0, 0.5);
297 hmuPt = _dbe->book1D(
"METTask_muonPt",
"METTask_muonPt", 50, 0, 500);
298 hmuEta = _dbe->book1D(
"METTask_muonEta",
"METTask_muonEta", 60, -3.0, 3.0);
299 hmuNhits = _dbe->book1D(
"METTask_muonNhits",
"METTask_muonNhits", 50, 0, 50);
300 hmuChi2 = _dbe->book1D(
"METTask_muonNormalizedChi2",
"METTask_muonNormalizedChi2", 20, 0, 20);
301 hmuD0 = _dbe->book1D(
"METTask_muonD0",
"METTask_muonD0", 50, -1, 1);
304 hMExCorrection = _dbe->book1D(
"METTask_MExCorrection",
"METTask_MExCorrection", 100, -500.0,500.0);
305 hMEyCorrection = _dbe->book1D(
"METTask_MEyCorrection",
"METTask_MEyCorrection", 100, -500.0,500.0);
306 hMuonCorrectionFlag = _dbe->book1D(
"METTask_CorrectionFlag",
"METTask_CorrectionFlag", 5, -0.5, 4.5);
313 if ( _HighPtJetEventFlag->on() ) _HighPtJetEventFlag->initRun( iRun, iSetup );
314 if ( _LowPtJetEventFlag ->on() ) _LowPtJetEventFlag ->initRun( iRun, iSetup );
315 if ( _MinBiasEventFlag ->on() ) _MinBiasEventFlag ->initRun( iRun, iSetup );
316 if ( _HighMETEventFlag ->on() ) _HighMETEventFlag ->initRun( iRun, iSetup );
318 if ( _EleEventFlag ->on() ) _EleEventFlag ->initRun( iRun, iSetup );
319 if ( _MuonEventFlag ->on() ) _MuonEventFlag ->initRun( iRun, iSetup );
321 if (_HighPtJetEventFlag->on() && _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
322 highPtJetExpr_ = _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup);
323 if (_LowPtJetEventFlag->on() && _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
324 lowPtJetExpr_ = _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup);
325 if (_HighMETEventFlag->on() && _HighMETEventFlag->expressionsFromDB(_HighMETEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
326 highMETExpr_ = _HighMETEventFlag->expressionsFromDB(_HighMETEventFlag->hltDBKey(), iSetup);
329 if (_MuonEventFlag->on() && _MuonEventFlag->expressionsFromDB(_MuonEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
330 muonExpr_ = _MuonEventFlag->expressionsFromDB(_MuonEventFlag->hltDBKey(), iSetup);
331 if (_EleEventFlag->on() && _EleEventFlag->expressionsFromDB(_EleEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
332 elecExpr_ = _EleEventFlag->expressionsFromDB(_EleEventFlag->hltDBKey(), iSetup);
333 if (_MinBiasEventFlag->on() && _MinBiasEventFlag->expressionsFromDB(_MinBiasEventFlag->hltDBKey(), iSetup)[0] !=
"CONFIG_ERROR")
334 minbiasExpr_ = _MinBiasEventFlag->expressionsFromDB(_MinBiasEventFlag->hltDBKey(), iSetup);
345 std::string
dirName = _FolderName+_source+
"/";
346 _dbe->setCurrentFolder(dirName);
351 meLumiSec = _dbe->get(
"JetMET/lumisec");
356 tlumisec = meLumiSec->
getTH1F();
357 for (
int i=0;
i<500;
i++){
358 if (tlumisec->GetBinContent(
i+1)) totlsec++;
360 totltime = double(totlsec*90);
363 if (totltime==0.) totltime=1.;
368 for (std::vector<std::string>::const_iterator ic = _FolderNames.begin(); ic != _FolderNames.end(); ic++)
372 DirName = dirName+*ic;
374 makeRatePlot(DirName,totltime);
375 if ( _HighPtJetEventFlag->on() )
376 makeRatePlot(DirName+
"/"+
"triggerName_HighJetPt",totltime);
377 if ( _LowPtJetEventFlag->on() )
378 makeRatePlot(DirName+
"/"+
"triggerName_LowJetPt",totltime);
379 if ( _MinBiasEventFlag->on() )
380 makeRatePlot(DirName+
"/"+
"triggerName_MinBias",totltime);
381 if ( _HighMETEventFlag->on() )
382 makeRatePlot(DirName+
"/"+
"triggerName_HighMET",totltime);
385 if ( _EleEventFlag->on() )
386 makeRatePlot(DirName+
"/"+
"triggerName_Ele",totltime);
387 if ( _MuonEventFlag->on() )
388 makeRatePlot(DirName+
"/"+
"triggerName_Muon",totltime);
397 _dbe->setCurrentFolder(DirName);
408 tMETRate = (TH1F*) tMET->Clone(
"METTask_METRate");
409 for (
int i = tMETRate->GetNbinsX()-1;
i>=0;
i--){
410 tMETRate->SetBinContent(
i+1,tMETRate->GetBinContent(
i+2)+tMET->GetBinContent(
i+1));
412 for (
int i = 0;
i<tMETRate->GetNbinsX();
i++){
413 tMETRate->SetBinContent(
i+1,tMETRate->GetBinContent(
i+1)/double(totltime));
416 tMETRate->SetName(
"METTask_METRate");
417 tMETRate->SetTitle(
"METTask_METRate");
418 hMETRate = _dbe->book1D(
"METTask_METRate",tMETRate);
426 if (_verbose)
std::cout <<
"METAnalyzer analyze" << std::endl;
428 std::string
DirName = _FolderName+_source;
446 if(&triggerResults) {
453 int ntrigs = triggerResults.
size();
454 if (_verbose)
std::cout <<
"ntrigs=" << ntrigs << std::endl;
463 const unsigned int nTrig(triggerNames.
size());
464 for (
unsigned int i=0;
i<nTrig;++
i)
466 if (triggerNames.
triggerName(
i).find(highPtJetExpr_[0].substr(0,highPtJetExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
467 _trig_HighPtJet=
true;
468 else if (triggerNames.
triggerName(
i).find(lowPtJetExpr_[0].substr(0,lowPtJetExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
470 else if (triggerNames.
triggerName(
i).find(highMETExpr_[0].substr(0,highMETExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
474 else if (triggerNames.
triggerName(
i).find(muonExpr_[0].substr(0,muonExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
476 else if (triggerNames.
triggerName(
i).find(elecExpr_[0].substr(0,elecExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
478 else if (triggerNames.
triggerName(
i).find(minbiasExpr_[0].substr(0,minbiasExpr_[0].rfind(
"_v")+2))!=std::string::npos && triggerResults.
accept(
i))
483 for (
unsigned int i=0;
i!=HLTPathsJetMBByName_.size();
i++) {
484 unsigned int triggerIndex = triggerNames.
triggerIndex(HLTPathsJetMBByName_[
i]);
485 if (triggerIndex<triggerResults.
size()) {
486 if (triggerResults.
accept(triggerIndex)) {
492 if (HLTPathsJetMBByName_.size()==0) _trig_JetMB=triggerResults.
size()-1;
520 edm::LogInfo(
"MetAnalyzer") <<
"TriggerResults::HLT not found, "
521 "automatically select events";
532 iEvent.
getByLabel(theMETCollectionLabel, metcoll);
535 std::cout<<
"Unable to find MET results for MET collection "<<theMETCollectionLabel<<std::endl;
541 met = &(metcol->front());
548 if (theMETCollectionLabel.label() ==
"tcMet" ) {
552 iEvent.
getByLabel(inputElectronLabel, electron_h);
553 iEvent.
getByLabel(inputBeamSpotLabel, beamSpot_h);
554 iEvent.
getByLabel(
"muonTCMETValueMapProducer" ,
"muCorrData", tcMet_ValueMap_Handle);
556 if(!muon_h.isValid())
edm::LogInfo(
"OutputInfo") <<
"falied to retrieve muon data require by MET Task";
557 if(!track_h.isValid())
edm::LogInfo(
"OutputInfo") <<
"falied to retrieve track data require by MET Task";
558 if(!electron_h.isValid())
edm::LogInfo(
"OutputInfo") <<
"falied to retrieve electron data require by MET Task";
559 if(!beamSpot_h.isValid())
edm::LogInfo(
"OutputInfo") <<
"falied to retrieve beam spot data require by MET Task";
561 bspot = ( beamSpot_h.isValid() ) ? beamSpot_h->position() :
math::XYZPoint(0, 0, 0);
569 iEvent.
getByLabel(HcalNoiseRBXCollectionTag,HRBXCollection);
570 if (!HRBXCollection.
isValid()) {
571 LogDebug(
"") <<
"METAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
572 if (_verbose)
std::cout <<
"METAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
577 iEvent.
getByLabel(HBHENoiseFilterResultTag, HBHENoiseFilterResultHandle);
578 bool HBHENoiseFilterResult = *HBHENoiseFilterResultHandle;
579 if (!HBHENoiseFilterResultHandle.
isValid()) {
580 LogDebug(
"") <<
"METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
581 if (_verbose)
std::cout <<
"METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
586 iEvent.
getByLabel(theJetCollectionLabel, caloJets);
588 LogDebug(
"") <<
"METAnalyzer: Could not find jet product" << std::endl;
589 if (_verbose)
std::cout <<
"METAnalyzer: Could not find jet product" << std::endl;
600 if (_verbose)
std::cout <<
"JetID starts" << std::endl;
605 bool bJetIDMinimal=
true;
606 for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
607 cal!=caloJets->end(); ++cal){
608 jetID->calculate(iEvent, *cal);
610 if (fabs(cal->eta())<=2.6 &&
611 cal->emEnergyFraction()<=0.01) bJetIDMinimal=
false;
618 bool bJetIDLoose=
true;
619 for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
620 cal!=caloJets->end(); ++cal){
621 jetID->calculate(iEvent, *cal);
622 if (_verbose)
std::cout << jetID->n90Hits() <<
" "
623 << jetID->restrictedEMF() <<
" "
624 << cal->pt() << std::endl;
628 if (jetID->n90Hits()<2) bJetIDLoose=
false;
629 if (jetID->fHPD()>=0.98) bJetIDLoose=
false;
633 if (fabs(cal->eta())<2.55){
634 if (cal->emEnergyFraction()<=0.01) bJetIDLoose=
false;
638 if (cal->emEnergyFraction()<=-0.9) bJetIDLoose=
false;
640 if (cal->emEnergyFraction()>= 1.0) bJetIDLoose=
false;
649 bool bJetIDTight=
true;
650 bJetIDTight=bJetIDLoose;
651 for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
652 cal!=caloJets->end(); ++cal){
653 jetID->calculate(iEvent, *cal);
657 if (jetID->fHPD()>=0.95) bJetIDTight=
false;
660 if (fabs(cal->eta())>=1.00 && fabs(cal->eta())<1.75){
661 if (cal->pt()>80. && cal->emEnergyFraction()>=1.) bJetIDTight=
false;
665 else if (fabs(cal->eta())>=1.75 && fabs(cal->eta())<2.55){
666 if (cal->pt()>80. && cal->emEnergyFraction()>=1.) bJetIDTight=
false;
670 else if (fabs(cal->eta())>=2.55 && fabs(cal->eta())<3.25){
671 if (cal->pt()< 50. && cal->emEnergyFraction()<=-0.3) bJetIDTight=
false;
672 if (cal->pt()>=50. && cal->pt()< 80. && cal->emEnergyFraction()<=-0.2) bJetIDTight=
false;
673 if (cal->pt()>=80. && cal->pt()<340. && cal->emEnergyFraction()<=-0.1) bJetIDTight=
false;
674 if (cal->pt()>=340. && cal->emEnergyFraction()<=-0.1
675 && cal->emEnergyFraction()>=0.95) bJetIDTight=
false;
679 else if (fabs(cal->eta())>=3.25){
680 if (cal->pt()< 50. && cal->emEnergyFraction()<=-0.3
681 && cal->emEnergyFraction()>=0.90) bJetIDTight=
false;
682 if (cal->pt()>=50. && cal->pt()<130. && cal->emEnergyFraction()<=-0.2
683 && cal->emEnergyFraction()>=0.80) bJetIDTight=
false;
684 if (cal->pt()>=130. && cal->emEnergyFraction()<=-0.1
685 && cal->emEnergyFraction()>=0.70) bJetIDTight=
false;
690 if (_verbose)
std::cout <<
"JetID ends" << std::endl;
696 bool bHcalNoiseFilter = HBHENoiseFilterResult;
701 iEvent.
getByLabel(BeamHaloSummaryTag, TheBeamHaloSummary) ;
703 if (!TheBeamHaloSummary.
isValid()) {
704 std::cout <<
"BeamHaloSummary doesn't exist" << std::endl;
707 bool bBeamHaloIDTightPass =
true;
708 bool bBeamHaloIDLoosePass =
true;
710 if(!TheBeamHaloSummary.
isValid()) {
716 bBeamHaloIDLoosePass =
false;
720 bBeamHaloIDTightPass =
false;
727 bool bPrimaryVertex =
true;
729 bPrimaryVertex =
false;
735 LogDebug(
"") <<
"CaloMETAnalyzer: Could not find vertex collection" << std::endl;
736 if (_verbose)
std::cout <<
"CaloMETAnalyzer: Could not find vertex collection" << std::endl;
741 int vertex_number = vertexCollection.size();
742 VertexCollection::const_iterator
v = vertexCollection.begin();
743 for ( ; v != vertexCollection.end(); ++
v) {
744 double vertex_chi2 = v->normalizedChi2();
745 double vertex_ndof = v->ndof();
746 bool fakeVtx = v->isFake();
747 double vertex_Z = v->z();
750 && vertex_number>=_nvtx_min
751 && vertex_ndof >_vtxndof_min
752 && vertex_chi2 <_vtxchi2_max
753 && fabs(vertex_Z)<_vtxz_max )
754 bPrimaryVertex =
true;
763 if (!gtReadoutRecord.
isValid()) {
764 LogDebug(
"") <<
"CaloMETAnalyzer: Could not find GT readout record" << std::endl;
765 if (_verbose)
std::cout <<
"CaloMETAnalyzer: Could not find GT readout record product" << std::endl;
768 bool bTechTriggers =
true;
769 bool bTechTriggersAND =
true;
770 bool bTechTriggersOR =
false;
771 bool bTechTriggersNOT =
false;
773 if (gtReadoutRecord.
isValid()) {
774 const TechnicalTriggerWord& technicalTriggerWordBeforeMask = gtReadoutRecord->technicalTriggerWord();
776 if (_techTrigsAND.size() == 0)
777 bTechTriggersAND =
true;
779 for (
unsigned ttr = 0; ttr != _techTrigsAND.size(); ttr++) {
780 bTechTriggersAND = bTechTriggersAND && technicalTriggerWordBeforeMask.at(_techTrigsAND.at(ttr));
783 if (_techTrigsAND.size() == 0)
784 bTechTriggersOR =
true;
786 for (
unsigned ttr = 0; ttr != _techTrigsOR.size(); ttr++) {
787 bTechTriggersOR = bTechTriggersOR || technicalTriggerWordBeforeMask.at(_techTrigsOR.at(ttr));
789 if (_techTrigsNOT.size() == 0)
790 bTechTriggersNOT =
false;
792 for (
unsigned ttr = 0; ttr != _techTrigsNOT.size(); ttr++) {
793 bTechTriggersNOT = bTechTriggersNOT || technicalTriggerWordBeforeMask.at(_techTrigsNOT.at(ttr));
798 bTechTriggersAND =
true;
799 bTechTriggersOR =
true;
800 bTechTriggersNOT =
false;
803 if (_techTrigsAND.size()==0)
804 bTechTriggersAND =
true;
805 if (_techTrigsOR.size()==0)
806 bTechTriggersOR =
true;
807 if (_techTrigsNOT.size()==0)
808 bTechTriggersNOT =
false;
810 bTechTriggers = bTechTriggersAND && bTechTriggersOR && !bTechTriggersNOT;
815 bool bHcalNoise = bHcalNoiseFilter;
816 bool bBeamHaloID = bBeamHaloIDLoosePass;
819 bool bPhysicsDeclared =
true;
820 if(_doHLTPhysicsOn) bPhysicsDeclared =_trig_PhysDec;
823 if (_tightBHFiltering) bBeamHaloID = bBeamHaloIDTightPass;
825 if (_tightJetIDFiltering==1) bJetID = bJetIDMinimal;
826 else if (_tightJetIDFiltering==2) bJetID = bJetIDLoose;
827 else if (_tightJetIDFiltering==3) bJetID = bJetIDTight;
828 else if (_tightJetIDFiltering==-1) bJetID =
true;
830 bool bBasicCleanup = bTechTriggers && bPrimaryVertex && bPhysicsDeclared;
831 bool bExtraCleanup = bBasicCleanup && bHcalNoise && bJetID && bBeamHaloID;
835 for (std::vector<std::string>::const_iterator ic = _FolderNames.begin();
836 ic != _FolderNames.end(); ic++){
837 if (*ic==
"All") fillMESet(iEvent, DirName+
"/"+*ic, *met);
838 if (DCSFilter->filter(iEvent, iSetup)) {
839 if (_cleanupSelection){
840 if (*ic==
"BasicCleanup" && bBasicCleanup) fillMESet(iEvent, DirName+
"/"+*ic, *met);
841 if (*ic==
"ExtraCleanup" && bExtraCleanup) fillMESet(iEvent, DirName+
"/"+*ic, *met);
844 if (*ic==
"HcalNoiseFilter" && bHcalNoiseFilter ) fillMESet(iEvent, DirName+
"/"+*ic, *met);
845 if (*ic==
"JetIDMinimal" && bJetIDMinimal) fillMESet(iEvent, DirName+
"/"+*ic, *met);
846 if (*ic==
"JetIDLoose" && bJetIDLoose) fillMESet(iEvent, DirName+
"/"+*ic, *met);
847 if (*ic==
"JetIDTight" && bJetIDTight) fillMESet(iEvent, DirName+
"/"+*ic, *met);
848 if (*ic==
"BeamHaloIDTightPass" && bBeamHaloIDTightPass) fillMESet(iEvent, DirName+
"/"+*ic, *met);
849 if (*ic==
"BeamHaloIDLoosePass" && bBeamHaloIDLoosePass) fillMESet(iEvent, DirName+
"/"+*ic, *met);
850 if (*ic==
"Triggers" && bTechTriggers) fillMESet(iEvent, DirName+
"/"+*ic, *met);
851 if (*ic==
"PV" && bPrimaryVertex) fillMESet(iEvent, DirName+
"/"+*ic, *met);
863 _dbe->setCurrentFolder(DirName);
865 bool bLumiSecPlot=
false;
866 if (DirName.find(
"All")) bLumiSecPlot=
true;
869 fillMonitorElement(iEvent,DirName,
"",met, bLumiSecPlot);
871 fillMonitorElement(iEvent,DirName,
"HighPtJet",met,
false);
873 fillMonitorElement(iEvent,DirName,
"LowPtJet",met,
false);
875 fillMonitorElement(iEvent,DirName,
"MinBias",met,
false);
877 fillMonitorElement(iEvent,DirName,
"HighMET",met,
false);
881 fillMonitorElement(iEvent,DirName,
"Ele",met,
false);
883 fillMonitorElement(iEvent,DirName,
"Muon",met,
false);
888 std::string TriggerTypeName,
892 if (TriggerTypeName==
"HighPtJet") {
893 if (!selectHighPtJetEvent(iEvent))
return;
895 else if (TriggerTypeName==
"LowPtJet") {
896 if (!selectLowPtJetEvent(iEvent))
return;
898 else if (TriggerTypeName==
"HighMET") {
899 if (met.
pt()<_highMETThreshold)
return;
904 else if (TriggerTypeName==
"Ele") {
905 if (!selectWElectronEvent(iEvent))
return;
907 else if (TriggerTypeName==
"Muon") {
908 if (!selectWMuonEvent(iEvent))
return;
912 double SumET = met.
sumEt();
913 double METSig = met.
mEtSig();
915 double MET = met.
pt();
916 double MEx = met.
px();
917 double MEy = met.
py();
918 double METPhi = met.
phi();
921 int myLuminosityBlock;
926 if (TriggerTypeName!=
"") DirName = DirName +
"/"+TriggerTypeName;
928 if (_verbose)
std::cout <<
"_etThreshold = " << _etThreshold << std::endl;
929 if (SumET>_etThreshold){
931 hMEx = _dbe->get(DirName+
"/"+
"METTask_MEx");
if (hMEx && hMEx->getRootObject()) hMEx ->
Fill(MEx);
932 hMEy = _dbe->get(DirName+
"/"+
"METTask_MEy");
if (hMEy && hMEy->getRootObject()) hMEy ->
Fill(MEy);
933 hMET = _dbe->get(DirName+
"/"+
"METTask_MET");
if (hMET && hMET->getRootObject()) hMET ->
Fill(MET);
934 hMETPhi = _dbe->get(DirName+
"/"+
"METTask_METPhi");
if (hMETPhi && hMETPhi->getRootObject()) hMETPhi ->
Fill(METPhi);
935 hSumET = _dbe->get(DirName+
"/"+
"METTask_SumET");
if (hSumET && hSumET->getRootObject()) hSumET ->
Fill(SumET);
936 hMETSig = _dbe->get(DirName+
"/"+
"METTask_METSig");
if (hMETSig && hMETSig->getRootObject()) hMETSig ->
Fill(METSig);
939 hMET_logx = _dbe->get(DirName+
"/"+
"METTask_MET_logx");
if (hMET_logx && hMET_logx->getRootObject()) hMET_logx->Fill(log10(MET));
940 hSumET_logx = _dbe->get(DirName+
"/"+
"METTask_SumET_logx");
if (hSumET_logx && hSumET_logx->getRootObject()) hSumET_logx->Fill(log10(SumET));
947 hMExLS = _dbe->get(DirName+
"/"+
"METTask_MExLS");
if (hMExLS && hMExLS->getRootObject()) hMExLS->Fill(MEx,myLuminosityBlock);
948 hMEyLS = _dbe->get(DirName+
"/"+
"METTask_MEyLS");
if (hMEyLS && hMEyLS->getRootObject()) hMEyLS->Fill(MEy,myLuminosityBlock);
953 if (theMETCollectionLabel.label() ==
"tcMet" ) {
955 if(track_h.isValid()) {
957 htrkPt = _dbe->get(DirName+
"/"+
"METTask_trackPt");
if (htrkPt && htrkPt->getRootObject()) htrkPt->Fill( trkit->pt() );
958 htrkEta = _dbe->get(DirName+
"/"+
"METTask_trackEta");
if (htrkEta && htrkEta->getRootObject()) htrkEta->Fill( trkit->eta() );
959 htrkNhits = _dbe->get(DirName+
"/"+
"METTask_trackNhits");
if (htrkNhits && htrkNhits->getRootObject()) htrkNhits->Fill( trkit->numberOfValidHits() );
960 htrkChi2 = _dbe->get(DirName+
"/"+
"METTask_trackNormalizedChi2");
if (htrkChi2 && htrkChi2->getRootObject()) htrkChi2->Fill( trkit->chi2() / trkit->ndof() );
961 double d0 = -1 * trkit->dxy( bspot );
962 htrkD0 = _dbe->get(DirName+
"/"+
"METTask_trackD0");
if (htrkD0 && htrkD0->getRootObject()) htrkD0->Fill( d0 );
966 if(electron_h.isValid()) {
968 helePt = _dbe->get(DirName+
"/"+
"METTask_electronPt");
if (helePt && helePt->getRootObject()) helePt->Fill( eleit->p4().pt() );
969 heleEta = _dbe->get(DirName+
"/"+
"METTask_electronEta");
if (heleEta && heleEta->getRootObject()) heleEta->Fill( eleit->p4().eta() );
970 heleHoE = _dbe->get(DirName+
"/"+
"METTask_electronHoverE");
if (heleHoE && heleHoE->getRootObject()) heleHoE->Fill( eleit->hadronicOverEm() );
974 if(muon_h.isValid()) {
975 for( reco::MuonCollection::const_iterator muonit = muon_h->begin(); muonit != muon_h->end(); muonit++ ) {
977 hmuPt = _dbe->
get(DirName+
"/"+
"METTask_muonPt");
if (hmuPt && hmuPt->getRootObject()) hmuPt ->
Fill( muonit->p4().pt() );
978 hmuEta = _dbe->get(DirName+
"/"+
"METTask_muonEta");
if (hmuEta && hmuEta->getRootObject()) hmuEta ->
Fill( muonit->p4().eta() );
979 hmuNhits = _dbe->get(DirName+
"/"+
"METTask_muonNhits");
if (hmuNhits && hmuNhits->getRootObject()) hmuNhits->Fill( siTrack.
isNonnull() ? siTrack->numberOfValidHits() : -999 );
980 hmuChi2 = _dbe->get(DirName+
"/"+
"METTask_muonNormalizedChi2");
if (hmuChi2 && hmuChi2->getRootObject()) hmuChi2 ->
Fill( siTrack.
isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
981 double d0 = siTrack.
isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
982 hmuD0 = _dbe->
get(DirName+
"/"+
"METTask_muonD0");
if (hmuD0 && hmuD0->getRootObject()) hmuD0->Fill( d0 );
985 const unsigned int nMuons = muon_h->size();
986 for(
unsigned int mus = 0; mus < nMuons; mus++ ) {
989 hMExCorrection = _dbe->get(DirName+
"/"+
"METTask_MExCorrection");
if (hMExCorrection && hMExCorrection->getRootObject()) hMExCorrection->
Fill(muCorrData.
corrY());
990 hMEyCorrection = _dbe->get(DirName+
"/"+
"METTask_MEyCorrection");
if (hMEyCorrection && hMEyCorrection->getRootObject()) hMEyCorrection->
Fill(muCorrData.
corrX());
991 hMuonCorrectionFlag = _dbe->get(DirName+
"/"+
"METTask_CorrectionFlag");
if (hMuonCorrectionFlag && hMuonCorrectionFlag->getRootObject()) hMuonCorrectionFlag->
Fill(muCorrData.
type());
1003 bool return_value=
false;
1006 iEvent.
getByLabel(theJetCollectionLabel, caloJets);
1008 LogDebug(
"") <<
"METAnalyzer: Could not find jet product" << std::endl;
1009 if (_verbose)
std::cout <<
"METAnalyzer: Could not find jet product" << std::endl;
1012 for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
1013 cal!=caloJets->end(); ++cal){
1014 if (cal->pt()>_highPtJetThreshold){
1019 return return_value;
1025 bool return_value=
false;
1028 iEvent.
getByLabel(theJetCollectionLabel, caloJets);
1030 LogDebug(
"") <<
"METAnalyzer: Could not find jet product" << std::endl;
1031 if (_verbose)
std::cout <<
"METAnalyzer: Could not find jet product" << std::endl;
1034 for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
1035 cal!=caloJets->end(); ++cal){
1036 if (cal->pt()>_lowPtJetThreshold){
1041 return return_value;
1049 bool return_value=
true;
1055 return return_value;
1062 bool return_value=
true;
1068 return return_value;
const bool EcalTightHaloId() const
T getParameter(std::string const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
const bool HcalTightHaloId() const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
const bool GlobalLooseHaloId() const
const std::string metname
bool accept() const
Has at least one path accepted the event?
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
edm::LuminosityBlockNumber_t luminosityBlock() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Strings::size_type size() const
const bool GlobalTightHaloId() const
const bool HcalLooseHaloId() const
const bool CSCTightHaloId() const
bool isNonnull() const
Checks for non-null.
unsigned int triggerIndex(std::string const &name) const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
unsigned int size() const
Get number of paths stored.
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
TObject * getRootObject(void) const
virtual double px() const
x coordinate of momentum vector
virtual double pt() const
transverse momentum
std::string const & triggerName(unsigned int index) const
XYZPointD XYZPoint
point in space with cartesian internal representation
TH1F * getTH1F(void) const
T const * product() const
const bool CSCLooseHaloId() const
T const * get() const
Returns C++ pointer to the item.
virtual double phi() const
momentum azimuthal angle
const bool EcalLooseHaloId() const
virtual double py() const
y coordinate of momentum vector
void setCurrentFolder(const std::string &fullpath)