/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 | Private Attributes
MuonHitSim Class Reference

#include <MuonHitSim.h>

Collaboration diagram for MuonHitSim:
Collaboration graph
[legend]

List of all members.

Classes

class  Configure

Public Member Functions

 MuonHitSim (const std::string &name, ISvcLocator *svcloc)
 Constructor has to be in this form.
virtual ~MuonHitSim ()
StatusCode initialize ()
 Three mandatory member functions of any algorithm.
StatusCode execute ()
StatusCode finalize ()
void addPE (const DayaBay::Detector &det, DayaBay::SimHitCollection *hits, double depE, const TimeStamp &ts)
void addWSPE (const DayaBay::Detector &det, DayaBay::SimHitCollection *hits, double trackTotal, const TimeStamp &ts)

Private Attributes

IRndmGenSvc * m_ranSvc
int m_earliestHit
int m_latestHit
double m_MeVtoPE
int m_ranSeed
TFile * m_wsFile
TH2F * m_tracPEIWS
TH2F * m_tracPEOWS
TH2F * m_tracNHitIWS
TH2F * m_tracNHitOWS
string m_dNameAd1
string m_dNameAd2
string m_dNameAd3
string m_dNameAd4
string m_dNameIws
string m_dNameOws
string m_cableSvcName
ICableSvcm_cableSvc
string m_simSite
list __all__ = ['Configure', 'MuonHitSimConf']

Detailed Description

Definition at line 24 of file MuonHitSim.h.


Constructor & Destructor Documentation

MuonHitSim::MuonHitSim ( const std::string &  name,
ISvcLocator *  svcloc 
)

Constructor has to be in this form.

Definition at line 26 of file MuonHitSim.cc.

: GaudiAlgorithm(name, svcloc)
{
  declareProperty("MeVtoPE", m_MeVtoPE = 134.8, "the PE/MeV conversion factor");
  declareProperty("CableSvcName", m_cableSvcName = "CableSvc",
                  "Name of service to map between det, hardware, and electronic IDs");
  declareProperty("SimSite", m_simSite = "DayaBay", "Simulation site");
}
MuonHitSim::~MuonHitSim ( ) [virtual]

Definition at line 35 of file MuonHitSim.cc.

{
}

Member Function Documentation

StatusCode MuonHitSim::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 39 of file MuonHitSim.cc.

{
  StatusCode sc = this->GaudiAlgorithm::initialize();
  if(sc != StatusCode::SUCCESS) return sc;
  if(sc.isFailure()) 
    {
      error() << "parent class failed to initialize"<< endreq;
      return sc;
    }

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

  //Get RndmGen Service
  sc = service("RndmGenSvc", m_ranSvc, true);
  if(sc.isFailure())
    {
      error() << "Unable get RndmGenSvc service"<< m_ranSvc<< endreq;
      return sc;
    }

  string wsFile = getenv("MUONHITSIMROOT");
  wsFile.append("/data/Anafile.root");
  m_wsFile = new TFile(wsFile.c_str(), "READ");
  m_tracPEIWS = (TH2F*)gDirectory->Get("TracPEIWS");
  m_tracPEOWS = (TH2F*)gDirectory->Get("TracPEOWS");
  m_tracNHitIWS = (TH2F*)gDirectory->Get("TracNHitIWS");
  m_tracNHitOWS = (TH2F*)gDirectory->Get("TracNHitOWS");

  debug() << "simSite: " << m_simSite << endreq;

  return StatusCode::SUCCESS;
}
StatusCode MuonHitSim::execute ( )

Loop over all SimHitCollections

Definition at line 78 of file MuonHitSim.cc.

