Skip to content

Commit

Permalink
Merge pull request #3150 from igv4321/igv4321/oot-pileup-prepare
Browse files Browse the repository at this point in the history
Reco -- Preparing HBHERecHit class for introducing out-of-time pileup correction
  • Loading branch information
ktf committed Apr 4, 2014
2 parents 1e0c2d2 + e3bc8f3 commit 510bb16
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
11 changes: 6 additions & 5 deletions DataFormats/HcalRecHit/interface/HBHERecHit.h
Expand Up @@ -15,18 +15,19 @@ class HBHERecHit : public CaloRecHit {

HBHERecHit();
//HBHERecHit(const HcalDetId& id, float energy, float time);
/// get the id
HBHERecHit(const HcalDetId& id, float amplitude, float timeRising, float timeFalling=0);
/// get the amplitude (generally fC, but can vary)
/// get the hit time

/// get the hit falling time
float timeFalling() const { return timeFalling_; }
/// get the id
HcalDetId id() const { return HcalDetId(detid()); }


inline void setRawEnergy(const float en) {rawEnergy_ = en;}
inline float eraw() const {return rawEnergy_;}

private:

float timeFalling_;
float rawEnergy_;
};

std::ostream& operator<<(std::ostream& s, const HBHERecHit& hit);
Expand Down
8 changes: 6 additions & 2 deletions DataFormats/HcalRecHit/src/HBHERecHit.cc
@@ -1,17 +1,21 @@
#include "DataFormats/HcalRecHit/interface/HBHERecHit.h"


HBHERecHit::HBHERecHit() : CaloRecHit() {
HBHERecHit::HBHERecHit() : CaloRecHit(), rawEnergy_(-1.0e21) {
}

HBHERecHit::HBHERecHit(const HcalDetId& id, float energy, float timeRising, float timeFalling) :
CaloRecHit(id,energy,timeRising),
timeFalling_(timeFalling)
timeFalling_(timeFalling),
rawEnergy_(-1.0e21)
{
}

std::ostream& operator<<(std::ostream& s, const HBHERecHit& hit) {
s << hit.id() << ": " << hit.energy() << " GeV";
if (hit.eraw() > -0.9e21) {
s << ", eraw=" << hit.eraw() << " GeV";
}
if(hit.time() > -998) {
s << ", t= " << hit.time() << " to " << hit.timeFalling() << " ns";
}
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/HcalRecHit/src/classes_def.xml
@@ -1,5 +1,6 @@
<lcgdict>
<class name="HBHERecHit" ClassVersion="12">
<class name="HBHERecHit" ClassVersion="13">
<version ClassVersion="13" checksum="1684878064"/>
<version ClassVersion="12" checksum="3812633329"/>
<version ClassVersion="10" checksum="3145355338"/>
</class>
Expand Down
38 changes: 28 additions & 10 deletions DataFormats/HcalRecHit/test/HcalRecHitDump.cc
Expand Up @@ -2,9 +2,14 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/GetterOfProducts.h"
#include "FWCore/Framework/interface/ProcessMatch.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"

#include <string>
#include <iostream>

using namespace std;
Expand All @@ -15,45 +20,58 @@ namespace cms {
\author J. Mans - Minnesota
*/
class HcalRecHitDump : public edm::EDAnalyzer {
class HcalRecHitDump : public edm::EDAnalyzer
{
public:
explicit HcalRecHitDump(edm::ParameterSet const& conf);
virtual void analyze(edm::Event const& e, edm::EventSetup const& c);

private:
edm::GetterOfProducts<HcalSourcePositionData> getHcalSourcePositionData_;

string hbhePrefix_;
string hoPrefix_;
string hfPrefix_;
};

HcalRecHitDump::HcalRecHitDump(edm::ParameterSet const& conf) :
getHcalSourcePositionData_(edm::ProcessMatch("*"), this) {
getHcalSourcePositionData_(edm::ProcessMatch("*"), this),
hbhePrefix_(conf.getUntrackedParameter<string>("hbhePrefix", "")),
hoPrefix_(conf.getUntrackedParameter<string>("hoPrefix", "")),
hfPrefix_(conf.getUntrackedParameter<string>("hfPrefix", ""))
{
callWhenNewProductsRegistered(getHcalSourcePositionData_);
}

template<typename COLL> void analyzeT(edm::Event const& e, const char * name=0) {

template<typename COLL>
static void analyzeT(edm::Event const& e, const char* name=0, const char* prefix=0)
{
const string marker(prefix ? prefix : "");
try {
std::vector<edm::Handle<COLL> > colls;
vector<edm::Handle<COLL> > colls;
e.getManyByType(colls);
typename std::vector<edm::Handle<COLL> >::iterator i;
for (i=colls.begin(); i!=colls.end(); i++) {
for (typename COLL::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++)
cout << *j << std::endl;
cout << marker << *j << endl;
}
} catch (...) {
if(name) cout << "No " << name << " RecHits." << endl;
}
}

void HcalRecHitDump::analyze(edm::Event const& e, edm::EventSetup const& c) {
analyzeT<HBHERecHitCollection>(e, "HB/HE");
analyzeT<HFRecHitCollection>(e, "HF");
analyzeT<HORecHitCollection>(e, "HO");
analyzeT<HBHERecHitCollection>(e, "HB/HE", hbhePrefix_.c_str());
analyzeT<HFRecHitCollection>(e, "HF", hfPrefix_.c_str());
analyzeT<HORecHitCollection>(e, "HO", hoPrefix_.c_str());
analyzeT<HcalCalibRecHitCollection>(e);
analyzeT<ZDCRecHitCollection>(e);
analyzeT<CastorRecHitCollection>(e);

std::vector<edm::Handle<HcalSourcePositionData> > handles;
getHcalSourcePositionData_.fillHandles(e, handles);
for (auto const& spd : handles){
cout << *spd << std::endl;
cout << *spd << endl;
}
cout << endl;
}
Expand Down

0 comments on commit 510bb16

Please sign in to comment.