CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TBHodoActiveVolumeRawInfoProducer Class Reference
Inheritance diagram for TBHodoActiveVolumeRawInfoProducer:
edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &event, const edm::EventSetup &eventSetup) override
 Produce digis out of raw data. More...
 
 TBHodoActiveVolumeRawInfoProducer (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~TBHodoActiveVolumeRawInfoProducer () override=default
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

edm::EDGetTokenT< edm::PCaloHitContainerm_EcalToken
 
double myThreshold
 
std::unique_ptr< EcalTBHodoscopeGeometrytheTBHodoGeom_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 27 of file TBHodoActiveVolumeRawInfoProducer.cc.

Constructor & Destructor Documentation

◆ TBHodoActiveVolumeRawInfoProducer()

TBHodoActiveVolumeRawInfoProducer::TBHodoActiveVolumeRawInfoProducer ( const edm::ParameterSet ps)
explicit

Constructor.

Definition at line 48 of file TBHodoActiveVolumeRawInfoProducer.cc.

References theTBHodoGeom_.

49  : myThreshold(0.05E-3),
50  m_EcalToken(consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalTBH4BeamHits"))) {
51  produces<EcalTBHodoscopeRawInfo>();
52 
53  theTBHodoGeom_ = std::make_unique<EcalTBHodoscopeGeometry>();
54 }
std::unique_ptr< EcalTBHodoscopeGeometry > theTBHodoGeom_
edm::EDGetTokenT< edm::PCaloHitContainer > m_EcalToken

◆ ~TBHodoActiveVolumeRawInfoProducer()

TBHodoActiveVolumeRawInfoProducer::~TBHodoActiveVolumeRawInfoProducer ( )
overridedefault

Destructor.

Member Function Documentation

◆ produce()

void TBHodoActiveVolumeRawInfoProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Produce digis out of raw data.

Definition at line 56 of file TBHodoActiveVolumeRawInfoProducer.cc.

References HodoscopeDetId::fibrId(), edm::HandleBase::isValid(), LogDebug, m_EcalToken, eostools::move(), myThreshold, HodoscopeDetId::planeId(), edm::Handle< T >::product(), EcalTBHodoscopePlaneRawHits::setHit(), and theTBHodoGeom_.

56  {
57  std::unique_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
58 
59  // caloHit container
60  const edm::Handle<edm::PCaloHitContainer> &pCaloHit = event.getHandle(m_EcalToken);
61  const edm::PCaloHitContainer *caloHits = nullptr;
62  if (pCaloHit.isValid()) {
63  caloHits = pCaloHit.product();
64  LogDebug("EcalTBHodo") << "total # caloHits: " << caloHits->size();
65  } else {
66  edm::LogError("EcalTBHodo") << "Error! can't get the caloHitContainer ";
67  }
68  if (!caloHits) {
69  return;
70  }
71 
72  // detid - energy_sum map
73  std::map<unsigned int, double> energyMap;
74 
75  for (auto &&aHit : *caloHits) {
76  double thisHitEne = aHit.energy();
77 
78  std::map<unsigned int, double>::iterator itmap = energyMap.find(aHit.id());
79  if (itmap == energyMap.end())
80  energyMap.insert(pair<unsigned int, double>(aHit.id(), thisHitEne));
81  else {
82  (*itmap).second += thisHitEne;
83  }
84  }
85 
86  // planes and fibers
87  int nPlanes = theTBHodoGeom_->getNPlanes();
88  int nFibers = theTBHodoGeom_->getNFibres();
89  product->setPlanes(nPlanes);
90 
91  bool firedChannels[4][64];
92  for (int iPlane = 0; iPlane < nPlanes; ++iPlane) {
93  for (int iFiber = 0; iFiber < nFibers; ++iFiber) {
94  firedChannels[iPlane][iFiber] = 0.;
95  }
96  }
97  for (std::map<unsigned int, double>::const_iterator itmap = energyMap.begin(); itmap != energyMap.end(); ++itmap) {
98  if ((*itmap).second > myThreshold) {
99  HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
100  firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = true;
101  }
102  }
103  for (int iPlane = 0; iPlane < nPlanes; ++iPlane) {
104  EcalTBHodoscopePlaneRawHits planeHit(nFibers);
105 
106  for (int iFiber = 0; iFiber < nFibers; ++iFiber) {
107  planeHit.setHit(iFiber, firedChannels[iPlane][iFiber]);
108  }
109  product->setPlane((unsigned int)iPlane, planeHit);
110  }
111 
112  LogDebug("EcalTBHodo") << (*product);
113 
114  event.put(std::move(product));
115 }
std::vector< PCaloHit > PCaloHitContainer
T const * product() const
Definition: Handle.h:70
Log< level::Error, false > LogError
bool isValid() const
Definition: HandleBase.h:70
int fibrId() const
int planeId() const
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< EcalTBHodoscopeGeometry > theTBHodoGeom_
#define LogDebug(id)
edm::EDGetTokenT< edm::PCaloHitContainer > m_EcalToken

Member Data Documentation

◆ m_EcalToken

edm::EDGetTokenT<edm::PCaloHitContainer> TBHodoActiveVolumeRawInfoProducer::m_EcalToken
private

Definition at line 40 of file TBHodoActiveVolumeRawInfoProducer.cc.

Referenced by produce().

◆ myThreshold

double TBHodoActiveVolumeRawInfoProducer::myThreshold
private

Definition at line 39 of file TBHodoActiveVolumeRawInfoProducer.cc.

Referenced by produce().

◆ theTBHodoGeom_

std::unique_ptr<EcalTBHodoscopeGeometry> TBHodoActiveVolumeRawInfoProducer::theTBHodoGeom_
private