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