{
  debug() << "execute() ______________________________ start" << endreq;

  //debug() << "MeVtoPE: " << m_MeVtoPE << endreq;
  // Get input header
  SimHeader* simHeader = get<SimHeader>(DayaBay::SimHeaderLocation::Default);

  // Get the SimHit Header
  const DayaBay::SimHitHeader* simHitHeader = simHeader->hits();
  const DayaBay::SimHitHeader::hc_map& hcMap = simHitHeader->hitCollection();

  //const Site::Site_t simSite = (simHeader->context()).GetSite();
  debug() << "MuonHitSim Site: " << m_simSite << endreq;
  
  m_dNameAd1 = m_simSite;
  m_dNameAd1.append("AD1");
  m_dNameAd2 = m_simSite;
  m_dNameAd2.append("AD2");
  m_dNameIws = m_simSite;
  m_dNameIws.append("IWS");
  m_dNameOws = m_simSite;
  m_dNameOws.append("OWS");
  if(m_simSite=="Far"){
    m_dNameAd3 = m_simSite;
    m_dNameAd3.append("AD3");
    m_dNameAd4 = m_simSite;
    m_dNameAd4.append("AD4");
  }

  debug() << "MuonHitSim dNameAd1: " << m_dNameAd1 << endreq;

  debug() << "Processing hit collections" <<endreq;
  
  debug() << "SimHeader TimeStamp: " << simHeader->timeStamp() << ", SimHeader Earliest: " << simHeader->earliest() << " , Latest: " <<simHeader->latest() << endreq;
  
  //debug() << "SimHeader Earliest: " << simHeader->earliest()-simHeader->timeStamp() << " , Latest: " <<simHeader->latest()-simHeader->timeStamp() << endreq;

  TimeStamp ts = simHeader->timeStamp();

  bool existHit = false;
  if(!hcMap.empty())
    {
      existHit = true;
    }

  m_earliestHit = 300;
  m_latestHit = 0;

  //-----------------------------------
  double depEinLSAD1 = 0;  
  double depEinGdLSAD1 = 0;
  double depEinLSAD2 = 0;
  double depEinGdLSAD2 = 0;
  double trackinIWS = 0;
  double trackinOWS = 0;

  double depEinLSAD3 = 0;  
  double depEinGdLSAD3 = 0;
  double depEinLSAD4 = 0;  
  double depEinGdLSAD4 = 0;

  
  const SimUnobservableStatisticsHeader* hstats=simHeader->unobservableStatistics();
  map<std::string, SimStatistic>::const_iterator hstatsIter;
  for(hstatsIter=hstats->stats().begin(); hstatsIter!=hstats->stats().end(); hstatsIter++)
    {
      if(hstatsIter->first=="QEDepInLS1")
        {
          depEinLSAD1=hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"AD1 qLS1  ="<<hstatsIter->second.sum()<<endreq;
        }
      if(hstatsIter->first=="QEDepInGdLS1")
        {
          depEinGdLSAD1=hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"AD1 qGdLS1  ="<<hstatsIter->second.sum()<<endreq;
        }
      if(hstatsIter->first=="QEDepInLS2")
        {
          depEinLSAD2 = hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"AD2 qLS2  ="<<hstatsIter->second.sum()<<endreq;
        }
      if(hstatsIter->first=="QEDepInGdLS2")
        {
          depEinGdLSAD2 = hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"AD2 qGdLS2  ="<<hstatsIter->second.sum()<<endreq;
        }
      if(m_simSite=="Far"){
        if(hstatsIter->first=="QEDepInLS3")
          {
            depEinLSAD3=hstatsIter->second.sum();
            if(hstatsIter->second.sum()>0)
              debug()<<"AD3 qLS3  ="<<hstatsIter->second.sum()<<endreq;
          }
        if(hstatsIter->first=="QEDepInGdLS3")
          {
            depEinGdLSAD3=hstatsIter->second.sum();
            if(hstatsIter->second.sum()>0)
              debug()<<"AD3 qGdLS3  ="<<hstatsIter->second.sum()<<endreq;
          }
        if(hstatsIter->first=="QEDepInLS4")
          {
            depEinLSAD4=hstatsIter->second.sum();
            if(hstatsIter->second.sum()>0)
              debug()<<"AD4 qLS4  ="<<hstatsIter->second.sum()<<endreq;
          }
        if(hstatsIter->first=="QEDepInGdLS4")
          {
            depEinGdLSAD4=hstatsIter->second.sum();
            if(hstatsIter->second.sum()>0)
              debug()<<"AD4 qGdLS4  ="<<hstatsIter->second.sum()<<endreq;
          }
      }
      if(hstatsIter->first=="MuTrackInIWS")
        {
          trackinIWS = hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"IWS Track  ="<<hstatsIter->second.sum()<<endreq;
        }
      if(hstatsIter->first=="MuTrackInOWS")
        {
          trackinOWS = hstatsIter->second.sum();
          if(hstatsIter->second.sum()>0)
            debug()<<"OWS Track  ="<<hstatsIter->second.sum()<<endreq;
        }
    }

  double depEAD1 = 0;
  depEAD1 = depEinGdLSAD1 + depEinLSAD1;
  debug() << "depE in AD1: " << depEAD1 << endreq;
  double depEAD2 = 0;
  depEAD2 = depEinGdLSAD2 + depEinLSAD2;
  debug() << "depE in AD2: " << depEAD2 << endreq;
  double depEAD3 = 0;
  double depEAD4 = 0;
  if(m_simSite=="Far"){
    depEAD3 = depEinGdLSAD3 + depEinLSAD3;
    debug() << "depE in AD3: " << depEAD3 << endreq;
    depEAD4 = depEinGdLSAD4 + depEinLSAD4;
    debug() << "depE in AD4: " << depEAD4 << endreq;
  }
  //double trackTotal = 0;
  //trackTotal = trackinIWS + trackinOWS;
  debug() << "Track in Inner Water Pool: " << trackinIWS << endreq;
  debug() << "Track in Outter Water Pool: " << trackinOWS << endreq;
    
  //------------------------------------

  if(depEAD1+depEAD2+trackinIWS+trackinOWS>0 || (m_simSite=="Far" && depEAD3+depEAD4>0))
    {
      bool ad1 = false;
      bool ad2 = false;
      bool iws = false;
      bool ows = false;

      bool ad3 = false;
      bool ad4 = false; 
      

      DayaBay::SimHitHeader::hc_map::const_iterator hcIter;
      for(hcIter=hcMap.begin(); hcIter != hcMap.end(); ++hcIter) {
        
        DayaBay::Detector det(hcIter->first);
        debug() << "Checking " << det.detName() << " for hits." << endreq;
        DayaBay::SimHitCollection* hits = hcIter->second;
        if(!hits) return StatusCode::FAILURE;
        
        debug() << "Got hit collection from " << det.detName()<<" (id= "
                << det.siteDetPackedData() << ") " << " with "
                << hits->collection().size() << " hits." << endreq;
        
        const DayaBay::SimHitCollection::hit_container& htcon = hits->collection();
        DayaBay::SimHitCollection::hit_container::const_iterator hcIter,
          hcDone = htcon.end();
        for (hcIter=htcon.begin(); hcIter != hcDone; ++hcIter) {
          
          DayaBay::DetectorSensor sensDetId((*hcIter)->sensDetId());
          debug() << "Requesting pmtData for " << sensDetId << "," << (*hcIter)->hitTime() << endreq;
        }

        if( det.detName() == m_dNameAd1) {
          ad1 = true;
          addPE(det, hits, depEAD1, ts);
        } else if( det.detName() == m_dNameAd2) {
          ad2 = true;
          addPE(det, hits, depEAD2, ts);
        } else if( det.detName() == m_dNameIws){
          iws = true;
          addWSPE(det, hits, trackinIWS, ts);
        } else if( det.detName() == m_dNameOws){
          ows = true;
          addWSPE(det, hits, trackinOWS, ts);
        }
        if(m_simSite=="Far") {
          if( det.detName() == m_dNameAd3) {
            ad3 = true;
            addPE(det, hits, depEAD3, ts);
          } else if( det.detName() == m_dNameAd4) {
            ad4 = true;
            addPE(det, hits, depEAD4, ts);
          }
        }
      }
      
      if(!ad1 && depEAD1>0) 
        {  //AD1 does not exist
          SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
          SimHitCollection *hits = new SimHitCollection;
          hits->setHeader(shh);
          
          Detector det(m_dNameAd1);
          hits->setDetector(det);
          
          SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
          hits->setCollection(*hc);
          addPE(det, hits, depEAD1, ts);
          if(hits->collection().empty()) 
            {
              delete hits;
            } 
          else 
            {
              shh->addHitCollection(hits);
            }
        }
      if(!ad2 && depEAD2>0) 
        {  //AD2 does not exist
          SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
          SimHitCollection *hits = new SimHitCollection;
          hits->setHeader(shh);
          
          Detector det(m_dNameAd2);
          hits->setDetector(det);
          
          SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
          hits->setCollection(*hc);
          addPE(det, hits, depEAD2, ts);
          if(hits->collection().empty()) 
            {
              delete hits;
            } 
          else 
            {
              shh->addHitCollection(hits);
            }
        }
      if(!iws && trackinIWS>0) 
        {  //IWS does not exist
          SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
          SimHitCollection *hits = new SimHitCollection;
          hits->setHeader(shh);
          
          Detector det(m_dNameIws);
          hits->setDetector(det);
          
          SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
          hits->setCollection(*hc);
          addWSPE(det, hits, trackinIWS, ts);
          if(hits->collection().empty()) 
            {
              delete hits;
            } 
          else 
            {
              shh->addHitCollection(hits);
            }
        }
      if(!ows && trackinOWS>0) 
        {  //OWS does not exist
          SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
          SimHitCollection *hits = new SimHitCollection;
          hits->setHeader(shh);
          
          Detector det(m_dNameOws);
          hits->setDetector(det);
          
          SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
          hits->setCollection(*hc);
          addWSPE(det, hits, trackinOWS, ts);
          if(hits->collection().empty()) 
            {
              delete hits;
            } 
          else 
            {
              shh->addHitCollection(hits);
            }
        }

      if(m_simSite=="Far") {
        if(!ad3 && depEAD3>0) 
          {  //AD3 does not exist
            SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
            SimHitCollection *hits = new SimHitCollection;
            hits->setHeader(shh);
            
            Detector det(m_dNameAd3);
            hits->setDetector(det);
            
            SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
            hits->setCollection(*hc);
            addPE(det, hits, depEAD3, ts);
            if(hits->collection().empty()) 
              {
                delete hits;
              } 
            else 
              {
                shh->addHitCollection(hits);
              }
          }
        if(!ad4 && depEAD4>0) 
          {  //AD4 does not exist
            SimHitHeader *shh = const_cast<SimHitHeader*>(simHitHeader);
            SimHitCollection *hits = new SimHitCollection;
            hits->setHeader(shh);
            
            Detector det(m_dNameAd4);
            hits->setDetector(det);
            
            SimHitCollection::hit_container *hc = new SimHitCollection::hit_container;
            hits->setCollection(*hc);
            addPE(det, hits, depEAD4, ts);
            if(hits->collection().empty()) 
              {
                delete hits;
              } 
            else 
              {
                shh->addHitCollection(hits);
              }
          }
      }

      /*
      // Set SimHeader Context
      if(trackinOWS>100)
        {
          Detector det(m_dNameOws);
          context.SetSite(det.site());
          context.SetDetId(det.detectorId());
          context.SetSimFlag(SimFlag::kMC);
          context.SetTimeStamp(simHeader->timeStamp());
        }
      else if(trackinIWS>100)
        {
          Detector det(m_dNameIws);
          context.SetSite(det.site());
          context.SetDetId(det.detectorId());
          context.SetSimFlag(SimFlag::kMC);
          context.SetTimeStamp(simHeader->timeStamp());
        }
      else if(depEAD1>0)
        {
          Detector det(m_dNameAd1);
          context.SetSite(det.site());
          context.SetDetId(det.detectorId());
          context.SetSimFlag(SimFlag::kMC);
          context.SetTimeStamp(simHeader->timeStamp());
        }
      else if(depEAD2>0)
        {
          Detector det(m_dNameAd2);
          context.SetSite(det.site());
          context.SetDetId(det.detectorId());
          context.SetSimFlag(SimFlag::kMC);
          context.SetTimeStamp(simHeader->timeStamp());
        }
      */

      // Set Earliest & Latest Hit time
      debug() << "Earliest Hit: " << m_earliestHit << ", Latest Hit: " << m_latestHit<< endreq;
      if(m_earliestHit <= m_latestHit)
        {
          TimeStamp tempEarliestStamp = simHeader->timeStamp();
          TimeStamp tempearliest(0, m_earliestHit);
          tempEarliestStamp.Add(tempearliest);
          TimeStamp tempLatestStamp = simHeader->timeStamp();
          TimeStamp templatest(0, m_latestHit);
          tempLatestStamp.Add(templatest);
          if(existHit)
            {
              if(simHeader->earliest()>tempEarliestStamp)
                {
                  simHeader->setEarliest(tempEarliestStamp);
                }
              if(simHeader->latest()<tempLatestStamp)
                {
                  simHeader->setLatest(tempLatestStamp);
                }
            }
          else
            {
              simHeader->setEarliest(tempEarliestStamp);
              simHeader->setLatest(tempLatestStamp);
            }
        }
      else if(m_earliestHit != 300 || m_latestHit != 0)
        {
          error() << "Fail to get earliest hit time or latest hit time!" << endreq;
        }

      //----------------------
      
      //debug() << "After AddPE, Earliest: " 
      //       << simHeader->earliest()-simHeader->timeStamp() 
      //       << " , Latest: " <<simHeader->latest()-simHeader->timeStamp() << endreq;

      debug() << "After AddPE, Earliest: " << simHeader->earliest() << " , Latest: " <<simHeader->latest() << endreq;
      
      //----------------------

      // Check SimHitCollection after muon 300ns simulation
      debug() << "Checking SimHitCollection after muon 300ns simulation." << endreq;
      for(hcIter=hcMap.begin(); hcIter != hcMap.end(); ++hcIter) {
        
        DayaBay::Detector det(hcIter->first);
        debug() << "Checking " << det.detName() << " for hits." << endreq;
        DayaBay::SimHitCollection* hits = hcIter->second;
        if(!hits) return StatusCode::FAILURE;
        
        debug() << "Got hit collection from " << det.detName()<<" (id= "
                << det.siteDetPackedData() << ") " << " with "
                << hits->collection().size() << " hits." << endreq;
      }
    }


  debug() << "execute() ______________________________ end" << endreq;

  return StatusCode::SUCCESS;
}
StatusCode MuonHitSim::finalize ( )

