CMS 3D CMS Logo

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

Public Member Functions

 CSCTnPEfficiencyTask (const edm::ParameterSet &config)
 Constructor. More...
 
 ~CSCTnPEfficiencyTask () override
 Destructor. More...
 
- Public Member Functions inherited from BaseTnPEfficiencyTask
 BaseTnPEfficiencyTask (const edm::ParameterSet &config)
 Constructor. More...
 
 ~BaseTnPEfficiencyTask () override
 Destructor. More...
 
- 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
 
 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 analyze (const edm::Event &event, const edm::EventSetup &context) override
 Analyze. More...
 
void bookHistograms (DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &context) override
 
std::string topFolder () const override
 Return the top folder. More...
 
- Protected Member Functions inherited from BaseTnPEfficiencyTask
void dqmBeginRun (const edm::Run &run, const edm::EventSetup &context) override
 BeginRun. More...
 
bool hasTrigger (std::vector< int > &trigIndices, const trigger::TriggerObjectCollection &trigObjs, edm::Handle< trigger::TriggerEvent > &trigEvent, const reco::Muon &muon)
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

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< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from BaseTnPEfficiencyTask
const double m_borderCut
 
const bool m_detailedAnalysis
 
const double m_dxCut
 
std::map< std::string, MonitorElement * > m_histos
 
const edm::EDGetTokenT< reco::MuonCollectionm_muToken
 
int m_nEvents
 
std::vector< std::vector< unsigned > > m_probeIndices
 
std::vector< std::vector< unsigned > > m_tagIndices
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 14 of file CSCTnPEfficiencyTask.cc.

Constructor & Destructor Documentation

◆ CSCTnPEfficiencyTask()

CSCTnPEfficiencyTask::CSCTnPEfficiencyTask ( const edm::ParameterSet config)

Constructor.

Definition at line 31 of file CSCTnPEfficiencyTask.cc.

References LogTrace.

32  LogTrace("DQMOffline|MuonDPG|CSCTnPEfficiencyTask") << "[CSCTnPEfficiencyTask]: Constructor" << std::endl;
33 }
Definition: config.py:1
#define LogTrace(id)
BaseTnPEfficiencyTask(const edm::ParameterSet &config)
Constructor.

◆ ~CSCTnPEfficiencyTask()

CSCTnPEfficiencyTask::~CSCTnPEfficiencyTask ( )
override

Destructor.

Definition at line 35 of file CSCTnPEfficiencyTask.cc.

References LogTrace, and BaseTnPEfficiencyTask::m_nEvents.

35  {
36  LogTrace("DQMOffline|MuonDPG|CSCTnPEfficiencyTask")
37  << "[CSCTnPEfficiencyTask]: analyzed " << m_nEvents << " events" << std::endl;
38 }
#define LogTrace(id)

Member Function Documentation

◆ analyze()

void CSCTnPEfficiencyTask::analyze ( const edm::Event event,
const edm::EventSetup context 
)
overrideprotectedvirtual

Analyze.

Reimplemented from BaseTnPEfficiencyTask.

Definition at line 115 of file CSCTnPEfficiencyTask.cc.

References funct::abs(), BaseTnPEfficiencyTask::analyze(), visDQMUpload::context, MuonSubdetId::CSC, PVValHelper::dx, mps_fire::i, dqmiolumiharvest::j, BaseTnPEfficiencyTask::m_borderCut, BaseTnPEfficiencyTask::m_detailedAnalysis, BaseTnPEfficiencyTask::m_dxCut, BaseTnPEfficiencyTask::m_histos, BaseTnPEfficiencyTask::m_muToken, BaseTnPEfficiencyTask::m_probeIndices, PDWG_BPHSkim_cff::muons, relativeConstraints::ring, relativeConstraints::station, and CSCDetId::zendcap().

