Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:39

0001 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
0002 #include "FWCore/ParameterSet/interface/Registry.h"
0003 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0004 
0005 #include <boost/algorithm/string.hpp>
0006 using namespace egHLT;
0007 
0008 TrigCodes::TrigBitSet trigTools::getFiltersPassed(const std::vector<std::pair<std::string, int> >& filters,
0009                                                   const trigger::TriggerEvent* trigEvt,
0010                                                   const std::string& hltTag,
0011                                                   const TrigCodes& trigCodes) {
0012   TrigCodes::TrigBitSet evtTrigs;
0013   for (auto const& filter : filters) {
0014     size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter.first, "", hltTag));
0015     const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filter.first.c_str());
0016     if (filterNrInEvt <
0017         trigEvt
0018             ->sizeFilters()) {  //filter found in event, however this only means that something passed the previous filter
0019       const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt);
0020       if (static_cast<int>(trigKeys.size()) >= filter.second) {
0021         evtTrigs |= filterCode;  //filter was passed
0022       }
0023     }  //end check if filter is present
0024   }    //end loop over all filters
0025 
0026   return evtTrigs;
0027 }
0028 
0029 //this function runs over all parameter sets for every module that has ever run on an event in this job
0030 //it looks for the specified filter module
0031 //and returns the minimum number of objects required to pass the filter, -1 if its not found
0032 //which is either the ncandcut or MinN parameter in the filter config
0033 //assumption: nobody will ever change MinN or ncandcut without changing the filter name
0034 //as this just picks the first module name and if 2 different versions of HLT were run with the filter having
0035 //a different min obj required in the two versions, this may give the wrong answer
0036 std::vector<int> trigTools::getMinNrObjsRequiredByFilter(const std::vector<std::string>& filterNames) {
0037   std::vector<int> retVal(filterNames.size(), -2);
0038   const std::string mag0("@module_label");
0039   const std::string mag1("ncandcut");
0040   const std::string mag2("nZcandcut");
0041   const std::string mag3("MinN");
0042   const std::string mag4("minN");
0043 
0044   std::vector<std::string> filterEntryStrings;
0045   filterEntryStrings.reserve(filterNames.size());
0046   for (auto const& filterName : filterNames) {
0047     const edm::Entry filterEntry(mag0, filterName, true);
0048     filterEntryStrings.push_back(filterEntry.toString());
0049   }
0050 
0051   //will return out of for loop once its found it to save time
0052   const edm::pset::Registry* psetRegistry = edm::pset::Registry::instance();
0053   if (psetRegistry == nullptr) {
0054     retVal = std::vector<int>(filterNames.size(), -1);
0055     return retVal;
0056   }
0057   for (auto& psetIt : *psetRegistry) {  //loop over every pset for every module ever run
0058     const std::map<std::string, edm::Entry>& mapOfPara =
0059         psetIt.second.tbl();  //contains the parameter name and value for all the parameters of the pset
0060     const auto itToModLabel = mapOfPara.find(mag0);
0061     if (itToModLabel != mapOfPara.end()) {
0062       std::string itString = itToModLabel->second.toString();
0063 
0064       for (unsigned int i = 0; i < filterNames.size(); i++) {
0065         if (retVal[i] == -1)
0066           continue;  //already done
0067 
0068         if (itString ==
0069             filterEntryStrings[i]) {  //moduleName is the filter name, we have found filter, we will now return something
0070           auto itToCandCut = mapOfPara.find(mag1);
0071           if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() == 'I')
0072             retVal[i] = itToCandCut->second.getInt32();
0073           else {  //checks if nZcandcut exists and is int32, if not return -1
0074             itToCandCut = mapOfPara.find(mag2);
0075             if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() == 'I')
0076               retVal[i] = itToCandCut->second.getInt32();
0077             else {  //checks if MinN exists and is int32, if not return -1
0078               itToCandCut = mapOfPara.find(mag3);
0079               if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() == 'I')
0080                 retVal[i] = itToCandCut->second.getInt32();
0081               else {  //checks if minN exists and is int32, if not return -1
0082                 itToCandCut = mapOfPara.find(mag4);
0083                 if (itToCandCut != mapOfPara.end() && itToCandCut->second.typeCode() == 'I')
0084                   retVal[i] = itToCandCut->second.getInt32();
0085                 else
0086                   retVal[i] = -1;
0087               }
0088             }
0089           }
0090         }
0091       }
0092     }
0093   }
0094   for (unsigned int i = 0; i < filterNames.size(); i++)
0095     if (retVal[i] == -2)
0096       retVal[i] = -1;
0097   return retVal;
0098 }
0099 
0100 //this looks into the HLT config and fills a sorted vector with the last filter of all HLT triggers
0101 //it assumes this filter is either the last (in the case of ES filters) or second to last in the sequence
0102 /*void trigTools::getActiveFilters(const HLTConfigProvider& hltConfig,std::vector<std::string>& activeFilters)
0103   {
0104   activeFilters.clear();
0105   
0106   for(size_t pathNr=0;pathNr<hltConfig.size();pathNr++){
0107   const std::string& pathName = hltConfig.triggerName(pathNr);
0108   if(pathName.find("HLT_")==0){ //hlt path as they all start with HLT_XXXX
0109   
0110   std::string lastFilter;
0111   const std::vector<std::string>& filters = hltConfig.moduleLabels(pathNr);
0112   if(!filters.empty()){
0113   if(filters.back()=="hltBoolEnd" && filters.size()>=2){
0114   activeFilters.push_back(filters[filters.size()-2]); //2nd to last element is the last filter, useally the case as last is hltBool except for ES bits
0115   }else activeFilters.push_back(filters.back());
0116   //std::cout<<filters[filters.size()-2]<<std::endl;
0117   }
0118   }//end hlt path check
0119   }//end path loop over
0120 
0121   std::sort(activeFilters.begin(),activeFilters.end());
0122   
0123   }*/
0124 //----Morse--------------
0125 //want to grab all modules with saveTags==true for e/g paths
0126 //veto x-triggers, which will be handled by PAGs
0127 //first step towards automation; for now it is just used to check against filtersToMon
0128 //should have some overhead but they will be filtered out by filterInactiveTriggers anyway
0129 void trigTools::getActiveFilters(const HLTConfigProvider& hltConfig,
0130                                  std::vector<std::string>& activeFilters,
0131                                  std::vector<std::string>& activeEleFilters,
0132                                  std::vector<std::string>& activeEle2LegFilters,
0133                                  std::vector<std::string>& activePhoFilters,
0134                                  std::vector<std::string>& activePho2LegFilters) {
0135   activeFilters.clear();
0136   activeEleFilters.clear();
0137   activeEle2LegFilters.clear();
0138   activePhoFilters.clear();
0139   activePho2LegFilters.clear();
0140 
0141   for (size_t pathNr = 0; pathNr < hltConfig.size(); pathNr++) {
0142     const std::string& pathName = hltConfig.triggerName(pathNr);
0143 
0144     if (pathName.find("HLT_") == 0) {  //hlt path as they all start with HLT_XXXX
0145       if ((pathName.find("Photon") == 4 || pathName.find("Ele") == 4 || pathName.find("EG") != pathName.npos ||
0146            pathName.find("PAPhoton") == 4 || pathName.find("PAEle") == 4 || pathName.find("PASinglePhoton") == 4 ||
0147            pathName.find("HIPhoton") == 4 || pathName.find("HIEle") == 4 || pathName.find("HISinglePhoton") == 4 ||
0148            pathName.find("Activity") == 4 || pathName.find("Physics") == 4 || pathName.find("DiSC") == 4) &&
0149           (pathName.find("Jet") == pathName.npos && pathName.find("Muon") == pathName.npos &&
0150            pathName.find("Tau") == pathName.npos && pathName.find("HT") == pathName.npos &&
0151            pathName.find("MR") == pathName.npos && pathName.find("LEITI") == pathName.npos &&
0152            pathName.find("Jpsi") == pathName.npos && pathName.find("Ups") == pathName.npos)) {  //veto x-triggers
0153         //std::string lastFilter;
0154         const std::vector<std::string>& filters = hltConfig.saveTagsModules(pathNr);
0155 
0156         //std::cout<<"Number of prescale sets: "<<hltConfig.prescaleSize()<<std::endl;
0157         //std::cout<<std::endl<<"Path Name: "<<pathName<<"   Prescale: "<<hltConfig.prescaleValue(1,pathName)<<std::endl;
0158 
0159         if (!filters.empty()) {
0160           //std::cout<<"Path Name: "<<pathName<<std::endl;
0161           //if(filters.back()=="hltBoolEnd" && filters.size()>=2){
0162           std::vector<int> minNRFFCache = getMinNrObjsRequiredByFilter(filters);
0163 
0164           for (size_t filter = 0; filter < filters.size(); filter++) {
0165             //std::cout << filters[filter] << std::endl;
0166             if (filters[filter].find("Filter") !=
0167                 filters[filter].npos) {  //keep only modules that contain the word "Filter"
0168               //std::cout<<"  Module Name: "<<filters[filter]<<" filter#: "<<int(filter)<<"/"<<filters.size()<<" ncandcut: "<<trigTools::getMinNrObjsRequiredByFilter(filters[filter])<<std::endl;
0169               int minNRFF = minNRFFCache[filter];
0170               int minNRFFP1 = -99;
0171               if (filter < filters.size() - 1)
0172                 minNRFFP1 = minNRFFCache[filter + 1];
0173               if (  //keep only the last filter and the last one with ncandcut==1 (for di-object triggers)
0174                   (minNRFF == 1 && minNRFFP1 == 2) ||
0175                   (minNRFF == 1 && minNRFFP1 == 1 && filters[filter + 1].find("Mass") != filters[filter + 1].npos) ||
0176                   (minNRFF == 1 && minNRFFP1 == 1 && filters[filter + 1].find("FEM") != filters[filter + 1].npos) ||
0177                   (minNRFF == 1 && minNRFFP1 == 1 && filters[filter + 1].find("PFMT") != filters[filter + 1].npos) ||
0178                   filter == filters.size() - 1) {
0179                 activeFilters.push_back(filters[filter]);  //saves all modules with saveTags=true
0180 
0181                 //std::cout<<"  Module Name: "<<filters[filter]<<" filter#: "<<int(filter)<<"/"<<filters.size()<<" ncandcut: "<<trigTools::getMinNrObjsRequiredByFilter(filters[filter])<<std::endl;
0182                 if (pathName.find("Photon") != pathName.npos || pathName.find("Activity") != pathName.npos ||
0183                     pathName.find("Physics") != pathName.npos || pathName.find("DiSC") == 4) {
0184                   activePhoFilters.push_back(filters[filter]);  //saves all "Photon" paths into photon set
0185                   int posPho = pathName.find("Pho") + 1;
0186                   if (pathName.find("Pho", posPho) != pathName.npos || pathName.find("SC", posPho) != pathName.npos) {
0187                     //This saves all "x_Photon_x_Photon_x" and "x_Photon_x_SC_x" path filters into 2leg photon set
0188                     activePho2LegFilters.push_back(filters[filter]);
0189                     //std::cout<<"Pho2LegPath: "<<pathName<<std::endl;
0190                   }
0191                 }
0192                 if (pathName.find("Ele") != pathName.npos || pathName.find("Activity") != pathName.npos ||
0193                     pathName.find("Physics") != pathName.npos) {
0194                   activeEleFilters.push_back(filters[filter]);  //saves all "Ele" paths into electron set
0195                   int posEle = pathName.find("Ele") + 1;
0196                   if (pathName.find("Ele", posEle) != pathName.npos || pathName.find("SC", posEle) != pathName.npos) {
0197                     if ((minNRFF == 1 && minNRFFP1 == 2) ||
0198                         (minNRFF == 1 && minNRFFP1 == 1 &&
0199                          filters[filter + 1].find("Mass") != filters[filter + 1].npos) ||
0200                         (minNRFF == 1 && minNRFFP1 == 1 &&
0201                          filters[filter + 1].find("SC") != filters[filter + 1].npos) ||
0202                         (minNRFF == 1 && minNRFFP1 == 1 &&
0203                          filters[filter + 1].find("FEM") != filters[filter + 1].npos)) {
0204                       //This saves all "x_Ele_x_Ele_x" and "x_Ele_x_SC_x" path filters into 2leg electron set
0205                       activeEle2LegFilters.push_back(filters[filter] + "::" + filters[filter + 1]);
0206                       //std::cout<<"Ele2LegPath: "<<pathName<<std::endl;
0207                     }
0208                   }
0209                 }
0210               }
0211             }
0212           }
0213           //std::cout<<filters[filters.size()-2]<<std::endl;
0214           //}else activeFilters.push_back(filters.back());
0215         }
0216       }
0217     }  //end hlt path check
0218   }    //end path loop over
0219   /*for(size_t i=0;i<activeEle2LegFilters.size();i++){
0220     std::cout<<"Leg1: "<<activeEle2LegFilters[i].substr(0,activeEle2LegFilters[i].find("::"))<<std::endl;
0221     std::cout<<"Leg2: "<<activeEle2LegFilters[i].substr(activeEle2LegFilters[i].find("::")+2)<<std::endl<<std::endl;
0222     }*/
0223   std::sort(activeFilters.begin(), activeFilters.end());
0224   std::sort(activeEleFilters.begin(), activeEleFilters.end());
0225   std::sort(activeEle2LegFilters.begin(), activeEle2LegFilters.end());
0226   std::sort(activePhoFilters.begin(), activePhoFilters.end());
0227 }
0228 //----------------------------
0229 
0230 //this function will filter the inactive filternames
0231 //it assumes the list of active filters is sorted
0232 //at some point this will be replaced with one line of fancy stl code but I want it to work now :)
0233 void trigTools::filterInactiveTriggers(std::vector<std::string>& namesToFilter,
0234                                        std::vector<std::string>& activeFilters) {
0235   //tempory vector to store the filtered results
0236   std::vector<std::string> filteredNames;
0237   /*
0238   for(size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
0239     if(std::binary_search(activeFilters.begin(),activeFilters.end(),namesToFilter[inputFilterNr])){
0240       filteredNames.push_back(namesToFilter[inputFilterNr]);
0241     }//std::cout<<filteredNames[inputFilterNr]<<std::endl;
0242   }
0243   */
0244   //namesToFilter.swap(activeFilters);
0245   filteredNames = activeFilters;
0246   namesToFilter.swap(filteredNames);
0247 }
0248 
0249 //input filters have format filter1:filter2, this checks both filters are active, rejects ones where both are not active
0250 void trigTools::filterInactiveTightLooseTriggers(std::vector<std::string>& namesToFilter,
0251                                                  const std::vector<std::string>& activeFilters) {
0252   //tempory vector to store the filtered results
0253   std::vector<std::string> filteredNames;
0254 
0255   for (auto& inputFilterNr : namesToFilter) {
0256     std::vector<std::string> names;
0257     boost::split(names, inputFilterNr, boost::is_any_of(std::string(":")));
0258     if (names.size() != 2)
0259       continue;  //format incorrect, reject it
0260     if (std::binary_search(activeFilters.begin(), activeFilters.end(), names[0]) &&
0261         std::binary_search(activeFilters.begin(), activeFilters.end(), names[1])) {  //both filters are valid
0262       filteredNames.push_back(inputFilterNr);
0263     }
0264   }
0265 
0266   namesToFilter.swap(filteredNames);
0267 }
0268 
0269 //a comparison functiod for std::pair<std::string,std::string>
0270 //this probably (infact must) exist elsewhere
0271 class StringPairCompare {
0272 public:
0273   bool operator()(const std::pair<std::string, std::string>& lhs,
0274                   const std::pair<std::string, std::string>& rhs) const {
0275     return keyLess(lhs.first, rhs.first);
0276   }
0277   bool operator()(const std::pair<std::string, std::string>& lhs,
0278                   const std::pair<std::string, std::string>::first_type& rhs) const {
0279     return keyLess(lhs.first, rhs);
0280   }
0281   bool operator()(const std::pair<std::string, std::string>::first_type& lhs,
0282                   const std::pair<std::string, std::string>& rhs) const {
0283     return keyLess(lhs, rhs.first);
0284   }
0285 
0286 private:
0287   bool keyLess(const std::pair<std::string, std::string>::first_type& k1,
0288                const std::pair<std::string, std::string>::first_type& k2) const {
0289     return k1 < k2;
0290   }
0291 };
0292 
0293 void trigTools::translateFiltersToPathNames(const HLTConfigProvider& hltConfig,
0294                                             const std::vector<std::string>& filters,
0295                                             std::vector<std::string>& paths) {
0296   paths.clear();
0297   std::vector<std::pair<std::string, std::string> > filtersAndPaths;
0298 
0299   for (size_t pathNr = 0; pathNr < hltConfig.size(); pathNr++) {
0300     const std::string& pathName = hltConfig.triggerName(pathNr);
0301     if (pathName.find("HLT_") == 0) {  //hlt path as they all start with HLT_XXXX
0302 
0303       std::string lastFilter;
0304       const std::vector<std::string>& pathFilters = hltConfig.moduleLabels(pathNr);
0305       if (!pathFilters.empty()) {
0306         if (pathFilters.back() == "hltBoolEnd" && pathFilters.size() >= 2) {
0307           //2nd to last element is the last filter, useally the case as last is hltBool except for ES bits
0308           filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size() - 2], pathName));
0309         } else
0310           filtersAndPaths.push_back(std::make_pair(pathFilters.back(), pathName));
0311       }
0312     }  //end hlt path check
0313   }    //end path loop over
0314 
0315   std::sort(filtersAndPaths.begin(), filtersAndPaths.end(), StringPairCompare());
0316 
0317   for (auto const& filter : filters) {
0318     typedef std::vector<std::pair<std::string, std::string> >::const_iterator VecIt;
0319     std::pair<VecIt, VecIt> searchResult =
0320         std::equal_range(filtersAndPaths.begin(), filtersAndPaths.end(), filter, StringPairCompare());
0321     if (searchResult.first != searchResult.second)
0322       paths.push_back(searchResult.first->second);
0323     else
0324       paths.push_back(filter);  //if cant find the path, just  write the filter
0325     //---Morse-----
0326     //std::cout<<filtersAndPaths[filterNr].first<<"  "<<filtersAndPaths[filterNr].second<<std::endl;
0327     //-------------
0328   }
0329 }
0330 
0331 std::string trigTools::getL1SeedFilterOfPath(const HLTConfigProvider& hltConfig, const std::string& path) {
0332   const std::vector<std::string>& modules = hltConfig.moduleLabels(path);
0333 
0334   for (auto const& moduleName : modules) {
0335     if (moduleName.find("hltL1s") == 0)
0336       return moduleName;  //found l1 seed module
0337   }
0338   std::string dummy;
0339   return dummy;
0340 }
0341 
0342 //hunts for first instance of pattern EtX where X = a number of any length and returns X
0343 float trigTools::getEtThresFromName(const std::string& trigName) {
0344   size_t etStrPos = trigName.find("Et");
0345   while (etStrPos != std::string::npos && trigName.find_first_of("1234567890", etStrPos) != etStrPos + 2) {
0346     etStrPos = trigName.find("Et", etStrPos + 1);
0347   }
0348   if (etStrPos != std::string::npos && trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) {
0349     size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
0350 
0351     std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
0352     float etVal;
0353     etValStr >> etVal;
0354     return etVal;
0355   }
0356   return 0;
0357 }
0358 
0359 //hunts for second instance of pattern X where X = a number of any length and returns X
0360 //This has gotten ridiculously more complicated now that filters do not have the "Et" string in them
0361 float trigTools::getSecondEtThresFromName(
0362     const std::string& trigName) {  //std::cout<<"What the heck is this trigName?:"<<trigName<<std::endl;
0363   bool isEle = false, isPhoton = false, isEG = false, isEle2 = false, isPhoton2 = false, isEG2 = false, isSC2 = false;
0364   size_t etStrPos = trigName.npos;
0365   if (trigName.find("Ele") < trigName.find("Photon") && trigName.find("Ele") < trigName.find("EG")) {
0366     etStrPos = trigName.find("Ele");
0367     isEle = true;
0368   } else if (trigName.find("EG") < trigName.find("Photon") && trigName.find("EG") < trigName.find("Ele")) {
0369     etStrPos = trigName.find("EG");
0370     isEG = true;
0371   } else if (trigName.find("Photon") < trigName.find("Ele") && trigName.find("Photon") < trigName.find("EG")) {
0372     etStrPos = trigName.find("Photon");
0373     isPhoton = true;
0374   }
0375   //size_t etStrPos = trigName.find("Et");
0376   //std::cout<<"Got Original Et spot; etStrPos="<<etStrPos<<std::endl;
0377   /*while(etStrPos!=std::string::npos && trigName.find_first_of("1234567890",etStrPos)!=etStrPos+2){
0378     etStrPos = trigName.find("Et",etStrPos+1);//std::cout<<"Got first Et spot; etStrPos="<<etStrPos<<std::endl;
0379     }*/
0380   if (etStrPos != trigName.npos &&
0381       (trigName.find("Ele", etStrPos + 1) != trigName.npos || trigName.find("EG", etStrPos + 1) != trigName.npos ||
0382        trigName.find("Photon", etStrPos + 1) != trigName.npos || trigName.find("SC", etStrPos + 1) != trigName.npos)) {
0383     if (trigName.find("Ele", etStrPos + 1) < trigName.find("Photon", etStrPos + 1) &&
0384         trigName.find("Ele", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
0385         trigName.find("Ele", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
0386       etStrPos = trigName.find("Ele", etStrPos + 1);
0387       isEle2 = true;
0388     } else if (trigName.find("EG", etStrPos + 1) < trigName.find("Photon", etStrPos + 1) &&
0389                trigName.find("EG", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
0390                trigName.find("EG", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
0391       etStrPos = trigName.find("EG", etStrPos + 1);
0392       isEG2 = true;
0393     } else if (trigName.find("Photon", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
0394                trigName.find("Photon", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
0395                trigName.find("Photon", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
0396       etStrPos = trigName.find("Photon", etStrPos + 1);
0397       isPhoton2 = true;
0398     } else if (trigName.find("SC", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
0399                trigName.find("SC", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
0400                trigName.find("SC", etStrPos + 1) < trigName.find("Photon", etStrPos + 1)) {
0401       etStrPos = trigName.find("Photon", etStrPos + 1);
0402       isSC2 = true;
0403     }
0404     //std::cout<<"Got second Et spot; etStrPos="<<etStrPos<<std::endl;//}//get second instance.  if it dne, keep first
0405 
0406     if (isEle2) {
0407       if (etStrPos != trigName.npos &&
0408           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 3) {  //std::cout<<"In if"<<std::endl;
0409         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 3);
0410 
0411         std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
0412         float etVal;
0413         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0414         return etVal;
0415       }
0416     }
0417     if (isEG2 || isSC2) {
0418       if (etStrPos != trigName.npos &&
0419           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) {  //std::cout<<"In if"<<std::endl;
0420         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
0421 
0422         std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
0423         float etVal;
0424         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0425         return etVal;
0426       }
0427     }
0428 
0429     if (isPhoton2) {
0430       if (etStrPos != trigName.npos &&
0431           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 6) {  //std::cout<<"In if"<<std::endl;
0432         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 6);
0433 
0434         std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
0435         float etVal;
0436         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0437         return etVal;
0438       }
0439     }
0440   } else if (etStrPos != trigName.npos) {
0441     if (isEle) {
0442       if (etStrPos != trigName.npos &&
0443           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 3) {  //std::cout<<"In if"<<std::endl;
0444         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 3);
0445 
0446         std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
0447         float etVal;
0448         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0449         return etVal;
0450       }
0451     }
0452     if (isEG) {
0453       if (etStrPos != trigName.npos &&
0454           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) {  //std::cout<<"In if"<<std::endl;
0455         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
0456 
0457         std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
0458         float etVal;
0459         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0460         return etVal;
0461       }
0462     }
0463 
0464     if (isPhoton) {
0465       if (etStrPos != trigName.npos &&
0466           trigName.find_first_of("1234567890", etStrPos) == etStrPos + 6) {  //std::cout<<"In if"<<std::endl;
0467         size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 6);
0468 
0469         std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
0470         float etVal;
0471         etValStr >> etVal;  //std::cout<<"TrigName= "<<trigName<<"   etVal= "<<etVal<<std::endl;
0472         return etVal;
0473       }
0474     }
0475   }
0476 
0477   return 0;
0478 }