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

#include <TotalKinematicsFilter.h>

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

Public Member Functions

 TotalKinematicsFilter (const edm::ParameterSet &)
 
 ~TotalKinematicsFilter ()
 
- 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 bool filter (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag src_
 
double tolerance_
 
bool verbose_
 

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

Filter to select events with deviation from nominal total kinematics smaller than a tolerance parameter.

This filter adds up the momenta of all generated particles (except the initial state protons) and requires that the sum of the of the three-momenta is zero (within tolerance) and that the sum of the energies is equal to the center of mass energy (within tolerance). The center of mass energy is obtained from the initial state protons. The tolerance is specified in GeV.

Definition at line 27 of file TotalKinematicsFilter.h.

Constructor & Destructor Documentation

TotalKinematicsFilter::TotalKinematicsFilter ( const edm::ParameterSet iPSet)
explicit

Definition at line 5 of file TotalKinematicsFilter.cc.

5  :
6  src_(iPSet.getParameter<edm::InputTag>("src")),
7  tolerance_(iPSet.getParameter<double>("tolerance")),
8  verbose_(iPSet.getUntrackedParameter<bool>("verbose",false))
9 {
10 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TotalKinematicsFilter::~TotalKinematicsFilter ( )

Definition at line 12 of file TotalKinematicsFilter.cc.

12 {}

Member Function Documentation

bool TotalKinematicsFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDFilter.

Definition at line 14 of file TotalKinematicsFilter.cc.

References funct::abs(), gather_cfg::cout, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), i, nPart(), mathSSE::sqrt(), src_, tolerance_, and verbose_.

15 {
16 
17  float nEcms = 0.;
18  unsigned int nInit = 0;
19 
20  std::vector<float> p4tot(4,0.);
21  unsigned int nPart = 0;
22 
23  // Gather information on the reco::GenParticle collection
25  iEvent.getByLabel(src_, genParticles );
26 
27  for (reco::GenParticleCollection::const_iterator iter=genParticles->begin();iter!=genParticles->end();++iter){
28  if ( nInit < 3 && (*iter).status() == 3 && (*iter).pdgId() == 2212 ) {
29  nInit++;
30  nEcms += (*iter).energy();
31  }
32  if ( (*iter).status() == 1) {
33  nPart++;
34  if (verbose_) {
35  std::cout << "Status 1 part # " << std::setw(4) << std::fixed << nPart
36  << std::setw(14) << std::fixed << (*iter).pdgId()
37  << std::setw(14) << std::fixed << (*iter).px()
38  << std::setw(14) << std::fixed << (*iter).py()
39  << std::setw(14) << std::fixed << (*iter).pz() << std::endl;
40  }
41  p4tot[0] += (*iter).px();
42  p4tot[1] += (*iter).py();
43  p4tot[2] += (*iter).pz();
44  p4tot[3] += std::sqrt( (*iter).px()*(*iter).px() +
45  (*iter).py()*(*iter).py() +
46  (*iter).pz()*(*iter).pz() +
47  (*iter).mass()*(*iter).mass()) ;
48  }
49  }
50 
51  if ( verbose_ ) {
52  std::cout << "Initial sqrt(s) = " << nEcms << std::endl;
53  for (unsigned int i=0; i<4; i++) {
54  std::cout << "p4tot["<<i<<"] = " << p4tot[i] << std::endl;
55  }
56  }
57 
58  bool pass = true;
59  if ( std::abs(p4tot[0]) > tolerance_ || std::abs(p4tot[1]) > tolerance_ || std::abs(p4tot[2]) > tolerance_ || std::abs(p4tot[3]-nEcms) > tolerance_ )
60  { pass = false; }
61 
62  return pass;
63 
64 }
int i
Definition: DBlmapReader.cc:9
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

edm::InputTag TotalKinematicsFilter::src_
private

Definition at line 38 of file TotalKinematicsFilter.h.

Referenced by filter().

double TotalKinematicsFilter::tolerance_
private

tolerance in GeV

Definition at line 41 of file TotalKinematicsFilter.h.

Referenced by filter().

bool TotalKinematicsFilter::verbose_
private

Definition at line 43 of file TotalKinematicsFilter.h.

Referenced by filter().