CMS 3D CMS Logo

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

#include <DuplicationChecker.h>

Inheritance diagram for DuplicationChecker:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef std::multimap< double,
edm::EventID
associationMap
 
typedef std::vector
< associationMap::iterator > 
itemList
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 

Public Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
 DuplicationChecker (const edm::ParameterSet &)
 
void endJob ()
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
void findValuesAssociatedWithKey (associationMap &mMap, double &key, itemList &theObjects)
 
virtual ~DuplicationChecker ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

DQMStoredbe
 
edm::InputTag generatedCollection_
 
edm::EDGetTokenT
< edm::HepMCProduct
generatedCollectionToken_
 
edm::InputTag lheEventProduct_
 
edm::EDGetTokenT< LHEEventProductlheEventProductToken_
 
bool searchForLHE_
 
WeightManager wmanager_
 
associationMap xBjorkenHistory
 
MonitorElementxBjorkenME
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
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

Definition at line 38 of file DuplicationChecker.h.

Member Typedef Documentation

typedef std::multimap<double,edm::EventID> DuplicationChecker::associationMap

Definition at line 43 of file DuplicationChecker.h.

typedef std::vector<associationMap::iterator> DuplicationChecker::itemList

Definition at line 44 of file DuplicationChecker.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file DuplicationChecker.cc.

References dbe, generatedCollection_, generatedCollectionToken_, edm::ParameterSet::getParameter(), lheEventProduct_, lheEventProductToken_, cppFunctionSkipper::operator, searchForLHE_, and xBjorkenHistory.

12  :
14  generatedCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
15  searchForLHE_(iPSet.getParameter<bool>("searchForLHE"))
16 {
17  if (searchForLHE_) {
18  lheEventProduct_ = iPSet.getParameter<edm::InputTag>("lheEventProduct");
19  }
20  dbe = 0;
22 
23  xBjorkenHistory.clear();
24 
25  if (searchForLHE_) lheEventProductToken_=consumes<LHEEventProduct>(lheEventProduct_);
26  else generatedCollectionToken_=consumes<HepMCProduct>(generatedCollection_);
27 
28 }
T getParameter(std::string const &) const
edm::EDGetTokenT< LHEEventProduct > lheEventProductToken_
edm::InputTag generatedCollection_
edm::EDGetTokenT< edm::HepMCProduct > generatedCollectionToken_
associationMap xBjorkenHistory
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
WeightManager wmanager_
edm::InputTag lheEventProduct_
DuplicationChecker::~DuplicationChecker ( )
virtual

Definition at line 30 of file DuplicationChecker.cc.

References xBjorkenHistory.

31 {
32  xBjorkenHistory.clear();
33 }
associationMap xBjorkenHistory

Member Function Documentation

void DuplicationChecker::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 46 of file DuplicationChecker.cc.

References MonitorElement::Fill(), generatedCollectionToken_, edm::Event::getByToken(), hepeup_, edm::EventBase::id(), lheEventProductToken_, lhef::HEPEUP::PUP, searchForLHE_, WeightManager::weight(), histoStyle::weight, wmanager_, xBjorkenHistory, and xBjorkenME.

47 {
48 
49  double bjorken = 0;
50 
51  double weight = 1.;
52 
53  if (searchForLHE_) {
54 
56  iEvent.getByToken(lheEventProductToken_, evt);
57 
58  const lhef::HEPEUP hepeup_ = evt->hepeup();
59 
60  const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP;
61 
62  double pz1=(pup_[0])[3];
63  double pz2=(pup_[1])[3];
64  bjorken+=(pz1/(pz1+pz2));
65  }
66  else {
67  //change teh weight in this case
68  weight = wmanager_.weight(iEvent);
69 
72 
73  const HepMC::PdfInfo *pdf = evt->GetEvent()->pdf_info();
74  if(pdf){
75  bjorken = ((pdf->x1())/((pdf->x1())+(pdf->x2())));
76  }
77 
78  }
79 
80  xBjorkenHistory.insert(std::pair<double,edm::EventID>(bjorken,iEvent.id()));
81 
82  xBjorkenME->Fill(bjorken,weight);
83 
84 }//analyze
edm::EDGetTokenT< LHEEventProduct > lheEventProductToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
struct HEPEUP_ hepeup_
edm::EDGetTokenT< edm::HepMCProduct > generatedCollectionToken_
associationMap xBjorkenHistory
void Fill(long long x)
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
WeightManager wmanager_
MonitorElement * xBjorkenME
edm::EventID id() const
Definition: EventBase.h:56
int weight
Definition: histoStyle.py:50
double weight(const edm::Event &)
void DuplicationChecker::beginJob ( void  )
virtual

