StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
simW_jacobKin.C
1 int yellCol=kYellow;
2 TH2F *h2D=new TH2F("kin2D","W #rightarrow e + #nu, 3D isotropic in W CMS; electron P_{Z} (GeV/c); electron P_{T} (GeV/c)",100,-60,60,50,0,60);
3 TH1F *hmcPt,*hmcP;
4 
5 TRandom3 *rnd=new TRandom3();
6 
7 void simW_jacobKin() {
8  gStyle->SetPalette(1,0);
9  gStyle->SetOptStat(1000000);
10 
11  //.... Pythia W events , Endcap ignored
12  TFile *fdnEPW = TFile::Open("noEndcap/mcSetD1_ppWprod.wana.hist.root");
13  assert(fdnEPW->IsOpen());
14  hPW=(TH1F*)fdnEPW->Get("pubJoe1"); assert(hPW);
15  hPW->SetTitle("accepted Pythia Ws");
16  int nEve=1000;
17  float sig=0.; // GeV
18 
19  ax=hPW->GetXaxis();
20  ax->SetTitleSize(0.05); ax->SetTitleOffset(0.8);
21 
22  hmcPt=(TH1F *) hPW->Clone();
23  hmcPt->Reset();
24  hmcPt->SetNameTitle("mcPt","Isotropic W decay; electron P_{T} (GeV/c)");
25 
26  hmcP=(TH1F *) hPW->Clone();
27  hmcP->Reset();
28  hmcP->SetNameTitle("mcP","Isotropic W decay; electron P (GeV/c)");
29 
30  hPW->SetLineColor(kRed);
31  hPW->Sumw2();
32 
33  //....... generate events
34  for(int i=0;i<nEve;i++) throwDecay(sig);
35 
36  float fac=hmcPt->Integral()/hPW->Integral();
37  hPW->Scale(fac);
38 
39  float mxY=hPW->GetMaximum();
40  if(mxY<mcPt->GetMaximum())mxY=mcPt->GetMaximum();
41  hmcPt->SetMaximum(1.1*mxY);
42 
43  // plot raw spectra ..........
44  c=new TCanvas("aa2","aa2",1000,400);
45  TPad *cL,*cR; splitPadX(0.5,&cL,&cR);
46  cL->cd(); h2D->Draw("colz");
47  ln=new TLine(-55,15,55,15); ln->SetLineColor(kBlue); ln->Draw();
48  tx=new TText(-28,10,"ET>15 GeV cut used in reco"); tx->Draw(); tx->SetTextColor(kBlue); tx->SetTextSize(0.04);
49  char txt[1000]; sprintf(txt,"smear 1D #sigma=%.0f GeV",sig);
50  tx=new TLatex(-50,55,txt); tx->Draw();
51 
52  cR->cd();
53  cR->Divide(2,1); //c->cd(3); hPW->Draw();
54 
55  cR->cd(1); hmcPt->Draw(); hmcPt->SetAxisRange(10,60); hPW->Draw("same");
56  cR->cd(2); hmcP->Draw(); hmcP->SetAxisRange(10,60);
57 
58 }
59 
60 void throwDecay(float sig=3.) {// spread W momentum in GeV
61  float Pmag=40; // energy avaliable to electron in GeV
62  float phi=2*3.1416*rnd->Uniform();
63  float cosTh=2*rnd->Uniform()-1.;
64  float theta=acos(cosTh);
65  TVector3 P(1,2,3); P.SetMag(Pmag); P.SetTheta(theta); P.SetPhi(phi); // mean
66  TVector3 sigP(rnd->Gaus(0,sig),rnd->Gaus(0,sig),rnd->Gaus(0,sig));// spread
67  P=P+sigP;
68  h2D->Fill(P.z(), P.Pt());
69  if( fabs(P.Pt())<15) continue; // minPt cut used in analysis
70  hmcPt->Fill(P.Pt());
71  hmcP->Fill(P.Mag());
72 }
73 
74  //printf("%f %f %f \n", P.x(),P.y(), P.z());
75  // printf("%f %f %f \n", sigP.x(),sigP.y(), sigP.z());
76 
77 
78 //------------------------
79 void splitPadX(float x, TPad **cL, TPad **cR) {
80  (*cL) = new TPad("padL", "apdL",0.0,0.,x,0.95);
81  (*cL)->Draw();
82  (*cR) = new TPad("padL", "apdL",x+0.005,0.,1.0,0.95);
83  (*cR)->Draw();
84 }
85