BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMdcDigitizer Class Reference

#include <BesMdcDigitizer.hh>

+ Inheritance diagram for BesMdcDigitizer:

Public Member Functions

 BesMdcDigitizer (G4String modName)
 
 ~BesMdcDigitizer ()
 
virtual void Digitize ()
 
void SetNoiseFlag (G4int flag)
 
void SetNoiseType (G4int type)
 
void SetNoiseLevel (G4double level)
 
void SetSmearFlag (G4int flag)
 
void SetMdcDRes (G4double res)
 
void SetEffFlag (G4int flag)
 
void SetEff (G4int layer, G4double eff)
 
 BesMdcDigitizer (G4String modName)
 
 ~BesMdcDigitizer ()
 
virtual void Digitize ()
 
void SetNoiseFlag (G4int flag)
 
void SetNoiseType (G4int type)
 
void SetNoiseLevel (G4double level)
 
void SetSmearFlag (G4int flag)
 
void SetMdcDRes (G4double res)
 
void SetEffFlag (G4int flag)
 
void SetEff (G4int layer, G4double eff)
 

Detailed Description

Constructor & Destructor Documentation

◆ BesMdcDigitizer() [1/2]

BesMdcDigitizer::BesMdcDigitizer ( G4String  modName)

Definition at line 29 of file BesMdcDigitizer.cc.

29 :G4VDigitizerModule(modName){
30 noiseFlag=0;
31 noiseType=3;
32 noiseLevel=0.1;//10%
33 maxNoiseT=300.;//ns
34 smearFlag=1;
35 mdcDRes = 0.13; //mm
36 effFlag = 0;
37 for(G4int i=0; i<43;i++){
38 layerEff.push_back(1.);
39 }
40 collectionName.push_back("BesMdcDigisCollection");
41 digitizerMessenger = new BesMdcDigitizerMessenger(this);
42 mdcGeoPointer=BesMdcGeoParameter::GetGeo();
43 mdcCalPointer=new BesMdcCalTransfer;
44
45 // ISvcLocator* svcLocator = Gaudi::svcLocator();
46 IG4Svc* tmpSvc;
47 //G4Svc* m_G4Svc;
48 StatusCode sc=Gaudi::svcLocator()->service("G4Svc", tmpSvc);
49 if (!sc.isSuccess())
50 G4cout <<" MdcDigitizer::Error,could not open G4Svc"<<G4endl;
51
52 m_G4Svc=dynamic_cast<G4Svc *>(tmpSvc);
53
55 sc= Gaudi::svcLocator()->service("MdcTunningSvc",IMdcTunningSvc);
56 if (!sc.isSuccess()){
57 G4cout <<" MdcDigitizer::Error,could not open Mdc Tunning Service"<<G4endl;
58 }else{
59 G4cout<<" MdcDigitizer:: Open Mdc Tunning Service"<<G4endl;
60 }
61 mdcTunningSvc=dynamic_cast<MdcTunningSvc *>(IMdcTunningSvc);
62
63 std::string noiseFile=m_G4Svc->GetMdcNoiseFile();
64 f=new TFile(noiseFile.c_str());
65 h1=(TH1F*)f->Get("h703");
66 h2=(TH1F*)f->Get("h501");
67 h3=(TH1F*)f->Get("h801");
68 /*
69 //get Mdc Ntuple from G4Svc
70 if(m_G4Svc->MdcRootFlag())
71 {
72 m_tupleMdc = m_G4Svc->GetTupleMdc();
73 sc = m_tupleMdc->addItem("NHits",m_NHits);
74 sc = m_tupleMdc->addItem("LayerId",m_layerId);
75 sc = m_tupleMdc->addItem("cellId",m_cellId);
76 sc = m_tupleMdc->addItem("Edep",m_edep);
77 sc = m_tupleMdc->addItem("driftD",m_driftD);
78 // sc = m_tupleMdc->addItem("driftT",m_driftT);
79 sc = m_tupleMdc->addItem("globalT",m_globalT);
80 sc = m_tupleMdc->addItem("theta",m_theta);
81 sc = m_tupleMdc->addItem("enterAngle",m_enterAngle);
82 sc = m_tupleMdc->addItem("driftDNew",m_driftDNew);
83 sc = m_tupleMdc->addItem("driftTNew",m_driftTNew);
84 // sc = m_tupleMdc->addItem("adc",m_adc);
85 // sc = m_tupleMdc->addItem("tdc",m_tdc);
86 }
87 */
88}
static BesMdcGeoParameter * GetGeo(void)

◆ ~BesMdcDigitizer() [1/2]

BesMdcDigitizer::~BesMdcDigitizer ( )

Definition at line 90 of file BesMdcDigitizer.cc.

90{delete digitizerMessenger;}

◆ BesMdcDigitizer() [2/2]

BesMdcDigitizer::BesMdcDigitizer ( G4String  modName)

◆ ~BesMdcDigitizer() [2/2]

BesMdcDigitizer::~BesMdcDigitizer ( )

Member Function Documentation

