mollerClass.C

Go to the documentation of this file.
00001 #define mollerClass_cxx
00002 #include "mollerClass.h"
00003 #include <TH3.h>
00004 #include <TH2.h>
00005 #include <TStyle.h>
00006 #include <TCanvas.h>
00007 #include <TMath.h>
00008 #include <iostream>
00009 #include <TGaxis.h>
00010 #include <TProfile2D.h>
00011 #include <TF1.h>
00012 #include <TPaveLabel.h>
00013 #include "profile.h"
00014 
00015 using namespace std;
00016 
00017 Int_t eventtype=-1;  //This comes from 0=moller, 1=proton, 2=inelastic
00018 Int_t num_thrown=0;
00019 char inifilename[256];
00020 
00021 void SetupHist(TH1F* histo, Int_t colorint) 
00022 {
00023   //histo->Sumw2();
00024   if (colorint==0) colorint=kRed;
00025   else if (colorint==1) colorint=kGreen;
00026   else if (colorint==2) colorint=kBlue;
00027   histo->SetLineColor(colorint);
00028   //histo->SetMarkerColor(colorint);
00029   //histo->SetMarkerStyle(20);
00030   histo->StatOverflows(0);
00031 }
00032 
00033 void PrintHist(TH1F* histo[], char* histoname, Int_t numhistos=4, Bool_t dology=0, Bool_t debug=0)
00034 {
00035   char my_name[256];
00036   char my_name2[256];
00037   snprintf(my_name2,200,"r_%i_0",eventtype);
00038   sprintf(my_name,"%s",histo[0]->GetName());
00039   int comp = strcmp( my_name, my_name2);
00040 
00041   if (debug) {
00042     Printf("Debug: %s\n",histoname);
00043     for  (int i=0; i<5; i++) {
00044       printf("  %f,",histo[i]->GetEntries());
00045     }
00046     printf("\n");
00047   }
00048   TCanvas printcanvas("printcanvas","canvas",640,480);
00049   Double_t minnum=0, maxnum=0;
00050   for (int i=0; i<numhistos; i++) {
00051     minnum = TMath::Min(minnum,histo[i]->GetMinimum(0));
00052     maxnum = TMath::Max(maxnum,histo[i]->GetMaximum());
00053     //printf("new min = %f\n",minnum);
00054   }
00055   printf("min = %f, max = %f\n",minnum, maxnum); 
00056 
00057   Double_t xmin;
00058   xmin = 0.75;
00059   if(!comp) xmin = 0.65;
00060   Double_t xmax=0.999;  
00061   Double_t ymax=0.999, deltay=0.045, ymin=ymax-deltay;
00062   char label[256][numhistos];
00063   TPaveLabel *pt[numhistos];
00064   TPaveLabel *pt_main;
00065   pt_main = new TPaveLabel(xmin,ymin,xmax,ymax,"Entries  Mean  RMS","NDC");
00066     if(!comp) pt_main = new TPaveLabel(xmin,ymin,xmax,ymax,"Entries  Mean  RMS  Int","NDC");
00067   pt_main->SetBorderSize(1);
00068   pt_main->SetFillColor(0);
00069   ymax=ymin;
00070   ymin=ymax-deltay;
00071   Bool_t first=1;
00072   for (Int_t j = 0; j < numhistos; j++) {
00073     Int_t i = numhistos - 1 - j;
00074     sprintf(label[i],"%.0f  %.4g  %.4g",histo[i]->GetEntries(),histo[i]->GetMean(),histo[i]->GetRMS());
00075     if(!comp) sprintf(label[i],"%.0f  %.4g  %.4g  %.4g",histo[i]->GetEntries(),histo[i]->GetMean(),histo[i]->GetRMS(),histo[i]->Integral());
00076 
00077     pt[i] = new TPaveLabel(xmin,ymin,xmax,ymax,label[i],"NDC");
00078     pt[i]->SetBorderSize(1);
00079     pt[i]->SetFillColor(0);
00080     if(dology==1&&minnum==0) minnum = 0.01;
00081     histo[i]->SetMinimum(minnum);
00082     histo[i]->SetMaximum(1.05*maxnum);
00083     histo[i]->GetXaxis()->SetTitleOffset(1.2);
00084     if (i==0) {
00085       pt[i]->SetTextColor(kRed);
00086       histo[i]->SetLineColor(kRed);
00087     }
00088     if (i==1) {
00089       pt[i]->SetTextColor(kGreen);
00090       histo[i]->SetLineColor(kGreen);
00091     }
00092     if (i==2) {
00093       pt[i]->SetTextColor(kBlue);
00094       histo[i]->SetLineColor(kBlue);
00095     }
00096     if (i==3) {
00097       pt[i]->SetTextColor(kBlack);
00098       histo[i]->SetLineColor(kBlack);
00099     }
00100     if (i==4) {
00101       pt[i]->SetTextColor(7);
00102       histo[i]->SetLineColor(7);
00103     }
00104     if (first) {
00105       histo[i]->Draw();
00106       pt_main->Draw();
00107       first=0;
00108     } else {
00109       histo[i]->Draw("same");
00110     }
00111     pt[i]->Draw();
00112     ymax=ymin;
00113     ymin=ymax-deltay;
00114   }
00115 
00116   //  pt4->SetTextColor(7);
00117   //  pt1->SetTextColor(kRed);
00118   //  pt2->SetTextColor(kBlue);
00119   //  pt3->SetTextColor(kGreen);
00120 
00121 
00122   //  char label[256][numhistos];//, label_1[256], label_2[256], label_3[256], label_4[256];
00123   //  //sprintf(formatstring,"%%.0f  %%e  %%e",);
00124   //  //sprintf(label,  "%.0f  %.3g  %.3g",sumhisto->GetEntries(),sumhisto->GetMean(),sumhisto->GetRMS());
00125   //  sprintf(label_4,"%.0f  %.3g  %.3g",histo[4]->GetEntries(),histo[4]->GetMean(),histo[4]->GetRMS());
00126   //  sprintf(label  ,"%.0f  %.3g  %.3g",histo[3]->GetEntries(),histo[3]->GetMean(),histo[3]->GetRMS());
00127   //  sprintf(label_1,"%.0f  %.3g  %.3g",histo[0]->GetEntries(),histo[0]->GetMean(),histo[0]->GetRMS());  
00128   //  sprintf(label_2,"%.0f  %.3g  %.3g",histo[2]->GetEntries(),histo[2]->GetMean(),histo[2]->GetRMS());
00129   //  sprintf(label_3,"%.0f  %.3g  %.3g",histo[1]->GetEntries(),histo[1]->GetMean(),histo[1]->GetRMS());
00130   //  Double_t xmin=0.75, xmax=0.999;  
00131   //  Double_t ymax=0.999, deltay=0.045, ymin=ymax-deltay;
00132   //  TPaveLabel *pt0 = new TPaveLabel(xmin,ymin,xmax,ymax,"Entries  Mean  RMS","NDC");
00133   //  pt0->SetBorderSize(1);
00134   //  ymax=ymin;
00135   //  ymin=ymax-deltay;
00136   //  TPaveLabel *pt4 = new TPaveLabel(xmin,ymin,xmax,ymax,label_4,"NDC");
00137   //  pt4->SetBorderSize(1);
00138   //  pt4->SetTextColor(7);
00139   //  ymax=ymin;
00140   //  ymin=ymax-deltay;
00141   //  TPaveLabel *pt = new TPaveLabel(xmin,ymin,xmax,ymax,label,"NDC");
00142   //  pt->SetBorderSize(1);
00143   //  ymax=ymin;
00144   //  ymin=ymax-deltay;
00145   //  TPaveLabel *pt1 = new TPaveLabel(xmin,ymin,xmax,ymax,label_1,"NDC");
00146   //  pt1->SetBorderSize(1);
00147   //  pt1->SetTextColor(kRed);
00148   //  ymax=ymin;
00149   //  ymin=ymax-deltay;
00150   //  TPaveLabel *pt2 = new TPaveLabel(xmin,ymin,xmax,ymax,label_2,"NDC");
00151   //  pt2->SetBorderSize(1);
00152   //  pt2->SetTextColor(kBlue);
00153   //  ymax=ymin;
00154   //  ymin=ymax-deltay;
00155   //  TPaveLabel *pt3 = new TPaveLabel(xmin,ymin,xmax,ymax,label_3,"NDC");
00156   //  pt3->SetBorderSize(1);
00157   //  pt3->SetTextColor(kGreen);
00158   //  ymax=ymin;
00159   //  ymin=ymax-deltay;
00160   //  pt0->SetFillColor(0); pt->SetFillColor(0);  pt1->SetFillColor(0);  
00161   //  pt2->SetFillColor(0);  pt3->SetFillColor(0);
00162   //  pt4->SetFillColor(0);
00163   //  pt0->Draw();
00164   //  pt->Draw();
00165   //  pt1->Draw();
00166   //  pt2->Draw();
00167   //  pt3->Draw();
00168   //  pt4->Draw();
00169 
00170 
00171   printcanvas.SetLogy(dology);
00172   printcanvas.Print(histoname);
00173 }
00174 
00175 void PrintHist2D(TH2F* histo[], char* histoname)
00176 {
00177   TCanvas printcanvas("printcanvas","canvas",640,480);
00178   histo[0]->SetMarkerColor(kRed);
00179   histo[1]->SetMarkerColor(kGreen);
00180   histo[2]->SetMarkerColor(kBlue);
00181   histo[0]->SetLineColor(kRed);
00182   histo[1]->SetLineColor(kGreen);
00183   histo[2]->SetLineColor(kBlue);
00184   histo[3]->Draw("contourz");
00185   char histoname2[200];
00186   snprintf(histoname2,200,"%s_black.gif",histoname);
00187   printcanvas.Print(histoname2);
00188   histo[0]->Draw("contourz");
00189   snprintf(histoname2,200,"%s_red.gif",histoname);
00190   printcanvas.Print(histoname2);
00191   histo[1]->Draw("contourz");
00192   snprintf(histoname2,200,"%s_green.gif",histoname);
00193   printcanvas.Print(histoname2);
00194   histo[2]->Draw("contourz");
00195   snprintf(histoname2,200,"%s_blue.gif",histoname);
00196   printcanvas.Print(histoname2);
00197   histo[4]->Draw("contourz");
00198   //histo[0]->Draw("contour,same");
00199   //histo[1]->Draw("contour,same");
00200   //histo[2]->Draw("contour,same");
00201   printcanvas.Print(histoname);
00202 }
00203 
00204 void mollerClass::Loop()
00205 {
00206 
00207   if (fChain == 0) return;
00208 
00209   Long64_t nentries = fChain->GetEntriesFast();
00210 
00211   TCanvas canvas("canvas","canvas",640,480);
00212 
00213   Double_t pi = TMath::Pi();
00214   gROOT->SetStyle("Plain");
00215   gStyle->SetOptStat(kFALSE);
00216   gStyle->SetPalette(1,0);
00217   gStyle->SetTitleBorderSize(0);
00218   gStyle->SetCanvasBorderMode(0);
00219 
00220   Int_t num_detectors = 28;
00221   char plotname[200],outdir[200],namestem[200],plottype[10];
00222 
00223 
00224   snprintf(namestem,200,"%sdets%i_",outdir,num_detectors);
00225   GetPrivateProfileString ("General", "outdir", "output", outdir, 200, inifilename);
00226   GetPrivateProfileString ("General", "plottype", ".gif", plottype, 20, inifilename);
00227 
00228 
00229   TH1F* std_ave_asym=new TH1F("ave_asym","Average transverse asymmetry;detector number;#bar{A_{T}}   (ppm)",
00230                 num_detectors/8,0,num_detectors); 
00231   TH1F* std_total_asym=new TH1F("total_asym","Total XSec and transverse asymmetry weighted events;detector number",
00232                   num_detectors/8,0,num_detectors); 
00233   TH1F* std_total_sample=new TH1F("total_sample","Total XSec weighted events;detector number",
00234                   num_detectors/8,0,num_detectors); 
00235   std_ave_asym->Sumw2();
00236   std_total_asym->Sumw2();
00237   std_total_sample->Sumw2();
00238   std_ave_asym->SetMarkerStyle(20);
00239   std_total_asym->SetMarkerStyle(20);
00240   std_total_sample->SetMarkerStyle(20);
00241   TH1F* std_red_ave_asym=new TH1F("std_red_ave_asym","Average transverse asymmetry;detector number;#bar{A_{T}}   (ppm)",
00242                   num_detectors,0,num_detectors); 
00243   TH1F* std_red_total_asym=new TH1F("std_red_total_asym","Total (XSec and transverse asymmetry weighted) events;detector number",
00244                     num_detectors,0,num_detectors); 
00245   TH1F* std_red_total_sample=new TH1F("std_red_total_sample","Total (XSec weighted) events;detector number",
00246                     num_detectors,0,num_detectors); 
00247   std_red_ave_asym->Sumw2();
00248   std_red_total_asym->Sumw2();
00249   std_red_total_sample->Sumw2();
00250   std_red_ave_asym->SetLineColor(kRed);
00251   std_red_total_asym->SetLineColor(kRed);
00252   std_red_total_sample->SetLineColor(kRed);
00253   std_red_ave_asym->SetMarkerColor(kRed);
00254   std_red_total_asym->SetMarkerColor(kRed);
00255   std_red_total_sample->SetMarkerColor(kRed);
00256   std_red_ave_asym->SetMarkerStyle(20);
00257   std_red_total_asym->SetMarkerStyle(20);
00258   std_red_total_sample->SetMarkerStyle(20);
00259   TH1F* std_green_ave_asym=new TH1F("std_green_ave_asym","Average transverse asymmetry;detector number;#bar{A_{T}}   (ppm)",
00260                     num_detectors,0,num_detectors); 
00261   TH1F* std_green_total_asym=new TH1F("std_green_total_asym","Total (XSec and transverse asymmetry weighted) events;detector number",
00262                     num_detectors,0,num_detectors); 
00263   TH1F* std_green_total_sample=new TH1F("std_green_total_sample","Total (XSec weighted) events;detector number",
00264                       num_detectors,0,num_detectors); 
00265   std_green_ave_asym->Sumw2();
00266   std_green_total_asym->Sumw2();
00267   std_green_total_sample->Sumw2();
00268   std_green_ave_asym->SetLineColor(kGreen);
00269   std_green_total_asym->SetLineColor(kGreen);
00270   std_green_total_sample->SetLineColor(kGreen);
00271   std_green_ave_asym->SetMarkerColor(kGreen);
00272   std_green_total_asym->SetMarkerColor(kGreen);
00273   std_green_total_sample->SetMarkerColor(kGreen);
00274   std_green_ave_asym->SetMarkerStyle(20);
00275   std_green_total_asym->SetMarkerStyle(20);
00276   std_green_total_sample->SetMarkerStyle(20);
00277   TH1F* std_blue_ave_asym=new TH1F("std_blue_ave_asym","Average transverse asymmetry;detector number;#bar{A_{T}}   (ppm)",
00278                    num_detectors,0,num_detectors); 
00279   TH1F* std_blue_total_asym=new TH1F("std_blue_total_asym","Total (XSec and transverse asymmetry weighted) events;detector number",
00280                      num_detectors,0,num_detectors); 
00281   TH1F* std_blue_total_sample=new TH1F("std_blue_total_sample","Total (XSec weighted) events;detector number",
00282                      num_detectors,0,num_detectors); 
00283   std_blue_ave_asym->Sumw2();
00284   std_blue_total_asym->Sumw2();
00285   std_blue_total_sample->Sumw2();
00286   std_blue_ave_asym->SetLineColor(kBlue);
00287   std_blue_total_asym->SetLineColor(kBlue);
00288   std_blue_total_sample->SetLineColor(kBlue);
00289   std_blue_ave_asym->SetMarkerColor(kBlue);
00290   std_blue_total_asym->SetMarkerColor(kBlue);
00291   std_blue_total_sample->SetMarkerColor(kBlue);
00292   std_blue_ave_asym->SetMarkerStyle(20);
00293   std_blue_total_asym->SetMarkerStyle(20);
00294   std_blue_total_sample->SetMarkerStyle(20);
00295 
00296 
00297 
00298 
00299   TH1F* eweight_ave_asym=new TH1F("eweight_ave_asym","Average transverse asymmetry, energy weighted detectors;detector number;#bar{A_{T}}   (ppm)",
00300                   num_detectors/8,0,num_detectors); 
00301   TH1F* eweight_total_asym=new TH1F("eweight_total_asym","Total (energy, XSec and transverse asymmetry weighted) events;detector number",
00302                     num_detectors/8,0,num_detectors); 
00303   TH1F* eweight_total_sample=new TH1F("eweight_total_sample","Total (energy and XSec weighted) events;detector number",
00304                     num_detectors/8,0,num_detectors); 
00305   eweight_ave_asym->Sumw2();
00306   eweight_total_asym->Sumw2();
00307   eweight_total_sample->Sumw2();
00308   eweight_ave_asym->SetMarkerStyle(20);
00309   eweight_total_asym->SetMarkerStyle(20);
00310   eweight_total_sample->SetMarkerStyle(20);
00311   TH1F* eweight_red_ave_asym=new TH1F("eweight_red_ave_asym","Average transverse asymmetry, energy weighted detectors;detector number;#bar{A_{T}}   (ppm)",
00312                     num_detectors,0,num_detectors); 
00313   TH1F* eweight_red_total_asym=new TH1F("eweight_red_total_asym","Total (energy, XSec and transverse asymmetry weighted) events;detector number",
00314                       num_detectors,0,num_detectors); 
00315   TH1F* eweight_red_total_sample=new TH1F("eweight_red_total_sample","Total (energy and XSec weighted) events;detector number",
00316                       num_detectors,0,num_detectors); 
00317   eweight_red_ave_asym->Sumw2();
00318   eweight_red_total_asym->Sumw2();
00319   eweight_red_total_sample->Sumw2();
00320   eweight_red_ave_asym->SetLineColor(kRed);
00321   eweight_red_total_asym->SetLineColor(kRed);
00322   eweight_red_total_sample->SetLineColor(kRed);
00323   eweight_red_ave_asym->SetMarkerColor(kRed);
00324   eweight_red_total_asym->SetMarkerColor(kRed);
00325   eweight_red_total_sample->SetMarkerColor(kRed);
00326   eweight_red_ave_asym->SetMarkerStyle(20);
00327   eweight_red_total_asym->SetMarkerStyle(20);
00328   eweight_red_total_sample->SetMarkerStyle(20);
00329   TH1F* eweight_green_ave_asym=new TH1F("eweight_green_ave_asym","Average transverse asymmetry, energy weighted detectors;detector number;#bar{A_{T}}   (ppm)",
00330                       num_detectors,0,num_detectors); 
00331   TH1F* eweight_green_total_asym=new TH1F("eweight_green_total_asym","Total (energy, XSec and transverse asymmetry weighted) events;detector number",
00332                       num_detectors,0,num_detectors); 
00333   TH1F* eweight_green_total_sample=new TH1F("eweight_green_total_sample","Total (energy and XSec weighted) events;detector number",
00334                         num_detectors,0,num_detectors); 
00335   eweight_green_ave_asym->Sumw2();
00336   eweight_green_total_asym->Sumw2();
00337   eweight_green_total_sample->Sumw2();
00338   eweight_green_ave_asym->SetLineColor(kGreen);
00339   eweight_green_total_asym->SetLineColor(kGreen);
00340   eweight_green_total_sample->SetLineColor(kGreen);
00341   eweight_green_ave_asym->SetMarkerColor(kGreen);
00342   eweight_green_total_asym->SetMarkerColor(kGreen);
00343   eweight_green_total_sample->SetMarkerColor(kGreen);
00344   eweight_green_ave_asym->SetMarkerStyle(20);
00345   eweight_green_total_asym->SetMarkerStyle(20);
00346   eweight_green_total_sample->SetMarkerStyle(20);
00347   TH1F* eweight_blue_ave_asym=new TH1F("eweight_blue_ave_asym","Average transverse asymmetry, energy weighted detectors;detector number;#bar{A_{T}}   (ppm)",
00348                      num_detectors,0,num_detectors); 
00349   TH1F* eweight_blue_total_asym=new TH1F("eweight_blue_total_asym","Total (energy, XSec and transverse asymmetry weighted) events;detector number",
00350                        num_detectors,0,num_detectors); 
00351   TH1F* eweight_blue_total_sample=new TH1F("eweight_blue_total_sample","Total (energy and XSec weighted) events;detector number",
00352                        num_detectors,0,num_detectors); 
00353   eweight_blue_ave_asym->Sumw2();
00354   eweight_blue_total_asym->Sumw2();
00355   eweight_blue_total_sample->Sumw2();
00356   eweight_blue_ave_asym->SetLineColor(kBlue);
00357   eweight_blue_total_asym->SetLineColor(kBlue);
00358   eweight_blue_total_sample->SetLineColor(kBlue);
00359   eweight_blue_ave_asym->SetMarkerColor(kBlue);
00360   eweight_blue_total_asym->SetMarkerColor(kBlue);
00361   eweight_blue_total_sample->SetMarkerColor(kBlue);
00362   eweight_blue_ave_asym->SetMarkerStyle(20);
00363   eweight_blue_total_asym->SetMarkerStyle(20);
00364   eweight_blue_total_sample->SetMarkerStyle(20);
00365 
00366 
00367   TH1F* rate_total=new TH1F("rate_total","Total rate for 85  #muA;detector number;rate   [Hz]",num_detectors,0,num_detectors);
00368   TH1F* num_events=new TH1F("num_events","Number of Moller e^{-}  in 1 hour at 85  #muA;detector number",num_detectors,0,num_detectors);
00369   TH1F* error=new TH1F("error","Uncertainty in 1 hour at 85  #muA;detector number;#Delta A_{T}   (ppm)",num_detectors,0,num_detectors);
00370 
00371   rate_total->SetMarkerStyle(20);
00372   num_events->SetMarkerStyle(20);
00373   error->SetMarkerStyle(20);
00374   rate_total->Sumw2();
00375   num_events->Sumw2();
00376   error->Sumw2();
00377   //  std_total_asym->SetMarkerStyle(20);
00378   //  std_total_sample->SetMarkerStyle(20);
00379 
00380 
00381 
00382   TH2F* test=new TH2F("test","test",num_detectors*2,-pi,pi,num_detectors*2,0,num_detectors);
00383   TH2F* paperfig=new TH2F("paperfig","A_{T}/sin#phi for E_{vert}=11 GeV;cos#theta_{c.m.};A_{T}/sin#phi   (ppm)",
00384               400,-1,1,400,-15,15);
00385   TH3F* paperfig2=new TH3F("paperfig2","A_{T};cos#theta_{c.m.};#phi_{c.m.};A_{T}   (ppm)",
00386                200,-1,1,200,-pi,pi,200,-15,15);
00387   TH2F* distro_red=new TH2F("distro_red","Distribution of red events;cos#theta_{c.m.};#phi_{c.m.}",
00388                 400,-1,1,400,-pi,pi);
00389   distro_red->SetMarkerColor(kRed);
00390   TH2F* distro_green=new TH2F("distro_green","Distribution of green events;cos#theta_{c.m.};#phi_{c.m.}",
00391                 400,-1,1,400,-pi,pi);
00392   distro_green->SetMarkerColor(kGreen);
00393   TH2F* distro_blue=new TH2F("distro_blue","Distribution of blue events;cos#theta_{c.m.};#phi_{c.m.}",
00394                  400,-1,1,400,-pi,pi);
00395   distro_blue->SetMarkerColor(kBlue);
00396 
00397 
00398   TH2F* distro_rphi=new TH2F("distro_rphi",";r   (m);#phi_{c.m.}", 400,0,1.3,400,-pi,pi);
00399   TH2F* distro_r_edet=new TH2F("distro_r_edet",";r   (m);E_{det}   (MeV)", 400,0,1.3,400,0,11000);
00400   TH2F* distro_r_evert=new TH2F("distro_r_evert",";r   (m);E_{vert}   (MeV)", 400,0,1.3,400,0,11000);
00401   TH1F* distro_r;
00402   if (eventtype==0) {
00403     distro_r=new TH1F("moller_distro_r",";r   (m);rate   (GHz)", 260,0,1.3);
00404   } else {
00405     if (eventtype==1) {
00406       distro_r=new TH1F("mott_distro_r",";r   (m);rate   (GHz)", 260,0,1.3);
00407     } else {
00408       if (eventtype==2) {
00409         distro_r=new TH1F("epinel_distro_r",";r   (m);rate   (GHz)", 260,0,1.3);
00410       }
00411     }
00412   }
00413 
00414 
00415 
00416   // **** Each quantity gets 5 histograms, within the r cut the three detectors [0],[1],[2] their sum [3] and 
00417   // **** outside the the r cut [4].
00418   Int_t numhistos = 5;
00419   TH1F *theta_cm[numhistos], *Eprime_vert_hist[numhistos], *Eprime_det_hist[numhistos], *theta_lab_hist[numhistos];
00420   TH1F *phi_wrap_hist[numhistos], *Q2_hist[numhistos], *W2_hist[numhistos], *W_hist[numhistos], *asym_hist[numhistos], *depol_hist[numhistos], *asymd_hist[numhistos], *asymEep_hist[numhistos],*asymIep_hist[numhistos],*z0_hist[numhistos];
00421   TH1F *Q2_eweight_hist[numhistos], *W2_Q2weight_hist[numhistos];
00422   TH1F *r_hist[numhistos], *r_asymtot[numhistos], *r_asymave[numhistos], *r_eweight[numhistos];
00423   TH2F *r_phi_hist[numhistos],*r_asym_hist[numhistos];
00424   char name[200];
00425   for (Int_t i=0; i<numhistos; i++) {
00426     // **** Setup the 1D histograms
00427     snprintf(name,200,"theta_cm_%i_%i",eventtype,i);
00428     theta_cm[i]=new TH1F(name,";#theta_{c.m.};rate   (GHz)/deg", 180,0,180);
00429     SetupHist(theta_cm[i],i);
00430     snprintf(name,200,"Eprime_vert_%i_%i",eventtype,i);
00431     Eprime_vert_hist[i]=new TH1F(name,";E'_{vert}   (GeV);rate   (GHz)/100MeV",110,0,11);
00432     SetupHist(Eprime_vert_hist[i],i);
00433     snprintf(name,200,"Eprime_det_%i_%i",eventtype,i);
00434     Eprime_det_hist[i]=new TH1F(name,";E'_{det}   (GeV);rate   (GHz)/100MeV",110,0,11);
00435     SetupHist(Eprime_det_hist[i],i);
00436     snprintf(name,200,"theta_lab_%i_%i",eventtype,i);
00437     theta_lab_hist[i]=new TH1F(name,";#theta_{lab}   (millirad);rate   (GHz)/0.3mrad", 100, 0,30);
00438     SetupHist(theta_lab_hist[i],i);
00439     snprintf(name,200,"phi_wrap_%i_%i",eventtype,i);
00440     phi_wrap_hist[i]=new TH1F(name,";#phi_{wrap};rate   (GHz)/0.402deg", 128,-25.7142857142857153,25.7142857142857153);
00441     SetupHist(phi_wrap_hist[i],i);
00442     snprintf(name,200,"Q2_%i_%i",eventtype,i);
00443     Q2_hist[i]=new TH1F(name,";Q^{2}   (GeV/c)^{2};rate   (GHz)/80(MeV/c)^{2}",200,0,0.016);
00444     SetupHist(Q2_hist[i],i);
00445     snprintf(name,200,"Q2_eweight_%i_%i",eventtype,i);
00446     Q2_eweight_hist[i]=new TH1F(name,";Q^{2}   (GeV/c)^{2};Energy weighted rate   (MeV*GHz)/80(MeV/c)^{2}",200,0,0.016);
00447     SetupHist(Q2_eweight_hist[i],i);
00448     snprintf(name,200,"W2_Q2weight_%i_%i",eventtype,i);
00449     W2_Q2weight_hist[i]=new TH1F(name,";W^{2}   (GeV^{2});Q^{2} weighted rate   ((GeV/c)^{2} *GHz)/0.1GeV^{2}",200,0,20);//0.880352,0.880357);
00450     SetupHist(W2_Q2weight_hist[i],i);
00451     snprintf(name,200,"W2_%i_%i",eventtype,i);
00452     W2_hist[i]=new TH1F(name,";W^{2}   (GeV^{2});rate   (GHz)/0.1GeV^{2}",200,0,20);//,0.880352,0.880357);
00453     SetupHist(W2_hist[i],i);
00454     snprintf(name,200,"W_%i_%i",eventtype,i);
00455     W_hist[i]=new TH1F(name,";W   (GeV);rate   (GHz)/30MeV",200,0,6);
00456     SetupHist(W_hist[i],i);
00457     snprintf(name,200,"asym_hist_%i_%i",eventtype,i);
00458     asym_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/0.2ppb",300,0,60);
00459     SetupHist(asym_hist[i],i);
00460     snprintf(name,200,"depol_hist_%i_%i",eventtype,i);
00461     depol_hist[i]=new TH1F(name,";Depolarization Factor  ;rate   (GHz)/1%",125,0,1.25);
00462     SetupHist(depol_hist[i],i);
00463     snprintf(name,200,"asymd_hist_%i_%i",eventtype,i);
00464     if(eventtype==0) asymd_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/0.2ppb",300,0,60);
00465     else if(eventtype==1) asymd_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/3ppb",200,0,600);
00466     else if(eventtype==2) asymd_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/5ppb",400,0,2000);
00467     SetupHist(asymd_hist[i],i);
00468 
00469     snprintf(name,200,"asymEep_hist_%i_%i",eventtype,i);
00470     asymEep_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/3ppb",200,0,600);
00471     SetupHist(asymEep_hist[i],i);
00472     snprintf(name,200,"asymIep_hist_%i_%i",eventtype,i);
00473     asymIep_hist[i]=new TH1F(name,";A_{PV}   (ppb);rate   (GHz)/5ppb",400,0,2000);
00474     SetupHist(asymIep_hist[i],i);
00475 
00476     snprintf(name,200,"z0_hist_%i_%i",eventtype,i);
00477     z0_hist[i]=new TH1F(name,";Target z   (mm);rate   (GHz)/cm",160,-800,800);
00478     SetupHist(z0_hist[i],i);
00479     // **** 1D histogrms for averages
00480     snprintf(name,200,"r_%i_%i",eventtype,i);
00481     r_hist[i]=new TH1F(name,";r   (m);rate   (GHz)/5mm",140,0.6,1.3);
00482     SetupHist(r_hist[i],i);
00483     snprintf(name,200,"r_eweight_%i_%i",eventtype,i);
00484     r_eweight[i]=new TH1F(name,";r   (m);Energy weighted rate   (MeV*GHz)/5mm",140,0.6,1.3);
00485     SetupHist(r_eweight[i],i);
00486     snprintf(name,200,"r_asymtot_%i_%i",eventtype,i);
00487     r_asymtot[i]=new TH1F(name,";r   (m);Asymmetry weighted rate (ppb*GHz)/5mm",140,0.6,1.3);
00488     SetupHist(r_asymtot[i],i);
00489     snprintf(name,200,"r_asymave_%i_%i",eventtype,i);
00490     r_asymave[i]=new TH1F(name,";r   (m);#bar{A_{PV}}   (ppb)/5mm",140,0.6,1.3);
00491     SetupHist(r_asymave[i],i);
00492     // **** Setup the 2D histograms
00493     snprintf(name,200,"r_phi_%i_%i",eventtype,i);
00494     r_phi_hist[i]=new TH2F(name,";#phi   (degrees);r   (m)",224,0,360,210,0.6,1.3);
00495     snprintf(name,200,"r_asym_%i_%i",eventtype,i);
00496     r_asym_hist[i]=new TH2F(name,";asym;r   (m)",42,0,42,70,0.6,1.3);
00497   }
00498 
00499   Long_t totalevents=0, numevcut_rcut=0, numevcut_thetacut=0, numevcut_volumecut=0,numevcut_kinecut=0,numevallpass=0;
00500 
00501   // *****  Here begins the loop
00502 
00503   Long64_t nbytes = 0, nb = 0;
00504   for (Long64_t jentry=0; jentry<nentries;jentry++) {
00505     Long64_t ientry = LoadTree(jentry);
00506     if (ientry < 0) break;
00507     nb = fChain->GetEntry(jentry);   nbytes += nb;
00508     // if (Cut(ientry) < 0) continue;
00509 
00510     totalevents++;
00511 
00512     Double_t r = sqrt(x*x+y*y);
00513 //    Double_t phi_wrap  = TMath::ATan2(y,x)-pi/3.5*(TMath::Floor((TMath::ATan2(y,x)+pi/7)/(pi/3.5)));
00514     Double_t phi_wrap  = (TMath::ATan2(y,x)-pi)-pi/3.5*(TMath::Floor((TMath::ATan2(y,x)+pi/7-pi)/(pi/3.5)));
00515     //    Double_t phi_org_wrap = TMath::ATan2(y0,x0)-pi/3.5*(TMath::Floor((TMath::ATan2(y0,x0)+pi/7)/(pi/3.5)));
00516     Double_t theta_lab;
00517     if (eventtype!=2) {
00518       if(kineE2==kineE_org&&kineE1==kineE_org) {
00519         theta_lab = acos(pz2/sqrt(px2*px2+py2*py2+pz2*pz2)) + acos(pz1/sqrt(px1*px1+py1*py1+pz1*pz1));  
00520       }else if(kineE2==kineE_org&&kineE1!=kineE_org) {
00521         theta_lab = acos(pz2/sqrt(px2*px2+py2*py2+pz2*pz2));
00522       }else if(kineE2!=kineE_org&&kineE1==kineE_org) {
00523         theta_lab = acos(pz1/sqrt(px1*px1+py1*py1+pz1*pz1));  
00524       }else {
00525         theta_lab = 0;
00526       }
00527     } else {
00528       theta_lab = acos(pz1/sqrt(px1*px1+py1*py1+pz1*pz1));
00529     }
00530 //    if (eventtype!=2) {
00531 //      theta_lab = (kineE2==kineE_org)*acos(pz2/sqrt(px2*px2+py2*py2+pz2*pz2)) +
00532 //        (kineE1==kineE_org)*acos(pz1/sqrt(px1*px1+py1*py1+pz1*pz1));  
00533 //      // only if (kineE2==kineE_org) does px2 represent the detected particle
00534 //    } else {
00535 //      theta_lab = acos(pz1/sqrt(px1*px1+py1*py1+pz1*pz1));
00536 //    }
00537 
00538     Double_t Q2_org = 4*kineE0/1000*(kineE_org/1000)*sin(theta_lab/2)*sin(theta_lab/2);
00539     Double_t mp=0.938272;
00540     Double_t nu=(kineE0-kineE_org)/1000;
00541     Double_t W_org = sqrt(-Q2_org + mp*mp + 2*mp*nu);
00542     Double_t y_org = 1-kineE_org/kineE0;
00543     Double_t asymMol_org = 10e8*0.0000116639/sqrt(2)/3.14159/0.0072973*(1-4*0.2388)*Q2_org*(1-y_org)/(1+pow(y_org,4)+pow((1-y_org),4)); 
00544     //10e8 to give ppb
00545     Double_t Din = 1.0 - (2./3.)*(11000. - kineE0)*(11000. - kineE0)/(kineE0*kineE0+11000.*11000. - (2./3.)*kineE0*11000.);
00546 
00547     Double_t asymEep_org = 1E9*0.0000116639/sqrt(2)/3.14159/0.0072973*(0.072/2.0)*Q2_org;
00548     Double_t asymIep_org = 1E9*(0.8E-4)*Q2_org;
00549 
00550 //Set proper Asymetry for the generator eventtype
00551     Double_t asym_org;
00552     if(eventtype==0) asym_org = asymMol_org;
00553     else if(eventtype==1) asym_org = asymEep_org;
00554     else if(eventtype==2) asym_org = asymIep_org;
00555 
00556     Double_t asymd_org = Din*asym_org; //depolarization effect
00557 
00558     Double_t ecm = sqrt(2*0.000511*0.000511+2.*0.000511*kineE0/1000);
00559     Double_t gammap = kineE0/1000/ecm;
00560     Double_t betap = 1/gammap*sqrt(gammap*gammap-1);
00561     Double_t e1cm = gammap*0.000511;
00562     Double_t pcm2_org = (kineE_org/1000-gammap*e1cm)/gammap/betap;
00563     Double_t costheta_cms_org = pcm2_org/e1cm;
00564 
00565     Double_t theta_cms_org = acos(pcm2_org/e1cm);
00566     Double_t phi_org =  (kineE2==kineE_org)*TMath::ATan2(py2,px2)+(kineE1==kineE_org)*TMath::ATan2(py1,px1);
00567     Double_t phi_det = TMath::ATan2(y,x);
00568     Double_t phi_det_deg = (phi_det+TMath::Pi())*180/TMath::Pi();
00569     Double_t m_e = 0.000511;
00570     Double_t E_vert = kineE0/1000;
00571 
00572     Double_t s = 2*m_e*E_vert;
00573     Double_t t = -s/2*(1-costheta_cms_org);
00574     Double_t u = -s/2*(1+costheta_cms_org);
00575     Double_t alpha = 1/137.;
00576     Double_t dsigma_born = alpha*alpha/2/s*((t*t+t*u+u*u)/t/u)*((t*t+t*u+u*u)/t/u);
00577     Double_t bracket_term = 3*s*(t*(u-s)*TMath::Log(-t/s)-u*(t-s)*TMath::Log(-u/s))-2*(t-u)*t*u;
00578     Double_t proton_term = -alpha*alpha*alpha/8*m_e/sqrt(s)*sin(theta_cms_org)*sin(phi_org)/t/t/u/u;
00579     Double_t dsigma_phi = proton_term*bracket_term;
00580     Double_t asym_trans = dsigma_phi/dsigma_born*1000000;
00581 
00582 
00583     Double_t rate_GHz = 85*rate/(num_thrown)/1000000000;
00584     //    Double_t pi = TMath::Pi();
00585 
00586         //This may need to be changed depending on the field map:
00587     //Bool_t rcut = (r>880 && r<1000);// for proposal maps
00588     //Bool_t rcut = (r>900 && r<1100);// for default TOSCA 
00589     //Bool_t rcut = (r>700 && r<740);// 
00590     //Bool_t rcut = (r>740 && r<820);// 
00591     //Bool_t rcut = (r>820 && r<860);// 
00592     //Bool_t rcut = (r>860 && r<900);// 
00593     //Bool_t rcut = (r>900 && r<1060);// 
00594     //Bool_t rcut = (r>1060 && r<1160);// 
00595     Bool_t rcut = (r>0 && r<10000);// 
00596 
00597     //Bool_t thetacut = (theta_lab>0.0095);
00598     Bool_t thetacut = (theta_lab>0.004);
00599     Bool_t volumecut;
00600     if (eventtype==0) {
00601       volumecut = volume==0;
00602     } else {
00603       volumecut = ((volume==0)&&(track==1));
00604     }
00605 //    Bool_t volumecut = volume==1;
00606     Bool_t kinecut = kineE_org>0;
00607 
00608     if (! rcut) numevcut_rcut++;
00609     if (! thetacut) numevcut_thetacut++;
00610     if (! volumecut) numevcut_volumecut++;
00611     if (! kinecut) numevcut_kinecut++;
00612 
00613     Bool_t maincut = volumecut && kinecut && thetacut;
00614     if (maincut && !thetacut) {
00615       printf("theta_lab=%f  kineE2=%f, kineE1=%f, kineE_org=%f   px1=%f, py1=%f, pz1=%f,  px2=%f, py2=%f, pz2=%f\n",
00616            theta_lab, kineE2, kineE1, kineE_org, px1, py1, pz1, px2, py2, pz2);
00617     }
00618 
00619     if (eventtype==2) {
00620       maincut = maincut && kineE2==0;
00621     }
00622     if (maincut) { // This is for stuff that may not make into the detectors
00623 
00624       distro_r->Fill(r/1000,rate_GHz);
00625       distro_rphi->Fill(r/1000,phi_org,rate_GHz);
00626       distro_r_evert->Fill(r/1000,kineE_org,rate_GHz);
00627       distro_r_edet->Fill(r/1000,kineE,rate_GHz);
00628       theta_cm[4]->Fill(acos(costheta_cms_org)*180/TMath::Pi(),rate_GHz);
00629       Eprime_vert_hist[4]->Fill(kineE_org/1000,rate_GHz);
00630       Eprime_det_hist[4]->Fill(kineE/1000,rate_GHz);
00631       theta_lab_hist[4]->Fill(theta_lab*1000,rate_GHz);
00632       phi_wrap_hist[4]->Fill(phi_wrap*180/TMath::Pi(),rate_GHz);
00633       Q2_hist[4]->Fill(Q2_org,rate_GHz);
00634       Q2_eweight_hist[4]->Fill(Q2_org,kineE*rate_GHz);
00635       W2_Q2weight_hist[4]->Fill(W_org*W_org,Q2_org*rate_GHz);
00636       W2_hist[4]->Fill(W_org*W_org,rate_GHz);
00637       W_hist[4]->Fill(W_org,rate_GHz);
00638       r_hist[4]->Fill(r/1000,rate_GHz);
00639       r_eweight[4]->Fill(r/1000,kineE*rate_GHz);
00640       r_asymtot[4]->Fill(r/1000,rate_GHz*asym_org);
00641       asym_hist[4]->Fill(asym_org,rate_GHz);
00642       depol_hist[4]->Fill(Din,rate_GHz);
00643       asymd_hist[4]->Fill(asymd_org,rate_GHz);
00644       asymEep_hist[4]->Fill(asymEep_org,rate_GHz);
00645       asymIep_hist[4]->Fill(asymIep_org,rate_GHz);
00646       z0_hist[4]->Fill(z0,rate_GHz);
00647 
00648       if (!(rcut)) {
00649         r_phi_hist[3]->Fill(phi_det_deg,r/1000,rate_GHz);
00650         r_asym_hist[3]->Fill(asym_org,r/1000,rate_GHz);
00651       }
00652       r_phi_hist[4]->Fill(phi_det_deg,r/1000,rate_GHz);
00653       r_asym_hist[4]->Fill(asym_org,r/1000,rate_GHz);
00654     }
00655     if (rcut and maincut) {
00656       numevallpass++;
00657       //if (1) printf("|");
00658       Double_t fillval;
00659       //fillval=num_detectors*((phi_det+pi)/(2.*pi));
00660       fillval=num_detectors*((phi_det+pi)/(2.*pi)-(1./56.));
00661       if (fillval<0) {
00662         //printf("%f  %f\n",fillval,fillval + num_detectors);
00663         fillval = fillval + num_detectors;
00664       }
00665       std_total_asym->Fill(fillval,asym_trans*totXS);
00666       std_total_sample->Fill(fillval,totXS);
00667       eweight_total_asym->Fill(fillval,kineE*asym_trans*totXS);
00668       eweight_total_sample->Fill(fillval,kineE*totXS);
00669       rate_total->Fill(fillval,85*rate/(num_thrown));
00670       
00671       num_events->Fill(fillval,60*60*85*rate/(num_thrown));
00672 
00673 
00674       if (TMath::Abs(phi_wrap)<pi/28.) {
00675         r_phi_hist[0]->Fill(phi_det_deg,r/1000,rate_GHz);
00676         r_asym_hist[0]->Fill(asym_org,r/1000,rate_GHz);
00677         //r_phi_hist[0]->Fill(r/1000,phi_det_deg);
00678       } else {
00679         if (TMath::Abs(phi_wrap)>pi/28.&&TMath::Abs(phi_wrap)<3*pi/28.) {
00680           r_phi_hist[1]->Fill(phi_det_deg,r/1000,rate_GHz);
00681           r_asym_hist[1]->Fill(asym_org,r/1000,rate_GHz);
00682           //r_phi_hist[1]->Fill(r/1000,phi_det_deg);
00683         } else {
00684           if (TMath::Abs(phi_wrap)>3*pi/28.) {
00685             //r_phi_hist[2]->Fill(r/1000,phi_det_deg);
00686             r_phi_hist[2]->Fill(phi_det_deg,r/1000,rate_GHz);
00687             r_asym_hist[2]->Fill(asym_org,r/1000,rate_GHz);
00688           }
00689         }
00690       }
00691       
00692       //if (Q2_org<0 || Q2_org>
00693       theta_cm[3]->Fill(acos(costheta_cms_org)*180/TMath::Pi(),rate_GHz);
00694       Eprime_vert_hist[3]->Fill(kineE_org/1000,rate_GHz);
00695       Eprime_det_hist[3]->Fill(kineE/1000,rate_GHz);
00696       theta_lab_hist[3]->Fill(theta_lab*1000,rate_GHz);
00697       phi_wrap_hist[3]->Fill(phi_wrap*180/TMath::Pi(),rate_GHz);
00698       Q2_hist[3]->Fill(Q2_org,rate_GHz);
00699       Q2_eweight_hist[3]->Fill(Q2_org,kineE*rate_GHz);
00700       W2_Q2weight_hist[3]->Fill(W_org*W_org,Q2_org*rate_GHz);
00701       W2_hist[3]->Fill(W_org*W_org,rate_GHz);
00702       W_hist[3]->Fill(W_org,rate_GHz);
00703       r_hist[3]->Fill(r/1000,rate_GHz);
00704       r_eweight[3]->Fill(r/1000,kineE*rate_GHz);
00705       r_asymtot[3]->Fill(r/1000,rate_GHz*asym_org);
00706       asym_hist[3]->Fill(asym_org,rate_GHz);
00707       depol_hist[3]->Fill(Din,rate_GHz);
00708       asymd_hist[3]->Fill(asymd_org,rate_GHz);
00709       asymEep_hist[3]->Fill(asymEep_org,rate_GHz);
00710       asymIep_hist[3]->Fill(asymIep_org,rate_GHz);
00711       z0_hist[3]->Fill(z0,rate_GHz);
00712       if (TMath::Abs(phi_wrap)<pi/28.) {
00713         eweight_red_total_asym->Fill(fillval,kineE*asym_trans*totXS);
00714         eweight_red_total_sample->Fill(fillval,kineE*totXS);
00715         std_red_total_asym->Fill(fillval,asym_trans*totXS);
00716         std_red_total_sample->Fill(fillval,totXS);
00717         distro_red->Fill(costheta_cms_org,phi_org, rate_GHz);
00718         theta_cm[0]->Fill(acos(costheta_cms_org)*180/TMath::Pi(),rate_GHz);
00719         Eprime_vert_hist[0]->Fill(kineE_org/1000,rate_GHz);
00720         Eprime_det_hist[0]->Fill(kineE/1000,rate_GHz);
00721         theta_lab_hist[0]->Fill(theta_lab*1000,rate_GHz);
00722         phi_wrap_hist[0]->Fill(phi_wrap*180/TMath::Pi(),rate_GHz);
00723         Q2_hist[0]->Fill(Q2_org,rate_GHz);
00724         Q2_eweight_hist[0]->Fill(Q2_org,kineE*rate_GHz);
00725         W2_Q2weight_hist[0]->Fill(W_org*W_org,Q2_org*rate_GHz);
00726         W2_hist[0]->Fill(W_org*W_org,rate_GHz);
00727         W_hist[0]->Fill(W_org,rate_GHz);
00728         r_hist[0]->Fill(r/1000,rate_GHz);
00729         r_eweight[0]->Fill(r/1000,kineE*rate_GHz);
00730         r_asymtot[0]->Fill(r/1000,rate_GHz*asym_org);
00731         asym_hist[0]->Fill(asym_org,rate_GHz);
00732         depol_hist[0]->Fill(Din,rate_GHz);
00733         asymd_hist[0]->Fill(asymd_org,rate_GHz);
00734         asymEep_hist[0]->Fill(asymEep_org,rate_GHz);
00735         asymIep_hist[0]->Fill(asymIep_org,rate_GHz);
00736         z0_hist[0]->Fill(z0,rate_GHz);
00737       } else {
00738         if (TMath::Abs(phi_wrap)>pi/28.&&TMath::Abs(phi_wrap)<3*pi/28.) {
00739           eweight_green_total_asym->Fill(fillval,kineE*asym_trans*totXS);
00740           eweight_green_total_sample->Fill(fillval,kineE*totXS);
00741           std_green_total_asym->Fill(fillval,asym_trans*totXS);
00742           std_green_total_sample->Fill(fillval,totXS);
00743           distro_green->Fill(costheta_cms_org,phi_org);
00744           theta_cm[1]->Fill(acos(costheta_cms_org)*180/TMath::Pi(),rate_GHz);
00745           Eprime_vert_hist[1]->Fill(kineE_org/1000,rate_GHz);
00746           Eprime_det_hist[1]->Fill(kineE/1000,rate_GHz);
00747           theta_lab_hist[1]->Fill(theta_lab*1000,rate_GHz);
00748           phi_wrap_hist[1]->Fill(phi_wrap*180/TMath::Pi(),rate_GHz);
00749           Q2_hist[1]->Fill(Q2_org,rate_GHz);
00750           Q2_eweight_hist[1]->Fill(Q2_org,kineE*rate_GHz);
00751           W2_Q2weight_hist[1]->Fill(W_org*W_org,Q2_org*rate_GHz);
00752           W2_hist[1]->Fill(W_org*W_org,rate_GHz);
00753           W_hist[1]->Fill(W_org,rate_GHz);
00754           r_hist[1]->Fill(r/1000,rate_GHz);
00755           r_eweight[1]->Fill(r/1000,kineE*rate_GHz);
00756           asym_hist[1]->Fill(asym_org,rate_GHz);
00757           depol_hist[1]->Fill(Din,rate_GHz);
00758           asymd_hist[1]->Fill(asymd_org,rate_GHz);
00759           asymEep_hist[1]->Fill(asymEep_org,rate_GHz);
00760           asymIep_hist[1]->Fill(asymIep_org,rate_GHz);
00761           r_asymtot[1]->Fill(r/1000,rate_GHz*asym_org);
00762           z0_hist[1]->Fill(z0,rate_GHz);
00763         } else {
00764           if (TMath::Abs(phi_wrap)>3*pi/28.) {
00765             eweight_blue_total_asym->Fill(fillval,kineE*asym_trans*totXS);
00766             eweight_blue_total_sample->Fill(fillval,kineE*totXS);
00767             std_blue_total_asym->Fill(fillval,asym_trans*totXS);
00768             std_blue_total_sample->Fill(fillval,totXS);
00769             distro_blue->Fill(costheta_cms_org,phi_org, rate_GHz);
00770             theta_cm[2]->Fill(acos(costheta_cms_org)*180/TMath::Pi(),rate_GHz);
00771             Eprime_vert_hist[2]->Fill(kineE_org/1000,rate_GHz);
00772             Eprime_det_hist[2]->Fill(kineE/1000,rate_GHz);
00773             theta_lab_hist[2]->Fill(theta_lab*1000,rate_GHz);
00774             phi_wrap_hist[2]->Fill(phi_wrap*180/TMath::Pi(),rate_GHz);
00775             Q2_hist[2]->Fill(Q2_org,rate_GHz);
00776             Q2_eweight_hist[2]->Fill(Q2_org,kineE*rate_GHz);
00777             W2_Q2weight_hist[2]->Fill(W_org*W_org,Q2_org*rate_GHz);
00778             W2_hist[2]->Fill(W_org*W_org,rate_GHz);
00779             W_hist[2]->Fill(W_org,rate_GHz);
00780             r_hist[2]->Fill(r/1000,rate_GHz);
00781             r_eweight[2]->Fill(r/1000,kineE*rate_GHz);
00782             r_asymtot[2]->Fill(r/1000,rate_GHz*asym_org);
00783             asym_hist[2]->Fill(asym_org,rate_GHz);
00784             depol_hist[2]->Fill(Din,rate_GHz);
00785             asymd_hist[2]->Fill(asymd_org,rate_GHz);
00786             asymEep_hist[2]->Fill(asymEep_org,rate_GHz);
00787             asymIep_hist[2]->Fill(asymIep_org,rate_GHz);
00788             z0_hist[2]->Fill(z0,rate_GHz);
00789           }
00790         }
00791       }
00792       test->Fill(phi_det,fillval);
00793       if (kineE0>10999.999) {
00794         paperfig->Fill(costheta_cms_org,asym_trans/sin(phi_org));
00795         paperfig2->Fill(costheta_cms_org,phi_org,asym_trans);
00796       }
00797     }
00798     
00799   }
00800 
00801   if (0) {
00802     rate_total->Draw();
00803     snprintf(plotname,200,"%sratetotal.gif",namestem);
00804     canvas.Print(plotname);
00805     num_events->Draw();
00806     snprintf(plotname,200,"%snumevents.gif",namestem);
00807     canvas.Print(plotname);
00808 
00809     std_red_ave_asym->Divide(std_red_total_asym,std_red_total_sample);
00810     std_green_ave_asym->Divide(std_green_total_asym,std_green_total_sample);
00811     std_blue_ave_asym->Divide(std_blue_total_asym,std_blue_total_sample);
00812     eweight_red_ave_asym->Divide(eweight_red_total_asym,eweight_red_total_sample);
00813     eweight_green_ave_asym->Divide(eweight_green_total_asym,eweight_green_total_sample);
00814     eweight_blue_ave_asym->Divide(eweight_blue_total_asym,eweight_blue_total_sample);
00815     Double_t errorfactor;
00816     // Set error bars expected for 1 hour of running at 85 uA
00817     for (Int_t i = 1; i<=num_detectors; i++) {
00818       errorfactor = 1000000/sqrt(num_events->GetBinContent(i));
00819       error->SetBinContent(i,errorfactor);
00820       if (std_red_ave_asym->GetBinContent(i)!=0) std_red_ave_asym->SetBinError(i,errorfactor);
00821       if (std_green_ave_asym->GetBinContent(i)!=0) std_green_ave_asym->SetBinError(i,errorfactor);
00822       if (std_blue_ave_asym->GetBinContent(i)!=0) std_blue_ave_asym->SetBinError(i,errorfactor);
00823       if (eweight_red_ave_asym->GetBinContent(i)!=0) eweight_red_ave_asym->SetBinError(i,errorfactor);
00824       if (eweight_green_ave_asym->GetBinContent(i)!=0) eweight_green_ave_asym->SetBinError(i,errorfactor);
00825       if (eweight_blue_ave_asym->GetBinContent(i)!=0) eweight_blue_ave_asym->SetBinError(i,errorfactor);
00826     }
00827     error->Draw();
00828     snprintf(plotname,200,"%serror.gif",namestem);
00829     canvas.Print(plotname);
00830 
00831     TF1 *fa1 = new TF1("fa1","1.5*sin(2*TMath::Pi()*(x+0.5)/28.)",0,28);
00832     fa1->SetLineWidth(2);
00833     snprintf(plotname,200,"%sstd_color_dettotal.gif",namestem);
00834     std_red_total_asym->Draw();
00835     std_green_total_asym->Draw("same");
00836     std_blue_total_asym->Draw("same");
00837     canvas.Print(plotname);
00838     snprintf(plotname,200,"%sstd_color_detsample.gif",namestem);
00839     std_red_total_sample->Draw();
00840     std_green_total_sample->Draw("same");
00841     std_blue_total_sample->Draw("same");
00842     canvas.Print(plotname);
00843     snprintf(plotname,200,"%sstd_color_detave.gif",namestem);
00844     std_blue_ave_asym->Draw();
00845     std_red_ave_asym->Draw("same");
00846     std_green_ave_asym->Draw("same");
00847     fa1->Draw("same");
00848     std_ave_asym->Divide(std_total_asym,std_total_sample);
00849     //  std_ave_asym->Draw("same");
00850     canvas.Print(plotname);
00851 
00852 
00853 
00854     TF1 *fa2 = new TF1("fa2","-2*sin(2*TMath::Pi()*(x+0.5)/28.)",0,28);
00855     fa2->SetLineWidth(2);
00856 
00857     snprintf(plotname,200,"%seweight_color_dettotal.gif",namestem);
00858     eweight_red_total_asym->Draw();
00859     eweight_green_total_asym->Draw("same");
00860     eweight_blue_total_asym->Draw("same");
00861     canvas.Print(plotname);
00862     snprintf(plotname,200,"%seweight_color_detsample.gif",namestem);
00863     eweight_red_total_sample->Draw();
00864     eweight_green_total_sample->Draw("same");
00865     eweight_blue_total_sample->Draw("same");
00866     canvas.Print(plotname);
00867     snprintf(plotname,200,"%seweight_color_detave.gif",namestem);
00868     eweight_blue_ave_asym->Draw();
00869     eweight_red_ave_asym->Draw("same");
00870     eweight_green_ave_asym->Draw("same");
00871     eweight_ave_asym->Divide(eweight_total_asym,eweight_total_sample);
00872     //  eweight_ave_asym->Draw("same");
00873     fa2->Draw("same");
00874     canvas.Print(plotname);
00875 
00876 
00877     test->Draw("colz");
00878     snprintf(plotname,200,"%stest.gif",namestem);
00879     canvas.Print(plotname);
00880   }
00881 
00882   // *** Draw the 1D histograms
00883   snprintf(plotname,200,"%stheta_cm%s",outdir,plottype);
00884   PrintHist(theta_cm,plotname,4,0);
00885   snprintf(plotname,200,"%sEprime_vert%s",outdir,plottype);
00886   PrintHist(Eprime_vert_hist,plotname,4,0);
00887   snprintf(plotname,200,"%sEprime_det%s",outdir,plottype);
00888   PrintHist(Eprime_det_hist,plotname,4,0);
00889   snprintf(plotname,200,"%stheta_lab%s",outdir,plottype);
00890   PrintHist(theta_lab_hist,plotname,4,0);
00891   snprintf(plotname,200,"%sphi_wrap%s",outdir,plottype);
00892   PrintHist(phi_wrap_hist,plotname);
00893   snprintf(plotname,200,"%sQ2%s",outdir,plottype);
00894   PrintHist(Q2_hist,plotname,4,0);
00895   snprintf(plotname,200,"%sQ2_eweight%s",outdir,plottype);
00896   PrintHist(Q2_eweight_hist,plotname,4,0);
00897   snprintf(plotname,200,"%sW2_Q2weight%s",outdir,plottype);
00898   PrintHist(W2_Q2weight_hist,plotname,4,0);
00899   snprintf(plotname,200,"%sW2%s",outdir,plottype);
00900   PrintHist(W2_hist,plotname,4,0);
00901   snprintf(plotname,200,"%sW%s",outdir,plottype);
00902   PrintHist(W_hist,plotname,4,0);
00903   snprintf(plotname,200,"%sr%s",outdir,plottype);
00904   PrintHist(r_hist,plotname,5,0);
00905   for (Int_t i=0; i<numhistos; i++) {
00906     r_asymave[i]->Divide(r_asymtot[i],r_hist[i]);
00907   }
00908   snprintf(plotname,200,"%sr_asymtot%s",outdir,plottype);
00909   PrintHist(r_asymtot,plotname,5,0);
00910   snprintf(plotname,200,"%sr_asymave%s",outdir,plottype);
00911   PrintHist(r_asymave,plotname,5,0);
00912   snprintf(plotname,200,"%sasym%s",outdir,plottype);
00913   PrintHist(asym_hist,plotname,4,0);
00914   snprintf(plotname,200,"%sdepol%s",outdir,plottype);
00915   PrintHist(depol_hist,plotname,5,1);
00916   snprintf(plotname,200,"%sasymd%s",outdir,plottype);
00917   PrintHist(asymd_hist,plotname,4,0);
00918 
00919   snprintf(plotname,200,"%sasymEep%s",outdir,plottype);
00920   PrintHist(asymEep_hist,plotname,4,0);
00921   snprintf(plotname,200,"%sasymIep%s",outdir,plottype);
00922   PrintHist(asymIep_hist,plotname,4,0);
00923   snprintf(plotname,200,"%sz0%s",outdir,plottype);
00924   PrintHist(z0_hist,plotname);
00925   // *** Draw the 2D histograms
00926   snprintf(plotname,200,"%s2Dr_phi%s",outdir,plottype);
00927   PrintHist2D(r_phi_hist,plotname);
00928   snprintf(plotname,200,"%s2D_r_asym%s",outdir,plottype);
00929   PrintHist2D(r_asym_hist,plotname);
00930 
00931 
00932   distro_r->Draw();
00933   snprintf(plotname,200,"%sdistro_r.gif",outdir);
00934   canvas.SetLogy(1);
00935   canvas.Print(plotname);
00936   if (0) {
00937     paperfig->Draw();
00938     snprintf(plotname,200,"%spaperfig.gif",outdir);
00939     canvas.Print(plotname);
00940     paperfig2->Project3DProfile("yx")->Draw("colz");
00941     snprintf(plotname,200,"%sasym_mag.gif",outdir);
00942     canvas.Print(plotname);
00943     distro_red->Draw("contourz");
00944     snprintf(plotname,200,"%sdistro_red.gif",outdir);
00945     canvas.Print(plotname);
00946     distro_green->Draw("contourz");
00947     snprintf(plotname,200,"%sdistro_green.gif",outdir);
00948     canvas.Print(plotname);
00949     distro_blue->Draw("contourz");
00950     snprintf(plotname,200,"%sdistro_blue.gif",outdir);
00951     canvas.Print(plotname);
00952 
00953     distro_rphi->Draw("contourz");
00954     snprintf(plotname,200,"%sdistro_rphi.gif",outdir);
00955     canvas.Print(plotname);
00956     distro_r_evert->Draw("contourz");
00957     snprintf(plotname,200,"%sdistro_r_evert.gif",outdir);
00958     canvas.Print(plotname);
00959     distro_r_edet->Draw("contourz");
00960     snprintf(plotname,200,"%sdistro_r_edet.gif",outdir);
00961     canvas.Print(plotname);
00962   }
00963 
00964   printf("Total number of events       = %8li\n", totalevents);
00965   printf("number not passing rcut      = %8li\n", numevcut_rcut);
00966   printf("number not passing thetacut  = %8li\n", numevcut_thetacut);
00967   printf("number not passing volumecut = %8li\n", numevcut_volumecut);
00968   printf("number not passing kinecut   = %8li\n", numevcut_kinecut);
00969   printf("number passing all cuts      = %8li\n", numevallpass);
00970 
00971   printf("Total rate is %5g GHz\n",distro_r->Integral());
00972   printf("Rate in detector zone is %5g GHz\n",distro_r->Integral(176,200));
00973   printf("Red   detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[0]->Integral(),r_eweight[0]->Integral());
00974   printf("Green detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[1]->Integral(),r_eweight[1]->Integral());
00975   printf("Blue  detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[2]->Integral(),r_eweight[2]->Integral());
00976   printf("Total detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[3]->Integral(),r_eweight[3]->Integral());
00977 
00978   printf("Rates between 0.66 and 0.82 m\n");
00979   printf("Red   detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[0]->Integral(12,44),r_eweight[0]->Integral(12,44));
00980   printf("Green detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[1]->Integral(12,44),r_eweight[1]->Integral(12,44));
00981   printf("Blue  detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[2]->Integral(12,44),r_eweight[2]->Integral(12,44));
00982   printf("Total detector rate: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",r_hist[3]->Integral(12,44),r_eweight[3]->Integral(12,44));
00983   printf("All detector plane rate between 0.66 and 0.82 m: %5g GHz,   energy weighted rate: %5g MeV*GHz\n",
00984        r_hist[4]->Integral(12,44),r_eweight[4]->Integral(12,44));
00985 
00986   printf("Red   ave asymmetry: %5g ppb\n",asym_hist[0]->GetMean());
00987   printf("Green ave asymmetry: %5g ppb\n",asym_hist[1]->GetMean());
00988   printf("Blue  ave asymmetry: %5g ppb\n",asym_hist[2]->GetMean());
00989   printf("Total ave asymmetry: %5g ppb\n",asym_hist[3]->GetMean());
00990   printf("{%5g ppb, %5g ppb, %5g ppb, %5g ppb}\n",
00991        asym_hist[0]->GetMean(), asym_hist[1]->GetMean(), asym_hist[2]->GetMean(),asym_hist[3]->GetMean());
00992 
00993   printf("Red   ave depol factor: %5.3f\n",depol_hist[0]->GetMean());
00994   printf("Green ave depol factor: %5.3f\n",depol_hist[1]->GetMean());
00995   printf("Blue  ave depol factor: %5.3f\n",depol_hist[2]->GetMean());
00996   printf("Total ave depol factor: %5.3f\n",depol_hist[3]->GetMean());
00997   printf("{%5.3f, %5.3f, %5.3f, %5.3f}\n",
00998        depol_hist[0]->GetMean(), depol_hist[1]->GetMean(), depol_hist[2]->GetMean(),depol_hist[3]->GetMean());
00999 
01000   printf("Red   ave asymmetry: %5g ppb\n",asymd_hist[0]->GetMean());
01001   printf("Green ave asymmetry: %5g ppb\n",asymd_hist[1]->GetMean());
01002   printf("Blue  ave asymmetry: %5g ppb\n",asymd_hist[2]->GetMean());
01003   printf("Total ave asymmetry: %5g ppb\n",asymd_hist[3]->GetMean());
01004   printf("{%5g ppb, %5g ppb, %5g ppb, %5g ppb}\n",
01005        asymd_hist[0]->GetMean(), asymd_hist[1]->GetMean(), asymd_hist[2]->GetMean(),asymd_hist[3]->GetMean());
01006 
01007   printf("Red   ave asymmetry: %5g ppb\n",asymEep_hist[0]->GetMean());
01008   printf("Green ave asymmetry: %5g ppb\n",asymEep_hist[1]->GetMean());
01009   printf("Blue  ave asymmetry: %5g ppb\n",asymEep_hist[2]->GetMean());
01010   printf("Total ave asymmetry: %5g ppb\n",asymEep_hist[3]->GetMean());
01011   printf("{%5g ppb, %5g ppb, %5g ppb, %5g ppb}\n",
01012        asymEep_hist[0]->GetMean(), asymEep_hist[1]->GetMean(), asymEep_hist[2]->GetMean(),asymEep_hist[3]->GetMean());
01013 
01014   printf("Red   ave asymmetry: %5g ppb\n",asymIep_hist[0]->GetMean());
01015   printf("Green ave asymmetry: %5g ppb\n",asymIep_hist[1]->GetMean());
01016   printf("Blue  ave asymmetry: %5g ppb\n",asymIep_hist[2]->GetMean());
01017   printf("Total ave asymmetry: %5g ppb\n",asymIep_hist[3]->GetMean());
01018   printf("{%5g ppb, %5g ppb, %5g ppb, %5g ppb}\n",
01019        asymIep_hist[0]->GetMean(), asymIep_hist[1]->GetMean(), asymIep_hist[2]->GetMean(),asymIep_hist[3]->GetMean());
01020 
01021   // Write some output to file
01022   char rootoutfilename[256];
01023   GetPrivateProfileString ("General", "rootoutfile", "defaultout.root", rootoutfilename, 256, inifilename);
01024   TFile *outfile=new TFile(rootoutfilename,"update");
01025   if (outfile->IsZombie()) {
01026     cerr << "\nError opening file " <<  rootoutfilename << endl << endl;
01027     exit(-1);
01028   }
01029   for (Int_t i=0; i<numhistos; i++) {
01030     r_hist[i]->Write("", TObject::kOverwrite);
01031     Eprime_det_hist[i]->Write("", TObject::kOverwrite);
01032     Eprime_vert_hist[i]->Write("", TObject::kOverwrite);
01033     theta_cm[i]->Write("", TObject::kOverwrite);
01034     theta_lab_hist[i]->Write("", TObject::kOverwrite);
01035     phi_wrap_hist[i]->Write("", TObject::kOverwrite);
01036     Q2_hist[i]->Write("", TObject::kOverwrite);
01037     Q2_eweight_hist[i]->Write("", TObject::kOverwrite);
01038     W_hist[i]->Write("", TObject::kOverwrite);
01039     W2_hist[i]->Write("", TObject::kOverwrite);
01040     W2_Q2weight_hist[i]->Write("", TObject::kOverwrite);
01041     r_asymave[i]->Write("", TObject::kOverwrite);
01042     asym_hist[i]->Write("", TObject::kOverwrite);
01043     asymd_hist[i]->Write("", TObject::kOverwrite);
01044     depol_hist[i]->Write("", TObject::kOverwrite);
01045     asymEep_hist[i]->Write("", TObject::kOverwrite);
01046     asymIep_hist[i]->Write("", TObject::kOverwrite);
01047 
01048 
01049   }
01050   outfile->Close();
01051 
01052 }
01053 
01054 
01055 
01056 
01057 
01058 
01059 
01060 
01061 int main(int argc,char **argv)
01062 {
01063 
01064   if (argc < 2) {
01065     cerr << "\nToo few arguements!\nuseage: mollerClass inputfile\n\n";
01066     exit(-1);
01067     //snprintf(inifilename,100,"fitsignal.ini");
01068   }
01069 
01070 
01071 
01072   for (int i=0; i<argc; i++) {
01073     cout << argv[i] << " ";
01074   }
01075   cout << "\n";
01076   if (argc < 2) {
01077     cerr << "\nuseage:  mollerClass\n\n";
01078     exit(-1);
01079   } else {
01080     snprintf(inifilename,256,argv[1]);
01081     TGaxis::SetMaxDigits(3); 
01082     gROOT->SetStyle("Plain");
01083     gStyle->SetOptStat(kFALSE);
01084     gStyle->SetPalette(1,0);
01085     gStyle->SetTitleBorderSize(0);
01086     gStyle->SetCanvasBorderMode(0);
01087 
01088 
01089 
01090 
01091     TChain *geant = new TChain("geant");
01092 
01093 
01094     char filenamestring[256], lookupstring[256];
01095     //snprintf(filenamestring,256,"start");
01096     Int_t counter=1;
01097     snprintf(lookupstring,256,"file%i",counter);
01098 //    printf("%s\n",lookupstring);
01099     GetPrivateProfileString ("Filenames", lookupstring, "0", filenamestring, 256, inifilename);
01100 //    printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01101 //    snprintf(lookupstring,256,"file%i",2);
01102 //    GetPrivateProfileString ("Filenames", lookupstring, "0", filenamestring, 256, inifilename);
01103 //    printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01104 //    snprintf(lookupstring,256,"file%i",3);
01105 //    GetPrivateProfileString ("Filenames", lookupstring, "0", filenamestring, 256, inifilename);
01106 //    printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01107 //    snprintf(lookupstring,256,"file%i",4);
01108 //    GetPrivateProfileString ("Filenames", lookupstring, "0", filenamestring, 256, inifilename);
01109 //    printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01110 
01111     while (strcmp(filenamestring,"0")!=0) {
01112       printf("%i  %s\n",counter,filenamestring);
01113       geant->Add(filenamestring);
01114 //      printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01115       counter++;
01116 //      printf("%i\n",counter);
01117       snprintf(lookupstring,256,"file%i",counter);
01118 //      printf("%i %s  %s\n",counter,lookupstring,filenamestring);
01119       GetPrivateProfileString ("Filenames", lookupstring, "0", filenamestring, 256, inifilename);
01120     }
01121 
01122     char num_thrown_string[50];
01123     GetPrivateProfileString ("General", "num_thrown", "0", num_thrown_string, 50, inifilename);
01124     num_thrown = atoi(num_thrown_string);
01125     if (num_thrown<=0) {
01126       printf("num_thrown cannot equal %i\n",num_thrown);
01127       exit(-1);
01128     }
01129 
01130     eventtype=GetPrivateProfileInt("General", "eventtype", -1, inifilename);
01131     switch (eventtype) {
01132     case 0:
01133       printf("Analysing MOLLER events.\n");
01134       num_thrown=2*num_thrown;
01135       break;
01136     case 1: 
01137       printf("Analysing ELASTIC ep events.\n");
01138       break;
01139     case 2: 
01140       printf("Analysing INelastic ep events.\n");
01141       break;
01142     default:
01143       printf("eventtype not set correctly\n");
01144       exit(-1);
01145     }
01146     printf("num_thrown = %i\n",num_thrown);
01147 
01148 
01149     mollerClass* mollerClassobj = new mollerClass(geant);
01150     mollerClassobj->Loop();
01151 
01152     return 1;
01153   }
01154 }
01155 
01156 
01157 
01158 /* emacs
01159  * Local Variables:
01160  * mode:C++
01161  * mode:font-lock
01162  * c-file-style: "stroustrup"
01163  * tab-width: 4
01164  * End:
01165  */
01166 
01167 

Generated on 16 Jun 2013 for mollersim by  doxygen 1.6.1