CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TBHodoActiveVolumeRawInfoProducer.cc
Go to the documentation of this file.
1 /*
2  * \file TBHodoActiveVolumeRawInfoProducer.cc
3  *
4  *
5  */
6 
8 
9 #include <iostream>
10 
11 using namespace cms;
12 using namespace std;
13 
15 
16  m_EcalToken = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","EcalTBH4BeamHits"));
17  produces<EcalTBHodoscopeRawInfo>();
18 
19  theTBHodoGeom_ = new EcalTBHodoscopeGeometry();
20 
21  myThreshold = 0.05E-3;
22 }
23 
25  delete theTBHodoGeom_;
26 }
27 
29 {
30  unique_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
31 
32  // caloHit container
34  const edm::PCaloHitContainer* caloHits = nullptr;
35  event.getByToken(m_EcalToken, pCaloHit);
36  if (pCaloHit.isValid()){
37  caloHits = pCaloHit.product();
38  LogDebug("EcalTBHodo") << "total # caloHits: " << caloHits->size() ;
39  } else {
40  edm::LogError("EcalTBHodo") << "Error! can't get the caloHitContainer " ;
41  }
42  if (!caloHits){ return; }
43 
44  // detid - energy_sum map
45  std::map<unsigned int, double> energyMap;
46 
47  for(auto&& aHit : *caloHits) {
48  double thisHitEne = aHit.energy();
49 
50  std::map<unsigned int,double>::iterator itmap = energyMap.find(aHit.id());
51  if ( itmap == energyMap.end() )
52  energyMap.insert(pair<unsigned int, double>( aHit.id(), thisHitEne));
53  else{
54  (*itmap).second += thisHitEne;
55  }
56  }
57 
58  // planes and fibers
59  int nPlanes=theTBHodoGeom_->getNPlanes();
60  int nFibers=theTBHodoGeom_->getNFibres();
61  product->setPlanes(nPlanes);
62 
63  bool firedChannels[4][64];
64  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
65  for (int iFiber = 0; iFiber < nFibers ; ++iFiber) {
66  firedChannels[iPlane][iFiber] = 0.;
67  }
68  }
69  for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();++itmap) {
70  if ( (*itmap).second > myThreshold ){
71  HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
72  firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = 1;
73  }
74  }
75  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
76  EcalTBHodoscopePlaneRawHits planeHit(nFibers);
77 
78  for (int iFiber = 0; iFiber < nFibers ; ++iFiber) {
79  planeHit.setHit(iFiber,firedChannels[iPlane][iFiber]);
80  }
81  product->setPlane((unsigned int)iPlane, planeHit);
82  }
83 
84  LogDebug("EcalTBHodo") << (*product);
85 
86  event.put(std::move(product));
87 }
#define LogDebug(id)
std::vector< PCaloHit > PCaloHitContainer
void setHit(unsigned int i, bool status)
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet &ps)
Constructor.
def move
Definition: eostools.py:510
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
int fibrId() const
T const * product() const
Definition: Handle.h:81
int planeId() const