CMS 3D CMS Logo

CMSSQLoopProcessDiscr.cc
Go to the documentation of this file.
1 
3 #include "G4SystemOfUnits.hh"
4 #include "G4Step.hh"
5 #include "G4ParticleDefinition.hh"
6 #include "G4VParticleChange.hh"
7 
9 
10 CMSSQLoopProcessDiscr::CMSSQLoopProcessDiscr(double mass, const G4String& name, G4ProcessType type)
11  : G4VDiscreteProcess(name, type) {
12  fParticleChange = new G4ParticleChange();
13  fParticleChange->ClearDebugFlag();
14  GenMass = mass;
15 }
16 
18 
19 G4VParticleChange* CMSSQLoopProcessDiscr::PostStepDoIt(const G4Track& track, const G4Step& step) {
20  G4Track* mytr = const_cast<G4Track*>(&track);
21  mytr->SetPosition(posini);
22  if (mytr->GetGlobalTime() / ns > 4990)
23  edm::LogWarning("CMSSQLoopProcess::AlongStepDoIt")
24  << "going to loose the particle because the GlobalTime is getting close to 5000" << std::endl;
25 
26  fParticleChange->Clear();
27  fParticleChange->Initialize(track);
28 
29  //adding secondary antiS
30  fParticleChange->SetNumberOfSecondaries(1);
31  G4DynamicParticle* replacementParticle =
32  new G4DynamicParticle(CMSAntiSQ::AntiSQ(GenMass), track.GetMomentumDirection(), track.GetKineticEnergy());
33  fParticleChange->AddSecondary(replacementParticle, globaltimeini);
34 
35  //killing original AntiS
36  fParticleChange->ProposeTrackStatus(fStopAndKill);
37 
38  // note SL: this way of working makes a very long history of the track,
39  // which all get saved recursively in SimTracks. If the cross section
40  // is too low such that 10's of thousands of iterations are needed, then
41  // this becomes too heavy to swallow writing out this history.
42  // So if we ever need very small cross sections, then we really need
43  // to change this way of working such that we can throw away all original
44  // tracks and only save the one that interacted.
45 
46  return fParticleChange;
47 }
48 
50  G4double previousStepSize,
51  G4ForceCondition* condition) {
52  *condition = NotForced;
53  G4double intLength =
54  DBL_MAX; //by default the interaction length is super large, only when outside tracker make it 0 to be sure it will do the reset to the original position
55  G4Track* mytr = const_cast<G4Track*>(&track);
56  if (sqrt(pow(mytr->GetPosition().rho(), 2)) >
57  2.45 *
58  centimeter) { //this is an important cut for the looping: if the radius of the particle is largher than 2.45cm its interaction length becomes 0 which means it will get killed
59  // updated from 2.5 to 2.45 so that the Sbar does not start to hit the support of the new inner tracker which was added in 2018
60  intLength = 0.0; //0 interaction length means particle will directly interact.
61  }
62  return intLength;
63 }
64 
65 G4double CMSSQLoopProcessDiscr::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*) { return DBL_MAX; }
66 
67 void CMSSQLoopProcessDiscr::StartTracking(G4Track* aTrack) {
68  posini = aTrack->GetPosition();
69  globaltimeini = aTrack->GetGlobalTime();
70 }
CMSSQLoopProcessDiscr(double mass, const G4String &name="SQLooper", G4ProcessType type=fUserDefined)
virtual void StartTracking(G4Track *aTrack)
T sqrt(T t)
Definition: SSEVec.h:23
virtual G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *)
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
const double intLength[kNumberCalorimeter]
static CMSAntiSQ * AntiSQ(double mass)
Definition: CMSAntiSQ.cc:41
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
step
Definition: StallMonitor.cc:83
G4ParticleChange * fParticleChange
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29