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 || pathName.find(
"Activity")==4 || pathName.find(
"Physics")==4 || pathName.find(
"DiSC") == 4)
119 && (pathName.find(
"Jet")==pathName.npos && pathName.find(
"Muon")==pathName.npos
120 && pathName.find(
"Tau")==pathName.npos && pathName.find(
"HT")==pathName.npos
121 && pathName.find(
"MR")==pathName.npos && pathName.find(
"LEITI")==pathName.npos
122 && pathName.find(
"Jpsi")==pathName.npos && pathName.find(
"Ups")==pathName.npos ) ){
129 if(!filters.empty()){
141 || filter==filters.size()-1 ){
142 activeFilters.push_back(filters[filter]);
145 if(pathName.find(
"Photon")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos || pathName.find(
"DiSC") == 4){
146 activePhoFilters.push_back(filters[filter]);
147 int posPho = pathName.find(
"Pho")+1;
148 if( pathName.find(
"Pho",posPho)!=pathName.npos || pathName.find(
"SC",posPho)!=pathName.npos) {
150 activePho2LegFilters.push_back(filters[filter]);
154 if(pathName.find(
"Ele")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos ){
155 activeEleFilters.push_back(filters[filter]);
156 int posEle = pathName.find(
"Ele")+1;
157 if( pathName.find(
"Ele",posEle)!=pathName.npos || pathName.find(
"SC",posEle)!=pathName.npos ){
165 activeEle2LegFilters.push_back(filters[filter]+
"::"+filters[filter+1]);
183 std::sort(activeFilters.begin(),activeFilters.end());
184 std::sort(activeEleFilters.begin(),activeEleFilters.end());
185 std::sort(activeEle2LegFilters.begin(),activeEle2LegFilters.end());
186 std::sort(activePhoFilters.begin(),activePhoFilters.end());
196 std::vector<std::string> filteredNames;
205 filteredNames = activeFilters;
206 namesToFilter.swap(filteredNames);
213 std::vector<std::string> filteredNames;
215 for(
size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
216 std::vector<std::string>
names;
218 if(names.size()!=2)
continue;
219 if(std::binary_search(activeFilters.begin(),activeFilters.end(),names[0]) &&
220 std::binary_search(activeFilters.begin(),activeFilters.end(),names[1])){
221 filteredNames.push_back(namesToFilter[inputFilterNr]);
225 namesToFilter.swap(filteredNames);
232 bool operator()(
const std::pair<std::string,std::string>&lhs,
233 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs.first,rhs.first);}
234 bool operator()(
const std::pair<std::string,std::string>&lhs,
235 const std::pair<std::string,std::string>::first_type& rhs)
const{
return keyLess(lhs.first,rhs);}
236 bool operator()(
const std::pair<std::string,std::string>::first_type &lhs,
237 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs,rhs.first);}
239 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;}
246 std::vector<std::pair<std::string,std::string> > filtersAndPaths;
248 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
250 if(pathName.find(
"HLT_")==0){
253 const std::vector<std::string>& pathFilters = hltConfig.
moduleLabels(pathNr);
254 if(!pathFilters.empty()){
255 if(pathFilters.back()==
"hltBoolEnd" && pathFilters.size()>=2){
257 filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size()-2],
pathName));
258 }
else filtersAndPaths.push_back(std::make_pair(pathFilters.back(),
pathName));
265 for(
size_t filterNr=0;filterNr<filters.size();filterNr++){
266 typedef std::vector<std::pair<std::string,std::string> >::const_iterator VecIt;
267 std::pair<VecIt,VecIt> searchResult = std::equal_range(filtersAndPaths.begin(),filtersAndPaths.end(),filters[filterNr],
StringPairCompare());
268 if(searchResult.first!=searchResult.second) paths.push_back(searchResult.first->second);
269 else paths.push_back(filters[filterNr]);
281 for(
size_t moduleNr=0;moduleNr<modules.size();moduleNr++){
283 if(moduleName.find(
"hltL1s")==0)
return moduleName;
293 size_t etStrPos = trigName.find(
"Et");
294 while(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)!=etStrPos+2){
295 etStrPos = trigName.find(
"Et",etStrPos+1);
297 if(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
298 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
300 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
314 bool isEle=
false,isPhoton=
false,isEG=
false,isEle2=
false,isPhoton2=
false,isEG2=
false,isSC2=
false;
315 size_t etStrPos = trigName.npos;
316 if( trigName.find(
"Ele")<trigName.find(
"Photon") && trigName.find(
"Ele")<trigName.find(
"EG") ){
317 etStrPos=trigName.find(
"Ele");isEle=
true; }
318 else if( trigName.find(
"EG")<trigName.find(
"Photon") && trigName.find(
"EG")<trigName.find(
"Ele") ){
319 etStrPos=trigName.find(
"EG");isEG=
true; }
320 else if( trigName.find(
"Photon")<trigName.find(
"Ele") && trigName.find(
"Photon")<trigName.find(
"EG") ){
321 etStrPos=trigName.find(
"Photon");isPhoton=
true; }
327 if(etStrPos!=trigName.npos
328 && ( trigName.find(
"Ele",etStrPos+1)!=trigName.npos || trigName.find(
"EG",etStrPos+1)!=trigName.npos
329 || trigName.find(
"Photon",etStrPos+1)!=trigName.npos || trigName.find(
"SC",etStrPos+1)!=trigName.npos)){
330 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;}
331 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;}
332 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;}
333 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;}
337 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
338 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
340 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
347 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
348 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
350 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
358 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
359 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
361 std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
368 else if(etStrPos!=trigName.npos){
370 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
371 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
373 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
380 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
381 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
383 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
391 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
392 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
394 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