5 #include <boost/algorithm/string.hpp> 9 const std::vector<std::pair<std::string,int> >&
filters,
15 for(
size_t filterNrInVec=0;filterNrInVec<
filters.size();filterNrInVec++){
18 if(filterNrInEvt<trigEvt->sizeFilters()){
20 if(static_cast<int>(trigKeys.size())>=
filters[filterNrInVec].
second){
21 evtTrigs |=filterCode;
43 std::vector<int> retVal(filterNames.size(),-2);
50 std::vector<std::string> filterEntryStrings;
51 filterEntryStrings.reserve(filterNames.size());
52 for (
unsigned int i=0;
i<filterNames.size();
i++) {
53 const edm::Entry filterEntry(mag0,filterNames[
i],
true);
54 filterEntryStrings.push_back(filterEntry.
toString());
59 if(psetRegistry==
NULL) { retVal=std::vector<int>(filterNames.size(),-1);
return retVal;}
61 const std::map<std::string,edm::Entry>& mapOfPara = psetIt->second.tbl();
62 const std::map<std::string,edm::Entry>::const_iterator itToModLabel = mapOfPara.find(mag0);
63 if(itToModLabel!=mapOfPara.end()){
64 std::string itString=itToModLabel->second.toString();
66 for (
unsigned int i=0;
i<filterNames.size();
i++) {
67 if ( retVal[
i] == -1 )
continue;
69 if(itString==filterEntryStrings[
i]){
70 std::map<std::string,edm::Entry>::const_iterator itToCandCut = mapOfPara.find(mag1);
71 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I') retVal[i]=itToCandCut->second.getInt32();
73 itToCandCut = mapOfPara.find(mag2);
74 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I') retVal[i]=itToCandCut->second.getInt32();
76 itToCandCut = mapOfPara.find(mag3);
77 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I') retVal[i]=itToCandCut->second.getInt32();
79 itToCandCut = mapOfPara.find(mag4);
80 if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()==
'I') retVal[i]= itToCandCut->second.getInt32();
89 for (
unsigned int i=0;
i<filterNames.size();
i++)
90 if ( retVal[
i]==-2 ) retVal[
i]=-1;
125 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)
128 activeFilters.clear();
129 activeEleFilters.clear();
130 activeEle2LegFilters.clear();
131 activePhoFilters.clear();
132 activePho2LegFilters.clear();
134 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
137 if(pathName.find(
"HLT_")==0){
138 if((pathName.find(
"Photon")==4 || pathName.find(
"Ele")==4 || pathName.find(
"EG")!=pathName.npos
139 || pathName.find(
"PAPhoton")==4 || pathName.find(
"PAEle")==4 || pathName.find(
"PASinglePhoton")==4
140 || pathName.find(
"HIPhoton")==4 || pathName.find(
"HIEle")==4 || pathName.find(
"HISinglePhoton")==4
141 || pathName.find(
"Activity")==4 || pathName.find(
"Physics")==4 || pathName.find(
"DiSC") == 4)
142 && (pathName.find(
"Jet")==pathName.npos && pathName.find(
"Muon")==pathName.npos
143 && pathName.find(
"Tau")==pathName.npos && pathName.find(
"HT")==pathName.npos
144 && pathName.find(
"MR")==pathName.npos && pathName.find(
"LEITI")==pathName.npos
145 && pathName.find(
"Jpsi")==pathName.npos && pathName.find(
"Ups")==pathName.npos ) ){
152 if(!filters.empty()){
161 int minNRFF=minNRFFCache[
filter];
163 if (
filter<filters.size()-1) minNRFFP1=minNRFFCache[
filter+1];
165 ( minNRFF==1 && minNRFFP1==2)
166 || (minNRFF==1 && minNRFFP1==1 && filters[
filter+1].find(
"Mass")!=filters[
filter+1].npos)
167 || (minNRFF==1 && minNRFFP1==1 && filters[
filter+1].
find(
"FEM")!=filters[
filter+1].npos)
168 || (minNRFF==1 && minNRFFP1==1 && filters[
filter+1].
find(
"PFMT")!=filters[
filter+1].npos)
169 ||
filter==filters.size()-1 ){
170 activeFilters.push_back(filters[
filter]);
173 if(pathName.find(
"Photon")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos || pathName.find(
"DiSC") == 4){
174 activePhoFilters.push_back(filters[filter]);
175 int posPho = pathName.find(
"Pho")+1;
176 if( pathName.find(
"Pho",posPho)!=pathName.npos || pathName.find(
"SC",posPho)!=pathName.npos) {
178 activePho2LegFilters.push_back(filters[filter]);
182 if(pathName.find(
"Ele")!=pathName.npos || pathName.find(
"Activity")!=pathName.npos || pathName.find(
"Physics")!=pathName.npos ){
183 activeEleFilters.push_back(filters[filter]);
184 int posEle = pathName.find(
"Ele")+1;
185 if( pathName.find(
"Ele",posEle)!=pathName.npos || pathName.find(
"SC",posEle)!=pathName.npos ){
187 ( minNRFF==1 && minNRFFP1==2)
188 || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].find(
"Mass")!=filters[filter+1].npos)
189 || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].
find(
"SC")!=filters[filter+1].npos)
190 || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].
find(
"FEM")!=filters[filter+1].npos)
193 activeEle2LegFilters.push_back(filters[filter]+
"::"+filters[filter+1]);
211 std::sort(activeFilters.begin(),activeFilters.end());
212 std::sort(activeEleFilters.begin(),activeEleFilters.end());
213 std::sort(activeEle2LegFilters.begin(),activeEle2LegFilters.end());
214 std::sort(activePhoFilters.begin(),activePhoFilters.end());
224 std::vector<std::string> filteredNames;
233 filteredNames = activeFilters;
234 namesToFilter.swap(filteredNames);
241 std::vector<std::string> filteredNames;
243 for(
size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
244 std::vector<std::string>
names;
246 if(names.size()!=2)
continue;
247 if(std::binary_search(activeFilters.begin(),activeFilters.end(),names[0]) &&
248 std::binary_search(activeFilters.begin(),activeFilters.end(),names[1])){
249 filteredNames.push_back(namesToFilter[inputFilterNr]);
253 namesToFilter.swap(filteredNames);
260 bool operator()(
const std::pair<std::string,std::string>&lhs,
261 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs.first,rhs.first);}
262 bool operator()(
const std::pair<std::string,std::string>&lhs,
263 const std::pair<std::string,std::string>::first_type& rhs)
const{
return keyLess(lhs.first,rhs);}
264 bool operator()(
const std::pair<std::string,std::string>::first_type &lhs,
265 const std::pair<std::string,std::string>& rhs)
const{
return keyLess(lhs,rhs.first);}
267 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;}
274 std::vector<std::pair<std::string,std::string> > filtersAndPaths;
276 for(
size_t pathNr=0;pathNr<hltConfig.
size();pathNr++){
278 if(pathName.find(
"HLT_")==0){
281 const std::vector<std::string>& pathFilters = hltConfig.
moduleLabels(pathNr);
282 if(!pathFilters.empty()){
283 if(pathFilters.back()==
"hltBoolEnd" && pathFilters.size()>=2){
285 filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size()-2],pathName));
286 }
else filtersAndPaths.push_back(std::make_pair(pathFilters.back(),pathName));
293 for(
size_t filterNr=0;filterNr<filters.size();filterNr++){
294 typedef std::vector<std::pair<std::string,std::string> >::const_iterator VecIt;
295 std::pair<VecIt,VecIt> searchResult = std::equal_range(filtersAndPaths.begin(),filtersAndPaths.end(),filters[filterNr],
StringPairCompare());
296 if(searchResult.first!=searchResult.second) paths.push_back(searchResult.first->second);
297 else paths.push_back(filters[filterNr]);
309 for(
size_t moduleNr=0;moduleNr<modules.size();moduleNr++){
311 if(moduleName.find(
"hltL1s")==0)
return moduleName;
321 size_t etStrPos = trigName.find(
"Et");
322 while(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)!=etStrPos+2){
323 etStrPos = trigName.find(
"Et",etStrPos+1);
325 if(etStrPos!=std::string::npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
326 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
328 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
342 bool isEle=
false,isPhoton=
false,isEG=
false,isEle2=
false,isPhoton2=
false,isEG2=
false,isSC2=
false;
343 size_t etStrPos = trigName.npos;
344 if( trigName.find(
"Ele")<trigName.find(
"Photon") && trigName.find(
"Ele")<trigName.find(
"EG") ){
345 etStrPos=trigName.find(
"Ele");isEle=
true; }
346 else if( trigName.find(
"EG")<trigName.find(
"Photon") && trigName.find(
"EG")<trigName.find(
"Ele") ){
347 etStrPos=trigName.find(
"EG");isEG=
true; }
348 else if( trigName.find(
"Photon")<trigName.find(
"Ele") && trigName.find(
"Photon")<trigName.find(
"EG") ){
349 etStrPos=trigName.find(
"Photon");isPhoton=
true; }
355 if(etStrPos!=trigName.npos
356 && ( trigName.find(
"Ele",etStrPos+1)!=trigName.npos || trigName.find(
"EG",etStrPos+1)!=trigName.npos
357 || trigName.find(
"Photon",etStrPos+1)!=trigName.npos || trigName.find(
"SC",etStrPos+1)!=trigName.npos)){
358 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;}
359 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;}
360 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;}
361 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;}
365 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
366 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
368 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
375 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
376 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
378 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
386 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
387 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
389 std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
396 else if(etStrPos!=trigName.npos){
398 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+3){
399 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+3);
401 std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
408 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+2){
409 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+2);
411 std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
419 if(etStrPos!=trigName.npos && trigName.find_first_of(
"1234567890",etStrPos)==etStrPos+6){
420 size_t endOfEtValStr = trigName.find_first_not_of(
"1234567890",etStrPos+6);
422 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
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
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
std::string toString() const
static Registry * instance()
std::bitset< maxNrBits_ > TrigBitSet