115  {
117 
119  event.getByToken(m_muToken, muons);
120 
121  //CSC variables
122  std::vector<std::vector<int>> probe_coll_CSC_zend;
123  std::vector<std::vector<int>> probe_coll_CSC_ring;
124  std::vector<std::vector<int>> probe_coll_CSC_sta;
125  std::vector<std::vector<float>> probe_coll_CSC_dx;
126  std::vector<uint8_t> probe_coll_CSC_staMatch;
127 
128  std::vector<unsigned> probe_indices;
129  if (!m_probeIndices.empty())
130  probe_indices = m_probeIndices.back();
131 
132  //Fill probe dx + subdetector coordinates
133  for (const auto i : probe_indices) {
134  //CSC variables
135  std::vector<int> probe_CSC_zend;
136  std::vector<int> probe_CSC_ring;
137  std::vector<int> probe_CSC_sta;
138  std::vector<float> probe_CSC_dx;
139  uint8_t CSC_stationMatching = 0;
140 
141  float csc_matched = false; // fill detailed plots only for probes matching CSC
142 
143  for (const auto& chambMatch : (*muons).at(i).matches()) {
144  // look in CSCs
145  if (chambMatch.detector() == MuonSubdetId::CSC) {
146  if (chambMatch.edgeX < m_borderCut && chambMatch.edgeY < m_borderCut) {
147  csc_matched = true; //fill detailed plots if at least one CSC match
148 
149  CSCDetId chId(chambMatch.id.rawId());
150 
151  int zendcap = chId.zendcap();
152  int ring = chId.ring();
153  int station = chId.station();
154 
155  reco::MuonSegmentMatch closest_matchedSegment;
156  double smallestDx = 99999.;
157  for (auto& seg : chambMatch.segmentMatches) {
158  float dx = std::abs(chambMatch.x - seg.x);
159  if (dx < smallestDx) {
160  smallestDx = dx;
161  closest_matchedSegment = seg;
162  }
163  }
164 
165  CSC_stationMatching = CSC_stationMatching | (1 << (station - 1));
166 
167  if (station == 1 && ring == 4 && chambMatch.y < -31.5) {
168  probe_CSC_zend.push_back(zendcap);
169  probe_CSC_ring.push_back(ring);
170  probe_CSC_sta.push_back(station);
171  probe_CSC_dx.push_back(smallestDx);
172  } else if (station == 1 && ring == 1 && chambMatch.y > -31.5) {
173  probe_CSC_zend.push_back(zendcap);
174  probe_CSC_ring.push_back(ring);
175  probe_CSC_sta.push_back(station);
176  probe_CSC_dx.push_back(smallestDx);
177  } else if (station > 1 || ring == 2 || ring == 3) {
178  probe_CSC_zend.push_back(zendcap);
179  probe_CSC_ring.push_back(ring);
180  probe_CSC_sta.push_back(station);
181  probe_CSC_dx.push_back(smallestDx);
182  }
183  }
184  } else
185  continue;
186  } //loop over chamber matches
187 
188  //Fill detailed plots
189  if (m_detailedAnalysis && csc_matched) {
190  m_histos.find("probeEta")->second->Fill((*muons).at(i).eta());
191  m_histos.find("probePhi")->second->Fill((*muons).at(i).phi());
192  m_histos.find("probeNumberOfMatchedStations")->second->Fill((*muons).at(i).numberOfMatchedStations());
193  m_histos.find("probePt")->second->Fill((*muons).at(i).pt());
194  }
195 
196  //Fill CSC variables
197  probe_coll_CSC_zend.push_back(probe_CSC_zend);
198  probe_coll_CSC_ring.push_back(probe_CSC_ring);
199  probe_coll_CSC_sta.push_back(probe_CSC_sta);
200  probe_coll_CSC_dx.push_back(probe_CSC_dx);
201  probe_coll_CSC_staMatch.push_back(CSC_stationMatching);
202  } //loop over probe collection
203 
204  //Loop over probes
205  for (unsigned i = 0; i < probe_indices.size(); ++i) {
206  uint8_t CSC_matchPatt = probe_coll_CSC_staMatch.at(i);
207 
208  //Loop over CSC matches
209  unsigned nCSC_matches = probe_coll_CSC_zend.at(i).size();
210  for (unsigned j = 0; j < nCSC_matches; ++j) {
211  int CSC_zendcap = probe_coll_CSC_zend.at(i).at(j);
212  int CSC_sta = probe_coll_CSC_sta.at(i).at(j);
213  int CSC_ring = probe_coll_CSC_ring.at(i).at(j);
214  float CSC_dx = probe_coll_CSC_dx.at(i).at(j);
215 
216  //Fill CSC plots
217  if ((CSC_matchPatt & (1 << (CSC_sta - 1))) != 0 && //avoids 0 station matching
218  (CSC_matchPatt & (1 << (CSC_sta - 1))) !=
219  CSC_matchPatt) //avoids matching with the station under consideration only
220  {
221  if (CSC_dx < m_dxCut) {
222  m_histos.find("CSC_nPassingProbe_allCh")->second->Fill(CSC_zendcap * CSC_sta, CSC_ring);
223  m_histos.find("CSC_nPassingProbe_allCh_1D")->second->Fill(CSC_zendcap * CSC_sta);
224  } else {
225  m_histos.find("CSC_nFailingProbe_allCh")->second->Fill(CSC_zendcap * CSC_sta, CSC_ring);
226  m_histos.find("CSC_nFailingProbe_allCh_1D")->second->Fill(CSC_zendcap * CSC_sta);
227  }
228  }
229  }
230  }
231 }
short int zendcap() const
Definition: CSCDetId.h:91
const edm::EDGetTokenT< reco::MuonCollection > m_muToken
std::vector< std::vector< unsigned > > m_probeIndices
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< std::string, MonitorElement * > m_histos
void analyze(const edm::Event &event, const edm::EventSetup &context) override
Analyze.
static constexpr int CSC
Definition: MuonSubdetId.h:12
Definition: event.py:1