Definition at line 516 of file MuonHitSim.cc.

{
  debug() << "finalize()" << endreq;

  if(m_wsFile) {
    m_wsFile->Close();
    delete m_wsFile;
  }

  return StatusCode::SUCCESS;
}
void MuonHitSim::addPE ( const DayaBay::Detector det,
DayaBay::SimHitCollection hits,
double  depE,
const TimeStamp ts 
)

Definition at line 528 of file MuonHitSim.cc.

{
  //m_MeVtoPE = 134.8; // constant of PE/MeV
  double totalPE = depE * m_MeVtoPE;
  if(totalPE > 198*5000 ) totalPE = 198*5000;
  double weightPE = 1;
  //double weightPE = totalPE / 198;
  //pmtPE = 1000;
  double PEsum = 0;

  Context context;
  if(m_simSite=="DayaBay")
    {
      context.SetSite(Site::kDayaBay);
    }
  else if(m_simSite=="LingAo")
    {
      context.SetSite(Site::kLingAo);
    }
  else if(m_simSite=="Far")
    {
      context.SetSite(Site::kFar);
    }
  else 
    {
      error() << "Unknow site: " << m_simSite << endreq;
      return;
    }
  context.SetDetId(det.detectorId());
  context.SetSimFlag(SimFlag::kMC);
  context.SetTimeStamp(ts);

  ServiceMode svcMode(context, 0);

  Rndm::Numbers hittime;
  if(hittime.initialize(m_ranSvc, Rndm::Gauss(70, 15)).isSuccess())
  {

    while(PEsum <= totalPE)
    {
      const vector<DayaBay::AdPmtSensor>& channelList = m_cableSvc->adPmtSensors(svcMode);
      vector<DayaBay::AdPmtSensor>::const_iterator chanIter, chanEnd = channelList.end();
      for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++)
        {
              DayaBay::AdPmtSensor pmtId = *chanIter;
              if(pmtId.detectorId()==det.detectorId())
                {
                  int ring = pmtId.ring();
                  int column = pmtId.column();
                  SimPmtHit *hit = new SimPmtHit;
                  int HTime = (int)hittime();
                  while(HTime<=0 || HTime>=300)
                    {
                      HTime = (int)hittime();
                    }
                  if(HTime<m_earliestHit) m_earliestHit = HTime;
                  if(HTime>m_latestHit) m_latestHit = HTime;
                  hit->setHc(hits);
                  hit->setHitTime(HTime);
                  hit->setWeight(weightPE);
                  hit->setSensDetId(AdPmtSensor(ring,column,det.site(),det.detectorId()).fullPackedData());
                  hits->collection().push_back(hit);
                  PEsum += weightPE;
                  if(PEsum >= totalPE) break;
                }
        }
    }


    /*            
    // Give each PMT 1 hit with certain weight
    const vector<DayaBay::AdPmtSensor>& channelList = m_cableSvc->adPmtSensors(svcMode);
    vector<DayaBay::AdPmtSensor>::const_iterator chanIter, chanEnd = channelList.end();
    for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++)
    {
      DayaBay::AdPmtSensor pmtId = *chanIter;
      if(pmtId.detectorId()==det.detectorId())
        {
          int ring = pmtId.ring();
          int column = pmtId.column;
          SimPmtHit *hit = new SimPmtHit;
          int HTime = (int)hittime();
          while(HTime<=0 || HTime>=300)
            {
              HTime = (int)hittime();
            }
          if(HTime<m_earliestHit) m_earliestHit = HTime;
          if(HTime>m_latestHit) m_latestHit = HTime;
          hit->setHc(hits);
          hit->setHitTime(HTime);
          hit->setWeight(weightPE);
          hit->setSensDetId(AdPmtSensor(ring,column,det.site(),det.detectorId()).fullPackedData());
          hits->collection().push_back(hit);
          PEsum += weightPE;
        }
    }
    */
  }
  else
  {
    error() << "Rndm number for hittime failed to initialize" << endreq;
  }
  debug() << "Total PMT PE: " << PEsum << endreq;
}
void MuonHitSim::addWSPE ( const DayaBay::Detector det,
DayaBay::SimHitCollection hits,
double  trackTotal,
const TimeStamp ts 
)

