CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastHFFibre.cc
Go to the documentation of this file.
1 // File: FastHFFibre.cc
3 // Description: Loads the table for attenuation length and calculates it
5 
11 
12 #include "CLHEP/Units/GlobalSystemOfUnits.h"
13 #include "CLHEP/Units/GlobalPhysicalConstants.h"
14 #include <iostream>
15 
16 //#define DebugLog
17 
18 FastHFFibre::FastHFFibre(std::string & name, const DDCompactView & cpv, double cLight) {
19 
20  cFibre = cLight;
21  edm::LogInfo("FastCalorimetry") << "HFFibre:: Speed of light in fibre " << cFibre
22  << " m/ns";
23 
24  std::string attribute = "Volume";
25  std::string value = "HF";
26  DDSpecificsFilter filter1;
27  DDValue ddv1(attribute,value,0);
29  DDFilteredView fv1(cpv);
30  fv1.addFilter(filter1);
31  bool dodet = fv1.firstChild();
32 
33  if (dodet) {
35 
36  // Attenuation length
37  nBinAtt = -1;
38  attL = getDDDArray("attl",sv,nBinAtt);
39  edm::LogInfo("FastCalorimetry") << "HFFibre: " << nBinAtt << " attL ";
40  for (int it=0; it<nBinAtt; it++)
41  edm::LogInfo("FastCalorimetry") << "HFFibre: attL[" << it << "] = "
42  << attL[it]*cm << "(1/cm)";
43 
44  // Limits on Lambda
45  int nb = 2;
46  std::vector<double> nvec = getDDDArray("lambLim",sv,nb);
47  lambLim[0] = static_cast<int>(nvec[0]);
48  lambLim[1] = static_cast<int>(nvec[1]);
49  edm::LogInfo("FastCalorimetry") << "HFFibre: Limits on lambda " << lambLim[0]
50  << " and " << lambLim[1];
51 
52  // Fibre Lengths
53  nb = 0;
54  longFL = getDDDArray("LongFL",sv,nb);
55  edm::LogInfo("FastCalorimetry") << "HFFibre: " << nb << " Long Fibre Length";
56  for (int it=0; it<nb; it++)
57  edm::LogInfo("FastCalorimetry") << "HFFibre: longFL[" << it << "] = "
58  << longFL[it]/cm << " cm";
59  nb = 0;
60  shortFL = getDDDArray("ShortFL",sv,nb);
61  edm::LogInfo("FastCalorimetry") << "HFFibre: " << nb << " Short Fibre Length";
62  for (int it=0; it<nb; it++)
63  edm::LogInfo("FastCalorimetry") << "HFFibre: shortFL[" << it << "] = "
64  << shortFL[it]/cm << " cm";
65  } else {
66  edm::LogError("FastCalorimetry") << "HFFibre: cannot get filtered "
67  << " view for " << attribute << " matching "
68  << name;
69  throw cms::Exception("Unknown", "HFFibre")
70  << "cannot match " << attribute << " to " << name <<"\n";
71  }
72 
73  // Now geometry parameters
74  attribute = "ReadOutName";
75  value = name;
76  DDSpecificsFilter filter2;
77  DDValue ddv2(attribute,value,0);
79  DDFilteredView fv2(cpv);
80  fv2.addFilter(filter2);
81  dodet = fv2.firstChild();
82  if (dodet) {
84 
85  // Special Geometry parameters
86  int nb = -1;
87  gpar = getDDDArray("gparHF",sv,nb);
88  edm::LogInfo("FastCalorimetry") << "HFFibre: " << nb <<" gpar (cm)";
89  for (int i=0; i<nb; i++)
90  edm::LogInfo("FastCalorimetry") << "HFFibre: gpar[" << i << "] = "
91  << gpar[i]/cm << " cm";
92 
93  nBinR = -1;
94  radius = getDDDArray("rTable",sv,nBinR);
95  edm::LogInfo("FastCalorimetry") << "HFFibre: " << nBinR <<" rTable (cm)";
96  for (int i=0; i<nBinR; i++)
97  edm::LogInfo("FastCalorimetry") << "HFFibre: radius[" << i << "] = "
98  << radius[i]/cm << " cm";
99  } else {
100  edm::LogError("FastCalorimetry") << "HFFibre: cannot get filtered "
101  << " view for " << attribute << " matching "
102  << name;
103  throw cms::Exception("Unknown", "HFFibre")
104  << "cannot match " << attribute << " to " << name <<"\n";
105  }
106 }
107 
109 
110 double FastHFFibre::attLength(double lambda) {
111 
112  int i = int(nBinAtt*(lambda - lambLim[0])/(lambLim[1]-lambLim[0]));
113 
114  int j =i;
115  if (i >= nBinAtt)
116  j = nBinAtt-1;
117  else if (i < 0)
118  j = 0;
119  double att = attL[j];
120 #ifdef DebugLog
121  edm::LogInfo("FastCalorimetry") << "HFFibre::attLength for Lambda " << lambda
122  << " index " << i << " " << j << " Att. Length "
123  << att;
124 #endif
125  return att;
126 }
127 
128 double FastHFFibre::tShift(const G4ThreeVector& point, int depth, int fromEndAbs) {
129 
130  double zFibre = zShift(point, depth, fromEndAbs);
131  double time = zFibre/cFibre;
132 #ifdef DebugLog
133  edm::LogInfo("FastCalorimetry") << "HFFibre::tShift for point " << point
134  << " ( depth = " << depth <<", traversed length = "
135  << zFibre/cm << " cm) = " << time/ns << " ns";
136 #endif
137  return time;
138 }
139 
140 double FastHFFibre::zShift(const G4ThreeVector& point, int depth, int fromEndAbs) { // point is z-local
141 
142  double zFibre = 0;
143  double hR = sqrt((point.x())*(point.x())+(point.y())*(point.y()));
144  int ieta = 0;
145  double length = 250*cm;
146  if (fromEndAbs < 0) {
147  zFibre = 0.5*gpar[1] - point.z(); // Never, as fromEndAbs=0 (?)
148  } else {
149  // Defines the Radius bin by radial subdivision
150  for (int i = nBinR-1; i > 0; --i) if (hR < radius[i]) ieta = nBinR - i - 1;
151  // define the length of the fibre
152  if (depth == 2) {
153  if ((int)(shortFL.size()) > ieta) length = shortFL[ieta];
154  } else {
155  if ((int)(longFL.size()) > ieta) length = longFL[ieta];
156  }
157  zFibre = length;
158  if (fromEndAbs > 0) {
159  zFibre -= gpar[1]; // Never, as fromEndAbs=0 (M.K. ?)
160  } else {
161  double zz = 0.5*gpar[1] + point.z();
162  zFibre -= zz;
163  }
164  if (depth == 2) zFibre += gpar[0]; // here zFibre is reduced for Short
165  }
166 
167 #ifdef DebugLog
168  edm::LogInfo("FastCalorimetry") << "HFFibre::zShift for point " << point
169  << " (R = " << hR/cm << " cm, Index = " << ieta
170  << ", depth = " << depth << ", Fibre Length = "
171  << length/cm << " cm = " << zFibre/cm
172  << " cm)";
173 #endif
174  return zFibre;
175 }
176 
177 std::vector<double> FastHFFibre::getDDDArray(const std::string & str,
178  const DDsvalues_type & sv,
179  int & nmin) {
180 
181 #ifdef DebugLog
182  LogDebug("FastCalorimetry") << "HFFibre:getDDDArray called for " << str
183  << " with nMin " << nmin;
184 #endif
185  DDValue value(str);
186  if (DDfetch(&sv,value)) {
187 #ifdef DebugLog
188  LogDebug("FastCalorimetry") << "HFFibre:getDDDArray value " << value;
189 #endif
190  const std::vector<double> & fvec = value.doubles();
191  int nval = fvec.size();
192  if (nmin > 0) {
193  if (nval < nmin) {
194  edm::LogError("FastCalorimetry") << "HFFibre : # of " << str << " bins "
195  << nval << " < " << nmin << " ==> illegal";
196  throw cms::Exception("Unknown", "HFFibre")
197  << "nval < nmin for array " << str <<"\n";
198  }
199  } else {
200  if (nval < 1 && nmin != 0) {
201  edm::LogError("FastCalorimetry") << "HFFibre : # of " << str << " bins "
202  << nval << " < 1 ==> illegal (nmin="
203  << nmin << ")";
204  throw cms::Exception("Unknown", "HFFibre")
205  << "nval < 1 for array " << str <<"\n";
206  }
207  }
208  nmin = nval;
209  return fvec;
210  } else {
211  if (nmin != 0) {
212  edm::LogError("FastCalorimetry") << "HFFibre : cannot get array " << str;
213  throw cms::Exception("Unknown", "HFFibre")
214  << "cannot get array " << str <<"\n";
215  } else {
216  std::vector<double> fvec;
217  return fvec;
218  }
219  }
220 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
double lambLim[2]
Definition: FastHFFibre.h:45
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
Definition: DDValue.cc:139
void addFilter(const DDFilter &, log_op op=AND)
double cFibre
Definition: FastHFFibre.h:40
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &)
Definition: FastHFFibre.cc:177
std::vector< double > gpar
Definition: FastHFFibre.h:41
FastHFFibre(std::string &name, const DDCompactView &cpv, double cFibre)
Definition: FastHFFibre.cc:18
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:80
std::vector< double > attL
Definition: FastHFFibre.h:43
std::vector< double > longFL
Definition: FastHFFibre.h:42
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
Definition: FastHFFibre.cc:128
T sqrt(T t)
Definition: SSEVec.h:48
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
double attLength(double lambda)
Definition: FastHFFibre.cc:110
int j
Definition: DBlmapReader.cc:9
std::vector< double > radius
Definition: FastHFFibre.h:41
DDsvalues_type mergedSpecifics() const
double zShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
Definition: FastHFFibre.cc:140
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
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
std::vector< double > shortFL
Definition: FastHFFibre.h:42
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:37