◆ bookHistograms()

void CSCTnPEfficiencyTask::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  run,
edm::EventSetup const &  context 
)
overrideprotectedvirtual

Reimplemented from BaseTnPEfficiencyTask.

Definition at line 40 of file CSCTnPEfficiencyTask.cc.

References ALCARECODTCalibSynchDQM_cff::baseDir, dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), BaseTnPEfficiencyTask::bookHistograms(), visDQMUpload::context, mps_fire::i, LogTrace, BaseTnPEfficiencyTask::m_histos, writedatasetfile::run, dqm::impl::MonitorElement::setAxisTitle(), dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::NavigatorBase::setCurrentFolder(), cond::impl::to_string(), and topFolder().

42  {
44 
45  LogTrace("DQMOffline|MuonDPG|CSCTnPEfficiencyTask") << "[CSCTnPEfficiencyTask]: bookHistograms" << std::endl;
46 
47  auto baseDir = topFolder() + "Task/";
48  iBooker.setCurrentFolder(baseDir);
49 
50  MonitorElement* me_CSC_pass_allCh =
51  iBooker.book2D("CSC_nPassingProbe_allCh", "CSC_nPassingProbe_allCh", 9, -4., 5., 4, 0., 4.5);
52  MonitorElement* me_CSC_fail_allCh =
53  iBooker.book2D("CSC_nFailingProbe_allCh", "CSC_nFailingProbe_allCh", 9, -4., 5., 4, 0., 4.5);
54 
55  MonitorElement* me_CSC_pass_allCh_1D =
56  iBooker.book1D("CSC_nPassingProbe_allCh_1D", "CSC_nPassingProbe_allCh_1D", 9, -4., 5.);
57  MonitorElement* me_CSC_fail_allCh_1D =
58  iBooker.book1D("CSC_nFailingProbe_allCh_1D", "CSC_nFailingProbe_allCh_1D", 9, -4., 5.);
59 
60  me_CSC_pass_allCh->setBinLabel(1, "ME-4", 1);
61  me_CSC_pass_allCh->setBinLabel(2, "ME-3", 1);
62  me_CSC_pass_allCh->setBinLabel(3, "ME-2", 1);
63  me_CSC_pass_allCh->setBinLabel(4, "ME-1", 1);
64  me_CSC_pass_allCh->setBinLabel(6, "ME1", 1);
65  me_CSC_pass_allCh->setBinLabel(7, "ME2", 1);
66  me_CSC_pass_allCh->setBinLabel(8, "ME3", 1);
67  me_CSC_pass_allCh->setBinLabel(9, "ME4", 1);
68  for (int i = 1; i < 5; ++i) {
69  me_CSC_pass_allCh->setBinLabel(i, std::to_string(i), 2);
70  }
71  me_CSC_pass_allCh->setAxisTitle("Ring", 2);
72  me_CSC_pass_allCh->setAxisTitle("Number of passing probes", 3);
73 
74  me_CSC_fail_allCh->setBinLabel(1, "ME-4", 1);
75  me_CSC_fail_allCh->setBinLabel(2, "ME-3", 1);
76  me_CSC_fail_allCh->setBinLabel(3, "ME-2", 1);
77  me_CSC_fail_allCh->setBinLabel(4, "ME-1", 1);
78  me_CSC_fail_allCh->setBinLabel(6, "ME1", 1);
79  me_CSC_fail_allCh->setBinLabel(7, "ME2", 1);
80  me_CSC_fail_allCh->setBinLabel(8, "ME3", 1);
81  me_CSC_fail_allCh->setBinLabel(9, "ME4", 1);
82  for (int i = 1; i < 5; ++i) {
83  me_CSC_fail_allCh->setBinLabel(i, std::to_string(i), 2);
84  }
85  me_CSC_fail_allCh->setAxisTitle("Ring", 2);
86  me_CSC_fail_allCh->setAxisTitle("Number of failing probes", 3);
87 
88  me_CSC_pass_allCh_1D->setBinLabel(1, "ME-4", 1);
89  me_CSC_pass_allCh_1D->setBinLabel(2, "ME-3", 1);
90  me_CSC_pass_allCh_1D->setBinLabel(3, "ME-2", 1);
91  me_CSC_pass_allCh_1D->setBinLabel(4, "ME-1", 1);
92  me_CSC_pass_allCh_1D->setBinLabel(6, "ME1", 1);
93  me_CSC_pass_allCh_1D->setBinLabel(7, "ME2", 1);
94  me_CSC_pass_allCh_1D->setBinLabel(8, "ME3", 1);
95  me_CSC_pass_allCh_1D->setBinLabel(9, "ME4", 1);
96  me_CSC_pass_allCh_1D->setAxisTitle("Number of passing probes", 2);
97 
98  me_CSC_fail_allCh_1D->setBinLabel(1, "ME-4", 1);
99  me_CSC_fail_allCh_1D->setBinLabel(2, "ME-3", 1);
100  me_CSC_fail_allCh_1D->setBinLabel(3, "ME-2", 1);
101  me_CSC_fail_allCh_1D->setBinLabel(4, "ME-1", 1);
102  me_CSC_fail_allCh_1D->setBinLabel(6, "ME1", 1);
103  me_CSC_fail_allCh_1D->setBinLabel(7, "ME2", 1);
104  me_CSC_fail_allCh_1D->setBinLabel(8, "ME3", 1);
105  me_CSC_fail_allCh_1D->setBinLabel(9, "ME4", 1);
106  me_CSC_fail_allCh_1D->setAxisTitle("Number of failing probes", 2);
107 
108  m_histos["CSC_nPassingProbe_allCh"] = me_CSC_pass_allCh;
109  m_histos["CSC_nFailingProbe_allCh"] = me_CSC_fail_allCh;
110 
111  m_histos["CSC_nPassingProbe_allCh_1D"] = me_CSC_pass_allCh_1D;
112  m_histos["CSC_nFailingProbe_allCh_1D"] = me_CSC_fail_allCh_1D;
113 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::string to_string(const V &value)
Definition: OMSAccess.h:71
#define LogTrace(id)
std::string topFolder() const override
Return the top folder.
std::map< std::string, MonitorElement * > m_histos
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &context) override
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)

◆ topFolder()

std::string CSCTnPEfficiencyTask::topFolder ( ) const
overrideprotectedvirtual

Return the top folder.

Implements BaseTnPEfficiencyTask.

Definition at line 233 of file CSCTnPEfficiencyTask.cc.

Referenced by bookHistograms().

233 { return "CSC/Segment_TnP/"; };