7 #include <boost/algorithm/string.hpp>
11 const std::vector<std::pair<std::string,int> >&
filters,
17 for(
size_t filterNrInVec=0;filterNrInVec<
filters.size();filterNrInVec++){
20 if(filterNrInEvt<trigEvt->sizeFilters()){
22 if(static_cast<int>(trigKeys.size())>=
filters[filterNrInVec].
second){
23 evtTrigs |=filterCode;
48 if(psetRegistry==
NULL)
return -1;
50 const std::map<std::string,edm::Entry>& mapOfPara = psetIt->second.tbl();
51 const std::map<std::string,edm::Entry>::const_iterator itToModLabel = mapOfPara.find(
"@module_label");
52 if(itToModLabel!=mapOfPara.end()){
53 if(itToModLabel->second.getString()==
filterName){
54 std::map<std::string,edm::Entry>::const_iterator itToCandCut = mapOfPara.find(
"ncandcut");
55 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I')
return itToCandCut->second.getInt32();
57 itToCandCut = mapOfPara.find(
"nZcandcut");
58 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I')
return itToCandCut->second.getInt32();
60 itToCandCut = mapOfPara.find(
"MinN");
61 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I')
return itToCandCut->second.getInt32();
63 itToCandCut = mapOfPara.find(
"minN");
64 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I')
return itToCandCut->second.getInt32();
105 void trigTools::getActiveFilters(
const HLTConfigProvider&
hltConfig,std::vector<std::string>& activeFilters,std::vector<std::string>& activeEleFilters,std::vector<std::string>& activeEle2LegFilters,std::vector<std::string>& activePhoFilters,std::vector<std::string>& activePho2LegFilters)
108 activeFilters.clear();
109 activeEleFilters.clear();
110 activeEle2LegFilters.clear();
111 activePhoFilters.clear();
112 activePho2LegFilters.clear();
114 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
117 if(pathName.find(
"HLT_")==0){
118 if((pathName.find(
"Photon")==4 || pathName.find(
"Ele")==4 || pathName.find(
"EG")!=pathName.npos
119 || pathName.find(
"PAPhoton")==4 || pathName.find(
"PAEle")==4 || pathName.find(
"PASinglePhoton")==4
120 || pathName.find(
"HIPhoton")==4 || pathName.find(
"HIEle")==4 || pathName.find(
"HISinglePhoton")==4
121 || pathName.find(
"Activity")==4 || pathName.find(
"Physics")==4 || pathName.find(
"DiSC") == 4)
122 && (pathName.find(
"Jet")==pathName.npos && pathName.find(
"Muon")==pathName.npos
123 && pathName.find(
"Tau")==pathName.npos && pathName.find(
"HT")==pathName.npos
124 && pathName.find(
"MR")==pathName.npos && pathName.find(
"LEITI")==pathName.npos
125 && pathName.find(
"Jpsi")==pathName.npos && pathName.find(
"Ups")==pathName.npos ) ){
132 if(!filters.empty()){
144 || filter==filters.size()-1 ){
145 activeFilters.push_back(filters[filter]);
148 if(pathName.find(
"Photon")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos || pathName.find(
"DiSC") == 4){
149 activePhoFilters.push_back(filters[filter]);
150 int posPho = pathName.find(
"Pho")+1;
151 if( pathName.find(
"Pho",posPho)!=pathName.npos || pathName.find(
"SC",posPho)!=pathName.npos) {
153 activePho2LegFilters.push_back(filters[filter]);
157 if(pathName.find(
"Ele")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos ){
158 activeEleFilters.push_back(filters[filter]);
159 int posEle = pathName.find(
"Ele")+1;
160 if( pathName.find(
"Ele",posEle)!=pathName.npos || pathName.find(
"SC",posEle)!=pathName.npos ){
168 activeEle2LegFilters.push_back(filters[filter]+
"::"+filters[filter+1]);
186 std::sort(activeFilters.begin(),activeFilters.end());
187 std::sort(activeEleFilters.begin(),activeEleFilters.end());
188 std::sort(activeEle2LegFilters.begin(),activeEle2LegFilters.end());
189 std::sort(activePhoFilters.begin(),activePhoFilters.end());
199 std::vector<std::string> filteredNames;
208 filteredNames = activeFilters;
209 namesToFilter.swap(filteredNames);
216 std::vector<std::string> filteredNames;
218 for(
size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
219 std::vector<std::string>
names;
221 if(names.size()!=2)
continue;
222 if(std::binary_search(activeFilters.begin(),activeFilters.end(),names[0]) &&
223 std::binary_search(activeFilters.begin(),activeFilters.end(),names[1])){
224 filteredNames.push_back(namesToFilter[inputFilterNr]);
228 namesToFilter.swap(filteredNames);
235 bool operator()(
const std::pair<std::string,std::string>&lhs,
236 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs.first,rhs.first);}
237 bool operator()(
const std::pair<std::string,std::string>&lhs,
238 const std::pair<std::string,std::string>::first_type& rhs)
const{
return keyLess(lhs.first,rhs);}
239 bool operator()(
const std::pair<std::string,std::string>::first_type &lhs,
240 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs,rhs.first);}
242 bool keyLess(
const std::pair<std::string,std::string>::first_type& k1,
const std::pair<std::string,std::string>::first_type&
k2)
const{
return k1<
k2;}
249 std::vector<std::pair<std::string,std::string> > filtersAndPaths;
251 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
253 if(pathName.find(
"HLT_")==0){
256 const std::vector<std::string>& pathFilters = hltConfig.
moduleLabels(pathNr);
257 if(!pathFilters.empty()){
258 if(pathFilters.back()==
"hltBoolEnd" && pathFilters.size()>=2){
260 filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size()-2],
pathName));
261 }
else filtersAndPaths.push_back(std::make_pair(pathFilters.back(),
pathName));
268 for(
size_t filterNr=0;filterNr<filters.size();filterNr++){
269 typedef std::vector<std::pair<std::string,std::string> >::const_iterator VecIt;
270 std::pair<VecIt,VecIt> searchResult = std::equal_range(filtersAndPaths.begin(),filtersAndPaths.end(),filters[filterNr],
StringPairCompare());
271 if(searchResult.first!=searchResult.second) paths.push_back(searchResult.first->second);
272 else paths.push_back(filters[filterNr]);
284 for(
size_t moduleNr=0;moduleNr<modules.size();moduleNr++){
286 if(moduleName.find(
"hltL1s")==0)
return moduleName;
296 size_t etStrPos = trigName.find(
"Et");
297 while(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)!=etStrPos+2){
298 etStrPos = trigName.find(
"Et",etStrPos+1);
300 if(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
301 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
303 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
317 bool isEle=
false,isPhoton=
false,isEG=
false,isEle2=
false,isPhoton2=
false,isEG2=
false,isSC2=
false;
318 size_t etStrPos = trigName.npos;
319 if( trigName.find(
"Ele")<trigName.find(
"Photon") && trigName.find(
"Ele")<trigName.find(
"EG") ){
320 etStrPos=trigName.find(
"Ele");isEle=
true; }
321 else if( trigName.find(
"EG")<trigName.find(
"Photon") && trigName.find(
"EG")<trigName.find(
"Ele") ){
322 etStrPos=trigName.find(
"EG");isEG=
true; }
323 else if( trigName.find(
"Photon")<trigName.find(
"Ele") && trigName.find(
"Photon")<trigName.find(
"EG") ){
324 etStrPos=trigName.find(
"Photon");isPhoton=
true; }
330 if(etStrPos!=trigName.npos
331 && ( trigName.find(
"Ele",etStrPos+1)!=trigName.npos || trigName.find(
"EG",etStrPos+1)!=trigName.npos
332 || trigName.find(
"Photon",etStrPos+1)!=trigName.npos || trigName.find(
"SC",etStrPos+1)!=trigName.npos)){
333 if(trigName.find(
"Ele",etStrPos+1)<trigName.find(
"Photon",etStrPos+1) && trigName.find(
"Ele",etStrPos+1)<trigName.find(
"EG",etStrPos+1) && trigName.find(
"Ele",etStrPos+1)<trigName.find(
"SC",etStrPos+1) ){etStrPos=trigName.find(
"Ele",etStrPos+1);isEle2=
true;}
334 else if(trigName.find(
"EG",etStrPos+1)<trigName.find(
"Photon",etStrPos+1) && trigName.find(
"EG",etStrPos+1)<trigName.find(
"Ele",etStrPos+1) && trigName.find(
"EG",etStrPos+1)<trigName.find(
"SC",etStrPos+1)){etStrPos=trigName.find(
"EG",etStrPos+1);isEG2=
true;}
335 else if(trigName.find(
"Photon",etStrPos+1)<trigName.find(
"EG",etStrPos+1) && trigName.find(
"Photon",etStrPos+1)<trigName.find(
"Ele",etStrPos+1) && trigName.find(
"Photon",etStrPos+1)<trigName.find(
"SC",etStrPos+1)){etStrPos=trigName.find(
"Photon",etStrPos+1);isPhoton2=
true;}
336 else if(trigName.find(
"SC",etStrPos+1)<trigName.find(
"EG",etStrPos+1) && trigName.find(
"SC",etStrPos+1)<trigName.find(
"Ele",etStrPos+1) && trigName.find(
"SC",etStrPos+1)<trigName.find(
"Photon",etStrPos+1)){etStrPos=trigName.find(
"Photon",etStrPos+1);isSC2=
true;}
340 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
341 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
343 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
350 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
351 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
353 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
361 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
362 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
364 std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
371 else if(etStrPos!=trigName.npos){
373 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
374 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
376 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
383 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
384 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
386 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
394 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
395 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
397 std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
unsigned int size() const
number of trigger paths in trigger table
map_type::const_iterator const_iterator
The single EDProduct to be saved for each event (AOD case)
const std::string & triggerName(unsigned int triggerIndex) const
static const HistoName names[]
const_iterator end() const
TrigBitSet getCode(const char *descript) const
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool operator()(const std::pair< std::string, std::string >::first_type &lhs, const std::pair< std::string, std::string > &rhs) const
std::vector< TPRegexp > filters
const std::vector< std::string > & saveTagsModules(unsigned int trigger) const
U second(std::pair< T, U > const &p)
bool keyLess(const std::pair< std::string, std::string >::first_type &k1, const std::pair< std::string, std::string >::first_type &k2) const
std::string moduleName(Provenance const &provenance)
bool operator()(const std::pair< std::string, std::string > &lhs, const std::pair< std::string, std::string > &rhs) const
const_iterator begin() const
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< size_type > Keys
bool operator()(const std::pair< std::string, std::string > &lhs, const std::pair< std::string, std::string >::first_type &rhs) const
static Registry * instance()
std::bitset< maxNrBits_ > TrigBitSet