CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

DuplicationChecker Class Reference

#include <DuplicationChecker.h>

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

List of all members.

Public Types

typedef std::multimap< double,
edm::EventID
associationMap
typedef std::vector
< associationMap::iterator > 
itemList

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 ()

Private Attributes

WeightManager _wmanager
DQMStoredbe
edm::InputTag generatedCollection_
edm::InputTag lheEventProduct_
bool searchForLHE_
associationMap xBjorkenHistory
MonitorElementxBjorkenME

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]
DuplicationChecker::~DuplicationChecker ( ) [virtual]

Definition at line 28 of file DuplicationChecker.cc.

References xBjorkenHistory.

{
  xBjorkenHistory.clear();
}

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(), histoStyle::weight, xBjorkenHistory, and xBjorkenME.

{
    
  double bjorken = 0;
 
  double weight = 1.;

  if (searchForLHE_) {

    Handle<LHEEventProduct> evt;
    iEvent.getByLabel(lheEventProduct_, evt);

    const lhef::HEPEUP hepeup_ = evt->hepeup();

    const std::vector<lhef::HEPEUP::FiveVector> pup_ = hepeup_.PUP;

    double pz1=(pup_[0])[3];
    double pz2=(pup_[1])[3];
    bjorken+=(pz1/(pz1+pz2));
  }
  else {
    //change teh weight in this case
    weight = _wmanager.weight(iEvent);

    edm::Handle<HepMCProduct> evt;
    iEvent.getByLabel(generatedCollection_, evt);

    const HepMC::PdfInfo *pdf = evt->GetEvent()->pdf_info();    
    if(pdf){
      bjorken = ((pdf->x1())/((pdf->x1())+(pdf->x2())));
    }

  }

  xBjorkenHistory.insert(std::pair<double,edm::EventID>(bjorken,iEvent.id()));

  xBjorkenME->Fill(bjorken,weight);

}//analyze
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.

{
  if(dbe){
        dbe->setCurrentFolder("Generator/DuplicationCheck");
        
        xBjorkenME = dbe->book1D("xBjorkenME", "x Bjorken ratio", 1000000, 0., 1.);
  }
}
virtual void DuplicationChecker::beginRun ( const edm::Run ,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file DuplicationChecker.h.

{ 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.

{

  itemList theObjects;
  theObjects.reserve(10);

  for (associationMap::iterator it = xBjorkenHistory.begin(); it != xBjorkenHistory.end(); it++) {
    double theKey = (*it).first;

    findValuesAssociatedWithKey(xBjorkenHistory, theKey, theObjects);

    if (theObjects.size() > 1) {
      edm::LogWarning("DuplicatedEventFound") << "Duplicated events found with xBjorken = " << std::fixed << std::setw(16) << std::setprecision(14) << theKey; 
      for (unsigned int i = 0; i < theObjects.size(); i++) {
        edm::LogPrint("DuplicatedEventList") << "Event = " << (*theObjects[i]).second;
      }
    }

    theObjects.clear();
 
  }

}
virtual void DuplicationChecker::endRun ( const edm::Run ,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file DuplicationChecker.h.

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

Definition at line 84 of file DuplicationChecker.cc.

Referenced by endJob().

{
  associationMap::iterator itr;
  associationMap::iterator lastElement;
        
  theObjects.clear();

  // locate an iterator to the first pair object associated with key
  itr = mMap.find(key);
  if (itr == mMap.end())
    return; // no elements associated with key, so return immediately

  // get an iterator to the element that is one past the last element associated with key
  lastElement = mMap.upper_bound(key);

  // for each element in the sequence [itr, lastElement)
  for ( ; itr != lastElement; ++itr)
    theObjects.push_back(itr);
}  

Member Data Documentation

Definition at line 58 of file DuplicationChecker.h.

Referenced by analyze().

Definition at line 67 of file DuplicationChecker.h.

Referenced by beginJob(), and DuplicationChecker().

Definition at line 60 of file DuplicationChecker.h.

Referenced by analyze().

Definition at line 61 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

Definition at line 63 of file DuplicationChecker.h.

Referenced by analyze(), and DuplicationChecker().

Definition at line 65 of file DuplicationChecker.h.

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

Definition at line 69 of file DuplicationChecker.h.

Referenced by analyze(), and beginJob().