| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

CalibParamAlg.cc

Go to the documentation of this file.
00001 #include "CalibParamAlg.h"
00002 
00003 #include "Event/ReadoutHeader.h"
00004 #include "Event/Readout.h"
00005 #include "Event/ReadoutPmtCrate.h"
00006 #include "Event/ReadoutRpcCrate.h"
00007 
00008 #include "CalibParam/IPmtCalibParamTool.h"
00009 #include "CalibParam/IRpcCalibParamTool.h"
00010 
00011 #include "CLHEP/Units/SystemOfUnits.h"
00012 
00013 using namespace DayaBay;
00014 
00015 CalibParamAlg::CalibParamAlg(const std::string& name, ISvcLocator* pSvcLocator)
00016     : GaudiAlgorithm(name,pSvcLocator)
00017     , m_pmtTools(0)
00018     , m_rpcTools(0)
00019 {
00020     declareProperty("ReadoutLocation",
00021                     m_readoutLocation=DayaBay::ReadoutHeaderLocation::Default,
00022                     "Location in the TES where the input ReadoutHeader is to be found.");
00023     declareProperty("PmtTools",m_pmtToolNames,
00024                     "Names of the PMT calibration tools");
00025     declareProperty("RpcTools",m_rpcToolNames,
00026                     "Names of the RPC calibration tools");
00027     declareProperty("UseFloatFeePedes",m_useFloatFeePedes=false,
00028                     "Use FloatFeePedes or not? In case of false, it will use CalibSvc.");
00029     declareProperty("FloatingFeePedestalSvcName",m_floatFeePedesSvcName="FloatingFeePedestalSvc",
00030                     "Name of service to access floating FEE channel baselines");
00031 }
00032 
00033 CalibParamAlg::~CalibParamAlg()
00034 {
00035 }
00036 
00037 StatusCode CalibParamAlg::initialize()
00038 {
00039   StatusCode sc = this->GaudiAlgorithm::initialize();
00040   if( sc != StatusCode::SUCCESS ) return sc;
00041 
00042   {  
00043     // Get PMT Calibration tools
00044     std::vector<std::string>::iterator toolIter, toolEnd=m_pmtToolNames.end();
00045     for(toolIter=m_pmtToolNames.begin(); toolIter != toolEnd; toolIter++){
00046       std::string toolName = *toolIter;
00047       IPmtCalibParamTool* calibTool = 0;
00048       try {
00049         calibTool = tool<IPmtCalibParamTool>(toolName);
00050       }
00051       catch(const GaudiException& exg) {
00052         fatal() << "Failed to get pmt calib tool: \"" << toolName << "\"" 
00053                 << endreq;
00054         return StatusCode::FAILURE;
00055       }
00056       m_pmtTools.push_back(calibTool);
00057       info () << "Added pmt calib tool " << toolName << endreq;
00058     }
00059   }
00060 
00061   {
00062     // Get RPC Calibration tools
00063     std::vector<std::string>::iterator toolIter, toolEnd=m_rpcToolNames.end();
00064     for(toolIter=m_rpcToolNames.begin(); toolIter != toolEnd; toolIter++){
00065       std::string toolName = *toolIter;
00066       IRpcCalibParamTool* calibTool = 0;
00067       try {
00068         calibTool = tool<IRpcCalibParamTool>(toolName);
00069       }
00070       catch(const GaudiException& exg) {
00071         fatal() << "Failed to get rpc calib tool: \"" << toolName << "\"" 
00072                 << endreq;
00073         return StatusCode::FAILURE;
00074       }
00075       m_rpcTools.push_back(calibTool);
00076       info () << "Added rpc calib tool " << toolName << endreq;
00077     }
00078   }
00079 
00080   if(m_useFloatFeePedes){
00081     // Get floating fee pedestal service
00082     m_floatFeePedesSvc = svc<IFloatingFeePedestalSvc>(m_floatFeePedesSvcName,true);
00083     if(!m_floatFeePedesSvc){
00084       error() << "Failed to access FloatingFeePedestalSvc: " << m_floatFeePedesSvcName << endreq;
00085       return StatusCode::FAILURE;
00086     }
00087   }
00088 
00089   return StatusCode::SUCCESS;
00090 }
00091 
00092 StatusCode CalibParamAlg::execute()
00093 {
00094   debug() << "calling execute()" << endreq; 
00095   // Get input header
00096   DayaBay::ReadoutHeader* readoutHeader = 
00097     get<DayaBay::ReadoutHeader>(m_readoutLocation);
00098 
00099   if(m_useFloatFeePedes){
00100     // Drop a readoutHeader for pedestal calculation
00101     StatusCode sc = m_floatFeePedesSvc->cumulate( readoutHeader );
00102     if( sc.isFailure() ) {
00103       return sc;
00104     }
00105   }
00106 
00107   TimeStamp trigTime = readoutHeader->timeStamp();
00108   static bool first=true;
00109   if(first) {
00110     m_beginTime = trigTime;
00111     first = false;
00112   }
00113   m_endTime = trigTime;
00114   
00115   DayaBay::Detector det(readoutHeader->context().GetSite(),
00116                         readoutHeader->context().GetDetId());
00117   debug() << "Got readout from " << det.detName() <<" id= "
00118          << det.siteDetPackedData() <<endreq;
00119   
00120   if(det.isAD() || det.isWaterShield()){
00121     // Loop over each PMT calibration tool
00122     std::vector<IPmtCalibParamTool*>::iterator toolIter, 
00123       toolEnd=m_pmtTools.end();
00124     for(toolIter=m_pmtTools.begin(); toolIter != toolEnd; toolIter++){
00125       IPmtCalibParamTool* calibTool = *toolIter;
00126       StatusCode sc = calibTool->process(*readoutHeader);
00127       if( sc != StatusCode::SUCCESS ) return sc;
00128     }
00129     
00130   }else if(det.detectorId() == DetectorId::kRPC){
00131     // Process RPC readout
00132     debug() << "Processing RPC readout" <<endreq;
00133     // Loop over each RPC calibration tool
00134     std::vector<IRpcCalibParamTool*>::iterator toolIter, 
00135       toolEnd=m_rpcTools.end();
00136     for(toolIter=m_rpcTools.begin(); toolIter != toolEnd; toolIter++){
00137       IRpcCalibParamTool* calibTool = *toolIter;
00138       StatusCode sc = calibTool->process(*readoutHeader);
00139       if( sc != StatusCode::SUCCESS ) return sc;
00140     }
00141     
00142   }else{
00143     error() << "Unknown detector " << det << endreq; 
00144     info() << "I am ignoring for now! " << endreq;//tmp
00145     //return StatusCode::FAILURE;//tmp !! quick fix by jpochoa, temporary! See track ticket #737
00146     return StatusCode::SUCCESS;//tmp
00147   }
00148   
00149   return StatusCode::SUCCESS;
00150 }
00151 
00152 StatusCode CalibParamAlg::finalize()
00153 {
00154   // Run calibration calculations for each tool
00155   {
00156     // Loop over each PMT calibration tool, calling calibrate()
00157     std::vector<IPmtCalibParamTool*>::iterator toolIter, 
00158       toolEnd=m_pmtTools.end();
00159     for(toolIter=m_pmtTools.begin(); toolIter != toolEnd; toolIter++){
00160       IPmtCalibParamTool* calibTool = *toolIter;
00161       StatusCode sc = calibTool->calibrate();
00162       if( sc != StatusCode::SUCCESS ) return sc;
00163     }
00164   }
00165   
00166   {
00167     // Loop over each RPC calibration tool, calling calibrate()
00168     std::vector<IRpcCalibParamTool*>::iterator toolIter, 
00169       toolEnd=m_rpcTools.end();
00170     for(toolIter=m_rpcTools.begin(); toolIter != toolEnd; toolIter++){
00171       IRpcCalibParamTool* calibTool = *toolIter;
00172       StatusCode sc = calibTool->calibrate();
00173       if( sc != StatusCode::SUCCESS ) return sc;
00174     }
00175   }
00176 
00177   info()<<"First trigger time: "<<m_beginTime.GetSec()<<" sec "<<m_beginTime.GetNanoSec()<<" nanoSec"<<endreq;
00178   info()<<"Last trigger time:  "<<m_endTime.GetSec()<<" sec "<<m_endTime.GetNanoSec()<<" nanoSec"<<endreq;
00179 
00180   return this->GaudiAlgorithm::finalize();
00181 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:29:39 2011 for CalibParam by doxygen 1.4.7