Definition at line 635 of file MuonHitSim.cc.

{
  if(track<100) return;
  double weightPE = 1;
  double PEsum = 0;
  Context context;
  if(m_simSite=="DayaBay")
    {
      context.SetSite(Site::kDayaBay);
    }
  else if(m_simSite=="LingAo")
    {
      context.SetSite(Site::kLingAo);
    }
  else if(m_simSite=="Far")
    {
      context.SetSite(Site::kFar);
    }
  else 
    {
      error() << "Unknow site: " << m_simSite << endreq;
      return;
    }
  context.SetDetId(det.detectorId());
  context.SetSimFlag(SimFlag::kMC);
  context.SetTimeStamp(ts);
  ServiceMode svcMode(context, 0);
  Rndm::Numbers hittime;
  if(hittime.initialize(m_ranSvc, Rndm::Gauss(70, 15)).isSuccess())
    {
      if( det.detName() == m_dNameIws)
        {
          TH1D* htrackNHitIWS = m_tracNHitIWS->ProjectionY("NHitIWS",(int)(track/100),(int)(track/100));
          TH1D* htrackPEIWS = m_tracPEIWS->ProjectionY("yPEIWS",(int)(track/100),(int)(track/100));
          int nPMT = 0;
          if(htrackNHitIWS->GetEntries()>0)
            {
              nPMT = (int)htrackNHitIWS->GetRandom();
            }
          else nPMT = 0;
          vector<DayaBay::PoolPmtSensor> channelList = m_cableSvc->poolPmtSensors(svcMode);
          int NkickPMT = channelList.size()-nPMT;
          debug() << "NHit in IWS:" << nPMT << endreq;
          for(int i=1;i<=NkickPMT;i++)
            {
              Rndm::Numbers kick;
              if(kick.initialize(m_ranSvc, Rndm::Flat(0, channelList.size()-1)).isSuccess())
                {
                  channelList.erase(channelList.begin()+(int)kick());
                }
              else
                {
                  error() << "Rndm number for kick PMT failed to initialize" << endreq;
                }
            }
          vector<DayaBay::PoolPmtSensor>::const_iterator chanIter, chanEnd = channelList.end();
          for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++)
            {
              DayaBay::PoolPmtSensor pmtId = *chanIter;
              if(pmtId.detectorId()==det.detectorId())
                {
                  int wallNumber = pmtId.wallNumber();
                  int wallSpot = pmtId.wallSpot();
                  bool inwardFacing = pmtId.inwardFacing();
                  int nPE = 0;
                  if(htrackPEIWS->GetEntries()>0)
                    {
                      nPE = (int)htrackPEIWS->GetRandom();
                    }
                  else nPE = 0;
                  for(int j=1; j<=nPE; j++)
                    {
                      SimPmtHit *hit = new SimPmtHit;
                      int HTime = (int)hittime();
                      while(HTime<=0 || HTime>=300)
                        {
                          HTime = (int)hittime();
                        }
                      if(HTime<m_earliestHit) m_earliestHit = HTime;
                      if(HTime>m_latestHit) m_latestHit = HTime;
                      hit->setHc(hits);
                      hit->setHitTime(HTime);
                      hit->setWeight(weightPE);
                      hit->setSensDetId(PoolPmtSensor(wallNumber,wallSpot,inwardFacing,det.site(),det.detectorId()).fullPackedData());
                      hits->collection().push_back(hit);
                      PEsum ++;
                    }
                }
            }
          debug() << "IWS PMT PE: " << PEsum << endreq;
        }
      if( det.detName() == m_dNameOws)
        {
          TH1D* htrackNHitOWS = m_tracNHitOWS->ProjectionY("NHitOWS",(int)(track/100),(int)(track/100));
          TH1D* htrackPEOWS = m_tracPEOWS->ProjectionY("yPEOWS",(int)(track/100),(int)(track/100));
          int nPMT = 0;
          if(htrackNHitOWS->GetEntries()>0)
            {
              nPMT = (int)htrackNHitOWS->GetRandom();
            }
          vector<DayaBay::PoolPmtSensor> channelList = m_cableSvc->poolPmtSensors(svcMode);
          int NkickPMT = channelList.size()-nPMT;
          debug() << "NHit in OWS:" << nPMT << endreq;
          for(int i=1;i<=NkickPMT;i++)
            {
              Rndm::Numbers kick;
              if(kick.initialize(m_ranSvc, Rndm::Flat(0, channelList.size()-1)).isSuccess())
                {
                  channelList.erase(channelList.begin()+(int)kick());
                }
              else
                {
                  error() << "Rndm number for kick PMT failed to initialize" << endreq;
                }
            }
          vector<DayaBay::PoolPmtSensor>::const_iterator chanIter, chanEnd = channelList.end();
          for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++)
            {
              DayaBay::PoolPmtSensor pmtId = *chanIter;
              if(pmtId.detectorId()==det.detectorId())
                {
                  int wallNumber = pmtId.wallNumber();
                  int wallSpot = pmtId.wallSpot();
                  bool inwardFacing = pmtId.inwardFacing();
                  int nPE = 0;
                  if(htrackPEOWS->GetEntries()>0)
                    {
                      nPE = (int)htrackPEOWS->GetRandom();
                    }
                  for(int j=1; j<=nPE; j++)
                    {
                      SimPmtHit *hit = new SimPmtHit;
                      int HTime = (int)hittime();
                      while(HTime<=0 || HTime>=300)
                        {
                          HTime = (int)hittime();
                        }
                      if(HTime<m_earliestHit) m_earliestHit = HTime;
                      if(HTime>m_latestHit) m_latestHit = HTime;
                      hit->setHc(hits);
                      hit->setHitTime(HTime);
                      hit->setWeight(weightPE);
                      hit->setSensDetId(PoolPmtSensor(wallNumber,wallSpot,inwardFacing,det.site(),det.detectorId()).fullPackedData());
                      hits->collection().push_back(hit);
                      PEsum ++;
                    }
                }
            }
          debug() << "OWS PMT PE: " << PEsum << endreq;
        }
    }
  else
    {
      error() << "Rndm number for hittime failed to initialize" << endreq;
    }
}

