Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emdqm standalone #1667

Merged
merged 12 commits into from Dec 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
212 changes: 150 additions & 62 deletions HLTriggerOffline/Egamma/interface/EmDQM.h
Expand Up @@ -3,26 +3,69 @@


// Base Class Headers
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "DataFormats/Common/interface/RefToBase.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include <vector>
#include "TDirectory.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/L1Trigger/interface/L1EmParticle.h"
#include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
#include "DataFormats/Common/interface/AssociationMap.h"
#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "HepMC/GenParticle.h"
#include "CommonTools/Utils/interface/PtComparator.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "DataFormats/Common/interface/TriggerResults.h"

#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>

#include "TDirectory.h"
#include "TFile.h"
#include "TH1F.h"
#include <memory>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <Math/VectorUtil.h>

class EmDQM;

template <class T>
class HistoFiller {
public:
HistoFiller(EmDQM* d):dqm(d) {};
~HistoFiller() {};

void fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& ,const edm::Event& ,unsigned int, unsigned int, std::vector<reco::Particle>&, bool & );
//std::vector<edm::EDGetTokenT<edm::AssociationMap<edm::OneToValue< T , float>>>> isoNameTokens_;

private:
EmDQM* dqm;
};

class EmDQM : public edm::EDAnalyzer{
public:

friend class HistoFiller<reco::ElectronCollection>;
friend class HistoFiller<reco::RecoEcalCandidateCollection>;
friend class HistoFiller<l1extra::L1EmParticleCollection>;

/// Constructor
explicit EmDQM(const edm::ParameterSet& pset);

Expand All @@ -39,6 +82,34 @@ class EmDQM : public edm::EDAnalyzer{
void endRun(edm::Run const&, edm::EventSetup const&);

private:
// interface to DQM framework
DQMStore * dbe;
std::string dirname_;

HistoFiller<reco::ElectronCollection>* histoFillerEle;
HistoFiller<reco::RecoEcalCandidateCollection>* histoFillerClu;
HistoFiller<l1extra::L1EmParticleCollection>* histoFillerL1NonIso;
HistoFiller<reco::RecoEcalCandidateCollection>* histoFillerPho;
HistoFiller<l1extra::L1EmParticleCollection>* histoFillerL1Iso;

// parameter set from config file
const edm::ParameterSet& pset;
// global parameters
edm::InputTag triggerObject_;
unsigned int verbosity_;
double genEtaAcc_;
double genEtAcc_;
bool isData_;
double ptMax_;
double ptMin_;
double etaMax_;
double phiMax_;
unsigned int nbins_;
unsigned int minEtForEtaEffPlot_;
bool useHumanReadableHistTitles_;
bool mcMatchedOnly_;
bool noPhiPlots_;
bool noIsolationPlots_;

/** helper to check whether there were enough generator level
* electrons/photons (MC) or enough reco level electrons/photons
Expand All @@ -55,49 +126,45 @@ class EmDQM : public edm::EDAnalyzer{
bool checkRecoParticlesRequirement(const edm::Event & event);

/// The instance of the HLTConfigProvider as a data member
HLTConfigProvider hltConf_;

// Input from cfg file
edm::InputTag triggerobjwithrefs;
HLTConfigProvider hltConfig_;

// routines to build validation configuration from HLTConfiguration
std::vector<std::vector<std::string> > findEgammaPaths();
std::vector<std::string> getFilterModules(const std::string&);
double getPrimaryEtCut(const std::string&);
edm::ParameterSet makePSetForL1SeedFilter(const std::string&);
edm::ParameterSet makePSetForL1SeedToSuperClusterMatchFilter(const std::string&);
edm::ParameterSet makePSetForEtFilter(const std::string&);
edm::ParameterSet makePSetForOneOEMinusOneOPFilter(const std::string&);
edm::ParameterSet makePSetForPixelMatchFilter(const std::string&);
edm::ParameterSet makePSetForEgammaGenericFilter(const std::string&);
edm::ParameterSet makePSetForEgammaGenericQuadraticFilter(const std::string&);
edm::ParameterSet makePSetForElectronGenericFilter(const std::string&);
edm::ParameterSet makePSetForEgammaDoubleEtDeltaPhiFilter(const std::string&);

// set validation configuration parameters for a trigger path
void SetVarsFromPSet(std::vector<edm::ParameterSet>::iterator);

// generated parameter set for trigger path
std::vector<edm::ParameterSet> paramSets;
// input from generated parameter set
unsigned int pathIndex;
std::vector<edm::InputTag> theHLTCollectionLabels;
unsigned int numOfHLTCollectionLabels; // Will be size of above vector
bool useHumanReadableHistTitles;
bool mcMatchedOnly;
bool noPhiPlots;
bool noIsolationPlots;
std::vector<std::string> theHLTCollectionHumanNames; // Human-readable names for the collections
edm::InputTag theL1Seed;
std::vector<int> theHLTOutputTypes;
std::vector<bool> plotiso;
std::vector<std::vector<edm::InputTag> > isoNames; // there has to be a better solution
std::vector<std::pair<double,double> > plotBounds;
std::vector<unsigned int> nCandCuts;
std::string theHltName;
unsigned verbosity;
// verbosity levels
static const unsigned OUTPUT_SILENT = 0;
static const unsigned OUTPUT_ERRORS = 1;
static const unsigned OUTPUT_WARNINGS = 2;
static const unsigned OUTPUT_ALL = 3;

////////////////////////////////////////////////////////////
// Read from configuration file //
////////////////////////////////////////////////////////////
// paramters for generator study
unsigned int reqNum;
int pdgGen;
double genEtaAcc;
double genEtAcc;
// plotting paramters
// plotting parameters
double plotEtMin;
double plotEtaMax;
double plotPhiMax;
double plotPtMin ;
double plotPtMax ;
unsigned int plotBins ;
unsigned int plotMinEtForEtaEffPlot;
// preselction cuts

/** collection which should be used for generator particles (MC)
* or reconstructed particles (data).
Expand All @@ -111,50 +178,71 @@ class EmDQM : public edm::EDAnalyzer{
unsigned int gencut_;

/** which hltCollectionLabels were SEEN at least once */
std::vector<std::set<std::string> > hltCollectionLabelsFoundPerPath;
std::set<std::string> hltCollectionLabelsFound;

/** which hltCollectionLabels were MISSED at least once */
std::vector<std::set<std::string> > hltCollectionLabelsMissedPerPath;
std::set<std::string> hltCollectionLabelsMissed;


////////////////////////////////////////////////////////////
// Create Histograms //
// Create Histogram containers
////////////////////////////////////////////////////////////
// Et & eta distributions
std::vector<MonitorElement*> etahist;
std::vector<MonitorElement*> phihist;
std::vector<MonitorElement*> ethist;
std::vector<MonitorElement*> etahistmatch;
std::vector<MonitorElement*> phihistmatch;
std::vector<MonitorElement*> ethistmatch;
std::vector<MonitorElement*> histEtOfHltObjMatchToGen;
std::vector<MonitorElement*> histEtaOfHltObjMatchToGen;
std::vector<MonitorElement*> histPhiOfHltObjMatchToGen;
std::vector<std::vector<MonitorElement*> > etahists;
std::vector<std::vector<MonitorElement*> > phihists;
std::vector<std::vector<MonitorElement*> > ethists;
std::vector<std::vector<MonitorElement*> > etahistmatchs;
std::vector<std::vector<MonitorElement*> > phihistmatchs;
std::vector<std::vector<MonitorElement*> > ethistmatchs;
std::vector<std::vector<MonitorElement*> > histEtOfHltObjMatchToGens;
std::vector<std::vector<MonitorElement*> > histEtaOfHltObjMatchToGens;
std::vector<std::vector<MonitorElement*> > histPhiOfHltObjMatchToGens;
// commented out because uses data not included in HTLDEBUG and uses getByLabel
// Isolation distributions
std::vector<MonitorElement*> etahistiso;
std::vector<MonitorElement*> phihistiso;
std::vector<MonitorElement*> ethistiso;
std::vector<MonitorElement*> etahistisomatch;
std::vector<MonitorElement*> phihistisomatch;
std::vector<MonitorElement*> ethistisomatch;
std::vector<MonitorElement*> histEtIsoOfHltObjMatchToGen;
std::vector<MonitorElement*> histEtaIsoOfHltObjMatchToGen;
std::vector<MonitorElement*> histPhiIsoOfHltObjMatchToGen;
//std::vector<std::vector<MonitorElement*> > etahistisos;
//std::vector<std::vector<MonitorElement*> > phihistisos;
//std::vector<std::vector<MonitorElement*> > ethistisos;
//std::vector<std::vector<MonitorElement*> > etahistisomatchs;
//std::vector<std::vector<MonitorElement*> > phihistisomatchs;
//std::vector<std::vector<MonitorElement*> > ethistisomatchs;
//std::vector<std::vector<MonitorElement*> > histEtIsoOfHltObjMatchToGens;
//std::vector<std::vector<MonitorElement*> > histEtaIsoOfHltObjMatchToGens;
//std::vector<std::vector<MonitorElement*> > histPhiIsoOfHltObjMatchToGens;
// Plots of efficiency per step
MonitorElement* total;
MonitorElement* totalmatch;
std::vector<MonitorElement*> totals;
std::vector<MonitorElement*> totalmatchs;
//generator histograms
MonitorElement* etgen;
MonitorElement* etagen;
MonitorElement* phigen;
std::vector<MonitorElement*> etgens;
std::vector<MonitorElement*> etagens;
std::vector<MonitorElement*> phigens;

// interface to DQM framework
DQMStore * dbe;
std::string dirname_;

template <class T> void fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& ,const edm::Event& ,unsigned int, std::vector<reco::Particle>&, bool & );
GreaterByPt<reco::Particle> pTComparator_;
GreaterByPt<reco::GenParticle> pTGenComparator_;


// tokens for data access
edm::EDGetTokenT<edm::View<reco::Candidate> > genParticles_token;
edm::EDGetTokenT<trigger::TriggerEventWithRefs> triggerObject_token;
edm::EDGetTokenT<edm::TriggerResults> hltResults_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidWenu_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidZee_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidGammaJet_token;
edm::EDGetTokenT<edm::View<reco::Candidate> > gencutColl_fidDiGamma_token;

// static variables
//
// trigger types considered
static const unsigned TYPE_SINGLE_ELE = 0;
static const unsigned TYPE_DOUBLE_ELE = 1;
static const unsigned TYPE_SINGLE_PHOTON = 2;
static const unsigned TYPE_DOUBLE_PHOTON = 3;
static const unsigned TYPE_TRIPLE_ELE = 4;

// verbosity levels
static const unsigned OUTPUT_SILENT = 0;
static const unsigned OUTPUT_ERRORS = 1;
static const unsigned OUTPUT_WARNINGS = 2;
static const unsigned OUTPUT_ALL = 3;
};
#endif
108 changes: 0 additions & 108 deletions HLTriggerOffline/Egamma/interface/EmDQMFeeder.h

This file was deleted.