BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofDigitizerEcV4.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Description: This is the Digitizer for the MRPC with doubled sided readout
5//Author: An Fenfen
6//Created: Nov, 2015
7
8//---------------------------------------------------------------------------//
9//$Id: BesTofDigitizerEcV4.cc
10
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/Bootstrap.h"
13#include "GaudiKernel/PropertyMgr.h"
14#include "GaudiKernel/IJobOptionsSvc.h"
15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/IDataProviderSvc.h"
17
19#include "BesTofDigi.hh"
20#include "BesTofHit.hh"
21#include "G4DigiManager.hh"
22#include "Randomize.hh"
23#include "TMath.h"
24#include <math.h>
25#include "TNtuple.h"
26#include "TFile.h"
27#include "TH1F.h"
28#include "TROOT.h"
29#include "TSpline.h"
30#include "G4SystemOfUnits.hh"
31#include "G4PhysicalConstants.hh"
32
34{
35 PropertyMgr m_propMgr;
36 m_propMgr.declareProperty("FileName", m_fileName = "mrpc.root");
37 m_propMgr.declareProperty("RootFlag", m_rootFlag = false);
38 m_propMgr.declareProperty("E", m_V = 7000);
39 m_propMgr.declareProperty("Threshold", m_threshold = 5.5e+08);
40
41 m_propMgr.declareProperty("nstep", m_nstep = -1);
42 m_propMgr.declareProperty("E_weight", m_E_weight = -1);
43 m_propMgr.declareProperty("saturationFlag", m_saturationFlag = true);
44 m_propMgr.declareProperty("tdcRes_const", tdcRes_const = -1);
45 m_propMgr.declareProperty("adcRes_const", adcRes_const = -1);
46 m_propMgr.declareProperty("calTdcRes_charge_flag", m_calTdcRes_charge_flag=0);
47 m_propMgr.declareProperty("charge2Time_flag", m_charge2Time_flag=0);
48 m_propMgr.declareProperty("calAdcRes_charge_flag", m_calAdcRes_charge_flag=0);
49
50 IJobOptionsSvc* jobSvc;
51 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
52 jobSvc->setMyProperties("BesTofDigitizerEcV4", &m_propMgr);
53
54 initial();
55
56 if(m_rootFlag)
57 {
58 m_file = new TFile(m_fileName.c_str(), "RECREATE");
59 m_tree = new TTree("mrpc", "mrpc");
60
61 m_tree->Branch("event", &m_event, "event/D");
62 m_tree->Branch("partId", &m_partId, "partId/D");
63 m_tree->Branch("module", &m_module, "module/D");
64 m_tree->Branch("time_leading_sphi", &m_time_leading_sphi, "time_leading_sphi/D");
65 m_tree->Branch("time_leading_xphi", &m_time_leading_xphi, "time_leading_xphi/D");
66 m_tree->Branch("time_trailing_sphi", &m_time_trailing_sphi, "time_trailing_sphi/D");
67 m_tree->Branch("time_trailing_xphi", &m_time_trailing_xphi, "time_trailing_xphi/D");
68 m_tree->Branch("tdcRes", &m_tdcRes, "tdcRes/D");
69 m_tree->Branch("tdcRes_charge", &m_tdcRes_charge, "tdcRes_charge/D");
70 m_tree->Branch("adc", &m_adc, "adc/D");
71 m_tree->Branch("adcRes", &m_adcRes, "adcRes/D");
72 m_tree->Branch("adcRes_charge", &m_adcRes_charge, "adcRes_charge/D");
73 m_tree->Branch("strip", &m_strip, "strip/D");
74 m_tree->Branch("trkIndex", &m_trkIndex, "trkIndex/D");
75 m_tree->Branch("tStart", &m_tStart, "tStart/D");
76 m_tree->Branch("tPropagate_sphi", &m_tPropagate_sphi, "tPropagate_sphi/D");
77 m_tree->Branch("tPropagate_xphi", &m_tPropagate_xphi, "tPropagate_xphi/D");
78 m_tree->Branch("tThreshold", &m_tThreshold, "tThreshold/D");
79 m_tree->Branch("charge", &m_charge, "charge/D");
80 m_tree->Branch("nhit", &m_nhit, "nhit/I");
81 m_tree->Branch("ions_hit", m_ions_hit, "ions_hit[nhit]/D");
82 m_tree->Branch("trkIndex_hit", m_trkIndex_hit, "trkIndex_hit[nhit]/D");
83 m_tree->Branch("pdgCode_hit", m_pdgCode_hit, "pdgCode_hit[nhit]/D");
84 m_tree->Branch("gap_hit", m_gap_hit, "gap_hit[nhit]/D");
85 m_tree->Branch("underStrip_hit", m_underStrip_hit, "underStrip_hit[nhit]/D");
86 m_tree->Branch("locx_hit", m_locx_hit, "locx_hit[nhit]/D");
87 m_tree->Branch("locy_hit", m_locy_hit, "locy_hit[nhit]/D");
88 m_tree->Branch("locz_hit", m_locz_hit, "locz_hit[nhit]/D");
89 m_tree->Branch("x_hit", m_x_hit, "x_hit[nhit]/D");
90 m_tree->Branch("y_hit", m_y_hit, "y_hit[nhit]/D");
91 m_tree->Branch("z_hit", m_z_hit, "z_hit[nhit]/D");
92 m_tree->Branch("px_hit", m_px_hit, "px_hit[nhit]/D");
93 m_tree->Branch("py_hit", m_py_hit, "py_hit[nhit]/D");
94 m_tree->Branch("pz_hit", m_pz_hit, "pz_hit[nhit]/D");
95 }
96}
97
98
100{
101 if(m_rootFlag)
102 {
103 m_file->Write();
104 m_file->Close();
105 }
106}
107
109{
110 m_param = Param();
111 m_param.setPar(m_nstep, m_E_weight, m_V);
112 m_param.print();
113 m_event=-1;
114 partId = -999;
115 module = -999;
116 tdc_sphi = -999;
117 tdc_xphi = -999;
118 if(tdcRes_const<0) tdcRes_const = 38;
119 //45; //sqrt(27*27.+30.*30+20.*20); //ps, 27:TDC; 30:gapNb; 20:cables..
120 tdcRes = -999;
121
122 adc = -999;
123 if(adcRes_const<0) adcRes_const = 27; //ps TDC
124 adcRes = -999;
125
126 time_leading_sphi = -999;
127 time_leading_xphi = -999;
128 time_trailing_sphi = -999;
129 time_trailing_xphi = -999;
130
131 cout<<"Property:"<<endl
132 <<" FileName= "<<m_fileName
133 <<" E= "<<m_V
134 <<" Threshold= "<<m_threshold
135 <<" nstep= "<<m_nstep
136 <<" E_weight= "<<m_E_weight
137 <<" saturationFlag= "<<m_saturationFlag
138 <<" tdcRes_const= "<<tdcRes_const
139 <<" adcRes_const= "<<adcRes_const
140 <<" calTdcRes_charge_flag= "<<m_calTdcRes_charge_flag
141 <<" charge2Time_flag= "<<m_charge2Time_flag
142 <<" calAdcRes_charge_flag= "<<m_calAdcRes_charge_flag
143 <<endl;
144}
145
147{
149 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
150 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
151 m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID));
152 if( !m_THC ) return;
153
154 partId = single_module->GetPartId();
155 module = single_module->GetModule_mrpc();
156 //cout<<"partId= "<<partId<<" module= "<<module<<endl;
157
158 //Process the hits
159 int nstrip = m_param.nstrip;
160 StripStruct stripStruct[12];
161 for(int i=0; i<nstrip; i++)
162 {
163 stripStruct[i].m_param = m_param;
164 stripStruct[i].setPar(m_param.alpha, m_param.eta, m_param.v_drift, m_threshold, m_saturationFlag);
165 }
166
167 BesTofHit* hit;
168 for(unsigned int i=0; i<single_module->GetHitIndexes_mrpc()->size(); i++)
169 {
170 hit = (*m_THC)[ (*(single_module->GetHitIndexes_mrpc()))[i] ];
171 m_event = hit->GetEvent();
172
173 HitStruct hitStruct;
174 hitStruct.m_param = m_param;
175 hitStruct.trkIndex = hit->GetG4Index();
176 hitStruct.pdgCode = hit->GetPDGcode();
177 hitStruct.ions = hit->GetIons();
178 hitStruct.strip = calStrip(hit->GetLocPos().z()/mm);
179 hitStruct.underStrip = underStrip(hit->GetLocPos().x()/mm, hit->GetLocPos().z()/mm);
180 hitStruct.gap = hit->GetGapNb();
181 hitStruct.glbTime = hit->GetTime()/ns;
182 hitStruct.locx = hit->GetLocPos().x()/mm;
183 hitStruct.locy = hit->GetLocPos().y()/mm;
184 hitStruct.locz = hit->GetLocPos().z()/mm;
185 hitStruct.x = hit->GetPos().x()/mm;
186 hitStruct.y = hit->GetPos().y()/mm;
187 hitStruct.z = hit->GetPos().z()/mm;
188 hitStruct.px = hit->GetMomentum().x()/(GeV/(3e+08*m/s));
189 hitStruct.py = hit->GetMomentum().y()/(GeV/(3e+08*m/s));
190 hitStruct.pz = hit->GetMomentum().z()/(GeV/(3e+08*m/s));
191 //hitStruct.print();
192
193 if(hitStruct.ions>0 && hitStruct.glbTime>0)
194 {
195 stripStruct[hitStruct.strip].hitStructCol.push_back(hitStruct);
196 }
197 }
198
199 //test multihit, study the lower peak in charge
200 int hitSize=0;
201
202 for(int i=0; i<nstrip; i++)
203 {
204 if(stripStruct[i].hitStructCol.size()==0) continue;
205 stripStruct[i].strip = i;
206 stripStruct[i].calFirstHit();
207 stripStruct[i].avalanche();
208 //stripStruct[i].print();
209
210 if(stripStruct[i].tThreshold<=0) continue;
211
212 tdc_sphi = stripStruct[i].tStart + stripStruct[i].tThreshold + stripStruct[i].tPropagate_sphi;
213 tdc_xphi = stripStruct[i].tStart + stripStruct[i].tThreshold + stripStruct[i].tPropagate_xphi;
214
215 double tdcRes_charge;
216 if(m_calTdcRes_charge_flag==0)
217 {
218 tdcRes_charge = calTdcRes_charge(stripStruct[i].charge*1000); //ps, charge in fC
219 }
220 else if(m_calTdcRes_charge_flag==1)
221 {
222 tdcRes_charge = calTdcRes_charge1(stripStruct[i].charge*1000);
223 }
224 else if(m_calTdcRes_charge_flag==2)
225 {
226 tdcRes_charge = 0;
227 }
228
229 tdcRes = sqrt(tdcRes_charge*tdcRes_charge+tdcRes_const*tdcRes_const)/1000; //ns
230
231 tdc_sphi = G4RandGauss::shoot(tdc_sphi, tdcRes);
232 tdc_xphi = G4RandGauss::shoot(tdc_xphi, tdcRes);
233
234 if(m_charge2Time_flag==0)
235 {
236 adc = charge2Time(stripStruct[i].charge*1000); //ns, charge in fC
237 }
238 else if(m_charge2Time_flag==1)
239 {
240 adc = charge2Time1(stripStruct[i].charge*1000);
241 }
242
243 double adcRes_charge;
244 if(m_calAdcRes_charge_flag==0)
245 {
246 adcRes_charge = calAdcRes_charge(stripStruct[i].charge*1000); //ps, charge in fC
247 }
248 else if(m_calAdcRes_charge_flag==1)
249 {
250 adcRes_charge = calAdcRes_charge1(stripStruct[i].charge*1000);
251 }
252 else if(m_calAdcRes_charge_flag==2)
253 {
254 adcRes_charge = 0;
255 }
256
257 adcRes = sqrt(adcRes_charge*adcRes_charge+adcRes_const*adcRes_const)/1000;
258 adc = G4RandGauss::shoot(adc, adcRes);
259 if(adc<0) adc=0;
260
261 time_leading_sphi = tdc_sphi;
262 time_leading_xphi = tdc_xphi;
263 time_trailing_sphi = tdc_sphi+adc;
264 time_trailing_xphi = tdc_xphi+adc;
265
266
267 //save digi information
268 BesTofDigi *digi = new BesTofDigi;
269 digi->SetTrackIndex(stripStruct[i].trkIndex);
270 digi->SetPartId(partId);
271 digi->SetModule(module);
272 digi->SetStrip(stripStruct[i].strip);
273 int mo = (partId-3)*36+module;
274 int st = stripStruct[i].strip;
275 if(m_param.deadChannel[mo][st]==0 || m_param.deadChannel[mo][st]==2)
276 {
277 //Set dead channel
278 digi->SetForwT1(-999);
279 digi->SetForwT2(-999);
280 }
281 else
282 {
283 digi->SetForwT1(time_leading_sphi);
284 digi->SetForwT2(time_trailing_sphi);
285 }
286 if(m_param.deadChannel[mo][st]==1 || m_param.deadChannel[mo][st]==2)
287 {
288 digi->SetBackT1(-999);
289 digi->SetBackT2(-999);
290 }
291 else
292 {
293 digi->SetBackT1(time_leading_xphi);
294 digi->SetBackT2(time_trailing_xphi);
295 }
296 m_besTofDigitsCollection->insert(digi);
297 //cout<<"Print digi info: "
298 // <<" partId= "<<partId
299 // <<" module= "<<module
300 // <<" strip= "<<stripStruct[i].strip
301 // <<" time_leading_sphi= "<<time_leading_sphi
302 // <<" time_leading_xphi= "<<time_leading_xphi
303 // <<" time_trailing_sphi= "<<time_trailing_sphi
304 // <<" time_trailing_xphi= "<<time_trailing_xphi
305 // <<endl;
306
307
308 //save digi information
309 if(m_rootFlag)
310 {
311 m_partId = partId;
312 m_module = module;
313 m_time_leading_sphi = time_leading_sphi;
314 m_time_leading_xphi = time_leading_xphi;
315 m_time_trailing_sphi = time_trailing_sphi;
316 m_time_trailing_xphi = time_trailing_xphi;
317 m_tdcRes = tdcRes;
318 m_tdcRes_charge = tdcRes_charge;
319 m_adc = adc;
320 m_adcRes = adcRes;
321 m_adcRes_charge = adcRes_charge;
322
323 m_strip = stripStruct[i].strip;
324 m_trkIndex = stripStruct[i].trkIndex;
325 m_tStart = stripStruct[i].tStart;
326 m_tPropagate_sphi = stripStruct[i].tPropagate_sphi;
327 m_tPropagate_xphi = stripStruct[i].tPropagate_xphi;
328 m_tThreshold = stripStruct[i].tThreshold;
329 m_charge = stripStruct[i].charge;
330
331 m_nhit = stripStruct[i].hitStructCol.size();
332 //cout<<"m_nhit= "<<m_nhit<<endl;
333 for(int j=0; j<m_nhit; j++)
334 {
335 m_ions_hit[j] = stripStruct[i].hitStructCol[j].ions;
336 m_trkIndex_hit[j] = stripStruct[i].hitStructCol[j].trkIndex;
337 m_pdgCode_hit[j] = stripStruct[i].hitStructCol[j].pdgCode;
338 m_gap_hit[j] = stripStruct[i].hitStructCol[j].gap;
339 m_underStrip_hit[j] = stripStruct[i].hitStructCol[j].underStrip;
340 m_locx_hit[j] = stripStruct[i].hitStructCol[j].locx;
341 m_locy_hit[j] = stripStruct[i].hitStructCol[j].locy;
342 m_locz_hit[j] = stripStruct[i].hitStructCol[j].locz;
343 m_x_hit[j] = stripStruct[i].hitStructCol[j].x;
344 m_y_hit[j] = stripStruct[i].hitStructCol[j].y;
345 m_z_hit[j] = stripStruct[i].hitStructCol[j].z;
346 m_px_hit[j] = stripStruct[i].hitStructCol[j].px;
347 m_py_hit[j] = stripStruct[i].hitStructCol[j].py;
348 m_pz_hit[j] = stripStruct[i].hitStructCol[j].pz;
349 }
350 m_tree->Fill();
351 }
352 }
353}
354
356{
357 int strip=-1;
358 double stripWidth = m_param.strip_z+m_param.strip_gap; //Strip spread: (24+3)mm
359 int nstrip = m_param.nstrip;
360 //the offset between strip coordinate and gas SD: 0.5
361 double length = locZ+stripWidth*nstrip/2-0.5;
362 if(length<=0)
363 {
364 strip=0;
365 }
366 else if(length<stripWidth*nstrip)
367 {
368 for(int i=0; i<nstrip; i++)
369 {
370 if(length>i*stripWidth && length<(i+1)*stripWidth)
371 {
372 strip = i;
373 break;
374 }
375 }
376 }
377 else
378 {
379 strip=nstrip-1;
380 }
381 if(strip<0) strip=0;
382 if(strip>nstrip-1) strip=nstrip-1;
383
384 return strip;
385}
386
387bool BesTofDigitizerEcV4::underStrip(double locX, double locZ)
388{
389 bool flag = 0;
390 int strip=-1;
391 double stripWidth = m_param.strip_z+m_param.strip_gap; //Strip spread: (24+3)mm
392 int nstrip = m_param.nstrip;
393 //the offset between strip coordinate and gas SD: 0.5
394 double length = locZ+stripWidth*nstrip/2-0.5;
395 if(length<stripWidth*nstrip)
396 {
397 for(int i=0; i<nstrip; i++)
398 {
399 if(length>i*stripWidth && length<(i+1)*stripWidth)
400 {
401 strip = i;
402 if(length>i*stripWidth+m_param.strip_gap/2 && length<(i+1)*stripWidth-m_param.strip_gap/2
403 && locX>-m_param.strip_x[strip]/2 && locX<m_param.strip_x[strip]/2) flag=1;
404 break;
405 }
406 }
407 }
408
409 return flag;
410}
411
412
414{
415 for(unsigned int i=0; i<hitStructCol.size(); i++)
416 {
417 if(hitStructCol[i].glbTime<tStart)
418 {
419 tStart = hitStructCol[i].glbTime;
420 trkIndex = hitStructCol[i].trkIndex;
421 hitStructCol[i].calTPropagate();
422 tPropagate_sphi = hitStructCol[i].tPropagate_sphi;
423 tPropagate_xphi = hitStructCol[i].tPropagate_xphi;
424 }
425 }
426}
427
429{
430 if(strip<0 || strip>m_param.nstrip-1)
431 {
432 cout<<"!! BesTofDigitizerEcV4::HitStruct::calTPropagate Wrong Strip !!!"<<endl;
433 return;
434 }
435
436 //It can be minus, consistent with calibration
437 double length_sphi = m_param.strip_x[strip]/2-locx; //mm
438 tPropagate_sphi = abs(length_sphi)/v_propagate;
439
440 double length_xphi = m_param.strip_x[strip]/2+locx; //mm
441 tPropagate_xphi = abs(length_xphi)/v_propagate;
442}
443
445{
446 //This calculation depends on the arangements of the gasLayer order and the turnover of gasContainer.
447 //all modules have the same local y trends: y larger, 11->0
448 //In units of mm
449 double length=0;
450 if(gap>=0 && gap<m_param.ngap/2) length = m_param.gapWidth/2+locy;
451 else if(gap<m_param.ngap) length = m_param.gapWidth/2-locy;
452 else
453 {
454 cout<<"BesTofDigitizerEcV4::StripStruct::calAvaLength Wrong gap calculation !!!"<<endl;
455 return -999.0;
456 }
457
458 return length;
459}
460
462{
463 //process each hit
464 for(unsigned int i=0; i<hitStructCol.size(); i++)
465 {
466 hitStructCol[i].ava_pos.clear();
467 hitStructCol[i].ava_num.clear();
468
469 hitStructCol[i].ava_pos[0] = hitStructCol[i].calAvaLength();
470 hitStructCol[i].ava_num[0] = hitStructCol[i].ions;
471 //cout<<"i= "<<i<<" gap= "<<hitStructCol[i].gap<<" initial pos= "<<hitStructCol[i].ava_pos[0]<<endl;
472 for(int j=1; j<m_param.nstep; j++)
473 {
474 hitStructCol[i].ava_pos[j] = hitStructCol[i].ava_pos[j-1] + m_param.stepWidth;
475 if(saturationFlag==true && hitStructCol[i].ava_num[j-1]>1.5e+07) //saturation e+07~e+08, ~2pC, Reather limit
476 {
477 hitStructCol[i].ava_num[j] = hitStructCol[i].ava_num[j-1];
478 }
479 else
480 {
481 hitStructCol[i].ava_num[j] = calNextN(hitStructCol[i].ava_num[j-1]);
482 }
483 if(hitStructCol[i].ava_pos[j]>m_param.gapWidth) break;
484 }
485 }
486
487 //decide threshold and charge
488 bool over_threshold = false;
489 long int sum = 0;
490 for(int i=0; i<m_param.nstep; i++)
491 {
492 for(unsigned int j=0; j<hitStructCol.size(); j++)
493 {
494 if(i<hitStructCol[j].ava_pos.size() && hitStructCol[j].ava_pos[i]<m_param.gapWidth)
495 {
496 sum += hitStructCol[j].ava_num[i];
497 }
498 }
499 //cout<<"sum= "<<sum<<" avaSize= "<<hitStructCol.size()<<endl;
500
501 if(over_threshold==false)
502 {
503 if(sum>threshold)
504 {
505 over_threshold = true;
506 tThreshold = (m_param.gapWidth)/(m_param.nstep)/v_drift*(i+1);
507 }
508 }
509 }
510
511 charge = sum*(m_param.E_weight)*(v_drift)*(m_param.eCharge)*(m_param.gapWidth)/(m_param.nstep)/v_drift;
512}
513
514
516{
517 if(num<150)
518 {
519 long int nextN = 0;
520 double rdm;
521 for(int i=0; i<num; i++)
522 {
523 rdm = G4UniformRand();
524 nextN += multiply(rdm);
525 }
526 return nextN;
527 }
528 else
529 {
530 double nbar = exp((alpha-eta)*m_param.stepWidth);
531 double sigma = calSigma();
532 double mean = num*nbar;
533 double resolution = G4RandGauss::shoot(0,(sqrt(num)*sigma));
534 long int nextN = mean+resolution;
535 return nextN;
536 }
537}
538
540{
541 double nbar = exp((alpha-eta)*m_param.stepWidth);
542 double k = eta/alpha;
543 double rdm_border = k*(nbar-1)/(nbar-k);
544 if(rdm<rdm_border)
545 {
546 return 0;
547 }
548 else
549 {
550 long int number = 1.+1./log((nbar-1.)/(nbar-k))*log((nbar-k)*(rdm-1)/(k-1)/nbar);
551 return number;
552 }
553}
554
556{
557 double nbar = exp((alpha-eta)*m_param.stepWidth);
558 double k = eta/alpha;
559 double sigma = sqrt((1+k)/(1-k)*nbar*(nbar-1));
560 return sigma;
561}
562
564{
565 double time=0;
566 if( charge_fC<250)
567 {
568 time = 100.764*exp(-charge_fC*0.0413966+0.377154)+ 13.814;
569 }
570 else
571 {
572 time = 12.8562+0.000507299*charge_fC;
573 }
574 if(time<0) time=0;
575 return time; //ps
576}
577
578double BesTofDigitizerEcV4::charge2Time(double charge_fC)
579{
580 double time=0;
581 time=-120.808/log(charge_fC*30.1306)+26.6024; //ns
582 if(time<0) time=0;
583 return time;
584}
585
587{
588 double time=0;
589 if(charge_fC<250)
590 {
591 time = 72.6005*exp(-charge_fC*0.0302626 + 1.49059) + 40.8627;
592 }
593 else
594 {
595 time = 32.6233+0.00404149*charge_fC;
596 }
597 if(time<0) time=0;
598 return time; //ps
599}
600
602{
603 double result =0;
604 if( charge_fC > 50.)
605 {
606 result = 67.6737*exp(-charge_fC/50.9995-0.27755)+9.06223;
607 }
608 else
609 {
610 result = 176.322-2.98345*charge_fC;
611 }
612 if(result<0) result=0;
613 return result; //ps
614}
615
616double BesTofDigitizerEcV4::charge2Time1(double charge_fC)
617{
618 double time=0;
619 time=-4.50565/log(charge_fC*0.0812208)+16.6653; //ns
620 if(time<0) time=0;
621 return time;
622}
623
625{
626 double time = 64.3326*exp(-charge_fC/25.4638 + 0.944184)+19.4846;
627 if(time<0) time=0;
628 return time; //ps
629}
630
631
636
637//in units of mm or ns
639{
640 trkIndex = -999.0;
641 pdgCode = -999.0;
642 ions = -999.0;
643 strip = -999.0;
644 gap = -999.0;
645 glbTime = -999.0;
646 locx = -999.0;
647 locy = -999.0;
648 locz = -999.0;
649 x = -999.0;
650 y = -999.0;
651 z = -999.0;
652 px = -999.0;
653 py = -999.0;
654 pz = -999.0;
655 v_propagate = 0.5*0.299792458e+3; //mm/ns
656 tPropagate_sphi = -999.0;
657 tPropagate_xphi = -999.0;
658}
659
664
666{
667 //properties to get
668 strip = -999.0;
669 trkIndex = -999.0;
670 tStart = 99999.0;
671 tPropagate_sphi = -999.0;
672 tPropagate_xphi = -999.0;
673 tThreshold = -999.0;
674 charge = -999.0;
675
676 //parameters to tune
677 E = 106;
678 alpha = 144800./1000; //-999.0; /mm^-1
679 eta = 5013./1000; //-999.0; /mm^-1
680 threshold = 1.5e+08; //Correspond to induced charge of 15 fC
681 v_drift = 210.9e-3; // mm/ns
682
683 hitStructCol.clear();
684}
685
686void BesTofDigitizerEcV4::StripStruct::setPar(double alpha_n, double eta_n, double drift_n, double threshold_n, bool saturationFlag_n)
687{
688 alpha = alpha_n;
689 eta = eta_n;
690 v_drift = drift_n;
691 threshold = threshold_n;
692
693 saturationFlag = saturationFlag_n;
694}
695
696void BesTofDigitizerEcV4::Param::setPar(int nstep_n, double E_weight_n, double E_n)
697{
698 if(nstep_n>0) nstep = nstep_n;
699 if(E_weight_n>0) E_weight = E_weight_n;
700
701 E = E_n;
702 double E_eff = E/1000*2/6/(gapWidth/10); //kV/cm
703 alpha = getAlpha(E_eff); //mm^-1
704 eta = getEta(E_eff); //mm^-1
705 v_drift = getV(E_eff); //mm/ns
706}
707
709{
710 //parameters fixed
712 nstrip = 12;
713 nmodule = 72;
714 std::stringstream ss;
715 for(int i=0; i<nstrip; i++)
716 {
717 ss.str("");
718 ss<<"strip_x["<<i<<"]";
719 strip_x[i] = tofPara->Get(ss.str().c_str()); //mm
720 }
721 strip_z = tofPara->Get("strip_z");
722 strip_gap = tofPara->Get("strip_gap");
723
724 ngap = 12;
725 gapWidth = 0.22; //mm
726 nstep = 200;
727 stepWidth = gapWidth/nstep;
728 E_weight = 1./(6.*0.22+(5.*0.4+2*0.55)/3.7); //V/mm
729 eCharge = 1.60217733e-7; //pC
730 tofPara->Get_deadChannel(deadChannel);
731
732 //print();
733}
734
736{
737 //electric field: kV/cm; alpha: mm-1
738 //kV/cm
739 double e[22] =
740 {
741 65,
742 70 ,
743 75 ,
744 80 ,
745 85 ,
746 90 ,
747 95 ,
748 100 ,
749 102 ,
750 104 ,
751 106 ,
752 108 ,
753 110 ,
754 112 ,
755 114 ,
756 116 ,
757 118 ,
758 120 ,
759 125 ,
760 130 ,
761 135 ,
762 140
763 };
764
765 //mm-1
766 double alpha[22]=
767 {
768 383.5/10 ,
769 471 /10 ,
770 564.5/10 ,
771 663.6/10 ,
772 777.1/10 ,
773 877 /10 ,
774 990.8/10 ,
775 1106 /10 ,
776 1154 /10 ,
777 1199 /10 ,
778 1253 /10 ,
779 1296 /10 ,
780 1344 /10 ,
781 1396 /10 ,
782 1448 /10 ,
783 1502 /10 ,
784 1545 /10 ,
785 1597 /10 ,
786 1726 /10 ,
787 1858 /10 ,
788 1992 /10 ,
789 2124 /10 ,
790 };
791
792 TSpline3* sp_alpha = new TSpline3("sp_alpha", e, alpha, 22);
793 double alphaVal = sp_alpha->Eval(E);
794 delete sp_alpha;
795 return alphaVal;
796}
797
799{
800 //electric field: kV/cm; eta: mm-1
801 //kV/cm
802 double e[22] =
803 {
804 65,
805 70 ,
806 75 ,
807 80 ,
808 85 ,
809 90 ,
810 95 ,
811 100 ,
812 102 ,
813 104 ,
814 106 ,
815 108 ,
816 110 ,
817 112 ,
818 114 ,
819 116 ,
820 118 ,
821 120 ,
822 125 ,
823 130 ,
824 135 ,
825 140
826 };
827
828 //mm-1
829 double eta[22]=
830 {
831 132.6/10 ,
832 117.2/10 ,
833 102.6/10 ,
834 88.26/10 ,
835 79.81/10 ,
836 74.0 /10 ,
837 66.7 /10 ,
838 62.7 /10 ,
839 61.4 /10 ,
840 57.4 /10 ,
841 55.45/10 ,
842 54.35/10 ,
843 52.48/10 ,
844 51.3 /10 ,
845 50.1 /10 ,
846 48.3 /10 ,
847 48.28/10 ,
848 46.00/10 ,
849 44.08/10 ,
850 41.67/10 ,
851 39.97/10 ,
852 38.04/10
853 };
854
855 TSpline3* sp_eta = new TSpline3("sp_eta", e, eta, 22);
856 double etaVal = sp_eta->Eval(E);
857 delete sp_eta;
858 return etaVal;
859}
860
862{
863 //electric field: kV/cm; velocity: mm/ns
864 //kV/cm
865 double e[22] =
866 {
867 65,
868 70 ,
869 75 ,
870 80 ,
871 85 ,
872 90 ,
873 95 ,
874 100 ,
875 102 ,
876 104 ,
877 106 ,
878 108 ,
879 110 ,
880 112 ,
881 114 ,
882 116 ,
883 118 ,
884 120 ,
885 125 ,
886 130 ,
887 135 ,
888 140
889 };
890
891 //mm/ns
892 double v[22]=
893 {
894 130.2/1000 ,
895 138.5/1000 ,
896 146.7/1000 ,
897 155.0/1000 ,
898 163.3/1000 ,
899 171.4/1000 ,
900 179.7/1000 ,
901 187.7/1000 ,
902 191.2/1000 ,
903 194.5/1000 ,
904 197.9/1000 ,
905 201.2/1000 ,
906 204.5/1000 ,
907 207.6/1000 ,
908 210.9/1000 ,
909 214.4/1000 ,
910 217.5/1000 ,
911 220.9/1000 ,
912 228.8/1000 ,
913 237.0/1000 ,
914 244.7/1000 ,
915 252.9/1000
916 };
917
918 TSpline3* sp_v = new TSpline3("sp_v", e, v, 22);
919 double vVal = sp_v->Eval(E);
920 delete sp_v;
921 return vVal;
922}
923
925{
926 cout<<"Fixed parameters: "<<endl;
927 for(int i=0; i<nstrip; i++)
928 {
929 cout<<" strip_x["<<i<<"]= "<<strip_x[i];
930 }
931 for(int i=0; i<nmodule; i++)
932 {
933 for(int j=0; j<nstrip; j++)
934 {
935 if(deadChannel[i][j]!=-999)
936 {
937 cout<<" deadChannel["<<i<<"]["<<j<<"]= "<<deadChannel[i][j];
938 }
939 }
940 }
941
942 cout<<" strip_z= "<<strip_z
943 <<" strip_gap= "<<strip_gap
944 <<" ngap= "<<ngap
945 <<" gapWidth= "<<gapWidth
946 <<" nstep= "<<nstep
947 <<" stepWidth= "<<stepWidth
948 <<" E_weight= "<<E_weight
949 <<" eCharge= "<<eCharge
950 <<" E= "<<E
951 <<" alpha= "<<alpha
952 <<" eta= "<<eta
953 <<" v_drift= "<<v_drift
954 <<endl;
955}
956
958{
959 cout<<"Hit information: "<<endl;
960 cout<<" trkIndex= "<<trkIndex
961 <<" pdgCode= "<<pdgCode
962 <<" ions= "<<pdgCode
963 <<" strip= "<<strip
964 <<" gap= "<<gap
965 <<" glbTime= "<<glbTime
966 <<" locx= "<<locx
967 <<" locy= "<<locy
968 <<" locz= "<<locz
969 <<" x= "<<x
970 <<" y= "<<y
971 <<" z= "<<z
972 <<" px= "<<px
973 <<" py= "<<py
974 <<" pz= "<<pz
975 <<" v_propagate= "<<v_propagate
976 <<" tPropagate_sphi= "<<tPropagate_sphi
977 <<" tPropagate_xphi= "<<tPropagate_xphi
978 <<endl;
979}
980
982{
983 cout<<"Strip information: "<<endl;
984 cout<<" strip= "<<strip
985 <<" trkIndex= "<<trkIndex
986 <<" tStart= "<<tStart
987 <<" tPropagate_sphi= "<<tPropagate_sphi
988 <<" tPropagate_xphi= "<<tPropagate_xphi
989 <<" tThreshold "<<tThreshold
990 <<" charge= "<<charge
991 <<" alpha= "<<alpha
992 <<" eta= "<<eta
993 <<" threshold= "<<threshold
994 <<" v_drift= "<<v_drift
995 <<endl;
996}
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
Definition BesTofDigi.hh:79
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition BesTofHit.hh:116
TTree * sigma
Double_t x[10]
Double_t time
EvtComplex exp(const EvtComplex &c)
const double alpha
XmlRpcServer s
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
void SetForwT1(G4double t1)
Definition BesTofDigi.hh:47
void SetPartId(G4int partId)
Definition BesTofDigi.hh:37
void SetTrackIndex(G4int index)
Definition BesTofDigi.hh:36
void SetForwT2(G4double t2)
Definition BesTofDigi.hh:49
void SetBackT1(G4double t1)
Definition BesTofDigi.hh:48
void SetModule(G4int module)
Definition BesTofDigi.hh:45
void SetBackT2(G4double t2)
Definition BesTofDigi.hh:50
void SetStrip(G4int strip)
Definition BesTofDigi.hh:46
double calTdcRes_charge1(double charge_fC)
double calAdcRes_charge(double charge_fC)
double calAdcRes_charge1(double charge_fC)
bool underStrip(double locX, double locZ)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
double charge2Time1(double charge_fC)
double charge2Time(double charge_fC)
double calTdcRes_charge(double charge_fC)
BesTofDigitsCollection * m_besTofDigitsCollection
BesTofHitsCollection * m_THC
static BesTofGeoParameter * GetInstance()
G4double GetEvent()
Definition BesTofHit.hh:42
G4ThreeVector GetLocPos()
Definition BesTofHit.hh:86
G4int GetIons()
Definition BesTofHit.hh:85
G4int GetPDGcode()
Definition BesTofHit.hh:81
G4double GetTime()
Definition BesTofHit.hh:74
G4ThreeVector GetPos()
Definition BesTofHit.hh:73
G4int GetGapNb()
Definition BesTofHit.hh:87
G4int GetG4Index()
Definition BesTofHit.hh:67
G4ThreeVector GetMomentum()
Definition BesTofHit.hh:77
vector< G4int > * GetHitIndexes_mrpc()
G4int GetPartId()
double y[1000]
float charge
void setPar(int nstep, double E_weight, double E)
void setPar(double alpha_n, double eta_n, double drift_n, double threshold, bool saturationFlag=true)
#define ns(x)
Definition xmltok.c:1504