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
std::shared_ptr< RunCache > globalBeginRun(edm::Run const &, const edm::EventSetup &) const final
const edm::ESGetToken< L1TriggerKey, L1TriggerKeyRcd > tokenTriggerKey_
Definition: L1Comparator.h:112
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_nonIsoEm_[2]
Definition: L1Comparator.h:91
float dt
Definition: AMPTWrapper.h:136
edm::EDGetTokenT< LTCDigiCollection > tokenLTCDigi_[2]
Definition: L1Comparator.h:105
const int DEnsys
Definition: DEtrait.h:38
edm::EDGetTokenT< L1GctEtHadCollection > tokenGctEtHad_[2]
Definition: L1Comparator.h:97
edm::EDGetTokenT< L1MuRegionalCandCollection > tokenMuRegionalCandRPCb_[2]
Definition: L1Comparator.h:107
L1Comparator(const edm::ParameterSet &)
Definition: L1Comparator.cc:29
static std::mutex mutex
Definition: Proxy.cc:8
edm::EDGetTokenT< L1GctJetCountsCollection > tokenGctJetCounts_[2]
Definition: L1Comparator.h:102
std::mutex m_fileGuard
Definition: L1Comparator.h:118
edm::EDGetTokenT< L1GctEtMissCollection > tokenGctEtMiss_[2]
Definition: L1Comparator.h:98
edm::EDGetTokenT< L1GctHFBitCountsCollection > tokenGctHFBitCounts_[2]
Definition: L1Comparator.h:100
edm::EDGetTokenT< L1MuDTChambThContainer > tokenMuDTChambTh_[2]
Definition: L1Comparator.h:104
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_tauJets_[2]
Definition: L1Comparator.h:94
std::vector< L1DataEmulDigi > L1DEDigiCollection
Definition: DEtrait.h:101
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
std::atomic< int > nevt_
Definition: L1Comparator.h:85
bool CompareCollections(edm::Handle< T > data, edm::Handle< T > emul, std::ostream &) const
bool dumpCandidate(const T &dt, const T &em, std::ostream &s) const
edm::EDGetTokenT< L1MuGMTReadoutCollection > tokenMuReadoutCand_[2]
Definition: L1Comparator.h:110
const std::string m_dumpFileName
Definition: L1Comparator.h:115
std::array< bool, dedefs::DEnsys > RunCache
Definition: L1Comparator.h:49
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_isoTauJets_[2]
Definition: L1Comparator.h:95
#define CMS_THREAD_GUARD(_var_)
const int verbose_
Definition: L1Comparator.h:86
edm::EDGetTokenT< L1MuRegionalCandCollection > tokenMuRegionalCandRPCf_[2]
Definition: L1Comparator.h:108
edm::EDGetTokenT< L1GctEtTotalCollection > tokenGctEtTotal_[2]
Definition: L1Comparator.h:96
edm::EDGetTokenT< L1CaloEmCollection > tokenCaloEm_[2]
Definition: L1Comparator.h:88
edm::EDGetTokenT< L1MuDTChambPhContainer > tokenMuDTChambPh_[2]
Definition: L1Comparator.h:103
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
Definition: L1Comparator.h:52
int verbose() const
Definition: L1Comparator.h:81
std::atomic< bool > m_match
Definition: L1Comparator.h:119
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_cenJets_[2]
Definition: L1Comparator.h:92
const std::array< bool, dedefs::DEnsys > m_doSys
Definition: L1Comparator.h:114
std::array< std::array< int, 2 >, dedefs::DEnsys > DEncand
Definition: L1Comparator.h:58
std::array< bool, dedefs::DEnsys > DEmatchEvt
Definition: L1Comparator.h:57
std::ostringstream dumpToFile_
Definition: L1Comparator.h:59
edm::EDGetTokenT< L1GctHFRingEtSumsCollection > tokenGctHFRingEtSums_[2]
Definition: L1Comparator.h:99
L1DEDigiCollection m_dedigis
Definition: L1Comparator.h:56
edm::EDGetTokenT< L1GctJetCandCollection > tokenGctJetCand_forJets_[2]
Definition: L1Comparator.h:93
edm::EDGetTokenT< L1GctHtMissCollection > tokenGctHtMiss_[2]
Definition: L1Comparator.h:101
edm::EDGetTokenT< L1CaloRegionCollection > tokenCaloRegion_[2]
Definition: L1Comparator.h:89
void process(T const *, T const *, const int, const int, EventInfo &eventInfo) const
void endJob() override
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::ofstream m_dumpFile
Definition: L1Comparator.h:116
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
eventInfo
add run, event number and lumi section
edm::EDGetTokenT< L1MuDTTrackContainer > tokenMuDTTrack_[2]
Definition: L1Comparator.h:106
long double T
edm::EDGetTokenT< L1GctEmCandCollection > tokenGctEmCand_isoEm_[2]
Definition: L1Comparator.h:90
Definition: Run.h:45
const int m_dumpMode
Definition: L1Comparator.h:117
edm::EDGetTokenT< L1MuGMTCandCollection > tokenMuGMTCand_[2]
Definition: L1Comparator.h:109
const bool m_stage1_layer2_
Definition: L1Comparator.h:82