CMS 3D CMS Logo

L1Comparator.h
Go to the documentation of this file.
1 #ifndef L1COMPARATOR_H
2 #define L1COMPARATOR_H
3 
4 /*\class L1Comparator
5  *\description L1 trigger data|emulation comparison and validation
6  *\author Nuno Leonardo (CERN)
7  *\date 07.02
8  */
9 
10 // common/system includes
11 #include <memory>
12 #include <string>
13 #include <iostream>
14 #include <fstream>
15 #include <iomanip>
16 #include <vector>
17 #include <algorithm>
18 #include <atomic>
28 
29 // l1 dataformats, d|e record includes
31 
32 // comparator template
34 
35 // db trigger/subsystem key access
37 //#include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
39 //#include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
40 
41 template <class T>
42 class DEcompare;
43 
44 class L1Comparator : public edm::global::EDProducer<edm::RunCache<std::array<bool, dedefs::DEnsys>>> {
45 public:
46  explicit L1Comparator(const edm::ParameterSet&);
47 
48 private:
49  using RunCache = std::array<bool, dedefs::DEnsys>;
50  std::shared_ptr<RunCache> globalBeginRun(edm::Run const&, const edm::EventSetup&) const final;
51  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
52  void globalEndRun(edm::Run const&, edm::EventSetup const&) const final {}
53  void endJob() override;
54 
55  struct EventInfo {
57  std::array<bool, dedefs::DEnsys> DEmatchEvt = {{true}};
58  std::array<std::array<int, 2>, dedefs::DEnsys> DEncand = {{{{0, 0}}}};
59  std::ostringstream dumpToFile_;
60  int nevt_;
61  int evtNum_;
62  int runNum_;
63  //flag whether event id has already been written to dumpFile
64  bool dumpEvent_ = true;
65  };
66 
67  template <class T>
68  void process(T const*, T const*, const int, const int, EventInfo& eventInfo) const;
69  template <class T>
70  void process(
71  const edm::Handle<T> data, const edm::Handle<T> emul, const int sys, const int cid, EventInfo& eventInfo) const {
72  if (data.isValid() && emul.isValid())
73  process(data.product(), emul.product(), sys, cid, eventInfo);
74  }
75 
76  template <class T>
77  bool CompareCollections(edm::Handle<T> data, edm::Handle<T> emul, std::ostream&) const;
78  template <class T>
79  bool dumpCandidate(const T& dt, const T& em, std::ostream& s) const;
80 
81  int verbose() const { return verbose_; }
82  const bool m_stage1_layer2_;
83 
84 private:
85  mutable std::atomic<int> nevt_;
86  const int verbose_;
87 
111 
113 
114  const std::array<bool, dedefs::DEnsys> m_doSys;
116  CMS_THREAD_GUARD(m_fileGuard) mutable std::ofstream m_dumpFile;
117  const int m_dumpMode;
119  mutable std::atomic<bool> m_match;
120 };
121 
122 #endif
edm::StreamID
Definition: StreamID.h:30
L1DEDigiCollection
std::vector< L1DataEmulDigi > L1DEDigiCollection
Definition: DEtrait.h:101
L1Comparator::m_fileGuard
std::mutex m_fileGuard
Definition: L1Comparator.h:118
L1Comparator::EventInfo::dumpToFile_
std::ostringstream dumpToFile_
Definition: L1Comparator.h:59
MessageLogger.h
L1Comparator::verbose_
const int verbose_
Definition: L1Comparator.h:86
edm::Run
Definition: Run.h:45
L1Comparator::tokenGctEtTotal_
edm::EDGetTokenT< L1GctEtTotalCollection > tokenGctEtTotal_[2]
Definition: L1Comparator.h:96
L1Comparator::tokenCaloEm_
edm::EDGetTokenT< L1CaloEmCollection > tokenCaloEm_[2]
Definition: L1Comparator.h:88
edm::EDGetTokenT< L1CaloEmCollection >
L1Comparator::EventInfo::evtNum_
int evtNum_
Definition: L1Comparator.h:61
L1Comparator::process
void process(const edm::Handle< T > data, const edm::Handle< T > emul, const int sys, const int cid, EventInfo &eventInfo) const
Definition: L1Comparator.h:70
L1Comparator::tokenMuDTChambPh_
edm::EDGetTokenT< L1MuDTChambPhContainer > tokenMuDTChambPh_[2]
Definition: L1Comparator.h:103
L1Comparator::globalBeginRun
std::shared_ptr< RunCache > globalBeginRun(edm::Run const &, const edm::EventSetup &) const final
Definition: L1Comparator.cc:193
L1Comparator::tokenGctJetCand_cenJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_cenJets_[2]
Definition: L1Comparator.h:92
L1Comparator::tokenTriggerKey_
const edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > tokenTriggerKey_
Definition: L1Comparator.h:112
DEcompare
Definition: DEcompare.h:25
L1Comparator::tokenGctJetCand_forJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_forJets_[2]
Definition: L1Comparator.h:93
L1Comparator::nevt_
std::atomic< int > nevt_
Definition: L1Comparator.h:85
L1Comparator::tokenMuReadoutCand_
edm::EDGetTokenT< L1MuGMTReadoutCollection > tokenMuReadoutCand_[2]
Definition: L1Comparator.h:110
L1Comparator::tokenGctHtMiss_
edm::EDGetTokenT< L1GctHtMissCollection > tokenGctHtMiss_[2]
Definition: L1Comparator.h:101
L1Comparator::tokenCaloRegion_
edm::EDGetTokenT< L1CaloRegionCollection > tokenCaloRegion_[2]
Definition: L1Comparator.h:89
edm::Handle
Definition: AssociativeIterator.h:50
L1Comparator::tokenGctHFRingEtSums_
edm::EDGetTokenT< L1GctHFRingEtSumsCollection > tokenGctHFRingEtSums_[2]
Definition: L1Comparator.h:99
ESGetToken.h
L1Comparator::process
void process(T const *, T const *, const int, const int, EventInfo &eventInfo) const
Definition: L1Comparator.cc:768
L1Comparator::endJob
void endJob() override
Definition: L1Comparator.cc:241
L1Comparator::m_dumpFile
std::ofstream m_dumpFile
Definition: L1Comparator.h:116
DEcompare.h
dt
float dt
Definition: AMPTWrapper.h:136
MakerMacros.h
L1Comparator::EventInfo::m_dedigis
L1DEDigiCollection m_dedigis
Definition: L1Comparator.h:56
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1Comparator::tokenGctJetCand_isoTauJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_isoTauJets_[2]
Definition: L1Comparator.h:95
L1Comparator::L1Comparator
L1Comparator(const edm::ParameterSet &)
Definition: L1Comparator.cc:29
L1TriggerKey.h
Service.h
L1Comparator::m_dumpMode
const int m_dumpMode
Definition: L1Comparator.h:117
L1Comparator::tokenMuGMTCand_
edm::EDGetTokenT< L1MuGMTCandCollection > tokenMuGMTCand_[2]
Definition: L1Comparator.h:109
L1Comparator::tokenMuDTTrack_
edm::EDGetTokenT< L1MuDTTrackContainer > tokenMuDTTrack_[2]
Definition: L1Comparator.h:106
L1Comparator::globalEndRun
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
Definition: L1Comparator.h:52
L1Comparator::verbose
int verbose() const
Definition: L1Comparator.h:81
L1Comparator::tokenLTCDigi_
edm::EDGetTokenT< LTCDigiCollection > tokenLTCDigi_[2]
Definition: L1Comparator.h:105
L1Comparator::EventInfo::DEncand
std::array< std::array< int, 2 >, dedefs::DEnsys > DEncand
Definition: L1Comparator.h:58
L1Comparator::m_match
std::atomic< bool > m_match
Definition: L1Comparator.h:119
EDGetToken.h
L1Comparator::EventInfo::DEmatchEvt
std::array< bool, dedefs::DEnsys > DEmatchEvt
Definition: L1Comparator.h:57
L1Comparator::m_doSys
const std::array< bool, dedefs::DEnsys > m_doSys
Definition: L1Comparator.h:114
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
L1Comparator::tokenGctEmCand_nonIsoEm_
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_nonIsoEm_[2]
Definition: L1Comparator.h:91
Event.h
L1Comparator
Definition: L1Comparator.h:44
L1Comparator::EventInfo::runNum_
int runNum_
Definition: L1Comparator.h:62
mutex
static std::mutex mutex
Definition: Proxy.cc:8
DEtrait.h
edm::EventSetup
Definition: EventSetup.h:58
L1Comparator::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: L1Comparator.cc:248
L1Comparator::tokenGctEtHad_
edm::EDGetTokenT< L1GctEtHadCollection > tokenGctEtHad_[2]
Definition: L1Comparator.h:97
L1TriggerKeyRcd.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd >
L1Comparator::tokenGctEtMiss_
edm::EDGetTokenT< L1GctEtMissCollection > tokenGctEtMiss_[2]
Definition: L1Comparator.h:98
dedefs::DEnsys
const int DEnsys
Definition: DEtrait.h:38
L1Comparator::tokenGctEmCand_isoEm_
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_isoEm_[2]
Definition: L1Comparator.h:90
dumpTauVariables_cfi.eventInfo
eventInfo
add run, event number and lumi section
Definition: dumpTauVariables_cfi.py:12
L1Comparator::tokenMuRegionalCandRPCf_
edm::EDGetTokenT< L1MuRegionalCandCollection > tokenMuRegionalCandRPCf_[2]
Definition: L1Comparator.h:108
L1Comparator::tokenGctJetCounts_
edm::EDGetTokenT< L1GctJetCountsCollection > tokenGctJetCounts_[2]
Definition: L1Comparator.h:102
L1TdeGEMTPG_cfi.emul
emul
Definition: L1TdeGEMTPG_cfi.py:21
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
L1Comparator::tokenMuDTChambTh_
edm::EDGetTokenT< L1MuDTChambThContainer > tokenMuDTChambTh_[2]
Definition: L1Comparator.h:104
L1Comparator::tokenGctHFBitCounts_
edm::EDGetTokenT< L1GctHFBitCountsCollection > tokenGctHFBitCounts_[2]
Definition: L1Comparator.h:100
L1Comparator::tokenGctJetCand_tauJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_tauJets_[2]
Definition: L1Comparator.h:94
L1Comparator::m_stage1_layer2_
const bool m_stage1_layer2_
Definition: L1Comparator.h:82
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
L1Comparator::CompareCollections
bool CompareCollections(edm::Handle< T > data, edm::Handle< T > emul, std::ostream &) const
L1Comparator::EventInfo
Definition: L1Comparator.h:55
ParameterSet.h
L1Comparator::dumpCandidate
bool dumpCandidate(const T &dt, const T &em, std::ostream &s) const
Definition: L1Comparator.cc:888
EDProducer.h
L1Comparator::EventInfo::dumpEvent_
bool dumpEvent_
Definition: L1Comparator.h:64
L1Comparator::m_dumpFileName
const std::string m_dumpFileName
Definition: L1Comparator.h:115
edm::Event
Definition: Event.h:73
L1Comparator::EventInfo::nevt_
int nevt_
Definition: L1Comparator.h:60
CMS_THREAD_GUARD
#define CMS_THREAD_GUARD(_var_)
Definition: thread_safety_macros.h:6
L1Comparator::RunCache
std::array< bool, dedefs::DEnsys > RunCache
Definition: L1Comparator.h:49
L1Comparator::tokenMuRegionalCandRPCb_
edm::EDGetTokenT< L1MuRegionalCandCollection > tokenMuRegionalCandRPCb_[2]
Definition: L1Comparator.h:107