StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
eemc.C
1 //=======================================================================
2 // owner: Oleg Rogachevsky
3 //=======================================================================
4 //
5 
6 #include <iostream.h>
7 
8 #define EEMC 5
9 #define EPRS 6
10 #define ESMDU 7
11 #define ESMDV 8
12 #define EPSTS 9
13 
14 //class StChain;
15 class St_geant_Maker;
16 
17 TBrowser *b = 0;
18 //StChain *chain= 0;
19 St_geant_Maker *geant= 0;
20 
21 const TString *detname[] = {
22  "bemc", "bprs", "bsmde", "bsmdp",
23  "eemc", "eprs", "esmdv", "esmdu", "epst" };
24 
25 // _____________________________________________________________________
26 Int_t getVolIdEemc(const Int_t ivid, Int_t &sector,Int_t &eta,
27 Int_t &sub, Int_t &detector)
28 {
29 
30  static Int_t emcIvid[4]={100000,1000,10,1};
31  Int_t emcChid[4], i, ividw, lowup, phi, dep;
32 
33  ividw = ivid;
34 
35  for(i=0; i<4; i++){
36  emcChid[i] = ividw/emcIvid[i];
37  ividw = ividw%emcIvid[i];
38  }
39 
40  if(ividw == 0){
41  lowup = emcChid[0]; // low/up half: =1 for lower, and =2 for upper
42  phi = emcChid[1]; // sector phi [1-60]
43  eta = emcChid[2]; // pseudorapidity bin number [1-12]
44  dep = emcChid[3]; // depth section [1-4];
45 
46  if (dep > 4)
47  printf(" getVolIdEemc => wrong value of section %i \n",dep);
48  detector = EEMC;
49  if (dep == 1) detector = EPRS;
50  else if
51  (dep == 4) detector = EPSTS;
52 
53  sector=(phi-1)/5 + 1;
54  sector=(phi-1)/5 + 1;
55  sub = (phi-1)%5 + 1;
56  // cout<<" Phi "<<phi<<endl;
57 
58  }
59  else{
60  printf("getVolIdEemc: error decoding EEMC Geant volume Id %i; lowup=%i\n",
61  ivid, lowup);
62  return 1;
63  }
64 
65  // TPC sector
66  if (lowup == 1) sector = sector + 3;
67  else {
68  sector = sector + 9;
69  if (sector > 12 )
70  sector = sector - 12;
71  }
72 
73  //printf(" vol_id=%i TPC sector=%2i subsector=%1i eta=%2i section=%2i\n",
74  // ivid,sector,sub,eta,dep);
75 
76  return 0;
77 }
78 
79 // _____________________________________________________________________
80 Int_t getVolIdEsmd(const Int_t ivid, Int_t &sector,Int_t &plane,
81 Int_t &strip, Int_t &detector)
82 {
83  static Int_t smdIvid[4]={1000000,10000,1000,1}; //matched with AGI&G2T
84  Int_t smdChid[5], i, ividw, lowup, phi;
85 
86  ividw = ivid;
87  for(i=0; i<4; i++){
88  smdChid[i] = ividw/smdIvid[i];
89  ividw = ividw%smdIvid[i];
90  }
91 
92  if(ividw == 0){ //
93  lowup = smdChid[0]; // low/up half: =1 for lower, and =2 for upper
94  phi = smdChid[1]; // sector phi [1-6]
95  plane = smdChid[2]; // SMD plane 1-3
96  strip = smdChid[3]; // strip number 1-288
97 
98  if (phi == 1 || phi == 4) {
99  if (plane == 3) detector = ESMDV;
100  if (plane == 1) detector = ESMDU;
101  }
102  else if (phi == 2 || phi == 5) {
103  if (plane == 1) detector = ESMDV;
104  if (plane == 2) detector = ESMDU;
105  }
106  else if (phi == 3 || phi == 6) {
107  if (plane == 2) detector = ESMDV;
108  if (plane == 3) detector = ESMDU;
109  }
110  else{
111  printf(" getVolIdEsmd -- error decoding ESMD Geant volume Id %i; lowup=%i\n",
112  ivid, lowup);
113  return 1;
114  }
115  }
116 
117  sector = phi;
118 
119 // TPC sector
120  if (lowup == 1) sector = sector + 3;
121  else {
122  sector = sector + 9;
123  if (sector > 12 )
124  sector = sector - 12;
125  }
126 
127 
128  //printf(" lowup=%i TPC sector=%i plane=%i strip=%i\n",
129  // lowup,sector,plane,strip);
130 
131  return 0;
132 }
133 
134 // _____________________________________________________________________
135 void eemc(const Int_t Nevents=2,
136  const Char_t *fzfile ="pt20y11phi50_0100.fzd")
137 {
138 
139  Float_t E;
140  Int_t nhit=0, id,m,e,s, adc;
141  Int_t ivid,sector,eta,plane,strip,sub,det;
142  Int_t i=0;
143 
144  gROOT->LoadMacro("bfc.C");
145 
146  bfc(0,"fzin sim_T gen_T",fzfile);
147 
148  for (i=1; i<=Nevents; i++ ) {
149  chain->Clear();
150  if (chain->Make(i)>=kStEOF) break;
151 
152  St_g2t_emc_hit *g2t_emc_hit = (St_g2t_emc_hit *) chain->FindObject("g2t_eem_hit");
153  if (g2t_emc_hit!=0) {
154  Int_t nhits = g2t_emc_hit->GetNRows();
155  g2t_emc_hit_st *hit = g2t_emc_hit->GetTable();
156  printf("#-# Emc hits :volume_id,energy\n");
157  for(Int_t ihit=0; ihit<nhits; ihit++,hit++) {
158  ivid = hit->volume_id;
159  E = hit->de;
160  getVolIdEemc(ivid,sector,eta,sub,det);
161  fprintf(stderr,"%2i %8i %s %8.6f \n",ihit,ivid,detname[det-1],E);
162  }
163  }
164 
165  St_g2t_emc_hit *g2t_smd_hit = (St_g2t_emc_hit *) chain->FindObject("g2t_esm_hit");
166  if (g2t_smd_hit !=0 ) {
167  Int_t nhits = g2t_smd_hit->GetNRows();
168  g2t_emc_hit_st *hit = g2t_smd_hit->GetTable();
169  printf("#-# Smd hits :volume_id,energy\n");
170  for(Int_t ihit=0; ihit<nhits; ihit++,hit++) {
171  ivid = hit->volume_id;
172  E = hit->de;
173  getVolIdEsmd(ivid,sector,plane,strip,det);
174  printf("%2i %8i %s %8.6f \n",ihit,ivid,detname[det-1],E);
175  }
176  }
177  printf ("=========================================== Done with Event no. %d\n",i);
178 
179  }
180 }
181 
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110