Skip to content

Commit

Permalink
Merge pull request #13559 from civanch/hcal_tb2006_update
Browse files Browse the repository at this point in the history
Hcal tb2006 update
  • Loading branch information
cmsbuild committed Mar 3, 2016
2 parents 215f4d0 + de23a1e commit db25ba1
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 122 deletions.
25 changes: 6 additions & 19 deletions SimG4CMS/EcalTestBeam/interface/EcalTBMCInfoProducer.h
Expand Up @@ -5,9 +5,7 @@
*
*
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -22,30 +20,19 @@

#include "Math/GenVector/Rotation3D.h"

#include <iostream>
#include <fstream>
#include <vector>

class EcalTBMCInfoProducer: public edm::EDProducer{

public:
class EcalTBMCInfoProducer: public edm::stream::EDProducer<>
{
public:

/// Constructor
EcalTBMCInfoProducer(const edm::ParameterSet& ps);
explicit EcalTBMCInfoProducer(const edm::ParameterSet& ps);

/// Destructor
virtual ~EcalTBMCInfoProducer();

/// Produce digis out of raw data
void produce(edm::Event & event, const edm::EventSetup& eventSetup);

// BeginJob
//void beginJob();

// EndJob
//void endJob(void);


private:

double beamEta;
Expand All @@ -64,7 +51,7 @@ class EcalTBMCInfoProducer: public edm::EDProducer{

ROOT::Math::Rotation3D * fromCMStoTB;

std::string GenVtxLabel;
edm::EDGetTokenT<edm::HepMCProduct> GenVtxToken;
};

#endif
22 changes: 7 additions & 15 deletions SimG4CMS/EcalTestBeam/interface/FakeTBEventHeaderProducer.h
Expand Up @@ -10,7 +10,7 @@
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -23,30 +23,22 @@
#include "TBDataFormats/EcalTBObjects/interface/EcalTBEventHeader.h"
#include "Geometry/EcalTestBeam/interface/EcalTBHodoscopeGeometry.h"

class FakeTBEventHeaderProducer: public edm::EDProducer{


public:
class FakeTBEventHeaderProducer: public edm::stream::EDProducer <>
{
public:

/// Constructor
FakeTBEventHeaderProducer(const edm::ParameterSet& ps);
explicit FakeTBEventHeaderProducer(const edm::ParameterSet& ps);

/// Destructor
virtual ~FakeTBEventHeaderProducer();

/// Produce digis out of raw data
void produce(edm::Event & event, const edm::EventSetup& eventSetup);

// BeginJob
//void beginJob();
void produce(edm::Event & event, const edm::EventSetup& eventSetup) override;

// EndJob
//void endJob(void);


private:

std::string ecalTBInfoLabel_;
edm::EDGetTokenT<PEcalTBInfo> ecalTBInfo_;

};

Expand Down
22 changes: 7 additions & 15 deletions SimG4CMS/EcalTestBeam/interface/FakeTBHodoscopeRawInfoProducer.h
Expand Up @@ -10,7 +10,7 @@
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -24,32 +24,24 @@
#include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRawInfo.h"
#include "Geometry/EcalTestBeam/interface/EcalTBHodoscopeGeometry.h"

class FakeTBHodoscopeRawInfoProducer: public edm::EDProducer{


public:
class FakeTBHodoscopeRawInfoProducer: public edm::stream::EDProducer<>
{
public:

/// Constructor
FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet& ps);
explicit FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet& ps);

/// Destructor
virtual ~FakeTBHodoscopeRawInfoProducer();

/// Produce digis out of raw data
void produce(edm::Event & event, const edm::EventSetup& eventSetup);

// BeginJob
//void beginJob();
void produce(edm::Event & event, const edm::EventSetup& eventSetup) override;

// EndJob
//void endJob(void);


private:

EcalTBHodoscopeGeometry * theTBHodoGeom_;

std::string ecalTBInfoLabel_;
edm::EDGetTokenT<PEcalTBInfo> ecalTBInfo_;

};

Expand Down
Expand Up @@ -6,8 +6,7 @@
*
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -24,24 +23,25 @@
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"

class TBHodoActiveVolumeRawInfoProducer: public edm::EDProducer{
class TBHodoActiveVolumeRawInfoProducer: public edm::stream::EDProducer<>
{


public:
public:

/// Constructor
TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet& ps);
explicit TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet& ps);

/// Destructor
virtual ~TBHodoActiveVolumeRawInfoProducer();

/// Produce digis out of raw data
void produce(edm::Event & event, const edm::EventSetup& eventSetup);
void produce(edm::Event & event, const edm::EventSetup& eventSetup) override;

private:

double myThreshold;

edm::EDGetTokenT<edm::PCaloHitContainer> m_EcalToken;
EcalTBHodoscopeGeometry * theTBHodoGeom_;
};

Expand Down
Expand Up @@ -12,6 +12,10 @@

#include "DataFormats/Math/interface/Point3D.h"

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;
using namespace cms;

Expand All @@ -20,7 +24,7 @@ EcalTBMCInfoProducer::EcalTBMCInfoProducer(const edm::ParameterSet& ps) {
produces<PEcalTBInfo>();

edm::FileInPath CrystalMapFile = ps.getParameter<edm::FileInPath>("CrystalMapFile");
GenVtxLabel = ps.getUntrackedParameter<string>("moduleLabelVtx","source");
GenVtxToken = consumes<edm::HepMCProduct>(edm::InputTag("moduleLabelVtx","source"));
double fMinEta = ps.getParameter<double>("MinEta");
double fMaxEta = ps.getParameter<double>("MaxEta");
double fMinPhi = ps.getParameter<double>("MinPhi");
Expand Down Expand Up @@ -100,7 +104,7 @@ EcalTBMCInfoProducer::~EcalTBMCInfoProducer() {
delete theTestMap;
}

void EcalTBMCInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
void EcalTBMCInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
{
edm::Service<edm::RandomNumberGenerator> rng;
CLHEP::HepRandomEngine* engine = &rng->getEngine(event.streamID());
Expand All @@ -120,7 +124,7 @@ EcalTBMCInfoProducer::~EcalTBMCInfoProducer() {
partXhodo = partYhodo = 0.;

edm::Handle<edm::HepMCProduct> GenEvt;
event.getByLabel(GenVtxLabel,GenEvt);
event.getByToken(GenVtxToken,GenEvt);

const HepMC::GenEvent* Evt = GenEvt->GetEvent() ;
HepMC::GenEvent::vertex_const_iterator Vtx = Evt->vertices_begin();
Expand Down
Expand Up @@ -10,35 +10,32 @@
using namespace cms;
using namespace std;


FakeTBEventHeaderProducer::FakeTBEventHeaderProducer(const edm::ParameterSet& ps) {
ecalTBInfo_ = consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel","SimEcalTBG4Object"));
produces<EcalTBEventHeader>();
ecalTBInfoLabel_ = ps.getUntrackedParameter<string>("EcalTBInfoLabel","SimEcalTBG4Object");

}


FakeTBEventHeaderProducer::~FakeTBEventHeaderProducer()
{
}

void FakeTBEventHeaderProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
void FakeTBEventHeaderProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
{
auto_ptr<EcalTBEventHeader> product(new EcalTBEventHeader());

// get the vertex information from the event

const PEcalTBInfo* theEcalTBInfo=0;
const PEcalTBInfo* theEcalTBInfo = nullptr;
edm::Handle<PEcalTBInfo> EcalTBInfo;
event.getByLabel(ecalTBInfoLabel_,EcalTBInfo);
event.getByToken(ecalTBInfo_,EcalTBInfo);
if (EcalTBInfo.isValid()){
theEcalTBInfo = EcalTBInfo.product();
} else {
edm::LogError("FakeTBEventHeaderProducer") << "Error! can't get the product " << ecalTBInfoLabel_.c_str() ;
edm::LogError("FakeTBEventHeaderProducer") << "Error! can't get the product PEcalTBInfo";
}

if (!theEcalTBInfo)
return;
{ return; }

// 64 bits event ID in CMSSW converted to EcalTBEventHeader ID
int evtid = (int)event.id().event();
Expand Down
Expand Up @@ -9,32 +9,28 @@
using namespace cms;
using namespace std;


FakeTBHodoscopeRawInfoProducer::FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet& ps) {

ecalTBInfo_ = consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel","SimEcalTBG4Object"));
produces<EcalTBHodoscopeRawInfo>();

ecalTBInfoLabel_ = ps.getUntrackedParameter<string>("EcalTBInfoLabel","SimEcalTBG4Object");

theTBHodoGeom_ = new EcalTBHodoscopeGeometry();

}


FakeTBHodoscopeRawInfoProducer::~FakeTBHodoscopeRawInfoProducer() {

delete theTBHodoGeom_;

}

void FakeTBHodoscopeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
void FakeTBHodoscopeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
{
auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());

// get the vertex information from the event

edm::Handle<PEcalTBInfo> theEcalTBInfo;
event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo);
event.getByToken(ecalTBInfo_,theEcalTBInfo);

double partXhodo = theEcalTBInfo->evXbeam();
double partYhodo = theEcalTBInfo->evYbeam();
Expand Down
Expand Up @@ -13,6 +13,7 @@ using namespace std;

TBHodoActiveVolumeRawInfoProducer::TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet& ps) {

m_EcalToken = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","EcalTBH4BeamHits"));
produces<EcalTBHodoscopeRawInfo>();

theTBHodoGeom_ = new EcalTBHodoscopeGeometry();
Expand All @@ -24,14 +25,14 @@ TBHodoActiveVolumeRawInfoProducer::~TBHodoActiveVolumeRawInfoProducer() {
delete theTBHodoGeom_;
}

void TBHodoActiveVolumeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
void TBHodoActiveVolumeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
{
auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());

// caloHit container
edm::Handle<edm::PCaloHitContainer> pCaloHit;
const edm::PCaloHitContainer* caloHits =0;
event.getByLabel( "g4SimHits", "EcalTBH4BeamHits", pCaloHit);
const edm::PCaloHitContainer* caloHits = nullptr;
event.getByToken(m_EcalToken, pCaloHit);
if (pCaloHit.isValid()){
caloHits = pCaloHit.product();
LogDebug("EcalTBHodo") << "total # caloHits: " << caloHits->size() ;
Expand All @@ -40,48 +41,43 @@ TBHodoActiveVolumeRawInfoProducer::~TBHodoActiveVolumeRawInfoProducer() {
}
if (!caloHits){ return; }


// detid - energy_sum map
std::map<unsigned int, double> energyMap;

int myCount = 0;
for(edm::PCaloHitContainer::const_iterator itch = caloHits->begin(); itch != caloHits->end(); ++itch) {

double thisHitEne = itch->energy();
for(auto&& aHit : *caloHits) {
double thisHitEne = aHit.energy();

std::map<unsigned int,double>::iterator itmap = energyMap.find(itch->id());
std::map<unsigned int,double>::iterator itmap = energyMap.find(aHit.id());
if ( itmap == energyMap.end() )
energyMap.insert(pair<unsigned int, double>( itch->id(), thisHitEne));
energyMap.insert(pair<unsigned int, double>( aHit.id(), thisHitEne));
else{
(*itmap).second+=thisHitEne;
(*itmap).second += thisHitEne;
}

myCount++;
}


// planes and fibers
int nPlanes=theTBHodoGeom_->getNPlanes();
int nFibers=theTBHodoGeom_->getNFibres();
product->setPlanes(nPlanes);

bool firedChannels[4][64];
for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane)
for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
for (int iFiber = 0; iFiber < nFibers ; ++iFiber) {
firedChannels[iPlane][iFiber] = 0.;

for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();itmap++)
}
}
for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();++itmap) {
if ( (*itmap).second > myThreshold ){
HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = 1;
}

}
for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
EcalTBHodoscopePlaneRawHits planeHit(nFibers);

for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
for (int iFiber = 0; iFiber < nFibers ; ++iFiber) {
planeHit.setHit(iFiber,firedChannels[iPlane][iFiber]);

}
product->setPlane((unsigned int)iPlane, planeHit);
}

Expand Down

0 comments on commit db25ba1

Please sign in to comment.