32 edm::FileInPath f1(
"L1Trigger/L1TGlobal/data/Luminosity/startup/prescale_L1TGlobal.csv");
59 m_PreScaleColumn = psColumn;
64 retrieveL1Setup(evSetup);
66 retrieveL1Event(iEvent,evSetup);
72 retrieveL1Setup(evSetup);
74 retrieveL1Event(iEvent,evSetup,gtAlgToken);
83 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
87 m_l1GtMenu = l1GtMenu.
product();
90 m_algorithmMap = &(m_l1GtMenu->getAlgorithmMap());
93 resetDecisionVectors();
95 m_l1GtMenuCacheID = l1GtMenuCacheID;
99 if(!m_filledPrescales) {
102 resetPrescaleVectors();
106 loadPrescalesAndMasks();
109 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
110 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
111 m_triggerMaskVetoAlgoTrig = &m_initialTriggerMaskVetoAlgoTrig;
115 if(m_PreScaleColumn > m_prescaleFactorsAlgoTrig->size() || m_PreScaleColumn < 1) {
117 <<
"\nNo Prescale Set: " << m_PreScaleColumn
118 <<
"\nMax Prescale Set value : " << m_prescaleFactorsAlgoTrig->size()
119 <<
"\nSetting prescale column to 1"
121 m_PreScaleColumn = 1;
123 LogDebug(
"l1t|Global") <<
"Grabing prescale column "<< m_PreScaleColumn << endl;
124 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn-1];
126 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
130 int algBit = (itAlgo->second).getIndex();
132 (m_prescales[algBit]).
first = algName;
133 (m_prescales[algBit]).
second = prescaleSet[algBit];
135 (m_masks[algBit]).
first = algName;
136 (m_masks[algBit]).
second = (*m_triggerMaskAlgoTrig)[algBit];
138 (m_vetoMasks[algBit]).
first = algName;
139 (m_vetoMasks[algBit]).
second = (*m_triggerMaskVetoAlgoTrig)[algBit];
142 m_filledPrescales =
true;
147 retrieveL1Event(iEvent, evSetup, m_l1tGlobalUtilHelper->l1tAlgBlkToken());
158 if(m_uGtAlgBlk.isValid()) {
160 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
161 if (algBlk != m_uGtAlgBlk->end(0)){
162 m_PreScaleColumn =
static_cast<unsigned int>(algBlk->getPreScColumn());
164 m_finalOR = algBlk->getFinalOR();
168 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
172 int algBit = (itAlgo->second).getIndex();
174 bool decisionInitial = algBlk->getAlgoDecisionInitial(algBit);
175 (m_decisionsInitial[algBit]).
first = algName;
176 (m_decisionsInitial[algBit]).
second = decisionInitial;
178 bool decisionInterm = algBlk->getAlgoDecisionInterm(algBit);
179 (m_decisionsInterm[algBit]).
first = algName;
180 (m_decisionsInterm[algBit]).
second = decisionInterm;
182 bool decisionFinal = algBlk->getAlgoDecisionFinal(algBit);
183 (m_decisionsFinal[algBit]).
first = algName;
184 (m_decisionsFinal[algBit]).
second = decisionFinal;
196 std::ifstream inputPrescaleFile;
197 inputPrescaleFile.open(m_preScaleFileName);
199 std::vector<std::vector<int> > vec;
200 std::vector<std::vector<int> > prescale_vec;
202 std::vector<unsigned int> temp_triggerMask;
203 std::vector<unsigned int> temp_triggerVetoMask;
205 if( inputPrescaleFile ){
213 while( getline(inputPrescaleFile,line) ){
215 if( !line.compare(0, prefix1.size(), prefix1) )
continue;
218 istringstream
split(line);
223 while( split >> value ){
226 vec.push_back(std::vector<int>());
229 vec[
col].push_back(value);
242 int NumPrescaleSets = 0;
245 int maskVetoColumn = -1;
246 for(
int iCol=0; iCol<int(vec.size()); iCol++ ){
247 if( vec[iCol].
size() > 0 ){
248 int firstRow = vec[iCol][0];
250 if( firstRow > 0 ) NumPrescaleSets++;
251 else if( firstRow==-2 ) maskColumn = iCol;
252 else if( firstRow==-3 ) maskVetoColumn = iCol;
257 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
258 unsigned int inputDefaultMask = 1;
259 unsigned int inputDefaultVetoMask = 0;
260 temp_triggerMask.push_back(inputDefaultMask);
261 temp_triggerVetoMask.push_back(inputDefaultVetoMask);
267 if( maskColumn>=0 || maskVetoColumn>=0 ){
268 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
269 unsigned int algoBit = vec[0][iBit];
271 if( algoBit < m_numberPhysTriggers ){
273 unsigned int triggerMask = vec[maskColumn][iBit];
274 temp_triggerMask[algoBit] = triggerMask;
277 if( maskVetoColumn>=0 ){
278 unsigned int triggerVetoMask = vec[maskVetoColumn][iBit];
279 temp_triggerVetoMask[algoBit] = triggerVetoMask;
286 if( NumPrescaleSets > 0 ){
288 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
289 prescale_vec.push_back(std::vector<int>());
290 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
291 int inputDefaultPrescale = 1;
292 prescale_vec[iSet].push_back(inputDefaultPrescale);
297 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
298 unsigned int algoBit = vec[0][iBit];
300 if( algoBit < m_numberPhysTriggers ){
301 for(
int iSet=0; iSet<int(vec.size()); iSet++ ){
303 if( vec[iSet].
size() > 0 ){
304 useSet = vec[iSet][0];
308 if( useSet<0 )
continue;
310 int prescale = vec[iSet][iBit];
311 prescale_vec[useSet][algoBit] = prescale;
316 <<
"\nPrescale file has algo bit: " << algoBit
317 <<
"\nThis is larger than the number of triggers: " << m_numberPhysTriggers
318 <<
"\nSomething is wrong. Ignoring."
327 <<
"\nCould not find file: " << m_preScaleFileName
328 <<
"\nFilling the prescale vectors with prescale 1"
329 <<
"\nSetting prescale set to 1"
332 m_PreScaleColumn = 1;
335 prescale_vec.push_back(std::vector<int>());
336 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
337 int inputDefaultPrescale = 1;
338 prescale_vec[
col].push_back(inputDefaultPrescale);
343 inputPrescaleFile.close();
345 m_initialPrescaleFactorsAlgoTrig = prescale_vec;
346 m_initialTriggerMaskAlgoTrig = temp_triggerMask;
347 m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
354 m_decisionsInitial.clear();
355 m_decisionsInitial.resize(m_numberPhysTriggers);
356 m_decisionsInterm.clear();
357 m_decisionsInterm.resize(m_numberPhysTriggers);
358 m_decisionsFinal.clear();
359 m_decisionsFinal.resize(m_numberPhysTriggers);
362 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
364 (m_decisionsInitial[algBit]).
first =
"NULL";
365 (m_decisionsInitial[algBit]).
second =
false;
367 (m_decisionsInterm[algBit]).
first =
"NULL";
368 (m_decisionsInterm[algBit]).
second =
false;
370 (m_decisionsFinal[algBit]).
first =
"NULL";
371 (m_decisionsFinal[algBit]).
second =
false;
382 m_prescales.resize(m_numberPhysTriggers);
384 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
386 (m_prescales[algBit]).
first =
"NULL";
387 (m_prescales[algBit]).
second = 1;
397 m_masks.resize(m_numberPhysTriggers);
399 m_vetoMasks.resize(m_numberPhysTriggers);
401 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
403 (m_masks[algBit]).
first =
"NULL";
404 (m_masks[algBit]).
second =
true;
406 (m_vetoMasks[algBit]).
first =
"NULL";
407 (m_vetoMasks[algBit]).
second =
false;
415 std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->find(algName);
416 if(itAlgo != m_algorithmMap->end()) {
417 bit = (itAlgo->second).getIndex();
427 if((m_decisionsInitial[bit]).
first !=
"NULL") {
428 algName = (m_decisionsInitial[bit]).
first;
443 if((m_decisionsInitial[bit]).
first !=
"NULL") {
444 decision = (m_decisionsInitial[bit]).
second;
453 if((m_decisionsInterm[bit]).
first !=
"NULL") {
454 decision = (m_decisionsInterm[bit]).
second;
463 if((m_decisionsFinal[bit]).
first !=
"NULL") {
464 decision = (m_decisionsFinal[bit]).
second;
473 if((m_prescales[bit]).
first !=
"NULL") {
474 prescale = (m_prescales[bit]).
second;
483 if((m_masks[bit]).
first !=
"NULL") {
484 mask = (m_masks[bit]).
second;
494 if((m_vetoMasks[bit]).
first !=
"NULL") {
495 veto = (m_vetoMasks[bit]).
second;
505 if(getAlgBitFromName(algName,bit)) {
506 decision = (m_decisionsInitial[bit]).
second;
516 if(getAlgBitFromName(algName,bit)) {
517 decision = (m_decisionsInterm[bit]).
second;
527 if(getAlgBitFromName(algName,bit)) {
528 decision = (m_decisionsFinal[bit]).
second;
537 if(getAlgBitFromName(algName,bit)) {
538 prescale = (m_prescales[bit]).
second;
547 if(getAlgBitFromName(algName,bit)) {
548 mask = (m_masks[bit]).
second;
557 if(getAlgBitFromName(algName,bit)) {
558 veto = (m_vetoMasks[bit]).
second;
const bool getInitialDecisionByBit(int &bit, bool &decision) const
std::string m_preScaleFileName
const bool getAlgBitFromName(const std::string &AlgName, int &bit) const
void retrieveL1Event(const edm::Event &iEvent, const edm::EventSetup &evSetup)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const bool getPrescaleByBit(int &bit, int &prescale) const
const bool getIntermDecisionByBit(int &bit, bool &decision) const
unsigned int m_PreScaleColumn
std::unique_ptr< L1TGlobalUtilHelper > m_l1tGlobalUtilHelper
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
void resetDecisionVectors()
clear decision vectors on a menu change
const bool getMaskByName(const std::string &algName, bool &mask) const
U second(std::pair< T, U > const &p)
const bool getFinalDecisionByName(const std::string &algName, bool &decision) const
void OverridePrescalesAndMasks(std::string filename, unsigned int psColumn=1)
const bool getAlgNameFromBit(int &bit, std::string &AlgName) const
const bool getVetoMaskByBit(int &bit, bool &veto) const
unsigned long long m_l1GtMenuCacheID
const bool getMaskByBit(int &bit, bool &mask) const
T const * product() const
const bool getVetoMaskByName(const std::string &algName, bool &veto) const
void resetPrescaleVectors()
const bool getFinalDecisionByBit(int &bit, bool &decision) const
const bool getPrescaleByName(const std::string &algName, int &prescale) const
std::string fullPath() const
const bool getIntermDecisionByName(const std::string &algName, bool &decision) const
virtual ~L1TGlobalUtil()
destructor
void retrieveL1Setup(const edm::EventSetup &evSetup)
void loadPrescalesAndMasks()
tuple size
Write out results.
unsigned int m_numberPhysTriggers
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)