32 edm::FileInPath f1(
"L1Trigger/L1TGlobal/data/Luminosity/startup/prescale_L1TGlobal.csv");
42 m_PreScaleColumn = psColumn;
53 retrieveL1Run(evSetup);
55 retrieveL1LumiBlock(evSetup);
57 retrieveL1Event(iEvent,evSetup,gtAlgToken);
67 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
71 m_l1GtMenu = l1GtMenu.
product();
74 m_algorithmMap = &(m_l1GtMenu->getAlgorithmMap());
77 resetDecisionVectors();
79 m_l1GtMenuCacheID = l1GtMenuCacheID;
86 if(!m_filledPrescales) {
89 resetPrescaleVectors();
93 loadPrescalesAndMasks();
96 m_prescaleFactorsAlgoTrig = &m_initialPrescaleFactorsAlgoTrig;
97 m_triggerMaskAlgoTrig = &m_initialTriggerMaskAlgoTrig;
98 m_triggerMaskVetoAlgoTrig = &m_initialTriggerMaskVetoAlgoTrig;
102 if(m_PreScaleColumn > m_prescaleFactorsAlgoTrig->size() || m_PreScaleColumn < 1) {
104 <<
"\nNo Prescale Set: " << m_PreScaleColumn
105 <<
"\nMax Prescale Set value : " << m_prescaleFactorsAlgoTrig->size()
106 <<
"\nSetting prescale column to 1"
108 m_PreScaleColumn = 1;
110 LogDebug(
"l1t|Global") <<
"Grabing prescale column "<< m_PreScaleColumn << endl;
111 const std::vector<int>& prescaleSet = (*m_prescaleFactorsAlgoTrig)[m_PreScaleColumn-1];
113 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
117 int algBit = (itAlgo->second).getIndex();
119 (m_prescales[algBit]).
first = algName;
120 (m_prescales[algBit]).
second = prescaleSet[algBit];
122 (m_masks[algBit]).
first = algName;
123 (m_masks[algBit]).
second = (*m_triggerMaskAlgoTrig)[algBit];
125 (m_vetoMasks[algBit]).
first = algName;
126 (m_vetoMasks[algBit]).
second = (*m_triggerMaskVetoAlgoTrig)[algBit];
129 m_filledPrescales =
true;
141 if(m_uGtAlgBlk.isValid()) {
143 std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
144 if (algBlk != m_uGtAlgBlk->end(0)){
146 m_finalOR = algBlk->getFinalOR();
150 for (std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
154 int algBit = (itAlgo->second).getIndex();
156 bool decisionInitial = algBlk->getAlgoDecisionInitial(algBit);
157 (m_decisionsInitial[algBit]).
first = algName;
158 (m_decisionsInitial[algBit]).
second = decisionInitial;
160 bool decisionPrescaled = algBlk->getAlgoDecisionInterm(algBit);
161 (m_decisionsPrescaled[algBit]).
first = algName;
162 (m_decisionsPrescaled[algBit]).
second = decisionPrescaled;
164 bool decisionFinal = algBlk->getAlgoDecisionFinal(algBit);
165 (m_decisionsFinal[algBit]).
first = algName;
166 (m_decisionsFinal[algBit]).
second = decisionFinal;
178 std::ifstream inputPrescaleFile;
179 inputPrescaleFile.open(m_preScaleFileName);
181 std::vector<std::vector<int> > vec;
182 std::vector<std::vector<int> > prescale_vec;
184 std::vector<unsigned int> temp_triggerMask;
185 std::vector<unsigned int> temp_triggerVetoMask;
187 if( inputPrescaleFile ){
195 while( getline(inputPrescaleFile,line) ){
197 if( !line.compare(0, prefix1.size(), prefix1) )
continue;
200 istringstream
split(line);
205 while( split >> value ){
208 vec.push_back(std::vector<int>());
211 vec[
col].push_back(value);
224 int NumPrescaleSets = 0;
227 int maskVetoColumn = -1;
228 for(
int iCol=0; iCol<int(vec.size()); iCol++ ){
229 if( vec[iCol].
size() > 0 ){
230 int firstRow = vec[iCol][0];
232 if( firstRow > 0 ) NumPrescaleSets++;
233 else if( firstRow==-2 ) maskColumn = iCol;
234 else if( firstRow==-3 ) maskVetoColumn = iCol;
239 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
240 unsigned int inputDefaultMask = 1;
241 unsigned int inputDefaultVetoMask = 0;
242 temp_triggerMask.push_back(inputDefaultMask);
243 temp_triggerVetoMask.push_back(inputDefaultVetoMask);
249 if( maskColumn>=0 || maskVetoColumn>=0 ){
250 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
251 unsigned int algoBit = vec[0][iBit];
253 if( algoBit < m_numberPhysTriggers ){
255 unsigned int triggerMask = vec[maskColumn][iBit];
256 temp_triggerMask[algoBit] = triggerMask;
259 if( maskVetoColumn>=0 ){
260 unsigned int triggerVetoMask = vec[maskVetoColumn][iBit];
261 temp_triggerVetoMask[algoBit] = triggerVetoMask;
268 if( NumPrescaleSets > 0 ){
270 for(
int iSet=0; iSet<NumPrescaleSets; iSet++ ){
271 prescale_vec.push_back(std::vector<int>());
272 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
273 int inputDefaultPrescale = 1;
274 prescale_vec[iSet].push_back(inputDefaultPrescale);
279 for(
int iBit=1; iBit<int(vec[0].
size()); iBit++ ){
280 unsigned int algoBit = vec[0][iBit];
282 if( algoBit < m_numberPhysTriggers ){
283 for(
int iSet=0; iSet<int(vec.size()); iSet++ ){
285 if( vec[iSet].
size() > 0 ){
286 useSet = vec[iSet][0];
290 if( useSet<0 )
continue;
292 int prescale = vec[iSet][iBit];
293 prescale_vec[useSet][algoBit] = prescale;
298 <<
"\nPrescale file has algo bit: " << algoBit
299 <<
"\nThis is larger than the number of triggers: " << m_numberPhysTriggers
300 <<
"\nSomething is wrong. Ignoring."
309 <<
"\nCould not find file: " << m_preScaleFileName
310 <<
"\nFilling the prescale vectors with prescale 1"
311 <<
"\nSetting prescale set to 1"
314 m_PreScaleColumn = 1;
317 prescale_vec.push_back(std::vector<int>());
318 for(
unsigned int iBit = 0; iBit < m_numberPhysTriggers; ++iBit ){
319 int inputDefaultPrescale = 1;
320 prescale_vec[
col].push_back(inputDefaultPrescale);
325 inputPrescaleFile.close();
327 m_initialPrescaleFactorsAlgoTrig = prescale_vec;
328 m_initialTriggerMaskAlgoTrig = temp_triggerMask;
329 m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
336 m_decisionsInitial.clear();
337 m_decisionsInitial.resize(m_numberPhysTriggers);
338 m_decisionsPrescaled.clear();
339 m_decisionsPrescaled.resize(m_numberPhysTriggers);
340 m_decisionsFinal.clear();
341 m_decisionsFinal.resize(m_numberPhysTriggers);
344 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
346 (m_decisionsInitial[algBit]).
first =
"NULL";
347 (m_decisionsInitial[algBit]).
second =
false;
349 (m_decisionsPrescaled[algBit]).
first =
"NULL";
350 (m_decisionsPrescaled[algBit]).
second =
false;
352 (m_decisionsFinal[algBit]).
first =
"NULL";
353 (m_decisionsFinal[algBit]).
second =
false;
364 m_prescales.resize(m_numberPhysTriggers);
366 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
368 (m_prescales[algBit]).
first =
"NULL";
369 (m_prescales[algBit]).
second = 1;
379 m_masks.resize(m_numberPhysTriggers);
381 m_vetoMasks.resize(m_numberPhysTriggers);
383 for(
unsigned int algBit = 0; algBit< m_numberPhysTriggers; algBit++) {
385 (m_masks[algBit]).
first =
"NULL";
386 (m_masks[algBit]).
second =
true;
388 (m_vetoMasks[algBit]).
first =
"NULL";
389 (m_vetoMasks[algBit]).
second =
false;
397 std::map<std::string, L1TUtmAlgorithm>::const_iterator itAlgo = m_algorithmMap->find(algName);
398 if(itAlgo != m_algorithmMap->end()) {
399 bit = (itAlgo->second).getIndex();
409 if((m_decisionsInitial[bit]).
first !=
"NULL") {
410 algName = (m_decisionsInitial[bit]).
first;
425 if((m_decisionsInitial[bit]).
first !=
"NULL") {
426 decision = (m_decisionsInitial[bit]).
second;
435 if((m_decisionsPrescaled[bit]).
first !=
"NULL") {
436 decision = (m_decisionsPrescaled[bit]).
second;
445 if((m_decisionsFinal[bit]).
first !=
"NULL") {
446 decision = (m_decisionsFinal[bit]).
second;
455 if((m_prescales[bit]).
first !=
"NULL") {
456 prescale = (m_prescales[bit]).
second;
465 if((m_masks[bit]).
first !=
"NULL") {
466 mask = (m_masks[bit]).
second;
476 if((m_vetoMasks[bit]).
first !=
"NULL") {
477 veto = (m_vetoMasks[bit]).
second;
487 if(getAlgBitFromName(algName,bit)) {
488 decision = (m_decisionsInitial[bit]).
second;
498 if(getAlgBitFromName(algName,bit)) {
499 decision = (m_decisionsPrescaled[bit]).
second;
509 if(getAlgBitFromName(algName,bit)) {
510 decision = (m_decisionsFinal[bit]).
second;
519 if(getAlgBitFromName(algName,bit)) {
520 prescale = (m_prescales[bit]).
second;
529 if(getAlgBitFromName(algName,bit)) {
530 mask = (m_masks[bit]).
second;
539 if(getAlgBitFromName(algName,bit)) {
540 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, edm::EDGetToken gtAlgToken)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const bool getPrescaleByBit(int &bit, int &prescale) const
unsigned int m_PreScaleColumn
void retrieveL1LumiBlock(const edm::EventSetup &evSetup)
const bool getInitialDecisionByName(const std::string &algName, bool &decision) const
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup, edm::EDGetToken gtAlgToken)
initialize the class (mainly reserve)
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
const bool getPrescaledDecisionByName(const std::string &algName, bool &decision) const
std::string fullPath() const
void retrieveL1Run(const edm::EventSetup &evSetup)
void loadPrescalesAndMasks()
tuple size
Write out results.
const bool getPrescaledDecisionByBit(int &bit, bool &decision) const
unsigned int m_numberPhysTriggers