CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/HLTriggerOffline/Egamma/src/EmDQMFeeder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EmDQMFeeder
00004 // Class:      EmDQMFeeder
00005 // 
00006 //
00007 // Original Author:  Thomas Reis,40 4-B24,+41227671567,
00008 //         Created:  Tue Mar 15 12:24:11 CET 2011
00009 // $Id: EmDQMFeeder.cc,v 1.23 2012/03/17 20:43:14 treis Exp $
00010 //
00011 //
00012 
00013 // class header file
00014 #include "HLTriggerOffline/Egamma/interface/EmDQMFeeder.h"
00015 
00017 // constructors and destructor
00019 EmDQMFeeder::EmDQMFeeder(const edm::ParameterSet& iConfig_) :
00020   iConfig(iConfig_)
00021 {
00022    //now do what ever initialization is needed
00023    //processName_ = iConfig_.getParameter<std::string>("processname");
00024    triggerObject_ = iConfig_.getParameter<edm::InputTag>("triggerobject");
00025    verbosity_ = iConfig_.getUntrackedParameter<unsigned int>("verbosity",0);
00026 }
00027 
00028 
00029 EmDQMFeeder::~EmDQMFeeder()
00030 {
00031  
00032    // do anything here that needs to be done at desctruction time
00033    // (e.g. close files, deallocate resources etc.)
00034 
00035 }
00036 
00037 
00039 // member functions
00041 
00042 // ------------ method called for each event  ------------
00043 void
00044 EmDQMFeeder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00045 {
00046    using namespace edm;
00047  
00048    for (unsigned i = 0; i < emDQMmodules.size(); ++i) {
00049       emDQMmodules[i]->analyze(iEvent, iSetup);
00050    }
00051 
00052 // #ifdef THIS_IS_AN_EVENT_EXAMPLE
00053 //    Handle<ExampleData> pIn;
00054 //    iEvent.getByLabel("example",pIn);
00055 // #endif
00056 //    
00057 // #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00058 //    ESHandle<SetupData> pSetup;
00059 //    iSetup.get<SetupRecord>().get(pSetup);
00060 // #endif
00061 }
00062 
00063 
00064 // ------------ method called once each job just before starting event loop  ------------
00065 void 
00066 EmDQMFeeder::beginJob()
00067 {
00068 //  for (unsigned i = 0; i < emDQMmodules.size(); ++i)
00069 //     emDQMmodules[i]->beginJob();
00070 }
00071 
00072 // ------------ method called once each job just after ending the event loop  ------------
00073 void 
00074 EmDQMFeeder::endJob() 
00075 {
00076   for (unsigned i = 0; i < emDQMmodules.size(); ++i)
00077      emDQMmodules[i]->endJob();
00078 }
00079 
00080 // ------------ method called when starting to processes a run  ------------
00081 void 
00082 EmDQMFeeder::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup)
00083 {
00084    bool changed(true);
00085    //if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
00086    if (hltConfig_.init(iRun, iSetup, triggerObject_.process(), changed)) {
00087 
00088       // if init returns TRUE, initialisation has succeeded!
00089 
00090       if (verbosity_ >= OUTPUT_ALL) {
00091          // Output general information on the menu
00092          edm::LogPrint("EmDQMFeeder") << "inited=" << hltConfig_.inited();
00093          edm::LogPrint("EmDQMFeeder") << "changed=" << hltConfig_.changed();
00094          edm::LogPrint("EmDQMFeeder") << "processName=" << hltConfig_.processName();
00095          edm::LogPrint("EmDQMFeeder") << "tableName=" << hltConfig_.tableName();
00096          edm::LogPrint("EmDQMFeeder") << "size=" << hltConfig_.size();
00097       }
00098 
00099       // All electron and photon paths
00100       std::vector<std::vector<std::string> > egammaPaths = findEgammaPaths();
00101       //std::cout << "Found " << egammaPaths[TYPE_SINGLE_ELE].size() << " single electron paths" << std::endl;
00102       //std::cout << "Found " << egammaPaths[TYPE_DOUBLE_ELE].size() << " double electron paths" << std::endl;
00103       //std::cout << "Found " << egammaPaths[TYPE_TRIPLE_ELE].size() << " triple electron paths" << std::endl;
00104       //std::cout << "Found " << egammaPaths[TYPE_SINGLE_PHOTON].size() << " single photon paths" << std::endl;
00105       //std::cout << "Found " << egammaPaths[TYPE_DOUBLE_PHOTON].size() << " double photon paths" << std::endl;
00106 
00107       std::vector<std::string> filterModules;
00108 
00109       for (unsigned int j=0; j < egammaPaths.size() ; j++) {
00110 
00111          for (unsigned int i=0; i < egammaPaths.at(j).size() ; i++) {
00112             // get pathname of this trigger 
00113             const std::string pathName = egammaPaths.at(j).at(i);
00114             if (verbosity_ >= OUTPUT_ALL)
00115                edm::LogPrint("EmDQMFeeder") << "Path: " << pathName;
00116 
00117             // get filters of the current path
00118             filterModules = getFilterModules(pathName);
00119 
00120             //--------------------         
00121             edm::ParameterSet paramSet;
00122 
00123             paramSet.addUntrackedParameter("pathIndex", hltConfig_.triggerIndex(pathName));
00124             paramSet.addParameter("@module_label", hltConfig_.removeVersion(pathName) + "_DQM");
00125             //paramSet.addParameter("@module_label", pathName + "_DQM");
00126             //paramSet.addParameter("triggerobject", iConfig.getParameter<edm::InputTag>("triggerobject"));
00127             paramSet.addParameter("triggerobject", triggerObject_);
00128             paramSet.addParameter("genEtaAcc", iConfig.getParameter<double>("genEtaAcc"));
00129             paramSet.addParameter("genEtAcc", iConfig.getParameter<double>("genEtAcc"));
00130 
00131             // plotting parameters (untracked because they don't affect the physics)
00132             double genEtMin = getPrimaryEtCut(pathName);
00133             if (genEtMin >= 0) {
00134                paramSet.addUntrackedParameter("genEtMin", genEtMin);
00135             } else {
00136                if (verbosity_ >= OUTPUT_WARNINGS)
00137                   edm::LogWarning("EmDQMFeeder") << "Pathname: '" << pathName << "':  Unable to determine a minimum Et. Will not include this path in the validation.";
00138                continue;
00139             }
00140 
00141             // set the x axis of the et plots to some reasonable value based
00142             // on the primary et cut determined from the path name
00143             double ptMax = iConfig.getUntrackedParameter<double>("PtMax",1000.);
00144             double ptMin = iConfig.getUntrackedParameter<double>("PtMin",0.);
00145             if (ptMax < (1.2*genEtMin)) {
00146                paramSet.addUntrackedParameter<double>("PtMax", (10*ceil(0.12 * genEtMin)));
00147                paramSet.addUntrackedParameter<double>("PtMin", (10*ceil(0.12 * genEtMin) - ptMax + ptMin));
00148             }
00149             else {
00150                paramSet.addUntrackedParameter<double>("PtMax", ptMax);
00151                paramSet.addUntrackedParameter<double>("PtMin", ptMin);
00152             }
00153 
00154             paramSet.addUntrackedParameter("EtaMax", iConfig.getUntrackedParameter<double>("EtaMax", 2.7));
00155             paramSet.addUntrackedParameter("PhiMax", iConfig.getUntrackedParameter<double>("PhiMax", 3.15));
00156             paramSet.addUntrackedParameter("Nbins", iConfig.getUntrackedParameter<unsigned int>("Nbins",40));
00157             paramSet.addUntrackedParameter("minEtForEtaEffPlot", iConfig.getUntrackedParameter<unsigned int>("minEtForEtaEffPlot", 15));
00158             paramSet.addUntrackedParameter("useHumanReadableHistTitles", iConfig.getUntrackedParameter<bool>("useHumanReadableHistTitles", false));
00159             paramSet.addUntrackedParameter("mcMatchedOnly", iConfig.getUntrackedParameter<bool>("mcMatchedOnly", true));
00160             paramSet.addUntrackedParameter("noPhiPlots", iConfig.getUntrackedParameter<bool>("noPhiPlots", true));
00161             paramSet.addUntrackedParameter("noIsolationPlots", iConfig.getUntrackedParameter<bool>("noIsolationPlots", true));
00162 
00163             // verbosity of output messages when running
00164             paramSet.addUntrackedParameter<unsigned int>("verbosity", verbosity_);
00165 
00166             //preselction cuts 
00167             switch (j) {
00168                case TYPE_SINGLE_ELE:
00169                   paramSet.addParameter<unsigned>("reqNum", 1);
00170                   paramSet.addParameter<int>("pdgGen", 11);
00171                   paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialWenu"));
00172                   paramSet.addParameter<int>("cutnum", 1);
00173                   break;
00174                case TYPE_DOUBLE_ELE:
00175                   paramSet.addParameter<unsigned>("reqNum", 2);
00176                   paramSet.addParameter<int>("pdgGen", 11);
00177                   paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialZee"));
00178                   paramSet.addParameter<int>("cutnum", 2);
00179                   break;
00180                case TYPE_TRIPLE_ELE:
00181                   paramSet.addParameter<unsigned>("reqNum", 3);
00182                   paramSet.addParameter<int>("pdgGen", 11);
00183                   paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialZee"));
00184                   paramSet.addParameter<int>("cutnum", 3);
00185                   break;
00186                case TYPE_SINGLE_PHOTON:
00187                   paramSet.addParameter<unsigned>("reqNum", 1);
00188                   paramSet.addParameter<int>("pdgGen", 22);
00189                   paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialGammaJet"));
00190                   paramSet.addParameter<int>("cutnum", 1);
00191                   break;
00192                case TYPE_DOUBLE_PHOTON:
00193                   paramSet.addParameter<unsigned>("reqNum", 2);
00194                   paramSet.addParameter<int>("pdgGen", 22);
00195                   paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("fiducialDiGamma"));
00196                   paramSet.addParameter<int>("cutnum", 2);
00197             }
00198             //--------------------
00199 
00200             // TODO: extend this
00201             if (iConfig.getParameter<bool>("isData")) paramSet.addParameter<edm::InputTag>("cutcollection", edm::InputTag("gsfElectrons"));
00202 
00203             std::vector<edm::ParameterSet> filterVPSet;
00204             edm::ParameterSet filterPSet;
00205             std::string moduleLabel;
00206 
00207             // loop over filtermodules of current trigger path
00208             for (std::vector<std::string>::iterator filter = filterModules.begin(); filter != filterModules.end(); ++filter) {
00209                std::string moduleType = hltConfig_.modulePSet(*filter).getParameter<std::string>("@module_type");
00210                moduleLabel = hltConfig_.modulePSet(*filter).getParameter<std::string>("@module_label");
00211 
00212                // first check if it is a filter we are not interrested in
00213                if (moduleType == "Pythia6GeneratorFilter" ||
00214                    moduleType == "HLTTriggerTypeFilter" ||
00215                    moduleType == "HLTLevel1Activity" ||
00216                    moduleType == "HLTPrescaler" ||
00217                    moduleType == "HLTBool")
00218                   continue;
00219 
00220                // now check for the known filter types
00221                if (moduleType == "HLTLevel1GTSeed") {
00222                   filterPSet = makePSetForL1SeedFilter(moduleLabel);
00223                }
00224                else if (moduleType == "HLTEgammaL1MatchFilterRegional") {
00225                   filterPSet = makePSetForL1SeedToSuperClusterMatchFilter(moduleLabel);
00226                }
00227                else if (moduleType == "HLTEgammaEtFilter") {
00228                   filterPSet = makePSetForEtFilter(moduleLabel);
00229                }
00230                else if (moduleType == "HLTElectronOneOEMinusOneOPFilterRegional") {
00231                   filterPSet = makePSetForOneOEMinusOneOPFilter(moduleLabel);
00232                }
00233                else if (moduleType == "HLTElectronPixelMatchFilter") {
00234                   filterPSet = makePSetForPixelMatchFilter(moduleLabel);
00235                }
00236                else if (moduleType == "HLTEgammaGenericFilter") {
00237                   filterPSet = makePSetForEgammaGenericFilter(moduleLabel);
00238                }
00239                else if (moduleType == "HLTEgammaGenericQuadraticFilter") {
00240                   filterPSet = makePSetForEgammaGenericQuadraticFilter(moduleLabel);
00241                }
00242                else if (moduleType == "HLTElectronGenericFilter") {
00243                   filterPSet = makePSetForElectronGenericFilter(moduleLabel);
00244                }
00245                else if (moduleType == "HLTEgammaDoubleEtDeltaPhiFilter") {
00246                   filterPSet = makePSetForEgammaDoubleEtDeltaPhiFilter(moduleLabel);
00247                }
00248                else if (moduleType == "HLTGlobalSumsMET"
00249                         || moduleType == "HLTMhtHtFilter"
00250                         || moduleType == "HLTJetTag"
00251                         || moduleType == "HLT1CaloJet"
00252                         || moduleType == "HLT1CaloBJet"
00253                         || moduleType == "HLT1Tau"
00254                         || moduleType == "PFTauSelector"
00255                         || moduleType == "EtMinCaloJetSelector"
00256                         || moduleType == "LargestEtCaloJetSelector"
00257                         || moduleType == "HLTEgammaTriggerFilterObjectWrapper"  // 'fake' filter
00258                         || moduleType == "HLTEgammaDoubleLegCombFilter" // filter does not put anything in TriggerEventWithRefs
00259                         //|| moduleType == "HLT2ElectronTau"
00260                         || moduleType == "HLTPMMassFilter"
00261                         || moduleType == "HLTHcalTowerFilter"
00262                         //|| moduleType == "HLT1Photon"
00263                        )
00264                   continue;
00265                else {
00266                   if (verbosity_ >= OUTPUT_WARNINGS)
00267                      edm::LogWarning("EmDQMFeeder")  << "No parameter set for filter '" << moduleLabel << "' with filter type '" << moduleType << "' added. Module will not be analyzed.";
00268                   continue;
00269                }
00270 
00271                // something went wrong when the parameter set is empty. 
00272                if (!filterPSet.empty()) {
00273                   if (!hltConfig_.modulePSet(moduleLabel).exists("saveTags")) {
00274                      // make sure that 'theHLTOutputTypes' before an unseeded filter in a photon path is set to trigger::TriggerPhoton
00275                      // this is coupled to the parameter 'saveTag = true'
00276                      if (moduleLabel.find("Unseeded") != std::string::npos && (j == TYPE_DOUBLE_PHOTON || j == TYPE_SINGLE_PHOTON)) {
00277                         filterVPSet.back().addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
00278                      }
00279                   }
00280                   // if ncandcut is -1 (when parsing for the number of particles in the name of the L1seed filter fails),
00281                   // fall back to setting ncandcut to the number of particles needed for the given path.
00282                   if (filterPSet.getParameter<int>("ncandcut") < 0) filterPSet.addParameter<int>("ncandcut", paramSet.getParameter<int>("cutnum"));
00283                   else if (filterPSet.getParameter<int>("ncandcut") > paramSet.getParameter<int>("cutnum")) {
00284                     paramSet.addParameter<int>("cutnum", filterPSet.getParameter<int>("ncandcut"));
00285                     paramSet.addParameter<unsigned>("reqNum", (unsigned)filterPSet.getParameter<int>("ncandcut"));
00286                   }
00287 
00288                   filterVPSet.push_back(filterPSet);
00289                }
00290                else
00291                   break;
00292 
00293             } // end loop over filter modules of current trigger path
00294 
00295             // do not include this path when an empty filterPSet is detected.
00296             if (!filterPSet.empty()) {
00297                std::string lastModuleName = filterPSet.getParameter<edm::InputTag>("HLTCollectionLabels").label();
00298                if (!hltConfig_.modulePSet(lastModuleName).exists("saveTags")) {
00299                   // make sure that 'theHLTOutputTypes' of the last filter of a photon path is set to trigger::TriggerPhoton
00300                   // this is coupled to the parameter 'saveTag = true'
00301                   if ((j == TYPE_SINGLE_PHOTON || j == TYPE_DOUBLE_PHOTON) && pathName.rfind("Ele") == std::string::npos) {
00302                      filterVPSet.back().addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);
00303                   }
00304                }
00305                paramSet.addParameter<std::vector<edm::ParameterSet> >("filters", filterVPSet);
00306             }
00307             else {
00308                if (verbosity_ >= OUTPUT_ALL)
00309                   edm::LogPrint("EmDQMFeeder") << "Will not include this path in the validation due to errors while generating the parameter set.";
00310                continue;
00311             }
00312 
00313             // dump generated parameter set
00314             //std::cout << paramSet.dump() << std::endl;
00315 
00316             emDQMmodules.push_back(new EmDQM(paramSet));
00317 
00318             emDQMmodules.back()->beginJob();
00319             emDQMmodules.back()->beginRun(iRun, iSetup);
00320          } // loop over all paths of this analysis type
00321 
00322       } // loop over analysis types (single ele etc.)
00323 
00324       if (changed) {
00325          // The HLT config has actually changed wrt the previous Run, hence rebook your
00326          // histograms or do anything else dependent on the revised HLT config
00327       }
00328    } else {
00329       // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
00330       // with the file and/or code and needs to be investigated!
00331       if (verbosity_ >= OUTPUT_ERRORS)
00332          edm::LogError("EmDQMFeeder") << " HLT config extraction failure with process name '" << triggerObject_.process() << "'.";
00333       // In this case, all access methods will return empty values!
00334    }
00335 }
00336 
00337 // ------------ method called when ending the processing of a run  ------------
00338 void 
00339 EmDQMFeeder::endRun(edm::Run const&iEvent, edm::EventSetup const&iSetup)
00340 {
00341   for (unsigned i = 0; i < emDQMmodules.size(); ++i)
00342      emDQMmodules[i]->endRun(iEvent, iSetup);
00343 }
00344 
00345 // ------------ method called when starting to processes a luminosity block  ------------
00346 void 
00347 EmDQMFeeder::beginLuminosityBlock(edm::LuminosityBlock const&lumi, edm::EventSetup const&iSetup)
00348 {
00349 //  for (unsigned i = 0; i < emDQMmodules.size(); ++i)
00350 //     emDQMmodules[i]->beginLuminosityBlock(lumi, iSetup);
00351 }
00352 
00353 // ------------ method called when ending the processing of a luminosity block  ------------
00354 void 
00355 EmDQMFeeder::endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& iSetup)
00356 {
00357 //  for (unsigned i = 0; i < emDQMmodules.size(); ++i)
00358 //     emDQMmodules[i]->endLuminosityBlock(lumi, iSetup);
00359 }
00360 
00361 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00362 void
00363 EmDQMFeeder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00364    //The following says we do not know what parameters are allowed so do no validation
00365    // Please change this to state exactly what you do use, even if it is no parameters
00366 
00367    // see: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideConfigurationValidationAndHelp
00368    edm::ParameterSetDescription desc;
00369    desc.setUnknown();
00370    descriptions.addDefault(desc);
00371 }
00372 
00373 //----------------------------------------------------------------------
00374 
00375 std::vector<std::vector<std::string> >
00376 EmDQMFeeder::findEgammaPaths()
00377 {
00378    std::vector<std::vector<std::string> > Paths(5);
00379    // Loop over all paths in the menu
00380    for (unsigned int i=0; i<hltConfig_.size(); i++) {
00381 
00382       std::string path = hltConfig_.triggerName(i);
00383 
00384       // Find electron and photon paths
00385       if (int(path.find("HLT_")) == 0) {    // Path should start with 'HLT_'
00386          if (path.find("HLT_Ele") != std::string::npos && path.rfind("Ele") == 4 && path.find("SC") == std::string::npos) {
00387             Paths[TYPE_SINGLE_ELE].push_back(path);
00388             //std::cout << "Electron " << path << std::endl;
00389          }
00390          if (path.find("HLT_Ele") != std::string::npos && path.find("EleId") != std::string::npos && path.rfind("Ele") == path.find("EleId")) {
00391             Paths[TYPE_SINGLE_ELE].push_back(path);
00392             //std::cout << "Electron " << path << std::endl;
00393          }
00394          else if (path.find("HLT_Ele") != std::string::npos && path.rfind("Ele") > 4) {
00395             Paths[TYPE_DOUBLE_ELE].push_back(path);
00396             //std::cout << "DoubleElectron " << path << std::endl;
00397          }
00398          else if (path.find("HLT_DoubleEle") != std::string::npos && path.find("Ele") == path.rfind("Ele")) {
00399             Paths[TYPE_DOUBLE_ELE].push_back(path);
00400             //std::cout << "DoubleElectron " << path << std::endl;
00401          }
00402          else if (path.find("HLT_Ele") != std::string::npos && path.find("SC") != std::string::npos) {
00403             Paths[TYPE_DOUBLE_ELE].push_back(path);
00404             //std::cout << "DoubleElectron " << path << std::endl;
00405          }
00406          else if (path.find("HLT_DoubleEle") != std::string::npos && path.find("Ele") != path.rfind("Ele")) {
00407             Paths[TYPE_TRIPLE_ELE].push_back(path);
00408             //std::cout << "TripleElectron " << path << std::endl;
00409          }
00410          else if (path.find("HLT_TripleEle") != std::string::npos && path.find("Ele") == path.rfind("Ele")) {
00411             Paths[TYPE_TRIPLE_ELE].push_back(path);
00412             //std::cout << "TripleElectron " << path << std::endl;
00413          }
00414          else if (path.find("HLT_Photon") != std::string::npos && path.find("Ele") != std::string::npos) {
00415             Paths[TYPE_DOUBLE_PHOTON].push_back(path);
00416             //std::cout << "DoublePhoton " << path << std::endl;
00417          }
00418          else if (path.find("HLT_Photon") != std::string::npos && path.rfind("Photon") == 4) {
00419             Paths[TYPE_SINGLE_PHOTON].push_back(path);
00420             //std::cout << "Photon " << path << std::endl;
00421          }
00422          else if (path.find("HLT_Photon") != std::string::npos && path.rfind("Photon") > 4) {
00423             Paths[TYPE_DOUBLE_PHOTON].push_back(path);
00424             //std::cout << "DoublePhoton " << path << std::endl;
00425          }
00426          else if (path.find("HLT_DoublePhoton") != std::string::npos) {
00427             Paths[TYPE_DOUBLE_PHOTON].push_back(path);
00428             //std::cout << "DoublePhoton " << path << std::endl;
00429          }
00430       }
00431       //std::cout << i << " triggerName: " << path << " containing " << hltConfig_.size(i) << " modules."<< std::endl;
00432    }
00433    return Paths;
00434 }
00435 
00436 //----------------------------------------------------------------------
00437 
00438 std::vector<std::string>
00439 EmDQMFeeder::getFilterModules(const std::string& path)
00440 {
00441    std::vector<std::string> filters;
00442 
00443    //std::cout << "Pathname: " << path << std::endl;
00444 
00445    // Loop over all modules in the path
00446    for (unsigned int i=0; i<hltConfig_.size(path); i++) {
00447 
00448       std::string module = hltConfig_.moduleLabel(path, i);
00449       std::string moduleType = hltConfig_.moduleType(module);
00450       std::string moduleEDMType = hltConfig_.moduleEDMType(module);
00451 
00452       // Find filters
00453       if (moduleEDMType == "EDFilter" || moduleType.find("Filter") != std::string::npos) {  // older samples may not have EDMType data included
00454          filters.push_back(module);
00455          //std::cout << i << "    moduleLabel: " << module << "    moduleType: " << moduleType << "    moduleEDMType: " << moduleEDMType << std::endl;
00456       }
00457    }
00458    return filters;
00459 }
00460 
00461 //----------------------------------------------------------------------
00462 
00463 double
00464 EmDQMFeeder::getPrimaryEtCut(const std::string& path)
00465 {
00466    double minEt = -1;
00467 
00468    boost::regex reg("^HLT_.*?([[:digit:]]+).*");
00469 
00470    boost::smatch what;
00471    if (boost::regex_match(path, what, reg, boost::match_extra))
00472    {
00473      minEt = boost::lexical_cast<double>(what[1]); 
00474    }
00475 
00476    return minEt;
00477 }
00478 
00479 //----------------------------------------------------------------------
00480 
00481 edm::ParameterSet 
00482 EmDQMFeeder::makePSetForL1SeedFilter(const std::string& moduleName)
00483 {
00484   // generates a PSet to analyze the behaviour of an L1 seed.
00485   //
00486   // moduleName is the name of the HLT module which filters
00487   // on the L1 seed.
00488   edm::ParameterSet retPSet;
00489   
00490   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00491   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00492   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00493   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00494   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerL1NoIsoEG);
00495   
00496   // as HLTLevel1GTSeed has no parameter ncandcut we determine the value from the name of the filter
00497   if (moduleName.find("Single") != std::string::npos)
00498      retPSet.addParameter<int>("ncandcut", 1);
00499   else if (moduleName.find("Double") != std::string::npos)
00500      retPSet.addParameter<int>("ncandcut", 2);
00501   else if (moduleName.find("Triple") != std::string::npos)
00502      retPSet.addParameter<int>("ncandcut", 3);
00503   else
00504      retPSet.addParameter<int>("ncandcut", -1);
00505 
00506   return retPSet;
00507 }
00508 
00509 //----------------------------------------------------------------------
00510 
00511 edm::ParameterSet 
00512 EmDQMFeeder::makePSetForL1SeedToSuperClusterMatchFilter(const std::string& moduleName)
00513 {
00514   // generates a PSet to analyze the behaviour of L1 to supercluster match filter.
00515   //
00516   // moduleName is the name of the HLT module which requires the match
00517   // between supercluster and L1 seed.
00518   //
00519   edm::ParameterSet retPSet;
00520   
00521   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00522   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00523   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00524   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00525   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00526   retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00527 
00528   return retPSet;
00529 }
00530 
00531 //----------------------------------------------------------------------
00532 
00533 edm::ParameterSet 
00534 EmDQMFeeder::makePSetForEtFilter(const std::string& moduleName)
00535 {
00536   edm::ParameterSet retPSet;
00537   
00538   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00539   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00540   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00541   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00542   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00543   retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00544 
00545   return retPSet;
00546 }
00547 
00548 //----------------------------------------------------------------------
00549 
00550 edm::ParameterSet 
00551 EmDQMFeeder::makePSetForOneOEMinusOneOPFilter(const std::string& moduleName)
00552 {
00553   edm::ParameterSet retPSet;
00554   
00555   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00556   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00557   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00558   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00559   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
00560   retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00561 
00562   return retPSet;
00563 }
00564 
00565 //----------------------------------------------------------------------
00566 
00567 edm::ParameterSet 
00568 EmDQMFeeder::makePSetForPixelMatchFilter(const std::string& moduleName)
00569 {
00570   edm::ParameterSet retPSet;
00571  
00572   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00573   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00574   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00575   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00576   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00577   retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00578 
00579   return retPSet;
00580 }
00581 
00582 //----------------------------------------------------------------------
00583 
00584 edm::ParameterSet 
00585 EmDQMFeeder::makePSetForEgammaDoubleEtDeltaPhiFilter(const std::string& moduleName)
00586 {
00587   edm::ParameterSet retPSet;
00588  
00589   retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00590   //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00591   retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00592   retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", std::vector<edm::InputTag>(1, std::string("none")));
00593   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00594   retPSet.addParameter<int>("ncandcut", 2);
00595 
00596   return retPSet;
00597 }
00598 
00599 //----------------------------------------------------------------------
00600 
00601 edm::ParameterSet 
00602 EmDQMFeeder::makePSetForEgammaGenericFilter(const std::string& moduleName)
00603 {
00604   edm::ParameterSet retPSet;
00605 
00606   // example usages of HLTEgammaGenericFilter are:
00607   //   R9 shape filter                        hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter 
00608   //   cluster shape filter                   hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter 
00609   //   Ecal isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
00610   //   H/E filter                             hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
00611   //   HCAL isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
00612 
00613   // infer the type of filter by the type of the producer which
00614   // generates the collection used to cut on this
00615   edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
00616   edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
00617   //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
00618 
00619   std::string inputType = hltConfig_.moduleType(isoTag.label());
00620   //std::cout << "inputType " << inputType << " moduleName " << moduleName << std::endl;
00621 
00622   //--------------------
00623   // sanity check: non-isolated path should be produced by the
00624   // same type of module
00625 
00626   // first check that the non-iso tag is non-empty
00627   //if (nonIsoTag.label().empty()) {
00628   //  edm::LogError("EmDQMFeeder") << "nonIsoTag of HLTEgammaGenericFilter '" << moduleName <<  "' is empty.";
00629   //  return retPSet;
00630   //}
00631   //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
00632   //  edm::LogError("EmDQMFeeder") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTEgammaGenericFilter '" << moduleName <<  "'.";
00633   //  return retPSet;
00634   //}
00635   //--------------------
00636 
00637   // parameter saveTag determines the output type
00638   if (hltConfig_.saveTags(moduleName))
00639      retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);  
00640   else
00641      retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00642 
00643   std::vector<edm::InputTag> isoCollections;
00644   isoCollections.push_back(isoTag);
00645   if (!nonIsoTag.label().empty())
00646      isoCollections.push_back(nonIsoTag);
00647 
00648   //--------------------
00649   // the following cases seem to have identical PSets ?
00650   //--------------------
00651 
00652   if (inputType == "EgammaHLTR9Producer" ||                       // R9 shape
00653       inputType == "EgammaHLTR9IDProducer" ||                     // R9 ID
00654       inputType == "EgammaHLTClusterShapeProducer" ||             // cluster shape
00655       inputType == "EgammaHLTEcalRecIsolationProducer" ||         // ecal isolation
00656       inputType == "EgammaHLTHcalIsolationProducersRegional" ||   // HCAL isolation and HE
00657       inputType == "EgammaHLTGsfTrackVarProducer"                 // GSF track deta and dphi filter
00658      ) {
00659     retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00660     //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00661     retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00662     retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
00663     retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00664 
00665     return retPSet;
00666   }
00667 
00668   if (verbosity_ >= OUTPUT_ERRORS)
00669      edm::LogError("EmDQMFeeder") << "Can't determine what the HLTEgammaGenericFilter '" << moduleName <<  "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
00670   return edm::ParameterSet();
00671 }
00672 
00673 //----------------------------------------------------------------------
00674 
00675 edm::ParameterSet 
00676 EmDQMFeeder::makePSetForEgammaGenericQuadraticFilter(const std::string& moduleName)
00677 {
00678   edm::ParameterSet retPSet;
00679 
00680   // example usages of HLTEgammaGenericFilter are:
00681   //   R9 shape filter                        hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolR9ShapeFilter 
00682   //   cluster shape filter                   hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolClusterShapeFilter 
00683   //   Ecal isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TIghterEleIdIsolEcalIsolFilter
00684   //   H/E filter                             hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHEFilter
00685   //   HCAL isolation filter                  hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolHcalIsolFilter
00686 
00687   // infer the type of filter by the type of the producer which
00688   // generates the collection used to cut on this
00689   edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
00690   edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
00691   //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
00692 
00693   std::string inputType = hltConfig_.moduleType(isoTag.label());
00694   //std::cout << "inputType " << inputType << " moduleName " << moduleName << std::endl;
00695 
00696   //--------------------
00697   // sanity check: non-isolated path should be produced by the
00698   // same type of module
00699 
00700   // first check that the non-iso tag is non-empty
00701   //if (nonIsoTag.label().empty()) {
00702   //  edm::LogError("EmDQMFeeder") << "nonIsoTag of HLTEgammaGenericFilter '" << moduleName <<  "' is empty.";
00703   //  return retPSet;
00704   //}
00705   //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
00706   //  edm::LogError("EmDQMFeeder") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTEgammaGenericFilter '" << moduleName <<  "'.";
00707   //  return retPSet;
00708   //}
00709   //--------------------
00710 
00711   // parameter saveTag determines the output type
00712   if (hltConfig_.saveTags(moduleName))
00713      retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerPhoton);  
00714   else
00715      retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerCluster);
00716 
00717   std::vector<edm::InputTag> isoCollections;
00718   isoCollections.push_back(isoTag);
00719   if (!nonIsoTag.label().empty())
00720      isoCollections.push_back(nonIsoTag);
00721 
00722   //--------------------
00723   // the following cases seem to have identical PSets ?
00724   //--------------------
00725 
00726   if (inputType == "EgammaHLTR9Producer" ||                            // R9 shape
00727       inputType == "EgammaHLTR9IDProducer" ||                          // R9 ID
00728       inputType == "EgammaHLTClusterShapeProducer" ||                  // cluster shape
00729       inputType == "EgammaHLTEcalRecIsolationProducer" ||              // ecal isolation
00730       inputType == "EgammaHLTHcalIsolationProducersRegional" ||        // HCAL isolation and HE
00731       inputType == "EgammaHLTPhotonTrackIsolationProducersRegional"    // Photon track isolation
00732      ) {
00733     retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00734     //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00735     retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00736     retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
00737     retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00738 
00739     return retPSet;
00740   }
00741  
00742   if (verbosity_ >= OUTPUT_ERRORS)
00743      edm::LogError("EmDQMFeeder") << "Can't determine what the HLTEgammaGenericQuadraticFilter '" << moduleName <<  "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
00744   return edm::ParameterSet();
00745 }
00746 
00747 
00748 //----------------------------------------------------------------------
00749 
00750 edm::ParameterSet
00751 EmDQMFeeder::makePSetForElectronGenericFilter(const std::string& moduleName)
00752 {
00753   edm::ParameterSet retPSet;
00754 
00755   // example usages of HLTElectronGenericFilter are:
00756   //
00757   // deta filter      hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDetaFilter
00758   // dphi filter      hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolDphiFilter
00759   // track isolation  hltL1NonIsoHLTNonIsoSingleElectronEt17TighterEleIdIsolTrackIsolFilter
00760 
00761   // infer the type of filter by the type of the producer which
00762   // generates the collection used to cut on this
00763   edm::InputTag isoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("isoTag");
00764   edm::InputTag nonIsoTag = hltConfig_.modulePSet(moduleName).getParameter<edm::InputTag>("nonIsoTag");
00765   //std::cout << "isoTag.label " << isoTag.label() << " nonIsoTag.label " << nonIsoTag.label() << std::endl;
00766 
00767   std::string inputType = hltConfig_.moduleType(isoTag.label());
00768   //std::cout << "inputType iso " << inputType << " inputType noniso " << hltConfig_.moduleType(nonIsoTag.label()) << " moduleName " << moduleName << std::endl;
00769 
00770   //--------------------
00771   // sanity check: non-isolated path should be produced by the
00772   // same type of module
00773   //if (nonIsoTag.label().empty()) {
00774   //  edm::LogError("EmDQMFeeder") << "nonIsoTag of HLTElectronGenericFilter '" << moduleName <<  "' is empty.";
00775   //  return retPSet;
00776   //}
00777   //if (inputType != hltConfig_.moduleType(nonIsoTag.label())) {
00778   //  edm::LogError("EmDQMFeeder") << "C++ Type of isoTag '" << inputType << "' and nonIsoTag '" << hltConfig_.moduleType(nonIsoTag.label()) << "' are not the same for HLTElectronGenericFilter '" << moduleName <<  "'.";
00779   //  return retPSet;
00780   //}
00781   //--------------------
00782 
00783   // the type of object to look for seems to be the
00784   // same for all uses of HLTEgammaGenericFilter
00785   retPSet.addParameter<int>("theHLTOutputTypes", trigger::TriggerElectron);
00786 
00787   std::vector<edm::InputTag> isoCollections;
00788   isoCollections.push_back(isoTag);
00789   if (!nonIsoTag.label().empty())
00790      isoCollections.push_back(nonIsoTag);
00791 
00792   //--------------------
00793   // the following cases seem to have identical PSets ?
00794   //--------------------
00795 
00796   // note that whether deta or dphi is used is determined from
00797   // the product instance (not the module label)
00798   if (inputType == "EgammaHLTElectronDetaDphiProducer" ||           // deta and dphi filter
00799       inputType == "EgammaHLTElectronTrackIsolationProducers"       // track isolation
00800      ) {
00801     retPSet.addParameter<std::vector<double> >("PlotBounds", std::vector<double>(2, 0.0));
00802     //retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", processName_));
00803     retPSet.addParameter<edm::InputTag>("HLTCollectionLabels", edm::InputTag(moduleName, "", triggerObject_.process()));
00804     retPSet.addParameter<std::vector<edm::InputTag> >("IsoCollections", isoCollections);
00805     retPSet.addParameter<int>("ncandcut", hltConfig_.modulePSet(moduleName).getParameter<int>("ncandcut"));
00806 
00807     return retPSet;
00808   }
00809 
00810   if (verbosity_ >= OUTPUT_ERRORS)
00811      edm::LogError("EmDQMFeeder") << "Can't determine what the HLTElectronGenericFilter '" << moduleName <<  "' should do: uses a collection produced by a module of C++ type '" << inputType << "'.";
00812   return edm::ParameterSet();
00813 }
00814 
00815 //----------------------------------------------------------------------
00816 
00817 DEFINE_FWK_MODULE(EmDQMFeeder);