10#include "TrkExtAlg/ExtSteppingAction.h"
13#include "G4TrackStatus.hh"
14#include "G4VPhysicalVolume.hh"
15#include "G4TransportationManager.hh"
16#include "G4FieldManager.hh"
18#include "G4LogicalVolume.hh"
23#include "MucRecEvent/MucRecHit.h"
24#include "TrkExtAlg/ExtMucKal.h"
25#include "TrkExtAlg/Ext_xp_err.h"
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<<
"Error matrix is:"<<extXpErr->
get_err()<<endl;
187 cout<<
"phi:"<<atan(currentPoint[1]/currentPoint[0])<<endl;
188 Hep3Vector nz(0.,0.,1.);
189 cout<<
"Projected z error:"<<extXpErr->
get_plane_err(currentMomentum.unit(),nz)
195 Hep3Vector nt(-
y/R,
x/R,0.);
196 cout<<
"Projected phi error:"<<(extXpErr->
get_plane_err(currentMomentum.unit(),nt))/R
201 Hep3Vector xVector(1.0,0,0);
202 Hep3Vector yVector(0,1.0,0);
203 Hep3Vector zVector(0,0,1.0);
205 tzVector.setRThetaPhi(1.0,
M_PI/2.0,currentPosition.phi());
206 double r = currentPosition.perp();
207 double x = currentPosition.x();
208 double y = currentPosition.y();
209 double z = currentPosition.z();
210 G4String newVolumeName = newVolume->GetName();
211 G4String oldVolumeName = oldVolume->GetName();
212 G4StepPoint* postStepPoint = currentStep->GetPostStepPoint();
213 G4TouchableHistory* theTouchable = (G4TouchableHistory*)(postStepPoint->GetTouchable());
214 int newVolumeNumber=newVolume->GetCopyNo();
218 if(newVolumeName==
"logical_gasLayer")
220 name1=theTouchable->GetVolume(3)->GetName();
221 newVolumeNumber=theTouchable->GetReplicaNumber(3);
268 if((!myTof1Flag) && (newVolumeName==
"logicalScinBr1" || newVolumeName.contains(
"ScinEc") ||
269 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))))
271 double currentTrackLength = currentTrack->GetTrackLength();
272 double totalTrackLength = currentTrackLength+initialPath;
273 double localTime = currentTrack->GetLocalTime();
274 double totalTOF = localTime + initialTof;
276 myPathIntoTof1 = currentTrackLength;
277 if(msgFlag) cout <<
"myPathIntoTof1 = " << myPathIntoTof1 << endl;
279 newVolumeNumber=theTouchable->GetReplicaNumber(2);
281 if(newVolumeName.contains(
"ScinEc")) {
282 newVolumeNumber=(95-newVolumeNumber)/2;
283 newVolumeNumber=newVolumeNumber+176;
285 if(newVolumeName.contains(
"East")) newVolumeNumber=newVolumeNumber+48;
287 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
288 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
289 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
290 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
291 myExtTrack->
SetTof1Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
296 else if(newVolumeName==
"logical_gasLayer")
298 G4ThreeVector currentPostPosition = currentStep->GetPostStepPoint()->GetPosition();
299 G4ThreeVector localPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(currentPostPosition);
304 double z_mm = localPosition.z()-0.5+(24+3)*6;
310 else if(z_mm>0 && z_mm<12*27)
312 strip=floor(z_mm/27);
319 if(strip>11) strip=11;
321 newVolumeNumber=theTouchable->GetReplicaNumber(3);
322 newVolumeNumber = 35-newVolumeNumber;
323 if( currentPosition.z() < 0.0 ) { newVolumeNumber = newVolumeNumber + 36; }
324 newVolumeNumber = 12*newVolumeNumber+strip;
325 newVolumeNumber = newVolumeNumber + 176 + 96;
327 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
328 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
329 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
330 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
331 Hep3Vector locP = Hep3Vector( localPosition.x(), localPosition.y(), localPosition.z() );
336 myExtTrack->
SetTof1Data(locP/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
342 newVolumeNumber=(527-newVolumeNumber)/3;
344 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
345 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
346 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
347 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
348 myExtTrack->
SetTof1Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
357 if( myInTof1 && ( oldVolumeName==
"logicalScinBr1" || oldVolumeName.contains(
"ScinEc") ||
358 (oldVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))) ) {
361 myPathOutTof1 = currentTrack->GetTrackLength();
362 myPathInTof1.push_back(myPathOutTof1 - myPathIntoTof1);
363 if(msgFlag) cout <<
"myPathOutTof1 = " << myPathOutTof1 << endl;
366 if( myOutTof1 && ( newVolumeName==
"logicalScinBr1" || newVolumeName.contains(
"ScinEc") ||
367 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m0" || name1==
"logical_container_m1"))) ) {
370 myPathIntoTof1 = currentTrack->GetTrackLength();
371 if(msgFlag) cout <<
"myPathIntoTof1 = " << myPathIntoTof1 << endl;
376 if( (!myTof2Flag) && (newVolumeName==
"logicalScinBr2" ||
377 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))))
379 double currentTrackLength = currentTrack->GetTrackLength();
380 double totalTrackLength = currentTrackLength+initialPath;
382 double localTime = currentTrack->GetLocalTime();
383 double totalTOF = localTime + initialTof;
385 myPathIntoTof2 = currentTrackLength;
386 if(msgFlag) cout <<
"myPathIntoTof2 = " << myPathIntoTof2 << endl;
387 newVolumeNumber=theTouchable->GetReplicaNumber(2);
389 if(newVolumeName==
"logical_gasLayer")
391 G4ThreeVector currentPostPosition = currentStep->GetPostStepPoint()->GetPosition();
392 G4ThreeVector localPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(currentPostPosition);
397 double z_mm = localPosition.z()-0.5+(24+3)*6;
403 else if(z_mm>0 && z_mm<12*27)
405 strip=floor(z_mm/27);
412 if(strip>11) strip=11;
414 newVolumeNumber=theTouchable->GetReplicaNumber(3);
415 newVolumeNumber = 35-newVolumeNumber;
416 if( currentPosition.z() < 0.0 ) { newVolumeNumber = newVolumeNumber + 36; }
417 newVolumeNumber = 12*newVolumeNumber+strip;
418 newVolumeNumber = newVolumeNumber + 176 + 96;
422 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
423 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
424 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
425 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
426 Hep3Vector locP = Hep3Vector( localPosition.x(), localPosition.y(), localPosition.z() );
431 myExtTrack->
SetTof2Data(locP/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
437 newVolumeNumber=(527-newVolumeNumber)/3;
440 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
441 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
442 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
443 double tzError= extXpErr->
get_plane_err(currentMomentum.unit(),tzVector);
444 myExtTrack->
SetTof2Data(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,totalTOF,totalTrackLength/10,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
451 if( myInTof2 && (oldVolumeName==
"logicalScinBr2" ||
452 (oldVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))) ) {
455 myPathOutTof2 = currentTrack->GetTrackLength();
456 myPathInTof2.push_back(myPathOutTof2 - myPathIntoTof2);
457 if(msgFlag) cout <<
"myPathOutTof2 = " << myPathOutTof2 << endl;
460 if( myOutTof2 && (newVolumeName==
"logicalScinBr2" ||
461 (newVolumeName==
"logical_gasLayer" && (name1==
"logical_container_m2" || name1==
"logical_container_m3"))) ) {
464 myPathIntoTof2 = currentTrack->GetTrackLength();
465 if(msgFlag) cout <<
"myPathIntoTof2 = " << myPathIntoTof2 << endl;
470 if( (!myPhyEmcFlag) && (!myEmcFlag) && (newVolumeName==
"EMC" || newVolumeName.contains(
"BSC") || newVolumeName==
"EndPhi"))
472 newVolumeNumber = -2;
476 Hep3Vector
nPhi(-
y/r,
x/r,0.);
479 Hep3Vector aPosition = currentPosition;
480 double R = aPosition.r();
481 double aTheta = aPosition.theta();
482 aPosition.setTheta(aTheta + M_PI_2);
484 errorTheta =(extXpErr->
get_plane_err(currentMomentum.unit(),aPosition.unit()))/R;
485 if(msgFlag) cout<<
"Theta direction: "<<aPosition<<endl;
486 myExtTrack->
SetEmcData(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,errorTheta,errorPhi,myOutputSymMatrix(extXpErr->
get_err()));
493 if(!myEmcPathFlag && newVolumeName.contains(
"Crystal") )
495 myPathIntoCrystal = currentTrack->GetTrackLength();
497 myEmcPathFlag =
true;
501 if( (!myEmcFlag) && newVolumeName.contains(
"Crystal") )
506 int npart,ntheta,nphi;
507 if(currentTrack->GetNextTouchableHandle()->GetVolume(1)->GetName().contains(
"BSC")) {
509 std::istringstream thetaBuf((currentTrack->GetNextTouchableHandle()->GetVolume(1)->GetName()).substr(16,2));
511 nphi = 308-currentTrack->GetNextTouchableHandle()->GetCopyNumber(2);
513 npart=2-2*currentTrack->GetNextTouchableHandle()->GetCopyNumber(3);
514 int endSector=currentTrack->GetNextTouchableHandle()->GetCopyNumber(2);
516 std::istringstream thetaBuf((currentTrack->GetNextTouchableHandle()->GetVolume(0)->GetName()).substr(20,2));
522 ostringstream strEmc;
524 strEmc<<
"EmcPart"<<npart<<
"Theta0"<<ntheta<<
"Phi"<<nphi;
526 strEmc<<
"EmcPart"<<npart<<
"Theta"<<ntheta<<
"Phi"<<nphi;
530 Hep3Vector
nPhi(-
y/r,
x/r,0.);
533 Hep3Vector aPosition = currentPosition;
534 double R = aPosition.r();
535 double aTheta = aPosition.theta();
536 aPosition.setTheta(aTheta + M_PI_2);
538 errorTheta =(extXpErr->
get_plane_err(currentMomentum.unit(),aPosition.unit()))/R;
539 if(msgFlag) cout<<
"Theta direction: "<<aPosition<<endl;
540 myExtTrack->
SetEmcData(currentPosition/10,currentMomentum/1000,strEmc.str(),
542 newVolumeNumber,errorTheta,errorPhi,myOutputSymMatrix(extXpErr->
get_err()));
549 if(myEmcPathFlag && oldVolumeName.contains(
"Crystal") )
551 myPathOutCrystal = currentTrack->GetTrackLength();
552 myPathInCrystal = myPathInCrystal+myPathOutCrystal-myPathIntoCrystal;
559 if( (!myMucFlag) && ( (fabs(
x)>=myMucR) || (fabs(
y)>=myMucR) || ((fabs(
x-
y)/sqrt(2.))>=myMucR) || ((fabs(
x+
y)/sqrt(2.))>=myMucR) || (fabs(z)>=myMucZ) ) )
561 int newVolumeNumber = newVolume->GetCopyNo();
564 Hep3Vector xVector(1.0,0,0);
565 Hep3Vector yVector(0,1.0,0);
566 Hep3Vector zVector(0,0,1.0);
567 double xError = extXpErr->
get_plane_err(currentMomentum.unit(),xVector);
568 double yError = extXpErr->
get_plane_err(currentMomentum.unit(),yVector);
569 double zError = extXpErr->
get_plane_err(currentMomentum.unit(),zVector);
571 double phi = currentPosition.phi();
572 if(phi<0.) phi+=
M_PI;
573 int i = int(8.0*phi/
M_PI);
574 if( i==0 || i==7 || i==8 )
580 Hep3Vector tzVector(-1.0,1.0,0.);
581 tzError =extXpErr->
get_plane_err(currentMomentum.unit(),tzVector.unit());
589 Hep3Vector tzVector(1.0,1.0,0.);
590 tzError =extXpErr->
get_plane_err(currentMomentum.unit(),tzVector.unit());
592 myExtTrack->
SetMucData(currentPosition/10,currentMomentum/1000,newVolumeName,newVolumeNumber,myOutputSymMatrix(extXpErr->
get_err()),zError/10,tzError/10,xError/10,yError/10);
595 if(!(ParticleName.contains(
"mu")&&myUseMucKalFlag))
598 currentStep->GetTrack()->SetTrackStatus(fStopAndKill);
607 HepSymMatrix XpErr = extXpErr->
get_err();
608 int namesize = oldVolumeName.size();
609 bool Flag1(
false),Flag2(
false),Flag3(
false),Flag4(
false),Flag5(
false);
610 Flag1 = m_mucdigicol->size()>0;
611 Flag2 = myUseMucKalFlag;
612 Flag3 = ParticleName.contains(
"mu")&&oldVolumeName.contains(
"lMuc")&&oldVolumeName.contains(
"P")&&oldVolumeName.contains(
"S")&&(oldVolumeName.contains(
"G")||oldVolumeName.contains(
"Ab"));
613 Flag4 = oldVolumeName.contains(
"lMuc")&&oldVolumeName.contains(
"P")&&oldVolumeName.contains(
"S")&&((namesize==10&&oldVolumeName.contains(
"G"))||(namesize==11&&oldVolumeName.contains(
"Ab")));
614 Flag5 = !((RemID[0]==1&&RemID[2]==9)||((RemID[0]==0||RemID[0]==2)&&RemID[2]==8));
616 if(Flag1&&Flag2&&Flag3&&Flag5)
619 double depth = currentStep-> GetStepLength();
620 if(oldVolumeName.contains(
"Ab"))
621 RemDepth = RemDepth+ depth;
622 if(RemStep==0&&Flag4)
624 Hep3Vector ID_1 =
GetGapID(oldVolumeName);
627 bool LastLay = (ID_1[0]==1&&ID_1[2]<9)||((ID_1[0]==0||ID_1[0]==2)&&ID_1[2]<8);
628 if(RememberID[2]!=ID_1[2]&&LastLay)
631 double dist = fabs(pos_loc.z());
632 RemPositon = currentPosition;
633 RemMomentum = currentMomentum;
641 bool WillFilter =
false;
642 bool LastLay_ =
false;
643 double dist_b = 99999.;
648 LastLay_ =(ID_2[0]==1&&ID_2[2]<9)||((ID_2[0]==0||ID_2[0]==2)&&ID_2[2]<8);
649 if(LastLay_)dist_b=fabs(
MucGeoGeneral::Instance()->GetGap(ID_2[0],ID_2[1],ID_2[2])->TransformToGap(currentPosition).z());
656 double dist = fabs(pos_loc.z());
658 if(!WillFilter&&RemDist>dist)
660 RemPositon = currentPosition;
661 RemMomentum = currentMomentum;
664 RemVol = oldVolumeName;
676 vector<MucRecHit*> tmp = muckal->
TrackHit();
679 double chi2 = muckal->
GetChi2();
686 myMucchisq_ = myMucchisq_+chi2;
687 muckal->
XPmod(m_pos_mod,m_mom_mod,m_err_mod);
689 if(RememberID[0]==1)myMucbrLastLay_=RememberID[2];
690 if(RememberID[0]==0||RememberID[0]==2)myMucecLastLay_=RememberID[2];
691 if(oldVolumeName.contains(
"Ab"))
692 RemDepth = RemDepth-depth;
694 myMucdepth_ = RemDepth;
696 myMucdepth_=myMucdepth_+RemDepth;
704 currentStep->GetTrack()->SetTrackStatus(fStopAndKill);
710 RemPositon = currentPosition;
711 RemMomentum = currentMomentum;
715 if(oldVolumeName.contains(
"Ab"))
720 if(msgFlag)cout<<
"---------Filter is OK---------- "<<endl;
726 RemPositon = currentPosition;
727 RemMomentum = currentMomentum;
736 if(myExtTrack)myExtTrack->
SetMucKalData(myMucchisq_,myMucnfit_,myMucdepth_,myMucbrLastLay_,myMucecLastLay_,myMucnhits_);
806 if(msgFlag) cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<endl;
807 double x = currentPosition.x();
808 double y = currentPosition.y();
809 double z = currentPosition.z();
810 if( (fabs(
x)>=2*myMucR) || (fabs(
y)>=2*myMucR) || (fabs(z)>=2*myMucZ) )
812 {currentStep->GetTrack()->SetTrackStatus(fStopAndKill);m_trackstop=
true;}
816 else if(currentTrackStatus == fStopAndKill)
819 if(myEmcFlag) myExtTrack->
SetEmcPath(myPathInCrystal/10.);
823 cout <<
"myPathInTof1 = " ;
824 for(
int i=0; i!=myPathInTof1.size(); i++)
825 cout << myPathInTof1[i] <<
" ";
827 cout <<
"myPathInTof2 = " ;
828 for(
int i=0; i!=myPathInTof2.size(); i++)
829 cout << myPathInTof2[i] <<
" ";
837 std::cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<
"//stoped"<<endl;
838 cout<<
"Error matrix is:"<<extXpErr->
get_err()<<endl;
841 cout<<
"x:"<<currentPosition.x()<<
"//y:"<<currentPosition.y()<<
"//z:"<<currentPosition.z()<<
"||px:"<<currentMomentum.x()<<
"//py:"<<currentMomentum.y()<<
"//pz:"<<currentMomentum.z()<<
"//escaped"<<std::endl;
842 std::cout<<
"Error matrix is:"<<extXpErr->
get_err()<<std::endl;
850void ExtSteppingAction::CalculateChicc(G4Material* currentMaterial)
852 int n = currentMaterial->GetNumberOfElements();
853 const double *p = currentMaterial->GetFractionVector();
854 double density = (currentMaterial->GetDensity())/(g/cm3);
858 const G4Element* mElement = currentMaterial->GetElement(i);
859 double z = mElement->GetZ();
860 double a = mElement->GetN();
862 temp += *(p++)/a*z*(z+1);
864 chicc = 0.39612e-3*std::sqrt(density*temp);
869HepSymMatrix & ExtSteppingAction::myOutputSymMatrix(
const HepSymMatrix & m1)
877 {
for(
int j=0;j<=i;j++)
882 m[i][j]=m[i][j]/10000;
885 m[i][j]=m[i][j]/1000000;
898 if((sector>=0)&&(sector<3))
905 nphi = (sector-3)*4+nb;
907 else if((nb>=4)&&(nb<8))
910 nphi = (sector-3)*4+nb-4;
912 else if((nb>=8)&&(nb<13))
915 nphi = (sector-3)*5+nb-8;
917 else if((nb>=13)&&(nb<18))
920 nphi = (sector-3)*5+nb-13;
922 else if((nb>=18)&&(nb<24))
925 nphi = (sector-3)*6+nb-18;
927 else if((nb>=24)&&(nb<30))
930 nphi = (sector-3)*6+nb-24;
983 }
else if(
num==2||
num==3) {
1028 int par(-1),se(-1),ga(-1);
1029 G4String strPart = vol.substr(5,1);
1032 G4String strSeg = vol.substr(7,1);
1034 if(vol.contains(
"G")) strGap= vol.substr(9,1);
1035 if(vol.contains(
"Ab")) strGap= vol.substr(10,1);
1036 std::istrstream partBuf(strPart.c_str(), strlen(strPart.c_str()));
1037 std::istrstream segBuf(strSeg.c_str(), strlen(strSeg.c_str()));
1038 std::istrstream gapBuf(strGap.c_str(), strlen(strGap.c_str()));
1043 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)