CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
STFilter Class Reference

#include <MyEDFilter/STFilter/src/STFilter.cc>

Inheritance diagram for STFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 STFilter (const edm::ParameterSet &)
 
 ~STFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &)
 

Private Attributes

unsigned int accepted_events
 
edm::ParameterSet conf_
 
int DEBUGLVL
 
std::string fOutputFileName
 
TH1D * hbEta
 
TH1D * hbEtaFiltered
 
TH1D * hbPt
 
TH1D * hbPtFiltered
 
edm::InputTag hepMCProductTag_
 
TFile * hOutputFile
 
unsigned int input_events
 
bool m_produceHistos
 
double pTMax_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description:

used for single top t-channel events generated with MadEvent and matched the "Karlsruhe way" filter on 2->2 process events, where the crucial candidate (the 2nd b quark) is not available until parton showering is done filter criterion: transverse momentum of 2nd b quark "pT < pTMax" -> event accepted! How-To: include STFilter.cfg in your .cfg, replace pTMax by the desired value, include module "STFilter" in outpath Implementation: <Notes on="" implementation>="">

Definition at line 13 of file STFilter.h.

Constructor & Destructor Documentation

STFilter::STFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 30 of file STFilter.cc.

References accepted_events, conf_, DEBUGLVL, fOutputFileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), input_events, m_produceHistos, pTMax_, and AlCaHLTBitMon_QueryRunRegistry::string.

