CGEM BOSS 6.6.5.g
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)
 

Detailed Description

Definition at line 30 of file BesMdcDigitizer.hh.

Constructor & Destructor Documentation

◆ BesMdcDigitizer()

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)
Definition: G4Svc.h:32
std::string GetMdcNoiseFile()
Definition: G4Svc.h:87
Definition: IG4Svc.h:30

◆ ~BesMdcDigitizer()

BesMdcDigitizer::~BesMdcDigitizer ( )

Definition at line 90 of file BesMdcDigitizer.cc.

90{delete digitizerMessenger;}

Member Function Documentation

◆ Digitize()

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 (*THC)[i]->SetDigiId(NbDigis-1);
223 }
224
225 if(noiseFlag==1)AddNoise();
226 if(noiseFlag==2){
227 ifstream readNoiseLevel("$MDCSIMROOT/share/noiselevel.txt");
228 if(!readNoiseLevel.good()){
229 std::cout<<" Error , noiselevel file not exist "<<std::endl;
230 }else{
231 std::cout<<" MdcDigitizer:: Open noiselevel file "<<std::endl;
232 }
233 G4int NLayer=mdcGeoPointer->SignalLayerNo();
234 G4double level;
235 for(G4int i=0;i<NLayer;i++){
236 readNoiseLevel>>level;
237 mixLevel.push_back(level);
238 }
239 AddNoise2();
240 }
241
242 if (verboseLevel>0) {
243 G4cout << "\n-------->digis Collection: in this event they are "
244 << digisCollection->entries()
245 << " digis in the MDC chambers: " << G4endl;
246 digisCollection->PrintAllDigi();
247 }
248 StoreDigiCollection(digisCollection);
249 }
250
251}
double cos(const BesAngle a)
Definition: BesAngle.h:213
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
Definition: BesMdcDigi.hh:59
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
Definition: BesMdcHit.hh:97
double sigma2(0)
double D2T(double driftDNew)
void SetHitPointer(BesMdcHit *hit)
double GetTimeWalk(void)
void SetEdep(G4double de)
Definition: BesMdcDigi.hh:40
void SetCellNo(G4int cell)
Definition: BesMdcDigi.hh:39
void SetDriftT(G4double time)
Definition: BesMdcDigi.hh:41
void SetTrackID(G4int track)
Definition: BesMdcDigi.hh:37
void SetLayerNo(G4int layer)
Definition: BesMdcDigi.hh:38
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)
std::ifstream ifstream
Definition: bpkt_streams.h:44

◆ SetEff()

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().

◆ SetEffFlag()

void BesMdcDigitizer::SetEffFlag ( G4int  flag)
inline

Definition at line 46 of file BesMdcDigitizer.hh.

46{effFlag=flag;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetMdcDRes()

void BesMdcDigitizer::SetMdcDRes ( G4double  res)
inline

Definition at line 44 of file BesMdcDigitizer.hh.

44{mdcDRes=res;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetNoiseFlag()

void BesMdcDigitizer::SetNoiseFlag ( G4int  flag)
inline

Definition at line 39 of file BesMdcDigitizer.hh.

39{noiseFlag=flag;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetNoiseLevel()

void BesMdcDigitizer::SetNoiseLevel ( G4double  level)
inline

Definition at line 41 of file BesMdcDigitizer.hh.

41{noiseLevel=level;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetNoiseType()

void BesMdcDigitizer::SetNoiseType ( G4int  type)
inline

Definition at line 40 of file BesMdcDigitizer.hh.

40{noiseType=type;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().

◆ SetSmearFlag()

void BesMdcDigitizer::SetSmearFlag ( G4int  flag)
inline

Definition at line 43 of file BesMdcDigitizer.hh.

43{smearFlag=flag;}

Referenced by BesMdcDigitizerMessenger::SetNewValue().


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