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

In This Package:

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
MuonSimpleAlg Class Reference

#include <MuonSimpleAlg.h>

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

List of all members.

Classes

struct  PmtProp

Public Member Functions

 MuonSimpleAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~MuonSimpleAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
DayaBay::UserDataHeaderGetCurrentHeaderObject () const
virtual StatusCode sysInitialize ()
virtual StatusCode sysExecute ()
virtual StatusCode preExecute ()
virtual StatusCode postExecute ()
virtual StatusCode sysFinalize ()
IDataProviderSvc * arcSvc () const
void putTES (DataObject *obj, std::string location) const
TYPE * getTES (std::string location) const
TYPE * getAES (std::string location, int index) const
std::vector< DataObject * > getAEScollection (std::string location) const
int getExecNum ()
std::string Location () const

Protected Member Functions

DayaBay::UserDataHeaderMakeHeaderObject ()
void InitializeHeader (DayaBay::HeaderObject *header)
TYPE * MakeHeader ()
TYPE * MakeHeader (std::vector< const DayaBay::IHeader * > &inputHeaders)
TYPE * MakeHeader (const DayaBay::IHeader *referenceHeader)
void AppendInputHeader (const DayaBay::HeaderObject *header) const

Protected Attributes

DayaBay::HeaderObjectm_headerObject
bool m_pullMode
std::string m_location

Private Attributes

map< unsigned int, PmtPropm_PmtPropMap
int m_PmtNumber
map< unsigned int, int > m_PmtId
ICableSvcm_cableSvc
ICalibDataSvcm_calibDataSvc
ICoordSysSvcmCss
string m_site
IDetectorElement * m_de
float m_timeCutLow
float m_timeCutHigh

Detailed Description

Definition at line 31 of file MuonSimpleAlg.h.


Constructor & Destructor Documentation

MuonSimpleAlg::MuonSimpleAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 28 of file MuonSimpleAlg.cc.

  : DybAlgorithm<DayaBay::UserDataHeader>(name,pSvcLocator)
{
  declareProperty("Site",m_site="DayaBay","Site name (DayaBay/Far)");
  declareProperty("m_timeCutLow", m_timeCutLow=-1700., "Lower limit of the TDC cut to get rid of noise");
  declareProperty("m_timeCutHigh", m_timeCutHigh=-1400., "Higher limit of the TDC cut to get rid of noise");
}
MuonSimpleAlg::~MuonSimpleAlg ( ) [virtual]

Definition at line 36 of file MuonSimpleAlg.cc.

{}

Member Function Documentation

StatusCode MuonSimpleAlg::initialize ( ) [virtual]

Cable service

Definition at line 38 of file MuonSimpleAlg.cc.

