#include <PhysicsTools/UtilAlgos/src/ConfigurableAnalysis.cc>
Public Member Functions | |
ConfigurableAnalysis (const edm::ParameterSet &) | |
~ConfigurableAnalysis () | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
virtual void | endJob () |
virtual bool | filter (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
std::vector< std::string > | flows_ |
NTupler * | ntupler_ |
Plotter * | plotter_ |
Selections * | selections_ |
bool | workAsASelector_ |
Implementation: <Notes on="" implementation>="">
Definition at line 45 of file ConfigurableAnalysis.cc.
ConfigurableAnalysis::ConfigurableAnalysis | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 74 of file ConfigurableAnalysis.cc.
References edm::ParameterSet::empty(), edm::ParameterSet::exists(), flows_, DBSPlugin::get(), edm::ParameterSet::getParameter(), init, moduleLabel(), ntupler_, plotter_, NTupler::registerleaves(), selections_, and workAsASelector_.
00074 : 00075 selections_(0), plotter_(0), ntupler_(0) 00076 { 00077 00078 std::string moduleLabel = iConfig.getParameter<std::string>("@module_label"); 00079 00080 //configure inputag distributor 00081 if (iConfig.exists("InputTags")) 00082 edm::Service<InputTagDistributorService>()->init(moduleLabel,iConfig.getParameter<edm::ParameterSet>("InputTags")); 00083 00084 //configure the variable helper 00085 edm::Service<VariableHelperService>()->init(moduleLabel,iConfig.getParameter<edm::ParameterSet>("Variables")); 00086 00087 //list of selections 00088 selections_ = new Selections(iConfig.getParameter<edm::ParameterSet>("Selections")); 00089 00090 //plotting device 00091 edm::ParameterSet plotPset = iConfig.getParameter<edm::ParameterSet>("Plotter"); 00092 if (!plotPset.empty()){ 00093 std::string plotterName = plotPset.getParameter<std::string>("ComponentName"); 00094 plotter_ = PlotterFactory::get()->create(plotterName, plotPset); 00095 } 00096 else 00097 plotter_ = 0; 00098 00099 //ntupling device 00100 edm::ParameterSet ntPset = iConfig.getParameter<edm::ParameterSet>("Ntupler"); 00101 if (!ntPset.empty()){ 00102 std::string ntuplerName=ntPset.getParameter<std::string>("ComponentName"); 00103 ntupler_ = NTuplerFactory::get()->create(ntuplerName, ntPset); 00104 } 00105 else ntupler_=0; 00106 00107 flows_ = iConfig.getParameter<std::vector<std::string> >("flows"); 00108 workAsASelector_ = iConfig.getParameter<bool>("workAsASelector"); 00109 00110 //vector of passed selections 00111 produces<std::vector<bool> >(); 00112 00113 //ntupler needs to register its products 00114 if (ntupler_) ntupler_->registerleaves(this); 00115 }
ConfigurableAnalysis::~ConfigurableAnalysis | ( | ) |
Definition at line 117 of file ConfigurableAnalysis.cc.
References selections_.
00118 { 00119 delete selections_; 00120 }
void ConfigurableAnalysis::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 223 of file ConfigurableAnalysis.cc.
References Plotter::complete(), plotter_, Selections::print(), and selections_.
00223 { 00224 //print summary tables 00225 selections_->print(); 00226 if (plotter_) plotter_->complete(); 00227 }
bool ConfigurableAnalysis::filter | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDFilter.
Definition at line 128 of file ConfigurableAnalysis.cc.
References Selections::begin(), Selections::end(), NTupler::fill(), Plotter::fill(), flows_, Filter::name(), ntupler_, plotter_, edm::Event::put(), selections_, Plotter::setDir(), skip(), and workAsASelector_.
00129 { 00130 using namespace edm; 00131 00132 //will the filter pass or not. 00133 bool majorGlobalAccept=false; 00134 00135 std::auto_ptr<std::vector<bool> > passedProduct(new std::vector<bool>(flows_.size(),false)); 00136 bool filledOnce=false; 00137 00138 // loop the requested selections 00139 for (Selections::iterator selection=selections_->begin(); selection!=selections_->end();++selection){ 00140 //was this flow of filter actually asked for 00141 bool skip=true; 00142 uint iFlow=0; 00143 for (;iFlow!=flows_.size();++iFlow){if (flows_[iFlow]==selection->name()){skip=false; break;}} 00144 if (skip) continue; 00145 00146 //make a specific direction in the plotter 00147 if (plotter_) plotter_->setDir(selection->name()); 00148 00149 // apply individual filters on the event 00150 std::map<std::string, bool> accept=selection->accept(iEvent); 00151 00152 bool globalAccept=true; 00153 std::string separator=""; 00154 std::string cumulative=""; 00155 std::string allButOne="allBut_"; 00156 std::string fullAccept="fullAccept"; 00157 std::string fullContent="fullContent"; 00158 00159 if (selection->makeContentPlots() && plotter_) 00160 plotter_->fill(fullContent,iEvent); 00161 00162 //loop the filters to make cumulative and allButOne job 00163 for (Selection::iterator filterIt=selection->begin(); filterIt!=selection->end();++filterIt){ 00164 Filter & filter=(**filterIt); 00165 // bool lastCut=((filterIt+1)==selection->end()); 00166 00167 //increment the directory name 00168 cumulative+=separator+filter.name(); separator="_"; 00169 00170 if (accept[filter.name()]){ 00171 // if (globalAccept && selection->makeCumulativePlots() && !lastCut) 00172 if (globalAccept && selection->makeCumulativePlots() && plotter_) 00173 plotter_->fill(cumulative,iEvent); 00174 } 00175 else{ 00176 globalAccept=false; 00177 // did all the others filter fire 00178 bool goodForAllButThisOne=true; 00179 for (std::map<std::string,bool>::iterator decision=accept.begin(); decision!=accept.end();++decision){ 00180 if (decision->first==filter.name()) continue; 00181 if (!decision->second) { 00182 goodForAllButThisOne=false; 00183 break;} 00184 } 00185 if (goodForAllButThisOne && selection->makeAllButOnePlots() && plotter_){ 00186 plotter_->fill(allButOne+filter.name(),iEvent); 00187 } 00188 } 00189 00190 }// loop over the filters in this selection 00191 00192 if (globalAccept){ 00193 (*passedProduct)[iFlow]=true; 00194 majorGlobalAccept=true; 00195 //make final plots only if no cumulative plots 00196 if (selection->makeFinalPlots() && !selection->makeCumulativePlots() && plotter_) 00197 plotter_->fill(fullAccept,iEvent); 00198 00199 //make the ntuple and put it in the event 00200 if (selection->ntuplize() && !filledOnce && ntupler_){ 00201 ntupler_->fill(iEvent); 00202 filledOnce=true;} 00203 } 00204 00205 }//loop the different filter order/number: loop the Selections 00206 00207 iEvent.put(passedProduct); 00208 if (workAsASelector_) 00209 return majorGlobalAccept; 00210 else 00211 return true; 00212 }
std::vector<std::string> ConfigurableAnalysis::flows_ [private] |
Definition at line 59 of file ConfigurableAnalysis.cc.
Referenced by ConfigurableAnalysis(), and filter().
NTupler* ConfigurableAnalysis::ntupler_ [private] |
Definition at line 57 of file ConfigurableAnalysis.cc.
Referenced by ConfigurableAnalysis(), and filter().
Plotter* ConfigurableAnalysis::plotter_ [private] |
Definition at line 56 of file ConfigurableAnalysis.cc.
Referenced by ConfigurableAnalysis(), endJob(), and filter().
Selections* ConfigurableAnalysis::selections_ [private] |
Definition at line 55 of file ConfigurableAnalysis.cc.
Referenced by ConfigurableAnalysis(), endJob(), filter(), and ~ConfigurableAnalysis().
bool ConfigurableAnalysis::workAsASelector_ [private] |
Definition at line 60 of file ConfigurableAnalysis.cc.
Referenced by ConfigurableAnalysis(), and filter().