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++){
116 if(pathName.find(
"HLT_")==0){
117 if((pathName.find(
"Photon")==4 || pathName.find(
"Ele")==4 || pathName.find(
"EG")==4 || pathName.find(
"Activity")==4 || pathName.find(
"Physics")==4)
118 && (pathName.find(
"Jet")==pathName.npos && pathName.find(
"Muon")==pathName.npos
119 && pathName.find(
"Tau")==pathName.npos && pathName.find(
"HT")==pathName.npos
120 && pathName.find(
"MR")==pathName.npos && pathName.find(
"LEITI")==pathName.npos
121 && pathName.find(
"Jpsi")==pathName.npos && pathName.find(
"Ups")==pathName.npos ) ){
128 if(!filters.empty()){
138 || filter==filters.size()-1 ){
139 activeFilters.push_back(filters[filter]);
141 if(pathName.find(
"Photon")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos ){
142 activePhoFilters.push_back(filters[filter]);
143 int posPho = pathName.find(
"Pho")+1;
144 if( pathName.find(
"Pho",posPho)!=pathName.npos || pathName.find(
"SC",posPho)!=pathName.npos ){
146 activePho2LegFilters.push_back(filters[filter]);
150 if(pathName.find(
"Ele")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos ){
151 activeEleFilters.push_back(filters[filter]);
152 int posEle = pathName.find(
"Ele")+1;
153 if( pathName.find(
"Ele",posEle)!=pathName.npos || pathName.find(
"SC",posEle)!=pathName.npos ){
161 activeEle2LegFilters.push_back(filters[filter]+
"::"+filters[filter+1]);
179 std::sort(activeFilters.begin(),activeFilters.end());
180 std::sort(activeEleFilters.begin(),activeEleFilters.end());
181 std::sort(activeEle2LegFilters.begin(),activeEle2LegFilters.end());
182 std::sort(activePhoFilters.begin(),activePhoFilters.end());
192 std::vector<std::string> filteredNames;
201 filteredNames = activeFilters;
202 namesToFilter.swap(filteredNames);
209 std::vector<std::string> filteredNames;
211 for(
size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
212 std::vector<std::string>
names;
214 if(names.size()!=2)
continue;
215 if(std::binary_search(activeFilters.begin(),activeFilters.end(),names[0]) &&
216 std::binary_search(activeFilters.begin(),activeFilters.end(),names[1])){
217 filteredNames.push_back(namesToFilter[inputFilterNr]);
221 namesToFilter.swap(filteredNames);
228 bool operator()(
const std::pair<std::string,std::string>&lhs,
229 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs.first,rhs.first);}
230 bool operator()(
const std::pair<std::string,std::string>&lhs,
231 const std::pair<std::string,std::string>::first_type& rhs)
const{
return keyLess(lhs.first,rhs);}
232 bool operator()(
const std::pair<std::string,std::string>::first_type &lhs,
233 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs,rhs.first);}
235 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;}
242 std::vector<std::pair<std::string,std::string> > filtersAndPaths;
244 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
246 if(pathName.find(
"HLT_")==0){
249 const std::vector<std::string>& pathFilters = hltConfig.
moduleLabels(pathNr);
250 if(!pathFilters.empty()){
251 if(pathFilters.back()==
"hltBoolEnd" && pathFilters.size()>=2){
253 filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size()-2],
pathName));
254 }
else filtersAndPaths.push_back(std::make_pair(pathFilters.back(),
pathName));
261 for(
size_t filterNr=0;filterNr<filters.size();filterNr++){
262 typedef std::vector<std::pair<std::string,std::string> >::const_iterator VecIt;
263 std::pair<VecIt,VecIt> searchResult = std::equal_range(filtersAndPaths.begin(),filtersAndPaths.end(),filters[filterNr],
StringPairCompare());
264 if(searchResult.first!=searchResult.second) paths.push_back(searchResult.first->second);
265 else paths.push_back(filters[filterNr]);
277 for(
size_t moduleNr=0;moduleNr<modules.size();moduleNr++){
279 if(moduleName.find(
"hltL1s")==0)
return moduleName;
289 size_t etStrPos = trigName.find(
"Et");
290 while(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)!=etStrPos+2){
291 etStrPos = trigName.find(
"Et",etStrPos+1);
293 if(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
294 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
296 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
310 bool isEle=
false,isPhoton=
false,isEG=
false,isEle2=
false,isPhoton2=
false,isEG2=
false,isSC2=
false;
311 size_t etStrPos = trigName.npos;
312 if( trigName.find(
"Ele")<trigName.find(
"Photon") && trigName.find(
"Ele")<trigName.find(
"EG") ){
313 etStrPos=trigName.find(
"Ele");isEle=
true; }
314 else if( trigName.find(
"EG")<trigName.find(
"Photon") && trigName.find(
"EG")<trigName.find(
"Ele") ){
315 etStrPos=trigName.find(
"EG");isEG=
true; }
316 else if( trigName.find(
"Photon")<trigName.find(
"Ele") && trigName.find(
"Photon")<trigName.find(
"EG") ){
317 etStrPos=trigName.find(
"Photon");isPhoton=
true; }
323 if(etStrPos!=trigName.npos
324 && ( trigName.find(
"Ele",etStrPos+1)!=trigName.npos || trigName.find(
"EG",etStrPos+1)!=trigName.npos
325 || trigName.find(
"Photon",etStrPos+1)!=trigName.npos || trigName.find(
"SC",etStrPos+1)!=trigName.npos)){
326 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;}
327 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;}
328 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;}
329 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;}
333 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
334 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
336 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
343 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
344 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
346 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
354 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
355 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
357 std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
364 else if(etStrPos!=trigName.npos){
366 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
367 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
369 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
376 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
377 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
379 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
387 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
388 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
390 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)
tuple path
else: Piece not in the list, fine.
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