00001 #include "EsIdealPulseTool.h"
00002
00003 #include "Event/SimHit.h"
00004 #include "Event/ElecPulse.h"
00005 #include "Event/ElecPmtPulse.h"
00006 #include "Event/ElecRpcPulse.h"
00007 #include "Event/SimTrackReference.h"
00008 #include "Event/SimTrack.h"
00009
00010 #include "Conventions/PulseType.h"
00011
00012 EsIdealPulseTool::EsIdealPulseTool(const std::string& type,
00013 const std::string& name,
00014 const IInterface* parent)
00015 : GaudiTool(type,name,parent)
00016 , m_cableSvc(0)
00017 {
00018 declareInterface< IEsPulseTool >(this) ;
00019 declareProperty("CableSvcName",m_cableSvcName="StaticCableSvc",
00020 "Name of service to map between detector, hardware, and electronic IDs");
00021 }
00022
00023 EsIdealPulseTool::~EsIdealPulseTool(){}
00024
00025 StatusCode EsIdealPulseTool::initialize()
00026 {
00027
00028 m_cableSvc = svc<ICableSvc>(m_cableSvcName,true);
00029
00030 return StatusCode::SUCCESS;
00031 }
00032
00033 StatusCode EsIdealPulseTool::finalize()
00034 {
00035 return StatusCode::SUCCESS;
00036 }
00037
00038 StatusCode EsIdealPulseTool::generatePulses(DayaBay::SimHitCollection* hits,
00039 DayaBay::ElecPulseCollection* pulses)
00040 {
00041 debug() << "running generatePulses()" << endreq;
00042
00043 const DayaBay::SimHitCollection::hit_container& htcon = hits->collection();
00044 DayaBay::SimHitCollection::hit_container::const_iterator hcIter, done = htcon.end();
00045 DayaBay::ElecPulseCollection::PulseContainer pulsecon;
00046 pulsecon.clear();
00047
00048
00049 Context context(pulses->detector().site(), SimFlag::kMC,
00050 pulses->header()->header()->timeStamp(),
00051 pulses->detector().detectorId());
00052 int task = 0;
00053 ServiceMode svcMode(context, task);
00054
00055 for (hcIter=htcon.begin(); hcIter != done; ++hcIter) {
00056 DayaBay::DetectorSensor sensDetId((*hcIter)->sensDetId());
00057 if (sensDetId.isAD()) {
00058 DayaBay::AdPmtSensor pmtid((*hcIter)->sensDetId());
00059 if (pmtid.bogus()) {
00060 warning() << "generatePulses() got bogus PMT ID: " << pmtid << endreq;
00061 }
00062 }
00063 const DayaBay::ElecChannelId& elecChannelId = m_cableSvc->elecChannelId(
00064 sensDetId,
00065 svcMode);
00066 DayaBay::ElecPulse* simpulse = 0;
00067 if(sensDetId.detectorId() != DetectorId::kRPC){
00068 simpulse = new DayaBay::ElecPmtPulse();
00069 }else{
00070 simpulse = new DayaBay::ElecRpcPulse();
00071 }
00072
00073
00074 TimeStamp vertexTime = (*hcIter)->hc()->header()->header()->timeStamp();
00075
00076 TimeStamp headerTime = pulses->header()->header()->timeStamp();
00077
00078 simpulse->setTime((vertexTime-headerTime)*1.e9 + (*hcIter)->hitTime());
00079
00080 simpulse->setAmplitude((*hcIter)->weight());
00081 simpulse->setAncestor((*hcIter));
00082 simpulse->setType(PulseType::kPmtHit);
00083 simpulse->setChannelId(elecChannelId);
00084
00085 pulsecon.push_back(simpulse);
00086 }
00087
00088 pulses->setPulses(pulsecon);
00089
00090 return StatusCode::SUCCESS;
00091 }