36 using namespace trigger;
40 LogDebug(
"BTVHLTOfflineSource") <<
"constructor....";
47 triggerSummaryToken = consumes <trigger::TriggerEvent> (triggerSummaryLabel_);
48 triggerResultsToken = consumes <edm::TriggerResults> (triggerResultsLabel_);
49 triggerSummaryFUToken = consumes <trigger::TriggerEvent> (
edm::InputTag(triggerSummaryLabel_.label(),triggerSummaryLabel_.instance(),
std::string(
"FU")));
51 csvCaloTagsToken_ = consumes<reco::JetTagCollection> (
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsCalo"));
52 csvPfTagsToken_ = consumes<reco::JetTagCollection> (
edm::InputTag(
"hltCombinedSecondaryVertexBJetTagsPF"));
60 std::vector<edm::ParameterSet>
paths = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"pathPairs");
61 for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
62 custompathnamepairs_.push_back(make_pair(
75 if (!hltConfig_.init(run, c, processname_, changed)) {
76 LogDebug(
"BTVHLTOfflineSource") <<
"HLTConfigProvider failed to initialize.";
79 const unsigned int numberOfPaths(hltConfig_.size());
80 for(
unsigned int i=0;
i!=numberOfPaths; ++
i){
81 pathname_ = hltConfig_.triggerName(
i);
82 filtername_ =
"dummy";
83 unsigned int usedPrescale = 1;
84 unsigned int objectType = 0;
86 bool trigSelected =
false;
88 for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin();
89 custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair){
90 if(pathname_.find(custompathnamepair->first)!=std::string::npos) { trigSelected =
true; triggerType = custompathnamepair->second;}
93 if (!trigSelected)
continue;
95 hltPathsAll_.push_back(
PathInfo(usedPrescale, pathname_,
"dummy", processname_, objectType, triggerType));
104 iEvent.
getByToken(triggerResultsToken, triggerResults_);
105 if(!triggerResults_.isValid()) {
106 iEvent.
getByToken(triggerResultsFUToken,triggerResults_);
107 if(!triggerResults_.isValid()) {
108 edm::LogInfo(
"BTVHLTOfflineSource") <<
"TriggerResults not found, "
116 iEvent.
getByToken(triggerSummaryToken,triggerObj_);
117 if(!triggerObj_.isValid()) {
118 iEvent.
getByToken(triggerSummaryFUToken,triggerObj_);
119 if(!triggerObj_.isValid()) {
120 edm::LogInfo(
"BTVHLTOfflineSource") <<
"TriggerEvent not found, "
126 iEvent.
getByToken(csvCaloTagsToken_, csvCaloTags);
127 iEvent.
getByToken(csvPfTagsToken_, csvPfTags);
132 iEvent.
getByToken(offlineCSVTokenPF_, offlineJetTagHandlerPF);
135 iEvent.
getByToken(offlineCSVTokenCalo_, offlineJetTagHandlerCalo);
138 iEvent.
getByToken(offlinePVToken_, offlineVertexHandler);
140 if(verbose_ && iEvent.
id().
event()%10000==0)
143 if(!triggerResults_.isValid())
return;
145 for(PathInfoCollection::iterator
v = hltPathsAll_.begin();
v!= hltPathsAll_.end(); ++
v ){
146 unsigned index = triggerNames_.triggerIndex(
v->getPath());
147 if (index < triggerNames_.size() ){
149 if (csvPfTags.isValid() &&
v->getTriggerType() ==
"PF")
151 auto iter = csvPfTags->begin();
153 float CSV_online =
iter->second;
154 if (CSV_online<0) CSV_online = -0.05;
156 v->getMEhisto_CSV()->Fill(CSV_online);
157 v->getMEhisto_Pt()->Fill(
iter->first->pt());
158 v->getMEhisto_Eta()->Fill(
iter->first->eta());
161 if(offlineJetTagHandlerPF.
isValid()){
163 float CSV_offline = iterO->second;
164 if (CSV_offline<0) CSV_offline = -0.05;
165 DR =
reco::deltaR(iterO->first->eta(),iterO->first->phi(),
iter->first->eta(),
iter->first->phi());
167 v->getMEhisto_CSV_RECOvsHLT()->Fill(CSV_offline,CSV_online);
continue;
172 iEvent.
getByToken(hltPFPVToken_, VertexHandler);
175 v->getMEhisto_PVz()->Fill(VertexHandler->begin()->z());
176 if (offlineVertexHandler.
isValid())
v->getMEhisto_PVz_HLTMinusRECO()->Fill(VertexHandler->begin()->z()-offlineVertexHandler->begin()->z());
180 if (csvCaloTags.isValid() &&
v->getTriggerType() ==
"Calo")
182 auto iter = csvCaloTags->begin();
184 float CSV_online =
iter->second;
185 if (CSV_online<0) CSV_online = -0.05;
187 v->getMEhisto_CSV()->Fill(CSV_online);
188 v->getMEhisto_Pt()->Fill(
iter->first->pt());
189 v->getMEhisto_Eta()->Fill(
iter->first->eta());
192 if(offlineJetTagHandlerCalo.
isValid()){
195 float CSV_offline = iterO->second;
196 if (CSV_offline<0) CSV_offline = -0.05;
197 DR =
reco::deltaR(iterO->first->eta(),iterO->first->phi(),
iter->first->eta(),
iter->first->phi());
200 v->getMEhisto_CSV_RECOvsHLT()->Fill(CSV_offline,CSV_online);
continue;
205 iEvent.
getByToken(hltFastPVToken_, VertexHandler);
208 v->getMEhisto_PVz()->Fill(VertexHandler->begin()->z());
209 if (offlineVertexHandler.
isValid())
v->getMEhisto_fastPVz_HLTMinusRECO()->Fill(VertexHandler->begin()->z()-offlineVertexHandler->begin()->z());
212 iEvent.
getByToken(hltCaloPVToken_, VertexHandler);
215 v->getMEhisto_fastPVz()->Fill(VertexHandler->begin()->z());
216 if (offlineVertexHandler.
isValid())
v->getMEhisto_PVz_HLTMinusRECO()->Fill(VertexHandler->begin()->z()-offlineVertexHandler->begin()->z());
231 for(PathInfoCollection::iterator
v = hltPathsAll_.begin();
v!= hltPathsAll_.end(); ++
v ){
234 std::string subdirName = dirname_ +
"/"+ trgPathName;
242 histoname = labelname+
"_CSV";
243 title = labelname+
"_CSV "+trigPath;
246 histoname = labelname+
"_Pt";
247 title = labelname+
"_Pt "+trigPath;
250 histoname = labelname+
"_Eta";
251 title = labelname+
"_Eta "+trigPath;
254 histoname =
"RECOvsHLT_CSV";
255 title =
"offline CSV vs online CSV "+trigPath;
256 MonitorElement * CSV_RECOvsHLT = iBooker.
book2D(histoname.c_str(),title.c_str(),110,-0.1,1,110,-0.1,1);
258 histoname = labelname+
"_PVz";
259 title =
"online z(PV) "+trigPath;
262 histoname = labelname+
"_fastPVz";
263 title =
"online z(fastPV) "+trigPath;
266 histoname =
"HLTMinusRECO_PVz";
267 title =
"online z(PV) - offline z(PV) "+trigPath;
268 MonitorElement * PVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),title.c_str(),200,-0.5,0.5);
270 histoname =
"HLTMinusRECO_fastPVz";
271 title =
"online z(fastPV) - offline z(PV) "+trigPath;
272 MonitorElement * fastPVz_HLTMinusRECO = iBooker.
book1D(histoname.c_str(),title.c_str(),100,-2,2);
274 v->setHistos(CSV,Pt,Eta,CSV_RECOvsHLT,PVz,fastPVz,PVz_HLTMinusRECO,fastPVz_HLTMinusRECO);
BTVHLTOfflineSource(const edm::ParameterSet &)
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
transient_vector_type::const_iterator const_iterator
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::LuminosityBlockNumber_t luminosityBlock() const
double deltaR(const T1 &t1, const T2 &t2)
static const std::string removeVersion(const std::string &trigger)
MonitorElement * book1D(Args &&...args)
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
virtual void dqmBeginRun(edm::Run const &run, edm::EventSetup const &c) override
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &run, edm::EventSetup const &c) override