/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ChargePoint Class Reference

#include <ChargePoint.h>

Inheritance diagram for ChargePoint:
Inheritance graph
[legend]
Collaboration diagram for ChargePoint:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ChargePoint (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ChargePoint ()
virtual StatusCode reconstruct (const DayaBay::CalibReadout &readout, DayaBay::RecTrigger &recTrigger)
virtual StatusCode initialize ()
virtual StatusCode finalize ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

void PmtIdPostion (Context context, int index)
void SelectFiredPmt (const CalibReadout &m_calibReadout, Site::Site_t m_site, vector< int > &m_id, vector< double > &m_charge)
void Sort_ChargeIndex (vector< int > &m_id, vector< double > &m_charge)
void PoolPoint (vector< int > m_id, vector< double > m_charge, Site::Site_t m_site, DetectorId::DetectorId_t m_det)

Private Attributes

map< int, int > db_id_convertor
map< int, int > la_id_convertor
map< int, int > far_id_convertor
float DbPmtX [288]
float DbPmtY [288]
float DbPmtZ [288]
float LaPmtX [288]
float LaPmtY [288]
float LaPmtZ [288]
float FarPmtX [384]
float FarPmtY [384]
float FarPmtZ [384]
double point_x
double point_y
double point_z

Detailed Description

Definition at line 33 of file ChargePoint.h.


Constructor & Destructor Documentation

ChargePoint::ChargePoint ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 35 of file ChargePoint.cc.

   : GaudiTool(type,name,parent)
{
   declareInterface< IReconTool >(this) ;  
}
ChargePoint::~ChargePoint ( ) [virtual]

Definition at line 43 of file ChargePoint.cc.

{}

Member Function Documentation

StatusCode ChargePoint::reconstruct ( const DayaBay::CalibReadout readout,
DayaBay::RecTrigger recTrigger 
) [virtual]

Implements IReconTool.

Definition at line 152 of file ChargePoint.cc.

{
   StatusCode sc = StatusCode::SUCCESS;
   //info()<< "----------------- execute -------------------" <<endreq;

   //   if(readout.detector().detectorId()==DetectorId::kRPC)
   //   {
      //RPC readout
      //info()<<"---------RPC readout-----------"<<endreq;
  //      return sc;
  //   }
  //   if(readout.detector().detectorId()<5)
  //   {
      //AD readout
      //info()<<"---------AD readout------------"<<endreq;
  //      return sc;
  //   }

   if(!readout.detector().isWaterShield())
   {
      debug()<<"-----not a Water Shield readout, ignoring and return -------"<<endreq;
      return sc;
   }
   //info()<<"============start============"<<endreq;

   // Water Pool
   vector<int> m_pmtId;
   vector<double> m_pmtCharge;
   Site::Site_t r_site;
   r_site = readout.detector().site();
   SelectFiredPmt(readout,r_site,m_pmtId,m_pmtCharge);
   if((int)m_pmtId.size()<5)
   {
      //some force trigger or cross triger,because the nHit is too small,
      //these events is not reconstructed.
      return sc;
   }
   Sort_ChargeIndex(m_pmtId,m_pmtCharge);
   DetectorId::DetectorId_t r_det = readout.detector().detectorId();
   PoolPoint(m_pmtId,m_pmtCharge,r_site,r_det);
   
   CLHEP::HepLorentzVector m_position(point_x,point_y,point_z,0);
   
   recTrigger.setPosition( m_position );
   //info()<<"=============End ============="<<endreq;
   return sc;

}
StatusCode ChargePoint::initialize ( ) [virtual]

Definition at line 45 of file ChargePoint.cc.

{
   //Get PMT geometry service
   IPmtGeomInfoSvc* m_pmtGeomSvc = svc<IPmtGeomInfoSvc>("PmtGeomInfoSvc", true);
   if(!m_pmtGeomSvc )
   {
      error()<< "-------Failed to access PMT geometry svc: --------"<<endreq;
      return StatusCode::FAILURE;
   }

   // Get Cable Service
   ICableSvc* m_cableSvc = svc<ICableSvc>("CableSvc",true);
   if(!m_cableSvc)
   {
      error()<< "----------Failed to access cable svc: -----------"<<endreq;
      return StatusCode::FAILURE;
   }

   Context m_context(Site::kDayaBay,SimFlag::kData,TimeStamp(2012,3,16,0,0,0),DetectorId::kIWS);
   //Daybay : IWS PmtNumber 121, index from 0~120 so OWS start 121    
   PmtIdPostion(m_context,0);
   m_context.SetDetId(DetectorId::kOWS);
   PmtIdPostion(m_context,121);

   //LingAo 
   m_context.SetSite(Site::kLingAo);
   m_context.SetDetId(DetectorId::kIWS);
   PmtIdPostion(m_context,0);
   m_context.SetDetId(DetectorId::kOWS);
   PmtIdPostion(m_context,121);

   //Far: IWS PmtNumber 160, index from 0~159 so OWS start 160
   m_context.SetSite(Site::kFar);
   m_context.SetDetId(DetectorId::kIWS);
   PmtIdPostion(m_context,0);
   m_context.SetDetId(DetectorId::kOWS);
   PmtIdPostion(m_context,160);

   return StatusCode::SUCCESS;
}
StatusCode ChargePoint::finalize ( ) [virtual]

Definition at line 332 of file ChargePoint.cc.

{
   return StatusCode::SUCCESS;
}
void ChargePoint::PmtIdPostion ( Context  context,
int  index 
) [private]

Definition at line 86 of file ChargePoint.cc.

{
   IPmtGeomInfoSvc* pmtGeomSvc = svc<IPmtGeomInfoSvc>("PmtGeomInfoSvc", true);
   if(!pmtGeomSvc )
   {
      error()<< "-------Failed to access PMT geometry svc: --------"<<endreq;
   }

   ICableSvc* cableSvc = svc<ICableSvc>("CableSvc",true);
   if(!cableSvc)
   {
      error()<< "----------Failed to access cable svc: -----------"<<endreq;
   }

   ServiceMode svcMode(context, 0);
   const std::vector<DayaBay::PoolPmtSensor>& pmtList = cableSvc->poolPmtSensors(svcMode); 

   string searchDet="/dd/Structure/Pool/";
   if(context.GetSite()==Site::kFar) searchDet.append("far-ows");
   if(context.GetSite()==Site::kDayaBay)searchDet.append("db-ows");
   if(context.GetSite()==Site::kLingAo)searchDet.append("la-ows");
   IDetectorElement *m_de = getDet<IDetectorElement>(searchDet);

   Gaudi::XYZPoint  local;
   CLHEP::Hep3Vector global;
   //if(context.GetSite()==Site::kDayaBay)info()<<"  DayaBay : "<<(int)pmtList.size()<<endreq;
   //if(context.GetSite()==Site::kFar)info()<<" Far : "<<(int)pmtList.size()<<endreq;
   //if(context.GetSite()==Site::kLingAo)info()<<" LingAo : "<<(int)pmtList.size()<<endreq;

   for(int i=0;i<(int)pmtList.size();i++)
   {
      int id_nuwa = pmtList[i].fullPackedData();
      global = pmtGeomSvc->get(id_nuwa)->globalPosition();
      Gaudi::XYZPoint global_point(global.x(), global.y(), global.z());
      local  = m_de->geometry()->toLocal(global_point);

      if(context.GetSite()==Site::kDayaBay)
      {
         db_id_convertor[id_nuwa] = i+index;
         DbPmtX[i+index]=local.x()/meter;
         DbPmtY[i+index]=local.y()/meter;
         DbPmtZ[i+index]=local.z()/meter;
         //info()<<i+index<<"   "<<id_nuwa<<"   "<<DbPmtX[i+index]<<"   "<<DbPmtY[i+index]<<"   "<<DbPmtZ[i+index]<<endreq;
      }

      if(context.GetSite()==Site::kLingAo)
      {
         la_id_convertor[id_nuwa] = i+index;
         LaPmtX[i+index]=local.x()/meter;
         LaPmtY[i+index]=local.y()/meter;
         LaPmtZ[i+index]=local.z()/meter;
         //info()<<i+index<<"   "<<id_nuwa<<"   "<<LaPmtX[i+index]<<"   "<<LaPmtY[i+index]<<"   "<<LaPmtZ[i+index]<<endreq;
      }

      if(context.GetSite()==Site::kFar)
      {
         far_id_convertor[id_nuwa] = i+index;
         FarPmtX[i+index]=local.x()/meter;
         FarPmtY[i+index]=local.y()/meter;
         FarPmtZ[i+index]=local.z()/meter;
         //info()<<i+index<<"   "<<id_nuwa<<"   "<<FarPmtX[i+index]<<"  "<<FarPmtY[i+index]<<"  "<<FarPmtZ[i+index]<<endreq;
      }
   }

}
void ChargePoint::SelectFiredPmt ( const CalibReadout m_calibReadout,
Site::Site_t  m_site,
vector< int > &  m_id,
vector< double > &  m_charge 
) [private]

Definition at line 202 of file ChargePoint.cc.

{
   map<int,int> id_convertor;
   if(m_site==Site::kFar)id_convertor = far_id_convertor;
   if(m_site==Site::kLingAo)id_convertor = la_id_convertor;
   if(m_site==Site::kDayaBay)id_convertor = db_id_convertor;

   const CalibReadoutPmtCrate& pmtReadout = dynamic_cast<const CalibReadoutPmtCrate&>(m_calibReadout);
   const vector<CalibReadoutPmtChannel>& pmtchannels = pmtReadout.channelReadout();
   for(int i=0;i<(int)pmtchannels.size();i++)
   {
      int pmt_id = pmtchannels[i].pmtSensorId().fullPackedData();
      double pmt_charge = pmtchannels[i].maxCharge();
      m_id.push_back(id_convertor[pmt_id]);
      m_charge.push_back(pmt_charge);
      //info()<<" full Data : "<<pmt_id<<"      "<<id_convertor[pmt_id]<<"      "<<pmt_charge<<"        "<<id_convertor.size()<<endreq;
   }
   //info()<<" charge size :: "<<m_charge.size()<<endreq;

}
void ChargePoint::Sort_ChargeIndex ( vector< int > &  m_id,
vector< double > &  m_charge 
) [private]

Definition at line 223 of file ChargePoint.cc.

{
//   for(int i=0;i<(int)m_charge.size()-1;i++)
   //{
   //cout<<m_id[i]<<" before charge : "<<m_charge[i]<<endl;
   //}

   //Sort from largest to smallest
   double tpe;
   int tid;
   int Num = (int)m_charge.size()-1;

   for(int j=0;j<Num;j++)
   {
      for(int i=0;i<Num-j;i++)
      {
         if(m_charge[i]<m_charge[i+1])
         {
            tpe = m_charge[i];
            tid = m_id[i];

            m_charge[i] = m_charge[i+1];
            m_id[i] = m_id[i+1];

            m_charge[i+1] = tpe;
            m_id[i+1] = tid;
         }
      }
   }
   //check
   for(int i=0;i<(int)m_charge.size()-1;i++)
   {
      //cout<<m_id[i]<<" charge : "<<m_charge[i]<<endl;
      assert(m_charge[i]>=m_charge[i+1]);
   }

}
void ChargePoint::PoolPoint ( vector< int >  m_id,
vector< double >  m_charge,
Site::Site_t  m_site,
DetectorId::DetectorId_t  m_det 
) [private]

Definition at line 261 of file ChargePoint.cc.

{
   //water pool reconstruction results (point)

   double m_ratio;
   double Nhit = (double)m_id.size();
   if(m_site==Site::kFar&&m_det==DetectorId::kOWS)
   {
      m_ratio = FAROWSRATIO;
   }
   if(m_site==Site::kFar&&m_det==DetectorId::kIWS)
   {
      m_ratio = FARIWSRATIO;
   }
   if(m_site!=Site::kFar&&m_det==DetectorId::kIWS)
   {
      m_ratio=NEARIWSRATIO;
   }
   if(m_site!=Site::kFar&&m_det==DetectorId::kOWS)
   {
      m_ratio=NEAROWSRATIO;
   }
   double MaxPeN = Nhit*m_ratio;
   if(MaxPeN<2.)MaxPeN = 4.;

   point_x = 0.;
   point_y = 0.;
   point_z = 0.;
   double sum_charge = 0.;

   //info()<<" ::::::::::::: "<<MaxPeN<<"......"<<(int)m_charge.size()<<endreq;
   if(m_site==Site::kFar)
   {
      for(int i=0;i<MaxPeN;i++)
      {
         sum_charge+= pow(m_charge[i],Q_ALPHA);
         point_x+=pow(m_charge[i],Q_ALPHA)*FarPmtX[m_id[i]];
         point_y+=pow(m_charge[i],Q_ALPHA)*FarPmtY[m_id[i]];
         point_z+=pow(m_charge[i],Q_ALPHA)*FarPmtZ[m_id[i]];
      }
   }

   if(m_site==Site::kDayaBay)
   {
      for(int i=0;i<MaxPeN;i++)
      {
         sum_charge+= pow(m_charge[i],Q_ALPHA);
         point_x+=pow(m_charge[i],Q_ALPHA)*DbPmtX[m_id[i]];
         point_y+=pow(m_charge[i],Q_ALPHA)*DbPmtY[m_id[i]];
         point_z+=pow(m_charge[i],Q_ALPHA)*DbPmtZ[m_id[i]];
      }
   }

   if(m_site==Site::kLingAo)
   {
      for(int i=0;i<MaxPeN;i++)
      {
         sum_charge+= pow(m_charge[i],Q_ALPHA);
         point_x+=pow(m_charge[i],Q_ALPHA)*LaPmtX[m_id[i]];
         point_y+=pow(m_charge[i],Q_ALPHA)*LaPmtY[m_id[i]];
         point_z+=pow(m_charge[i],Q_ALPHA)*LaPmtZ[m_id[i]];
      }
   }

   point_x/=sum_charge;
   point_y/=sum_charge;
   point_z/=sum_charge;

   //info()<<"PoolSimple : "<<m_det<<"  size : "<<(int)m_charge.size()<<"  x: "<<point_x<<"  y: "<<point_y<<" z : "<<point_z<<endreq;
}

Member Data Documentation

map<int,int> ChargePoint::db_id_convertor [private]

Definition at line 48 of file ChargePoint.h.

map<int,int> ChargePoint::la_id_convertor [private]

Definition at line 49 of file ChargePoint.h.

map<int,int> ChargePoint::far_id_convertor [private]

Definition at line 50 of file ChargePoint.h.

float ChargePoint::DbPmtX[288] [private]

Definition at line 52 of file ChargePoint.h.

float ChargePoint::DbPmtY[288] [private]

Definition at line 53 of file ChargePoint.h.

float ChargePoint::DbPmtZ[288] [private]

Definition at line 54 of file ChargePoint.h.

float ChargePoint::LaPmtX[288] [private]

Definition at line 56 of file ChargePoint.h.

float ChargePoint::LaPmtY[288] [private]

Definition at line 57 of file ChargePoint.h.

float ChargePoint::LaPmtZ[288] [private]

Definition at line 58 of file ChargePoint.h.

float ChargePoint::FarPmtX[384] [private]

Definition at line 60 of file ChargePoint.h.

float ChargePoint::FarPmtY[384] [private]

Definition at line 61 of file ChargePoint.h.

float ChargePoint::FarPmtZ[384] [private]

Definition at line 62 of file ChargePoint.h.

double ChargePoint::point_x [private]

Definition at line 69 of file ChargePoint.h.

double ChargePoint::point_y [private]

Definition at line 70 of file ChargePoint.h.

double ChargePoint::point_z [private]

Definition at line 71 of file ChargePoint.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:12:54 for PoolSimple by doxygen 1.7.4