BOSS 8.0.0
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)
 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/3]

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++ ) { layerEff.push_back( 1. ); }
38 collectionName.push_back( "BesMdcDigisCollection" );
39 digitizerMessenger = new BesMdcDigitizerMessenger( this );
40 mdcGeoPointer = BesMdcGeoParameter::GetGeo();
41 mdcCalPointer = new BesMdcCalTransfer;
42
43 StatusCode sc = Gaudi::svcLocator()->service( "G4Svc", m_G4Svc );
44 if ( !sc.isSuccess() ) G4cout << " MdcDigitizer::Error,could not open G4Svc" << G4endl;
45
46 sc = Gaudi::svcLocator()->service( "MdcTunningSvc", mdcTunningSvc );
47 if ( !sc.isSuccess() )
48 { G4cout << " MdcDigitizer::Error,could not open Mdc Tunning Service" << G4endl; }
49 else { G4cout << " MdcDigitizer:: Open Mdc Tunning Service" << G4endl; }
50
51 std::string noiseFile = m_G4Svc->GetMdcNoiseFile();
52 f = new TFile( noiseFile.c_str() );
53 h1 = (TH1F*)f->Get( "h703" );
54 h2 = (TH1F*)f->Get( "h501" );
55 h3 = (TH1F*)f->Get( "h801" );
56 /*
57 //get Mdc Ntuple from G4Svc
58 if(m_G4Svc->MdcRootFlag())
59 {
60 m_tupleMdc = m_G4Svc->GetTupleMdc();
61 sc = m_tupleMdc->addItem("NHits",m_NHits);
62 sc = m_tupleMdc->addItem("LayerId",m_layerId);
63 sc = m_tupleMdc->addItem("cellId",m_cellId);
64 sc = m_tupleMdc->addItem("Edep",m_edep);
65 sc = m_tupleMdc->addItem("driftD",m_driftD);
66 // sc = m_tupleMdc->addItem("driftT",m_driftT);
67 sc = m_tupleMdc->addItem("globalT",m_globalT);
68 sc = m_tupleMdc->addItem("theta",m_theta);
69 sc = m_tupleMdc->addItem("enterAngle",m_enterAngle);
70 sc = m_tupleMdc->addItem("driftDNew",m_driftDNew);
71 sc = m_tupleMdc->addItem("driftTNew",m_driftTNew);
72 // sc = m_tupleMdc->addItem("adc",m_adc);
73 // sc = m_tupleMdc->addItem("tdc",m_tdc);
74 }
75 */
76}
static BesMdcGeoParameter * GetGeo(void)

◆ ~BesMdcDigitizer() [1/3]

BesMdcDigitizer::~BesMdcDigitizer ( )

Definition at line 78 of file BesMdcDigitizer.cc.

78{ delete digitizerMessenger; }

◆ BesMdcDigitizer() [2/3]

BesMdcDigitizer::BesMdcDigitizer ( G4String modName)

◆ ~BesMdcDigitizer() [2/3]

BesMdcDigitizer::~BesMdcDigitizer ( )

◆ BesMdcDigitizer() [3/3]

BesMdcDigitizer::BesMdcDigitizer ( G4String modName)

◆ ~BesMdcDigitizer() [3/3]

BesMdcDigitizer::~BesMdcDigitizer ( )

Member Function Documentation

◆ Digitize() [1/3]

void BesMdcDigitizer::Digitize ( )
virtual

Definition at line 88 of file BesMdcDigitizer.cc.

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

◆ Digitize() [2/3]

virtual void BesMdcDigitizer::Digitize ( )
virtual

◆ Digitize() [3/3]

virtual void BesMdcDigitizer::Digitize ( )
virtual

◆ SetEff() [1/3]

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

Definition at line 80 of file BesMdcDigitizer.cc.

80 {
81 if ( layer == -1 )
82 {
83 for ( G4int i = 0; i < 43; i++ ) { layerEff[i] = eff; }
84 }
85 else { layerEff[layer] = eff; }
86}

◆ SetEff() [2/3]

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

◆ SetEff() [3/3]

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

◆ SetEffFlag() [1/3]

