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>
27 
28 // l1 dataformats, d|e record includes
30 
31 // comparator template
33 
34 // db trigger/subsystem key access
36 //#include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
38 //#include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
39 
40 template <class T>
41 class DEcompare;
42 
43 class L1Comparator : public edm::global::EDProducer<edm::RunCache<std::array<bool, dedefs::DEnsys>>> {
44 public:
45  explicit L1Comparator(const edm::ParameterSet&);
46 
47 private:
48  using RunCache = std::array<bool, dedefs::DEnsys>;
49  std::shared_ptr<RunCache> globalBeginRun(edm::Run const&, const edm::EventSetup&) const final;
50  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
51  void globalEndRun(edm::Run const&, edm::EventSetup const&) const final {}
52  void endJob() override;
53 
54  struct EventInfo {
56  std::array<bool, dedefs::DEnsys> DEmatchEvt = {{true}};
57  std::array<std::array<int, 2>, dedefs::DEnsys> DEncand = {{{{0, 0}}}};
58  std::ostringstream dumpToFile_;
59  int nevt_;
60  int evtNum_;
61  int runNum_;
62  //flag whether event id has already been written to dumpFile
63  bool dumpEvent_ = true;
64  };
65 
66  template <class T>
67  void process(T const*, T const*, const int, const int, EventInfo& eventInfo) const;
68  template <class T>
69  void process(
70  const edm::Handle<T> data, const edm::Handle<T> emul, const int sys, const int cid, EventInfo& eventInfo) const {
71  if (data.isValid() && emul.isValid())
72  process(data.product(), emul.product(), sys, cid, eventInfo);
73  }
74 
75  template <class T>
76  bool CompareCollections(edm::Handle<T> data, edm::Handle<T> emul, std::ostream&) const;
77  template <class T>
78  bool dumpCandidate(const T& dt, const T& em, std::ostream& s) const;
79 
80  int verbose() const { return verbose_; }
81  const bool m_stage1_layer2_;
82 
83 private:
84  mutable std::atomic<int> nevt_;
85  const int verbose_;
86 
110 
111  const std::array<bool, dedefs::DEnsys> m_doSys;
113  CMS_THREAD_GUARD(m_fileGuard) mutable std::ofstream m_dumpFile;
114  const int m_dumpMode;
116  mutable std::atomic<bool> m_match;
117 };
118 
119 #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:115
L1Comparator::EventInfo::dumpToFile_
std::ostringstream dumpToFile_
Definition: L1Comparator.h:58
MessageLogger.h
L1Comparator::verbose_
const int verbose_
Definition: L1Comparator.h:85
edm::Run
Definition: Run.h:45
L1Comparator::tokenGctEtTotal_
edm::EDGetTokenT< L1GctEtTotalCollection > tokenGctEtTotal_[2]
Definition: L1Comparator.h:95
L1Comparator::tokenCaloEm_
edm::EDGetTokenT< L1CaloEmCollection > tokenCaloEm_[2]
Definition: L1Comparator.h:87
edm::EDGetTokenT< L1CaloEmCollection >
L1Comparator::EventInfo::evtNum_
int evtNum_
Definition: L1Comparator.h:60
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:69
L1Comparator::tokenMuDTChambPh_
edm::EDGetTokenT< L1MuDTChambPhContainer > tokenMuDTChambPh_[2]
Definition: L1Comparator.h:102
L1Comparator::globalBeginRun
std::shared_ptr< RunCache > globalBeginRun(edm::Run const &, const edm::EventSetup &) const final
Definition: L1Comparator.cc:192
L1Comparator::tokenGctJetCand_cenJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_cenJets_[2]
Definition: L1Comparator.h:91
DEcompare
Definition: DEcompare.h:25
L1Comparator::tokenGctJetCand_forJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_forJets_[2]
Definition: L1Comparator.h:92
L1Comparator::nevt_
std::atomic< int > nevt_
Definition: L1Comparator.h:84
L1Comparator::tokenMuReadoutCand_
edm::EDGetTokenT< L1MuGMTReadoutCollection > tokenMuReadoutCand_[2]
Definition: L1Comparator.h:109
L1Comparator::tokenGctHtMiss_
edm::EDGetTokenT< L1GctHtMissCollection > tokenGctHtMiss_[2]
Definition: L1Comparator.h:100
L1Comparator::tokenCaloRegion_
edm::EDGetTokenT< L1CaloRegionCollection > tokenCaloRegion_[2]
Definition: L1Comparator.h:88
edm::Handle
Definition: AssociativeIterator.h:50
L1Comparator::tokenGctHFRingEtSums_
edm::EDGetTokenT< L1GctHFRingEtSumsCollection > tokenGctHFRingEtSums_[2]
Definition: L1Comparator.h:98
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:113
DEcompare.h
dt
float dt
Definition: AMPTWrapper.h:136
MakerMacros.h
L1Comparator::EventInfo::m_dedigis
L1DEDigiCollection m_dedigis
Definition: L1Comparator.h:55
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1Comparator::tokenGctJetCand_isoTauJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_isoTauJets_[2]
Definition: L1Comparator.h:94
L1Comparator::L1Comparator
L1Comparator(const edm::ParameterSet &)
Definition: L1Comparator.cc:29
L1TriggerKey.h
Service.h
L1Comparator::m_dumpMode
const int m_dumpMode
Definition: L1Comparator.h:114
L1Comparator::tokenMuGMTCand_
edm::EDGetTokenT< L1MuGMTCandCollection > tokenMuGMTCand_[2]
Definition: L1Comparator.h:108
L1Comparator::tokenMuDTTrack_
edm::EDGetTokenT< L1MuDTTrackContainer > tokenMuDTTrack_[2]
Definition: L1Comparator.h:105
L1Comparator::globalEndRun
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
Definition: L1Comparator.h:51
L1Comparator::verbose
int verbose() const
Definition: L1Comparator.h:80
L1Comparator::tokenLTCDigi_
edm::EDGetTokenT< LTCDigiCollection > tokenLTCDigi_[2]
Definition: L1Comparator.h:104
L1Comparator::EventInfo::DEncand
std::array< std::array< int, 2 >, dedefs::DEnsys > DEncand
Definition: L1Comparator.h:57
L1Comparator::m_match
std::atomic< bool > m_match
Definition: L1Comparator.h:116
EDGetToken.h
L1Comparator::EventInfo::DEmatchEvt
std::array< bool, dedefs::DEnsys > DEmatchEvt
Definition: L1Comparator.h:56
L1Comparator::m_doSys
const std::array< bool, dedefs::DEnsys > m_doSys
Definition: L1Comparator.h:111
edm::global::EDProducer
Definition: EDProducer.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
L1Comparator::tokenGctEmCand_nonIsoEm_
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_nonIsoEm_[2]
Definition: L1Comparator.h:90
Event.h
L1Comparator
Definition: L1Comparator.h:43
L1Comparator::EventInfo::runNum_
int runNum_
Definition: L1Comparator.h:61
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:96
L1TriggerKeyRcd.h
L1Comparator::tokenGctEtMiss_
edm::EDGetTokenT< L1GctEtMissCollection > tokenGctEtMiss_[2]
Definition: L1Comparator.h:97
dedefs::DEnsys
const int DEnsys
Definition: DEtrait.h:38
L1Comparator::tokenGctEmCand_isoEm_
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_isoEm_[2]
Definition: L1Comparator.h:89
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:107
L1Comparator::tokenGctJetCounts_
edm::EDGetTokenT< L1GctJetCountsCollection > tokenGctJetCounts_[2]
Definition: L1Comparator.h:101
L1TdeGEMTPG_cfi.emul
emul
Definition: L1TdeGEMTPG_cfi.py:7
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
L1Comparator::tokenMuDTChambTh_
edm::EDGetTokenT< L1MuDTChambThContainer > tokenMuDTChambTh_[2]
Definition: L1Comparator.h:103
L1Comparator::tokenGctHFBitCounts_
edm::EDGetTokenT< L1GctHFBitCountsCollection > tokenGctHFBitCounts_[2]
Definition: L1Comparator.h:99
L1Comparator::tokenGctJetCand_tauJets_
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_tauJets_[2]
Definition: L1Comparator.h:93
L1Comparator::m_stage1_layer2_
const bool m_stage1_layer2_
Definition: L1Comparator.h:81
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:54
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:63
L1Comparator::m_dumpFileName
const std::string m_dumpFileName
Definition: L1Comparator.h:112
edm::Event
Definition: Event.h:73
L1Comparator::EventInfo::nevt_
int nevt_
Definition: L1Comparator.h:59
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:48
L1Comparator::tokenMuRegionalCandRPCb_
edm::EDGetTokenT< L1MuRegionalCandCollection > tokenMuRegionalCandRPCb_[2]
Definition: L1Comparator.h:106