StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEtower.cxx
1 // $Id: EEtower.cxx,v 1.2 2004/06/08 17:10:41 balewski Exp $
2 
3 #include <assert.h>
4 #include <stdlib.h>
5 
6 #include <TClonesArray.h>
7 #include <TObjArray.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 #include <TFile.h>
11 
12 #include "EEtower.h"
13 
14 ClassImp(EEtower)
15 //--------------------------------------------------
16 //--------------------------------------------------
18  setThres(0.3,0);
19  printf("EEtower() constructed\n");
20  nInpEve=0;
21  HList=0;
22  eeDb=0;
23 }
24 
25 //--------------------------------------------------
26 //--------------------------------------------------
27 EEtower::~EEtower() {/* noop */}
28 
29 
30 //-------------------------------------------------
31 //-------------------------------------------------
32 //-------------------------------------------------
33 void EEtower::init( ){
34  int i;
35  float Emax=2;
36  memset(hA,0,sizeof(hA));
37 
38  hA[0]=new TH1F ("tE","Eneregy (GeV) from any tower",100,0.,Emax);
39  hA[1]=new TH1F ("sE","Total Eneregy in event (GeV) (sum from all tower)",200,0.,Emax*10);
40  hA[4]=new TH1F ("tN","No. of towers with energy above th1",30,-0.5,29.5);
41 
42  // add histos to the list (if provided)
43  if(HList) {
44  for(i=0;i<32;i++) {
45  if(hA[i]==0) continue;
46  HList->Add(hA[i]);
47  }
48  }
49 
50 }
51 
52 //-------------------------------------------------
53 //-------------------------------------------------
54 //-------------------------------------------------
55 void EEtower::clear(){ // called for every event
56  memset(towerE,0,sizeof(towerE));
57 }
58 
59 //-------------------------------------------------
60 //-------------------------------------------------
61 //-------------------------------------------------
62 void EEtower::finish(){
63  printf("\n EEtower::finish() nInpEve=%d\n",nInpEve);
64 }
65 
66 //-------------------------------------------------
67 //-------------------------------------------------
68 void EEtower::print(){
69  printf("\n EEtower::print()\n dump event:\n");
70  int i,j;
71  printf("phiBin, towerE for %d eta bins \n",MaxPhiBins);
72  for(j=0;j<MaxPhiBins;j++) {
73  printf("%4d: ",j);
74  for(i=0;i<MaxEtaBins;i++)
75  printf("%8.3f ",towerE[i][j]);
76  printf("\n");
77  }
78 }
79 
80 
81 //-------------------------------------------------
82 //-------------------------------------------------
83 //-------------------------------------------------
84 void EEtower::task1(){
85  // printf("\n EEtower::task1()\n");
86  int i,j;
87  int nd=0;
88  float totE=0;
89  for(j=0;j<MaxPhiBins;j++) {
90  for(i=0;i<MaxEtaBins;i++) {
91  float e=towerE[i][j];
92  totE+=e;
93  if(e>th1) nd++;
94  hA[0]->Fill(e);
95  }
96  }
97 
98  hA[1]->Fill(totE);
99  hA[4]->Fill(nd);
100 }
101 
102 
103 //-------------------------------------------------
104 //-------------------------------------------------
105 void EEtower:: saveHisto(TString fname){
106  TString outName=fname+".hist.root";
107  TFile f( outName,"recreate");
108  assert(f.IsOpen());
109  printf("%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
110  HList->Write();
111  f.Close();
112 }
113 
float towerE[MaxEtaBins][MaxPhiBins]
no. of input events
Definition: EEtower.h:45
TObjArray * HList
DB access point.
Definition: EEtower.h:50