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  * $Id: TBHodoActiveVolumeRawInfoProducer.cc,v 1.4 2008/03/07 11:55:36 fabiocos Exp $
5  *
6  */
7 
9 
10 #include <iostream>
11 
12 using namespace cms;
13 using namespace std;
14 
16 
17  produces<EcalTBHodoscopeRawInfo>();
18 
19  theTBHodoGeom_ = new EcalTBHodoscopeGeometry();
20 
21  myThreshold = 0.05E-3;
22 }
23 
25  delete theTBHodoGeom_;
26 }
27 
29 {
30  auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
31 
32  // caloHit container
34  const edm::PCaloHitContainer* caloHits =0;
35  event.getByLabel( "g4SimHits", "EcalTBH4BeamHits", 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 
45  // detid - energy_sum map
46  std::map<unsigned int, double> energyMap;
47 
48  int myCount = 0;
49  for(edm::PCaloHitContainer::const_iterator itch = caloHits->begin(); itch != caloHits->end(); ++itch) {
50 
51  double thisHitEne = itch->energy();
52 
53  std::map<unsigned int,double>::iterator itmap = energyMap.find(itch->id());
54  if ( itmap == energyMap.end() )
55  energyMap.insert(pair<unsigned int, double>( itch->id(), thisHitEne));
56  else{
57  (*itmap).second+=thisHitEne;
58  }
59 
60  myCount++;
61  }
62 
63 
64  // planes and fibers
65  int nPlanes=theTBHodoGeom_->getNPlanes();
66  int nFibers=theTBHodoGeom_->getNFibres();
67  product->setPlanes(nPlanes);
68 
69  bool firedChannels[4][64];
70  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane)
71  for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
72  firedChannels[iPlane][iFiber] = 0.;
73 
74  for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();itmap++)
75  if ( (*itmap).second > myThreshold ){
76  HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
77  firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = 1;
78  }
79 
80  for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
81  EcalTBHodoscopePlaneRawHits planeHit(nFibers);
82 
83  for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
84  planeHit.setHit(iFiber,firedChannels[iPlane][iFiber]);
85 
86  product->setPlane((unsigned int)iPlane, planeHit);
87  }
88 
89  LogDebug("EcalTBHodo") << (*product);
90 
91  event.put(product);
92 }
#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:76
int fibrId() const
T const * product() const
Definition: Handle.h:74
int planeId() const