Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

AcdDigiAlg.cpp

Go to the documentation of this file.
00001 #define GlastDigi_AcdDigiAlg_CPP 
00002 
00003 // Include files
00004 #include "AcdDigiAlg.h"
00005 
00007 #include "GaudiKernel/MsgStream.h"
00008 #include "GaudiKernel/AlgFactory.h"
00009 #include "GaudiKernel/IDataProviderSvc.h"
00010 #include "GaudiKernel/SmartDataPtr.h"
00011 
00013 #include "GlastEvent/TopLevel/EventModel.h"
00014 #include "GlastEvent/TopLevel/Event.h"
00015 #include "GaudiKernel/ObjectVector.h"
00016 
00018 #include "GlastEvent/TopLevel/IrfEvent.h"
00019 #include "GlastEvent/Irf/IrfAcdHit.h"
00020 #include "GlastEvent/Digi/AcdDigi.h"
00021 
00023 #include <algorithm>
00024 #include <math.h>
00025 
00027 #include "xml/IFile.h"
00028 
00030 static const AlgFactory<AcdDigiAlg>  Factory;
00031 const IAlgFactory& AcdDigiAlgFactory = Factory;
00032 
00033 //------------------------------------------------------------------------------
00036 AcdDigiAlg::AcdDigiAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00037 Algorithm(name, pSvcLocator) {
00038 
00040     declareProperty ("xmlFile", m_xmlFile);
00041 }
00042 
00043 
00044 //------------------------------------------------------------------------------
00049 StatusCode AcdDigiAlg::initialize() {
00050     
00051     MsgStream log(msgSvc(), name());
00052     log << MSG::INFO << "initialize" << endreq;
00053     
00054     // Use the Job options service to set the Algorithm's parameters
00056     setProperties();
00057     
00059     xml::IFile m_ifile(m_xmlFile.c_str());
00060     double lowThreshold = m_ifile.getDouble("acd", "lowThreshold");
00061     double vetoThreshold = m_ifile.getDouble("acd", "vetoThreshold");
00062     double highThreshold = m_ifile.getDouble("acd", "highThreshold");
00063     double adcChannelsPerMeV = m_ifile.getDouble("acd", "adcChannelsPerMeV");
00064 
00065     // Convert from MeV to GeV
00066     m_lowThresholdGeV = lowThreshold / 1000.f;
00067     m_vetoThresholdGeV = vetoThreshold / 1000.f;
00068     m_highThresholdGeV = highThreshold / 1000.f;
00069     m_adcChannelsPerGeV = adcChannelsPerMeV * 1000.0f;
00070 
00071     return StatusCode::SUCCESS;
00072 }
00073 
00074 
00075 //------------------------------------------------------------------------------
00081 StatusCode AcdDigiAlg::execute() {
00082     
00083     StatusCode  sc = StatusCode::SUCCESS;
00084     MsgStream   log( msgSvc(), name() );
00085     log << MSG::INFO << "execute" << endreq;
00086 
00095     SmartDataPtr<IrfAcdHitVector> IrfAcd(eventSvc(),"/Event/Irf/IrfAcdHits");
00096 
00097     if (IrfAcd == 0) {
00098         log << MSG::INFO << "no acd data is available" << endreq;
00099         return sc;
00100     }
00101 
00104     
00105     AcdDigiVector *DigiAcd = new AcdDigiVector;
00107     for (ObjectVector<IrfAcdHit>::const_iterator it = IrfAcd->begin(); it != IrfAcd->end(); it++) {
00108         
00109         bool overLow = false;
00110         bool overVeto = false;
00111         bool overHigh = false;
00112 
00113         double energyDeposited = (*it)->energy();  // GeV
00114 
00116         if (energyDeposited < m_lowThresholdGeV) continue;
00117         overLow = true;
00118         if (energyDeposited > m_vetoThresholdGeV) overVeto = true;
00119         if (energyDeposited > m_highThresholdGeV) overHigh = true;
00120         
00122         int pha = static_cast<int>(std::min((float)floor(energyDeposited * m_adcChannelsPerGeV), 4095.0f)) ;
00123 
00125         DigiAcd->push_back(new AcdDigi(idents::AcdId((*it)->id()), pha, overVeto, overLow, overHigh) );
00126     }
00127 
00130     sc = eventSvc()->registerObject("/Event/Digi/AcdDigis", DigiAcd);
00131 
00132     if (sc != StatusCode::SUCCESS) log << MSG::INFO << "Failed to register ACD digi vector" << endreq;
00133 
00137 
00138     return sc;
00139 }
00140 
00141 
00142 //------------------------------------------------------------------------------
00143 /*
00144 Finalize is called once at the end of event processing.
00145 Any cleanup to occur - will occur here.
00146 */
00147 StatusCode AcdDigiAlg::finalize() {
00148     
00149     MsgStream log(msgSvc(), name());
00150     log << MSG::INFO << "finalize" << endreq;
00151     
00152     return StatusCode::SUCCESS;
00153 }
00154 
00155 
00156 
00157 
00158 
00159 

Generated at Wed Nov 21 12:22:36 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000