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

In This Package:

FastQCtrTool.cc

Go to the documentation of this file.
00001 #include "FastQCtrTool.h"
00002 
00003 #include "Event/RecHeader.h"
00004 #include "Event/RecTrigger.h"
00005 
00006 #include "Event/CalibReadoutHeader.h"
00007 #include "Event/CalibReadoutPmtCrate.h"
00008 #include "Event/CalibReadoutPmtChannel.h"
00009 
00010 #include "CLHEP/Vector/ThreeVector.h"
00011 #include "DetHelpers/IPmtGeomInfoSvc.h"
00012 #include "DataSvc/ICableSvc.h"
00013 #include "Conventions/Detectors.h"
00014 #include "Conventions/Reconstruction.h"
00015 
00016 using namespace CLHEP;
00017 using namespace DayaBay;
00018 
00019 FastQCtrTool::FastQCtrTool(const std::string& type,
00020       const std::string& name,
00021       const IInterface* parent)
00022   :  GaudiTool(type, name, parent)
00023   ,  m_cableSvc(0)
00024   ,  m_pmtGeomSvc(0)
00025   ,  m_usedChannels()
00026 {
00027   declareInterface< IReconTool >(this);
00028   declareProperty("CableSvcName", m_cableSvcName = "StaticCableSvc",
00029     "Name of service to map between detector, hardware, and electronic IDs");
00030   declareProperty("PmtGeomSvcName", m_pmtGeomSvcName = "PmtGeomInfoSvc",
00031     "Name of Pmt Geometry Information Service");
00032 }
00033 
00034 FastQCtrTool::~FastQCtrTool() {}
00035 
00036 StatusCode FastQCtrTool::initialize()
00037 {
00038   // Get Cable Service
00039   m_cableSvc = svc<ICableSvc>(m_cableSvcName, true);
00040 
00041   // Get PmtGeomInfo Service
00042   m_pmtGeomSvc = svc<IPmtGeomInfoSvc>(m_pmtGeomSvcName, true);
00043 
00044   return StatusCode::SUCCESS;
00045 }
00046 
00047 
00048 StatusCode FastQCtrTool::finalize()
00049 {
00050   return StatusCode::SUCCESS;
00051 }
00052 
00053 StatusCode FastQCtrTool::reconstruct(const DayaBay::CalibReadout& calibReadout, 
00054                                      DayaBay::RecTrigger& recTrigger)
00055 {
00056   debug() << "running reconstruct() " << endreq;
00057 
00058   if(!calibReadout.detector().isAD()){
00059     debug() << "Ignore non-AD detector: " << calibReadout.detector().detName()
00060             << endreq;
00061     recTrigger.setEnergyStatus( ReconStatus::kNotProcessed);
00062     recTrigger.setPositionStatus( ReconStatus::kNotProcessed);
00063     return StatusCode::SUCCESS;
00064   }
00065 
00066   // Get CalibPmtCrate
00067   const DayaBay::CalibReadoutPmtCrate* calibCrate
00068     = dynamic_cast<const DayaBay::CalibReadoutPmtCrate*>(&calibReadout);
00069   
00070   // Check CalibPmtCrate
00071   if(calibCrate == NULL) {
00072     error() << "reconstruction():  no calib readouts." << endreq;
00073     recTrigger.setEnergyStatus( ReconStatus::kBadReadout);
00074     recTrigger.setPositionStatus( ReconStatus::kBadReadout);
00075     return StatusCode::FAILURE;
00076   }
00077   
00078   // Get CalibPmtChannelReadouts
00079   DayaBay::CalibReadoutPmtCrate::PmtChannelReadouts calib_chMap;
00080   calib_chMap = calibCrate->channelReadout();
00081   DayaBay::CalibReadoutPmtCrate::PmtChannelReadouts::const_iterator cpcrIter 
00082     = calib_chMap.begin();
00083 
00084   debug() << "successfully get PmtChannelReadouts " << endreq;
00085   
00086   //  Context, ServiceMode for this data
00087   int task = 0;
00088   ServiceMode svcMode(calibReadout.header()->context(), task);
00089 
00090   debug() << "successfully get service mode " << endreq;
00091 
00092   // determine FeeChannels that used for reconstruction
00093   setUsedChannels(calibCrate, &recTrigger);
00094 
00095   // Calculate the charge center, loop over all calibrated channels
00096   double sumQ = 0.0, Xc, Yc, Zc;
00097   
00098   for(; cpcrIter!=calib_chMap.end(); ++cpcrIter) {
00099 
00100     DayaBay::AdPmtSensor adPmtId(cpcrIter->pmtSensorId().fullPackedData());
00101     if(m_usedChannels[adPmtId]==false) continue;
00102 
00103     // Get charge on this PMT
00104     double charge = cpcrIter->maxCharge();
00105 
00106     // Get Pmt Position from its id
00107     unsigned int pmtid = adPmtId.fullPackedData();
00108     if(adPmtId.site() == Site::kSAB) {
00109        pmtid = DayaBay::AdPmtSensor(adPmtId.ring(),adPmtId.column(),Site::kDayaBay,adPmtId.detectorId()).fullPackedData();
00110     }
00111     const CLHEP::Hep3Vector pos = m_pmtGeomSvc->get(pmtid)->localPosition();
00112     
00113     Xc   +=  charge * pos.x();
00114     Yc   +=  charge * pos.y();
00115     Zc   +=  charge * pos.z();
00116     sumQ +=  charge;
00117   }
00118   if(sumQ!=0) { Xc /= sumQ; Yc /= sumQ; Zc /= sumQ;}
00119   double position_unit= CLHEP::millimeter;
00120   debug() << "Xc, Yc, Zc (mm): " << Xc/position_unit
00121          << ", " << Yc/position_unit << ", " << Zc/position_unit << endreq;
00122 
00123   CLHEP::HepLorentzVector Qcenter(Xc, Yc, Zc, 0);
00124   recTrigger.setEnergy(sumQ/100.);
00125   recTrigger.setPosition(Qcenter);
00126   
00127   return StatusCode::SUCCESS;
00128 }
00129 
00130 StatusCode FastQCtrTool::setUsedChannels(
00131                                const DayaBay::CalibReadoutPmtCrate* calibCrate,
00132                                DayaBay::RecTrigger* recTrigger)
00133 {
00134   m_usedChannels.clear();
00135   
00136   Context context = calibCrate->header()->context();
00137   int task = 0;
00138   ServiceMode svcMode(context, task);
00139 
00140   Site::Site_t site = calibCrate->detector().site();
00141   DetectorId::DetectorId_t  detid = calibCrate->detector().detectorId();
00142 
00143   // default is use all channels
00144   for(int local_id=0; local_id<192; local_id++) {
00145     int ring = local_id/24 + 1;
00146     int col  = local_id%24 + 1;
00147 
00148     AdPmtSensor adPmtId(ring, col, site, detid);
00149     m_usedChannels[adPmtId] = true;
00150     //FeeChannelId channelId = m_cableSvc->feeChannelId(adPmtId, svcMode);
00151     //m_usedChannels[channelId] = true;
00152   }
00153   // Other options, depending on CalibReadoutPmtCrate data
00154 
00155   //recTrigger->setUsedChannels(m_usedChannels);
00156 
00157   return StatusCode::SUCCESS;
00158 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:42:45 2011 for AdRec by doxygen 1.4.7