◆ Digitize() [1/2]

void BesMdcDigitizer::Digitize ( )
virtual

Definition at line 102 of file BesMdcDigitizer.cc.

102 {
103
104 //initialize
105 for(G4int i=0; i<43;i++){
106 for(G4int j=0;j<288;j++){
107 digiPointer[i][j]=-1;
108 }
109 }
110
111 G4int NHits,layerId, cellId, posFlag;
112 G4double edep,driftD,driftT, globalT, theta,cosTheta,enterAngle;
113 G4double mean,sigma,mean1,mean2,sigma1, sigma2, f,sig,delSig, fRandom, driftDNew, driftTNew;
114 G4double tempEff;
115 G4double resLargest,resSmallest,resRatio;//added by liukai
116
117 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
118
119 //hits collection ID
120 G4int THCID=-1;
121 THCID = DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
122
123 //hits collection
124 BesMdcHitsCollection* THC = 0;
125 THC = (BesMdcHitsCollection*) (DigiMan->GetHitsCollection(THCID));
126
127 if(THC){
128 digisCollection=new BesMdcDigisCollection
129 (moduleName, collectionName[0]);
130 NHits=THC->entries();
131 for(G4int i=0;i<NHits;i++){
132 layerId = (*THC)[i]->GetLayerNo();
133 cellId = (*THC)[i]->GetCellNo();
134 edep = (*THC)[i]->GetEdep();
135 driftD = (*THC)[i]->GetDriftD();
136 globalT = (*THC)[i]->GetGlobalT();
137 theta = (*THC)[i]->GetTheta();
138 cosTheta = cos(theta);
139 enterAngle = (*THC)[i]->GetEnterAngle();
140 posFlag = (*THC)[i]->GetPosFlag();
141
142 //Transfer hit pointer to BesMdcCalTransfer
143 mdcCalPointer->SetHitPointer((*THC)[i]);
144
145 //Filter with wire efficiency
146 if(effFlag==0){
147 //tempEff = mdcCalPointer->GetEff();
148 tempEff=mdcTunningSvc->GetEff(layerId,cellId,driftD,cosTheta,posFlag);
149 }else{
150 tempEff = layerEff[layerId];
151 }
152 fRandom=G4UniformRand();
153 if(fRandom>tempEff)continue;
154
155 //cout<<"layerid "<<layerId<<" cellid "<<cellId<<" theta "<<cosTheta<<" enterangle "<<enterAngle<<endl;
156 //Drift distance smear
157 if(smearFlag==0){ //No smear
158 driftDNew = driftD;
159 }else if(smearFlag==1){ //Smear from TuningSvc
160 // mdcTunningSvc->GetRes(layerId,cellId,driftD,cosTheta,posFlag,enterAngle,mean,sigma);
161 //mdcTunningSvc->GetRes2(layerId,cellId,driftD,cosTheta,posFlag,enterAngle,f,mean1,sigma1,mean2,sigma2);
162 mdcTunningSvc->GetRes3(layerId,cellId,driftD,cosTheta,posFlag,enterAngle,f,mean1,sigma1,mean2,sigma2,resLargest,resSmallest,resRatio);
163
164 //driftDNew = Smear(driftD,f,mean1,sigma1,mean2,sigma2);
165 //driftDNew = Smear(driftD-(f*mean1+(1-f)*mean2),f,mean1,sigma1,mean2,sigma2);//new method
166
167 driftDNew = Smear(driftD-(f*mean1+(1-f)*mean2),f,mean1,sigma1,mean2,sigma2,resLargest,resSmallest,resRatio);//----added by liukai 2012-6-4
168
169
170 }else if(smearFlag==2){ //Smear with fixed resolution
171 driftDNew = Smear(driftD);
172 }else{
173 G4cerr<<"MdcDigitizer::worong smearFlag: "<<smearFlag<<G4endl;
174 }
175
176 //Do X-T conversion
177 driftTNew = mdcCalPointer->D2T(driftDNew);
178
179 //Do Q-T correct
180 driftTNew += mdcCalPointer->GetTimeWalk();
181
182 //Add T0
183 driftTNew += mdcCalPointer->GetT0();
184
185 //Add TOF
186 driftTNew += globalT;
187
188 //Signal transfer time on wire
189 // transferT=Transfer(layerId,cellId,hitPosition);
190 //driftTNew+=transferT;
191
192 if(isnan(driftTNew)){
193 G4cout<<"MdcDigitizer::error, driftT is nan"<<G4endl;
194 continue;
195 }
196
197 /*
198 if(m_G4Svc->MdcRootFlag())
199 {
200 m_NHits= NHits;
201 m_layerId= layerId;
202 m_cellId= cellId;
203 m_edep= edep;
204 m_driftD= driftD;
205 // m_driftT= driftT;
206 m_globalT = globalT;
207 m_enterAngle = enterAngle;
208 m_driftDNew = driftDNew;
209 m_driftTNew = driftTNew;
210 m_theta = theta;
211 m_tupleMdc ->write();
212 }
213 */
214 BesMdcDigi* newDigi = new BesMdcDigi();
215 newDigi->SetTrackID((*THC)[i]->GetTrackID());
216 newDigi->SetLayerNo(layerId);
217 newDigi->SetCellNo(cellId);
218 newDigi->SetEdep(edep);
219 newDigi->SetDriftT(driftTNew);
220 G4int NbDigis = digisCollection->insert(newDigi);
221 digiPointer[layerId][cellId]=NbDigis-1;
222 }
223
224 if(noiseFlag==1)AddNoise();
225 if(noiseFlag==2){
226 ifstream readNoiseLevel("$MDCSIMROOT/share/noiselevel.txt");
227 if(!readNoiseLevel.good()){
228 std::cout<<" Error , noiselevel file not exist "<<std::endl;
229 }else{
230 std::cout<<" MdcDigitizer:: Open noiselevel file "<<std::endl;
231 }
232 G4int NLayer=mdcGeoPointer->SignalLayerNo();
233 G4double level;
234 for(G4int i=0;i<NLayer;i++){
235 readNoiseLevel>>level;
236 mixLevel.push_back(level);
237 }
238 AddNoise2();
239 }
240
241 if (verboseLevel>0) {
242 G4cout << "\n-------->digis Collection: in this event they are "
243 << digisCollection->entries()
244 << " digis in the MDC chambers: " << G4endl;
245 digisCollection->PrintAllDigi();
246 }
247 StoreDigiCollection(digisCollection);
248 }
249
250}
TTree * sigma
double cos(const BesAngle a)
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
double D2T(double driftDNew)
void SetHitPointer(BesMdcHit *hit)
double GetTimeWalk(void)
double GetEff(int layerId, int cellId, double driftD, double cosTheta, int posFlag)
double GetRes3(int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &f, double &mean1, double &sigma1, double &mean2, double &sigma2, double &ResLargest, double &ResSmallest, double &ResRatio)

