CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HFShowerFibreBundle.cc
Go to the documentation of this file.
1 // File: HFShowerFibreBundle.cc
3 // Description: Hits in the fibre bundles
5 
10 
12 
13 #include "G4NavigationHistory.hh"
14 #include "G4VPhysicalVolume.hh"
15 #include "G4Step.hh"
16 #include "G4Track.hh"
17 #include "CLHEP/Units/GlobalPhysicalConstants.h"
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 
20 //#define DebugLog
21 
23  const DDCompactView & cpv,
24  edm::ParameterSet const & p) {
25 
26  edm::ParameterSet m_HF1 = p.getParameter<edm::ParameterSet>("HFShowerStraightBundle");
27  facTube = m_HF1.getParameter<double>("FactorBundle");
28  cherenkov1 = new HFCherenkov(m_HF1);
29  edm::ParameterSet m_HF2 = p.getParameter<edm::ParameterSet>("HFShowerConicalBundle");
30  facCone = m_HF2.getParameter<double>("FactorBundle");
31  cherenkov2 = new HFCherenkov(m_HF2);
32  edm::LogInfo("HFShower") << "HFShowerFibreBundle intialized with factors: "
33  << facTube << " for the straight portion and "
34  << facCone << " for the curved portion";
35 
36  G4String attribute = "ReadOutName";
37  G4String value = name;
38  DDSpecificsFilter filter0;
39  DDValue ddv0(attribute,value,0);
41  DDFilteredView fv0(cpv);
42  fv0.addFilter(filter0);
43  if (fv0.firstChild()) {
45 
46  //Special Geometry parameters
47  rTable = getDDDArray("rTable",sv0);
48  edm::LogInfo("HFShower") << "HFShowerFibreBundle: " << rTable.size()
49  << " rTable (cm)";
50  for (unsigned int ig=0; ig<rTable.size(); ig++)
51  edm::LogInfo("HFShower") << "HFShowerFibreBundle: rTable[" << ig
52  << "] = " << rTable[ig]/cm << " cm";
53  } else {
54  edm::LogError("HFShower") << "HFShowerFibreBundle: cannot get filtered "
55  << " view for " << attribute << " matching "
56  << value;
57  throw cms::Exception("Unknown", "HFShowerFibreBundle")
58  << "cannot match " << attribute << " to " << name <<"\n";
59  }
60 
61  attribute = "Volume";
62  value = "HFPMT";
63  DDSpecificsFilter filter1;
64  DDValue ddv1(attribute,value,0);
66  DDFilteredView fv1(cpv);
67  fv1.addFilter(filter1);
68  if (fv1.firstChild()) {
70  std::vector<double> neta;
71  neta = getDDDArray("indexPMTR",sv1);
72  for (unsigned int ii=0; ii<neta.size(); ii++) {
73  int index = static_cast<int>(neta[ii]);
74  int ir=-1, ifib=-1;
75  if (index >= 0) {
76  ir = index/10; ifib = index%10;
77  }
78  pmtR1.push_back(ir);
79  pmtFib1.push_back(ifib);
80  }
81  neta = getDDDArray("indexPMTL",sv1);
82  for (unsigned int ii=0; ii<neta.size(); ii++) {
83  int index = static_cast<int>(neta[ii]);
84  int ir=-1, ifib=-1;
85  if (index >= 0) {
86  ir = index/10; ifib = index%10;
87  }
88  pmtR2.push_back(ir);
89  pmtFib2.push_back(ifib);
90  }
91  edm::LogInfo("HFShower") << "HFShowerFibreBundle: gets the Index matches "
92  << "for " << neta.size() << " PMTs";
93  for (unsigned int ii=0; ii<neta.size(); ii++)
94  edm::LogInfo("HFShower") << "HFShowerFibreBundle: rIndexR[" << ii
95  << "] = " << pmtR1[ii] << " fibreR[" << ii
96  << "] = " << pmtFib1[ii] << " rIndexL[" << ii
97  << "] = " << pmtR2[ii] << " fibreL[" << ii
98  << "] = " << pmtFib2[ii];
99  } else {
100  edm::LogWarning("HFShower") << "HFShowerFibreBundle: cannot get filtered "
101  << " view for " << attribute << " matching "
102  << value;
103  }
104 
105 }
106 
108  delete cherenkov1;
109  delete cherenkov2;
110 }
111 
112 double HFShowerFibreBundle::getHits(G4Step * aStep, bool type) {
113 
114  indexR = indexF = -1;
115 
116  G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
117  const G4VTouchable* touch = preStepPoint->GetTouchable();
118  int boxNo = touch->GetReplicaNumber(1);
119  int pmtNo = touch->GetReplicaNumber(0);
120  if (boxNo <= 1) {
121  indexR = pmtR1[pmtNo-1];
122  indexF = pmtFib1[pmtNo-1];
123  } else {
124  indexR = pmtR2[pmtNo-1];
125  indexF = pmtFib2[pmtNo-1];
126  }
127 
128 #ifdef DebugLog
129  double edep = aStep->GetTotalEnergyDeposit();
130  LogDebug("HFShower") << "HFShowerFibreBundle: Box " << boxNo << " PMT "
131  << pmtNo << " Mapped Indices " << indexR << ", "
132  << indexF << " Edeposit " << edep/MeV << " MeV";
133 #endif
134 
135  double photons = 0;
136  if (indexR >= 0 && indexF > 0) {
137  G4Track *aTrack = aStep->GetTrack();
138  G4ParticleDefinition *particleDef = aTrack->GetDefinition();
139  double stepl = aStep->GetStepLength();
140  double beta = preStepPoint->GetBeta();
141  G4ThreeVector pDir = aTrack->GetDynamicParticle()->GetMomentumDirection();
142  G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->
143  GetTopTransform().TransformAxis(pDir);
144  if (type) {
145  photons = facCone*cherenkov2->computeNPEinPMT(particleDef, beta,
146  localMom.x(), localMom.y(),
147  localMom.z(), stepl);
148  } else {
149  photons = facTube*cherenkov1->computeNPEinPMT(particleDef, beta,
150  localMom.x(), localMom.y(),
151  localMom.z(), stepl);
152  }
153 #ifdef DebugLog
154  LogDebug("HFShower") << "HFShowerFibreBundle::getHits: for particle "
155  << particleDef->GetParticleName() << " Step " << stepl
156  << " Beta " << beta << " Direction " << pDir
157  << " Local " << localMom << " p.e. " << photons;
158 #endif
159 
160  }
161  return photons;
162 }
163 
165 
166  double r = 0.;
167  if (indexR >= 0 && indexR+1 < (int)(rTable.size()))
168  r = 0.5*(rTable[indexR]+rTable[indexR+1]);
169 #ifdef DebugLog
170  else
171  LogDebug("HFShower") << "HFShowerFibreBundle::getRadius: R " << indexR
172  << " F " << indexF;
173 #endif
174  if (indexF == 2) r =-r;
175 #ifdef DebugLog
176  LogDebug("HFShower") << "HFShowerFibreBundle: Radius (" << indexR << "/"
177  << indexF << ") " << r;
178 #endif
179  return r;
180 }
181 
182 std::vector<double> HFShowerFibreBundle::getDDDArray(const std::string & str,
183  const DDsvalues_type& sv){
184 
185 #ifdef DebugLog
186  LogDebug("HFShower") << "HFShowerFibreBundle:getDDDArray called for " << str;
187 #endif
188  DDValue value(str);
189  if (DDfetch(&sv,value)) {
190 #ifdef DebugLog
191  LogDebug("HFShower") << value;
192 #endif
193  const std::vector<double> & fvec = value.doubles();
194  int nval = fvec.size();
195  if (nval < 2) {
196  edm::LogError("HFShower") << "HFShowerFibreBundle: # of " << str
197  << " bins " << nval << " < 2 ==> illegal";
198  throw cms::Exception("Unknown", "HFShowerFibreBundle")
199  << "nval < 2 for array " << str << "\n";
200  }
201 
202  return fvec;
203  } else {
204  edm::LogError("HFShower") <<"HFShowerFibreBundle: cannot get array " <<str;
205  throw cms::Exception("Unknown", "HFShowerFibreBundle")
206  << "cannot get array " << str << "\n";
207  }
208 }
#define LogDebug(id)
const double beta
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:134
void addFilter(const DDFilter &, log_op op=AND)
std::vector< int > pmtFib1
std::vector< double > rTable
double getHits(G4Step *aStep, bool type)
int ii
Definition: cuy.py:588
type of data representation of DDCompactView
Definition: DDCompactView.h:77
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:102
int computeNPEinPMT(G4ParticleDefinition *pDef, double pBeta, double u, double v, double w, double step_length)
Definition: HFCherenkov.cc:226
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
std::vector< int > pmtR1
HFShowerFibreBundle(std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p)
DDsvalues_type mergedSpecifics() const
bool firstChild()
set the current node to the first child ...
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:285
std::vector< int > pmtR2
std::vector< int > pmtFib2
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37