StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEsectorDst.cxx
1 // $Id: EEsectorDst.cxx,v 1.8 2007/05/30 02:38:48 balewski Exp $
2 
3 #include <cassert>
4 #include <TClonesArray.h>
5 #include <StMessMgr.h>
6 
7 #include "EEtwHitDst.h"
8 #include "EEsmdHitDst.h"
9 #include "EEsectorDst.h"
10 
11 ClassImp(EEsectorDst)
12 
13 //---------------------------------------------------
14 //---------------------------------------------------
15 //---------------------------------------------------
16 EEsectorDst::EEsectorDst(int id){
17  // printf("EEsectorDst(ID=%d) constructed\n",id);
18  ID=id;
19  Pre1Hits = new TClonesArray("EEtwHitDst",1000);
20  Pre2Hits = new TClonesArray("EEtwHitDst",1000);
21  TwHits = new TClonesArray("EEtwHitDst",1000);
22  SmdUHits = new TClonesArray("EEsmdHitDst",1000);
23  SmdVHits = new TClonesArray("EEsmdHitDst",1000);
24  PostHits = new TClonesArray("EEtwHitDst",1000);
25 }
26 
27 //---------------------------------------------------
28 //---------------------------------------------------
29 //---------------------------------------------------
30 EEsectorDst::~EEsectorDst() {
31  delete Pre1Hits;
32  delete Pre2Hits;
33  delete TwHits;
34  delete SmdUHits;
35  delete SmdVHits;
36  delete PostHits;
37 }
38 
39 //---------------------------------------------------
40 //---------------------------------------------------
41 //---------------------------------------------------
42 void EEsectorDst::clear(){
43  Pre1Hits->Clear();
44  Pre2Hits->Clear();
45  SmdUHits->Clear();
46  SmdVHits->Clear();
47  TwHits->Clear();
48  PostHits->Clear();
49 }
50 
51 
52 //---------------------------------------------------
53 //---------------------------------------------------
54 //---------------------------------------------------
55 void EEsectorDst::print(int k){
56 
57  LOG_INFO<<Form("EEsectorDst(ID=%d)::print() nPre1Hit=%d nPre2Hit=%d nSmdUHit=%d nSmdVHit=%d nTowerHit=%d nPostHit=%d \n",ID,Pre1Hits->GetEntries(),Pre2Hits->GetEntries(),SmdUHits->GetEntries(),SmdVHits->GetEntries(),TwHits->GetEntries(),PostHits->GetEntries())<<endm;
58 
59  if(k<0) return;
60 
61  LOG_INFO<<Form("EEsectorDst(Tower) nHit=%d\n",TwHits->GetEntries())<<endm;
62  int i;
63 
64  TClonesArray *hitA=getTwHits();
65  for(i=0;i<hitA->GetEntries();i++){
66  EEtwHitDst *hit=(EEtwHitDst*)hitA->At(i);
67  hit->print();
68  }
69 
70  LOG_INFO<<Form ("EEsectorDst(pre/post/SMD) not implemented\n")<<endm;
71 }
72 
73 
74 //---------------------------------------------------
75 //---------------------------------------------------
76 //---------------------------------------------------
77 void EEsectorDst::addTwHit(char sub, int eta, float ener, TClonesArray *hitA) {
78 
79  TClonesArray &hits = *hitA;
80  int len=hits.GetEntries();
81  EEtwHitDst *hit= new(hits[len]) EEtwHitDst;
82  hit->set(sub,eta,ener);
83  // printf("in , added ~tw hit=%d ener=%f\n",len,ener);
84 }
85 
86 
87 //---------------------------------------------------
88 //---------------------------------------------------
89 //---------------------------------------------------
90 void EEsectorDst::addSmdHit(int strip, float ener, TClonesArray *hitA) {
91 
92  TClonesArray &hits = *hitA;
93  int len=hits.GetEntries();
94  EEsmdHitDst *hit= new(hits[len]) EEsmdHitDst;
95  //printf("in , added ~smd hit=%d ener=%f\n",len,ener);
96 
97  hit->set(strip,ener);
98 }
99 
100 //---------------------------------------------------
101 //---------------------------------------------------
102 //---------------------------------------------------
103 void EEsectorDst::sumRawMC(EEsectorDst *outSec, float minE) {
104 
105  // const float fac[4]={1,1,1,1}; //tmp, needs to be adjusted
106  // for Tower=sum over layers
107 
108  const int mx=60;
109  const int mx2=300;
110  float sum1[mx]; // hit accumulator for geant depth 1 == layer 1
111  float sum2[mx]; // depth 2 == layer 2
112  float sumU[mx2]; // depth - == smd U
113  float sumV[mx2]; // depth - == smd V
114  float sum3[mx]; // depth 3 == layer 3-23
115  float sum4[mx]; // depth 4 == layer 24
116 
117  sumRawMCtw(Pre1Hits,sum1,mx);
118  sumRawMCtw(Pre2Hits,sum2,mx);
119 
120  sumRawMCsmd(SmdUHits ,sumU,mx2);
121  sumRawMCsmd(SmdVHits ,sumV,mx2);
122  sumRawMCtw(TwHits ,sum3,mx);
123  sumRawMCtw(PostHits,sum4,mx);
124 
125  int j;
126 
127  // extract non-zero elements, build tower response
128  float grandSum=0;
129 
130 
131  // for(j=0;j<mx2;j++) grandSum+=sumU[j];
132  // for(j=0;j<mx2;j++) grandSum+=sumV[j];
133 
134  // copy tower hits above energy threshold
135  for(j=0;j<mx;j++) {
136  char sub='A'+j/12;
137  int eta=1+j%12;
138  float ener1=sum1[j]; // layer 1
139  float ener2=sum2[j]; // layer 2
140  float ener3=sum3[j]; // layer 3-23
141  float ener4=sum4[j]; // layer 24
142 
143  float ener14=ener1+ener2+ener3+ener4; // all layers
144 
145  grandSum+=ener14;
146 
147  if(ener1>minE) //Pre1
148  addTwHit(sub,eta,ener1,outSec->Pre1Hits);
149 
150  if(ener2>minE) //Pre2
151  addTwHit(sub,eta,ener2,outSec->Pre2Hits);
152 
153  if(ener14>minE) //Tower
154  addTwHit(sub,eta,ener14,outSec->TwHits);
155 
156  if(ener4>minE) //Post
157  addTwHit(sub,eta,ener4,outSec->PostHits);
158 
159  }// end of loop over 60 towers in subsect
160 
161  // printf(" sector=%d towerOnlySum=%f\n",ID,grandSum);
162  // copy smd-U&V hits above energy threshold
163  for(j=0;j<mx2;j++) {
164  int strip=j+1;
165 
166  float ener=sumU[j];
167  grandSum+=ener;
168  if(ener>minE)
169  addSmdHit(strip,ener,outSec->SmdUHits);
170 
171  ener=sumV[j];
172  grandSum+=ener;
173  if(ener>minE)
174  addSmdHit(strip,ener,outSec->SmdVHits);
175 
176  }// end of loop over 288 SMD strip
177 
178  // printf(" sector=%d grandSum=%f\n",ID,grandSum);
179 
180 }
181 
182 //---------------------------------------------------
183 //---------------------------------------------------
184 //---------------------------------------------------
185 void EEsectorDst::sumRawMCtw(TClonesArray *inH, float* sum, int mx) {
186  //printf("\n \ncall EEsectorDst::sumRawMCtw\n");
187 
188  int j;
189  for(j=0;j<mx;j++) sum[j]=0;
190 
191  int nOK=0;
192  // acumulate hits
193  int ih;
194  for(ih=0;ih<inH->GetEntries();ih++) {
195  EEtwHitDst *hit=(EEtwHitDst*)inH->At(ih);
196  char sub;
197  int eta;
198  float ener;
199 
200  hit->get(sub,eta,ener);
201  //printf(" index=%d sub=%c etaBin=%d ener=%f \n",index, sub, eta,ener);
202 
203  nOK++;
204 
205  int index=(sub-'A')*12+ (eta-1);
206  assert(index>=0 && index<mx);
207  sum[index]+=ener;
208  }
209  // printf("sumRawMCtw() accepted %d of %d raw GEANT hits\n",nOK,inH->GetEntries());
210 }
211 
212 
213 //---------------------------------------------------
214 //---------------------------------------------------
215 //---------------------------------------------------
216 void EEsectorDst::sumRawMCsmd(TClonesArray *inH, float* sum, int mx) {
217 
218  int j;
219  for(j=0;j<mx;j++) sum[j]=0;
220 
221  int nOK=0;
222  int ih;
223  for(ih=0;ih<inH->GetEntries();ih++) { // acumulate hits
224  EEsmdHitDst *hit=(EEsmdHitDst*)inH->At(ih);
225  int strip;
226  float ener;
227 
228  hit->get(strip,ener);
229  // hit->print();
230  nOK++;
231 
232  int index=strip-1;
233  assert(index>=0 && index<mx);
234  sum[index]+=ener;
235  }
236  // printf("sumRawMCsmd() accepted %d of %d raw GEANT hits\n",nOK,inH->GetEntries());
237 }
238 
239 // $Log: EEsectorDst.cxx,v $
240 // Revision 1.8 2007/05/30 02:38:48 balewski
241 // replace printf -->LOG_XXX
242 //
243 // Revision 1.7 2003/11/12 19:59:06 balewski
244 // I forgot what has changed
245 //
246 // Revision 1.6 2003/10/02 20:52:45 balewski
247 // more functionality for print()
248 //
249 // Revision 1.5 2003/09/11 19:40:56 zolnie
250 // updates for gcc3.2
251 //
252 // Revision 1.4 2003/07/01 14:13:13 balewski
253 // no clue
254 //
255 // Revision 1.3 2003/02/20 20:13:15 balewski
256 // fixxy
257 // xy
258 //
259 // Revision 1.2 2003/02/20 05:15:14 balewski
260 // reorganization
261 //
262 // Revision 1.1 2003/01/28 23:16:07 balewski
263 // start
264 //
265 // Revision 1.8 2002/11/30 20:03:15 balewski
266 // consistent with FeeRawTTree
267 //
268 // Revision 1.7 2002/10/03 00:30:46 balewski
269 // tof taken away
270 //
271 // Revision 1.6 2002/10/01 06:03:16 balewski
272 // added smd & pre2 to TTree, tof removed
273 //
274 // Revision 1.5 2002/09/27 19:10:37 balewski
275 // aaa
276 //
277 // Revision 1.4 2002/09/25 16:47:55 balewski
278 // cleanup , cut in geant time for twoer-like detectors
279 //
280 // Revision 1.3 2002/09/25 01:36:13 balewski
281 // fixed TOF in geant
282 //
283 // Revision 1.2 2002/09/20 21:58:13 balewski
284 // sum of MC hits over activ detectors
285 // produce total tower energy with weight 1 1 1 1
286 //
287 // Revision 1.1.1.1 2002/09/19 18:58:54 zolnie
288 // Imported sources
289 //
290 // Revision 1.1.1.1 2002/08/29 19:32:01 zolnie
291 // imported sources
292 //
293 // Revision 1.2 2002/08/28 01:43:42 zolnie
294 // version alpha - 2
295 //
296 // Revision 1.1 2002/08/26 19:46:12 zolnie
297 // Initial revision
298 //
299 
300 
301 
302 
303