32 #include "TDirectory.h"
36 #include <Math/VectorUtil.h>
37 using namespace ROOT::Math::VectorUtil ;
53 dirname_=
"HLT/HLTEgammaValidation/"+pset.
getParameter<std::string>(
"@module_label");
54 dbe->setCurrentFolder(dirname_);
78 std::vector<edm::ParameterSet>
filters =
79 pset.
getParameter<std::vector<edm::ParameterSet> >(
"filters");
82 for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++)
85 theHLTCollectionLabels.push_back(filterconf->getParameter<
edm::InputTag>(
"HLTCollectionLabels"));
86 theHLTOutputTypes.push_back(filterconf->getParameter<
int>(
"theHLTOutputTypes"));
88 theHLTCollectionHumanNames.push_back(filterconf->getUntrackedParameter<std::string>(
"HLTCollectionHumanName",theHLTCollectionLabels[i].label()));
90 std::vector<double> bounds = filterconf->getParameter<std::vector<double> >(
"PlotBounds");
92 assert(bounds.size() == 2);
93 plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
94 isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >(
"IsoCollections"));
96 assert(isoNames.back().size()>0);
97 if (isoNames.back().at(0).label()==
"none") {
98 plotiso.push_back(
false);
100 plotiso.push_back(
true);
106 numOfHLTCollectionLabels = theHLTCollectionLabels.size();
118 dbe->setCurrentFolder(dirname_);
126 std::string histName=
"total_eff";
127 std::string histTitle =
"total events passing";
130 total = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
131 total->setBinLabel(numOfHLTCollectionLabels+1,
"Total");
132 total->setBinLabel(numOfHLTCollectionLabels+2,
"Gen");
133 for (
unsigned int u=0; u<numOfHLTCollectionLabels; u++){
total->setBinLabel(u+1,theHLTCollectionLabels[u].
label().c_str());}
135 histName=
"total_eff_MC_matched";
136 histTitle=
"total events passing (mc matched)";
137 totalmatch = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
138 totalmatch->setBinLabel(numOfHLTCollectionLabels+1,
"Total");
139 totalmatch->setBinLabel(numOfHLTCollectionLabels+2,
"Gen");
140 for (
unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalmatch->setBinLabel(u+1,theHLTCollectionLabels[u].
label().c_str());}
148 std::string pdgIdString;
151 pdgIdString=
"Electron";
break;
153 pdgIdString=
"Photon";
break;
155 pdgIdString=
"Particle";
159 histTitle=
"E_{T} of " + pdgIdString +
"s" ;
160 etgen = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
161 histName =
"gen_eta";
162 histTitle=
"#eta of "+ pdgIdString +
"s " ;
163 etagen = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
164 histName =
"gen_phi";
165 histTitle=
"#phi of "+ pdgIdString +
"s " ;
166 phigen = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
175 std::vector<std::string> HltHistTitle;
176 if ( theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles ) {
177 HltHistTitle = theHLTCollectionHumanNames;
179 for (
unsigned int i =0;
i < numOfHLTCollectionLabels;
i++) {
180 HltHistTitle.push_back(theHLTCollectionLabels[
i].
label());
184 for(
unsigned int i = 0;
i< numOfHLTCollectionLabels ;
i++){
186 histName = theHLTCollectionLabels[
i].label()+
"et_all";
187 histTitle = HltHistTitle[
i]+
" Et (ALL)";
188 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
189 ethist.push_back(tmphisto);
192 histName = theHLTCollectionLabels[
i].label()+
"eta_all";
193 histTitle = HltHistTitle[
i]+
" #eta (ALL)";
194 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
195 etahist.push_back(tmphisto);
198 histName = theHLTCollectionLabels[
i].label()+
"phi_all";
199 histTitle = HltHistTitle[
i]+
" #phi (ALL)";
200 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
201 phihist.push_back(tmphisto);
205 histName = theHLTCollectionLabels[
i].label()+
"et_MC_matched";
206 histTitle = HltHistTitle[
i]+
" Et (MC matched)";
207 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
208 ethistmatch.push_back(tmphisto);
211 histName = theHLTCollectionLabels[
i].label()+
"eta_MC_matched";
212 histTitle = HltHistTitle[
i]+
" #eta (MC matched)";
213 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
214 etahistmatch.push_back(tmphisto);
217 histName = theHLTCollectionLabels[
i].label()+
"phi_MC_matched";
218 histTitle = HltHistTitle[
i]+
" #phi (MC matched)";
219 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
220 phihistmatch.push_back(tmphisto);
225 histName = theHLTCollectionLabels[
i].label()+
"et";
226 histTitle = HltHistTitle[
i]+
" Et";
227 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
228 histEtOfHltObjMatchToGen.push_back(tmphisto);
231 histName = theHLTCollectionLabels[
i].label()+
"eta";
232 histTitle = HltHistTitle[
i]+
" eta";
233 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
234 histEtaOfHltObjMatchToGen.push_back(tmphisto);
237 histName = theHLTCollectionLabels[
i].label()+
"phi";
238 histTitle = HltHistTitle[
i]+
" phi";
239 tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
240 histPhiOfHltObjMatchToGen.push_back(tmphisto);
246 etahistiso.push_back(tmpiso);
247 phihistiso.push_back(tmpiso);
248 ethistiso.push_back(tmpiso);
249 etahistisomatch.push_back(tmpiso);
250 phihistisomatch.push_back(tmpiso);
251 ethistisomatch.push_back(tmpiso);
252 histEtaIsoOfHltObjMatchToGen.push_back(tmpiso);
253 histPhiIsoOfHltObjMatchToGen.push_back(tmpiso);
254 histEtIsoOfHltObjMatchToGen.push_back(tmpiso);
257 histName = theHLTCollectionLabels[
i].label()+
"eta_isolation_all";
258 histTitle = HltHistTitle[
i]+
" isolation vs #eta (all)";
259 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
260 etahistiso.push_back(tmpiso);
263 histName = theHLTCollectionLabels[
i].label()+
"phi_isolation_all";
264 histTitle = HltHistTitle[
i]+
" isolation vs #phi (all)";
265 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
266 phihistiso.push_back(tmpiso);
270 histName = theHLTCollectionLabels[
i].label()+
"et_isolation_all";
271 histTitle = HltHistTitle[
i]+
" isolation vs Et (all)";
272 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
273 ethistiso.push_back(tmpiso);
276 histName = theHLTCollectionLabels[
i].label()+
"eta_isolation_MC_matched";
277 histTitle = HltHistTitle[
i]+
" isolation vs #eta (mc matched)";
278 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
279 etahistisomatch.push_back(tmpiso);
282 histName = theHLTCollectionLabels[
i].label()+
"phi_isolation_MC_matched";
283 histTitle = HltHistTitle[
i]+
" isolation vs #phi (mc matched)";
284 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
285 phihistisomatch.push_back(tmpiso);
289 histName = theHLTCollectionLabels[
i].label()+
"et_isolation_MC_matched";
290 histTitle = HltHistTitle[
i]+
" isolation vs Et (mc matched)";
291 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
292 ethistisomatch.push_back(tmpiso);
297 histName = theHLTCollectionLabels[
i].label()+
"eta_isolation";
298 histTitle = HltHistTitle[
i]+
" isolation vs #eta";
299 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
300 histEtaIsoOfHltObjMatchToGen.push_back(tmpiso);
304 histName = theHLTCollectionLabels[
i].label()+
"phi_isolation";
305 histTitle = HltHistTitle[
i]+
" isolation vs #phi";
306 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
307 histPhiIsoOfHltObjMatchToGen.push_back(tmpiso);
311 histName = theHLTCollectionLabels[
i].label()+
"et_isolation";
312 histTitle = HltHistTitle[
i]+
" isolation vs Et";
313 tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[
i].first,plotBounds[
i].second);
314 histEtIsoOfHltObjMatchToGen.push_back(tmpiso);
340 event.getByLabel(gencutCollection_,cutCounter);
341 if (cutCounter->size() < (
unsigned int)gencut_) {
350 event.getByLabel(triggerobjwithrefs,triggerObj);
352 edm::LogWarning(
"EmDQM") <<
"triggerobjwithrefs=" << triggerobjwithrefs;
363 event.getByLabel(
"genParticles", genParticles);
369 std::vector<reco::GenParticle> allSortedGenParticles;
373 if ( !(
abs((*currentGenParticle).pdgId())==pdgGen && (*currentGenParticle).status()==1 && (*currentGenParticle).et() > 2.0) )
continue;
376 allSortedGenParticles.push_back(tmpcand);
379 std::sort(allSortedGenParticles.begin(), allSortedGenParticles.end(),pTGenComparator_);
382 if (allSortedGenParticles.size() < gencut_) {
390 bool keepEvent =
true;
391 for (
unsigned int i = 0 ;
i < gencut_ ;
i++ ) {
392 bool inECALgap = fabs(allSortedGenParticles[
i].
eta()) > 1.4442 && fabs(allSortedGenParticles[
i].
eta()) < 1.556;
393 if ( (fabs(allSortedGenParticles[
i].
eta()) > genEtaAcc) || inECALgap ) {
410 total->Fill(numOfHLTCollectionLabels+0.5);
411 totalmatch->Fill(numOfHLTCollectionLabels+0.5);
419 std::vector<reco::Particle> sortedGen;
421 reco::Particle tmpcand( genpart->charge(), genpart->p4(), genpart->vertex(),genpart->pdgId(),genpart->status() );
422 sortedGen.push_back(tmpcand);
424 std::sort(sortedGen.begin(),sortedGen.end(),pTComparator_ );
429 sortedGen.erase(sortedGen.begin()+gencut_,sortedGen.end());
430 if (gencut_ != sortedGen.size() ){
435 for (
unsigned int i = 0 ;
i < gencut_ ;
i++ ) {
436 etgen ->Fill( sortedGen[
i].
et() );
437 etagen->Fill( sortedGen[
i].
eta() );
438 phigen->Fill( sortedGen[
i].
phi() );
440 if (gencut_ >= reqNum)
total->Fill(numOfHLTCollectionLabels+1.5);
441 if (gencut_ >= reqNum) totalmatch->Fill(numOfHLTCollectionLabels+1.5);
447 for(
unsigned int n=0;
n < numOfHLTCollectionLabels ;
n++) {
450 switch(theHLTOutputTypes[
n])
453 fillHistos<l1extra::L1EmParticleCollection>(triggerObj,
event,
n,sortedGen);
break;
455 fillHistos<l1extra::L1EmParticleCollection>(triggerObj,
event,
n,sortedGen);
break;
457 fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,
event,
n,sortedGen);
break;
459 fillHistos<reco::ElectronCollection>(triggerObj,
event,
n,sortedGen);
break;
461 fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,
event,
n,sortedGen);
break;
463 throw(
cms::Exception(
"Release Validation Error") <<
"HLT output type not implemented: theHLTOutputTypes[n]" );
475 std::vector<edm::Ref<T> > recoecalcands;
476 if ( ( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){
483 triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[
n],recoecalcands);
487 std::vector<edm::Ref<T> > isocands;
489 if (isocands.size()>0)
491 for (
unsigned int i=0;
i < isocands.size();
i++)
492 recoecalcands.push_back(isocands[
i]);
497 if (recoecalcands.size() < 1){
502 if (recoecalcands.size() >= reqNum )
510 for (
unsigned int j=0;
j<recoecalcands.size();
j++){
511 if(!( recoecalcands.at(
j).isAvailable())){
512 edm::LogError(
"EmDQM") <<
"Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl <<
"invalid refs for: " << theHLTCollectionLabels[
n].label();
521 for (
unsigned int i=0;
i < gencut_;
i++) {
524 float closestDeltaR = 0.5;
525 int closestEcalCandIndex = -1;
526 for (
unsigned int j=0;
j<recoecalcands.size();
j++) {
527 float deltaR =
DeltaR(recoecalcands[
j]->momentum(),currentGenParticleMomentum);
529 if (deltaR < closestDeltaR) {
531 closestEcalCandIndex =
j;
537 if ( closestEcalCandIndex >= 0 ) {
538 histEtOfHltObjMatchToGen[
n] ->Fill( recoecalcands[closestEcalCandIndex]->
et() );
539 histEtaOfHltObjMatchToGen[
n]->Fill( recoecalcands[closestEcalCandIndex]->
eta() );
540 histPhiOfHltObjMatchToGen[
n]->Fill( recoecalcands[closestEcalCandIndex]->
phi() );
543 if (n+1 < numOfHLTCollectionLabels){
545 for (
unsigned int j = 0 ;
j < isoNames[n+1].size() ;
j++ ){
550 if (mapi!=depMap->end()) {
551 histEtaIsoOfHltObjMatchToGen[n+1]->Fill( recoecalcands[closestEcalCandIndex]->
eta(),mapi->val);
552 histPhiIsoOfHltObjMatchToGen[n+1]->Fill( recoecalcands[closestEcalCandIndex]->
phi(),mapi->val);
553 histEtIsoOfHltObjMatchToGen[n+1] ->Fill( recoecalcands[closestEcalCandIndex]->
et(), mapi->val);
570 for (
unsigned int i=0;
i<recoecalcands.size();
i++) {
589 ethist[
n] ->Fill(recoecalcands[
i]->
et() );
590 etahist[
n]->Fill(recoecalcands[
i]->
eta() );
591 phihist[
n]->Fill(recoecalcands[
i]->
phi() );
597 if ( n+1 < numOfHLTCollectionLabels ) {
599 for (
unsigned int j = 0 ;
j < isoNames[n+1].size() ;
j++ ){
604 if (mapi!=depMap->end()){
605 etahistiso[n+1]->Fill(recoecalcands[i]->
eta(),mapi->val);
606 phihistiso[n+1]->Fill(recoecalcands[i]->
phi(),mapi->val);
607 ethistiso[n+1]->Fill(recoecalcands[i]->
et(),mapi->val);
619 unsigned int mtachedMcParts = 0;
621 if(n==0) mindist=0.5;
622 for(
unsigned int i =0;
i < gencut_;
i++){
624 bool matchThis=
false;
626 unsigned int closest = 0;
627 double closestDr = 1000.;
628 for(
unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
629 double dr =
DeltaR(recoecalcands[trigOb]->momentum(),candDir);
630 if (dr < closestDr) {
634 if (closestDr > mindist) {
641 if ( !matchThis )
continue;
643 ethistmatch[
n] ->Fill( sortedGen[
i].
et() );
644 etahistmatch[
n]->Fill( sortedGen[
i].
eta() );
645 phihistmatch[
n]->Fill( sortedGen[
i].
phi() );
650 if (n+1 < numOfHLTCollectionLabels){
652 for (
unsigned int j = 0 ;
j < isoNames[n+1].size() ;
j++ ){
657 if (mapi!=depMap->end()){
658 etahistisomatch[n+1]->Fill(sortedGen[
i].
eta(),mapi->val);
659 phihistisomatch[n+1]->Fill(sortedGen[
i].
phi(),mapi->val);
660 ethistisomatch[n+1]->Fill(sortedGen[
i].
et(),mapi->val);
668 if (mtachedMcParts >= reqNum )
669 totalmatch->Fill(n+0.5);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int, std::vector< reco::Particle > &)
#define DEFINE_FWK_MODULE(type)
std::vector< TPRegexp > filters
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
EmDQM(const edm::ParameterSet &pset)
Constructor.
double deltaR(double eta1, double eta2, double phi1, double phi2)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void analyze(const edm::Event &event, const edm::EventSetup &)