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

Public Types

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

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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

WeightManager _wmanager
 
DQMStoredbe
 
edm::InputTag generatedCollection_
 
edm::InputTag lheEventProduct_
 
bool searchForLHE_
 
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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 40 of file DuplicationChecker.h.

Member Typedef Documentation

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

Definition at line 45 of file DuplicationChecker.h.

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

Definition at line 46 of file DuplicationChecker.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file DuplicationChecker.cc.

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

14  :
15  _wmanager(iPSet),
16  generatedCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
17  searchForLHE_(iPSet.getParameter<bool>("searchForLHE"))
18 {
19  if (searchForLHE_) {
20  lheEventProduct_ = iPSet.getParameter<edm::InputTag>("lheEventProduct");
21  }
22  dbe = 0;
24 
25  xBjorkenHistory.clear();
26 }
T getParameter(std::string const &) const
edm::InputTag generatedCollection_
associationMap xBjorkenHistory
WeightManager _wmanager
edm::InputTag lheEventProduct_
DuplicationChecker::~DuplicationChecker ( )
virtual

Definition at line 28 of file DuplicationChecker.cc.

References xBjorkenHistory.

29 {
30  xBjorkenHistory.clear();
31 }
associationMap xBjorkenHistory

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 44 of file DuplicationChecker.cc.

References _wmanager, MonitorElement::Fill(), generatedCollection_, edm::Event::getByLabel(), hepeup_, edm::EventBase::id(), lheEventProduct_, lhef::HEPEUP::PUP, searchForLHE_, WeightManager::weight(), CommonMethods::weight(), xBjorkenHistory, and xBjorkenME.

45 {
46 
47  double bjorken = 0;
48 
49  double weight = 1.;
50 
51  if (searchForLHE_) {
52 
54  iEvent.getByLabel(lheEventProduct_, evt);
55 
56  const lhef::HEPEUP hepeup_ = evt->hepeup();
57 
58  const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP;
59 
60  double pz1=(pup_[0])[3];
61  double pz2=(pup_[1])[3];
62  bjorken+=(pz1/(pz1+pz2));
63  }
64  else {
65  //change teh weight in this case
66  weight = _wmanager.weight(iEvent);
67 
69  iEvent.getByLabel(generatedCollection_, evt);
70 
71  const HepMC::PdfInfo *pdf = evt->GetEvent()->pdf_info();
72  if(pdf){
73  bjorken = ((pdf->x1())/((pdf->x1())+(pdf->x2())));
74  }
75 
76  }
77 
78  xBjorkenHistory.insert(std::pair<double,edm::EventID>(bjorken,iEvent.id()));
79 
80  xBjorkenME->Fill(bjorken,weight);
81 
82 }//analyze
edm::InputTag generatedCollection_
struct HEPEUP_ hepeup_
associationMap xBjorkenHistory
void Fill(long long x)
WeightManager _wmanager
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
MonitorElement * xBjorkenME
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag lheEventProduct_
edm::EventID id() const
Definition: EventBase.h:56
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 33 of file DuplicationChecker.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file DuplicationChecker.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 104 of file DuplicationChecker.cc.

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

105 {
106 
107  itemList theObjects;
108  theObjects.reserve(10);
109 
110  for (associationMap::iterator it = xBjorkenHistory.begin(); it != xBjorkenHistory.end(); it++) {
111  double theKey = (*it).first;
112 
113  findValuesAssociatedWithKey(xBjorkenHistory, theKey, theObjects);
114 
115  if (theObjects.size() > 1) {
116  edm::LogWarning("DuplicatedEventFound") << "Duplicated events found with xBjorken = " << std::fixed << std::setw(16) << std::setprecision(14) << theKey;
117  for (unsigned int i = 0; i < theObjects.size(); i++) {
118  edm::LogPrint("DuplicatedEventList") << "Event = " << (*theObjects[i]).second;
119  }
120  }
121 
122  theObjects.clear();
123 
124  }
125 
126 }
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 54 of file DuplicationChecker.h.

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

Definition at line 84 of file DuplicationChecker.cc.

Referenced by endJob().

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

Member Data Documentation

WeightManager DuplicationChecker::_wmanager
private

Definition at line 58 of file DuplicationChecker.h.

Referenced by analyze().

DQMStore* DuplicationChecker::dbe
private

Definition at line 67 of file DuplicationChecker.h.

Referenced by beginJob(), and DuplicationChecker().

edm::InputTag DuplicationChecker::generatedCollection_
private

Definition at line 60 of file DuplicationChecker.h.

Referenced by analyze().

edm::InputTag DuplicationChecker::lheEventProduct_
private

Definition at line 61 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

bool DuplicationChecker::searchForLHE_
private

Definition at line 63 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

associationMap DuplicationChecker::xBjorkenHistory
private

Definition at line 65 of file DuplicationChecker.h.

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

MonitorElement* DuplicationChecker::xBjorkenME
private

Definition at line 69 of file DuplicationChecker.h.

Referenced by analyze(), and beginJob().