![]() |
![]() |
00001 /* 00002 * \file FakeTBHodoscopeRawInfoProducer.cc 00003 * 00004 * $Id: FakeTBHodoscopeRawInfoProducer.cc,v 1.3 2006/10/26 08:01:06 fabiocos Exp $ 00005 * 00006 */ 00007 00008 #include "SimG4CMS/EcalTestBeam/interface/FakeTBHodoscopeRawInfoProducer.h" 00009 00010 using namespace cms; 00011 using namespace std; 00012 00013 00014 FakeTBHodoscopeRawInfoProducer::FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet& ps) { 00015 00016 produces<EcalTBHodoscopeRawInfo>(); 00017 00018 ecalTBInfoLabel_ = ps.getUntrackedParameter<string>("EcalTBInfoLabel","SimEcalTBG4Object"); 00019 00020 theTBHodoGeom_ = new EcalTBHodoscopeGeometry(); 00021 00022 } 00023 00024 00025 FakeTBHodoscopeRawInfoProducer::~FakeTBHodoscopeRawInfoProducer() { 00026 00027 delete theTBHodoGeom_; 00028 00029 } 00030 00031 void FakeTBHodoscopeRawInfoProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup) 00032 { 00033 auto_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo()); 00034 00035 // get the vertex information from the event 00036 00037 edm::Handle<PEcalTBInfo> theEcalTBInfo; 00038 event.getByLabel(ecalTBInfoLabel_,theEcalTBInfo); 00039 00040 double partXhodo = theEcalTBInfo->evXbeam(); 00041 double partYhodo = theEcalTBInfo->evYbeam(); 00042 00043 LogDebug("EcalTBHodo") << "TB frame vertex (X,Y) for hodoscope simulation: \n" 00044 << "x = " << partXhodo << " y = " << partYhodo; 00045 00046 // for each hodoscope plane determine the fibre number corresponding 00047 // to the event vertex coordinates in the TB reference frame 00048 // plane 0/2 = x plane 1/3 = y 00049 00050 int nPlanes = (int)theTBHodoGeom_->getNPlanes(); 00051 product->setPlanes(nPlanes); 00052 00053 for ( int iPlane = 0 ; iPlane < nPlanes ; ++iPlane) { 00054 00055 float theCoord = (float)partXhodo; 00056 if (iPlane == 1 || iPlane == 3) theCoord = (float)partYhodo; 00057 00058 vector<int> firedChannels = theTBHodoGeom_->getFiredFibresInPlane(theCoord, iPlane); 00059 unsigned int nChannels = firedChannels.size(); 00060 00061 EcalTBHodoscopePlaneRawHits planeHit(nChannels); 00062 for ( unsigned int i = 0 ; i < nChannels ; ++i ) { 00063 planeHit.addHit(firedChannels[i]); 00064 } 00065 00066 product->setPlane((unsigned int)iPlane, planeHit); 00067 00068 } 00069 00070 LogDebug("EcalTBHodo") << (*product); 00071 00072 event.put(product); 00073 00074 }