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
XtoFFbarFilter Class Reference

#include <XtoFFbarFilter.h>

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

Public Member Functions

virtual bool filter (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 XtoFFbarFilter (const edm::ParameterSet &)
 
 ~XtoFFbarFilter ()
 
- 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 endJob ()
 
bool found (const std::vector< int > &v, int j)
 
bool foundXtoFFbar (const reco::GenParticleRef &moth, const std::vector< int > &idMotherX, const std::vector< int > &idDaughterF)
 

Private Attributes

edm::Handle
< reco::GenParticleCollection
genParticles_
 
std::vector< int > idDaughterF_
 
std::vector< int > idDaughterG_
 
std::vector< int > idMotherX_
 
std::vector< int > idMotherY_
 
unsigned int rejectedEvents_
 
bool requireY_
 
edm::InputTag src_
 
unsigned int totalEvents_
 
double xSumCtau_
 
double xSumPt_
 
double xSumR_
 
unsigned int xTotal_
 

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

XtoFFbarFilter A GenParticle-based filter that searches for X -> f fbar where X and f are any particle you choose. Can optionally also require a second decay Y -> g g-bar to be present in same event.

Author
Ian Tomalin, RAL

Definition at line 30 of file XtoFFbarFilter.h.

Constructor & Destructor Documentation

XtoFFbarFilter::XtoFFbarFilter ( const edm::ParameterSet iConfig)

Definition at line 6 of file XtoFFbarFilter.cc.

References idDaughterG_, idMotherY_, and requireY_.

6  :
7  src_(iConfig.getParameter<edm::InputTag>("src")),
8  idMotherX_(iConfig.getParameter<vector<int> >("idMotherX")),
9  idDaughterF_(iConfig.getParameter<vector<int> >("idDaughterF")),
10  idMotherY_(iConfig.getParameter<vector<int> >("idMotherY")),
11  idDaughterG_(iConfig.getParameter<vector<int> >("idDaughterG")),
13 {
14  // Note if if not searching for Y --> g-gbar.
15  requireY_ = (idMotherY_.size() > 0 && idDaughterG_.size() > 0);
16 }
T getParameter(std::string const &) const
edm::InputTag src_
unsigned int rejectedEvents_
std::vector< int > idMotherX_
std::vector< int > idMotherY_
unsigned int totalEvents_
std::vector< int > idDaughterG_
unsigned int xTotal_
std::vector< int > idDaughterF_
XtoFFbarFilter::~XtoFFbarFilter ( )
inline

Definition at line 33 of file XtoFFbarFilter.h.

33 {}

Member Function Documentation

void XtoFFbarFilter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 103 of file XtoFFbarFilter.cc.

References gather_cfg::cout, rejectedEvents_, totalEvents_, xSumCtau_, xSumPt_, xSumR_, and xTotal_.

103  {
104  cout<<endl;
105  cout<<"=== XtoFFbarFilter statistics of selected X->ffbar or Y->ggbar"<<endl;
106  if (xTotal_ > 0) {
107  cout<<"=== mean X & Y Pt = "<<xSumPt_/xTotal_<<" GeV and transverse decay length = "<<xSumR_/xTotal_<<" cm"<<endl;
108  cout<<"=== mean c*tau = "<<xSumCtau_/xTotal_<<" cm"<<endl;
109  } else {
110  cout<<"=== WARNING: NONE FOUND !"<<endl;
111  }
112  cout<<"=== events rejected = "<<rejectedEvents_<<"/"<<totalEvents_<<endl;
113 }
unsigned int rejectedEvents_
unsigned int totalEvents_
unsigned int xTotal_
tuple cout
Definition: gather_cfg.py:121
bool XtoFFbarFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 19 of file XtoFFbarFilter.cc.

References foundXtoFFbar(), genParticles_, edm::Event::getByLabel(), idDaughterF_, idDaughterG_, idMotherX_, idMotherY_, j, rejectedEvents_, requireY_, src_, and totalEvents_.

19  {
20 
21  iEvent.getByLabel(src_, genParticles_);
22 
23  totalEvents_++;
24 
25  unsigned int numX = 0;
26  unsigned int numY = 0;
27  unsigned int numXorY = 0;
28 
29  for (unsigned int j = 0; j < genParticles_->size(); j++) {
31 
32  // Is it X -> f fbar ?
33  bool isXtoFFbar = this->foundXtoFFbar(moth, idMotherX_, idDaughterF_);
34  if (isXtoFFbar) numX++;
35 
36  if (!requireY_) {
37 
38  // Has X been found already ?
39  if (numX >= 1) return true;
40 
41  } else {
42 
43  // Is it Y -> g gbar ?
44  bool isYtoGGbar = this->foundXtoFFbar(moth, idMotherY_, idDaughterG_);
45  if (isYtoGGbar) numY++;
46  if (isXtoFFbar || isYtoGGbar) numXorY++;
47 
48  // Have X and Y been found already ?
49  if (numX >= 1 && numY >= 1 && numXorY >= 2) return true;
50  }
51  }
52 
54  // cout<<"REJECTED "<<totalEvents_<<endl;
55  return false;
56 }
edm::InputTag src_
unsigned int rejectedEvents_
std::vector< int > idMotherX_
std::vector< int > idMotherY_
unsigned int totalEvents_
std::vector< int > idDaughterG_
edm::Handle< reco::GenParticleCollection > genParticles_
int j
Definition: DBlmapReader.cc:9
std::vector< int > idDaughterF_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
bool foundXtoFFbar(const reco::GenParticleRef &moth, const std::vector< int > &idMotherX, const std::vector< int > &idDaughterF)
bool XtoFFbarFilter::found ( const std::vector< int > &  v,
int  j 
)
inlineprivate

Definition at line 40 of file XtoFFbarFilter.h.

References spr::find(), and j.

Referenced by pf_01_customizeAll.SeqVisitor::__init__(), pf_01_customizeSimulation.SeqVisitor::__init__(), pf_01_customizeAll.SeqVisitor::enter(), pf_01_customizeSimulation.SeqVisitor::enter(), foundXtoFFbar(), pf_01_customizeAll.SeqVisitor::prepareSearch(), and pf_01_customizeSimulation.SeqVisitor::prepareSearch().

40  {
41  return std::find(v.begin(), v.end(), j) != v.end();
42  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int j
Definition: DBlmapReader.cc:9
bool XtoFFbarFilter::foundXtoFFbar ( const reco::GenParticleRef moth,
const std::vector< int > &  idMotherX,
const std::vector< int > &  idDaughterF 
)
private

Definition at line 59 of file XtoFFbarFilter.cc.

References found(), i, j, rho, xSumCtau_, xSumPt_, xSumR_, and xTotal_.

Referenced by filter().

61  {
62  // Check if given particle "moth" is X-->f fbar
63  bool isXtoFFbar = false;
64  int pdgIdMoth = moth->pdgId();
65  double rho = -9.9e9;
66 
67  if (this->found(idMother, pdgIdMoth)) {
68  bool foundF = false;
69  bool foundFbar = false;
70  unsigned int nDau = moth->numberOfDaughters();
71 
72  for (unsigned int i = 0; i < nDau; i++) {
73  GenParticleRef dau = moth->daughterRef(i);
74  int pdgIdDau = dau->pdgId();
75  if (this->found(idDaughter, -pdgIdDau)) foundFbar = true;
76  if (this->found(idDaughter, pdgIdDau)) {foundF = true;
77 
78  // Just for statistics, get transverse decay length.
79  // (To be really accurate, should do it w.r.t. P.V., but couldn't be bothered ...)
80  // This is the normal case
81  rho = dau->vertex().Rho();
82  // Unfortunately, duplicate particles can appear in the event record. Handle this as follows:
83  for (unsigned int j = 0; j < dau->numberOfDaughters(); j++) {
84  GenParticleRef granddau = dau->daughterRef(j);
85  if (granddau->pdgId() == pdgIdDau) rho = granddau->vertex().Rho();
86  }
87  }
88  }
89  if (foundF && foundFbar) isXtoFFbar = true;
90  }
91 
92  if (isXtoFFbar) {
93  // Get statistics
94  xTotal_++;
95  xSumPt_ += moth->pt();
96  xSumR_ += rho;
97  xSumCtau_ += rho*(moth->mass()/(moth->pt()+0.01)); // protection against unlikely case Pt = 0.
98  }
99 
100  return isXtoFFbar;
101 }
bool found(const std::vector< int > &v, int j)
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
unsigned int xTotal_

Member Data Documentation

edm::Handle<reco::GenParticleCollection> XtoFFbarFilter::genParticles_
private

Definition at line 60 of file XtoFFbarFilter.h.

Referenced by filter().

std::vector<int> XtoFFbarFilter::idDaughterF_
private

Definition at line 55 of file XtoFFbarFilter.h.

Referenced by filter().

std::vector<int> XtoFFbarFilter::idDaughterG_
private

Definition at line 57 of file XtoFFbarFilter.h.

Referenced by filter(), and XtoFFbarFilter().

std::vector<int> XtoFFbarFilter::idMotherX_
private

Definition at line 54 of file XtoFFbarFilter.h.

Referenced by filter().

std::vector<int> XtoFFbarFilter::idMotherY_
private

Definition at line 56 of file XtoFFbarFilter.h.

Referenced by filter(), and XtoFFbarFilter().

unsigned int XtoFFbarFilter::rejectedEvents_
private

Definition at line 68 of file XtoFFbarFilter.h.

Referenced by endJob(), and filter().

bool XtoFFbarFilter::requireY_
private

Definition at line 58 of file XtoFFbarFilter.h.

Referenced by filter(), and XtoFFbarFilter().

edm::InputTag XtoFFbarFilter::src_
private

Definition at line 53 of file XtoFFbarFilter.h.

Referenced by filter().

unsigned int XtoFFbarFilter::totalEvents_
private

Definition at line 67 of file XtoFFbarFilter.h.

Referenced by endJob(), and filter().

double XtoFFbarFilter::xSumCtau_
private

Definition at line 66 of file XtoFFbarFilter.h.

Referenced by endJob(), and foundXtoFFbar().

double XtoFFbarFilter::xSumPt_
private

Definition at line 64 of file XtoFFbarFilter.h.

Referenced by endJob(), and foundXtoFFbar().

double XtoFFbarFilter::xSumR_
private

Definition at line 65 of file XtoFFbarFilter.h.

Referenced by endJob(), and foundXtoFFbar().

unsigned int XtoFFbarFilter::xTotal_
private

Definition at line 63 of file XtoFFbarFilter.h.

Referenced by endJob(), and foundXtoFFbar().