{
  StatusCode sc = this->GaudiAlgorithm::initialize();
  if(sc.isFailure()) return sc;

  sc = service("StaticCableSvc",m_cableSvc);
  if( sc.isFailure() ) {
    error() << "Can't get StaticCableSvc" << endreq;
    return sc;
  }

  sc = service("StaticCalibDataSvc",m_calibDataSvc);
  if( sc.isFailure() ) {
    error() << "Can't get StaticCalibDataSvc" << endreq;
    return sc;
  }

  sc = service("CoordSysSvc",mCss);
  if(sc.isFailure()) {
    error()<<"Can't get CoordSysSvc"<<endreq;
    return sc;
  }

  // Make use of svc<>
  IMessageSvc* msg = svc<IMessageSvc>("MessageSvc");
  MsgStream log(msg, name());
  log << MSG::DEBUG << "intializing ......" << endreq;
  
  // Get PmtGeoSvc
  IPmtGeomInfoSvc* pmtGeoSvc;
  sc = service("PmtGeomInfoSvc",pmtGeoSvc);
  if(sc.isFailure()) {
    error()<<"Can't get PmtGeomInfoSvc"<<endreq;
    return sc;
  }
  
  //choose Site
  //Site :: Site_t sitestr = Site :: FromString("DayaBay");
  Site :: Site_t sitestr = Site :: FromString(m_site.c_str());
  //choose DetectorId
  DetectorId::DetectorId_t idetid = DetectorId :: FromString("IWS");
  DetectorId::DetectorId_t odetid = DetectorId :: FromString("OWS");
  //for the inward_facing or outward_facing
  bool inward_facing = true;
  bool outward_facing = false;
  CLHEP::Hep3Vector global;
  Gaudi::XYZPoint pos;

  string searchDet="/dd/Structure/Pool/";
  if(m_site=="Far")     searchDet.append("far-ows");
  if(m_site=="DayaBay") searchDet.append("db-ows");
  m_de = getDet<IDetectorElement>(searchDet);

  int PMTcount = 0;
  //IWS
  for(int iwall_number=1;iwall_number<10;++iwall_number){
    for(int iwall_spot=1;iwall_spot<33;++iwall_spot){
      PoolPmtSensor poolPmtId(iwall_number,iwall_spot,inward_facing,sitestr,idetid);
      unsigned int pmtid = poolPmtId.fullPackedData();
      bool p = pmtGeoSvc->get(pmtid); if(!p){break;}

      global = pmtGeoSvc->get(pmtid)->globalPosition();
      Gaudi::XYZPoint global_point(global.x(), global.y(), global.z());
      m_PmtPropMap[pmtid].Position = m_de->geometry()->toLocal(global_point);

      m_PmtId[pmtid] = PMTcount;
      PMTcount++;
    }
  }
  //Outer Pool OWS facing outward
  for(int iwall_number=1;iwall_number<9;++iwall_number){
    for(int iwall_spot=1;iwall_spot<17;++iwall_spot){
      PoolPmtSensor poolPmtId(iwall_number,iwall_spot,outward_facing,sitestr,odetid);
      unsigned int pmtid = poolPmtId.fullPackedData();
      bool p = pmtGeoSvc->get(pmtid); if(!p){break;}

      global = pmtGeoSvc->get(pmtid)->globalPosition();
      Gaudi::XYZPoint global_point(global.x(), global.y(), global.z());
      m_PmtPropMap[pmtid].Position = m_de->geometry()->toLocal(global_point);

      m_PmtId[pmtid] = PMTcount;
      PMTcount++;
    }      
  }
  //Outer Pool OWS facing inward
  for(int iwall_number=1;iwall_number<10;++iwall_number){
    for(int iwall_spot=1;iwall_spot<33;++iwall_spot){
      PoolPmtSensor poolPmtId(iwall_number,iwall_spot,inward_facing,sitestr,odetid);
      unsigned int pmtid = poolPmtId.fullPackedData();
      bool p = pmtGeoSvc->get(pmtid); if(!p){break;}

      global = pmtGeoSvc->get(pmtid)->globalPosition();
      Gaudi::XYZPoint global_point(global.x(), global.y(), global.z());
      m_PmtPropMap[pmtid].Position = m_de->geometry()->toLocal(global_point);

      m_PmtId[pmtid] = PMTcount;
      PMTcount++;
    }
  }

  return StatusCode::SUCCESS;
}
StatusCode MuonSimpleAlg::execute ( ) [virtual]

Loop over channel data

Definition at line 147 of file MuonSimpleAlg.cc.

