102 {
103
104
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;
116
117 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
118
119
120 G4int THCID=-1;
121 THCID = DigiMan->GetHitsCollectionID("BesMdcHitsCollection");
122
123
126
127 if(THC){
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
144
145
146 if(effFlag==0){
147
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
156
157 if(smearFlag==0){
158 driftDNew = driftD;
159 }else if(smearFlag==1){
160
161
162 mdcTunningSvc->
GetRes3(layerId,cellId,driftD,cosTheta,posFlag,enterAngle,f,mean1,sigma1,mean2,sigma2,resLargest,resSmallest,resRatio);
163
164
165
166
167 driftDNew = Smear(driftD-(f*mean1+(1-f)*mean2),f,mean1,sigma1,mean2,sigma2,resLargest,resSmallest,resRatio);
168
169
170 }else if(smearFlag==2){
171 driftDNew = Smear(driftD);
172 }else{
173 G4cerr<<"MdcDigitizer::worong smearFlag: "<<smearFlag<<G4endl;
174 }
175
176
177 driftTNew = mdcCalPointer->
D2T(driftDNew);
178
179
181
182
183 driftTNew += mdcCalPointer->
GetT0();
184
185
186 driftTNew += globalT;
187
188
189
190
191
192 if(isnan(driftTNew)){
193 G4cout<<"MdcDigitizer::error, driftT is nan"<<G4endl;
194 continue;
195 }
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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 }
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}
double cos(const BesAngle a)
G4TDigiCollection< BesMdcDigi > BesMdcDigisCollection
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
void NHits(const AList< TMLink > &links, unsigned nHits[50])
returns # of hits per layer.
double D2T(double driftDNew)
void SetHitPointer(BesMdcHit *hit)
void SetEdep(G4double de)
void SetCellNo(G4int cell)
void SetDriftT(G4double time)
void SetTrackID(G4int track)
void SetLayerNo(G4int layer)
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)