22 #include <boost/algorithm/string.hpp> 23 #include <type_traits> 26 #include "DataFormats/Provenance/interface/Provenance.h" 28 #include "FWCore/Framework/interface/Frameworkfwd.h" 29 #include "FWCore/Framework/interface/EDAnalyzer.h" 31 #include "FWCore/Framework/interface/Event.h" 32 #include "FWCore/Framework/interface/MakerMacros.h" 34 #include "FWCore/ParameterSet/interface/ParameterSet.h" 36 #include "FWCore/ServiceRegistry/interface/Service.h" 37 #include "CommonTools/UtilAlgos/interface/TFileService.h" 39 #include "DataFormats/L1Trigger/interface/L1JetParticle.h" 40 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h" 42 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h" 43 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" 45 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h" 46 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h" 49 #include "DataFormats/JetReco/interface/CaloJet.h" 50 #include "DataFormats/JetReco/interface/CaloJetCollection.h" 52 #include "DataFormats/JetReco/interface/PFJet.h" 53 #include "DataFormats/JetReco/interface/PFJetCollection.h" 55 #include "DataFormats/MuonReco/interface/Muon.h" 56 #include "DataFormats/MuonReco/interface/MuonFwd.h" 58 #include "DataFormats/TrackReco/interface/Track.h" 59 #include "DataFormats/TrackReco/interface/TrackFwd.h" 62 #include "DataFormats/PatCandidates/interface/Jet.h" 63 #include "DataFormats/PatCandidates/interface/Muon.h" 64 #include "DataFormats/PatCandidates/interface/MET.h" 66 #include "DataFormats/L1Trigger/interface/Jet.h" 67 #include "DataFormats/L1Trigger/interface/Muon.h" 69 #include "DataFormats/PatCandidates/interface/TriggerObject.h" 71 #include "DataFormats/JetReco/interface/GenJet.h" 73 #include "DataFormats/HepMCCandidate/interface/GenParticle.h" 74 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" 79 #include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h" 87 #include "SimDataFormats/GeneratorProducts/interface/GenFilterInfo.h" 88 #include "DataFormats/Common/interface/MergeableCounter.h" 90 #include "DataFormats/Common/interface/OwnVector.h" 91 #include "DataFormats/Common/interface/TriggerResults.h" 92 #include "DataFormats/HLTReco/interface/TriggerEvent.h" 94 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" 95 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" 96 #include "DataFormats/Scalers/interface/LumiScalers.h" 105 #include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h" 107 using namespace boost;
175 explicit Ntuplizer(
const edm::ParameterSet&);
181 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
185 virtual void beginJob()
override;
186 virtual void analyze(
const edm::Event&,
const edm::EventSetup&)
override;
187 virtual void endJob()
override;
189 virtual void beginRun(edm::Run
const&, edm::EventSetup
const&)
override;
190 virtual void endRun(edm::Run
const&, edm::EventSetup
const&)
override;
191 virtual void beginLuminosityBlock(edm::LuminosityBlock
const&, edm::EventSetup
const&)
override;
192 virtual void endLuminosityBlock(edm::LuminosityBlock
const&, edm::EventSetup
const&)
override;
240 std::map<std::string, edm::EDGetTokenT<l1extra::L1JetParticleCollection> >
l1JetTokens_;
241 std::map<std::string, edm::EDGetTokenT<l1extra::L1MuonParticleCollection> >
l1MuonTokens_;
242 std::map<std::string, edm::EDGetTokenT<reco::CaloJetCollection> >
caloJetTokens_;
243 std::map<std::string, edm::EDGetTokenT<reco::PFJetCollection> >
pfJetTokens_;
249 std::map<std::string, edm::EDGetTokenT<reco::GenJetCollection> >
genJetTokens_;
250 std::map<std::string, edm::EDGetTokenT<reco::GenParticleCollection> >
genPartTokens_;
251 std::map<std::string, edm::EDGetTokenT<pat::TriggerObjectStandAloneCollection> >
triggerObjTokens_;
255 std::map<std::string, edm::EDGetTokenT<reco::JetTagCollection> >
jetTagTokens_;
256 std::map<std::string, edm::EDGetTokenT<l1t::JetBxCollection> >
l1tJetTokens_;
290 std::map<std::string, TTree*>
tree_;
346 is_mc_ = config.getParameter<
bool> (
"MonteCarlo");
347 readprescale_ =
true;
348 if ( config.exists(
"ReadPrescale") )
350 readprescale_ = config.getParameter<
bool> (
"ReadPrescale");
352 use_full_name_ =
false;
354 inputTagsVec_ = config.getParameterNamesForType<
InputTags>();
355 inputTags_ = config.getParameterNamesForType<edm::InputTag>();
358 for (
auto & inputTags : inputTagsVec_ )
361 for (
auto & collection : collections )
363 std::string label = collection.label();
364 std::string inst = collection.instance();
365 std::string proc = collection.process();
366 std::string collection_name = label+
"_"+inst+
"_"+proc;
367 if ( inputTags ==
"L1ExtraJets" ) l1JetTokens_[collection_name] = consumes<l1extra::L1JetParticleCollection>(collection);
368 if ( inputTags ==
"L1ExtraMuons" ) l1MuonTokens_[collection_name] = consumes<l1extra::L1MuonParticleCollection>(collection);
369 if ( inputTags ==
"CaloJets" ) caloJetTokens_[collection_name] = consumes<reco::CaloJetCollection>(collection);
370 if ( inputTags ==
"PFJets" ) pfJetTokens_[collection_name] = consumes<reco::PFJetCollection>(collection);
371 if ( inputTags ==
"RecoMuons" ) recoMuonTokens_[collection_name] = consumes<reco::MuonCollection>(collection);
372 if ( inputTags ==
"RecoTracks" ) recoTrackTokens_[collection_name] = consumes<reco::TrackCollection>(collection);
373 if ( inputTags ==
"PatJets" ) patJetTokens_[collection_name] = consumes<pat::JetCollection>(collection);
374 if ( inputTags ==
"PatMETs" ) patMETTokens_[collection_name] = consumes<pat::METCollection>(collection);
375 if ( inputTags ==
"PatMuons" ) patMuonTokens_[collection_name] = consumes<pat::MuonCollection>(collection);
376 if ( inputTags ==
"GenJets" ) genJetTokens_[collection_name] = consumes<reco::GenJetCollection>(collection);
377 if ( inputTags ==
"GenParticles" ) genPartTokens_[collection_name] = consumes<reco::GenParticleCollection>(collection);
378 if ( inputTags ==
"TriggerObjectStandAlone" ) triggerObjTokens_[collection_name] = consumes<pat::TriggerObjectStandAloneCollection>(collection);
379 if ( inputTags ==
"TriggerEvent" ) triggerEventTokens_[collection_name] = consumes<trigger::TriggerEvent>(collection);
380 if ( inputTags ==
"PrimaryVertices" ) primaryVertexTokens_[collection_name] = consumes<reco::VertexCollection>(collection);
381 if ( inputTags ==
"TriggerResults" ) triggerResultsTokens_[collection_name] = consumes<edm::TriggerResults>(collection);
382 if ( inputTags ==
"JetsTags" ) jetTagTokens_[collection_name] = consumes<reco::JetTagCollection>(collection);
383 if ( inputTags ==
"L1TJets" ) l1tJetTokens_[collection_name] = consumes<l1t::JetBxCollection>(collection);
384 if ( inputTags ==
"L1TMuons" ) l1tMuonTokens_[collection_name] = consumes<l1t::MuonBxCollection>(collection);
385 if ( inputTags ==
"ChargedCandidates" ) chargedCandTokens_[collection_name] = consumes<reco::RecoChargedCandidateCollection>(collection);
389 hltPrescaleProvider_ = std::shared_ptr<HLTPrescaleProvider>(
new HLTPrescaleProvider(config, consumesCollector(), *
this));;
392 for (
auto & inputTag : inputTags_ )
394 edm::InputTag collection = config_.getParameter<edm::InputTag>(inputTag);
396 if ( inputTag ==
"GenFilterInfo" ) { genFilterInfoToken_ = consumes<GenFilterInfo,edm::InLumi>(collection); genFilterInfo_ = collection;}
397 if ( inputTag ==
"TotalEvents" ) { totalEventsToken_ = consumes<edm::MergeableCounter,edm::InLumi>(collection); totalEvents_ = collection;}
398 if ( inputTag ==
"FilteredEvents" ) { filteredEventsToken_ = consumes<edm::MergeableCounter,edm::InLumi>(collection); filteredEvents_ = collection;}
399 if ( inputTag ==
"FilteredMHatEvents" ) { filteredMHatEventsToken_ = consumes<edm::MergeableCounter,edm::InLumi>(collection); filteredMHatEvents_ = collection;}
400 if ( inputTag ==
"GenRunInfo" ) { genRunInfoToken_ = consumes<GenRunInfoProduct,edm::InRun>(collection); genRunInfo_ = collection;}
402 if ( inputTag ==
"PileupInfo" ) { pileupInfoToken_ = consumes<std::vector<PileupSummaryInfo> >(collection); pileupInfo_ = collection;}
403 if ( inputTag ==
"GenEventInfo" ) { genEventInfoToken_ = consumes<GenEventInfoProduct>(collection); genEventInfo_ = collection;}
404 if ( inputTag ==
"LumiScalers" ) { lumiScalersToken_ = consumes<LumiScalersCollection>(collection); lumiScalers_ = collection;}
405 if ( inputTag ==
"FixedGridRhoAll" ){ fixedGridRhoAllToken_ = consumes<double>(collection); fixedGridRhoAll_ = collection;}
442 eventinfo_ -> Fill(event);
453 for (
auto & collection : l1jets_collections_ )
454 collection -> Fill(event);
457 for (
auto & collection : l1muons_collections_ )
458 collection -> Fill(event);
461 for (
auto & collection : calojets_collections_ )
462 collection -> Fill(event);
465 for (
auto & collection : pfjets_collections_ )
466 collection -> Fill(event);
469 for (
auto & collection : recomuons_collections_ )
470 collection -> Fill(event);
473 for (
auto & collection : recotracks_collections_ )
474 collection -> Fill(event);
477 for (
auto & collection : patjets_collections_ )
478 collection -> Fill(event, setup);
481 for (
auto & collection : patmets_collections_ )
482 collection -> Fill(event);
485 for (
auto & collection : patmuons_collections_ )
486 collection -> Fill(event);
489 for (
auto & collection : genjets_collections_ )
490 collection -> Fill(event);
493 for (
auto & collection : genparticles_collections_ )
494 collection -> Fill(event);
497 for (
auto & collection : jetstags_collections_ )
498 collection -> Fill(event);
502 for (
auto & collection : triggeraccepts_collections_ )
503 collection -> Fill(event, setup);
510 for (
auto & collection : primaryvertices_collections_ )
511 collection -> Fill(event);
514 for (
auto & collection : triggerobjects_collections_ )
515 collection -> Fill(event);
517 for (
auto & collection : triggerobjectsreco_collections_ )
518 collection -> Fill(event);
521 for (
auto & collection : l1tjets_collections_ )
522 collection -> Fill(event);
524 for (
auto & collection : l1tmuons_collections_ )
525 collection -> Fill(event);
528 for (
auto & collection : chargedcands_collections_ )
529 collection -> Fill(event);
539 do_pileupinfo_ = config_.exists(
"PileupInfo") && is_mc_;
540 do_geneventinfo_ = config_.exists(
"GenEventInfo") && is_mc_;
541 do_lumiscalers_ = config_.exists(
"LumiScalers");
542 do_l1jets_ = config_.exists(
"L1ExtraJets");
543 do_l1muons_ = config_.exists(
"L1ExtraMuons");
544 do_calojets_ = config_.exists(
"CaloJets");
545 do_pfjets_ = config_.exists(
"PFJets");
546 do_recomuons_ = config_.exists(
"RecoMuons");
547 do_recotracks_ = config_.exists(
"RecoTracks");
548 do_patjets_ = config_.exists(
"PatJets");
549 do_patmets_ = config_.exists(
"PatMETs");
550 do_patmuons_ = config_.exists(
"PatMuons");
551 do_genjets_ = config_.exists(
"GenJets");
552 do_genparticles_ = config_.exists(
"GenParticles");
553 do_jetstags_ = config_.exists(
"JetsTags");
555 do_triggeraccepts_ = config_.exists(
"TriggerResults");
557 do_primaryvertices_ = config_.exists(
"PrimaryVertices");
559 do_eventfilter_ = config_.exists(
"TotalEvents") && config_.exists(
"FilteredEvents");
560 do_genfilter_ = config_.exists(
"GenFilterInfo");
561 do_triggerobjects_ = ( config_.exists(
"TriggerObjectStandAlone") || config_.exists(
"TriggerEvent") ) && config_.exists(
"TriggerObjectLabels");
562 do_genruninfo_ = config_.exists(
"GenRunInfo") && is_mc_ ;
563 do_l1tjets_ = config_.exists(
"L1TJets");
564 do_l1tmuons_ = config_.exists(
"L1TMuons");
565 do_chargedcands_ = config_.exists(
"ChargedCandidates");
567 if ( config_.exists(
"TestMode") )
568 testmode_ = config_.getParameter<
bool> (
"TestMode");
570 if ( config_.exists(
"UseFullName") )
571 use_full_name_ = config_.getParameter<
bool> (
"UseFullName");
574 edm::Service<TFileService> fs;
576 TFileDirectory eventsDir = fs -> mkdir(
"Events");
579 std::string fullname;
581 genFilterResults_ = {};
582 eventFilterResults_ = {};
587 btagAlgosAlias_.clear();
588 btagAlgos_.push_back(
"pfCombinedInclusiveSecondaryVertexV2BJetTags");
589 btagAlgosAlias_.push_back(
"btag_csvivf");
590 if ( config_.exists(
"BTagAlgorithmsAlias") )
592 btagAlgosAlias_.clear();
593 btagAlgosAlias_ = config_.getParameter< std::vector<std::string> >(
"BTagAlgorithmsAlias");
595 if ( config_.exists(
"BTagAlgorithms") )
598 btagAlgos_ = config_.getParameter< std::vector<std::string> >(
"BTagAlgorithms");
600 if ( btagAlgos_.size() != btagAlgosAlias_.size() )
603 btagAlgosAlias_.clear();
604 for (
auto& it : btagAlgos_ )
605 btagAlgosAlias_.push_back(it);
609 for (
size_t it = 0 ; it < btagAlgos_.size() ; ++it )
611 btagVars_.push_back({btagAlgos_[it],btagAlgosAlias_[it]});
616 std::vector<std::string > jec_files;
619 if ( do_patjets_ && config_.exists(
"JECRecords") )
621 jecRecords_ = config_.getParameter< std::vector<std::string> >(
"JECRecords");
622 if(config_.exists(
"JECUncertaintyFiles"))
624 jec_files = config_.getParameter< std::vector<std::string > >(
"JECUncertaintyFiles");
628 std::vector<std::string > jer_files;
629 std::vector<std::string > jersf_files;
632 if ( do_patjets_ && config_.exists(
"JERRecords") )
634 jerRecords_ = config_.getParameter< std::vector<std::string> >(
"JERRecords");
635 if(config_.exists(
"JERResFiles"))
637 jer_files = config_.getParameter< std::vector<std::string > >(
"JERResFiles");
639 if(config_.exists(
"JERSfFiles"))
641 jersf_files = config_.getParameter< std::vector<std::string > >(
"JERSfFiles");
648 nPatJets = config_.getParameter<
InputTags>(
"PatJets").size();
650 if ( nPatJets > jecRecords_.size() && jecRecords_.size() != 0 )
652 std::cout <<
"*** ERROR *** Ntuplizer: Number of JEC Records less than the number of PatJet collections." << std::endl;;
655 if ( nPatJets > jerRecords_.size() && jerRecords_.size() != 0 )
657 std::cout <<
"*** ERROR *** Ntuplizer: Number of JER Records less than the number of PatJet collections." << std::endl;;
660 if ( jerRecords_.size() != 0 && jer_files.size() != 0 && jersf_files.size()!=0 &&(jerRecords_.size() != jer_files.size() || jerRecords_.size() != jersf_files.size()) )
662 std::cerr <<
"*** ERROR *** Ntuplizer: Number of JER Records are not the same as number of provided input files. " <<std::endl;
669 if ( config_.exists(
"FixedGridRhoAll") )
671 eventinfo_ -> FixedGridRhoInfo(config_.getParameter<edm::InputTag>(
"FixedGridRhoAll"));
673 if ( do_pileupinfo_ )
674 eventinfo_ ->
PileupInfo(config_.getParameter<edm::InputTag>(
"PileupInfo"));
675 if ( do_geneventinfo_ )
676 eventinfo_ ->
GenEventInfo(config_.getParameter<edm::InputTag>(
"GenEventInfo"));
677 if ( do_lumiscalers_ )
678 eventinfo_ -> LumiScalersInfo(config_.getParameter<edm::InputTag>(
"LumiScalers"));
682 metadata_ -> AddDefinitions(btagVars_,
"btagging");
685 if ( config_.exists(
"CrossSection") )
686 xsection_ = config_.getParameter<
double>(
"CrossSection");
688 edm::InputTag trgRes;
689 if ( do_triggeraccepts_ )
696 bool splitTriggerObject = config_.exists(
"TriggerObjectSplits");
697 if ( do_triggerobjects_ && triggerObjectSplits_.empty() && splitTriggerObject )
699 triggerObjectSplits_ = config_.getParameter< std::vector<std::string> >(
"TriggerObjectSplits");
700 if ( ! triggerObjectSplits_.empty() && triggerObjectSplitsTypes_.empty() && config_.exists(
"TriggerObjectSplitsTypes") )
702 triggerObjectSplitsTypes_ = config_.getParameter< std::vector<std::string> >(
"TriggerObjectSplitsTypes");
703 for (
auto & tot : triggerObjectSplitsTypes_ ) std::transform(tot.begin(), tot.end(), tot.begin(), ::tolower);
704 splitTriggerObject = !triggerObjectSplitsTypes_.empty();
708 if ( triggerObjectSplits_.size() != triggerObjectSplitsTypes_.size() )
710 std::cout <<
"-w- Ntuplizer: Size of trigger splits and splits types do not match!" << std::endl;
711 std::cout <<
" No splitting will be done" << std::endl;
712 splitTriggerObject =
false;
725 for (
auto & inputTags : inputTagsVec_ )
728 int patJetCounter = 0;
729 for (
auto & collection : collections )
732 std::string label = collection.label();
733 std::string inst = collection.instance();
734 std::string proc = collection.process();
736 if ( find_first(inputTags,
"L1Extra") )
739 std::string l1obj = inputTags;
740 erase_first(l1obj,
"L1Extra");
743 fullname = name +
"_" + inst +
"_" + proc;
744 name += inputTags ==
"L1ExtraJets" && ! use_full_name_ ?
"_" + inst :
"";
745 if ( collection.instance() !=
"" && collections.size() > 1 )
747 if ( use_full_name_ ) name = fullname;
748 if ( inputTags ==
"L1TJets" && l1tjets_collections_.size() == 0 ) name =
"l1tJets";
749 if ( inputTags ==
"L1TMuons" && l1tmuons_collections_.size() == 0 ) name =
"l1tMuons";
752 if ( inputTags !=
"TriggerObjectStandAlone" && inputTags !=
"TriggerEvent" )
753 tree_[
name] = eventsDir.make<TTree>(name.c_str(),fullname.c_str());
756 if ( inputTags ==
"L1ExtraJets" )
759 l1jets_collections_.back() -> Init();
763 if ( inputTags ==
"L1ExtraMuons" )
766 l1muons_collections_.back() -> Init();
770 if ( inputTags ==
"CaloJets" )
773 calojets_collections_.back() -> Init();
776 if ( inputTags ==
"PFJets" )
779 pfjets_collections_.back() -> Init();
782 if ( inputTags ==
"RecoMuons" )
785 recomuons_collections_.back() -> Init();
788 if ( inputTags ==
"RecoTracks" )
791 recotracks_collections_.back() -> Init();
795 if ( inputTags ==
"PatJets" )
798 patjets_collections_.back() -> Init(btagVars_);
799 patjets_collections_.back() -> QGTaggerInstance(
"QGTagger");
800 patjets_collections_.back() -> PileupJetIdInstance(
"pileupJetId");
802 if ( patJetCounter == 0 && jecRecords_.size() > 0 ) std::cout <<
"*** Jet Energy Corrections Records - PatJets ***" << std::endl;
803 if ( jecRecords_.size() > 0 )
805 if ( jec_files.size() > 0 && jec_files[patJetCounter] !=
"" )
806 patjets_collections_.back() -> AddJecInfo(jecRecords_[patJetCounter],jec_files[patJetCounter]);
808 patjets_collections_.back() -> AddJecInfo(jecRecords_[patJetCounter]);
812 if ( patJetCounter == 0 && jerRecords_.size() > 0 ) std::cout <<
"*** Jet Energy Resolutions Records - PatJets ***" << std::endl;
813 if ( jerRecords_.size() > 0 && is_mc_ )
815 if ( jer_files.size() > 0 && jer_files[patJetCounter] !=
"" )
816 patjets_collections_.back() -> AddJerInfo(jerRecords_[patJetCounter],jer_files[patJetCounter], jersf_files[patJetCounter],fixedGridRhoAll_);
818 patjets_collections_.back() -> AddJerInfo(jerRecords_[patJetCounter],fixedGridRhoAll_);
841 if ( inputTags ==
"PatMETs" )
844 patmets_collections_.back() -> Init();
847 if ( inputTags ==
"PatMuons" )
850 patmuons_collections_.back() -> Init();
853 if ( inputTags ==
"GenJets" )
856 genjets_collections_.back() -> Init();
859 if ( inputTags ==
"GenParticles" )
862 genparticles_collections_.back() -> Init();
865 if ( inputTags ==
"JetsTags" )
867 jetstags_collections_.push_back(
pJetsTags(
new JetsTags(collection, tree_[name]) ));
868 jetstags_collections_.back() -> Branches();
872 if ( inputTags ==
"L1TJets" )
874 if ( l1tjets_collections_.size() == 0 )
877 l1tjets_collections_.back() -> Init();
881 std::cout <<
"Ntuplizer: # l1 jet collections > 1. Skipping." << std::endl;
886 if ( inputTags ==
"L1TMuons" )
888 if ( l1tmuons_collections_.size() == 0 )
891 l1tmuons_collections_.back() -> Init();
895 std::cout <<
"Ntuplizer: # l1 muon collections > 1. Skipping." << std::endl;
899 if ( inputTags ==
"ChargedCandidates" )
902 chargedcands_collections_.back() -> Init();
906 if ( do_triggeraccepts_ && do_triggerobjects_ && inputTags ==
"TriggerObjectStandAlone" )
908 if ( triggerObjectLabels_.empty() )
909 triggerObjectLabels_ = config_.getParameter< std::vector<std::string> >(
"TriggerObjectLabels");
910 sort( triggerObjectLabels_.begin(), triggerObjectLabels_.end() );
911 triggerObjectLabels_.erase( unique( triggerObjectLabels_.begin(), triggerObjectLabels_.end() ), triggerObjectLabels_.end() );
912 std::string dir =
name;
913 TFileDirectory triggerObjectsDir = eventsDir.mkdir(dir);
915 for (
auto & triggerObjectLabel : triggerObjectLabels_ )
917 name = triggerObjectLabel;
918 if ( use_full_name_ ) name +=
"_" + dir;
919 tree_[
name] = triggerObjectsDir.make<TTree>(name.c_str(),name.c_str());
921 triggerobjects_collections_.back() -> Init();
922 triggerobjects_collections_.back() -> UseTriggerResults(trgRes);
923 if ( splitTriggerObject )
925 std::vector<std::string> types;
926 for (
size_t tos = 0; tos < triggerObjectSplits_.size() ; ++tos )
928 if ( triggerObjectSplits_.at(tos) ==
name )
930 boost::split(types,triggerObjectSplitsTypes_.at(tos),boost::is_any_of(
":"));
934 sort( types.begin(), types.end() );
935 types.erase( unique( types.begin(), types.end() ), types.end() );
936 for (
auto & tot : types )
938 std::string namesplit = name +
"_" + tot;
939 tree_[namesplit] = triggerObjectsDir.make<TTree>(namesplit.c_str(),namesplit.c_str());
941 triggerobjects_collections_.back() -> Init();
942 triggerobjects_collections_.back() -> UseTriggerResults(trgRes);
943 triggerobjects_collections_.back() -> TriggerObjectType(tot);
951 if ( do_triggerobjects_ && inputTags ==
"TriggerEvent" )
953 if ( triggerObjectLabels_.empty() )
954 triggerObjectLabels_ = config_.getParameter< std::vector<std::string> >(
"TriggerObjectLabels");
955 sort( triggerObjectLabels_.begin(), triggerObjectLabels_.end() );
956 triggerObjectLabels_.erase( unique( triggerObjectLabels_.begin(), triggerObjectLabels_.end() ), triggerObjectLabels_.end() );
957 std::string dir =
name;
958 TFileDirectory triggerObjectsDir = eventsDir.mkdir(dir);
960 for (
auto & triggerObjectLabel : triggerObjectLabels_ )
962 name = triggerObjectLabel;
963 if ( use_full_name_ ) name +=
"_" + dir;
964 tree_[
name] = triggerObjectsDir.make<TTree>(name.c_str(),name.c_str());
966 triggerobjectsreco_collections_.back() -> Init();
971 if ( do_triggeraccepts_ && inputTags ==
"TriggerResults" )
974 std::vector< std::string> triggerpaths;
975 triggerpaths.clear();
976 std::vector< std::string> l1seeds;
979 if ( config_.exists(
"TriggerPaths") ) triggerpaths = config_.getParameter< std::vector< std::string> >(
"TriggerPaths");
980 if ( config_.exists(
"L1Seeds") ) l1seeds = config_.getParameter< std::vector< std::string> >(
"L1Seeds");
982 triggeraccepts_collections_.push_back(
pTriggerAccepts(
new TriggerAccepts(collection, tree_[name], triggerpaths, l1seeds, hltPrescaleProvider_) ));
983 triggeraccepts_collections_.back() -> Init();
984 triggeraccepts_collections_.back() -> ReadPrescaleInfo(readprescale_);
1006 if ( inputTags ==
"PrimaryVertices" )
1018 int nMHatCounters = 0;
1019 for (
auto & inputTag : inputTags_ )
1021 edm::InputTag collection = config_.getParameter<edm::InputTag>(inputTag);
1024 std::string label = collection.label();
1025 std::string inst = collection.instance();
1026 std::string proc = collection.process();
1028 fullname = name +
"_" + inst +
"_" + proc;
1029 if ( use_full_name_ ) name = fullname;
1032 if ( do_genfilter_ && inputTag ==
"GenFilterInfo" && is_mc_ )
1034 metadata_ -> SetGeneratorFilter(config_.getParameter<edm::InputTag> (
"GenFilterInfo"));
1037 if ( do_eventfilter_ )
1039 eventCounters_.resize(2);
1040 mHatEventCounters_.resize(2);
1041 if ( inputTag ==
"TotalEvents" ) { eventCounters_[0] = totalEvents_; mHatEventCounters_[0] = totalEvents_; ++nCounters; ++nMHatCounters; }
1042 if ( inputTag ==
"FilteredEvents" ) { eventCounters_[1] = filteredEvents_; ++nCounters; }
1043 if ( inputTag ==
"FilteredMHatEvents" ) { mHatEventCounters_[1] = filteredMHatEvents_; ++nMHatCounters; }
1045 if ( nCounters == 2 ) metadata_ -> SetEventFilter(eventCounters_);
1046 if ( nMHatCounters == 2) metadata_ -> SetMHatEventFilter(mHatEventCounters_);
1069 metadata_ -> Fill();
1076 if ( do_triggeraccepts_ )
1078 for (
size_t i = 0; i < triggeraccepts_collections_.size() ; ++i )
1080 triggeraccepts_collections_[i] -> Run(run,setup);
1092 if ( do_genruninfo_ )
1094 metadata_ -> SetCrossSections(run,genRunInfo_,
xsection_);
1118 metadata_ -> IncrementEventFilters(lumi);
1127 edm::ParameterSetDescription desc;
1129 descriptions.addDefault(desc);
std::unique_ptr< Metadata > pMetadata
std::vector< pL1TJetCandidates > l1tjets_collections_
std::unique_ptr< EventInfo > pEventInfo
std::map< std::string, edm::EDGetTokenT< reco::GenParticleCollection > > genPartTokens_
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< std::string > inputTags_
analysis::ntuple::PileupInfo PileupInfo
std::vector< pTriggerObjectCandidates > triggerobjects_collections_
std::vector< std::string > triggerObjectLabels_
std::unique_ptr< L1JetCandidates > pL1JetCandidates
analysis::ntuple::Metadata Metadata
std::unique_ptr< ChargedCandidates > pChargedCandidates
std::vector< pL1JetCandidates > l1jets_collections_
analysis::ntuple::Candidates< trigger::TriggerObject > TriggerObjectRecoCandidates
std::unique_ptr< PatJetCandidates > pPatJetCandidates
edm::EDGetTokenT< edm::MergeableCounter > filteredEventsToken_
analysis::ntuple::FilterResults genFilterResults_
std::vector< pL1MuonCandidates > l1muons_collections_
edm::InputTag genRunInfo_
std::unique_ptr< Definitions > pDefinitions
std::unique_ptr< PatMETCandidates > pPatMETCandidates
std::vector< pPFJetCandidates > pfjets_collections_
analysis::ntuple::JetsTags JetsTags
virtual void beginJob() override
std::unique_ptr< GenParticleCandidates > pGenParticleCandidates
std::vector< TitleAlias > btagVars_
std::shared_ptr< HLTPrescaleProvider > hltPrescaleProvider_
std::unique_ptr< JetsTags > pJetsTags
analysis::ntuple::Candidates< l1extra::L1MuonParticle > L1MuonCandidates
std::unique_ptr< L1TJetCandidates > pL1TJetCandidates
std::vector< std::string > triggerObjectSplitsTypes_
std::vector< std::string > triggerObjectSplits_
analysis::ntuple::Definitions Definitions
std::vector< std::string > btagAlgos_
std::map< std::string, edm::EDGetTokenT< pat::TriggerObjectStandAloneCollection > > triggerObjTokens_
std::map< std::string, edm::EDGetTokenT< edm::TriggerResults > > triggerResultsTokens_
std::vector< pPatJetCandidates > patjets_collections_
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
std::map< std::string, edm::EDGetTokenT< reco::PFJetCollection > > pfJetTokens_
std::map< std::string, edm::EDGetTokenT< reco::CaloJetCollection > > caloJetTokens_
analysis::ntuple::TitleAlias TitleAlias
std::vector< pPatMETCandidates > patmets_collections_
std::map< std::string, edm::EDGetTokenT< pat::METCollection > > patMETTokens_
edm::InputTag genEventInfo_
InputTags mHatEventCounters_
std::unique_ptr< TriggerObjectCandidates > pTriggerObjectCandidates
std::vector< std::string > jecRecords_
std::map< std::string, edm::EDGetTokenT< l1extra::L1JetParticleCollection > > l1JetTokens_
std::vector< std::string > strings
edm::EDGetTokenT< edm::MergeableCounter > totalEventsToken_
std::map< std::string, edm::EDGetTokenT< l1t::JetBxCollection > > l1tJetTokens_
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
analysis::ntuple::TriggerAccepts TriggerAccepts
std::map< std::string, edm::EDGetTokenT< reco::RecoChargedCandidateCollection > > chargedCandTokens_
std::unique_ptr< RecoTrackCandidates > pRecoTrackCandidates
std::vector< std::string > jerRecords_
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
std::unique_ptr< RecoMuonCandidates > pRecoMuonCandidates
edm::InputTag genFilterInfo_
std::vector< std::string > btagAlgosAlias_
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupInfoToken_
std::vector< pCaloJetCandidates > calojets_collections_
analysis::ntuple::Candidates< pat::Jet > PatJetCandidates
analysis::ntuple::Candidates< reco::GenParticle > GenParticleCandidates
std::unique_ptr< L1TMuonCandidates > pL1TMuonCandidates
edm::EDGetTokenT< edm::MergeableCounter > filteredMHatEventsToken_
edm::InputTag totalEvents_
analysis::ntuple::Candidates< reco::Muon > RecoMuonCandidates
analysis::ntuple::Candidates< reco::PFJet > PFJetCandidates
analysis::ntuple::FilterResults eventFilterResults_
std::vector< pTriggerObjectRecoCandidates > triggerobjectsreco_collections_
analysis::ntuple::Candidates< l1t::Muon > L1TMuonCandidates
Ntuplizer(const edm::ParameterSet &)
std::unique_ptr< PrimaryVertices > pPrimaryVertices
analysis::ntuple::Candidates< l1extra::L1JetParticle > L1JetCandidates
std::unique_ptr< GenJetCandidates > pGenJetCandidates
virtual void endJob() override
edm::InputTag lumiScalers_
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoToken_
std::vector< pRecoTrackCandidates > recotracks_collections_
analysis::ntuple::TitleIndex TitleIndex
std::vector< pChargedCandidates > chargedcands_collections_
edm::InputTag filteredEvents_
analysis::ntuple::Candidates< l1t::Jet > L1TJetCandidates
edm::EDGetTokenT< double > fixedGridRhoAllToken_
edm::ParameterSet config_
edm::InputTag fixedGridRhoAll_
edm::InputTag pileupInfo_
analysis::ntuple::Candidates< reco::CaloJet > CaloJetCandidates
std::vector< pL1TMuonCandidates > l1tmuons_collections_
std::map< std::string, TTree * > tree_
std::unique_ptr< CaloJetCandidates > pCaloJetCandidates
std::vector< std::string > inputTagsVec_
analysis::ntuple::Candidates< reco::RecoChargedCandidate > ChargedCandidates
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
std::map< std::string, edm::EDGetTokenT< reco::TrackCollection > > recoTrackTokens_
std::unique_ptr< PFJetCandidates > pPFJetCandidates
std::vector< pRecoMuonCandidates > recomuons_collections_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Member function.
std::map< std::string, edm::EDGetTokenT< pat::MuonCollection > > patMuonTokens_
edm::EDGetTokenT< GenRunInfoProduct > genRunInfoToken_
std::map< std::string, edm::EDGetTokenT< trigger::TriggerEvent > > triggerEventTokens_
std::map< std::string, edm::EDGetTokenT< l1extra::L1MuonParticleCollection > > l1MuonTokens_
std::vector< pPatMuonCandidates > patmuons_collections_
std::unique_ptr< PileupInfo > pPileupInfo
std::map< std::string, edm::EDGetTokenT< l1t::MuonBxCollection > > l1tMuonTokens_
std::map< std::string, edm::EDGetTokenT< reco::VertexCollection > > primaryVertexTokens_
std::unique_ptr< L1MuonCandidates > pL1MuonCandidates
edm::InputTag filteredMHatEvents_
analysis::ntuple::Candidates< reco::Track > RecoTrackCandidates
std::unique_ptr< TriggerAccepts > pTriggerAccepts
std::vector< pGenJetCandidates > genjets_collections_
edm::EDGetTokenT< GenFilterInfo > genFilterInfoToken_
std::vector< pTriggerAccepts > triggeraccepts_collections_
std::vector< pPrimaryVertices > primaryvertices_collections_
std::vector< edm::InputTag > InputTags
std::map< std::string, edm::EDGetTokenT< reco::MuonCollection > > recoMuonTokens_
analysis::ntuple::Candidates< pat::MET > PatMETCandidates
std::unique_ptr< PatMuonCandidates > pPatMuonCandidates
analysis::ntuple::EventInfo EventInfo
std::map< std::string, edm::EDGetTokenT< reco::GenJetCollection > > genJetTokens_
analysis::ntuple::Candidates< pat::Muon > PatMuonCandidates
std::unique_ptr< TriggerObjectRecoCandidates > pTriggerObjectRecoCandidates
std::map< std::string, edm::EDGetTokenT< pat::JetCollection > > patJetTokens_
analysis::ntuple::Candidates< reco::GenJet > GenJetCandidates
std::vector< pJetsTags > jetstags_collections_
DEFINE_FWK_MODULE(Ntuplizer)
std::vector< pGenParticleCandidates > genparticles_collections_
analysis::ntuple::Vertices PrimaryVertices
std::map< std::string, edm::EDGetTokenT< reco::JetTagCollection > > jetTagTokens_
analysis::ntuple::Candidates< pat::TriggerObject > TriggerObjectCandidates