void BesMdcDigitizer::SetEffFlag ( G4int flag)
inline

◆ SetEffFlag() [2/3]

void BesMdcDigitizer::SetEffFlag ( G4int flag)
inline

Definition at line 45 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

45{ effFlag = flag; }

◆ SetEffFlag() [3/3]

void BesMdcDigitizer::SetEffFlag ( G4int flag)
inline

Definition at line 45 of file Simulation/BOOST/MdcSim/include/MdcSim/BesMdcDigitizer.hh.

45{ effFlag = flag; }

◆ SetMdcDRes() [1/3]

void BesMdcDigitizer::SetMdcDRes ( G4double res)
inline

Definition at line 43 of file InstallArea/x86_64-el9-gcc13-dbg/include/MdcSim/BesMdcDigitizer.hh.

43{ mdcDRes = res; }

◆ SetMdcDRes() [2/3]

void BesMdcDigitizer::SetMdcDRes ( G4double res)
inline

Definition at line 43 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

43{ mdcDRes = res; }

◆ SetMdcDRes() [3/3]

void BesMdcDigitizer::SetMdcDRes ( G4double res)
inline

Definition at line 43 of file Simulation/BOOST/MdcSim/include/MdcSim/BesMdcDigitizer.hh.

43{ mdcDRes = res; }

◆ SetNoiseFlag() [1/3]

void BesMdcDigitizer::SetNoiseFlag ( G4int flag)
inline

Definition at line 38 of file InstallArea/x86_64-el9-gcc13-dbg/include/MdcSim/BesMdcDigitizer.hh.

38{ noiseFlag = flag; }

◆ SetNoiseFlag() [2/3]

void BesMdcDigitizer::SetNoiseFlag ( G4int flag)
inline

Definition at line 38 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

38{ noiseFlag = flag; }

◆ SetNoiseFlag() [3/3]

void BesMdcDigitizer::SetNoiseFlag ( G4int flag)
inline

Definition at line 38 of file Simulation/BOOST/MdcSim/include/MdcSim/BesMdcDigitizer.hh.

38{ noiseFlag = flag; }

◆ SetNoiseLevel() [1/3]

void BesMdcDigitizer::SetNoiseLevel ( G4double level)
inline

Definition at line 40 of file InstallArea/x86_64-el9-gcc13-dbg/include/MdcSim/BesMdcDigitizer.hh.

40{ noiseLevel = level; }

◆ SetNoiseLevel() [2/3]

void BesMdcDigitizer::SetNoiseLevel ( G4double level)
inline

Definition at line 40 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

40{ noiseLevel = level; }

◆ SetNoiseLevel() [3/3]

void BesMdcDigitizer::SetNoiseLevel ( G4double level)
inline

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

40{ noiseLevel = level; }

◆ SetNoiseType() [1/3]

void BesMdcDigitizer::SetNoiseType ( G4int type)
inline

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-dbg/include/MdcSim/BesMdcDigitizer.hh.

39{ noiseType = type; }

◆ SetNoiseType() [2/3]

void BesMdcDigitizer::SetNoiseType ( G4int type)
inline

Definition at line 39 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

39{ noiseType = type; }

◆ SetNoiseType() [3/3]

void BesMdcDigitizer::SetNoiseType ( G4int type)
inline

Definition at line 39 of file Simulation/BOOST/MdcSim/include/MdcSim/BesMdcDigitizer.hh.

39{ noiseType = type; }

◆ SetSmearFlag() [1/3]

void BesMdcDigitizer::SetSmearFlag ( G4int flag)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-dbg/include/MdcSim/BesMdcDigitizer.hh.

42{ smearFlag = flag; }

◆ SetSmearFlag() [2/3]

void BesMdcDigitizer::SetSmearFlag ( G4int flag)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-opt/include/MdcSim/BesMdcDigitizer.hh.

42{ smearFlag = flag; }

◆ SetSmearFlag() [3/3]

void BesMdcDigitizer::SetSmearFlag ( G4int flag)
inline

Definition at line 42 of file Simulation/BOOST/MdcSim/include/MdcSim/BesMdcDigitizer.hh.

42{ smearFlag = flag; }

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