/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/TofSim/TofSim-00-02-33/src/BesTofDigitizerBrV1.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //      BOOST --- BESIII Object_Oriented Simulation Tool                     //
00003 //---------------------------------------------------------------------------//
00004 //Description:
00005 //Author: Dengzy
00006 //Created: Mar, 2004
00007 //Modified:
00008 //Comment:
00009 //---------------------------------------------------------------------------//
00010 //$Id: BesTofDigitizerBrV1.cc
00011 
00012 #include "BesTofDigitizerBrV1.hh"
00013 #include "BesTofDigi.hh"
00014 #include "BesTofHit.hh"
00015 #include "G4DigiManager.hh"
00016 #include "BesTofGeoParameter.hh"
00017 #include "Randomize.hh"
00018 #include <TMath.h>
00019 #include <math.h>
00020 
00021 BesTofDigitizerBrV1::BesTofDigitizerBrV1()
00022 {
00023     BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
00024     m_scinLength = tofPara->GetBr1L();
00025 }
00026 
00027 BesTofDigitizerBrV1::~BesTofDigitizerBrV1()
00028 {
00029 }
00030 
00031 void BesTofDigitizerBrV1::Digitize(ScintSingle* scint, BesTofDigitsCollection* DC)
00032 {
00033     G4cout<<"BesTofDigitizerBrV1::Digitize"<<G4endl;
00034     m_besTofDigitsCollection = DC;
00035     G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
00036     G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
00037     m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID));
00038     if (m_THC)
00039     {
00040         G4int partId, scinNb, nHits;
00041         BesTofHit* hit;
00042         partId=scint->GetPartId();
00043         scinNb=scint->GetScinNb();
00044         nHits=scint->GetHitIndexes()->size();
00045         TofPmtInit();
00046         for (G4int j=0;j<nHits;j++)
00047         {
00048             hit= (*m_THC)[( *(scint->GetHitIndexes()) )[j]];
00049             TofPmtAccum(hit);
00050         }
00051 
00052         Smear(scinNb);
00053         if ( m_TDC[0]>0 )
00054         {
00055             BesTofDigi* digi = new BesTofDigi;
00056             digi->SetTrackIndex(m_trackIndex);
00057             digi->SetPartId(partId);
00058             digi->SetScinNb(scinNb);
00059             digi->SetForwADC( m_ADC[0]) ;
00060             digi->SetForwTDC( m_TDC[0]) ;
00061             digi->SetBackADC( m_ADC[1]) ;
00062             digi->SetBackTDC( m_TDC[1]) ;
00063             m_besTofDigitsCollection->insert(digi);
00064         }
00065     }
00066 }
00067 
00068 void BesTofDigitizerBrV1::TofPmtInit()
00069 {
00070     Initialize();
00071     m_t1st = 9999.;
00072 }
00073 
00074 void BesTofDigitizerBrV1::TofPmtAccum(BesTofHit* hit)
00075 {
00076     G4int trackIndex = hit->GetTrackIndex();
00077     G4int partId = hit->GetPartId();
00078     G4int scinNb = hit->GetScinNb();
00079     G4double time = hit->GetTime();
00080     if (time<m_globalTime)
00081     {
00082         m_globalTime = time;
00083         m_trackIndex = trackIndex;
00084     }
00085     G4double edep = hit->GetEdep();
00086     G4ThreeVector pos = hit->GetPos();
00087     G4double posx = pos.x();
00088     G4double posy = pos.y();
00089     G4double posz = pos.z();
00090 
00091     G4double atten;
00092     atten = m_tofCaliSvc->BAtten(scinNb);
00093     G4double pathL[2];
00094     pathL[0]=m_scinLength/2-posz;
00095     pathL[1]=posz+m_scinLength/2;
00096     for (G4int j=0;j<2;j++)
00097     {
00098         //G4cout<<"atten:"<<atten<<G4endl;
00099         m_ADC[j] += edep*exp(-pathL[j]/atten);
00100     }
00101     if (time<m_t1st)
00102     {
00103         m_t1st = time;
00104         m_z = posz;
00105         m_TDC[0] = m_TDC[1] = m_t1st;
00106     }
00107 }
00108 
00109 void BesTofDigitizerBrV1::Smear(G4int scinNb)
00110 {
00111     G4cout<<"m_t1st:"<<m_t1st<<"  m_z:"<<m_z<<G4endl;
00112 
00113     /*G4double tofRes = 0.08;
00114     G4double atten;
00115     for(G4int i=0;i<2;i++)
00116     {
00117       m_TDC[i] += tofRes * G4RandGauss::shoot();
00118     }*/
00119 
00120     double pp1[10];
00121     double pp2[10];
00122     for (int i=0;i<10;i++)
00123     {
00124         pp1[i]=m_tofCaliSvc->BTof(scinNb)->getP1(i);
00125         pp2[i]=m_tofCaliSvc->BTof(scinNb)->getP2(i);
00126         //G4cout<<"pp1["<<i<<"]:"<<pp1[i]<<"  "<<"pp2["<<i<<"]:"<<pp2[i]<<G4endl;
00127     }
00128     double pp[10];
00129     for (int i=0;i<2;i++)
00130     {
00131         m_ADC[i] *= 7.;
00132         for (int j=0;j<10;j++)
00133         {
00134             if (i==0)
00135                 pp[j]=pp1[j];
00136             else
00137                 pp[j]=pp2[j];
00138         }
00139         m_TDC[i] += (pp[0]+pp[1]*m_z)/TMath::Sqrt(m_ADC[i])+
00140                     pp[2]*m_ADC[i]+
00141                     pp[3]*m_ADC[i]*m_ADC[i]+
00142                     pp[4]*m_ADC[i]*m_ADC[i]*m_ADC[i]+
00143                     pp[5]/(84.2*84.2+m_z*m_z)+
00144                     pp[6]*m_z+
00145                     pp[7]*m_z*m_z+
00146                     pp[8]*m_z*m_z*m_z+
00147                     pp[9];
00148     }
00149 }

Generated on Tue Nov 29 23:14:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7