StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcGeom.cxx
1 /***************************************************************************
2  *
3  * $Id: StEmcGeom.cxx,v 1.13 2018/12/20 22:07:05 perev Exp $
4  *
5  * Author: Aleksei Pavlinov , June 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEmcGeom.cxx,v $
13  * Revision 1.13 2018/12/20 22:07:05 perev
14  * Remove creating and deleting StMaker
15  *
16  * Revision 1.12 2012/04/03 00:04:04 perev
17  * Defence against zero size table added
18  *
19  * Revision 1.11 2008/11/03 21:00:37 mattheww
20  * updated the geometry again
21  *
22  * Revision 1.10 2008/10/21 19:14:16 mattheww
23  * Update to Barrel Geometry (corrected edge locations to eta = 0.0035, 0.9835)
24  *
25  * Revision 1.9 2008/04/22 12:24:52 kocolosk
26  * bug was actually in the BSMDP mapping the whole time -- see RT #1162
27  *
28  * Revision 1.8 2008/04/16 20:57:05 kocolosk
29  * rollback to 1.6 till we get RT#1162 ironed out
30  *
31  * Revision 1.7 2008/04/14 21:53:35 kocolosk
32  * fix mapping between GEANT volume ID and m-e-s space for BTOW/BPRS, eta<0 (see RT# 1162)
33  *
34  * Revision 1.6 2007/04/04 17:32:11 kocolosk
35  * Added softId-based versions of getEta, getTheta, and getPhi. Also added getId(phi,eta,&softId). Implemented const-correctness and used meaningful argument names in method declarations to improve readability
36  *
37  * Revision 1.5 2004/08/19 17:31:45 pavlinov
38  * getBin(const Float_t phi, const Float_t eta, Int_t &m,Int_t &e,Int_t &s) works bsmde too - request of Dmitry Arkhipkin
39  *
40  * Revision 1.4 2003/09/02 17:58:01 perev
41  * gcc 3.2 updates + WarnOff
42  *
43  * Revision 1.3 2003/04/16 15:27:51 suaide
44  * small fix on default geant geometry
45  *
46  * Revision 1.2 2003/01/23 03:04:56 jeromel
47  * Include modif
48  *
49  * Revision 1.1 2003/01/23 01:30:28 suaide
50  * moving to sub directories
51  *
52  * Revision 1.15 2003/01/17 00:45:38 suaide
53  * Default option for geometry is Y2003
54  *
55  * Revision 1.14 2001/09/28 23:54:37 pavlinov
56  * Change dtor
57  *
58  * Revision 1.13 2001/09/22 00:29:05 pavlinov
59  * No public constructor for StEmcGeom
60  *
61  * Revision 1.12 2001/07/30 00:16:07 pavlinov
62  * Correct numbering scheme for BSMDE
63  *
64  * Revision 1.11 2001/05/30 18:01:22 perev
65  * stdlib.h added
66  *
67  * Revision 1.10 2001/05/02 20:34:02 pavlinov
68  * mCalg must zero on constractor
69  *
70  * Revision 1.9 2001/05/02 16:35:51 pavlinov
71  * Change default value of calb for year2001 geometry
72  *
73  * Revision 1.8 2001/04/29 16:26:32 pavlinov
74  * clean up
75  *
76  * Revision 1.7 2001/04/28 19:46:29 pavlinov
77  * Reject output
78  *
79  * Revision 1.6 2001/04/26 14:23:40 akio
80  * Quick and dirty fix for crashing non-bfc chain
81  *
82  * Revision 1.5 2001/04/25 02:41:45 pavlinov
83  * Fixed erorr for transition from ivid to EMC numeration
84  *
85  * Revision 1.4 2001/04/25 01:03:03 pavlinov
86  * Clean up
87  *
88  * Revision 1.3 2001/03/23 18:59:05 pavlinov
89  * delete gROOT definition because exist in TROOT.h
90  *
91  * Revision 1.2 2001/03/22 21:50:40 pavlinov
92  * Clean up for mdc4
93  *
94  * Revision 1.1 2000/06/20 17:11:25 pavlinov
95  * Move StEmcGeom.h from St_emc_Maker to StEmcUtil
96  *
97  * Revision 1.10 2000/05/23 14:35:02 pavlinov
98  * Clean up for SUN
99  *
100  * Revision 1.9 2000/05/18 17:07:31 pavlinov
101  * Fixed error for methods getXYZ(...)
102  *
103  * Revision 1.8 2000/05/17 16:05:32 pavlinov
104  * Change method getVolIdBemc
105  *
106  * Revision 1.7 2000/04/25 17:02:06 pavlinov
107  * Added methods for gettinng x,y,z from volume ID
108  *
109  * Revision 1.6 2000/04/21 17:43:02 pavlinov
110  * Added methods for for decoding Geant volume Id
111  *
112  * Revision 1.5 2000/04/18 20:38:10 pavlinov
113  * Added ctor from Geant geometry
114  *
115  * Revision 1.4 2000/04/11 19:48:40 pavlinov
116  * Merge versions of Pavlinov and Ogawa
117  *
118  * Revision 1.3 2000/01/29 00:04:57 akio
119  * temprary fix for endcap. need more work, but no more junk messages and crash
120  *
121  * Revision 1.2 1999/07/02 03:01:55 pavlinov * Little corrections for Linux
122  *
123  * Revision 1.1 1999/07/01 16:17:57 pavlinov
124  * class StEmcGeom was created and maker was remade for new maker scheme
125  *
126  **************************************************************************/
127 #include "StEmcGeom.h"
128 #include <assert.h>
129 #include <strings.h>
130 #include <stdlib.h>
131 #include <TROOT.h>
132 #include "StMaker.h"
133 #include "StEmcUtil/others/emcInternalDef.h"
134 
135 ClassImp(StEmcGeom)
136 
137 StEmcGeom *StEmcGeom::mGeom[8] = {0,0,0,0,0,0,0,0};
138 
139 const Float_t perr=0.01;
140 Float_t rmin, rsmdEta, rsmdPhi;
141 
142 StEmcGeom
143 *StEmcGeom::instance(const Int_t det)
144 {
145  return getEmcGeom(det);
146 }
147 StEmcGeom
148 *StEmcGeom::getEmcGeom(const Int_t det)
149 {
150  if(det>=1 && det<=4) {
151  Int_t indDet = det - 1;
152  if(mGeom[indDet] == 0) mGeom[indDet] = new StEmcGeom(det);
153  return mGeom[indDet];
154  } else return 0; // wrong index
155 }
156 
157 
158 StEmcGeom
159 *StEmcGeom::instance(const Char_t *cdet)
160 {
161  return getEmcGeom(cdet);
162 }
163 StEmcGeom
164 *StEmcGeom::getEmcGeom(const Char_t *cdet)
165 {
166  Int_t det=getDetNumFromName(cdet);
167  return getEmcGeom(det);
168 }
169 
170 
171 StEmcGeom
172 *StEmcGeom::instance(const Int_t det, const Char_t* mode)
173 {
174  return getEmcGeom(det,mode);
175 }
176 StEmcGeom
177 *StEmcGeom::getEmcGeom(const Int_t det, const Char_t* mode)
178 {
179  if(det>=1 && det<=4) {
180  Int_t indDet = det - 1;
181  if(mGeom[indDet] == 0) mGeom[indDet] = new StEmcGeom(det, mode);
182  return mGeom[indDet];
183  } else return 0; // wrong index
184 }
185 
186 //===============================================
187 StEmcGeom::StEmcGeom(const Int_t det)
188 {
189  initGeom(det);
190 }
191 
192 StEmcGeom::StEmcGeom(const Char_t *cdet)
193 {
194  Int_t det=getDetNumFromName(cdet);
195  if(det) initGeom(det);
196 }
197 
198 Int_t
199 StEmcGeom::getDetNumFromName(const Char_t *cdet)
200 {
201  Int_t det=0;
202  if (!strcmp(cdet,"bemc")) {det=1;}
203  else if(!strcmp(cdet,"bprs")) {det=2;}
204  else if(!strcmp(cdet,"bsmde")){det=3;}
205  else if(!strcmp(cdet,"bsmdp")){det=4;}
206  else if(!strcmp(cdet,"eemc")) {det=5;}
207  else if(!strcmp(cdet,"eprs")) {det=6;}
208  else if(!strcmp(cdet,"esmde")){det=7;}
209  else if(!strcmp(cdet,"esmdp")){det=8;}
210  else {LOG_ERROR << Form(" StEmcGeom: Bad value of cdet %s ", cdet) << endm;}
211  return det;
212 }
213 
214 StEmcGeom::~StEmcGeom()
215 {// for shure
216  mGeom[mDetector] = 0;
217 }
218 
219 void StEmcGeom::initGeom(const Int_t det)
220 {
221  mMode="default";
222  mDetector = det;
223  mGeantGeom = 0;
224  mCalg = 0;
225  mCalg_st = 0;
226  mCalr = 0;
227  mCalr_st = 0;
228 
229  mPhiOffset.Set(2); mPhiStep.Set(2); mPhiBound.Set(2);
230 
231  defineDefaultCommonConstants();
232  defineModuleGridOnPhi();
233 
234  mMaxAdc = 1024; if(det==1) mMaxAdc = 4096;
235  // getGeantGeometryTable();
236 
237  switch (det){
238  case 1:
239  case 2:
240  mRadius = 225.405; // Edge of SC1 (223.5+2* 0.9525)
241  mYWidth = 11.174; // Was 11.1716 before 18-apr-2000;
242  initBEMCorBPRS();
243  break;
244  case 3:
245  mRadius = 230.705; // Was 230.467 before 18-apr-2000;
246  mYWidth = 11.2014*2;
247  initBSMDE();
248  break;
249  case 4:
250  mRadius = 232.742; // Was 232.467 before 18-apr-2000;
251  mYWidth = 22.835; // From UCLA drawing
252  initBSMDP();
253  break;
254  case 5:
255  case 6:
256  initEEMCorEPRS();
257  break;
258  case 7:
259  initESMDE();
260  break;
261  case 8:
262  initESMDP();
263  break;
264  default:
265  LOG_FATAL << Form(" StEmcGeom: Bad value of mDetector %i ", mDetector) << endm;
266  assert(0);
267  }
268  mGeom[det-1] = this; // 19-aug-04
269 }
270 // _____________________________________________________________________
271 StEmcGeom::StEmcGeom(const Int_t det, const Char_t *mode)
272 {
273  mMode=mode; mMode.ToLower();
274  if(mMode == "geant"){ // Compare without case
275  getGeantGeometryTable();
276  }
277  else mMode.Append(" : wrong option !!! ");
278 
279  if(!(mMode=="geant")){
280  LOG_WARN << Form("<W> Something wrong(%s)=> using default",mMode.Data()) << endm;
281  initGeom(det);
282  return;
283  }
284 
285  LOG_INFO << Form("<I> Used Geant Geometry for BEMC, version %5.2f ",mCalg_st->version) << endm;
286  mDetector = det;
287  mPhiOffset.Set(2); mPhiStep.Set(2); mPhiBound.Set(2);
288 
289  defineCommonConstants();
290  defineModuleGridOnPhi();
291 
292  Float_t currentDepth;
293  switch (det){
294  case 1:
295  case 2:
296  mRadius = rmin;
297  // see CSCI in geometry.g
298  currentDepth = mRadius+mCalg_st->scintthk[0]+2.*mCalg_st->abpapthk;
299  mYWidth = currentDepth*tan(mPhiStepHalf)-mCalg_st->crackwd;
300  initBEMCorBPRS();
301  break;
302  case 3:
303  mRadius = rsmdEta;
304  mYWidth = mCalg_st->smalfwdh*2.;
305  initBSMDE();
306  break;
307  case 4:
308  mRadius = rsmdPhi;
309  mYWidth = mCalg_st->smalfwdh*2.;
310  initBSMDP();
311  break;
312  case 5:
313  case 6:
314  initEEMCorEPRS();
315  break;
316  case 7:
317  initESMDE();
318  break;
319  case 8:
320  initESMDP();
321  break;
322  default:
323  LOG_ERROR << Form(" StEmcGeom: Bad value of mDetector %i ", mDetector) << endm;
324  }
325 }
326 
327 void
328 StEmcGeom::defineDefaultCommonConstants()
329 {
330  // Common information for all detectors
331  mNModule = 120;
332  mEtaMax = 0.984;
333  mEtaMin = 0.0035;
334 
335  mPhiOffset[0] = (75.-3.)/ 180. * C_PI;
336  mPhiOffset[1] = (105.+3.)/180. * C_PI;
337  mPhiStep[0] = -C_2PI /(mNModule/2);
338  mPhiStep[1] = -mPhiStep[0];
339 
340  mPhiBound[0] = 75. /180. * C_PI;
341  mPhiBound[1] = 105./180. * C_PI;
342  mPhiStepHalf = 3. * C_PI/180.;
343 }
344 
345 void
346 StEmcGeom::defineCommonConstants()
347 {
348  Float_t lW[2], smdW;
349  mNModule = 120; // mCalg_st->maxmodul;
350  mEtaMax = 0.984; // mCalg_st->etacut; ?? Why 1.0 in geometry
351  mEtaMin = 0.0035;
352 
353  mPhiStepHalf = 360. / (Float_t)mNModule; // in degree
354 
355  //
356  // 24-apr 2001 because mCalg_st->shift can change in Geant !!!
357  //
358  mPhiOffset[0] = (75.-3.)/ 180. * C_PI;
359  mPhiOffset[1] = (105.+3.)/180. * C_PI;
360 
361  mPhiStep[0] = -toRad(2.*mPhiStepHalf);
362  mPhiStep[1] = -mPhiStep[0];
363  mPhiStepHalf = toRad(mPhiStepHalf);
364 
365  rmin = mCalr_st->rmin;
366  Int_t nsuper=(Int_t)mCalg_st->nsuper;
367  Int_t nsmd=(Int_t)mCalg_st->nsmd;
368  for(Int_t i=0; i<2; i++){
369  lW[i] = mCalg_st->scintthk[i]+mCalg_st->absorthk+2.*mCalg_st->abpapthk;
370  }
371  // Radius of begin of SMD (Eta plane)
372  rsmdEta=rmin+2.*(lW[0]*nsuper+lW[1]*(nsmd-nsuper));
373  // Half width of SMD
374  smdW=2.*(mCalg_st->g10sbthk+mCalg_st->smalfthk+mCalg_st->abpapthk);
375  // Radius of end of SMD (Phi plane)
376  rsmdPhi=rsmdEta + 2.*smdW;
377 }
378 
379 void
380 StEmcGeom::defineModuleGridOnPhi()
381 {
382  //
383  // -pi <= phi < pi
384  //
385  Int_t mw,ew,sw;
386  Float_t etaw=-0.1;
387  mPhiModule.Set(mNModule);
388  Int_t im = 0;
389  for(Int_t i=0; i<mNModule/2; i++){
390  // Int_t im = 2*i/mNModule;
391  Double_t phiW = mPhiOffset[im] + mPhiStep[im]*i;
392  while(phiW >= C_PI) phiW -= C_2PI;
393  while(phiW < -C_PI) phiW += C_2PI;
394  if(phiW > (C_PI-0.0001)) phiW = -C_PI; // -pi<=phi<phi
395  mPhiModule[i] = phiW;
396  Int_t cond = getBin(mPhiModule[i], etaw, mw,ew,sw);
397  if (!cond) mPhiModule[mw-1] = phiW; // Second barrel
398  else {LOG_WARN << "<W> Something wrong in StEmcGeom::defineModuleGridOnPhi()" << endm;}
399  }
400 }
401 
402 void
403 StEmcGeom::initBEMCorBPRS()
404 {
405  if(mMode.CompareTo("geant") == 0) {
406  mNEta = (Int_t)mCalg_st->netat;
407  mNSub = (Int_t)mCalg_st->nsub;
408  }
409  else {mNEta = 20; mNSub= 2;}
410 
411  mNes = mNEta * mNSub;
412  mNRaw = mNes * mNModule;
413  mZlocal.Set(mNEta); mEta.Set(mNEta);
414  mYlocal.Set(mNSub); mPhi.Set(mNSub);
415 
416  // Eta variable ( Z direction)
417  mEtaB.Set(mNEta+1); Int_t i;
418 
419  for(i=0; i<mNEta; i++) {mEtaB[i] = 0.05*i;} mEtaB[mNEta]=mEtaMax; mEtaB[0]=mEtaMin;
420 
421  for(i=0; i< mNEta; i++){
422  mEta[i] = (mEtaB[i+1] + mEtaB[i])/2.;
423  mZlocal[i] = mRadius * sinh(mEta[i]); // z=r/tan(theta) => 1./tan(theta) = sinh(eta)
424  }
425 
426  // Phi variable ( Y direction)
427  // mYlocal, mPhi, mYB and mPhiB - have the same sign ( 29-jul-2001) !!!
428  mYlocal.Set(mNSub);
429  mYlocal[0] = -mYWidth/2.; mYlocal[1] = mYWidth/2.;
430 
431  mPhi.Set(mNSub);
432  for(Int_t i=0;i<mNSub; i++) mPhi[i] = atan2(mYlocal[i],mRadius);
433 
434  mYB.Set(mNSub+1); mPhiB.Set(mNSub+1); // 28-jul-2001
435  mYB[0] = -mYWidth;
436  mYB[1] = 0.0;
437  mYB[2] = +mYWidth;
438  for(Int_t i=0; i<mNSub+1; i++) mPhiB[i] = atan2(mYB[i],mRadius);
439 
440 }
441 // _____________________________________________________________________
442 void StEmcGeom::initBSMDE(){
443  Float_t smetawdh, seta1wdh, seta2wdh, seta12wdh; // Size for eta strips
444  if(mMode.CompareTo("geant") == 0) {
445  mNEta = (Int_t)mCalg_st->netfirst + (Int_t)mCalg_st->netsecon;
446  mNSub = 1;
447  smetawdh = mCalg_st->smetawdh;
448  seta1wdh = mCalg_st->seta1wdh;
449  seta2wdh = mCalg_st->seta2wdh;
450  seta12wdh= mCalg_st->set12wdh;
451  }
452  else {
453  mNEta = 150;
454  mNSub = 1;
455  smetawdh=0.9806;
456  seta1wdh=0.7277;
457  seta2wdh=0.9398;
458  seta12wdh=0.0406;
459  }
460 
461  mNes = mNEta * mNSub;
462  mNRaw = mNes * mNModule;
463  mZlocal.Set(mNEta); mEta.Set(mNEta);
464  mYlocal.Set(mNSub); mPhi.Set(mNSub);
465  mEtaB.Set(mNEta+1); // Eta boundaries 27-jul-2001
466  TArrayF zb(mNEta+1); // z boundaries
467 
468  // Eta variable ( Z direction)
469  Int_t i;
470  Float_t shift1, shift2;
471  shift1 = 2.*smetawdh + seta1wdh; // The center of first eta strip
472  //shift1 = (1.18-0.032/2-0.573/2)*2.54; // From drawing of SMD
473  shift2 = shift1 + (seta1wdh+seta12wdh)*2*74 + (seta1wdh+seta12wdh)
474  + (seta2wdh+seta12wdh); // The center of 76h eta strip
475  zb[0] = 2.*smetawdh;
476  for(i=0; i<mNEta; i++) {
477  if(i<mNEta/2) {
478  mZlocal[i] = shift1 + (seta1wdh+seta12wdh)*2*i;
479  zb[i+1] = zb[i] + (seta1wdh+seta12wdh)*2;
480  }
481  else {
482  mZlocal[i] = shift2 + (seta2wdh+seta12wdh)*2*(i-75);
483  zb[i+1] = zb[i] + (seta2wdh+seta12wdh)*2;
484  }
485  mEta[i] = -::log(tan(atan2(mRadius,mZlocal[i])/2.0));
486  mEtaB[i] = -::log(tan(atan2(mRadius,zb[i])/2.0));
487  }
488  mEtaB[mNEta] = -::log(tan(atan2(mRadius,zb[mNEta])/2.0));
489  // 19-aug-2004 ; request of Dmitry Arkhipkin
490  mEtaMin = mEtaB[0];
491  mEtaMax = mEtaB[mNEta];
492 
493  // Phi variable ( Y direction)
494  mYlocal.Set(mNSub); mYlocal[0] = 0.0;
495  mPhi.Set(mNSub); mPhi[0] = 0.0;
496 
497  mYB.Set(mNSub+1); mPhiB.Set(mNSub+1); // 29-jul-2009
498  mYB[0] = -mYWidth/2.;
499  mYB[1] = mYWidth/2.;
500  for(Int_t i=0; i<mNSub+1; i++) mPhiB[i] = atan2(mYB[i],mRadius);
501 }
502 // _____________________________________________________________________
503 void StEmcGeom::initBSMDP()
504 {
505  Float_t sphiwdh, sphidwdh, shift, smdgaswdh;
506 
507  if(mMode.CompareTo("geant") == 0) {
508  mNEta = (Int_t)mCalg_st->netasmdp;
509  mNSub = (Int_t)mCalg_st->nphistr;
510  sphiwdh = mCalg_st->sphiwdh;
511  sphidwdh = mCalg_st->sphidwdh;
512  smdgaswdh= mCalg_st->smgaswdh;
513 
514  }
515  else{
516  mNEta = 10;
517  mNSub = 15;
518  sphiwdh = 0.668; // half width for phi strips
519  sphidwdh = 0.07874; // half distance between strips in phi
520  smdgaswdh = 0.295; // smd gas box volume half width
521  }
522  shift = - mYWidth/2. + smdgaswdh + sphiwdh; // The position of center first phi strip
523 
524  mNes = mNEta * mNSub;
525  mNRaw = mNes * mNModule;
526  mZlocal.Set(mNEta); mEta.Set(mNEta);
527  mYlocal.Set(mNSub); mPhi.Set(mNSub);
528 
529  // Eta variable ( Z direction)
530  mEtaB.Set(mNEta+1); Int_t i;
531 
532  for(i=0; i<mNEta; i++) {mEtaB[i] = 0.1*i;}
533  mEtaB[mNEta]=mEtaMax;
534 
535  for(i=0; i< mNEta; i++){
536  mEta[i] = (mEtaB[i+1] + mEtaB[i])/2.;
537  mZlocal[i] = mRadius * sinh(mEta[i]); // z=r/tan(theta) => 1./tan(theta) = sinh(eta)
538  }
539 
540  // Phi variable ( Y direction)
541 
542  mYlocal.Set(mNSub); mPhi.Set(mNSub);
543  mYB.Set(mNSub+1); mPhiB.Set(mNSub+1); // 27-jul-2001
544  mYB[0] = -mYWidth/2. + smdgaswdh;
545 
546  if(mMode.CompareTo("geant") == 0){ // For odd numbers ( default 15) ?? must check
547  Int_t n2=mNSub/2;
548  mYlocal[n2] = 0.0;
549  for(i=n2+1; i<mNSub; i++){
550  mYlocal[i] = (sphiwdh+sphidwdh)*2*(i-n2);
551  mYlocal[mNSub-i-1] = -mYlocal[i];
552  }
553  for(i=0; i<mNSub; i++){
554  mPhi[i] = atan2(mYlocal[i], mRadius);
555  }
556  }
557  else{
558  for(i=0; i<mNSub; i++){
559  mYlocal[i] = shift + (sphiwdh+sphidwdh)*2*i;
560  mPhi[i] = atan2(mYlocal[i], mRadius);
561  if(i==0 || i==(mNSub-1)) mYB[i+1] = mYB[i] + sphiwdh*2. + sphidwdh;
562  else mYB[i+1] = mYB[i] + (sphiwdh + sphidwdh)*2.;
563  mPhiB[i] = atan2(mYB[i], mRadius);
564  }
565  mPhiB[mNSub] = atan2(mYB[mNSub], mRadius);
566  }
567 }
568 // _____________________________________________________________________
569 Int_t StEmcGeom::getVolIdBemc(const Int_t ivid, Int_t &module,Int_t &eta,Int_t &sub, Int_t &detector)
570 {
571  // Transition from Geant Volume Id to usual for BEMC and BPRS
572  // See emc/util/volid_bemc.F
573 
574  static Int_t emcIvid[5]={10000000,100000,100,10,1};
575  Int_t emcChid[5], i, ividw, rl, phi, dep;
576  // assert(mCalg_st); // 24-apr
577  if(mCalg_st == 0) getGeantGeometryTable();
578 
579  ividw = ivid;
580  for(i=0; i<5; i++){
581  emcChid[i] = ividw/emcIvid[i];
582  ividw = ividw%emcIvid[i];
583  }
584  if(ividw == 0){
585  rl = emcChid[0]; // right/left: =1 for Z>0, and =2 for Z<0
586  eta = emcChid[1]; // pseudorapidity bin number [1,20]
587  phi = emcChid[2]; // module phi [1,120]
588  sub = emcChid[3]; // d(eta)=0.1 tower number [1,2]
589  dep = emcChid[4]; // depth section [1,2];
590  switch (dep) {// see ems_interface2.F
591  case 1:
592  detector = BPRS; break;
593  case 2:
594  detector = BEMC; break;
595  default:
596  LOG_WARN << Form("<W> StEmcGeom::getVolIdBemc => wrong value of dep %i ",dep) << endm;
597  }
598  if (rl==1) {
599  // cout<<" Phi 1 "<<phi<<endl;
600  //phi += Int_t((mCalg_st->shift[0]-75.)/6.);
601  phi += Int_t((75.-mCalg_st->shift[0])/6.);
602  while (phi<=0) phi+=60;
603  while (phi>=61) phi-=60;
604  module=phi;
605  // cout<<" Phi 2 "<<phi<<endl;
606  }
607  else if(rl==2) {
608  // phi += Int_t((shift[1]-105.)/6.);
609  phi += Int_t((105.-mCalg_st->shift[1])/6.);
610  while (phi<=0) phi+=60;
611  while (phi>=61) phi-=60;
612  module=phi+60;
613  sub =(sub+1)%2+1;
614  }
615  else{
616  LOG_ERROR << Form("<E> getVolIdBemc -- error decoding BEMC Geant volume Id %i; rl=%i", ivid, rl) << endm;
617  return 1;
618  }
619  }
620  else {
621  LOG_ERROR << Form("<E> getVolIdBemc -- error decoding BEMC Geant volume Id %i=>%i", ivid, ividw) << endm;
622  return 1;
623  }
624  // printf(" vid %i m %3i eta %3i sub %3i dep %3i \n",
625  // ivid,module,eta,sub,dep);
626  return 0;
627 }
628 // _____________________________________________________________________
629 Int_t StEmcGeom::getVolIdBsmd(const Int_t ivid, Int_t &module,Int_t &eta,Int_t &sub, Int_t &detector)
630 {
631  // Transition from Geant Volume Id to usual for BSMDE and BSMDP
632  // See emc/util/volid_bsmd.F
633  static Int_t smdIvid[5]={100000000,1000000,1000,100,1}; //matched with AGI&G2T
634  Int_t smdChid[5], i, ividw, rl, phi, t, strip;
635  // assert(mCalg_st); // 24-apr
636  if(mCalg_st == 0) getGeantGeometryTable();
637 
638  ividw = ivid;
639  for(i=0; i<5; i++){
640  smdChid[i] = ividw/smdIvid[i];
641  ividw = ividw%smdIvid[i];
642  }
643  if(ividw == 0){
644  rl = smdChid[0]; // right/left: =1 for Z>0, and =2 for Z<0
645  eta = smdChid[1]; // pseudorapidity bin number [-10,10]
646  phi = smdChid[2]; // module phi [1,60]
647  t = smdChid[3]; // SMD type 1->3
648  strip = smdChid[4]; // strip number 1-75(type 1,2) 1-15(type 3)
649  if (rl==1) {
650  // phi += Int_t((mCalg_st->shift[0]-75.)/6.);
651  phi += Int_t((75. - mCalg_st->shift[0])/6.);
652  while (phi<=0) phi+=60;
653  while (phi>=61) phi-=60;
654  module=phi;
655  }
656  else if(rl==2) {
657  // phi += Int_t((mCalg_st->shift[1]-105.)/6.);
658  phi += Int_t((105. - mCalg_st->shift[1])/6.);
659  while (phi<=0) phi+=60;
660  while (phi>=61) phi-=60;
661  module=phi+60;
662  }
663  else{
664  LOG_ERROR << Form("<E> getVolIdBsmd -- error decoding BSMD Geant volume Id %i; rl=%i", ivid, rl) << endm;
665  return 1;
666  }
667  if (t==1){
668  detector = BSMDE;
669  eta = strip;
670  sub = 1;
671  }
672  else if(t==2){
673  detector = BSMDE;
674  eta = strip + 75;
675  sub = 1;
676  }
677  else if(t==3){
678  detector = BSMDP;
679  eta = abs(eta);
680 
681  // SMDP West: sub = 16 - strip
682  // SMDP East: sub = strip
683  switch (rl) {
684  case 1:
685  sub = 16 - strip;
686  break;
687  case 2:
688  sub = strip;
689  break;
690  }
691  }
692  else {
693  LOG_ERROR << Form("<E> getVolIdBsmd: Type mismatch %i ",t) << endm;
694  return 1;
695  }
696  }
697  else {
698  LOG_ERROR << Form("<E> getVolIdBsmd -- error decoding BSMD Geant volume Id %i=>%i", ivid, ividw) << endm;
699  return 1;
700  }
701  // printf(" vid %i m %3i eta %3i sub %3i type %3i \n",
702  //ivid,module,eta,sub,type);
703  return 0;
704 }
705 // _____________________________________________________________________
706 Int_t StEmcGeom::getVolId(const Int_t ivid, Int_t &module,Int_t &eta,Int_t &sub, Int_t &det)
707 {
708  if (mDetector==1||mDetector==2) return getVolIdBemc(ivid,module,eta,sub,det);
709  else if(mDetector==3||mDetector==4) return getVolIdBsmd(ivid,module,eta,sub,det);
710  else {
711  LOG_ERROR << Form("<E> getVolId -- wrong detectot number %i ",mDetector) << endm;
712  return 0;
713  }
714 }
715 // _____________________________________________________________________
716 void StEmcGeom::initEEMCorEPRS() //wrong need to update
717 {
718  mNModule = 24;
719  mNEta = 12;
720  mNSub = 5;
721  mNes = mNEta * mNSub;
722  mNRaw = mNes * mNModule;
723  mRadius = 225.405; // Edge of SC1 (223.5+2* 0.9525)
724  mYWidth = 11.1716;
725  mZlocal.Set(mNEta); mEta.Set(mNEta);
726  mYlocal.Set(mNSub); mPhi.Set(mNSub);
727 
728  // Eta variable ( Z direction)
729  mEtaB.Set(mNEta+1); Int_t i;
730 
731  for(i=0; i<mNEta; i++) {mEtaB[i] = 0.05*i;} mEtaB[mNEta]=0.99;
732 
733  for(i=0; i< mNEta; i++){
734  mEta[i] = (mEtaB[i+1] + mEtaB[i])/2.;
735  mZlocal[i] = mRadius * sinh(mEta[i]); // z=r/tan(theta) => 1./tan(theta) = sinh(eta)
736  }
737 
738  // Phi variable ( Y direction)
739  mYlocal.Set(mNSub);
740  mYlocal[0] = mYWidth/2; mYlocal[1] = - mYlocal[0];
741 
742  mPhi.Set(mNSub);
743  mPhi[0] = atan2(mYWidth/2,mRadius); mPhi[1] = -mPhi[0];
744 
745  // cout<<" Default constructor for StEmcGeom (Ver. 1.00 # 20-Jun-1999 )"<<endl;
746 }
747 // _____________________________________________________________________
748 void StEmcGeom::initESMDE(){ //wrong need to update
749  mNModule = 24;
750  mNEta = 200;
751  mNSub = 200;
752  mNes = mNEta * mNSub;
753  mNRaw = mNes * mNModule;
754  mRadius = 230.467; // See find_pos_ems.F or Geant Geometry
755  mYWidth = 11.2014*2;
756  mZlocal.Set(mNEta); mEta.Set(mNEta);
757  mYlocal.Set(mNSub); mPhi.Set(mNSub);
758 
759  // Eta variable ( Z direction)
760  Int_t i;
761  Float_t smetawdh=0.9806;
762  Float_t seta1wdh=0.7277, seta2wdh=0.9398, seta12wdh=0.0406; // Size for eta strips
763  Float_t shift1, shift2;
764  shift1 = 2.*smetawdh + seta1wdh; // The center of first eta strip
765  //shift1 = (1.18-0.032/2-0.573/2)*2.54; // From drawing of SMD
766  shift2 = shift1 + (seta1wdh+seta12wdh)*2*74 + (seta1wdh+seta12wdh)
767  + (seta2wdh+seta12wdh); // The center of 76h eta strip
768 
769  for(i=0; i<mNEta; i++) {
770  if(i<mNEta/2) mZlocal[i] = shift1 + (seta1wdh+seta12wdh)*2*i;
771  else mZlocal[i] = shift2 + (seta2wdh+seta12wdh)*2*(i-75);
772  mEta[i] = -::log(tan(atan2(mRadius,mZlocal[i])/2.0));
773  }
774 
775  // Phi variable ( Y direction)
776  mYlocal.Set(mNSub); mYlocal[0] = 0.0;
777 
778  mPhi.Set(mNSub); mPhi[0] = 0.0;
779 
780  // cout<<" (BSMDE) shift1 "<<shift1<<endl;
781  //cout<<" (BSMDE) shift2 "<<shift2<<endl;
782 }
783 // _____________________________________________________________________
784 void StEmcGeom::initESMDP() //wrong Need to update
785 {
786  mNModule = 24;
787  mNEta = 200;
788  mNSub = 200;
789  mNes = mNEta * mNSub;
790  mNRaw = mNes * mNModule;
791  mRadius = 232.467; // See find_pos_ems.F or Geant Geometry
792  mYWidth = 22.835;
793  mZlocal.Set(mNEta); mEta.Set(mNEta);
794  mYlocal.Set(mNSub); mPhi.Set(mNSub);
795 
796  // Eta variable ( Z direction)
797  mEtaB.Set(mNEta+1); Int_t i;
798 
799  for(i=0; i<mNEta; i++) {mEtaB[i] = 0.1*i;}
800  mEtaB[mNEta]=0.99;
801 
802  for(i=0; i< mNEta; i++){
803  mEta[i] = (mEtaB[i+1] + mEtaB[i])/2.;
804  mZlocal[i] = mRadius * sinh(mEta[i]); // z=r/tan(theta) => 1./tan(theta) = sinh(eta)
805  }
806 
807  // Phi variable ( Y direction)
808 
809  mYlocal.Set(mNSub); mPhi.Set(mNSub);
810 
811  Float_t sphiwdh = 0.668; // half width for phi strips
812  Float_t sphidwdh = 0.07874; // half distance between strips in phi
813  Float_t shift = mYWidth/2. - 0.295 - sphiwdh; // The position of center first phi strip
814 
815  for(i=0; i<mNSub; i++){
816  mYlocal[i] = shift - (sphiwdh+sphidwdh)*2*i;
817  mPhi[i] = atan2(mYlocal[i], mRadius);
818  }
819 }
820 // _____________________________________________________________________
821 void StEmcGeom::printGeom() const
822 {
823  cout<<" mMode "<<mMode.Data()<<endl;
824  cout<<" mDetector "<<mDetector<<endl;
825  cout<<" mNModule "<<mNModule<<endl;
826  cout<<" mNEta "<<mNEta<<endl;
827  cout<<" mNSub "<<mNSub<<endl;
828  cout<<" mNes "<<mNes<<endl;
829  cout<<" mNRaw "<<mNRaw<<endl;
830  cout<<" mRadius "<<mRadius<<endl;
831  cout<<" mYWidth "<<mYWidth<<endl;
832  cout<<" mEtaMin "<<mEtaMin<<endl;
833  cout<<" mEtaMax "<<mEtaMax<<endl;
834  cout<<" mPhiOffset "<<mPhiOffset[0]<<"("<<toDeg(mPhiOffset[0])<<") "
835  <<mPhiOffset[1]<<"("<<toDeg(mPhiOffset[0])<<")"<<endl;
836  cout<<" mPhiStep "<<mPhiStep[0]<<"("<<toDeg(mPhiStep[0])<<") "
837  <<mPhiStep[1]<<"("<<toDeg(mPhiStep[1])<<")"<<endl;
838  cout<<" Max ADC "<<mMaxAdc<<endl;
839 
840  Int_t i;
841  cout<<"\n Z grid and Eta grid "<<endl;
842  cout<<" mEtaB[0] "<<mEtaB[0]<<endl;
843  for(i=0; i<mNEta; i++){
844  printf(" i %3i Zl %7.3f Eta %8.5f mEtaB %7.5f\n"
845  , i, mZlocal[i], mEta[i], mEtaB[i+1]);
846  }
847 
848  cout<<"\n Y grid and Phi grid "<<endl;
849  // cout<<"mYB[0] "<<mYB[0]<<" mPhiB[0] "<<mPhiB[0]<<endl;
850  printf(" mYB %7.3f mPhiB %9.5f \n", mYB[0], mPhiB[0]);
851  for(i=0; i<mNSub; i++){
852  printf(" i %2i Yl %7.3f Phi %9.5f ", i, mYlocal[i], mPhi[i]);
853  printf(" mYB %7.3f mPhiB %9.5f \n", mYB[i+1], mPhiB[i+1]);
854  }
855  cout<<"\n Phi grid of center of modules in STAR system\n";
856  cout<<" =============================================\n";
857  Int_t mw,ew,sw;
858  Float_t etaw=-0.1;
859  for(i=0; i<mNModule/2; i++){
860  printf(" %3i phi %10.7f (%6.1f)", // First barrel
861  i+1,mPhiModule[i],mPhiModule[i]*C_DEG_PER_RAD);
862  Int_t cond = getBin(mPhiModule[i], etaw, mw,ew,sw);
863  if(!cond) {
864  printf(" => %3i phi %10.7f (%6.1f)", // Second barrel
865  mw,mPhiModule[mw-1],mPhiModule[mw-1]*C_DEG_PER_RAD);
866  }
867  printf("\n");
868  }
869  cout<<"\n == "<<endl;
870  for(Int_t i=0;i<4; i++){
871  cout<<" Pointer for det = "<<i+1<<" -> "<<mGeom[i]<<endl;
872  }
873 }
874 // _____________________________________________________________________
875 void StEmcGeom::compare(const StEmcGeom &g, Bool_t key=kFALSE) const
876 {
877  Float_t err;
878  Int_t i;
879  if(mDetector==g.Detector()) {
880  printf(" mMode %10s | %10s \n", mMode.Data(), g.Mode()->Data());
881  printf("---------------------------------------------------\n");
882  if(mNModule != g.NModule() || key)
883  printf(" mNModule %10i | %10i\n",mNModule,g.NModule());
884  if(mNEta != g.NEta() || key)
885  printf(" mNEta %10i | %10i\n",mNEta,g.NEta());
886  if(mNSub != g.NSub() || key)
887  printf(" mNSub %10i | %10i\n",mNSub,g.NSub());
888  if(mNes != g.Nes() || key)
889  printf(" mNes %10i | %10i\n",mNes,g.Nes());
890  if(mNRaw != g.NRaw() || key)
891  printf(" mNRaw %10i | %10i\n",mNRaw,g.NRaw());
892 
893  err=relativeError(mRadius,g.Radius());
894  if(err>perr || key){
895  printf(" mRadius %10.3f | %10.3f",mRadius,g.Radius());
896  printError(err);
897  }
898 
899  err=relativeError(mYWidth,g.YWidth());
900  if(err>perr || key) {
901  printf(" mYWidth %10.3f | %10.3f",mYWidth,g.YWidth());
902  printError(err);
903  }
904 
905  err=relativeError(mEtaMax,g.EtaMax());
906  if(err>perr || key) {
907  printf(" mEtaMax %10.3f | %10.3f",mEtaMax,g.EtaMax());
908  printError(err);
909  }
910 
911  for(i=0; i<2; i++){
912  err=relativeError(mPhiOffset[i],g.PhiOffset()[i]);
913  if(err>perr || key){
914  printf(" mPhiOffset[%1i] %7.3f | %10.3f",i,mPhiOffset[i],g.PhiOffset()[i]);
915  printError(err);
916  }
917  }
918  for(i=0; i<2; i++){
919  err=relativeError(mPhiStep[i],g.PhiStep()[i]);
920  if(err>perr || key){
921  printf(" mPhiStep[%1i] %7.3f | %10.3f",i,mPhiStep[i],g.PhiStep()[i]);
922  printError(err);
923  }
924  }
925  printf("\n Phi grid for center of module in STAR system mNModule=%i\n",mNModule);
926  for(i=0; i<mNModule; i++){
927  err=relativeError(mPhiModule[i],g.PhiModule()[i]);
928  if(err>perr || key){
929  printf(" %3i phi %7.2f | %10.2f",i,toDeg(mPhiModule[i])
930  ,toDeg(g.PhiModule()[i]));
931  printError(err);
932  }
933  }
934 
935  printf("\n Z grid and Eta grid => mNEta=%i\n",mNEta);
936  for(i=0; i<mNEta; i++){
937  err=relativeError(mZlocal[i], g.Zlocal()[i]);
938  if(err>perr || key){
939  printf(" %3i Zl %7.2f | %10.2f || ",i, mZlocal[i], g.Zlocal()[i]);
940  printf("Eta %7.3f | %7.3f",mEta[i], g.Eta()[i]);
941  printError(err);
942  }
943  }
944 
945  printf("\n Y grid and Phi grid => mNSub=%i\n",mNSub);
946  for(i=0; i<mNSub; i++){
947  err=relativeError(mYlocal[i], g.Ylocal()[i]);
948  if(err>perr || key){
949  printf("%3i Yl %7.3f | %10.3f || ",i, mYlocal[i], g.Ylocal()[i]);
950  printf("Phi %9.6f | %9.6f",mPhi[i], g.Phi()[i]);
951  printError(err);
952  }
953  }
954  }
955  else printf("<W> You compare geometry for different detector %i != %i \n",
956  mDetector, g.mDetector);
957 }
958 // _____________________________________________________________________
959 Float_t StEmcGeom::relativeError(Float_t a, Float_t b) const
960 {
961  Float_t sum = fabs(a) + fabs(b), perr;
962  if(sum == 0.0) return 0.0; // Both zero
963  else {
964  perr = 200.*fabs(a-b)/sum;
965  return perr;
966  }
967 }
968 
969 void
970 StEmcGeom::printError(Float_t err) const
971 {
972  if(err>perr) {LOG_INFO << Form(" | perr=%6.3f%% ",err) << endm;}
973  else {LOG_INFO << " " << endm; }
974 }
975 
976 void
977 StEmcGeom::getGeantGeometryTable()
978 {
979 // 24-apr-2000 for MDC4
980 // Will be work if BFC has name "bfc" !!! Be carefull
981  mGeantGeom = NULL;
982  mCalg = 0;
983  mCalr = 0;
984  mCalg_st = 0;
985  mCalr_st = 0;
986  mChain = StMaker::GetChain();
987 
988  if(mChain) mGeantGeom = mChain->GetDataSet(".const/geom");
989 
990  TString line;
991 
992  if(mGeantGeom) {
993  mCalg = (St_calb_calg *) mGeantGeom->Find("calb_calg");
994  if(mCalg && mCalg->GetNRows()) {
995  mCalg_st = mCalg->GetTable();
996  printf("calb_calr get from Geant::");
997  for(Int_t i=0;i<2;i++) printf(" Barrel %i Angle shift %6.0f ", i+1, mCalg_st->shift[i]);
998  printf("\n");
999  mCalr = (St_calb_calr *) mGeantGeom->Find("calb_calr");
1000  if(mCalr) mCalr_st = mCalr->GetTable(); // BARREL EMC RADIUSES
1001  }
1002  }
1003  if(!mCalg_st || !mCalr_st) {
1004  mMode.Append(" : No table");
1005  LOG_INFO << Form("StEmcGeom::getGeantGeometryTable() could not find geom") << endm;
1006  LOG_INFO << Form("StEmcGeom::getGeantGeometryTable() create own calb_calg/r") << endm;
1007  mCalg = new St_calb_calg("calg", 1);
1008  mCalr = new St_calb_calr("calr", 1);
1009  mCalg_st = mCalg->GetTable();
1010  mCalr_st = mCalr->GetTable();
1011  // For year2001 configuration only
1012  //mCalg_st[0].shift[0]=21.0;
1013  //mCalg_st[0].shift[1]=0.0;
1014  // For year2003 configuration only
1015  mCalg_st[0].shift[0]=75.0;
1016  mCalg_st[0].shift[1]=105.0;
1017  }
1018 }
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
Definition: StEmcGeom.h:321
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362