CMS 3D CMS Logo

DTTrigProd.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
11 //
12 //--------------------------------------------------
13 
14 // Framework related classes
25 
29 
30 // Data Formats classes
37 
38 // Collaborating classes
39 #include <iostream>
40 
41 using namespace edm;
42 using namespace std;
43 
44 // DataFormats interface
45 typedef vector<DTSectCollPhSegm> SectCollPhiColl;
46 typedef SectCollPhiColl::const_iterator SectCollPhiColl_iterator;
47 typedef vector<DTSectCollThSegm> SectCollThetaColl;
48 typedef SectCollThetaColl::const_iterator SectCollThetaColl_iterator;
49 
51 public:
54 
56  void beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) override;
57 
59  void produce(edm::Event& iEvent, const edm::EventSetup& iEventSetup) override;
60 
61 private:
62  // Trigger istance
64 
68 
69  // Trigger Configuration Manager CCB validity flag
70  bool my_CCBValid = false;
71 
72  // Sector Format Flag true=[0-11] false=[1-12]
73  const bool my_DTTFnum;
74 
75  // Debug Flag
76  const bool my_debug;
77 
78  // Lut dump file parameters
79  const bool my_lut_dump_flag;
80  const short int my_lut_btic;
81 };
82 
84  : my_trig(pset, consumesCollector()),
85  phToken_{produces<L1MuDTChambPhContainer>()},
86  thToken_{produces<L1MuDTChambThContainer>()},
87  dtConfigToken_(esConsumes<DTConfigManager, DTConfigManagerRcd, edm::Transition::BeginRun>()),
88  my_DTTFnum{pset.getParameter<bool>("DTTFSectorNumbering")},
89  my_debug{pset.getUntrackedParameter<bool>("debug")},
90  my_lut_dump_flag{pset.getUntrackedParameter<bool>("lutDumpFlag")},
91  my_lut_btic{static_cast<short int>(pset.getUntrackedParameter<int>("lutBtic"))} {}
92 
93 void DTTrigProd::beginRun(edm::Run const& iRun, const edm::EventSetup& iEventSetup) {
94  if (my_debug)
95  cout << "DTTrigProd::beginRun " << iRun.id().run() << endl;
96 
97  ESHandle<DTConfigManager> dtConfig = iEventSetup.getHandle(dtConfigToken_);
98 
99  my_CCBValid = dtConfig->CCBConfigValidity();
100 
101  my_trig.createTUs(iEventSetup);
102  if (my_debug)
103  cout << "[DTTrigProd] TU's Created" << endl;
104 
105  if (my_lut_dump_flag) {
106  cout << "Dumping luts...." << endl;
107  my_trig.dumpLuts(my_lut_btic, dtConfig.product());
108  }
109 }
110 
111 void DTTrigProd::produce(Event& iEvent, const EventSetup& iEventSetup) {
112  vector<L1MuDTChambPhDigi> outPhi;
113  vector<L1MuDTChambThDigi> outTheta;
114 
115  // SV check if CCB configuration is valid, otherwise just produce empty collections
116  if (!my_CCBValid) {
117  if (my_debug)
118  cout << "[DTTrigProd] CCB configuration is not valid for this run, empty collection will be produced " << endl;
119  } else {
120  my_trig.triggerReco(iEvent, iEventSetup);
121  // BX offset used to correct DTTPG output
122  int bx_offset = my_trig.getBXOffset();
123 
124  if (my_debug)
125  cout << "[DTTrigProd] Trigger algorithm run for " << iEvent.id() << endl;
126 
127  // Convert Phi Segments
128  SectCollPhiColl myPhiSegments;
129  myPhiSegments = my_trig.SCPhTrigs();
130 
131  SectCollPhiColl_iterator SCPCend = myPhiSegments.end();
132  for (SectCollPhiColl_iterator it = myPhiSegments.begin(); it != SCPCend; ++it) {
133  int step = (*it).step() - bx_offset; // Shift correct BX to 0 (needed for DTTF data processing)
134  int sc_sector = (*it).SCId().sector();
135  if (my_DTTFnum == true)
136  sc_sector--; // Modified for DTTF numbering [0-11]
137  outPhi.push_back(L1MuDTChambPhDigi(step,
138  (*it).ChamberId().wheel(),
139  sc_sector,
140  (*it).ChamberId().station(),
141  (*it).phi(),
142  (*it).phiB(),
143  (*it).code(),
144  !(*it).isFirst(),
145  0));
146  }
147 
148  // Convert Theta Segments
149  SectCollThetaColl myThetaSegments;
150  myThetaSegments = my_trig.SCThTrigs();
151 
152  SectCollThetaColl_iterator SCTCend = myThetaSegments.end();
153  for (SectCollThetaColl_iterator it = myThetaSegments.begin(); it != SCTCend; ++it) {
154  int pos[7], qual[7];
155  for (int i = 0; i < 7; i++) {
156  pos[i] = (*it).position(i);
157  qual[i] = (*it).quality(i);
158  }
159  int step = (*it).step() - bx_offset; // Shift correct BX to 0 (needed for DTTF data processing)
160  int sc_sector = (*it).SCId().sector();
161  if (my_DTTFnum == true)
162  sc_sector--; // Modified for DTTF numbering [0-11]
163  outTheta.push_back(
164  L1MuDTChambThDigi(step, (*it).ChamberId().wheel(), sc_sector, (*it).ChamberId().station(), pos, qual));
165  }
166  }
167 
168  // Write everything into the event (CB write empty collection as default actions if emulator does not run)
169  iEvent.emplace(phToken_, std::move(outPhi));
170  iEvent.emplace(thToken_, std::move(outTheta));
171 }
172 
bool my_CCBValid
Definition: DTTrigProd.cc:70
bool CCBConfigValidity() const
flag for CCB configuration validity
DTTrigProd(const edm::ParameterSet &pset)
Constructor.
Definition: DTTrigProd.cc:83
edm::ESGetToken< DTConfigManager, DTConfigManagerRcd > dtConfigToken_
Definition: DTTrigProd.cc:67
edm::EDPutTokenT< L1MuDTChambPhContainer > phToken_
Definition: DTTrigProd.cc:65
const bool my_debug
Definition: DTTrigProd.cc:76
int getBXOffset() const
Get BX Offset.
Definition: DTTrig.h:201
const bool my_lut_dump_flag
Definition: DTTrigProd.cc:79
vector< DTSectCollThSegm > SectCollThetaColl
Definition: DTTrigProd.cc:47
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
std::vector< DTSectCollPhSegm > SCPhTrigs() const
Return a copy of all the Sector Collector (Phi) triggers.
Definition: DTTrig.cc:466
SectCollThetaColl::const_iterator SectCollThetaColl_iterator
Definition: DTTrigProd.cc:48
DTTrig my_trig
Definition: DTTrigProd.cc:63
std::vector< DTSectCollThSegm > SCThTrigs() const
Return a copy of all the Sector Collector (Theta) triggers.
Definition: DTTrig.cc:489
edm::EDPutTokenT< L1MuDTChambThContainer > thToken_
Definition: DTTrigProd.cc:66
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void triggerReco(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Run the whole trigger reconstruction chain.
Definition: DTTrig.cc:132
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
RunID const & id() const
Definition: RunBase.h:39
const short int my_lut_btic
Definition: DTTrigProd.cc:80
Definition: DTTrig.h:59
SectCollPhiColl::const_iterator SectCollPhiColl_iterator
Definition: DTTrigProd.cc:46
HLT enums.
const bool my_DTTFnum
Definition: DTTrigProd.cc:73
step
Definition: StallMonitor.cc:83
vector< DTSectCollPhSegm > SectCollPhiColl
Definition: DTTrigProd.cc:45
void produce(edm::Event &iEvent, const edm::EventSetup &iEventSetup) override
Producer: process every event and generates trigger data.
Definition: DTTrigProd.cc:111
void dumpLuts(short int lut_btic, const DTConfigManager *conf) const
Dump the LUT files.
Definition: DTTrig.cc:399
void createTUs(const edm::EventSetup &iSetup)
Create the trigger units and store them in the cache.
Definition: DTTrig.cc:63
void beginRun(edm::Run const &iRun, const edm::EventSetup &iEventSetup) override
Create Trigger Units before starting event processing.
Definition: DTTrigProd.cc:93
def move(src, dest)
Definition: eostools.py:511
RunNumber_t run() const
Definition: RunID.h:26
Definition: Run.h:45