36 _analysisname(analysisname),
40 _hltProcessName(pset.getParameter<std::
string>(
"hltProcessName")),
41 _histDirectory(pset.getParameter<std::
string>(
"histDirectory")),
44 _recoHtJetLabel(iC.consumes<
reco::
PFJetCollection>(pset.getUntrackedParameter<std::
string>(
"recoHtJetLabel",
"ak4PFJetsCHS"))),
45 _parametersEta(pset.getParameter<std::vector<double> >(
"parametersEta")),
46 _parametersPhi(pset.getParameter<std::vector<double> >(
"parametersPhi")),
47 _parametersPu(pset.getParameter<std::vector<double> >(
"parametersPu")),
49 _parametersTurnOn(pset.getParameter<std::vector<double> >(
"parametersTurnOn")),
50 _trigResultsTag(iC.consumes<edm::TriggerResults>(edm::
InputTag(
"TriggerResults",
"",_hltProcessName))),
54 _recCaloMETSelector(0),
57 _recPhotonSelector(0),
67 if( anpset.
exists(
"parametersTurnOn") )
74 for(std::map<unsigned int,std::string>::const_iterator it =
_recLabels.begin();
84 for(std::map<unsigned int,std::string>::const_iterator it =
_recLabels.begin();
96 if(anpset.
existsAs<
double>( objStr+
"_cutMinPt" ,
false) )
100 if(anpset.
existsAs<
double>( objStr+
"_cutMaxEta" ,
false) )
108 std::vector<double> default_parametersHt;
109 default_parametersHt.push_back(100);
110 default_parametersHt.push_back(0);
111 default_parametersHt.push_back(1000);
117 if( _HtJetPtMin>0 && _HtJetEtaMax>0 )
_bookHtPlots =
true;
120 if( pset.
exists(
"pileUpInfoLabel") )
125 if( anpset.
existsAs<std::vector<double>>(
"NminOneCuts" ,
false) )
129 edm::LogError(
"HiggsValidation") <<
"In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
130 <<
"Incoherence found in the python configuration file!!\nThe SubAnalysis '"
132 <<
_NminOneCuts.size() <<
", while it needs to be at least of size "
189 edm::LogError(
"HiggsValidations") <<
"HLTHiggsSubAnalysis::beginRun: "
190 <<
"Initializtion of HLTConfigProvider failed!!";
204 if(TString(thetriggername).Contains(pattern))
212 LogDebug(
"HiggsValidations") <<
"HLTHiggsSubAnalysis::beginRun, In "
219 <<
"\nHLT Trigger Paths found >>>";
222 for(std::set<std::string>::iterator iPath =
_hltPaths.begin();
229 if(path.rfind(
"_v") < path.length())
231 shortpath = path.substr(0, path.rfind(
"_v"));
236 const std::vector<unsigned int> objsNeedHLT = this->
getObjectsType(shortpath);
239 std::vector<unsigned int> userInstantiate;
240 for(std::map<unsigned int,std::string>::iterator it =
_recLabels.begin() ;
243 userInstantiate.push_back(it->first);
245 for(std::vector<unsigned int>::const_iterator it = objsNeedHLT.begin(); it != objsNeedHLT.end();
248 if(
std::find(userInstantiate.begin(),userInstantiate.end(), *it) ==
249 userInstantiate.end() )
251 edm::LogError(
"HiggsValidation") <<
"In HLTHiggsSubAnalysis::beginRun, "
252 <<
"Incoherence found in the python configuration file!!\nThe SubAnalysis '"
253 <<
_analysisname <<
"' has been asked to evaluate the trigger path '"
254 << shortpath <<
"' (found it in 'hltPathsToCheck') BUT this path"
256 <<
"' which has not been instantiate ('recVariableLabels'"
261 LogTrace(
"HiggsValidation") <<
" --- " << shortpath;
275 std::vector<std::string> sources(2);
279 for(std::map<unsigned int,std::string>::const_iterator it =
_recLabels.begin();
285 for(
size_t i = 0;
i < sources.size();
i++)
289 if( source ==
"gen" )
continue;
297 else bookHist(source, objStr,
"CSV1", ibooker);
304 bookHist(source, objStr,
"Eta", ibooker);
305 bookHist(source, objStr,
"Phi", ibooker);
310 bookHist(source, objStr, maxPt.Data(), ibooker);
316 for(std::vector<HLTHiggsPlotter>::iterator it =
_analyzers.begin();
322 for(
size_t i = 0;
i < sources.size();
i++)
324 std::string nameGlobalEfficiency =
"SummaryPaths_"+_analysisname+
"_"+sources[
i];
328 std::string nameGlobalEfficiencyPassing= nameGlobalEfficiency+
"_passingHLT";
331 std::string titlePu =
"nb of interations in the event";
332 std::string nameVtxPlot =
"trueVtxDist_"+_analysisname+
"_"+sources[
i];
334 int nBinsPu = (int)paramsPu[0];
335 double minPu = paramsPu[1];
336 double maxPu = paramsPu[2];
338 std::string titleHt =
"sum of jet pT in the event";
339 std::string nameHtPlot =
"HtDist_"+_analysisname+
"_"+sources[
i];
341 int nBinsHt = (int)paramsHt[0];
342 double minHt = paramsHt[1];
343 double maxHt = paramsHt[2];
351 if(path.rfind(
"_v") < path.length())
353 shortpath = path.substr(0, path.rfind(
"_v"));
355 std::string titlePassingPu =
"nb of interations in the event passing path " + shortpath;
356 if( (!
_useNminOneCuts) || sources[
i] ==
"rec" )
_elements[nameVtxPlot+
"_"+shortpath] = ibooker.
book1D(nameVtxPlot+
"_"+shortpath, titlePassingPu.c_str(), nBinsPu, minPu, maxPu);
358 std::string titlePassingHt =
"sum of jet pT in the event passing path " + shortpath;
362 _elements[nameGlobalEfficiency]->setBinLabel(
j+1,shortpath);
363 _elements[nameGlobalEfficiencyPassing]->setBinLabel(
j+1,shortpath);
376 std::map<unsigned int,std::string> u2str;
380 std::map<unsigned int,double> Htmap;
388 std::vector<PileupSummaryInfo>::const_iterator PVI;
389 for(PVI = puInfo->begin(); PVI != puInfo->end(); ++PVI) {
390 if(PVI->getBunchCrossing()==0){
391 nbMCvtx = PVI->getPU_NumInteractions();
402 std::vector<MatchStruct> *
matches =
new std::vector<MatchStruct>;
404 for(std::map<unsigned int,std::string>::iterator it =
_recLabels.begin();
419 for(
size_t i = 0;
i < cols->
genJets->size(); ++
i)
459 std::map<unsigned int,std::vector<MatchStruct> > sourceMatchMap;
468 std::map<std::string,bool> nMinOne;
469 std::map<std::string,bool> jetCutResult;
476 bool passAllCuts =
false;
489 this->
passJetCuts(matches, jetCutResult, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3);
493 for(std::map<unsigned int,std::string>::iterator it =
_recLabels.begin();
511 for(std::map<std::string,bool>::const_iterator it = jetCutResult.begin(); it != jetCutResult.end(); ++it)
513 nMinOne[it->first] =
true;
514 for(std::map<std::string,bool>::const_iterator it2 = jetCutResult.begin(); it2 != jetCutResult.end(); ++it2)
517 if( it->first==
"CSV1" && it2->first==
"CSV3")
continue;
518 if( it->first==
"CSV1" && it2->first==
"CSV2")
continue;
521 if( it->first==
"CSV2" && it2->first==
"CSV3")
continue;
523 if( it->first != it2->first && !(it2->second) ) {
524 nMinOne[it->first] =
false;
530 for(std::map<std::string,bool>::const_iterator it = nMinOne.begin(); it != nMinOne.end(); ++it)
532 if( temp && it->second ) {
536 if( it->second ) temp =
true;
552 for( reco::PFJetCollection::const_iterator iJet = recoJet->begin(); iJet != recoJet->end(); iJet++ ){
553 double pt = iJet->pt();
554 double eta = iJet->eta();
564 for( reco::GenJetCollection::const_iterator iJet = genJet->begin(); iJet != genJet->end(); iJet++ ){
565 double pt = iJet->pt();
566 double eta = iJet->eta();
576 for(
std::map<
unsigned int,std::vector<MatchStruct> >::iterator it = sourceMatchMap.begin();
577 it != sourceMatchMap.end(); ++it)
587 std::map<unsigned int,int> * countobjects =
new std::map<unsigned int,int>;
589 for(std::map<unsigned int,std::string>::iterator co =
_recLabels.begin();
593 countobjects->insert(std::pair<unsigned int,int>(co->first,0));
596 const int totalobjectssize2 =
NptPlots*countobjects->size();
597 for(
size_t j = 0;
j < it->second.size(); ++
j)
599 const unsigned int objType = it->second[
j].objType;
602 float pt = (it->second)[
j].pt;
603 float eta = (it->second)[
j].eta;
604 float phi = (it->second)[
j].phi;
612 if( (
unsigned)(*countobjects)[objType] <
NptPlots )
615 maxPt += (*countobjects)[objType]+1;
617 if( nMinOne[maxPt.Data()] )
619 this->
fillHist(u2str[it->first],objTypeStr,maxPt.Data(),
pt);
623 this->
fillHist(u2str[it->first],objTypeStr,maxPt.Data(),
pt);
626 ++((*countobjects)[objType]);
631 ++((*countobjects)[objType]);
640 this->
fillHist(u2str[it->first],objTypeStr,
"Eta",eta);
641 this->
fillHist(u2str[it->first],objTypeStr,
"Phi",phi);
645 this->
fillHist(u2str[it->first],objTypeStr,
"Eta",eta);
646 this->
fillHist(u2str[it->first],objTypeStr,
"Phi",phi);
650 if( counttotal == totalobjectssize2 )
692 for(std::vector<HLTHiggsPlotter>::iterator an =
_analyzers.begin();
696 const std::string fillShortPath = an->gethltpath();
700 an->analyze(ispassTrigger,source,it->second, nMinOne, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3, passAllCuts);
706 int refOfThePath = -1;
711 _elements[SummaryName]->Fill(refOfThePath);
713 _elements[SummaryName+
"_passingHLT"]->Fill(refOfThePath,1);
718 _elements[SummaryName+
"_passingHLT"]->Fill(refOfThePath,0);
728 static const unsigned int objSize = 7;
729 static const unsigned int objtriggernames[] = {
740 std::set<unsigned int> objsType;
742 for(
unsigned int i = 0;
i < objSize; ++
i)
746 if( ! TString(hltPath).Contains(objTypeStr) )
753 objsType.insert(objtriggernames[i]);
757 if( ( objtriggernames[i] ==
EVTColContainer::CALOMET && (TString(hltPath).Contains(
"PFMET") || TString(hltPath).Contains(
"MHT") ) ) ||
758 (objtriggernames[i] ==
EVTColContainer::PFJET && TString(hltPath).Contains(
"JetIdCleaned") && ! TString(hltPath).Contains(TRegexp(
"Jet[^I]"))) ||
764 objsType.insert(objtriggernames[i]);
767 return std::vector<unsigned int>(objsType.begin(),objsType.end());
774 if( anpset.
exists(
"recMuonLabel") )
780 if( anpset.
exists(
"recElecLabel") )
786 if( anpset.
exists(
"recPhotonLabel") )
792 if( anpset.
exists(
"recCaloMETLabel") )
798 if( anpset.
exists(
"recPFMETLabel") )
804 if( anpset.
exists(
"recPFTauLabel") )
810 if( anpset.
exists(
"recJetLabel") )
814 if( anpset.
exists(
"jetTagLabel") )
826 edm::LogError(
"HiggsValidation") <<
"HLTHiggsSubAnalysis::bookobjects, "
827 <<
"Not included any object (recMuonLabel, recElecLabel, ...) "
859 for(std::map<unsigned int,std::string>::iterator it =
_recLabels.begin();
913 edm::LogError(
"HiggsValidation") <<
"HLTHiggsSubAnalysis::initobjects "
914 <<
" NOT IMPLEMENTED (yet) ERROR: '" << it->second <<
"'";
924 sourceUpper[0] = std::toupper(sourceUpper[0]);
928 if(variable.find(
"MaxPt") != std::string::npos)
931 if (variable ==
"MaxPt1") desc =
"Leading";
932 else if (variable ==
"MaxPt2") desc =
"Next-to-Leading";
933 else desc = variable.substr(5,6) +
"th Leading";
936 size_t nBins = nBinsStandard;
937 float *
edges =
new float[nBinsStandard + 1];
938 for(
size_t i = 0;
i < nBinsStandard + 1;
i++)
944 if( objType == jetObj ) {
945 const size_t nBinsJets = 25;
948 edges =
new float[nBinsJets+1];
949 for(
size_t i = 0;
i < nBinsJets + 1;
i++)
955 const size_t nBinsJets = 30;
958 edges =
new float[nBinsJets+1];
959 for(
size_t i = 0;
i < nBinsJets + 1;
i++)
964 h =
new TH1F(name.c_str(), title.c_str(), nBins,
edges);
967 else if( variable ==
"dEtaqq" ){
972 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
974 else if ( variable ==
"mqq" ){
979 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
981 else if ( variable ==
"dPhibb" ){
986 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
988 else if ( variable ==
"CSV1" ){
993 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
995 else if ( variable ==
"CSV2" ){
1000 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
1002 else if ( variable ==
"CSV3" ){
1007 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
1009 else if ( variable ==
"maxCSV" ){
1014 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
1018 std::string symbol = (variable ==
"Eta") ?
"#eta" :
"#phi";
1022 int nBins = (int)params[0];
1023 double min = params[1];
1024 double max = params[2];
1025 h =
new TH1F(name.c_str(), title.c_str(), nBins,
min,
max);
1036 sourceUpper[0] = toupper(sourceUpper[0]);
1086 std::vector<MatchStruct> * matches)
1097 for(reco::PFJetCollection::const_iterator it = PFJetHandle->begin();
1098 it != PFJetHandle->end(); ++it)
1107 float bTag = (*(JetTagHandle.
product()))[jetBaseRef];
1117 void HLTHiggsSubAnalysis::passJetCuts(std::vector<MatchStruct> * matches, std::map<std::string,bool> & jetCutResult,
float & dEtaqq,
float & mqq,
float & dPhibb,
float & CSV1,
float & CSV2,
float & CSV3)
1127 if( (*matches)[
i].pt >
_NminOneCuts[9+
i] ) jetCutResult[maxPt.Data()] =
true;
1128 else jetCutResult[maxPt.Data()] =
false;
1132 if( matches->size() < NbTag ) NbTag = matches->size();
1137 dEtaqq = fabs((*matches)[2].
eta - (*matches)[3].
eta);
1138 if( dEtaqq >
_NminOneCuts[0] ) jetCutResult[
"dEtaqq"] =
true;
1139 else jetCutResult[
"dEtaqq"] =
false;
1143 mqq = ((*matches)[2].lorentzVector + (*matches)[3].lorentzVector).M();
1144 if( mqq >
_NminOneCuts[1] ) jetCutResult[
"mqq"] =
true;
1145 else jetCutResult[
"mqq"] =
false;
1149 dPhibb = fmod(fabs((*matches)[0].
phi - (*matches)[1].
phi),3.1416);
1150 if( dPhibb <
_NminOneCuts[2] ) jetCutResult[
"dPhibb"] =
true;
1151 else jetCutResult[
"dPhibb"] =
false;
1155 CSV2 = (*matches)[1].bTag;
1158 if( CSV2 >
_NminOneCuts[4] ) jetCutResult[nameCSV2plot] =
true;
1159 else jetCutResult[nameCSV2plot] =
false;
1163 CSV3 = (*matches)[2].bTag;
1166 if( CSV3 >
_NminOneCuts[5] ) jetCutResult[nameCSV3plot] =
true;
1167 else jetCutResult[nameCSV3plot] =
false;
1172 CSV1 = (*matches)[0].bTag;
1176 if( CSV1 >
_NminOneCuts[3] ) jetCutResult[nameCSVplot] =
true;
1177 else jetCutResult[nameCSVplot] =
false;
1182 CSV1 = (*matches)[0].bTag;
1184 if (
_NminOneCuts[6] > matches->size()) Njets = matches->size();
1185 for(
unsigned int i=1;
i < (
unsigned int) Njets ; ++
i) {
1186 if( (*matches)[
i].bTag > CSV1 && (*matches)[
i].pt >
_NminOneCuts[7] ) CSV1 = (*matches)[
i].bTag;
1194 jetCutResult[
"PFMET"] =
false;
1195 for(std::vector<MatchStruct>::const_iterator it = matches.begin(); it != matches.end(); ++it)
1198 if( it->pt >
_NminOneCuts[8] ) jetCutResult[
"PFMET"] =
true;
1206 std::vector<MatchStruct> * matches)
1210 for(
size_t i = 0;
i < cols->
muons->size();
i++)
1230 for(
size_t i = 0;
i < cols->
photons->size();
i++)
1240 for(
size_t i = 0;
i < cols->
caloMETs->size();
i++)
1250 for(
size_t i = 0;
i < cols->
pfMETs->size();
i++)
1260 for(
size_t i = 0;
i < cols->
pfTaus->size();
i++)
const std::vector< reco::Muon > * muons
std::vector< double > _parametersTurnOn
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void InitSelector(const unsigned int &objtype)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
std::map< std::string, std::string > _shortpath2long
Relation between the short version of a path.
StringCutObjectSelector< reco::CaloMET > * _recCaloMETSelector
std::vector< PFTau > PFTauCollection
collection of PFTau objects
edm::EDGetTokenT< reco::PFMETCollection > _recLabelsPFMET
edm::EDGetTokenT< reco::PFJetCollection > _recLabelsPFJet
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
edm::EDGetTokenT< reco::GenParticleCollection > _genParticleLabel
void passJetCuts(std::vector< MatchStruct > *matches, std::map< std::string, bool > &jetCutResult, float &dEtaqq, float &mqq, float &dPhibb, float &CSV1, float &CSV2, float &CSV3)
std::map< unsigned int, std::string > _genCut
gen/rec objects cuts
void initobjects(const edm::Event &iEvent, EVTColContainer *col)
edm::EDGetTokenT< reco::PFJetCollection > _recoHtJetLabel
const std::vector< reco::CaloMET > * caloMETs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< reco::PFTauCollection > _recLabelsPFTau
unsigned int _minCandidates
The minimum number of reco/gen candidates needed by the analysis.
std::map< std::string, MonitorElement * > _elements
std::vector< double > _NminOneCuts
bool accept() const
Has at least one path accepted the event?
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const std::vector< std::string > & triggerNames() const
names of trigger paths
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::set< std::string > _hltPaths
the hlt paths found in the hltConfig
const reco::GenParticleCollection * genParticles
container with all the objects needed
StringCutObjectSelector< reco::PFMET > * _recPFMETSelector
edm::EDGetTokenT< reco::GenJetCollection > _genJetLabel
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
HLTConfigProvider _hltConfig
edm::EDGetTokenT< reco::JetTagCollection > _recTagPFJet
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const std::vector< reco::PFTau > * pfTaus
std::vector< Muon > MuonCollection
collection of Muon objects
void bookHistograms(DQMStore::IBooker &)
std::vector< double > _parametersPu
edm::EDGetTokenT< reco::PhotonCollection > _recLabelsPhoton
edm::EDGetTokenT< reco::CaloMETCollection > _recLabelsCaloMET
StringCutObjectSelector< reco::Track > * _recTrackSelector
std::map< unsigned int, std::string > _recCut
void passOtherCuts(const std::vector< MatchStruct > &matches, std::map< std::string, bool > &jetCutResult)
std::map< unsigned int, StringCutObjectSelector< reco::GenParticle > * > _genSelectorMap
void set(const reco::MuonCollection *v)
Setter: multiple overloaded function.
const reco::GenJetCollection * genJets
unsigned int triggerIndex(std::string const &name) const
std::string _hltProcessName
StringCutObjectSelector< reco::GenJet > * _genJetSelector
void initAndInsertJets(const edm::Event &iEvent, EVTColContainer *cols, std::vector< MatchStruct > *matches)
void addParameter(std::string const &name, T const &value)
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > _puSummaryInfo
std::vector< HLTHiggsPlotter > _analyzers
MonitorElement * book1D(Args &&...args)
std::map< unsigned int, std::string > _recLabels
const std::vector< reco::Photon > * photons
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void analyze(const edm::Event &iEvent, const edm::EventSetup &iEventSetup, EVTColContainer *cols)
std::map< unsigned int, double > _cutMinPt
StringCutObjectSelector< reco::PFTau > * _recPFTauSelector
void beginRun(const edm::Run &iRun, const edm::EventSetup &iEventSetup)
edm::EDGetTokenT< edm::TriggerResults > _trigResultsTag
static const char *const trigNames[]
void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
void setCurrentFolder(const std::string &fullpath)
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
std::vector< double > _parametersHt
edm::EDGetTokenT< reco::GsfElectronCollection > _recLabelsElec
HLTHiggsSubAnalysis(const edm::ParameterSet &pset, const std::string &analysisname, edm::ConsumesCollector &&iC)
T const * product() const
StringCutObjectSelector< reco::Muon > * _recMuonSelector
std::string _histDirectory
void fillHist(const std::string &source, const std::string &objType, const std::string &variable, const float &value)
std::vector< Photon > PhotonCollection
collectin of Photon objects
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
const std::vector< reco::GsfElectron > * electrons
Helper structure to order MatchStruct.
const std::vector< unsigned int > getObjectsType(const std::string &hltpath) const
Extract what objects need this analysis.
void insertcandidates(const unsigned int &objtype, const EVTColContainer *col, std::vector< MatchStruct > *matches)
std::vector< PFJet > PFJetCollection
collection of PFJet objects
edm::EDGetTokenT< reco::MuonCollection > _recLabelsMuon
std::vector< double > _parametersPhi
std::string _analysisname
std::vector< std::string > _hltPathsToCheck
the hlt paths with regular expressions
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
std::vector< double > _parametersEta
Some kinematical parameters.
std::map< unsigned int, double > _cutMaxEta
void bookobjects(const edm::ParameterSet &anpset, edm::ConsumesCollector &iC)
StringCutObjectSelector< reco::Photon > * _recPhotonSelector
const std::vector< reco::PFMET > * pfMETs
StringCutObjectSelector< reco::PFJet > * _recPFJetSelector
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
const edm::TriggerResults * triggerResults
static std::string const source
StringCutObjectSelector< reco::GsfElectron > * _recElecSelector