CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Member Functions | Private Attributes
OffsetAnalyzerDQM Class Reference
Inheritance diagram for OffsetAnalyzerDQM:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Classes

struct  Plot1D
 
struct  PlotProfile
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 OffsetAnalyzerDQM (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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Protected Member Functions

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

Private Attributes

std::vector< double > etabins
 
int muHigh
 
edm::EDGetTokenT< edm::View< PileupSummaryInfo > > muToken
 
int npvHigh
 
std::string offsetPlotBaseName
 
std::map< std::string, PlotProfileoffsetPlots
 
std::map< int, std::string > pdgMap
 
edm::EDGetTokenT< edm::View< pat::PackedCandidate > > pfToken
 
std::vector< std::string > pftypes
 
edm::EDGetTokenT< edm::View< reco::Vertex > > pvToken
 
std::map< std::string, Plot1Dth1dPlots
 

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 >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 16 of file OffsetAnalyzerDQM.cc.

Constructor & Destructor Documentation

◆ OffsetAnalyzerDQM()

OffsetAnalyzerDQM::OffsetAnalyzerDQM ( const edm::ParameterSet iConfig)

Definition at line 95 of file OffsetAnalyzerDQM.cc.

95  {
96  offsetPlotBaseName = iConfig.getParameter<std::string>("offsetPlotBaseName");
97 
98  pvToken = consumes<edm::View<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvTag"));
99  muToken = consumes<edm::View<PileupSummaryInfo>>(iConfig.getParameter<edm::InputTag>("muTag"));
100  pfToken = consumes<edm::View<pat::PackedCandidate>>(iConfig.getParameter<edm::InputTag>("pfTag"));
101 
102  etabins = iConfig.getParameter<std::vector<double>>("etabins");
103  pftypes = iConfig.getParameter<std::vector<std::string>>("pftypes");
104 
105  muHigh = iConfig.getUntrackedParameter<int>("muHigh");
106  npvHigh = iConfig.getUntrackedParameter<int>("npvHigh");
107 
108  //initialize offset plots
109  const auto& offset_psets = iConfig.getParameter<std::vector<edm::ParameterSet>>("offsetPlots");
110  for (auto& pset : offset_psets) {
111  std::string name = pset.getParameter<std::string>("name");
112  std::string title = pset.getParameter<std::string>("title");
113  std::string dir = pset.getParameter<std::string>("dir");
114  std::vector<double> vx = pset.getParameter<std::vector<double>>("vx");
115  int ny = pset.getParameter<uint32_t>("ny");
116  double y0 = pset.getParameter<double>("y0");
117  double y1 = pset.getParameter<double>("y1");
118 
119  offsetPlots[name] = PlotProfile(name, title, dir, 0, 0, 0, vx, ny, y0, y1);
120  }
121 
122  //initialize th1d
123  const auto& th1d_psets = iConfig.getParameter<std::vector<edm::ParameterSet>>("th1dPlots");
124  for (auto& pset : th1d_psets) {
125  std::string name = pset.getParameter<std::string>("name");
126  std::string title = pset.getParameter<std::string>("title");
127  std::string dir = pset.getParameter<std::string>("dir");
128  int nx = pset.getParameter<uint32_t>("nx");
129  double x0 = pset.getParameter<double>("x0");
130  double x1 = pset.getParameter<double>("x1");
131 
132  th1dPlots[name] = Plot1D(name, title, dir, nx, x0, x1);
133  }
134 
135  //create pdg map
136  std::vector<uint32_t> pdgKeys = iConfig.getParameter<std::vector<uint32_t>>("pdgKeys");
137  std::vector<std::string> pdgStrs = iConfig.getParameter<std::vector<std::string>>("pdgStrs");
138  for (int i = 0, n = pdgKeys.size(); i < n; i++)
139  pdgMap[pdgKeys[i]] = pdgStrs[i];
140 }

References DeadROC_duringRun::dir, etabins, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, muHigh, muToken, dqmiodumpmetadata::n, Skims_PA_cff::name, npvHigh, offsetPlotBaseName, offsetPlots, offsetAnalyzerDQM_cff::pdgKeys, pdgMap, offsetAnalyzerDQM_cff::pdgStrs, pfToken, pftypes, Plot1D, muonDTDigis_cfi::pset, pvToken, AlCaHLTBitMon_QueryRunRegistry::string, th1dPlots, overlapproblemtsosanalyzer_cfi::title, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::y1.

Member Function Documentation

◆ analyze()

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

Reimplemented from DQMEDAnalyzer.

Definition at line 152 of file OffsetAnalyzerDQM.cc.

152  {
153  //npv//
155  iEvent.getByToken(pvToken, vertexHandle);
156 
157  unsigned int nPVall = vertexHandle->size();
158  bool isGoodPV[nPVall];
159  for (size_t i = 0; i < nPVall; ++i)
160  isGoodPV[i] = false;
161 
162  int npv = 0;
163  for (unsigned int i = 0; i < nPVall; i++) {
164  const auto& pv = vertexHandle->at(i);
165 
166  if (!pv.isFake() && pv.ndof() >= 4 && fabs(pv.z()) <= 24.0 && fabs(pv.position().rho()) <= 2.0) {
167  npv++;
168  isGoodPV[i] = true;
169  }
170  }
171  th1dPlots["npv"].fill(npv);
172  int npv_in_range = npv;
173  if (npv_in_range < 0)
174  npv_in_range = 0;
175  else if (npv_in_range >= npvHigh)
176  npv_in_range = npvHigh - 1; // make sure int_mu won't lead to non-existing ME
177 
178  //mu//
179  int int_mu = -1;
181  if (iEvent.getByToken(muToken, muHandle)) {
182  const auto& summary = *muHandle;
183  auto it = std::find_if(summary.begin(), summary.end(), [](const auto& s) { return s.getBunchCrossing() == 0; });
184 
185  if (it->getBunchCrossing() != 0) {
186  edm::LogError("OffsetAnalyzerDQM") << "Cannot find the in-time pileup info " << it->getBunchCrossing();
187  } else {
188  float mu = it->getTrueNumInteractions();
189  th1dPlots["mu"].fill(mu);
190  int_mu = mu + 0.5;
191  }
192  }
193  if (int_mu >= muHigh)
194  int_mu = muHigh - 1; // make sure int_mu won't lead to non-existing ME
195 
196  //create map of pftypes vs total energy / eta
197  std::map<std::string, std::vector<double>> m_pftype_etaE;
198  int nEta = etabins.size() - 1;
199  for (const auto& pftype : pftypes)
200  m_pftype_etaE[pftype].assign(nEta, 0.0);
201 
202  //pf particles//
204  iEvent.getByToken(pfToken, pfHandle);
205 
206  for (unsigned int i = 0, n = pfHandle->size(); i < n; i++) {
207  const auto& cand = pfHandle->at(i);
208 
209  int etaIndex = getEtaIndex(cand.eta());
210  std::string pftype = pdgMap[abs(cand.pdgId())];
211  if (etaIndex == -1 || pftype.empty())
212  continue;
213 
214  if (pftype == "chm") { //check charged hadrons ONLY
215  bool attached = false;
216 
217  for (unsigned int ipv = 0; ipv < nPVall && !attached; ipv++) {
218  if (isGoodPV[ipv] && cand.fromPV(ipv) == 3)
219  attached = true; //pv used in fit
220  }
221  if (!attached)
222  pftype = "chu"; //unmatched charged hadron
223  }
225  /*
226  reco::TrackRef candTrkRef( cand.trackRef() );
227  if ( pftype == "chm" && !candTrkRef.isNull() ) { //check charged hadrons ONLY
228  bool attached = false;
229 
230  for (auto ipv=vertexHandle->begin(), endpv=vertexHandle->end(); ipv != endpv && !attached; ++ipv) {
231  if ( !ipv->isFake() && ipv->ndof() >= 4 && fabs(ipv->z()) < 24 ) { //must be attached to a good pv
232 
233  for(auto ivtrk=ipv->tracks_begin(), endvtrk=ipv->tracks_end(); ivtrk != endvtrk && !attached; ++ivtrk) {
234  reco::TrackRef pvTrkRef(ivtrk->castTo<reco::TrackRef>());
235  if (pvTrkRef == candTrkRef) attached = true;
236  }
237  }
238  }
239  if (!attached) pftype = "chu"; //unmatched charged hadron
240  }
241 */
243  m_pftype_etaE[pftype][etaIndex] += cand.et();
244  }
245 
246  for (const auto& pair : m_pftype_etaE) {
247  std::string pftype = pair.first;
248  std::vector<double> etaE = pair.second;
249 
250  std::string offset_name_npv = offsetPlotBaseName + "_npv" + std::to_string(npv_in_range) + "_" + pftype;
251  if (offsetPlots.find(offset_name_npv) == offsetPlots.end())
252  return; //npv is out of range ()
253 
254  for (int i = 0; i < nEta; i++) {
255  double eta = 0.5 * (etabins[i] + etabins[i + 1]);
256  offsetPlots[offset_name_npv].fill2D(eta, etaE[i]);
257  }
258 
259  if (int_mu != -1) {
260  std::string offset_name_mu = offsetPlotBaseName + "_mu" + std::to_string(int_mu) + "_" + pftype;
261  if (offsetPlots.find(offset_name_mu) == offsetPlots.end())
262  return; //mu is out of range
263 
264  for (int i = 0; i < nEta; i++) {
265  double eta = 0.5 * (etabins[i] + etabins[i + 1]);
266  offsetPlots[offset_name_mu].fill2D(eta, etaE[i]);
267  }
268  }
269  }
270 }

References funct::abs(), PVValHelper::eta, etabins, getEtaIndex(), mps_fire::i, iEvent, amptDefaultParameters_cff::mu, muHigh, muToken, dqmiodumpmetadata::n, HLT_2018_cff::nEta, npvHigh, offsetPlotBaseName, offsetPlots, pdgMap, pfToken, pftypes, MetAnalyzer::pv(), pvToken, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, edmLumisInFiles::summary, and th1dPlots.

◆ bookHistograms()

void OffsetAnalyzerDQM::bookHistograms ( DQMStore::IBooker booker,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 142 of file OffsetAnalyzerDQM.cc.

142  {
143  //std::cout << "OffsetAnalyzerDQM booking offset histograms" << std::endl;
144  for (auto& pair : offsetPlots) {
145  pair.second.book(booker);
146  }
147  for (auto& pair : th1dPlots) {
148  pair.second.book(booker);
149  }
150 }

References offsetPlots, and th1dPlots.

◆ getEtaIndex()

int OffsetAnalyzerDQM::getEtaIndex ( float  eta)
protected

Definition at line 272 of file OffsetAnalyzerDQM.cc.

272  {
273  int nEta = etabins.size() - 1;
274 
275  for (int i = 0; i < nEta; i++) {
276  if (etabins[i] <= eta && eta < etabins[i + 1])
277  return i;
278  }
279  if (eta == etabins[nEta])
280  return nEta - 1;
281  else
282  return -1;
283 }

References PVValHelper::eta, etabins, mps_fire::i, and HLT_2018_cff::nEta.

Referenced by analyze().

Member Data Documentation

◆ etabins

std::vector<double> OffsetAnalyzerDQM::etabins
private

Definition at line 85 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), getEtaIndex(), and OffsetAnalyzerDQM().

◆ muHigh

int OffsetAnalyzerDQM::muHigh
private

Definition at line 87 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ muToken

edm::EDGetTokenT<edm::View<PileupSummaryInfo> > OffsetAnalyzerDQM::muToken
private

Definition at line 91 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ npvHigh

int OffsetAnalyzerDQM::npvHigh
private

Definition at line 88 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ offsetPlotBaseName

std::string OffsetAnalyzerDQM::offsetPlotBaseName
private

Definition at line 83 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ offsetPlots

std::map<std::string, PlotProfile> OffsetAnalyzerDQM::offsetPlots
private

Definition at line 80 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), bookHistograms(), and OffsetAnalyzerDQM().

