CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
PFJetAnalyzerDQM Class Reference
Inheritance diagram for PFJetAnalyzerDQM:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Classes

class  Plot1DInBin
 
class  Plot1DInBinVariable
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 PFJetAnalyzerDQM (const edm::ParameterSet &)
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Private Member Functions

void fillJetResponse (edm::View< pat::Jet > &recoJetCollection, edm::View< reco::Jet > &genJetCollection)
 
void prepareGenJetPlots (const std::vector< edm::ParameterSet > &genjet_plots_pset)
 
void prepareJetResponsePlots (const std::vector< edm::ParameterSet > &genjet_plots_pset)
 

Private Attributes

std::vector< Plot1DInBinVariablegenJetPlots
 
edm::InputTag genJetsLabel
 
bool genJetsOn
 
edm::EDGetTokenT< edm::View
< reco::Jet > > 
genJetsToken
 
bool isMC
 
std::string jetCollectionName
 
float jetDeltaR
 
std::vector< Plot1DInBinjetResponsePlots
 
std::vector< Plot1DInBinjetResponsePlots_noJEC
 
edm::InputTag recoJetsLabel
 
edm::EDGetTokenT< edm::View
< pat::Jet > > 
recoJetsToken
 
edm::EDGetTokenT
< reco::CandViewMatchMap
srcRefToJetMap
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr
< DQMEDAnalyzerGlobalCache
initializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 21 of file PFJetAnalyzerDQM.cc.

Constructor & Destructor Documentation

PFJetAnalyzerDQM::PFJetAnalyzerDQM ( const edm::ParameterSet iConfig)

Definition at line 191 of file PFJetAnalyzerDQM.cc.

References genJetsLabel, genJetsOn, genJetsToken, edm::ParameterSet::getParameter(), jetCollectionName, jetDeltaR, edm::InputTag::label(), prepareGenJetPlots(), prepareJetResponsePlots(), recoJetsLabel, and recoJetsToken.

191  {
192  recoJetsLabel = iConfig.getParameter<edm::InputTag>("recoJetCollection");
193  genJetsLabel = iConfig.getParameter<edm::InputTag>("genJetCollection");
194 
195  //label for making new folder
197 
198  //DeltaR for reco to gen jet matching
199  jetDeltaR = iConfig.getParameter<double>("jetDeltaR");
200 
201  //for turn genJet on/off
202  genJetsOn = iConfig.getParameter<bool>("genJetsOn");
203 
204  //Create all jet response plots in bins of genjet pt and eta
205  const auto& response_plots = iConfig.getParameter<std::vector<edm::ParameterSet>>("responsePlots");
206  prepareJetResponsePlots(response_plots);
207 
208  const auto& genjet_plots = iConfig.getParameter<std::vector<edm::ParameterSet>>("genJetPlots");
209  prepareGenJetPlots(genjet_plots);
210 
211  recoJetsToken = consumes<edm::View<pat::Jet>>(recoJetsLabel);
212  genJetsToken = consumes<edm::View<reco::Jet>>(genJetsLabel);
213 }
edm::EDGetTokenT< edm::View< pat::Jet > > recoJetsToken
void prepareJetResponsePlots(const std::vector< edm::ParameterSet > &genjet_plots_pset)
edm::EDGetTokenT< edm::View< reco::Jet > > genJetsToken
edm::InputTag genJetsLabel
std::string jetCollectionName
edm::InputTag recoJetsLabel
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void prepareGenJetPlots(const std::vector< edm::ParameterSet > &genjet_plots_pset)
std::string const & label() const
Definition: InputTag.h:36

Member Function Documentation

void PFJetAnalyzerDQM::analyze ( const edm::Event iEvent,
const edm::EventSetup  
)
overridevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 281 of file PFJetAnalyzerDQM.cc.

References fillJetResponse(), genJetsToken, edm::Event::getByToken(), isMC, edm::EventBase::isRealData(), and recoJetsToken.

