StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
setWALmodel.C
1 class TH1F;
2 enum {mxH=2, mxQ=2};
3 TH1F *hA[mxQ][mxH];
4 
5 void setWALmodel(int plot=1) {
6  TString outF="WALModel_a.hist.root";
7  TFile *fd=new TFile(outF,"recreate");
8 
9  //........... initialize histos .....
10  TString titA[mxH]={"AL","ALL"};
11 
12  for (int q=0;q<mxQ;q++) {
13  TString Q="P"; if (q) Q="N";
14  for (int i=0;i<mxH; i++) {
15  TString tit=+titA[i]+"_"+Q;
16  hA[q][i]=newEtaBinHisto("modW_"+tit,"model W "+tit);
17  if(i==0) hA[q][i]->SetLineColor(kRed);
18  if(i==1) hA[q][i]->SetLineColor(kGreen);
19  }
20  }
21 
22  //......... populate bins, use errors if known
23  //fillDataBin20();//for barrel-integral based on 2009 analysis
24 
25  //......... populate bins with arbitrary model shape
26  for (int iq=0;iq<mxQ;iq++)
27  fillDataBin11_18(iq);
28 
29  if(plot) { // special case
30  ln=new TLine(10,0,20,0);
31  c=new TCanvas();
32  gStyle->SetOptStat(0);
33  c->Divide(2,2);
34  float yMx=0.9; int k=1;
35  for (int i=0;i<mxH; i++) {
36  for (int q=0;q<mxQ;q++) {
37  c->cd(k++);
38  TH1F *h=hA[q][i];
39  h->Draw(); h->SetFillColor(16);
40  h->SetMinimum(-yMx); h->SetMaximum(yMx);
41  h->SetAxisRange(11,18);
42  gPad->SetGrid();
43  ln->Draw();
44 
45  if(i==0) {
46  ar=new TArrow(10.6,yMx*0.9,18.3,yMx*0.9, 0.025); ar->Draw(); ar->SetLineColor(kBlue);
47  tx1=new TLatex(10.8,yMx*.7,"-1.3 "); tx1->Draw(); tx1->SetTextColor(kBlue);
48  tx1=new TLatex(14.8,yMx*.7," polBeam #eta 1.3"); tx1->Draw(); tx1->SetTextColor(kBlue);
49  }
50  if(i==1) {
51  ar=new TArrow(14.6,yMx*0.9,18.3,yMx*0.9, 0.025); ar->Draw(); ar->SetLineColor(kBlue);
52  tx1=new TLatex(14.8,yMx*.7,"0 polBeam #eta 1.3"); tx1->Draw(); tx1->SetTextColor(kBlue);
53  }
54  }
55  }
56  printf("WARN: histos NOT saved\n");
57  return;
58  }
59 
60 
61  fd->Write();
62  fd->ls();
63  fd->Close();
64 
65 }
66 
67 //------------------
68 TH1F *newEtaBinHisto(TString name="aa", TString title="bb", TString yLable=""){
69  int nb=22;
70  TH1F *h=new TH1F(name, title+"; (STAR #eta <9< polBeam #eta) #eta-bins;"+yLable,nb,0.5,nb+0.5);
71  return h;
72 }
73 //------------------
74 TH1F *newSpin4Histo(TString name="aa", TString title="bb"){
75  int nb=16; // WARN: counts from 0 from historic reasons
76  return new TH1F(name, title+"; spin4 index ",nb,-0.5,nb-0.5);
77 }
78 
79 //-----------------
80 void fillDataBin11_18(int iq=0) {//arbitrary model shape
81  double ALP[8]={-0.4,-0.2,0.1,0.3,0.4,0.6,0.5,0.4};
82  double ALLP[4]={0.5,-0.1,-0.3,-0.4};
83 
84  double ALN[8]={0.4,0.6,0.8,0.4,0.2,0.4,0.6,0.3};
85  double ALLN[4]={-0.6,-0.5,-0.3,-0.7};
86 
87  double *AL=ALP, *ALL=ALLP;
88  if(iq) { AL=ALN; ALL=ALLN;}
89 
90  for(int k=11; k<=18;k++) {
91  hA[iq][0]->SetBinContent(k,AL[k-11]);//AL
92  int j=k-15;
93  if (j<0) j=14-k;
94  printf("k=%d AL=%.1f j=%d ALL=%.1f\n",k,AL[k-11],j,ALL[j]);
95  hA[iq][1]->SetBinContent(k,ALL[j]);//ALL
96  }
97 }
98 
99 
100 //-----------------
101 void fillDataBin20() {
102  // for barrel-integral based on 2009 analysis
103  int bin=20; // for physics eta-range[-1,+1]
104 
105  hA[0][0]->SetBinContent(bin,-0.27);//AL,W+
106  hA[0][1]->SetBinContent(bin,0.5);//ALL,W+
107 
108  hA[1][0]->SetBinContent(bin,0.14);//AL,W-
109  hA[1][1]->SetBinContent(bin,-0.3);//ALL,W-
110 
111 }