CMS 3D CMS Logo

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