Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "SimG4CMS/EcalTestBeam/interface/TBHodoActiveVolumeRawInfoProducer.h"
00009
00010 #include <iostream>
00011
00012 using namespace cms;
00013 using namespace std;
00014
00015 TBHodoActiveVolumeRawInfoProducer::TBHodoActiveVolumeRawInfoProducer(const edm::ParameterSet& ps) {
00016
00017 produces<EcalTBHodoscopeRawInfo>();
00018
00019 theTBHodoGeom_ = new EcalTBHodoscopeGeometry();
00020
00021 myThreshold = 0.05E-3;
00022 }
00023
00024 TBHodoActiveVolumeRawInfoProducer::~TBHodoActiveVolumeRawInfoProducer() {
00025 delete theTBHodoGeom_;
00026 }
00027
00028 void TBHodoActiveVolumeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
00029 {
00030 auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
00031
00032
00033 edm::Handle<edm::PCaloHitContainer> pCaloHit;
00034 const edm::PCaloHitContainer* caloHits =0;
00035 event.getByLabel( "g4SimHits", "EcalTBH4BeamHits", pCaloHit);
00036 if (pCaloHit.isValid()){
00037 caloHits = pCaloHit.product();
00038 LogDebug("EcalTBHodo") << "total # caloHits: " << caloHits->size() ;
00039 } else {
00040 edm::LogError("EcalTBHodo") << "Error! can't get the caloHitContainer " ;
00041 }
00042 if (!caloHits){ return; }
00043
00044
00045
00046 std::map<unsigned int, double> energyMap;
00047
00048 int myCount = 0;
00049 for(edm::PCaloHitContainer::const_iterator itch = caloHits->begin(); itch != caloHits->end(); ++itch) {
00050
00051 double thisHitEne = itch->energy();
00052
00053 std::map<unsigned int,double>::iterator itmap = energyMap.find(itch->id());
00054 if ( itmap == energyMap.end() )
00055 energyMap.insert(pair<unsigned int, double>( itch->id(), thisHitEne));
00056 else{
00057 (*itmap).second+=thisHitEne;
00058 }
00059
00060 myCount++;
00061 }
00062
00063
00064
00065 int nPlanes=theTBHodoGeom_->getNPlanes();
00066 int nFibers=theTBHodoGeom_->getNFibres();
00067 product->setPlanes(nPlanes);
00068
00069 bool firedChannels[4][64];
00070 for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane)
00071 for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
00072 firedChannels[iPlane][iFiber] = 0.;
00073
00074 for(std::map<unsigned int,double>::const_iterator itmap=energyMap.begin();itmap!=energyMap.end();itmap++)
00075 if ( (*itmap).second > myThreshold ){
00076 HodoscopeDetId myHodoDetId = HodoscopeDetId((*itmap).first);
00077 firedChannels[myHodoDetId.planeId()][myHodoDetId.fibrId()] = 1;
00078 }
00079
00080 for (int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) {
00081 EcalTBHodoscopePlaneRawHits planeHit(nFibers);
00082
00083 for (int iFiber = 0; iFiber < nFibers ; ++iFiber)
00084 planeHit.setHit(iFiber,firedChannels[iPlane][iFiber]);
00085
00086 product->setPlane((unsigned int)iPlane, planeHit);
00087 }
00088
00089 LogDebug("EcalTBHodo") << (*product);
00090
00091 event.put(product);
00092 }