Project

General

Profile

Script to obtain first scintillator events from runs ยป yield_W_cuts.C

Richard Trotta, 05/10/2018 03:22 PM

 
1
int yield_W_cuts(Int_t RunNumber=0){
2
  
3
  if(RunNumber == 0) {
4
    cout << "Enter a Run Number (-1 to exit): ";
5
    cin >> RunNumber;
6
    if( RunNumber<=0 ){
7
    	cerr << "...Invalid entry\n";
8
      	exit;
9
    }
10
  }
11
   const char* ROOTFileNamePattern = "$HOME/Analysis/hallc_replay/ROOTfiles/hms_replay_production_all_%d_-1.root";
12
   TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber);
13
   TString rNumber = Form("%d",RunNumber);  
14
  
15
  TChain *T=new TChain("T");
16
  T-> Add(ROOTFileName); 
17
  Int_t N1= T->GetEntries();
18
  //TSH->StartViewer();
19

    
20
  TCut cTrotta = "";
21
  //TCut cCuts = "hcer_npe>0.5 && hsshtrk>0.7 && hsdelta>-8.5 && hsdelta<8.5 && hsxptar>-0.09 && hsxptar<0.09 && hsyptar>-0.055 &&  		hsyptar<0.055 && hsytar>-3.5 && hsytar<3.5";
22
  TCut cCuts = "H.cer.npeSum>0.5 && H.tr.tg_dp>-8.5 && H.tr.tg_dp<8.5 && H.cal.etracknorm>0.7";
23

    
24
 TH1F *h1 = new TH1F("h1","W Cuts for " + rNumber, 200, -20, 20);
25
 TCanvas *c0 = new TCanvas("c0","c0");
26
 
27
 //T->Draw("H.kin.W>>h1");
28
 T->Draw("H.kin.W>>h1", cCuts); 
29

    
30
 
31
//*/
32
//title of axes
33
//h1->GetXaxis()->SetTitle("W (GeV)");
34
h1->GetYaxis()->SetTitle("H.kin.W"); 
35
h1->SetLineColor(2);
36

    
37
/*
38
//legend
39
leg = new TLegend(0.1,0.9,0.38,0.8);
40
//leg->SetBorderSize(0);
41
leg->AddEntry(h1, "Q^{2}=3.0 GeV^{2} #epsilon = 0.8800", "l");
42
leg->AddEntry(h1a, "Q^{2}=3.0 GeV^{2} #epsilon = 0.6070", "l");
43
leg->Draw();
44
*/
45

    
46
gStyle->SetOptStat(0); //gets rid of the annoying box
47

    
48

    
49
cout << "Integrate: " << h1->Integral() << endl;
50

    
51
ofstream myfile;
52
  myfile.open ("eltrack_events.txt", fstream::app);
53
  myfile << rNumber << "->" << h1->Integral() <<"\n"; //write to file
54
  myfile.close();
55

    
56

    
57
//c0->Print("yield_W_"+ rNumber + ".png");
58
c0->Print("yield_W_Cuts_"+ rNumber + ".png");
59

    
60

    
61
  return 0;
62
    }
63

    
    (1-1/1)