Setting the DQM top directories

Booking the ME's

Reimplemented from edm::EDAnalyzer.

Definition at line 35 of file DuplicationChecker.cc.

References DQMStore::book1D(), dbe, DQMStore::setCurrentFolder(), and xBjorkenME.

36 {
37  if(dbe){
39  dbe->setCurrentFolder("Generator/DuplicationCheck");
40 
42  xBjorkenME = dbe->book1D("xBjorkenME", "x Bjorken ratio", 1000000, 0., 1.);
43  }
44 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
MonitorElement * xBjorkenME
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
virtual void DuplicationChecker::beginRun ( const edm::Run ,
const edm::EventSetup  
)
inlinevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file DuplicationChecker.h.

51 { return;}
void DuplicationChecker::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 106 of file DuplicationChecker.cc.

References findValuesAssociatedWithKey(), i, edm::second(), and xBjorkenHistory.

107 {
108 
109  itemList theObjects;
110  theObjects.reserve(10);
111 
112  for (associationMap::iterator it = xBjorkenHistory.begin(); it != xBjorkenHistory.end(); it++) {
113  double theKey = (*it).first;
114 
115  findValuesAssociatedWithKey(xBjorkenHistory, theKey, theObjects);
116 
117  if (theObjects.size() > 1) {
118  edm::LogWarning("DuplicatedEventFound") << "Duplicated events found with xBjorken = " << std::fixed << std::setw(16) << std::setprecision(14) << theKey;
119  for (unsigned int i = 0; i < theObjects.size(); i++) {
120  edm::LogPrint("DuplicatedEventList") << "Event = " << (*theObjects[i]).second;
121  }
122  }
123 
124  theObjects.clear();
125 
126  }
127 
128 }
int i
Definition: DBlmapReader.cc:9
std::vector< associationMap::iterator > itemList
associationMap xBjorkenHistory
U second(std::pair< T, U > const &p)
void findValuesAssociatedWithKey(associationMap &mMap, double &key, itemList &theObjects)
virtual void DuplicationChecker::endRun ( const edm::Run ,
const edm::EventSetup  
)
inlinevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file DuplicationChecker.h.

52 { return;}
void DuplicationChecker::findValuesAssociatedWithKey ( associationMap mMap,
double &  key,
itemList theObjects 
)

Definition at line 86 of file DuplicationChecker.cc.

Referenced by endJob().

87 {
88  associationMap::iterator itr;
89  associationMap::iterator lastElement;
90 
91  theObjects.clear();
92 
93  // locate an iterator to the first pair object associated with key
94  itr = mMap.find(key);
95  if (itr == mMap.end())
96  return; // no elements associated with key, so return immediately
97 
98  // get an iterator to the element that is one past the last element associated with key
99  lastElement = mMap.upper_bound(key);
100 
101  // for each element in the sequence [itr, lastElement)
102  for ( ; itr != lastElement; ++itr)
103  theObjects.push_back(itr);
104 }
list key
Definition: combine.py:13

Member Data Documentation

DQMStore* DuplicationChecker::dbe
private

Definition at line 65 of file DuplicationChecker.h.

Referenced by beginJob(), and DuplicationChecker().

edm::InputTag DuplicationChecker::generatedCollection_
private

Definition at line 58 of file DuplicationChecker.h.

Referenced by DuplicationChecker().

edm::EDGetTokenT<edm::HepMCProduct> DuplicationChecker::generatedCollectionToken_
private

Definition at line 70 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

edm::InputTag DuplicationChecker::lheEventProduct_
private

Definition at line 59 of file DuplicationChecker.h.

Referenced by DuplicationChecker().

edm::EDGetTokenT<LHEEventProduct> DuplicationChecker::lheEventProductToken_
private

Definition at line 69 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

bool DuplicationChecker::searchForLHE_
private

Definition at line 61 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

WeightManager DuplicationChecker::wmanager_
private

Definition at line 56 of file DuplicationChecker.h.

Referenced by analyze().

associationMap DuplicationChecker::xBjorkenHistory
private

Definition at line 63 of file DuplicationChecker.h.

Referenced by analyze(), DuplicationChecker(), endJob(), and ~DuplicationChecker().

MonitorElement* DuplicationChecker::xBjorkenME
private

Definition at line 67 of file DuplicationChecker.h.

Referenced by analyze(), and beginJob().