281  {
282  edm::Handle<edm::View<pat::Jet>> recoJetCollectionHandle;
283  iEvent.getByToken(recoJetsToken, recoJetCollectionHandle);
284  auto recoJetCollection = *recoJetCollectionHandle;
285 
286  isMC = !iEvent.isRealData();
287 
288  if (isMC) {
289  edm::Handle<edm::View<reco::Jet>> genJetCollectionHandle;
290  iEvent.getByToken(genJetsToken, genJetCollectionHandle);
291  auto genJetCollection = *genJetCollectionHandle;
292 
293  fillJetResponse(recoJetCollection, genJetCollection);
294  }
295 }
edm::EDGetTokenT< edm::View< pat::Jet > > recoJetsToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void fillJetResponse(edm::View< pat::Jet > &recoJetCollection, edm::View< reco::Jet > &genJetCollection)
edm::EDGetTokenT< edm::View< reco::Jet > > genJetsToken
bool isRealData() const
Definition: EventBase.h:62
void PFJetAnalyzerDQM::bookHistograms ( DQMStore::IBooker booker,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 261 of file PFJetAnalyzerDQM.cc.

References genJetPlots, genJetsOn, jetCollectionName, jetResponsePlots, jetResponsePlots_noJEC, bigModule::plot(), and dqm::implementation::NavigatorBase::setCurrentFolder().

261  {
262  booker.setCurrentFolder("ParticleFlow/JetResponse/" + jetCollectionName + "/JEC/");
263  for (auto& plot : jetResponsePlots) {
264  plot.book(booker);
265  }
266  //Book plots for noJEC
267  booker.setCurrentFolder("ParticleFlow/JetResponse/" + jetCollectionName + "/noJEC/");
268  for (auto& plot : jetResponsePlots_noJEC) {
269  plot.book(booker);
270  }
271 
272  //Book plots for gen-jet pt spectra
273  if (genJetsOn) {
274  booker.setCurrentFolder("ParticleFlow/GenJets/");
275  for (auto& plot : genJetPlots) {
276  plot.book(booker);
277  }
278  }
279 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::vector< Plot1DInBin > jetResponsePlots
def plot
Definition: bigModule.py:18
std::string jetCollectionName
std::vector< Plot1DInBinVariable > genJetPlots
std::vector< Plot1DInBin > jetResponsePlots_noJEC
void PFJetAnalyzerDQM::fillJetResponse ( edm::View< pat::Jet > &  recoJetCollection,
edm::View< reco::Jet > &  genJetCollection 
)
private

Definition at line 215 of file PFJetAnalyzerDQM.cc.

References funct::abs(), edm::View< T >::at(), genJetPlots, genJetsOn, mps_fire::i, jetDeltaR, jetResponsePlots, jetResponsePlots_noJEC, PFB::match(), bigModule::plot(), uploadConditions::response, and edm::View< T >::size().

Referenced by analyze().

215  {
216  //match gen jets to reco jets, require minimum jetDeltaR, choose closest, do not try to match charge
217  std::vector<int> matchIndices;
218  PFB::match(genJetCollection, recoJetCollection, matchIndices, false, jetDeltaR);
219 
220  for (unsigned int i = 0; i < genJetCollection.size(); i++) {
221  const auto& genJet = genJetCollection.at(i);
222  const auto pt_gen = genJet.pt();
223  const auto eta_gen = abs(genJet.eta());
224  const int iMatch = matchIndices[i];
225 
226  //Fill genjet pt if genJetOn
227  if (genJetsOn) {
228  for (auto& plot : genJetPlots) {
229  if (plot.isInEtaBin(eta_gen)) {
230  plot.fill(pt_gen);
231  }
232  }
233  }
234 
235  //If gen jet had a matched reco jet
236  if (iMatch != -1) {
237  const auto& recoJet = recoJetCollection[iMatch];
238  auto pt_reco = recoJet.pt();
239 
240  const auto response = pt_reco / pt_gen;
241  const auto response_raw = pt_reco * recoJet.jecFactor("Uncorrected") / pt_gen;
242 
243  //Loop linearly through all plots and check if they match the pt and eta bin
244  //this is not algorithmically optimal but we don't expect to more than a few hundred plots
245  //If this turns out to be a problem, can easily make a 2D-map for indices
246  for (auto& plot : jetResponsePlots) {
247  if (plot.isInPtEtaBin(pt_gen, eta_gen)) {
248  plot.fill(response);
249  }
250  }
251  // this loop should be for NoJEC plots
252  for (auto& plot : jetResponsePlots_noJEC) {
253  if (plot.isInPtEtaBin(pt_gen, eta_gen)) {
254  plot.fill(response_raw);
255  }
256  }
257  }
258  }
259 }
void match(const C &candCollection, const M &matchedCandCollection, std::vector< int > &matchIndices, bool matchCharge=false, float dRMax=-1)
Definition: Matchers.h:17
std::vector< Plot1DInBin > jetResponsePlots
size_type size() const
def plot
Definition: bigModule.py:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< Plot1DInBinVariable > genJetPlots
const_reference at(size_type pos) const
std::vector< Plot1DInBin > jetResponsePlots_noJEC
void PFJetAnalyzerDQM::prepareGenJetPlots ( const std::vector< edm::ParameterSet > &  genjet_plots_pset)
private

Definition at line 168 of file PFJetAnalyzerDQM.cc.

References genJetPlots, mergeVDriftHistosByStation::name, TrackValidation_cff::pset, defaults_cfi::ptbins, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

Referenced by PFJetAnalyzerDQM().

168  {
169  for (auto& pset : genjet_plots_pset) {
170  const auto name = pset.getParameter<std::string>("name");
171  const auto title = pset.getParameter<std::string>("title");
172 
173  //Low and high edges of the eta bins for jets to pass to be filled into this histogram
174  const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
175  std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());
176 
177  const auto etabin_low = pset.getParameter<double>("etaBinLow");
178  const auto etabin_high = pset.getParameter<double>("etaBinHigh");
179 
180  genJetPlots.push_back(Plot1DInBinVariable(
181  name,
182  title,
183  std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
184  0.0,
185  0.0,
186  etabin_low,
187  etabin_high));
188  }
189 }
std::vector< Plot1DInBinVariable > genJetPlots
void PFJetAnalyzerDQM::prepareJetResponsePlots ( const std::vector< edm::ParameterSet > &  genjet_plots_pset)
private

Definition at line 138 of file PFJetAnalyzerDQM.cc.

References jetResponsePlots, jetResponsePlots_noJEC, mergeVDriftHistosByStation::name, TrackValidation_cff::pset, AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

Referenced by PFJetAnalyzerDQM().

138  {
139  for (auto& pset : response_plots) {
140  //Low and high edges of the pt and eta bins for jets to pass to be filled into this histogram
141  const auto ptbin_low = pset.getParameter<double>("ptBinLow");
142  const auto ptbin_high = pset.getParameter<double>("ptBinHigh");
143  const auto etabin_low = pset.getParameter<double>("etaBinLow");
144  const auto etabin_high = pset.getParameter<double>("etaBinHigh");
145 
146  const auto response_nbins = pset.getParameter<uint32_t>("responseNbins");
147  const auto response_low = pset.getParameter<double>("responseLow");
148  const auto response_high = pset.getParameter<double>("responseHigh");
149 
150  const auto name = pset.getParameter<std::string>("name");
151  const auto title = pset.getParameter<std::string>("title");
152 
153  // for title of raw jet response histograms
154  auto rawTitle = title;
155  rawTitle = rawTitle.replace(rawTitle.begin(), rawTitle.begin(), "Raw ");
156 
157  jetResponsePlots.push_back(Plot1DInBin(
158  name, title, response_nbins, response_low, response_high, ptbin_low, ptbin_high, etabin_low, etabin_high));
159 
160  jetResponsePlots_noJEC.push_back(Plot1DInBin(
161  name, rawTitle, response_nbins, response_low, response_high, ptbin_low, ptbin_high, etabin_low, etabin_high));
162  }
163  if (jetResponsePlots.size() > 200) {
164  throw std::runtime_error("Requested too many jet response plots, aborting as this seems unusual.");
165  }
166 }
std::vector< Plot1DInBin > jetResponsePlots
std::vector< Plot1DInBin > jetResponsePlots_noJEC

Member Data Documentation

std::vector<Plot1DInBinVariable> PFJetAnalyzerDQM::genJetPlots
private

Definition at line 116 of file PFJetAnalyzerDQM.cc.

Referenced by bookHistograms(), fillJetResponse(), and prepareGenJetPlots().

edm::InputTag PFJetAnalyzerDQM::genJetsLabel
private

Definition at line 128 of file PFJetAnalyzerDQM.cc.

Referenced by PFJetAnalyzerDQM().

bool PFJetAnalyzerDQM::genJetsOn
private

Definition at line 123 of file PFJetAnalyzerDQM.cc.

Referenced by bookHistograms(), fillJetResponse(), and PFJetAnalyzerDQM().

edm::EDGetTokenT<edm::View<reco::Jet> > PFJetAnalyzerDQM::genJetsToken
private

Definition at line 130 of file PFJetAnalyzerDQM.cc.

Referenced by analyze(), and PFJetAnalyzerDQM().

bool PFJetAnalyzerDQM::isMC
private

Definition at line 119 of file PFJetAnalyzerDQM.cc.

Referenced by analyze().

std::string PFJetAnalyzerDQM::jetCollectionName
private

Definition at line 125 of file PFJetAnalyzerDQM.cc.

Referenced by bookHistograms(), and PFJetAnalyzerDQM().

float PFJetAnalyzerDQM::jetDeltaR
private

Definition at line 121 of file PFJetAnalyzerDQM.cc.

Referenced by fillJetResponse(), and PFJetAnalyzerDQM().

std::vector<Plot1DInBin> PFJetAnalyzerDQM::jetResponsePlots
private

Definition at line 114 of file PFJetAnalyzerDQM.cc.

Referenced by bookHistograms(), fillJetResponse(), and prepareJetResponsePlots().

std::vector<Plot1DInBin> PFJetAnalyzerDQM::jetResponsePlots_noJEC
private

Definition at line 115 of file PFJetAnalyzerDQM.cc.

Referenced by bookHistograms(), fillJetResponse(), and prepareJetResponsePlots().

edm::InputTag PFJetAnalyzerDQM::recoJetsLabel
private

Definition at line 127 of file PFJetAnalyzerDQM.cc.

Referenced by PFJetAnalyzerDQM().

edm::EDGetTokenT<edm::View<pat::Jet> > PFJetAnalyzerDQM::recoJetsToken
private

Definition at line 129 of file PFJetAnalyzerDQM.cc.

Referenced by analyze(), and PFJetAnalyzerDQM().

edm::EDGetTokenT<reco::CandViewMatchMap> PFJetAnalyzerDQM::srcRefToJetMap
private

Definition at line 131 of file PFJetAnalyzerDQM.cc.