StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St2009WlumiMaker.cxx
1 // $Id: St2009WlumiMaker.cxx,v 1.3 2011/09/14 14:23:21 stevens4 Exp $
2 //
3 //*-- Author : Ross Corliss, MIT
4 
5 #include "St2009WMaker.h"
6 
7 #include "St2009WlumiMaker.h"
8 
9 ClassImp(St2009WlumiMaker)
10 
11 //_____________________________________________________________________________
12 //
13 St2009WlumiMaker::St2009WlumiMaker(const char *name):StMaker(name){
14  wMK=0;muMK=0;HList=0;
15 
16 }
17 
18 
19 //_____________________________________________________________________________
20 //
21 Int_t St2009WlumiMaker::Init(){
22  assert(wMK);
23  assert(muMK);
24  assert(HList);
25  initHistos();
26  return StMaker::Init();
27 }
28 
29 
30 //_____________________________________________________________________________
31 //
32 Int_t St2009WlumiMaker::InitRun (int runumber){
33  towerInfoIsCurrent=false; // make sure we check the tower info on the first event.
34  nActiveTowers=0;
35  for (int i=0;i<16;i++) nBHT3[i]=0;
36  nBHT3_software_L0=0;
37  nBHT3_hardware_L0=0;
38  for (int i=0;i<120;i++)
39  for (int j=0;j<16;j++)
40  nBx[j][i]=0;
41 
42  return 0;
43 }
44 
45 //_____________________________________________________________________________
46 //
47 Int_t St2009WlumiMaker::FinishRun (int runnumber){
48 
49  printf("Finishing Run %d (lumi)\n",runnumber);
50 
51  char runName[9];
52  sprintf(runName,"%d",runnumber);
53 
54  float activeFraction=nActiveTowers*1.0/4800.0; //portion of the detector that was working.
55  float effective_lumi;//pb^-1, effective integrated luminosity, given not all the detector is necessarily working.
56  float total_lumi;//pb^-1, total integrated luminosity if the whole detector were working.
57  int BHT3prescale=50;//recorded 1/n events:
58  int nBHT3triggers;//number of non-background BHT3 events roughly (nBHT3*BHT3prescale);
59  float BHT3xs=520000;//pb . 520nb.
60  int nAbortGap1, nAbortGap2; //number of counts in the first and second abort gap.
61 
62  //try all possible alignments of the abort gaps to find the right relative alignment,
63  //then count the events in those two gaps.
64  getAbortGapCounts(0,&nAbortGap1,&nAbortGap2);
65 
66  hA[19]->Fill(runName,nBHT3_software_L0);
67  hA[20]->Fill(runName,nBHT3_hardware_L0);
68  hA[21]->Fill(runName,nAbortGap1);
69  hA[22]->Fill(runName,nAbortGap2);
70  nBHT3triggers=(nBHT3_software_L0-nAbortGap1*111.0/11.0-nAbortGap2*109.0/9.0)*BHT3prescale;
71  hA[23]->Fill(runName,nBHT3triggers);
72 
73  effective_lumi=nBHT3triggers*1.0/BHT3xs;
74  hA[24]->Fill(runName,effective_lumi);
75  //this value doesn't have any factors of activeFraction, because they cancel out:
76  //ntotaltriggers=nBHT3triggers/activeFraction
77  //total_lumi=ntotaltriggers/bht3xs
78  //effective_lumi=total_lumi*activeFraction
79 
80  total_lumi=effective_lumi/activeFraction;
81  hA[16]->Fill(runName,total_lumi);
82  hA[17]->Fill(runName,activeFraction);
83  hA[18]->Fill(runName,nAbortGap1*120/11+nAbortGap2*120/9);
84  printf("eff_lumi=%f, active=%2.2f, nTowers=%d\n",effective_lumi,activeFraction,nActiveTowers);
85 
86  for (int i=0;i<16;i++)
87  {
88  //printf("nBHT3[%d]=%d\n",i,nBHT3[i]);
89  hA[25]->Fill(i,nBHT3[i]);
90  hA[30+i]->Fill(runName,nBHT3[i]);
91  getAbortGapCounts(i,&nAbortGap1,&nAbortGap2);
92  hA[50+i]->Fill(runName,nAbortGap1);
93  hA[70+i]->Fill(runName,nAbortGap2);
94  }
95 
96  TH1F* temp;
97  temp=(TH1F*)(HList->FindObject("muWET"));
98  hA[5]->Add(temp,1.0/activeFraction);//yield scaled by the active fraction
99 
100 
101  //temp=HList("");
102  //repeat for other histos.
103 
104 return 0;
105 }
106 
107 //_____________________________________________________________________________
108 //
109 Int_t
111  // printf("in %s\n", GetName());
112  //hA[0]->Fill("",1.);
113 
114  //if we haven't done it yet, calculate the working fraction of the bemc
115  if (!towerInfoIsCurrent) getActiveTowers();
116 
117  //fill various histograms and arrays with event data
118  sortTrigger();
119 
120  // printf("Out of Make\n");
121  return kStOK;
122 }
123 
124 //_____________________________________________________________________________
125 //
126 void
127 St2009WlumiMaker::getActiveTowers(){
128  //count the number of good towers:
129  nActiveTowers=0;
130  WeveBEMC *barrel=&(wMK->wEve.bemc);
131  for (int i=0;i<4800;i++)
132  if (barrel->statTile[0][i]==0)//[0]=kBtow
133  nActiveTowers++;
134 
135  //count good trigger patches?
136 
137  if (nActiveTowers>0) towerInfoIsCurrent=true;
138  return;
139 }
140 
141 //_____________________________________________________________________________
142 //
143 void
144 St2009WlumiMaker::sortTrigger(){
145  int thresh[16];
146  thresh[0]=-1;
147  thresh[1]=14;
148  thresh[2]=36;
149  thresh[3]=56;
150  thresh[4]=78;
151  thresh[5]=98;
152  thresh[6]=119;
153  thresh[7]=139;
154  thresh[8]=161;
155  thresh[9]=181;
156  thresh[10]=201;
157  thresh[11]=222;
158  thresh[12]=243;
159  thresh[13]=263;
160  thresh[14]=283;
161  thresh[15]=306;
162 
163  //printf("sortTrigger()\n");
164  //has access to whole W-algo-maker data via pointer 'wMK'
165  Wevent2009 *weve=&(wMK->wEve);
166 
167  if (weve->l2bitET) {
168  //printf("ET\n");
169  hA[0]->Fill("L2W",1);
170  hA[0]->Fill("L2Wnormal",1);
171  }
172  if (weve->l2bitRnd) {
173  //printf("Rnd\n");
174  hA[0]->Fill("L2W",1);
175  hA[0]->Fill("L2Wrandom",1);
176  nBHT3_hardware_L0++;
177  if (wMK->passes_L0())
178  {
179  nBHT3_software_L0++;
180  //hA[1]->Fill(weve->bx7);
181  //printf("passes_L0\n");
182  for (int i=0;i<16;i++)
183  {
184  //fill histo for awayside sum
185  hA[90+i]->Fill(weve->trigAwaySum[i]);
186 
187  //printf("AwaySum[%d]=%d\n",i,weve->trigAwaySum[i]);
188  if (weve->trigAwaySum[i]>=thresh[i]) //for bg test
189  {
190  //printf("Passes coin(%d)!\n",i);
191  nBHT3[i]++;
192  //printf("Passes coin(%d)(%d)\n",i,nBHT3[i]);
193  nBx[i][weve->bx7]++;
194  }
195  }
196  }
197  }
198 
199 
200  //printf("out of sort\n");
201  return;
202 }
203 
204 //_____________________________________________________________________________
205 //
206 void
207 St2009WlumiMaker::getAbortGapCounts(int angle, int *n1, int* n2){
208 
209  //new, simple method: count only over the last 8 bins of the gap.
210  *n1=0;
211  for (int i=32;i<=39;i++)
212  *n1+=nBx[angle][i];
213  *n2=0;
214  for (int i=112;i<=119;i++)
215  *n2+=nBx[angle][i];
216  return;
217 }
218 
219 // $Log: St2009WlumiMaker.cxx,v $
220 // Revision 1.3 2011/09/14 14:23:21 stevens4
221 // update used for cross section PRD paper
222 //
223 // Revision 1.2 2010/12/02 18:31:43 rcorliss
224 // updated lumi code to match the starnote version
225 //
226 // Revision 1.1 2009/11/23 23:00:18 balewski
227 // code moved spin-pool
228 //
229 // Revision 1.1 2009/11/23 21:11:18 balewski
230 // start
231 //
gathers all results from W-analysis, Jan&#39;s analysis
Definition: Stypes.h:40
virtual Int_t Make()