◆ pdgMap

std::map<int, std::string> OffsetAnalyzerDQM::pdgMap
private

Definition at line 81 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ pfToken

edm::EDGetTokenT<edm::View<pat::PackedCandidate> > OffsetAnalyzerDQM::pfToken
private

Definition at line 92 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ pftypes

std::vector<std::string> OffsetAnalyzerDQM::pftypes
private

Definition at line 84 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ pvToken

edm::EDGetTokenT<edm::View<reco::Vertex> > OffsetAnalyzerDQM::pvToken
private

Definition at line 90 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), and OffsetAnalyzerDQM().

◆ th1dPlots

std::map<std::string, Plot1D> OffsetAnalyzerDQM::th1dPlots
private

Definition at line 79 of file OffsetAnalyzerDQM.cc.

Referenced by analyze(), bookHistograms(), and OffsetAnalyzerDQM().

mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
OffsetAnalyzerDQM::pftypes
std::vector< std::string > pftypes
Definition: OffsetAnalyzerDQM.cc:84
offsetAnalyzerDQM_cff.pdgKeys
pdgKeys
Definition: offsetAnalyzerDQM_cff.py:70
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
OffsetAnalyzerDQM::pfToken
edm::EDGetTokenT< edm::View< pat::PackedCandidate > > pfToken
Definition: OffsetAnalyzerDQM.cc:92
edm::Handle
Definition: AssociativeIterator.h:50
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
OffsetAnalyzerDQM::pdgMap
std::map< int, std::string > pdgMap
Definition: OffsetAnalyzerDQM.cc:81
PVValHelper::eta
Definition: PVValidationHelpers.h:69
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OffsetAnalyzerDQM::etabins
std::vector< double > etabins
Definition: OffsetAnalyzerDQM.cc:85
edm::LogError
Definition: MessageLogger.h:183
Plot1D
Definition: PlotTypes.h:4
cand
Definition: decayParser.h:34
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
HLT_2018_cff.nEta
nEta
Definition: HLT_2018_cff.py:5271
offsetAnalyzerDQM_cff.pdgStrs
pdgStrs
Definition: offsetAnalyzerDQM_cff.py:71
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
OffsetAnalyzerDQM::getEtaIndex
int getEtaIndex(float eta)
Definition: OffsetAnalyzerDQM.cc:272
OffsetAnalyzerDQM::muHigh
int muHigh
Definition: OffsetAnalyzerDQM.cc:87
OffsetAnalyzerDQM::npvHigh
int npvHigh
Definition: OffsetAnalyzerDQM.cc:88
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OffsetAnalyzerDQM::offsetPlotBaseName
std::string offsetPlotBaseName
Definition: OffsetAnalyzerDQM.cc:83
OffsetAnalyzerDQM::muToken
edm::EDGetTokenT< edm::View< PileupSummaryInfo > > muToken
Definition: OffsetAnalyzerDQM.cc:91
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
OffsetAnalyzerDQM::offsetPlots
std::map< std::string, PlotProfile > offsetPlots
Definition: OffsetAnalyzerDQM.cc:80
OffsetAnalyzerDQM::pvToken
edm::EDGetTokenT< edm::View< reco::Vertex > > pvToken
Definition: OffsetAnalyzerDQM.cc:90
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
OffsetAnalyzerDQM::th1dPlots
std::map< std::string, Plot1D > th1dPlots
Definition: OffsetAnalyzerDQM.cc:79
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23