30  :
31  hepMCProductTag_(iConfig.getParameter<edm::InputTag>("hepMCProductTag")) {
32 
33  pTMax_ = iConfig.getParameter<double>("pTMax");
34  edm::LogInfo("SingleTopMatchingFilter")<<"+++ maximum pt of associated-b pTMax = "<<pTMax_;
35  DEBUGLVL = iConfig.getUntrackedParameter<int>("debuglvl", 0); // get debug level
36  input_events=0; accepted_events=0; // counters
37  m_produceHistos = iConfig.getParameter<bool>("produceHistos"); // produce histograms?
38  fOutputFileName = iConfig.getUntrackedParameter<std::string>("histOutFile"); // get name of output file with histograms
39  conf_ = iConfig;
40 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet conf_
Definition: STFilter.h:36
int DEBUGLVL
Definition: STFilter.h:24
double pTMax_
Definition: STFilter.h:22
unsigned int accepted_events
Definition: STFilter.h:27
unsigned int input_events
Definition: STFilter.h:26
edm::InputTag hepMCProductTag_
Definition: STFilter.h:37
bool m_produceHistos
Definition: STFilter.h:29
std::string fOutputFileName
Definition: STFilter.h:33
STFilter::~STFilter ( )

Definition at line 43 of file STFilter.cc.

43 {}

Member Function Documentation

void STFilter::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 115 of file STFilter.cc.

References conf_, fOutputFileName, edm::ParameterSet::getParameter(), hbEta, hbEtaFiltered, hbPt, hbPtFiltered, hOutputFile, and m_produceHistos.

115  {
116  if(m_produceHistos){ // initialize histogram output file
118  edm::LogInfo("SingleTopMatchingFilter)")<<"beginJob : creating histogram file: "<<fOutputFileName.c_str()<<std::endl;
119  hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ; hOutputFile->cd();
120  // book histograms
121  Parameters = conf_.getParameter<edm::ParameterSet>("TH1bPt");
122  hbPt = new TH1D( "bPt", "Pt of 2nd b quark", Parameters.getParameter<int32_t>("Nbinx"), Parameters.getParameter<double>("xmin"), Parameters.getParameter<double>("xmax"));
123  Parameters = conf_.getParameter<edm::ParameterSet>("TH1bEta");
124  hbEta = new TH1D( "bEta", "Eta of 2nd b quark", Parameters.getParameter<int32_t>("Nbinx"), Parameters.getParameter<double>("xmin"), Parameters.getParameter<double>("xmax"));
125  Parameters = conf_.getParameter<edm::ParameterSet>("TH1bPtFiltered");
126  hbPtFiltered = new TH1D( "bPtFiltered", "Pt of 2nd b quark filtered", Parameters.getParameter<int32_t>("Nbinx"), Parameters.getParameter<double>("xmin"), Parameters.getParameter<double>("xmax"));
127  Parameters = conf_.getParameter<edm::ParameterSet>("TH1bEtaFiltered");
128  hbEtaFiltered = new TH1D( "bEtaFiltered", "Eta of 2nd b quark filtered", Parameters.getParameter<int32_t>("Nbinx"), Parameters.getParameter<double>("xmin"), Parameters.getParameter<double>("xmax"));
129  }
130 }
T getParameter(std::string const &) const
TH1D * hbEta
Definition: STFilter.h:31
edm::ParameterSet conf_
Definition: STFilter.h:36
vector< ParameterSet > Parameters
TH1D * hbPt
Definition: STFilter.h:30
TH1D * hbEtaFiltered
Definition: STFilter.h:31
bool m_produceHistos
Definition: STFilter.h:29
TFile * hOutputFile
Definition: STFilter.h:34
TH1D * hbPtFiltered
Definition: STFilter.h:30
std::string fOutputFileName
Definition: STFilter.h:33
void STFilter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 132 of file STFilter.cc.

References accepted_events, gather_cfg::cout, relativeConstraints::error, HLT_25ns14e33_v1_cff::fraction, hbEta, hbEtaFiltered, hbPt, hbPtFiltered, hOutputFile, input_events, m_produceHistos, and mathSSE::sqrt().

132  {
133  if(m_produceHistos){
134  hOutputFile->cd();
135  hbPt->Write(); hbEta->Write(); hbPtFiltered->Write(); hbEtaFiltered->Write();
136  hOutputFile->Write() ; hOutputFile->Close() ;} // Write out histograms to file, then close it
137  double fraction = (double) accepted_events / (double) input_events;
138  double percent = 100. * fraction; double error = 100. * sqrt( fraction*(1-fraction) / (double) input_events );
139  std::cout<<"STFilter ++ accepted_events/input_events = "<<accepted_events<<"/"<<input_events<<" = "<<fraction<<std::endl;
140  std::cout<<"STFilter ++ efficiency = "<<percent<<" % +/- "<<error<<" %"<<std::endl;
141 }
TH1D * hbEta
Definition: STFilter.h:31
T sqrt(T t)
Definition: SSEVec.h:48
TH1D * hbPt
Definition: STFilter.h:30
TH1D * hbEtaFiltered
Definition: STFilter.h:31
unsigned int accepted_events
Definition: STFilter.h:27
unsigned int input_events
Definition: STFilter.h:26
bool m_produceHistos
Definition: STFilter.h:29
tuple cout
Definition: gather_cfg.py:121
TFile * hOutputFile
Definition: STFilter.h:34
TH1D * hbPtFiltered
Definition: STFilter.h:30
bool STFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 45 of file STFilter.cc.

References funct::abs(), accepted_events, edm::Event::getByLabel(), hbEta, hbEtaFiltered, hbPt, hbPtFiltered, hepMCProductTag_, i, input_events, visualization-live-secondInstance_cfg::m, m_produceHistos, AlCaHLTBitMon_ParallelJobs::p, parents, and pTMax_.

45  {
46  using namespace edm;
47 
48  bool accEvt = false;
49  bool lo = false;
50 
51  int secBcount = 0;
52  double pTSecB = 100;
53  double etaSecB = 100;
54 
55  ++input_events;
56 
58  iEvent.getByLabel(hepMCProductTag_, evt);
59  const HepMC::GenEvent * myEvt = evt->GetEvent(); // GET EVENT FROM HANDLE
60 
61  bool bQuarksOpposite = false;
62  for(HepMC::GenEvent::particle_const_iterator i = myEvt->particles_begin();
63  (*i)->status() == 3; ++i) { // abort after status 3 particles
64  // logic:
65  // - in 2->2 matrix elements, the incoming (top production)
66  // b quark and the outgoing (top decay) b quark have same sign,
67  // so we flip the bQuarksOpposite flag twice -> false
68  // (opposite-sign b quark comes from the shower and has status 2)
69  // - in 2->3 matrix elements, we have two outgoing b quarks with status
70  // 3 and opposite signs -> true
71  if ((*i)->pdg_id() == -5)
72  bQuarksOpposite = !bQuarksOpposite;
73  }
74 
75  // ---- 22 or 23? ----
76  if (!bQuarksOpposite) // 22
77  lo = true;
78  else
79  accEvt = true; // 23
80 
81  // ---- filter only 22 events ----
82  if (lo){
83  for (HepMC::GenEvent::particle_const_iterator p = myEvt->particles_begin(); p!=myEvt->particles_end(); ++p){
84  // ---- look in shower for 2nd b quark ----
85  if ((*p)->status() == 2 && abs((*p)->pdg_id()) == 5){
86  // ---- if b quark is found, loop over its parents ----
87  for (HepMC::GenVertex::particle_iterator m = (*p)->production_vertex()->particles_begin(HepMC::parents);
88  m != (*p)->production_vertex()->particles_end(HepMC::parents); ++m){
89  // ---- found 2ndb-candidate in shower ---- // ---- check mother of this candidate ----
90  if(abs((*m)->barcode()) < 5){
91  if(secBcount == 1) break;
92  secBcount ++;
93  pTSecB = (*p)->operator HepMC::FourVector().perp();
94  etaSecB = (*p)->operator HepMC::FourVector().eta();
95  }
96  }
97  }
98  }
99  if(pTSecB < pTMax_) accEvt = true;
100  // fill histos if requested
101  if(m_produceHistos){
102  hbPt->Fill(pTSecB);
103  hbEta->Fill(etaSecB);
104  if(accEvt){
105  hbPtFiltered->Fill(pTSecB);
106  hbEtaFiltered->Fill(etaSecB);
107  }
108  }
109  }
110  if(accEvt) ++accepted_events;
111  return accEvt;
112 }
int i
Definition: DBlmapReader.cc:9
TPRegexp parents
Definition: eve_filter.cc:21
TH1D * hbEta
Definition: STFilter.h:31
TH1D * hbPt
Definition: STFilter.h:30
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
TH1D * hbEtaFiltered
Definition: STFilter.h:31
double pTMax_
Definition: STFilter.h:22
unsigned int accepted_events
Definition: STFilter.h:27
unsigned int input_events
Definition: STFilter.h:26
edm::InputTag hepMCProductTag_
Definition: STFilter.h:37
bool m_produceHistos
Definition: STFilter.h:29
TH1D * hbPtFiltered
Definition: STFilter.h:30

Member Data Documentation

unsigned int STFilter::accepted_events
private

Definition at line 27 of file STFilter.h.

Referenced by endJob(), filter(), and STFilter().

edm::ParameterSet STFilter::conf_
private

Definition at line 36 of file STFilter.h.

Referenced by beginJob(), and STFilter().

int STFilter::DEBUGLVL
private

Definition at line 24 of file STFilter.h.

Referenced by STFilter().

std::string STFilter::fOutputFileName
private

Definition at line 33 of file STFilter.h.

Referenced by beginJob(), and STFilter().

TH1D* STFilter::hbEta
private

Definition at line 31 of file STFilter.h.

Referenced by beginJob(), endJob(), and filter().

TH1D* STFilter::hbEtaFiltered
private

Definition at line 31 of file STFilter.h.

Referenced by beginJob(), endJob(), and filter().

TH1D* STFilter::hbPt
private

Definition at line 30 of file STFilter.h.

Referenced by beginJob(), endJob(), and filter().

TH1D* STFilter::hbPtFiltered
private

Definition at line 30 of file STFilter.h.

Referenced by beginJob(), endJob(), and filter().

edm::InputTag STFilter::hepMCProductTag_
private

Definition at line 37 of file STFilter.h.

Referenced by filter().

TFile* STFilter::hOutputFile
private

Definition at line 34 of file STFilter.h.

Referenced by beginJob(), and endJob().

unsigned int STFilter::input_events
private

Definition at line 26 of file STFilter.h.

Referenced by endJob(), filter(), and STFilter().

bool STFilter::m_produceHistos
private

Definition at line 29 of file STFilter.h.

Referenced by beginJob(), endJob(), filter(), and STFilter().

double STFilter::pTMax_
private

Definition at line 22 of file STFilter.h.

Referenced by filter(), and STFilter().