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 
SectCollThetaColl
vector< DTSectCollThSegm > SectCollThetaColl
Definition: DTTrigProd.cc:47
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
DTConfigManager::CCBConfigValidity
bool CCBConfigValidity() const
flag for CCB configuration validity
Definition: DTConfigManager.h:111
mps_fire.i
i
Definition: mps_fire.py:428
L1MuDTChambThDigi.h
L1MuDTChambPhDigi.h
DTTrig::getBXOffset
int getBXOffset() const
Get BX Offset.
Definition: DTTrig.h:201
ESHandle.h
step
step
Definition: StallMonitor.cc:94
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT< L1MuDTChambPhContainer >
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
SectCollPhiColl
vector< DTSectCollPhSegm > SectCollPhiColl
Definition: DTTrigProd.cc:45
DTTrigProd::my_lut_btic
const short int my_lut_btic
Definition: DTTrigProd.cc:80
EDProducer.h
DTTrig::SCPhTrigs
std::vector< DTSectCollPhSegm > SCPhTrigs() const
Return a copy of all the Sector Collector (Phi) triggers.
Definition: DTTrig.cc:466
DTConfigManager.h
L1MuDTChambThContainer.h
ESGetToken.h
MakerMacros.h
DTTrig::triggerReco
void triggerReco(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Run the whole trigger reconstruction chain.
Definition: DTTrig.cc:132
DTTrigProd::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iEventSetup) override
Producer: process every event and generates trigger data.
Definition: DTTrigProd.cc:111
DTTrigProd::my_DTTFnum
const bool my_DTTFnum
Definition: DTTrigProd.cc:73
DTTrigProd
Definition: DTTrigProd.cc:50
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
DTTrigProd::beginRun
void beginRun(edm::Run const &iRun, const edm::EventSetup &iEventSetup) override
Create Trigger Units before starting event processing.
Definition: DTTrigProd.cc:93
Run.h
edm::ESHandle
Definition: DTSurvey.h:22
DTSectCollThSegm.h
SectCollPhiColl_iterator
SectCollPhiColl::const_iterator SectCollPhiColl_iterator
Definition: DTTrigProd.cc:46
DTSectCollPhSegm.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DTTrigProd::DTTrigProd
DTTrigProd(const edm::ParameterSet &pset)
Constructor.
Definition: DTTrigProd.cc:83
EDPutToken.h
DTTrigProd::my_CCBValid
bool my_CCBValid
Definition: DTTrigProd.cc:70
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:38
DTTrig::SCThTrigs
std::vector< DTSectCollThSegm > SCThTrigs() const
Return a copy of all the Sector Collector (Theta) triggers.
Definition: DTTrig.cc:489
edm::EventSetup
Definition: EventSetup.h:58
DTTrigProd::dtConfigToken_
edm::ESGetToken< DTConfigManager, DTConfigManagerRcd > dtConfigToken_
Definition: DTTrigProd.cc:67
L1MuDTChambPhContainer.h
edm::ESGetToken< DTConfigManager, DTConfigManagerRcd >
DTTrig::dumpLuts
void dumpLuts(short int lut_btic, const DTConfigManager *conf) const
Dump the LUT files.
Definition: DTTrig.cc:399
DTTrigProd::my_debug
const bool my_debug
Definition: DTTrigProd.cc:76
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DTConfigManagerRcd.h
DTTrig::createTUs
void createTUs(const edm::EventSetup &iSetup)
Create the trigger units and store them in the cache.
Definition: DTTrig.cc:63
L1MuDTChambThDigi
Definition: L1MuDTChambThDigi.h:33
DTTrig
Definition: DTTrig.h:59
Frameworkfwd.h
DTTrigProd::phToken_
edm::EDPutTokenT< L1MuDTChambPhContainer > phToken_
Definition: DTTrigProd.cc:65
EventSetup.h
DTTrigProd::my_trig
DTTrig my_trig
Definition: DTTrigProd.cc:63
DTTrigProd::my_lut_dump_flag
const bool my_lut_dump_flag
Definition: DTTrigProd.cc:79
ParameterSet.h
edm::Event
Definition: Event.h:73
SectCollThetaColl_iterator
SectCollThetaColl::const_iterator SectCollThetaColl_iterator
Definition: DTTrigProd.cc:48
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
DTTrigProd::thToken_
edm::EDPutTokenT< L1MuDTChambThContainer > thToken_
Definition: DTTrigProd.cc:66
DTTrig.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
L1MuDTChambPhDigi
Definition: L1MuDTChambPhDigi.h:31