BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMdcSD.cc
Go to the documentation of this file.
1#include "MdcSim/BesMdcSD.hh"
2#include "CalibData/Dedx/DedxCalibData.h"
3#include "CalibData/Dedx/DedxSimData.h"
4#include "G4HCofThisEvent.hh"
5#include "G4RunManager.hh"
6#include "G4SDManager.hh"
7#include "G4Step.hh"
8#include "G4Svc/IG4Svc.h"
9#include "G4ThreeVector.hh"
10#include "G4UnitsTable.hh"
11#include "G4ios.hh"
12#include "GaudiKernel/DataSvc.h"
13#include "SimUtil/ReadBoostRoot.hh"
14#include "TFile.h"
15#include "TH1F.h"
16#include "TH2D.h"
17
18#include "GaudiKernel/Bootstrap.h"
19#include "GaudiKernel/IService.h"
20#include "GaudiKernel/Service.h"
21#include "GaudiKernel/SmartDataPtr.h"
22
23#include <iostream>
24
25BesMdcSD::BesMdcSD( G4String name ) : BesSensitiveDetector( name ) {
26 collectionName.insert( "BesMdcHitsCollection" );
27 collectionName.insert( "BesMdcTruthCollection" );
28
29 mdcGeoPointer = BesMdcGeoParameter::GetGeo();
30 mdcCalPointer = new BesMdcCalTransfer;
31
32 StatusCode sc = Gaudi::svcLocator()->service( "MdcGeomSvc", mdcGeomSvc );
33 if ( !sc.isSuccess() ) std::cout << "BesMdcSD::Could not open MdcGeomSvc" << std::endl;
34
35 sc = Gaudi::svcLocator()->service( "G4Svc", m_G4Svc );
36 if ( !sc.isSuccess() ) G4cout << " MdcSD::Error,could not open G4Svc" << G4endl;
37
38 if ( m_G4Svc->GetMdcDedxFlag() == 1 )
39 {
40 G4cout << " MdcSD: Use sampled dedx instead of Geant4 value" << G4endl;
42 }
43
44 // get DedxSimSvc
45 sc = Gaudi::svcLocator()->service( "DedxSimSvc", m_pDedxSimSvc, true );
46 if ( !sc.isSuccess() ) { std::cout << "Could not get DedxSimSvc" << std::endl; }
47
48 // get CalibCurSvc
49 IDedxCurSvc* tmp_dedxCurSvc;
50 sc = Gaudi::svcLocator()->service( "DedxCurSvc", m_pDedxCurSvc, true );
51 if ( !sc.isSuccess() ) { std::cout << "Could not get DedxCurSvc" << std::endl; }
52
53 if ( m_G4Svc->MdcRootFlag() )
54 {
55 m_tupleMdc = m_G4Svc->GetTupleMdc();
56 sc = m_tupleMdc->addItem( "betaGamma", m_betaGamma );
57 sc = m_tupleMdc->addItem( "fitval", m_fitval );
58 sc = m_tupleMdc->addItem( "dedx", m_dedx );
59 sc = m_tupleMdc->addItem( "de", m_de );
60 // sc = m_tupleMdc->addItem("length",m_length);
61 // sc = m_tupleMdc->addItem("random",m_random);
62 sc = m_tupleMdc->addItem( "charge", m_charge );
63 sc = m_tupleMdc->addItem( "costheta", m_costheta );
64 }
65}
66
68
69void BesMdcSD::Initialize( G4HCofThisEvent* HCE ) {
70 hitsCollection = new BesMdcHitsCollection( SensitiveDetectorName, collectionName[0] );
71 static G4int HCID = -1;
72 if ( HCID < 0 )
73 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[0] ); }
74 HCE->AddHitsCollection( HCID, hitsCollection );
75 G4int i, j;
76 for ( i = 0; i < 43; i++ )
77 {
78 for ( j = 0; j < 288; j++ )
79 {
80 hitPointer[i][j] = -1;
81 truthPointer[i][j] = -1;
82 }
83 }
84}
85
86// for MC Truth
87void BesMdcSD::BeginOfTruthEvent( const G4Event* evt ) {
88 truthCollection = new BesMdcHitsCollection( SensitiveDetectorName, collectionName[1] );
89 // G4cout<<" begin event "<<evt->GetEventID()<<G4endl;
90}
91
92void BesMdcSD::EndOfTruthEvent( const G4Event* evt ) {
93 static G4int HLID = -1;
94 if ( HLID < 0 )
95 { HLID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[1] ); }
96 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
97 HCE->AddHitsCollection( HLID, truthCollection );
98}
99
100G4bool BesMdcSD::ProcessHits( G4Step* aStep, G4TouchableHistory* ) {
101 G4Track* gTrack = aStep->GetTrack();
102
103 G4double globalT =
104 gTrack->GetGlobalTime(); // Time since the event in which the track belongs is created
105 if ( std::isnan( globalT ) )
106 {
107 G4cout << "MdcSD:error, globalT is nan " << G4endl;
108 return false;
109 }
110 if ( globalT > 2000 ) return false; // MDC T window is 2 microsecond
111
112 // skip neutral tracks
113 G4int charge = gTrack->GetDefinition()->GetPDGCharge();
114 if ( charge == 0 ) return false;
115
116 // skip no energy deposit tracks
117 G4double stepLength = aStep->GetStepLength();
118 if ( stepLength == 0 )
119 {
120 // G4cout<<"step length equal 0!!"<<G4endl;
121 return false;
122 }
123
124 G4double edep = aStep->GetTotalEnergyDeposit() / stepLength;
125 if ( edep == 0. ) return false;
126
127 // get position of the track at the beginning and at the end of step
128 G4StepPoint* prePoint = aStep->GetPreStepPoint();
129 G4StepPoint* postPoint = aStep->GetPostStepPoint();
130
131 // get position coordinate
132 G4ThreeVector pointIn = prePoint->GetPosition();
133 G4ThreeVector pointOut = postPoint->GetPosition();
134
135 // get physical volumes
136 const G4VTouchable* touchable = prePoint->GetTouchable();
137 G4VPhysicalVolume* volume = touchable->GetVolume( 0 );
138
139 G4double driftD = 0;
140 G4double driftT = 0;
141 G4double edepTemp = 0;
142 G4double lengthTemp = 0;
143 G4int cellId = 0;
144 G4int layerId = touchable->GetVolume( 1 )->GetCopyNo();
145 if ( volume->IsReplicated() ) { cellId = touchable->GetReplicaNumber(); }
146 else { cellId = touchable->GetVolume( 0 )->GetCopyNo(); }
147 if ( layerId == 18 && ( cellId == 27 || cellId == 42 ) ) return false; // no sense wire
148
149 if ( ReadBoostRoot::GetMdc() == 2 )
150 { // gdml
151 // layerId 0-35 -> CopyNo 0-35 in gdml
152 // layerId 36-42 -> CopyNo (36,37),(38,39),...(48,49)
153 if ( layerId >= 36 ) layerId = 36 + ( layerId - 36 ) / 2;
154 }
155
156 G4double halfLayerLength = mdcGeomSvc->Layer( layerId )->Length() / 2.;
157 if ( ( ( fabs( pointIn.z() ) - halfLayerLength ) > -7. ) &&
158 ( ( fabs( pointOut.z() ) - halfLayerLength ) > -7. ) )
159 return false; // Out sensitive area
160
161 G4int trackID = gTrack->GetTrackID(); // G4 track ID of current track.
162 G4int truthID, g4TrackID;
163 GetCurrentTrackIndex( truthID, g4TrackID ); // ID of current primary track.
164
165 G4double theta = gTrack->GetMomentumDirection().theta();
166
167 G4ThreeVector hitPosition( 0, 0, 0 );
168 G4double transferT = 0;
169 driftD = Distance( layerId, cellId, pointIn, pointOut, hitPosition, transferT );
170
171 G4double posPhi, wirePhi;
172 posPhi = hitPosition.phi(); // from -pi to pi
173 if ( posPhi < 0 ) posPhi += 2 * pi;
174 wirePhi =
175 mdcGeoPointer->SignalWire( layerId, cellId ).Phi( hitPosition.z() ); // from 0 to 2pi
176
177 G4int posFlag;
178 if ( posPhi <= wirePhi ) { posFlag = 0; }
179 else { posFlag = 1; }
180 // if x axis is between pos and wire, phi will has a jump of one of them.
181 if ( posPhi < 1. && wirePhi > 5. ) posFlag = 1;
182 if ( posPhi > 5. && wirePhi < 1. ) posFlag = 0;
183
184 G4ThreeVector hitLine = pointOut - pointIn;
185 G4double enterAngle = hitLine.phi() - wirePhi;
186 while ( enterAngle < -pi / 2. ) enterAngle += pi;
187 while ( enterAngle > pi / 2. ) enterAngle -= pi;
188
189 if ( m_G4Svc->GetMdcDedxFlag() == 1 )
190 {
191 G4double betaGamma =
192 aStep->GetPreStepPoint()->GetBeta() * aStep->GetPreStepPoint()->GetGamma();
193 if ( betaGamma < 0.01 ) return false; // too low momentum
194 // if (betaGamma < 10.0) betaGamma = 10.0;
195
196 G4double eCount = dedxSample( betaGamma, charge, theta );
197 edep = eCount;
198 }
199
200 BesMdcHit* newHit = new BesMdcHit();
201 newHit->SetTrackID( truthID );
202 // newHit->SetTrkID(trackID);
203 newHit->SetLayerNo( layerId );
204 newHit->SetCellNo( cellId );
205 newHit->SetEdep( edep );
206 newHit->SetPos( hitPosition );
207 newHit->SetDriftD( driftD );
208 newHit->SetTheta( theta );
209 newHit->SetPosFlag( posFlag );
210 newHit->SetEnterAngle( enterAngle );
211
212 // Transfer hit pointer to BesMdcCalTransfer
213 mdcCalPointer->SetHitPointer( newHit );
214
215 driftT = mdcCalPointer->D2T( driftD );
216 globalT += transferT;
217 driftT += globalT;
218
219 newHit->SetDriftT( driftT );
220 newHit->SetGlobalT( globalT );
221
222 if ( hitPointer[layerId][cellId] == -1 )
223 {
224 hitsCollection->insert( newHit );
225 G4int NbHits = hitsCollection->entries();
226 hitPointer[layerId][cellId] = NbHits - 1;
227 }
228 else
229 {
230 G4int pointer = hitPointer[layerId][cellId];
231 if ( g4TrackID == trackID )
232 { G4double preDriftT = ( *hitsCollection )[pointer]->GetDriftT(); }
233
234 G4double preDriftT = ( *hitsCollection )[pointer]->GetDriftT();
235 if ( driftT < preDriftT )
236 {
237 ( *hitsCollection )[pointer]->SetTrackID( truthID );
238 //(*hitsCollection)[pointer]->SetTrkID(trackID);
239 ( *hitsCollection )[pointer]->SetDriftD( driftD );
240 ( *hitsCollection )[pointer]->SetDriftT( driftT );
241 ( *hitsCollection )[pointer]->SetPos( hitPosition );
242 ( *hitsCollection )[pointer]->SetGlobalT( globalT );
243 ( *hitsCollection )[pointer]->SetTheta( theta );
244 ( *hitsCollection )[pointer]->SetPosFlag( posFlag );
245 ( *hitsCollection )[pointer]->SetEnterAngle( enterAngle );
246 }
247
248 delete newHit;
249 }
250
251 // for mc truth
252 if ( truthCollection )
253 {
254 if ( g4TrackID == trackID )
255 { // This track is the primary track & will appear in MC truth
256 G4int pointer = truthPointer[layerId][cellId];
257 if ( pointer == -1 )
258 {
259 BesMdcHit* truthHit = new BesMdcHit();
260 truthHit->SetTrackID( truthID );
261 truthHit->SetLayerNo( layerId );
262 truthHit->SetCellNo( cellId );
263 truthHit->SetEdep( edep );
264 truthHit->SetPos( hitPosition );
265 truthHit->SetDriftD( driftD );
266 truthHit->SetDriftT( driftT );
267 truthHit->SetGlobalT( globalT );
268 truthHit->SetTheta( theta );
269 truthHit->SetPosFlag( posFlag );
270 truthHit->SetEnterAngle( enterAngle );
271
272 truthCollection->insert( truthHit );
273 G4int NbHits = truthCollection->entries();
274 truthPointer[layerId][cellId] = NbHits - 1;
275 }
276 else
277 {
278 if ( truthID == ( *truthCollection )[pointer]->GetTrackID() )
279 {
280 G4double preDriftT = ( *truthCollection )[pointer]->GetDriftT();
281 if ( driftT < preDriftT )
282 {
283 ( *truthCollection )[pointer]->SetDriftD( driftD );
284 ( *truthCollection )[pointer]->SetDriftT( driftT );
285 ( *truthCollection )[pointer]->SetPos( hitPosition );
286 ( *truthCollection )[pointer]->SetGlobalT( globalT );
287 ( *truthCollection )[pointer]->SetTheta( theta );
288 ( *truthCollection )[pointer]->SetPosFlag( posFlag );
289 ( *truthCollection )[pointer]->SetEnterAngle( enterAngle );
290 }
291 edepTemp = ( *truthCollection )[pointer]->GetEdep();
292 ( *truthCollection )[pointer]->SetEdep( edepTemp + edep );
293 }
294 else
295 {
296 BesMdcHit* truthHit = new BesMdcHit();
297 truthHit->SetTrackID( truthID );
298 truthHit->SetLayerNo( layerId );
299 truthHit->SetCellNo( cellId );
300 truthHit->SetEdep( edep );
301 truthHit->SetPos( hitPosition );
302 truthHit->SetDriftD( driftD );
303 truthHit->SetDriftT( driftT );
304 truthHit->SetGlobalT( globalT );
305 truthHit->SetTheta( theta );
306 truthHit->SetPosFlag( posFlag );
307 truthHit->SetEnterAngle( enterAngle );
308
309 truthCollection->insert( truthHit );
310 G4int NbHits = truthCollection->entries();
311 truthPointer[layerId][cellId] = NbHits - 1;
312 }
313 }
314 }
315 }
316
317 // newHit->Print();
318 // newHit->Draw();
319
320 return true;
321}
322
323void BesMdcSD::EndOfEvent( G4HCofThisEvent* ) {
324 if ( verboseLevel > 0 )
325 {
326 hitsCollection->PrintAllHits();
327 /*
328 G4int NbHits = hitsCollection->entries();
329 G4cout << "\n-------->Hits Collection: in this event they are " << NbHits
330 << " hits in the MDC chambers: " << G4endl;
331 for (G4int i=0;i<NbHits;i++) (*hitsCollection)[i]->Print();
332 */
333 }
334}
335
336G4double BesMdcSD::Distance( G4int layerId, G4int cellId, G4ThreeVector pointIn,
337 G4ThreeVector pointOut, G4ThreeVector& hitPosition,
338 G4double& transferT ) {
339 // For two lines r=r1+t1.v1 & r=r2+t2.v2
340 // the closest approach is d=|(r2-r1).(v1 x v2)|/|v1 x v2|
341 // the point where closest approach are
342 // t1=(v1 x v2).[(r2-r1) x v2]/[(v1 x v2).(v1 x v2)]
343 // t2=(v1 x v2).[(r2-r1) x v1]/[(v1 x v2).(v1 x v2)]
344 // if v1 x v2=0 means two lines are parallel
345 // d=|(r2-r1) x v1|/|v1|
346
347 G4double t1, distance, dInOut, dHitIn, dHitOut;
348 // Get wirepoint @ endplate
349 G4ThreeVector east = mdcGeomSvc->Wire( layerId, cellId )->Backward();
350 G4ThreeVector west = mdcGeomSvc->Wire( layerId, cellId )->Forward();
351 G4ThreeVector wireLine = east - west;
352 G4ThreeVector hitLine = pointOut - pointIn;
353
354 G4ThreeVector hitXwire = hitLine.cross( wireLine );
355 G4ThreeVector wire2hit = east - pointOut;
356 // Hitposition is the position on hit line where closest approach
357 // of two lines, but it may out the area from pointIn to pointOut
358 if ( hitXwire.mag() == 0 )
359 {
360 distance = wireLine.cross( wire2hit ).mag() / wireLine.mag();
361 hitPosition = pointIn;
362 }
363 else
364 {
365 t1 = hitXwire.dot( wire2hit.cross( wireLine ) ) / hitXwire.mag2();
366 hitPosition = pointOut + t1 * hitLine;
367
368 dInOut = ( pointOut - pointIn ).mag();
369 dHitIn = ( hitPosition - pointIn ).mag();
370 dHitOut = ( hitPosition - pointOut ).mag();
371 if ( dHitIn <= dInOut && dHitOut <= dInOut )
372 { // Between point in & out
373 distance = fabs( wire2hit.dot( hitXwire ) / hitXwire.mag() );
374 }
375 else if ( dHitOut > dHitIn )
376 { // out pointIn
377 distance = wireLine.cross( pointIn - east ).mag() / wireLine.mag();
378 hitPosition = pointIn;
379 }
380 else
381 { // out pointOut
382 distance = wireLine.cross( pointOut - east ).mag() / wireLine.mag();
383 hitPosition = pointOut;
384 }
385 }
386
387 // Calculate signal transferT on wire
388 G4double halfLayerLength = mdcGeomSvc->Layer( layerId )->Length() / 2.;
389 G4double halfWireLength = wireLine.mag() / 2.;
390 G4double transferZ = 0;
391 if ( layerId % 2 == 0 )
392 {
393 transferZ = halfLayerLength + hitPosition.z(); // West readout
394 }
395 else
396 {
397 transferZ = halfLayerLength - hitPosition.z(); // East readout
398 }
399 if ( layerId < 8 ) { transferT = transferZ * halfWireLength / halfLayerLength / 220; }
400 else { transferT = transferZ * halfWireLength / halfLayerLength / 240; }
401
402 return distance;
403}
404
406 dEdE_mylanfunc = new TF1(
407 "dEdE_mylanfunc", "[3]*TMath::Exp([2]*((x[0]-[0])/[1]+TMath::Exp(-1*((x[0]-[0])/[1]))))",
408 0, 7500 );
409 // dEdE_mylanfunc->SetParameters(2009.35,559.776,-1.0932,6327.38);
410 dEdE_mylanfunc->SetParNames( "MPV", "Sigma", "constant1", "constant2" );
411}
412
413G4double BesMdcSD::dedxSample( G4double betagamma, G4double charge, G4double theta ) {
414 m_version = m_pDedxSimSvc->getVersion();
415 m_numBg = m_pDedxSimSvc->getRangeNo();
416 m_numTheta = m_pDedxSimSvc->getThetaNo();
417 m_dedx_hists = m_pDedxSimSvc->getHist();
418 m_bgRange = m_pDedxSimSvc->getRange();
419 G4double x = betagamma;
420 G4double fitval = GetValDedxCurve( x, charge );
421 if ( fitval <= 0 ) return 0;
422
423 G4double random1, random2, dedx1, dedx2, de;
424 G4double standard1, standard2, beta_temp1, beta_temp2;
425 G4double dedx = -1;
426
427 G4int range_idx, bg_idx, angle_idx, charge_idx, hist_idx;
428 range_idx = GetBetagammaIndex( betagamma );
429 angle_idx = GetAngleIndex( theta );
430 charge_idx = GetChargeIndex( charge );
431
432 if ( range_idx == -1 )
433 {
434 while ( dedx <= 0 )
435 {
436 bg_idx = 0;
437 hist_idx = bg_idx * 2 * m_numTheta + angle_idx * 2 + charge_idx;
438 random1 = m_dedx_hists->at( hist_idx ).GetRandom();
439 beta_temp1 = ( m_bgRange->at( 0 ) + m_bgRange->at( 1 ) ) / 2;
440 standard1 = GetValDedxCurve( beta_temp1, charge );
441 dedx = random1 + fitval - standard1;
442 }
443 }
444 else if ( range_idx == m_numBg - 1 )
445 {
446 while ( dedx <= 0 )
447 {
448 bg_idx = (G4int)( range_idx / 2 );
449 hist_idx = bg_idx * 2 * m_numTheta + angle_idx * 2 + charge_idx;
450 random1 = m_dedx_hists->at( hist_idx ).GetRandom();
451 beta_temp1 = ( m_bgRange->at( m_numBg - 2 ) + m_bgRange->at( m_numBg - 1 ) ) / 2;
452 standard1 = GetValDedxCurve( beta_temp1, charge );
453 dedx = random1 + fitval - standard1;
454 }
455 }
456 else
457 {
458 // case 1: Given betagamma fall in one histograph range
459 if ( range_idx % 2 == 0 )
460 {
461 while ( dedx <= 0 )
462 {
463 bg_idx = (G4int)( range_idx / 2 );
464 hist_idx = bg_idx * 2 * m_numTheta + angle_idx * 2 + charge_idx;
465 random1 = m_dedx_hists->at( hist_idx ).GetRandom();
466 beta_temp1 = ( m_bgRange->at( range_idx ) + m_bgRange->at( range_idx + 1 ) ) / 2;
467 standard1 = GetValDedxCurve( beta_temp1, charge );
468 dedx1 = random1 + fitval - standard1;
469 dedx = dedx1;
470 }
471 }
472 // case 2: Given betagamma fall in interval between
473 // two histographs.
474 else
475 {
476 while ( dedx <= 0 )
477 {
478 // standard1
479 beta_temp1 = ( m_bgRange->at( range_idx - 1 ) + m_bgRange->at( range_idx ) ) / 2;
480 standard1 = GetValDedxCurve( beta_temp1, charge );
481
482 // stardard2
483 beta_temp2 = ( m_bgRange->at( range_idx + 1 ) + m_bgRange->at( range_idx + 2 ) ) / 2;
484 standard2 = GetValDedxCurve( beta_temp2, charge );
485
486 // random1
487 bg_idx = (G4int)( range_idx / 2 );
488 hist_idx = bg_idx * 2 * m_numTheta + angle_idx * 2 + charge_idx;
489 random1 = m_dedx_hists->at( hist_idx ).GetRandom();
490
491 // random2
492 bg_idx++;
493 hist_idx = bg_idx * 2 * m_numTheta + angle_idx * 2 + charge_idx;
494 random2 = m_dedx_hists->at( hist_idx ).GetRandom();
495
496 // combine dedx1 and dedx2
497 dedx1 = random1 + fitval - standard1;
498 dedx2 = random2 + fitval - standard2;
499 dedx = ( dedx2 * ( x - m_bgRange->at( range_idx ) ) +
500 dedx1 * ( m_bgRange->at( range_idx + 1 ) - x ) ) /
501 ( m_bgRange->at( range_idx + 1 ) - m_bgRange->at( range_idx ) );
502 }
503 }
504 }
505
506 de = dedx; // * y/10./1.5;// stepLength unit is mm in Geant4, cm in Rec.& Cal. software
507 // dedx counts *1.5 in dedx Cal.
508
509 if ( m_G4Svc->MdcRootFlag() )
510 {
511 m_betaGamma = x;
512 m_fitval = fitval;
513 // m_trackId = trackId;
514 // m_layer = layerId;
515 // m_wire = cellId;
516 // m_random= random;
517 m_dedx = dedx;
518 m_de = de;
519 // m_length=y;
520 m_charge = charge;
521 m_costheta = cos( theta );
522 m_tupleMdc->write();
523 }
524 return de;
525}
526
527/*-----------------------------------------------------
528Func: GetValDedxCurve
529Pre: A betagamma is given.
530Post: Return dE/dx value from betagamma~dE/dx curve.
531-----------------------------------------------------*/
532G4double BesMdcSD::GetValDedxCurve( G4double x, G4double charge ) {
533 G4int dedxflag = -1;
534 G4int size = -1;
535 G4double A = 0.;
536 G4double B = 0.;
537 G4double C = 0.;
538 std::vector<G4double> par;
539 G4double val;
540 G4int index = -1;
541
542 par.clear();
543 dedxflag = m_pDedxCurSvc->getCurve( 0 );
544 size = m_pDedxCurSvc->getCurveSize();
545 for ( G4int i = 1; i < size; i++ ) { par.push_back( m_pDedxCurSvc->getCurve( i ) ); }
546
547 if ( x < 4.5 ) A = 1;
548 else if ( x < 10 ) B = 1;
549 else C = 1;
550
551 G4double partA = par[0] * pow( sqrt( x * x + 1 ), par[2] ) / pow( x, par[2] ) *
552 ( par[1] - par[5] * log( pow( 1 / x, par[3] ) ) ) -
553 par[4] + exp( par[6] + par[7] * x );
554 G4double partB = par[8] * pow( x, 3 ) + par[9] * pow( x, 2 ) + par[10] * x + par[11];
555 G4double partC = -par[12] * log( par[15] + pow( 1 / x, par[13] ) ) + par[14];
556
557 val = 550 * ( A * partA + B * partB + C * partC );
558 return val;
559}
560
561/*-----------------------------------------------------
562Func: GetBetagammaIndex
563Pre : A betagamma of a track is given.
564Post: Return index of the betagamma range.
565-----------------------------------------------------*/
566G4int BesMdcSD::GetBetagammaIndex( G4double bg ) {
567 if ( bg < m_bgRange->at( 0 ) ) return -1;
568 for ( G4int i = 0; i < m_numBg - 1; i++ )
569 {
570 if ( bg > m_bgRange->at( i ) && bg < m_bgRange->at( i + 1 ) ) { return i; }
571 }
572 if ( bg > m_bgRange->at( m_numBg - 1 ) ) return ( m_numBg - 1 );
573 return -1;
574}
575
576/*-----------------------------------------------------
577Func: GetAngleIndex
578Pre : A theta of a track is given.
579Post: version 0 - Return index of the angle (|cos(theta)| in 10 bins),
580 version 1 - Return index of the angle ( cos(theta) in m_numTheta bins).
581-----------------------------------------------------*/
582G4int BesMdcSD::GetAngleIndex( G4double theta ) {
583 if ( m_version == 0 )
584 {
585 if ( fabs( cos( theta ) ) >= 0.93 ) return 9;
586 return (G4int)( fabs( cos( theta ) ) * 10 / 0.93 );
587 }
588 else
589 {
590 G4double cos_min = -0.93;
591 G4double cos_max = 0.93;
592 G4int nbin = m_numTheta;
593 G4double cos_step = ( cos_max - cos_min ) / nbin;
594
595 if ( cos( theta ) < cos_min ) return 0;
596 else if ( cos_min < cos( theta ) && cos( theta ) < cos_max )
597 { return (G4int)( ( cos( theta ) - cos_min ) / cos_step ); }
598 else return nbin - 1;
599 }
600}
601
602/*-----------------------------------------------------
603Func: GetChargeIndex
604Pre : A charge of a track is given.
605Post: Return index of charge (pos->0 ~ neg->1).
606-----------------------------------------------------*/
607G4int BesMdcSD::GetChargeIndex( G4int charge ) {
608 if ( charge > 0 ) return 0;
609 if ( charge == 0 ) return -1; // warning: -1 is illegal, for charged tracks are expected.
610 if ( charge < 0 ) return 1;
611 return -1;
612}
************Class m_alfQCDMZ INTEGER m_KFfin INTEGER m_IVfin INTEGER m_ibox *COMMON c_DZface $ alphaQED at(Q^2=MZ^2) DIZET $ m_alfQCDMZ
Double_t x[10]
EvtComplex exp(const EvtComplex &c)
double pi
G4THitsCollection< BesMdcHit > BesMdcHitsCollection
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition RRes.h:29
static BesMdcGeoParameter * GetGeo(void)
void dedxFuncInti(void)
Definition BesMdcSD.cc:405
void BeginOfTruthEvent(const G4Event *)
Definition BesMdcSD.cc:87
void EndOfTruthEvent(const G4Event *)
Definition BesMdcSD.cc:92
G4double Distance(G4int, G4int, G4ThreeVector, G4ThreeVector, G4ThreeVector &, G4double &)
Definition BesMdcSD.cc:336
G4bool ProcessHits(G4Step *, G4TouchableHistory *)
Definition BesMdcSD.cc:100
void EndOfEvent(G4HCofThisEvent *)
Definition BesMdcSD.cc:323
BesMdcSD(G4String)
Definition BesMdcSD.cc:25
void Initialize(G4HCofThisEvent *)
Definition BesMdcSD.cc:69
~BesMdcSD()
Definition BesMdcSD.cc:67
void GetCurrentTrackIndex(G4int &trackIndex, G4int &g4TrackId) const
BesSensitiveDetector(const G4String name)
virtual std::vector< double > * getRange()=0
virtual std::vector< TH1F > * getHist()=0
virtual int getThetaNo()=0
virtual int getRangeNo()=0
virtual int getVersion()=0