Member Data Documentation

IRndmGenSvc* MuonHitSim::m_ranSvc [private]

Definition at line 41 of file MuonHitSim.h.

Definition at line 43 of file MuonHitSim.h.

int MuonHitSim::m_latestHit [private]

Definition at line 44 of file MuonHitSim.h.

double MuonHitSim::m_MeVtoPE [private]

Definition at line 45 of file MuonHitSim.h.

int MuonHitSim::m_ranSeed [private]

Definition at line 46 of file MuonHitSim.h.

TFile* MuonHitSim::m_wsFile [private]

Definition at line 48 of file MuonHitSim.h.

TH2F* MuonHitSim::m_tracPEIWS [private]

Definition at line 50 of file MuonHitSim.h.

TH2F* MuonHitSim::m_tracPEOWS [private]

Definition at line 51 of file MuonHitSim.h.

TH2F* MuonHitSim::m_tracNHitIWS [private]

Definition at line 52 of file MuonHitSim.h.

TH2F* MuonHitSim::m_tracNHitOWS [private]

Definition at line 53 of file MuonHitSim.h.

string MuonHitSim::m_dNameAd1 [private]

Definition at line 55 of file MuonHitSim.h.

string MuonHitSim::m_dNameAd2 [private]

Definition at line 56 of file MuonHitSim.h.

string MuonHitSim::m_dNameAd3 [private]

Definition at line 57 of file MuonHitSim.h.

string MuonHitSim::m_dNameAd4 [private]

Definition at line 58 of file MuonHitSim.h.

string MuonHitSim::m_dNameIws [private]

Definition at line 59 of file MuonHitSim.h.

string MuonHitSim::m_dNameOws [private]

Definition at line 60 of file MuonHitSim.h.

string MuonHitSim::m_cableSvcName [private]

Definition at line 62 of file MuonHitSim.h.

Definition at line 63 of file MuonHitSim.h.

string MuonHitSim::m_simSite [private]

Definition at line 65 of file MuonHitSim.h.

list MuonHitSim::__all__ = ['Configure', 'MuonHitSimConf'] [private]

Definition at line 3 of file __init__.py.


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:05:36 for MuonHitSim by doxygen 1.7.4