File indexing completed on 2024-04-06 12:32:10
0001
0002
0003
0004
0005
0006
0007
0008 #include "Validation/EventGenerator/interface/DuplicationChecker.h"
0009 #include "Validation/EventGenerator/interface/DQMHelper.h"
0010 using namespace edm;
0011
0012 DuplicationChecker::DuplicationChecker(const edm::ParameterSet &iPSet)
0013 : wmanager_(iPSet, consumesCollector()),
0014 generatedCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
0015 searchForLHE_(iPSet.getParameter<bool>("searchForLHE")) {
0016 if (searchForLHE_) {
0017 lheEventProduct_ = iPSet.getParameter<edm::InputTag>("lheEventProduct");
0018 }
0019 xBjorkenHistory.clear();
0020
0021 if (searchForLHE_)
0022 lheEventProductToken_ = consumes<LHEEventProduct>(lheEventProduct_);
0023 else
0024 generatedCollectionToken_ = consumes<HepMCProduct>(generatedCollection_);
0025 }
0026
0027 DuplicationChecker::~DuplicationChecker() { xBjorkenHistory.clear(); }
0028
0029 void DuplicationChecker::bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) {
0030
0031 DQMHelper dqm(&i);
0032 i.setCurrentFolder("Generator/DuplicationCheck");
0033
0034
0035 xBjorkenME = dqm.book1dHisto("xBjorkenME", "x Bjorken ratio", 1000000, 0., 1.);
0036 }
0037
0038 void DuplicationChecker::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0039 double bjorken = 0;
0040
0041 double weight = 1.;
0042
0043 if (searchForLHE_) {
0044 Handle<LHEEventProduct> evt;
0045 iEvent.getByToken(lheEventProductToken_, evt);
0046
0047 const lhef::HEPEUP hepeup_ = evt->hepeup();
0048
0049 const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP;
0050
0051 double pz1 = (pup_[0])[3];
0052 double pz2 = (pup_[1])[3];
0053 bjorken += (pz1 / (pz1 + pz2));
0054 } else {
0055
0056 weight = wmanager_.weight(iEvent);
0057
0058 edm::Handle<HepMCProduct> evt;
0059 iEvent.getByToken(generatedCollectionToken_, evt);
0060
0061 const HepMC::PdfInfo *pdf = evt->GetEvent()->pdf_info();
0062 if (pdf) {
0063 bjorken = ((pdf->x1()) / ((pdf->x1()) + (pdf->x2())));
0064 }
0065 }
0066
0067 xBjorkenHistory.insert(std::pair<double, edm::EventID>(bjorken, iEvent.id()));
0068
0069 xBjorkenME->Fill(bjorken, weight);
0070
0071 }
0072
0073 void DuplicationChecker::findValuesAssociatedWithKey(associationMap &mMap, double &key, itemList &theObjects) {
0074 associationMap::iterator itr;
0075 associationMap::iterator lastElement;
0076
0077 theObjects.clear();
0078
0079
0080 itr = mMap.find(key);
0081 if (itr == mMap.end())
0082 return;
0083
0084
0085 lastElement = mMap.upper_bound(key);
0086
0087
0088 for (; itr != lastElement; ++itr)
0089 theObjects.push_back(itr);
0090 }
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116