13#include "G4TrackStatus.hh"
14#include "G4VPhysicalVolume.hh"
15#include "G4TransportationManager.hh"
16#include "G4FieldManager.hh"
18#include "G4LogicalVolume.hh"
33ExtSteppingAction::ExtSteppingAction():chicc(0.0),initialPath(0.),myPathIntoCrystal(0.),myPathOutCrystal(0.),myPathInCrystal(0.),myBetaInMDC(0.),extXpErr(0),myExtTrack(0),msgFlag(
true),myUseMucKalFlag(
true),m_trackstop(
false),myMucnfit_(0),myMucchisq_(0.),myMucdepth_(-99.),myMucbrLastLay_(-1),myMucecLastLay_(-1),myMucnhits_(-1),myMucWindow(6)
43 m_which_tof_version=2;
52 myPathIntoCrystal = 0.;
53 myPathOutCrystal = 0.;
107 G4Track* currentTrack = currentStep->GetTrack();
110 cout<<
"Can't get currentTrack"<<endl;
113 G4TrackStatus currentTrackStatus = currentTrack->GetTrackStatus();
115 int stepNumber = currentTrack->GetCurrentStepNumber();
116 if(msgFlag) cout<<
"STEP "<<stepNumber<<
":"<<endl;
119 Hep3Vector currentPosition = currentTrack->GetPosition();
120 Hep3Vector currentMomentum = currentTrack->GetMomentum();
124 G4VPhysicalVolume* oldVolume;
125 G4VPhysicalVolume* newVolume;
126 if(!currentTrack->GetTouchableHandle()) cout<<
"Can't get currentTrack->GetTouchableHandle()"<<endl;
127 else oldVolume= currentTrack->GetTouchableHandle()->GetVolume();
128 if(!currentTrack->GetNextTouchableHandle()) cout<<
"Can't get currentTrack->GetNextTouchableHandle()"<<endl;
129 else newVolume= currentTrack->GetNextTouchableHandle()->GetVolume();
130 if(!oldVolume) cout<<
"Can't get oldVolume!"<<endl;
133 if(stepNumber>50000) {
134 cout<<
"infinite steps in the track "<<endl;
135 currentTrack->SetTrackStatus(fStopAndKill); m_trackstop =
true;
138 G4String ParticleName = currentTrack->GetDefinition()->GetParticleName();
139 double x_ = currentPosition.x();
140 double y_ = currentPosition.y();
141 double z_ = currentPosition.z();
142 bool inner = (oldVolume!=newVolume)&&(!( (fabs(x_)>=myMucR) || (fabs(y_)>=myMucR) || ((fabs(x_-y_)/sqrt(2.))>=myMucR) || ((fabs(x_+y_)/sqrt(2.))>=myMucR) || (fabs(z_)>=myMucZ)) );
143 bool mucdec = (fabs(x_)>=myMucR) || (fabs(y_)>=myMucR) || ((fabs(x_-y_)/sqrt(2.))>=myMucR) || ((fabs(x_+y_)/sqrt(2.))>=myMucR) || (fabs(z_)>=myMucZ);
146 if(currentTrackStatus == fAlive)
152 double currentPoint[3]={currentPosition.x(),currentPosition.y(),currentPosition.z()};
153 double currentBfield[3]={0.0,0.0,0.0};
154 Hep3Vector currentB(0.0,0.0,1.0);
155 if(G4TransportationManager::GetTransportationManager())
157 G4FieldManager* fieldManager=G4TransportationManager::GetTransportationManager()->GetFieldManager();
160 if(fieldManager->GetDetectorField())
162 fieldManager->GetDetectorField()->GetFieldValue(currentPoint,currentBfield);
163 currentB.set(currentBfield[0]/tesla,currentBfield[1]/tesla,currentBfield[2]/tesla);
164 if(msgFlag) cout<<
"B:"<<currentB.x()<<
","<<currentB.y()<<
","<<currentB.z()<<endl;
170 G4Material* oldMaterial = oldVolume->GetLogicalVolume()->GetMaterial();
171 if(!oldMaterial) std::cout<<
"Can't get oldMaterial"<<std::endl;
172 else CalculateChicc(oldMaterial);
175 if(!(extXpErr->
move(currentPosition,currentMomentum,currentB,1,chicc)))
176 if(msgFlag) cout<<
"can not update Error Matrix!!"<<endl;
181 cout<<
"Volume name:"<<newVolume->GetName()<<endl;
182 cout<<
"Volume number:"<<newVolume->GetCopyNo()<<endl;
183 cout<<
"x:"<<currentPoint[0]<<
"//y:"<<currentPoint[1]<<
"//z:"<<currentPoint[2]
184 <<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"
185 <<currentMomentum.z()<<endl;
186 cout<<
"ptot = "<<currentMomentum.mag()<<endl;
187 cout<<
"trk len = "<<currentTrack->GetTrackLength()<<endl;
188 cout<<
"Error matrix is:"<<extXpErr->
get_err()<<endl;
189 cout<<
"phi:"<<atan(currentPoint[1]/currentPoint[0])<<endl;
190 Hep3Vector nz(0.,0.,1.);
191 cout<<
"Projected z error:"<<extXpErr->
get_plane_err(currentMomentum.unit(),nz)
197 Hep3Vector nt(-
y/R,
x/R,0.);
198 cout<<
"Projected phi error:"<<(extXpErr->
get_plane_err(currentMomentum.unit(),nt))/R
203 Hep3Vector xVector(1.0,0,0);
204 Hep3Vector yVector(0,1.0,0);
205 Hep3Vector zVector(0,0,1.0);
207 tzVector.setRThetaPhi(1.0,
M_PI/2.0,currentPosition.phi());
208 double r = currentPosition.perp();
209 double x = currentPosition.x();
210 double y = currentPosition.y();
211 double z = currentPosition.z();
212 G4String newVolumeName = newVolume->GetName();
213 G4String oldVolumeName = oldVolume->GetName();
214 G4StepPoint* postStepPoint = currentStep->GetPostStepPoint();
215 G4TouchableHistory* theTouchable = (G4TouchableHistory*)(postStepPoint->GetTouchable());
216 int newVolumeNumber=newVolume->GetCopyNo();
220 if(newVolumeName==
"logical_gasLayer")
222 name1=theTouchable->GetVolume(3)->GetName();
223 newVolumeNumber=theTouchable->GetReplicaNumber(3);
270 if((!myTof1Flag) && (newVolumeName==
"logicalScinBr1" || newVolumeName.contains(
"ScinEc") ||
271 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))))
273 double currentTrackLength = currentTrack->GetTrackLength();
274 double totalTrackLength = currentTrackLength+initialPath;
275 double localTime = currentTrack->GetLocalTime();
276 double totalTOF = localTime + initialTof;
278 myPathIntoTof1 = currentTrackLength;
279 if(msgFlag) cout <<
"myPathIntoTof1 = " << myPathIntoTof1 << endl;
281 newVolumeNumber=theTouchable->GetReplicaNumber(2);
283 if(newVolumeName.contains(
"ScinEc")) {
284 newVolumeNumber=(95-newVolumeNumber)/2;
285 newVolumeNumber=newVolumeNumber+176;
287 if(newVolumeName.contains(
"East")) newVolumeNumber=newVolumeNumber+48;
289 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
290 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
291 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
292 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
293 myExtTrack->
SetTof1Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
298 else if(newVolumeName==
"logical_gasLayer")
300 G4ThreeVector currentPostPosition = currentStep->GetPostStepPoint()->GetPosition();
301 G4ThreeVector localPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(currentPostPosition);
306 double z_mm = localPosition.z()-0.5+(24+3)*6;
312 else if(z_mm>0 && z_mm<12*27)
314 strip=floor(z_mm/27);
321 if(strip>11) strip=11;
323 newVolumeNumber=theTouchable->GetReplicaNumber(3);
324 newVolumeNumber = 35-newVolumeNumber;
325 if( currentPosition.z() < 0.0 ) { newVolumeNumber = newVolumeNumber + 36; }
326 newVolumeNumber = 12*newVolumeNumber+strip;
327 newVolumeNumber = newVolumeNumber + 176 + 96;
329 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
330 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
331 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
332 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
333 Hep3Vector locP = Hep3Vector( localPosition.x(), localPosition.y(), localPosition.z() );
338 myExtTrack->
SetTof1Data(locP/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
344 newVolumeNumber=(527-newVolumeNumber)/3;
346 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
347 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
348 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
349 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
350 myExtTrack->
SetTof1Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
359 if( myInTof1 && ( oldVolumeName==
"logicalScinBr1" || oldVolumeName.contains(
"ScinEc") ||
360 (oldVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))) ) {
363 myPathOutTof1 = currentTrack->GetTrackLength();
364 myPathInTof1.push_back(myPathOutTof1 - myPathIntoTof1);
365 if(msgFlag) cout <<
"myPathOutTof1 = " << myPathOutTof1 << endl;
368 if( myOutTof1 && ( newVolumeName==
"logicalScinBr1" || newVolumeName.contains(
"ScinEc") ||
369 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))) ) {
372 myPathIntoTof1 = currentTrack->GetTrackLength();
373 if(msgFlag) cout <<
"myPathIntoTof1 = " << myPathIntoTof1 << endl;
378 if( (!myTof2Flag) && (newVolumeName==
"logicalScinBr2" ||
379 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))))
381 double currentTrackLength = currentTrack->GetTrackLength();
382 double totalTrackLength = currentTrackLength+initialPath;
384 double localTime = currentTrack->GetLocalTime();
385 double totalTOF = localTime + initialTof;
387 myPathIntoTof2 = currentTrackLength;
388 if(msgFlag) cout <<
"myPathIntoTof2 = " << myPathIntoTof2 << endl;
389 newVolumeNumber=theTouchable->GetReplicaNumber(2);
391 if(newVolumeName==
"logical_gasLayer")
393 G4ThreeVector currentPostPosition = currentStep->GetPostStepPoint()->GetPosition();
394 G4ThreeVector localPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(currentPostPosition);
399 double z_mm = localPosition.z()-0.5+(24+3)*6;
405 else if(z_mm>0 && z_mm<12*27)
407 strip=floor(z_mm/27);
414 if(strip>11) strip=11;
416 newVolumeNumber=theTouchable->GetReplicaNumber(3);
417 newVolumeNumber = 35-newVolumeNumber;
418 if( currentPosition.z() < 0.0 ) { newVolumeNumber = newVolumeNumber + 36; }
419 newVolumeNumber = 12*newVolumeNumber+strip;
420 newVolumeNumber = newVolumeNumber + 176 + 96;
424 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
425 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
426 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
427 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
428 Hep3Vector locP = Hep3Vector( localPosition.x(), localPosition.y(), localPosition.z() );
433 myExtTrack->
SetTof2Data(locP/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
439 newVolumeNumber=(527-newVolumeNumber)/3;
442 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
443 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
444 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
445 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
446 myExtTrack->
SetTof2Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
453 if( myInTof2 && (oldVolumeName==
"logicalScinBr2" ||
454 (oldVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))) ) {
457 myPathOutTof2 = currentTrack->GetTrackLength();
458 myPathInTof2.push_back(myPathOutTof2 - myPathIntoTof2);
459 if(msgFlag) cout <<
"myPathOutTof2 = " << myPathOutTof2 << endl;
462 if( myOutTof2 && (newVolumeName==
"logicalScinBr2" ||
463 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))) ) {
466 myPathIntoTof2 = currentTrack->GetTrackLength();
467 if(msgFlag) cout <<
"myPathIntoTof2 = " << myPathIntoTof2 << endl;
472 if( (!myPhyEmcFlag) && (!myEmcFlag) && (newVolumeName==
"EMC" || newVolumeName.contains(
"BSC") || newVolumeName==
"EndPhi"))
474 newVolumeNumber = -2;
478 Hep3Vector
nPhi(-
y/r,
x/r,0.);
481 Hep3Vector aPosition = currentPosition;
482 double R = aPosition.r();
483 double aTheta = aPosition.theta();
484 aPosition.setTheta(aTheta + M_PI_2);
486 errorTheta =(extXpErr->
get_plane_err(currentMomentum.unit(),aPosition.unit()))/R;
487 if(msgFlag) cout<<
"Theta direction: "<<aPosition<<endl;
488 myExtTrack->
SetEmcData(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,errorTheta,errorPhi,myOutputSymMatrix(extXpErr->
get_err()));
495 if(!myEmcPathFlag && newVolumeName.contains(
"Crystal") )
497 myPathIntoCrystal = currentTrack->GetTrackLength();
499 myEmcPathFlag =
true;
503 if( (!myEmcFlag) && newVolumeName.contains(
"Crystal") )
508 int npart,ntheta,nphi;
509 if(currentTrack->GetNextTouchableHandle()->GetVolume(1)->GetName().contains(
"BSC")) {
511 std::istringstream thetaBuf((currentTrack->GetNextTouchableHandle()->GetVolume(1)->GetName()).substr(16,2));
513 nphi = 308-currentTrack->GetNextTouchableHandle()->GetCopyNumber(2);
515 npart=2-2*currentTrack->GetNextTouchableHandle()->GetCopyNumber(3);
516 int endSector=currentTrack->GetNextTouchableHandle()->GetCopyNumber(2);
518 std::istringstream thetaBuf((currentTrack->GetNextTouchableHandle()->GetVolume(0)->GetName()).substr(20,2));
524 ostringstream strEmc;
526 strEmc<<
"EmcPart"<<npart<<
"Theta0"<<ntheta<<
"Phi"<<nphi;
528 strEmc<<
"EmcPart"<<npart<<
"Theta"<<ntheta<<
"Phi"<<nphi;
532 Hep3Vector
nPhi(-
y/r,
x/r,0.);
535 Hep3Vector aPosition = currentPosition;
536 double R = aPosition.r();
537 double aTheta = aPosition.theta();
538 aPosition.setTheta(aTheta + M_PI_2);
540 errorTheta =(extXpErr->
get_plane_err(currentMomentum.unit(),aPosition.unit()))/R;
541 if(msgFlag) cout<<
"Theta direction: "<<aPosition<<endl;
542 myExtTrack->
SetEmcData(currentPosition/10,currentMomentum/1000,strEmc.str(),
543 newVolumeNumber,errorTheta,errorPhi,myOutputSymMatrix(extXpErr->
get_err()));
550 if(myEmcPathFlag && oldVolumeName.contains(
"Crystal") )
552 myPathOutCrystal = currentTrack->GetTrackLength();
553 myPathInCrystal = myPathInCrystal+myPathOutCrystal-myPathIntoCrystal;
560 if( (!myMucFlag) && ( (fabs(
x)>=myMucR) || (fabs(
y)>=myMucR) || ((fabs(
x-
y)/sqrt(2.))>=myMucR) || ((fabs(
x+
y)/sqrt(2.))>=myMucR) || (fabs(z)>=myMucZ) ) )
562 int newVolumeNumber = newVolume->GetCopyNo();
565 Hep3Vector xVector(1.0,0,0);
566 Hep3Vector yVector(0,1.0,0);
567 Hep3Vector zVector(0,0,1.0);
568 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
569 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
570 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
572 double phi = currentPosition.phi();
573 if(phi<0.) phi+=
M_PI;
574 int i = int(8.0*phi/
M_PI);
575 if( i==0 || i==7 || i==8 )
581 Hep3Vector tzVector(-1.0,1.0,0.);
582 tzError =extXpErr->
get_plane_err(currentMomentum.unit(),tzVector.unit());
590 Hep3Vector tzVector(1.0,1.0,0.);
591 tzError =extXpErr->
get_plane_err(currentMomentum.unit(),tzVector.unit());
593 myExtTrack->
SetMucData(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
596 if(!(ParticleName.contains(
"mu")&&myUseMucKalFlag))
599 currentStep->GetTrack()->SetTrackStatus(fStopAndKill);
608 HepSymMatrix XpErr = extXpErr->
get_err();
609 int namesize = oldVolumeName.size();
610 bool Flag1(
false),Flag2(
false),Flag3(
false),Flag4(
false),Flag5(
false);
611 Flag1 = m_mucdigicol->size()>0;
612 Flag2 = myUseMucKalFlag;
613 Flag3 = ParticleName.contains(
"mu")&&oldVolumeName.contains(
"lMuc")&&oldVolumeName.contains(
"P")&&oldVolumeName.contains(
"S")&&(oldVolumeName.contains(
"G")||oldVolumeName.contains(
"Ab"));
614 Flag4 = oldVolumeName.contains(
"lMuc")&&oldVolumeName.contains(
"P")&&oldVolumeName.contains(
"S")&&((namesize==10&&oldVolumeName.contains(
"G"))||(namesize==11&&oldVolumeName.contains(
"Ab")));
615 Flag5 = !((RemID[0]==1&&RemID[2]==9)||((RemID[0]==0||RemID[0]==2)&&RemID[2]==8));
617 if(Flag1&&Flag2&&Flag3&&Flag5)
620 double depth = currentStep-> GetStepLength();
621 if(oldVolumeName.contains(
"Ab"))
622 RemDepth = RemDepth+ depth;
623 if(RemStep==0&&Flag4)
625 Hep3Vector ID_1 =
GetGapID(oldVolumeName);
628 bool LastLay = (ID_1[0]==1&&ID_1[2]<9)||((ID_1[0]==0||ID_1[0]==2)&&ID_1[2]<8);
629 if(RememberID[2]!=ID_1[2]&&LastLay)
632 double dist = fabs(pos_loc.z());
633 RemPositon = currentPosition;
634 RemMomentum = currentMomentum;
642 bool WillFilter =
false;
643 bool LastLay_ =
false;
644 double dist_b = 99999.;
649 LastLay_ =(ID_2[0]==1&&ID_2[2]<9)||((ID_2[0]==0||ID_2[0]==2)&&ID_2[2]<8);
650 if(LastLay_)dist_b=fabs(
MucGeoGeneral::Instance()->GetGap(ID_2[0],ID_2[1],ID_2[2])->TransformToGap(currentPosition).z());
657 double dist = fabs(pos_loc.z());
659 if(!WillFilter&&RemDist>dist)
661 RemPositon = currentPosition;
662 RemMomentum = currentMomentum;
665 RemVol = oldVolumeName;
677 vector<MucRecHit*> tmp = muckal->
TrackHit();
680 double chi2 = muckal->
GetChi2();
687 myMucchisq_ = myMucchisq_+chi2;
688 muckal->
XPmod(m_pos_mod,m_mom_mod,m_err_mod);
690 if(RememberID[0]==1)myMucbrLastLay_=RememberID[2];
691 if(RememberID[0]==0||RememberID[0]==2)myMucecLastLay_=RememberID[2];
692 if(oldVolumeName.contains(
"Ab"))
693 RemDepth = RemDepth-depth;
695 myMucdepth_ = RemDepth;
697 myMucdepth_=myMucdepth_+RemDepth;
705 currentStep->GetTrack()->SetTrackStatus(fStopAndKill);
711 RemPositon = currentPosition;
712 RemMomentum = currentMomentum;
716 if(oldVolumeName.contains(
"Ab"))
721 if(msgFlag)cout<<
"---------Filter is OK---------- "<<endl;
727 RemPositon = currentPosition;
728 RemMomentum = currentMomentum;
737 if(myExtTrack)myExtTrack->
SetMucKalData(myMucchisq_,myMucnfit_,myMucdepth_,myMucbrLastLay_,myMucecLastLay_,myMucnhits_);
807 if(msgFlag) cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<endl;
808 double x = currentPosition.x();
809 double y = currentPosition.y();
810 double z = currentPosition.z();
811 if( (fabs(
x)>=2*myMucR) || (fabs(
y)>=2*myMucR) || (fabs(z)>=2*myMucZ) )
813 {currentStep->GetTrack()->SetTrackStatus(fStopAndKill);m_trackstop=
true;}
817 else if(currentTrackStatus == fStopAndKill)
820 if(myEmcFlag) myExtTrack->
SetEmcPath(myPathInCrystal/10.);
824 cout <<
"myPathInTof1 = " ;
825 for(
int i=0; i!=myPathInTof1.size(); i++)
826 cout << myPathInTof1[i] <<
" ";
828 cout <<
"myPathInTof2 = " ;
829 for(
int i=0; i!=myPathInTof2.size(); i++)
830 cout << myPathInTof2[i] <<
" ";
838 std::cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<
"//stoped"<<endl;
839 cout<<
"Error matrix is:"<<extXpErr->
get_err()<<endl;
842 cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<
"//escaped"<<std::endl;
843 std::cout<<
"Error matrix is:"<<extXpErr->
get_err()<<std::endl;
851void ExtSteppingAction::CalculateChicc(G4Material* currentMaterial)
853 int n = currentMaterial->GetNumberOfElements();
854 const double *p = currentMaterial->GetFractionVector();
855 double density = (currentMaterial->GetDensity())/(g/cm3);
859 const G4Element* mElement = currentMaterial->GetElement(i);
860 double z = mElement->GetZ();
861 double a = mElement->GetN();
863 temp += *(p++)/a*z*(z+1);
865 chicc = 0.39612e-3*std::sqrt(density*temp);
870HepSymMatrix & ExtSteppingAction::myOutputSymMatrix(
const HepSymMatrix &
m1)
878 {
for(
int j=0;j<=i;j++)
883 m[i][j]=m[i][j]/10000;
886 m[i][j]=m[i][j]/1000000;
899 if((sector>=0)&&(sector<3))
906 nphi = (sector-3)*4+nb;
908 else if((nb>=4)&&(nb<8))
911 nphi = (sector-3)*4+nb-4;
913 else if((nb>=8)&&(nb<13))
916 nphi = (sector-3)*5+nb-8;
918 else if((nb>=13)&&(nb<18))
921 nphi = (sector-3)*5+nb-13;
923 else if((nb>=18)&&(nb<24))
926 nphi = (sector-3)*6+nb-18;
928 else if((nb>=24)&&(nb<30))
931 nphi = (sector-3)*6+nb-24;
984 }
else if(
num==2||
num==3) {
1029 int par(-1),se(-1),ga(-1);
1030 G4String strPart = vol.substr(5,1);
1033 G4String strSeg = vol.substr(7,1);
1035 if(vol.contains(
"G")) strGap= vol.substr(9,1);
1036 if(vol.contains(
"Ab")) strGap= vol.substr(10,1);
1037 std::istrstream partBuf(strPart.c_str(), strlen(strPart.c_str()));
1038 std::istrstream segBuf(strSeg.c_str(), strlen(strSeg.c_str()));
1039 std::istrstream gapBuf(strGap.c_str(), strlen(strGap.c_str()));
1044 if(vol.contains(
"Ab")&&par==1) ga = ga+1;
void SetTof1Data(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aTof, double aPath, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetEmcData(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aThetaSigma, double aPhiSigma, HepSymMatrix aErrorMatrix)
void SetTof2Data(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aTof, double aPath, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetMucData(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetEmcPath(double path)
void SetMucKalData(double chi2, int dof, double depth, int brLastLay, int ecLastLay, int nhits)
void SetGapID(Hep3Vector id)
void SetPosMomErr(Hep3Vector pos, Hep3Vector mom, HepSymMatrix err)
void SetMucWindow(int aMucWindow)
void XPmod(Hep3Vector &pos, Hep3Vector &mom, HepSymMatrix &err)
void SetMucDigiCol(MucDigiCol *amucdigi)
vector< MucRecHit * > TrackHit()
Hep3Vector GetGapID(G4String vol)
void CalculateEmcEndThetaPhi(int npart, int sector, int nb, int &ntheta, int &nphi)
void InfmodMuc(Hep3Vector &pos, Hep3Vector &mom, HepSymMatrix &err)
void UserSteppingAction(const G4Step *currentStep)
int CalculateEmcEndCopyNb(int num)
int CalculateEmcEndPhiNb(int num)
void put_err(const double error[])
const HepSymMatrix & get_err() const
double get_plane_err(const Hep3Vector &np, const Hep3Vector &nr) const
void set_mom(const Hep3Vector &mom)
bool move(const Hep3Vector &xv1, const Hep3Vector &pv1, const Hep3Vector &B, const int ms_on, const double chi_cc)
void set_pos(const Hep3Vector &pos)
HepPoint3D TransformToGap(const HepPoint3D gPoint) const
Transform a point from global coordinate to gap coordinate.
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
void setPathInTof1(vector< double > x)
void setPathInTof2(vector< double > x)