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  produces<EcalTBHodoscopeRawInfo>();
17 
18  theTBHodoGeom_ = new EcalTBHodoscopeGeometry();
19 
20  myThreshold = 0.05E-3;
21 }
22 
24  delete theTBHodoGeom_;
25 }
26 
28 {
29  auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
30 
31  // caloHit container
33  const edm::PCaloHitContainer* caloHits =0;
34  event.getByLabel( "g4SimHits", "EcalTBH4BeamHits", pCaloHit);
35  if (pCaloHit.isValid()){
36  caloHits = pCaloHit.product();
37  LogDebug("EcalTBHodo") << "total # caloHits: " << caloHits->size() ;
38  } else {
39  edm::LogError("EcalTBHodo") << "Error! can't get the caloHitContainer " ;
40  }
41  if (!caloHits){ return; }
42 
43 
44  // detid - energy_sum map
45  std::map<unsigned int, double> energyMap;
46 
47  int myCount = 0;
48  for(edm::PCaloHitContainer::const_iterator itch = caloHits->begin(); itch != caloHits->end(); ++itch) {
49 
50  double thisHitEne = itch->energy();
51 
52  std::map<unsigned int,double>::iterator itmap = energyMap.find(itch->id());
53  if ( itmap == energyMap.end() )
54  energyMap.insert(pair<unsigned int, double>( itch->id(), thisHitEne));
55  else{
56  (*itmap).second+=thisHitEne;
57  }
58 
59  myCount++;
60  }
61 
62 
63  // planes and fibers
64  int nPlanes=theTBHodoGeom_->getNPlanes();
65  int nFibers=theTBHodoGeom_->getNFibres();
66  product->setPlanes(nPlanes);
67 
68  bool firedChannels[4][64];
69  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane)
70  for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
71  firedChannels[iPlane][iFiber] = 0.;
72 
73  for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();itmap++)
74  if ( (*itmap).second > myThreshold ){
75  HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
76  firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = 1;
77  }
78 
79  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
80  EcalTBHodoscopePlaneRawHits planeHit(nFibers);
81 
82  for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
83  planeHit.setHit(iFiber,firedChannels[iPlane][iFiber]);
84 
85  product->setPlane((unsigned int)iPlane, planeHit);
86  }
87 
88  LogDebug("EcalTBHodo") << (*product);
89 
90  event.put(product);
91 }
#define LogDebug(id)
std::vector< PCaloHit > PCaloHitContainer
void setHit(unsigned int i, bool status)
TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet &ps)
Constructor.
void produce(edm::Event &event, const edm::EventSetup &eventSetup)
Produce digis out of raw data.
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