◆ Digitize() [2/2]

virtual void BesMdcDigitizer::Digitize ( )
virtual

◆ SetEff() [1/2]

void BesMdcDigitizer::SetEff ( G4int  layer,
G4double  eff 
)

Definition at line 92 of file BesMdcDigitizer.cc.

92 {
93 if(layer==-1){
94 for(G4int i=0; i<43;i++){
95 layerEff[i]=eff;
96 }
97 }else{
98 layerEff[layer]=eff;
99 }
100}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetEff() [2/2]

void BesMdcDigitizer::SetEff ( G4int  layer,
G4double  eff 
)

◆ SetEffFlag() [1/2]

void BesMdcDigitizer::SetEffFlag ( G4int  flag)
inline

◆ SetEffFlag() [2/2]

void BesMdcDigitizer::SetEffFlag ( G4int  flag)
inline

◆ SetMdcDRes() [1/2]

void BesMdcDigitizer::SetMdcDRes ( G4double  res)
inline

Definition at line 44 of file InstallArea/include/MdcSim/MdcSim/BesMdcDigitizer.hh.

44{mdcDRes=res;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetMdcDRes() [2/2]

void BesMdcDigitizer::SetMdcDRes ( G4double  res)
inline

Definition at line 44 of file Simulation/BOOST/MdcSim/MdcSim-00-00-73/MdcSim/BesMdcDigitizer.hh.

44{mdcDRes=res;}

◆ SetNoiseFlag() [1/2]

void BesMdcDigitizer::SetNoiseFlag ( G4int  flag)
inline

◆ SetNoiseFlag() [2/2]

void BesMdcDigitizer::SetNoiseFlag ( G4int  flag)
inline

◆ SetNoiseLevel() [1/2]

void BesMdcDigitizer::SetNoiseLevel ( G4double  level)
inline

Definition at line 41 of file InstallArea/include/MdcSim/MdcSim/BesMdcDigitizer.hh.

41{noiseLevel=level;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetNoiseLevel() [2/2]

void BesMdcDigitizer::SetNoiseLevel ( G4double  level)
inline

Definition at line 41 of file Simulation/BOOST/MdcSim/MdcSim-00-00-73/MdcSim/BesMdcDigitizer.hh.

41{noiseLevel=level;}

◆ SetNoiseType() [1/2]

void BesMdcDigitizer::SetNoiseType ( G4int  type)
inline

Definition at line 40 of file InstallArea/include/MdcSim/MdcSim/BesMdcDigitizer.hh.

40{noiseType=type;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetNoiseType() [2/2]

void BesMdcDigitizer::SetNoiseType ( G4int  type)
inline

Definition at line 40 of file Simulation/BOOST/MdcSim/MdcSim-00-00-73/MdcSim/BesMdcDigitizer.hh.

40{noiseType=type;}

◆ SetSmearFlag() [1/2]

void BesMdcDigitizer::SetSmearFlag ( G4int  flag)
inline

◆ SetSmearFlag() [2/2]

void BesMdcDigitizer::SetSmearFlag ( G4int  flag)
inline

The documentation for this class was generated from the following files: