Project

General

Profile

PC 120112 » MCpiDecay.C

Karadzhov, Yordan, 12 January 2012 14:22

 
1
{
2
  const double Dist = 2.46;
3
  const double P1 = 0.;               // m      TOF1 position
4
  const double P2 = P1 + Dist;        // m      TOF2 position
5
  const double tau_pi = 2.6e-8;       // s      pion lifetime
6
  const double E_pi_beam = 270.;      // MeV    beam energy
7
  const double m_pi = 139.57;         // MeV    pion mass
8
  const double m_mu = 105.66;         // MeV    muon mass
9
  //const double Ek_mu_cm = 4.12;     // MeV
10
  const double E_mu_cm = 109.78;      // MeV    muon energy in the c.m. system
11
  //const double P_mu_cm = 29.79;     // MeV/c
12
  const double P_mu_cm = sqrt(E_mu_cm*E_mu_cm - m_mu*m_mu);  // MeV/c
13
  
14
  TCanvas *c1 = new TCanvas("MC","MC",1200,800);
15
  TH1F *h1 = new TH1F("pi_time","time",200,7.,12.);   // time of flight for pions (no decay)
16
  TH1F *h2 = new TH1F("pimu_time","time",200,7.,12.); // time of flight for pions->muons (decay between TOF1 and TOF2)
17
  TH1F *h2a = new TH1F("dtimea","dtimea",200,7.,12.); 
18
  TH1F *h3 = new TH1F("tof","tof  MC",200,7.,12.);    // time of flight for all events
19
  h3->GetXaxis()->SetTitle("tof ns");
20
  TH1F *h4 = new TH1F("betaMu","betaMu",100,.6,1.);   // beta of the muons
21
  TH1F *h5 = new TH1F("betaPi","betaPi",100,.6,1.);   // beta of the pions
22
  TH1F *h6 = new TH1F("ThetaMu","ThetaMu",200,0,.6);//TMath::Pi());
23
  TH1F *h7 = new TH1F("dbeta","dbeta",100,-.5,.5);
24

    
25
  double P_pi_beam = sqrt(E_pi_beam*E_pi_beam - m_pi*m_pi);
26
  cout<<"E_pi = "<<E_pi_beam<<"   P_pi = "<<P_pi_beam<<"  beta_pi = "<< P_pi_beam/E_pi_beam <<endl;
27
  TRandom* Rand = new TRandom();
28
  Rand->SetSeed(0);
29

    
30
  int i = 0;
31
  while( i<1e4 )
32
  {
33
    double E_pi = Rand->Gaus(E_pi_beam, E_pi_beam*0.03);  // initial energy of the pion
34
    double Pz_pi = sqrt(E_pi*E_pi - m_pi*m_pi);
35
    TLorentzVector pi(0, 0, Pz_pi, E_pi);
36
    double beta_pi = pi.Beta();                           // pion beta
37
    double gamma_pi = pi.Gamma();                         // pion gamma
38

    
39
    // pion decay simulation
40
    double u = Rand->Uniform(0,1);
41
    double t_pi = -gamma_pi*tau_pi*log(u);
42
    double l_pi = t_pi*beta_pi*TMath::C();
43
    double l_mu = P2 - l_pi;
44

    
45
    double CosThCM_mu = Rand->Uniform(-1,1);
46
    double SinThCM_mu = sqrt(1 - CosThCM_mu*CosThCM_mu);
47
    double PhiCM_mu = Rand->Uniform(-TMath::Pi(),TMath::Pi());
48

    
49
    double px = P_mu_cm*SinThCM_mu*cos(PhiCM_mu);
50
    double py = P_mu_cm*SinThCM_mu*sin(PhiCM_mu);
51
    double pz = P_mu_cm*CosThCM_mu;
52

    
53
    TLorentzVector mu(px, py, pz, E_mu_cm);               // muon in the c.m. system
54
    mu.Boost(0,0,beta_pi);                                // muon in the lab. system
55
    double beta_mu = mu.Beta();
56
    double theta_mu = mu.Theta();
57

    
58
    h4->Fill(beta_mu);
59
    h5->Fill(beta_pi);
60
    h6->Fill(theta_mu);
61
    h7->Fill(beta_mu - beta_pi);
62

    
63
    if( l_pi < P1)
64
    {
65
      h2a->Fill( Dist/( beta_mu*TMath::C() )*1e9 );
66
      //h3->Fill( Dist/( beta_mu*TMath::C() )*1e9 );	  
67
    }
68
    else if(l_pi > P1 && l_pi < P2)  // decay between TOF1 and TOF2
69
    {
70
      double t1_pi = (l_pi - P1)/( beta_pi*TMath::C() )*1e9;
71
      double t2_mu = (P2 - l_pi)/( beta_mu*TMath::C() )*1e9;
72
      double tof = Rand->Gaus(t1_pi + t2_mu, 7e-2);  // measured time of flight [ns]
73
      h2->Fill(tof);
74
      h3->Fill(tof);
75
    }
76
    else if(l_pi > P2)   //No decay
77
    {
78
      double tof = Rand->Gaus( Dist/( beta_pi*TMath::C() )*1e9, 7e-2);
79
      h1->Fill(tof);
80
      h3->Fill(tof);
81
    }
82
    i++;
83
  }
84

    
85
  c1->Divide(2,0);
86
  /*
87
  c1->cd(4);
88
  h7->GetXaxis()->SetTitle("#beta_{#mu} -#beta_{#pi} ");
89
  h7->Draw();
90
  */
91
  c1->cd(2);
92

    
93
  h3->SetFillColor(kGray);
94
  h3->Draw();
95
  h2->SetLineColor(kBlue);
96
  h2->Draw("same");
97
  h2a->SetLineColor(kGreen);
98
  //h2a->Draw("same"); 
99
  h1->SetLineColor(kRed);
100
  h1->Draw("same"); 
101

    
102
  c1->cd(1);
103
  h5->SetLineColor(kBlue);
104
  h5->GetXaxis()->SetTitle("#beta");
105
  h5->Draw();
106
  h5->SetLineColor(kRed);
107
  h4->Draw("sames");
108
/*
109
  c1->cd(3);
110
  h6->Draw();
111
*/
112
}
113

    
114

    
115

    
116

    
117

    
118

    
119

    
120

    
121

    
(5-5/7)