CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DuplicationChecker.cc
Go to the documentation of this file.
1 /*class DuplicationChecker
2  *
3  * Class to monitor duplication of events
4  *
5  * $Date: 2012/08/24 21:47:06 $
6  * $Revision: 1.3 $
7  *
8  */
9 
11 
12 using namespace edm;
13 
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 }
27 
29 {
30  xBjorkenHistory.clear();
31 }
32 
34 {
35  if(dbe){
37  dbe->setCurrentFolder("Generator/DuplicationCheck");
38 
40  xBjorkenME = dbe->book1D("xBjorkenME", "x Bjorken ratio", 1000000, 0., 1.);
41  }
42 }
43 
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
83 
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 }
103 
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 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
edm::InputTag generatedCollection_
struct HEPEUP_ hepeup_
std::vector< associationMap::iterator > itemList
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
associationMap xBjorkenHistory
void Fill(long long x)
U second(std::pair< T, U > const &p)
WeightManager _wmanager
int iEvent
Definition: GenABIO.cc:243
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
std::multimap< double, edm::EventID > associationMap
MonitorElement * xBjorkenME
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
edm::InputTag lheEventProduct_
DuplicationChecker(const edm::ParameterSet &)
edm::EventID id() const
Definition: EventBase.h:56
list key
Definition: combine.py:13
double weight(const edm::Event &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void findValuesAssociatedWithKey(associationMap &mMap, double &key, itemList &theObjects)