{
  DayaBay::HeaderObject *muonTag = 0;

  if (exist<DayaBay::HeaderObject>(evtSvc(), "/Event/Tag/Muon/MuonAll")) {
    muonTag = get<DayaBay::HeaderObject>("/Event/Tag/Muon/MuonAll");
    //    calibHdrs = muonTag->findHeaders("/Event/CalibReadout/CalibReadoutHeader");
    std::vector<const DayaBay::IHeader*> calibHdrs = muonTag->findHeaders(CalibReadoutHeader::classID());

    //info() << "Calib header size:" << calibHdrs.size() << endreq;

    Gaudi::XYZPoint p1(0,0,0), p2(0,0,0);
    Gaudi::XYZVector vect;
    int ntrigger = 0;
    vector<const DayaBay::IHeader*>::iterator it;
    for(it=calibHdrs.begin(); it!=calibHdrs.end(); it++){
      const CalibReadoutHeader* calibHeader = dynamic_cast<const CalibReadoutHeader*>(*it);
      
      const CalibReadout* calibReadout = calibHeader->calibReadout();
      if(!calibReadout) {
        info() << "No CalibReadout retrieved this cycle." << endreq;
        continue;
      } 
      if(!calibReadout->detector().isWaterShield()) continue;

      ntrigger++;
      //reset values
      map<unsigned int/*PmtId*/,PmtProp>::iterator pmtit,idend=m_PmtPropMap.end();
      for(pmtit=m_PmtPropMap.begin(); pmtit!=idend; pmtit++) {
        PmtProp& PoolPmt = pmtit->second;
        PoolPmt.Charge = 0;
        PoolPmt.FirstHit = 999999;
      }

      const CalibReadoutPmtCrate* pCalibPmtCrate = 0;    
      pCalibPmtCrate = dynamic_cast< const DayaBay::CalibReadoutPmtCrate* >(calibReadout);
      if(!pCalibPmtCrate) {
        error()<<"Failed to get CalibReadoutPmtCrate"<<endreq;
        return StatusCode::FAILURE;
      }
      
      Detector det = pCalibPmtCrate->detector();
      //ServiceMode svcMode( pCalibReadoutHdr->context(),0 );
    
      CalibReadoutPmtCrate::PmtChannelReadouts channels = pCalibPmtCrate->channelReadout();
      CalibReadoutPmtCrate::PmtChannelReadouts::iterator ci, ci_end = channels.end();
      for(ci = channels.begin(); ci!=ci_end; ci++) {
        unsigned int multi = ci->size();
        
        double charge = 0;
        for(unsigned int i=0; i<multi; i++){
          if(ci->time(i)>m_timeCutLow && ci->time(i)<m_timeCutHigh){
            if(charge<ci->charge(i)) charge = ci->charge(i);
            //if(hittime>calibChannel->time(i)) hittime = calibChannel->time(i);
          }
        } 

        //int sensor = ci->pmtSensorId().sensorId();
        //if(sensor==0)  continue;//skip fake PMT hits
        //PoolPmtSensor PmtId = PoolPmtSensor(sensor);
        //unsigned int pmtid = PmtId.fullPackedData();
        unsigned int pmtid = ci->pmtSensorId().fullPackedData();
        
        m_PmtPropMap[pmtid].Charge = charge;
        m_PmtPropMap[pmtid].FirstHit = ci->earliestTime();
      }
      
      //find maximum PMT
      double max = 0;
      double maxid = 0;
      for(pmtit=m_PmtPropMap.begin(); pmtit!=idend; pmtit++) {
        PmtProp& PoolPmt = pmtit->second;
        if(max<PoolPmt.Charge){
          max = PoolPmt.Charge;
          maxid = pmtit->first;
        }
      }
      
      //if(ntrigger==1) p1 = m_PmtPropMap[maxid].Position;
      //if(ntrigger==2) p2 = m_PmtPropMap[maxid].Position;
      if(calibReadout->detector().detectorId()==5) p1 = m_PmtPropMap[maxid].Position;
      if(calibReadout->detector().detectorId()==6) p2 = m_PmtPropMap[maxid].Position;
    }
    
    int PositionStatus = 0;
    float PositionX = 0;
    float PositionY = 0;
    float PositionZ = 0;
    int DirectionStatus = 0;
    float DirectionX = 0;
    float DirectionY = 0;
    float DirectionZ = 0;
    
    //when both IWS and OWS triggers exist
    if(p1.Mag2()>0 && p2.Mag2()>0){
      //info() << "simple muon reconstruction using IWS and OWS" << endreq;

      vect = p1-p2;
      PositionStatus = 1;
      PositionX = p1.X();
      PositionY = p1.Y();
      PositionZ = p1.Z();
      DirectionStatus = 1;    
      DirectionX = vect.X();
      DirectionY = vect.Y();
      DirectionZ = vect.Z();
      
    }
    
    // Create output user data header
    UserDataHeader* muonSimple = MakeHeaderObject();
    muonSimple->set("PositionStatus",PositionStatus);
    muonSimple->set("PositionX",PositionX);
    muonSimple->set("PositionY",PositionY);
    muonSimple->set("PositionZ",PositionZ);
    muonSimple->set("DirectionStatus",DirectionStatus);
    muonSimple->set("DirectionX",DirectionX);
    muonSimple->set("DirectionY",DirectionY);
    muonSimple->set("DirectionZ",DirectionZ);
    
  }
  return StatusCode::SUCCESS;
}
StatusCode MuonSimpleAlg::finalize ( ) [virtual]

