CMS 3D CMS Logo

HcalTB02HcalNumberingScheme.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTestBeam
4 // Class : HcalTB02HcalNumberingScheme
5 //
6 // Implementation:
7 // Numbering scheme for hadron calorimeter in 2002 test beam
8 //
9 // Original Author:
10 // Created: Sun 21 10:14:34 CEST 2006
11 //
12 
13 // system include files
14 
15 // user include files
18 
19 #include "G4SystemOfUnits.hh"
20 
21 using namespace std;
22 
23 //
24 // constructors and destructor
25 //
26 
28  HcalTB02NumberingScheme(), phiScale(1000000), etaScale(10000) {
29  edm::LogInfo("HcalTBSim") << "Creating HcalTB02HcalNumberingScheme";
30 }
31 
33  edm::LogInfo("HcalTBSim") << "Deleting HcalTB02HcalNumberingScheme";
34 }
35 
36 //
37 // member functions
38 //
39 
40 int HcalTB02HcalNumberingScheme::getUnitID(const G4Step* aStep) const {
41 
42  int scintID = 0;
43 
44  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
45  const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
46  float hx = hitPoint.x();
47  float hy = hitPoint.y();
48  float hz = hitPoint.z();
49  float hr = std::sqrt( pow(hx,2)+pow(hy,2) );
50 
51  // Check if hit happened in first HO layer or second.
52 
53  if ( (hr > 3.*m) && (hr < 3.830*m) ) return scintID=17;
54  if (hr > 3.830*m) return scintID=18;
55 
56  // Compute the scintID in the HB.
57 
58  float hR = hitPoint.mag();//sqrt( pow(hx,2)+pow(hy,2)+pow(hz,2) );
59  float htheta = (hR == 0. ? 0. : acos(max(min(hz/hR,float(1.)),float(-1.))));
60  float hsintheta = sin(htheta);
61  float hphi = (hR*hsintheta == 0. ? 0. :acos( max(min(hx/(hR*hsintheta),float(1.)),float(-1.)) ) );
62  float heta = ( fabs(hsintheta) == 1.? 0. : -log(fabs(tan(htheta/2.))) );
63  int eta = int(heta/0.087);
64  int phi = int(hphi/(5.*degree));
65 
66  G4VPhysicalVolume* thePV = preStepPoint->GetPhysicalVolume();
67  int ilayer = ((thePV->GetCopyNo())/10)%100;
68  LogDebug("HcalTBSim") << "HcalTB02HcalNumberingScheme:: Layer "
69  << thePV->GetName() << " found at phi = " << phi
70  << " eta = " << eta << " lay = " << thePV->GetCopyNo()
71  << " " << ilayer;
72 
73  scintID = phiScale*phi + etaScale*eta + ilayer;
74  if (hy<0.) scintID = -scintID;
75 
76  return scintID;
77 }
78 
80 
81  sID = abs(sID);
82  int layerID = sID;
83  if ( (layerID != 17) && (layerID != 18) )
84  layerID = sID - int(float(sID)/float(etaScale))*etaScale;
85 
86  LogDebug("HcalTBSim") << "HcalTB02HcalNumberingScheme:: scintID " << sID
87  << " layer = " << layerID;
88  return layerID;
89 }
90 
92 
93  float IDsign = 1.;
94  if (sID<0) IDsign = -1;
95  sID = abs(sID);
96  int phiID = int(float(sID)/float(phiScale));
97  LogDebug("HcalTBSim") << "HcalTB02HcalNumberingScheme:: scintID " << sID
98  << " phi = " << phiID;
99  if (IDsign>0) {
100  phiID += 4;
101  } else {
102  phiID = abs(phiID-3);
103  }
104  return phiID;
105 }
106 
108 
109  sID = abs(sID);
110  int aux = sID - int(float(sID)/float(phiScale))*phiScale;
111  int etaID = int(float(aux)/float(etaScale));
112 
113  LogDebug("HcalTBSim") << "HcalTB02HcalNumberingScheme:: scintID " << sID
114  << " eta = " << etaID;
115  return etaID;
116 
117 }
#define LogDebug(id)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
susybsm::HSCParticleRef hr
Definition: classes.h:26
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
int getUnitID(const G4Step *aStep) const override
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40