Definition at line 142 of file MuonSimpleAlg.cc.

{
  return this->GaudiAlgorithm::finalize();
}
DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::GetCurrentHeaderObject ( ) const [inherited]
virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysInitialize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::preExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::postExecute ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

virtual StatusCode DybAlgorithm< DayaBay::UserDataHeader >::sysFinalize ( ) [virtual, inherited]

Reimplemented from DybBaseAlg.

IDataProviderSvc * DybAlgorithm< DayaBay::UserDataHeader >::arcSvc ( ) const [inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::putTES ( DataObject *  obj,
std::string  location 
) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getTES ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::getAES ( std::string  location,
int  index 
) const [inherited]

Reimplemented from DybBaseAlg.

std::vector< DataObject * > DybAlgorithm< DayaBay::UserDataHeader >::getAEScollection ( std::string  location) const [inherited]

Reimplemented from DybBaseAlg.

int DybAlgorithm< DayaBay::UserDataHeader >::getExecNum ( ) [inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::Location ( ) const [inherited]

Reimplemented from DybBaseAlg.

DayaBay::UserDataHeader * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeaderObject ( ) [protected, inherited]
void DybAlgorithm< DayaBay::UserDataHeader >::InitializeHeader ( DayaBay::HeaderObject header) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( ) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( std::vector< const DayaBay::IHeader * > &  inputHeaders) [protected, inherited]

Reimplemented from DybBaseAlg.

TYPE * DybAlgorithm< DayaBay::UserDataHeader >::MakeHeader ( const DayaBay::IHeader referenceHeader) [protected, inherited]

Reimplemented from DybBaseAlg.

void DybAlgorithm< DayaBay::UserDataHeader >::AppendInputHeader ( const DayaBay::HeaderObject header) const [protected, inherited]

Reimplemented from DybBaseAlg.


Member Data Documentation

map<unsigned int,PmtProp> MuonSimpleAlg::m_PmtPropMap [private]

Definition at line 54 of file MuonSimpleAlg.h.

Definition at line 55 of file MuonSimpleAlg.h.

map<unsigned int,int> MuonSimpleAlg::m_PmtId [private]

Definition at line 56 of file MuonSimpleAlg.h.

Definition at line 58 of file MuonSimpleAlg.h.

Definition at line 61 of file MuonSimpleAlg.h.

Definition at line 64 of file MuonSimpleAlg.h.

string MuonSimpleAlg::m_site [private]

Definition at line 66 of file MuonSimpleAlg.h.

IDetectorElement* MuonSimpleAlg::m_de [private]

Definition at line 67 of file MuonSimpleAlg.h.

float MuonSimpleAlg::m_timeCutLow [private]

Definition at line 68 of file MuonSimpleAlg.h.

Definition at line 69 of file MuonSimpleAlg.h.

Reimplemented from DybBaseAlg.

bool DybAlgorithm< DayaBay::UserDataHeader >::m_pullMode [protected, inherited]

Reimplemented from DybBaseAlg.

std::string DybAlgorithm< DayaBay::UserDataHeader >::m_location [protected, inherited]

Reimplemented from DybBaseAlg.


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:11:18 for MuonSimple by doxygen 1.7.4