Belle II Software  release-08-01-10
CDCGeometryPar.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/gearbox/GearDir.h>
12 #include <framework/database/DBArray.h>
13 #include <framework/database/DBObjPtr.h>
14 #include <framework/dbobjects/HardwareClockSettings.h>
15 #include <framework/geometry/B2Vector3.h>
16 
17 #include <cdc/dataobjects/WireID.h>
18 #include <cdc/dbobjects/CDCTimeZeros.h>
19 #include <cdc/dbobjects/CDCBadWires.h>
20 #include <cdc/dbobjects/CDCPropSpeeds.h>
21 #include <cdc/dbobjects/CDCTimeWalks.h>
22 #include <cdc/dbobjects/CDCXtRelations.h>
23 #include <cdc/dbobjects/CDCSpaceResols.h>
24 #include <cdc/dbobjects/CDCFudgeFactorsForSigma.h>
25 #include <cdc/dbobjects/CDCChannelMap.h>
26 #include <cdc/dbobjects/CDCDisplacement.h>
27 #include <cdc/dbobjects/CDCAlignment.h>
28 #include <cdc/dbobjects/CDCMisalignment.h>
29 #include <cdc/dbobjects/CDCGeometry.h>
30 #include <cdc/dbobjects/CDCEDepToADCConversions.h>
31 
32 #include <cdc/geometry/CDCGeometryParConstants.h>
33 
34 #include <vector>
35 #include <string>
36 #include <map>
37 //#include <fstream>
38 
39 
40 namespace Belle2 {
45  namespace CDC {
46 
48 
52 
53  public:
54 
56  enum EWirePosition {c_Base = 0, c_Misaligned, c_Aligned};
57 
59  virtual ~CDCGeometryPar();
60 
62 
65  static CDCGeometryPar& Instance(const CDCGeometry* = nullptr);
66 
68  void clear();
69 
71  void Print() const;
72 
74  void readFromDB(const CDCGeometry&);
75 
76  // /**
77  // * Read z-corrections.
78  // * @param GearDir Gear Dir.
79  // */
80  // void readDeltaz(const GearDir);
81  //
82  // /**
83  // * Read z-corrections from DB.
84  // *
85  // */
86  // void readDeltaz(const CDCGeometry&);
87 
88  // /**
89  // * Open a file
90  // * @param[in] ifs input file-stream
91  // * @param[in] fileName0 file-name on cdc/data directory
92  // */
93  // void openFile(std::ifstream& ifs, const std::string& fileName0) const;
94 
100  // void readWirePositionParams(EWirePosition set, const CDCGeometry*, const GearDir);
101  void readWirePositionParams(EWirePosition set, const CDCGeometry* geom);
102 
106  void setWirPosAlignParams();
107 
112 
118  void readXT(const GearDir& gbxParams, int mode = 0);
119 
125  void newReadXT(const GearDir& gbxParams, int mode = 0);
126 
130  void setXT();
131 
135  void setXtRel();
136 
142  void readSigma(const GearDir& gbxParams, int mode = 0);
143 
149  void newReadSigma(const GearDir& gbxParams, int mode = 0);
150 
156  void readFFactor(const GearDir& gbxParams, int mode = 0);
157 
161  void setSResol();
162 
166  void setFFactor();
167 
173  void readPropSpeed(const GearDir& gbxParams, int mode = 0);
174 
178  void setPropSpeed();
179 
185  void readT0(const GearDir& gbxParams, int mode = 0);
186 
190  void setT0();
191 
200  void calcMeanT0(double minT0 = 3800, double maxT0 = 5800, int maxIt = 10, double nStdv = 3, double epsi = 0.1);
201 
202  // /**
203  // * Read bad-wires (from a file).
204  // * @param GearDir Gear Dir.
205  // * @param mode 0: read simulation file, 1: read reconstruction file.
206  // */
207  // void readBadWire(const GearDir, int mode = 0);
208 
212  void setBadWire();
213 
217  // void readChMap(const GearDir);
218  void readChMap();
219 
223  void setChMap();
224 
230  void readTW(const GearDir& gbxParams, int mode = 0);
231 
237  void readEDepToADC(const GearDir& gbxParams, int mode = 0);
238 
242  void setTW();
243 
246 
254  double getEDepToADCConvFactor(unsigned short layer, unsigned short cell, double edep, double dx, double costh);
255 
256 
262  double getEDepToADCMainFactor(unsigned short layer, unsigned short cell, double costh = 0)
263  {
264  return m_eDepToADCParams[layer][cell][0] + m_eDepToADCParams[layer][cell][4] * (costh - m_eDepToADCParams[layer][cell][5]);
265  };
266 
271  double getEDepToADCSigma(unsigned short layer, unsigned short cell)
272  {
273  return m_eDepToADCParams[layer][cell][6];
274  };
275 
277 
280  void generateXML(const std::string& of);
281 
283 
286  std::string version() const;
287 
289 
292  double motherInnerR() const;
293 
295 
298  double motherOuterR() const;
299 
301 
304  double motherLength() const;
305 
307 
310  int momBound() const;
311 
313 
317  double momZ(int iBound) const;
318 
320 
324  double momRmin(int iBound) const;
325 
327 
332  unsigned cellId(unsigned layerId, const B2Vector3D& position) const;
333 
335 
338  double innerRadiusOuterWall() const;
339 
341 
344  double outerRadiusOuterWall() const;
345 
347 
350  double zOuterWall() const;
351 
353 
356  double zOffsetOuterWall() const;
357 
359 
362  double innerRadiusInnerWall() const;
363 
365 
368  double outerRadiusInnerWall() const;
369 
371 
374  double zInnerWall() const;
375 
377 
380  double zOffsetInnerWall() const;
381 
383 
386  double senseWireDiameter() const;
387 
389 
392  double fieldWireDiameter() const;
393 
395 
398  unsigned nWireLayers() const;
399 
401 
405  unsigned nWiresInLayer(int layerId) const;
406 
408 
411  const double* innerRadiusWireLayer() const;
412 
414 
417  const double* outerRadiusWireLayer() const;
418 
420 
423  const double* zForwardWireLayer() const;
424 
426 
429  const double* zBackwardWireLayer() const;
430 
432 
436  double zOffsetWireLayer(unsigned i) const;
437 
439 
442  double getMeanT0() const;
443 
445 
451  const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set = c_Base) const;
452 
454  const B2Vector3D wireForwardPosition(const WireID& wireID, EWirePosition set = c_Base) const
455  {
456  return wireForwardPosition(wireID.getICLayer(), wireID.getIWire(), set);
457  }
458 
460 
467  const B2Vector3D wireForwardPosition(uint layerId, int cellId, double z, EWirePosition set = c_Base) const;
469  const B2Vector3D wireForwardPosition(const WireID& wireID, double z,
470  EWirePosition set = c_Base) const
471  {
472  return wireForwardPosition(wireID.getICLayer(), wireID.getIWire(), z, set);
473  }
474 
476 
482  const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set = c_Base) const;
483 
485  const B2Vector3D wireBackwardPosition(const WireID& wireID, EWirePosition set = c_Base) const
486  {
487  return wireBackwardPosition(wireID.getICLayer(), wireID.getIWire(), set);
488  }
489 
491 
498  const B2Vector3D wireBackwardPosition(uint layerId, int cellId, double z, EWirePosition set = c_Base) const;
500  const B2Vector3D wireBackwardPosition(const WireID& wireID, double z, EWirePosition set = c_Base) const
501  {
502  return wireBackwardPosition(wireID.getICLayer(), wireID.getIWire(), z, set);
503  }
504 
506 
512  double getWireSagCoef(EWirePosition set, uint layerId, int cellId) const;
513 
514 
516 
520  {
522  }
523 
525 
528  double getMinTrackLength() const
529  {
530  return m_minTrackLength;
531  }
532 
534 
536  bool isWireSagOn() const
537  {
538  return m_wireSag;
539  }
540 
542 
545  {
546  return m_modLeftRightFlag;
547  }
548 
549 
551 
555  float getT0(const WireID& wireID) const
556  {
557  // std::cout << wireID.getICLayer() <<" "<< wireID.getIWire() << std::endl;
558  return m_t0[wireID.getICLayer()][wireID.getIWire()];
559  }
560 
562 
566  unsigned short getBoardID(const WireID& wID) const
567  {
568  std::map<WireID, unsigned short>::const_iterator it = m_wireToBoard.find(wID);
569  unsigned short iret = (it != m_wireToBoard.end()) ? it->second : -999;
570  return iret;
571  }
572 
574 
578  unsigned short getChannelID(const WireID& wID) const
579  {
580  std::map<WireID, unsigned short>::const_iterator it = m_wireToChannel.find(wID);
581  unsigned short iret = (it != m_wireToChannel.end()) ? it->second : -999;
582  return iret;
583  }
584 
586 
591  const WireID getWireID(unsigned short bd, unsigned short ch) const
592  {
593  return WireID(m_boardAndChannelToWire[bd][ch]);
594  }
595 
597 
602  double getTimeWalk(const WireID& wID, unsigned short adcCount) const
603  {
604  std::map<WireID, unsigned short>::const_iterator it = m_wireToBoard.find(wID);
605  // std::cout <<"SL,L,W, bd#= " << wID.getISuperLayer() <<" "<< wID.getILayer() <<" "<< wID.getIWire() <<" "<< it->second << std::endl;
606  double tw = 0.;
607  if (it != m_wireToBoard.end() && adcCount > 0) {
608  if (m_twParamMode == 0) {
609  tw = m_timeWalkCoef[it->second][0] / sqrt(adcCount);
610  } else if (m_twParamMode == 1) {
611  double p0 = m_timeWalkCoef[it->second][0];
612  double p1 = m_timeWalkCoef[it->second][1];
613  tw = p0 * exp(-p1 * adcCount);
614  }
615  }
616  // std::cout <<"bd#,coef,adc,tw= " << it->second <<" "<< m_timeWalkCoef[it->second] <<" "<< adcCount <<" "<< tw << std::endl;
617  return tw;
618  }
619 
621 
623  void setShiftInSuperLayer();
624 
626 
630  signed short getShiftInSuperLayer(unsigned short iSuperLayer, unsigned short iLayer) const;
631 
633 
637  double senseWireR(int layerId) const;
638 
640 
644  double senseWireFZ(int layerId) const;
645 
647 
651  double senseWireBZ(int layerId) const;
652 
654 
658  double fieldWireR(int layerId) const;
659 
661 
665  double fieldWireFZ(int layerId) const;
666 
668 
672  double fieldWireBZ(int layerId) const;
673 
675 
679  int nShifts(int layerId) const;
680 
686  double offset(int layerID) const;
687 
689 
693  void setSenseWireR(int layerId, double r);
694 
696 
700  void setSenseWireFZ(int layerId, double fz);
701 
703 
707  void setSenseWireBZ(int layerId, double bz);
708 
713  inline unsigned short getTdcOffset() const
714  {
715  return m_tdcOffset;
716  }
717 
722  inline double getTdcBinWidth() const
723  {
724  return m_tdcBinWidth;
725  }
726 
732  inline double getNominalDriftV() const
733  {
734  return m_nominalDriftV;
735  }
736 
742  inline double getNominalPropSpeed() const
743  {
744  return m_nominalPropSpeed;
745  }
746 
752  inline double getNominalSpaceResol() const
753  {
754  return m_nominalSpaceResol;
755  }
756 
767  inline int getMaterialDefinitionMode() const
768  {
770  }
771 
780  inline int getSenseWireZposMode() const
781  {
782  return m_senseWireZposMode;
783  }
784 
790  inline double getBwdDeltaZ(unsigned short layerID) const
791  {
792  return m_dzSBackwardLayer[layerID];
793  }
794 
800  inline double getFwdDeltaZ(unsigned short layerID) const
801  {
802  return m_dzSForwardLayer[layerID];
803  }
804 
811  inline void setNominalSpaceResol(double resol)
812  {
813  m_nominalSpaceResol = resol;
814  }
815 
822  inline double getPropSpeedInv(const unsigned int layerID) const
823  {
824  return m_propSpeedInv[layerID];
825  }
826 
830  inline bool isBadWire(const WireID& wid)
831  {
832  // std::map<unsigned short, float>::iterator it = m_badWire.find(wid.getEWire());
833  // bool torf = (it != m_badWire.end()) ? true : false;
834  // return torf;
835  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isBadWire(wid) : false;
836  return torf;
837 
838  }
839 
843  inline bool isDeadWire(const WireID& wid, double& eff)
844  {
845  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isDeadWire(wid, eff) : false;
846  return torf;
847  }
848 
852  inline bool isHotWire(const WireID& wid)
853  {
854  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isHotWire(wid) : false;
855  return torf;
856  }
857 
871  void getWireSagEffect(EWirePosition set, unsigned layerID, unsigned cellID, double zw, double& ywb_sag, double& ywf_sag) const;
872 
883  double getDriftV(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
884 
896  double getDriftLength(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI,
897  bool calculateMinTime = true, double minTime = 0.) const;
898 
907  double getDriftLength0(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
908 
916  double getMinDriftTime(unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
917 
927  double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const;
928 
937  double getSigma(double dist, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
938 
943  double getFudgeFactorForSigma(unsigned short target) const
944  {
945  return m_fudgeFactorForSigma[target];
946  }
947 
954  unsigned short getOldLeftRight(const B2Vector3D& posOnWire, const B2Vector3D& posOnTrack, const B2Vector3D& momentum) const;
955 
963  unsigned short getNewLeftRightRaw(const B2Vector3D& posOnWire, const B2Vector3D& posOnTrack, const B2Vector3D& momentum) const;
964 
971  double getAlpha(const B2Vector3D& posOnWire, const B2Vector3D& momentum) const;
972 
977  double getTheta(const B2Vector3D& momentum) const;
978 
979 
985  unsigned short getOutgoingLR(const unsigned short lr, const double alpha) const;
986 
987 
992  double getOutgoingAlpha(const double alpha) const;
993 
994 
1000  double getOutgoingTheta(const double alpha, const double theta) const;
1001 
1002 
1006  void getClosestAlphaPoints(const double alpha, double& wal, unsigned short points[2], unsigned short lrs[2]) const;
1007 
1011  void getClosestAlphaPoints4Sgm(const double alpha, double& wal, unsigned short points[2], unsigned short lrs[2]) const;
1012 
1016  void getClosestThetaPoints(const double alpha, const double theta, double& wth, unsigned short points[2]) const;
1017 
1021  void getClosestThetaPoints4Sgm(const double alpha, const double theta, double& wth, unsigned short points[2]) const;
1022 
1028  void setDesignWirParam(unsigned layerID, unsigned cellID);
1029 
1035  void outputDesignWirParam(unsigned layerID, unsigned cellID) const;
1036 
1040  void setDisplacement();
1041 
1042 
1046  ushort getNumberOfSenseWires() const { return m_nSenseWires;}
1047 
1051  ushort getNumberOfFieldWires() const { return m_nFieldWires;}
1052 
1056  ushort getNumberOfSenseLayers() const { return m_maxNSenseLayers;}
1057 
1061  ushort getNumberOfFieldLayers() const { return m_maxNFieldLayers;}
1062 
1067 
1071  ushort getOffsetOfFirstLayer() const { return m_firstLayerOffset;}
1072 
1077 
1082 
1083  private:
1085  CDCGeometryPar(const CDCGeometry* = nullptr);
1090 
1091  bool m_debug;
1094  bool m_XTetc;
1100  bool m_wireSag;
1103  std::string m_version;
1113  unsigned short m_nAlphaPoints;
1114  unsigned short m_nThetaPoints;
1115  unsigned short m_nAlphaPoints4Sgm;
1116  unsigned short m_nThetaPoints4Sgm;
1117  signed short m_shiftInSuperLayer[c_nSuperLayers][8];
1119  double m_rWall[4];
1120  double m_zWall[4][2];
1122  double m_rSLayer[c_maxNSenseLayers];
1123  double m_zSForwardLayer[c_maxNSenseLayers];
1124  double m_dzSForwardLayer[c_maxNSenseLayers];
1125  double m_zSBackwardLayer[c_maxNSenseLayers];
1126  double m_dzSBackwardLayer[c_maxNSenseLayers];
1127  double m_rFLayer[c_maxNFieldLayers];
1128  double m_zFForwardLayer[c_maxNFieldLayers];
1129  double m_zFBackwardLayer[c_maxNFieldLayers];
1130  double m_offSet[c_maxNSenseLayers];
1131  double m_cellSize[c_maxNSenseLayers];
1132  int m_nShifts[c_maxNSenseLayers];
1133  unsigned m_nWires[c_maxNSenseLayers];
1142  double m_momZ[7];
1143  double m_momRmin[7];
1145  // double m_bwdDz[c_maxNSenseLayers]; /*!< Tentative backward z-corrections.*/
1146  // double m_fwdDz[c_maxNSenseLayers]; /*!< Tentative forward z-corrections.*/
1147 
1151  float m_FWirPos[c_maxNSenseLayers][c_maxNDriftCells][3];
1152  float m_BWirPos[c_maxNSenseLayers][c_maxNDriftCells][3];
1153  float m_WireSagCoef[c_maxNSenseLayers][c_maxNDriftCells];
1155  float m_FWirPosMisalign[c_maxNSenseLayers][c_maxNDriftCells][3];
1156  float m_BWirPosMisalign[c_maxNSenseLayers][c_maxNDriftCells][3];
1157  float m_WireSagCoefMisalign[c_maxNSenseLayers][c_maxNDriftCells];
1159  float m_FWirPosAlign[c_maxNSenseLayers][c_maxNDriftCells][3];
1160  float m_BWirPosAlign[c_maxNSenseLayers][c_maxNDriftCells][3];
1161  float m_WireSagCoefAlign[c_maxNSenseLayers][c_maxNDriftCells];
1162  float m_eDepToADCParams[c_maxNSenseLayers][c_maxNDriftCells][7] = {};
1164  float m_alphaPoints[c_maxNAlphaPoints];
1165  float m_thetaPoints[c_maxNThetaPoints];
1166  float m_alphaPoints4Sgm[c_maxNAlphaPoints];
1167  float m_thetaPoints4Sgm[c_maxNThetaPoints];
1169  float m_XT[c_maxNSenseLayers][2][c_maxNAlphaPoints][c_maxNThetaPoints][c_nXTParams];
1170  float m_Sigma[c_maxNSenseLayers][2][c_maxNAlphaPoints][c_maxNThetaPoints][c_nSigmaParams];
1171  float m_propSpeedInv[c_maxNSenseLayers];
1172  float m_t0[c_maxNSenseLayers][c_maxNDriftCells] = {};
1173  float m_timeWalkCoef[c_nBoards][2];
1175  // float m_meanT0; /*!< mean t0 over all wires. */
1176  double m_meanT0;
1178  std::map<WireID, unsigned short> m_wireToBoard;
1179  std::map<WireID, unsigned short> m_wireToChannel;
1180  unsigned short m_boardAndChannelToWire[c_nBoards][48];
1182  // std::map<unsigned short, float> m_badWire; /*!< list of bad-wires. */
1183 
1184  unsigned short m_tdcOffset;
1186  double m_tdcBinWidth;
1211  ushort m_nSenseWires = c_nSenseWires;
1212  ushort m_nFieldWires = c_nFieldWires;
1213  ushort m_maxNSenseLayers = c_maxNSenseLayers;
1214  ushort m_maxNFieldLayers = c_maxNFieldLayers;
1215  ushort m_maxNSuperLayers = c_nSuperLayers;
1216  ushort m_firstLayerOffset = 0;
1218  ushort m_maxNCellsPerLayer = c_maxNDriftCells;
1220  };
1221 
1222 //-----------------------------------------------------------------------------
1223 // Inline functions
1224 //-----------------------------------------------------------------------------
1225  inline std::string CDCGeometryPar::version() const
1226  {
1227  return m_version;
1228  }
1229 
1230  inline double CDCGeometryPar::momZ(int iBound) const
1231  {
1232  return m_momZ[iBound];
1233  }
1234 
1235  inline double CDCGeometryPar::momRmin(int iBound) const
1236  {
1237  return m_momRmin[iBound];
1238  }
1239 
1240  inline int CDCGeometryPar::nShifts(int layerID) const
1241  {
1242  return m_nShifts[layerID];
1243  }
1244 
1245  inline double CDCGeometryPar::offset(int layerID) const
1246  {
1247  return m_offSet[layerID];
1248  }
1249 
1250  inline unsigned CDCGeometryPar::nWiresInLayer(int layerID) const
1251  {
1252  return m_nWires[layerID];
1253  }
1254 
1255  inline void CDCGeometryPar::setSenseWireR(int layerId, double r)
1256  {
1257  m_rSLayer[layerId] = r;
1258  }
1259 
1260  inline void CDCGeometryPar::setSenseWireFZ(int layerId, double fz)
1261  {
1262  m_zSForwardLayer[layerId] = fz;
1263  }
1264 
1265  inline void CDCGeometryPar::setSenseWireBZ(int layerId, double bz)
1266  {
1267  m_zSBackwardLayer[layerId] = bz;
1268  }
1269 
1270  inline double CDCGeometryPar::senseWireR(int layerID) const
1271  {
1272  return m_rSLayer[layerID];
1273  }
1274 
1275  inline double CDCGeometryPar::senseWireFZ(int layerID) const
1276  {
1277  return m_zSForwardLayer[layerID];
1278  }
1279 
1280  inline double CDCGeometryPar::senseWireBZ(int layerID) const
1281  {
1282  return m_zSBackwardLayer[layerID];
1283  }
1284 
1285  inline double CDCGeometryPar::fieldWireR(int layerID) const
1286  {
1287  return m_rFLayer[layerID];
1288  }
1289 
1290  inline double CDCGeometryPar::fieldWireFZ(int layerID) const
1291  {
1292  return m_zFForwardLayer[layerID];
1293  }
1294 
1295  inline double CDCGeometryPar::fieldWireBZ(int layerID) const
1296  {
1297  return m_zFBackwardLayer[layerID];
1298  }
1299 
1301  {
1302  return m_rWall[2];
1303  }
1304 
1306  {
1307  return m_rWall[3];
1308  }
1309 
1310  inline double CDCGeometryPar::zOuterWall() const
1311  {
1312  return (m_zWall[2][1] - m_zWall[2][0]);
1313  }
1314 
1316  {
1317  return m_rWall[0];
1318  }
1319 
1321  {
1322  return m_rWall[1];
1323  }
1324 
1325  inline double CDCGeometryPar::zInnerWall() const
1326  {
1327  return (m_zWall[0][1] - m_zWall[0][0]);
1328  }
1329 
1330  inline double CDCGeometryPar::zOffsetOuterWall() const
1331  {
1332  return (m_zWall[2][0] + zOuterWall() / 2);
1333  }
1334 
1335  inline double CDCGeometryPar::zOffsetInnerWall() const
1336  {
1337  return (m_zWall[0][0] + zInnerWall() / 2);
1338  }
1339 
1341  {
1342  return m_senseWireDiameter;
1343  }
1344 
1346  {
1347  return m_fieldWireDiameter;
1348  }
1349 
1350  inline unsigned CDCGeometryPar::nWireLayers() const
1351  {
1352  return c_maxNSenseLayers;
1353  }
1354 
1355  inline const double* CDCGeometryPar::zForwardWireLayer() const
1356  {
1357  return m_zSForwardLayer;
1358  }
1359 
1360  inline const double* CDCGeometryPar::zBackwardWireLayer() const
1361  {
1362  return m_zSBackwardLayer;
1363  }
1364 
1365  inline double CDCGeometryPar::zOffsetWireLayer(unsigned i) const
1366  {
1367  return (m_zSBackwardLayer[i] + (m_zSForwardLayer[i] - m_zSBackwardLayer[i]) / 2);
1368  }
1369 
1370  inline double CDCGeometryPar::getMeanT0() const
1371  {
1372  return m_meanT0;
1373  }
1374 
1375  } // end of namespace CDC
1377 } // end of namespace Belle2
The Class for CDC geometry.
Definition: CDCGeometry.h:27
The Class for CDC Geometry Parameters.
void outputDesignWirParam(unsigned layerID, unsigned cellID) const
Write the designed wire parameters to the alignment.dat (default).
std::map< WireID, unsigned short > m_wireToChannel
map relating wire-id and channel-id.
void setWirPosAlignParams()
Set wire alignment params.
int m_materialDefinitionMode
Control switch for gas and wire material definition.
unsigned short m_nAlphaPoints4Sgm
No.
double getTimeWalk(const WireID &wID, unsigned short adcCount) const
Returns time-walk.
void readSigma(const GearDir &gbxParams, int mode=0)
Read spatial resolution table.
void readTW(const GearDir &gbxParams, int mode=0)
Read time-walk parameter.
void setXtRel()
Set XT-relation table (from DB) (new).
double getNominalPropSpeed() const
Return the nominal propagation speed of the sense wire (default: 27.25 cm/nsec).
float m_BWirPosMisalign[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
DBObjPtr< CDCBadWires > * m_badWireFromDB
bad-wires retrieved from DB.
double getTheta(const B2Vector3D &momentum) const
Returns track incident angle (theta in rad.).
double motherLength() const
The method to get cdc mother volume length.
void readT0(const GearDir &gbxParams, int mode=0)
Read t0 parameters (from a file).
void setT0()
Set t0 parameters (from DB)
float m_alphaPoints4Sgm[c_maxNAlphaPoints]
alpha sampling points for sigma (rad)
virtual ~CDCGeometryPar()
Destructor.
double fieldWireDiameter() const
Returns diameter of the field wire.
ushort m_maxNSuperLayers
Maximum number of Super Layers.
double m_fudgeFactorForSigma[3]
Fuge factor for space resol.
double outerRadiusInnerWall() const
Returns the outer radius of the inner wall.
double zOuterWall() const
Returns the length of the outer wall in Z.
int m_sigmaParamMode
Mode for sigma parameterization.
bool m_alignment
Switch for alignment.
float m_alphaPoints[c_maxNAlphaPoints]
alpha sampling points for xt (rad)
void getClosestAlphaPoints(const double alpha, double &wal, unsigned short points[2], unsigned short lrs[2]) const
Returns the two closest alpha points for the input track incident angle (alpha).
void readEDepToADC(const GearDir &gbxParams, int mode=0)
Read spatial edep-to-adc conv.
const double * zBackwardWireLayer() const
Returns an array of backward z of wire layers.
double m_globalPhiRotation
Global ratation in phi (rad.); only for sence wires now.
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
EWirePosition
Wire position set.
double innerRadiusOuterWall() const
Returns the inner radius of the outer wall.
unsigned cellId(unsigned layerId, const B2Vector3D &position) const
The method to get cell id based on given layer id and the position.
void newReadSigma(const GearDir &gbxParams, int mode=0)
Read spatial resolution table in new format.
void setEDepToADCConversions()
Set edep-to-ADC conversion params.
double m_nominalPropSpeed
Nominal propagation speed of the sense wire (27.25 cm/nsec).
void setNominalSpaceResol(double resol)
Set the nominal spacial resolution in the unit of um.
int nShifts(int layerId) const
Returns number shift.
float m_thetaPoints[c_maxNThetaPoints]
theta sampling points for xt (rad)
void setDesignWirParam(unsigned layerID, unsigned cellID)
Set the desizend wire parameters.
void getWireSagEffect(EWirePosition set, unsigned layerID, unsigned cellID, double zw, double &ywb_sag, double &ywf_sag) const
Compute effects of the sense wire sag.
DBArray< CDCDisplacement > * m_displacementFromDB
displacement params.
bool m_XTetc
Switch for reading x-t etc.
void setShiftInSuperLayer()
Calculates and saves shifts in super-layers (to be used in searching hits in neighboring cells)
int m_nShifts[c_maxNSenseLayers]
The array to store shifted cell number in each sense wire layer.
bool m_wireSag
Switch for sense wire sag.
bool m_XTetc4Recon
Switch for selecting xt etc.
double getFwdDeltaZ(unsigned short layerID) const
Return forward 'deltaZ'.
double motherInnerR() const
The method to get cdc mother volume inner R.
const double * zForwardWireLayer() const
Returns an array of forward z of wire layers.
double getDriftLength0(double dt, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI) const
Return the drift dength to the sense wire; tentative ver.
unsigned short m_boardAndChannelToWire[c_nBoards][48]
array relating board-channel-id and wire-id.
unsigned short m_nThetaPoints4Sgm
No.
float m_WireSagCoef[c_maxNSenseLayers][c_maxNDriftCells]
Wire sag coefficient for each cell; ibid.
CDCGeometryPar & operator=(const CDCGeometryPar &)
Singleton class.
void generateXML(const std::string &of)
Generate an xml file used in gearbox.
void getClosestAlphaPoints4Sgm(const double alpha, double &wal, unsigned short points[2], unsigned short lrs[2]) const
Returns the two closest alpha points for sigma for the input track incident angle (alpha).
DBObjPtr< HardwareClockSettings > m_clockSettings
hardware clock settings
double getNominalSpaceResol() const
Return the nominal spacial resolution.
float m_eDepToADCParams[c_maxNSenseLayers][c_maxNDriftCells][7]
edep-to-ADC conv.
double getThresholdEnerguDeposit() const
Returns threshold for energy deposit in one G4 step.
double m_minTrackLength
Minimum track length for G4 step.
double getAlpha(const B2Vector3D &posOnWire, const B2Vector3D &momentum) const
Returns track incident angle in rphi plane (alpha in rad.).
double fieldWireR(int layerId) const
Returns radius of field wire in each layer.
ushort getOffsetOfFirstLayer() const
Get the offset of the first layer.
float m_FWirPosMisalign[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
double getMinTrackLength() const
Returns the minimum track length required in one G4 step (only secondary particles which pass this cr...
const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
bool isDeadWire(const WireID &wid, double &eff)
Inquire if the wire is dead.
unsigned m_nWires[c_maxNSenseLayers]
The array to store the wire number in each sense wire layre.
const WireID getWireID(unsigned short bd, unsigned short ch) const
Returns wire id. corresponding to the board-and-cannel ids.
double momRmin(int iBound) const
Returns inner radius of the CDC mother volume.
double getDriftV(double dt, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI) const
Get the realistic drift velocity.
double m_clockFreq4TDC
Clock frequency used for TDC (GHz).
bool isWireSagOn() const
Returns on/off for sense wire sag in FullSim.
const B2Vector3D wireForwardPosition(const WireID &wireID, double z, EWirePosition set=c_Base) const
The same function but in a different input format.
ushort getMaxNumberOfSuperLayers() const
Get the maximum number of super layers.
int m_nFLayer
The number of field wire layer.
static CDCGeometryPar * m_B4CDCGeometryParDB
Pointer that saves the instance of this class.
double zOffsetOuterWall() const
Returns the offset of the outer wall in z direction.
DBObjPtr< CDCMisalignment > * m_misalignmentFromDB
misalignment params.
ushort getNumberOfFieldWires() const
Get the number of field wires.
float m_XT[c_maxNSenseLayers][2][c_maxNAlphaPoints][c_maxNThetaPoints][c_nXTParams]
XT-relation coefficients for each layer, Left/Right, entrance angle and polar angle.
void setSenseWireR(int layerId, double r)
Set radius of sense wire in each layer.
signed short m_shiftInSuperLayer[c_nSuperLayers][8]
shift in phi-direction wrt the 1st layer in each super layer
std::string m_version
The version of geometry parameters.
double senseWireDiameter() const
Returns diameter of the sense wire.
const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
bool m_linearInterpolationOfXT
Switch for linear interpolation of xt.
double getTdcBinWidth() const
Return TDC bin width (nsec).
DBObjPtr< CDCSpaceResols > * m_sResolFromDB
sigma params.
void setDisplacement()
Set displacement of sense wire.
double getOutgoingAlpha(const double alpha) const
Converts incoming- to outgoing-alpha.
bool isHotWire(const WireID &wid)
Inquire if the wire is hot.
double m_meanT0
mean t0 over all wires; should be double.
double momZ(int iBound) const
Returns boundary position in Z axis of the CDC mother volume.
bool m_debug
Switch for debug printing.
DBObjPtr< CDCTimeWalks > * m_timeWalkFromDB
time-walk coeffs.
ushort m_nSenseWires
Maximum number of Sense Wires.
unsigned short m_tdcOffset
Not used; to be removed later.
float getT0(const WireID &wireID) const
Returns t0 parameter of the specified sense wire.
double getSigma(double dist, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI) const
Return the basic resolution of drift length (cm).
CDCGeometryPar(const CDCGeometry *=nullptr)
Singleton class.
unsigned short getOutgoingLR(const unsigned short lr, const double alpha) const
Converts incoming-lr to outgoing-lr.
ushort m_maxNSenseLayers
Maximum number of Sense Wire Layers.
void readWirePositionParams(EWirePosition set, const CDCGeometry *geom)
Read displacement or (mis)alignment params from text file.
double getFudgeFactorForSigma(unsigned short target) const
Return the fuge factor for space resol.
float m_thetaPoints4Sgm[c_maxNThetaPoints]
theta sampling points for sigma (rad)
const B2Vector3D wireForwardPosition(const WireID &wireID, EWirePosition set=c_Base) const
The same function but in a different input format.
double zInnerWall() const
Returns the length of the inner wall in Z.
void setXT()
Set XT-relation table (from DB).
std::map< WireID, unsigned short > m_wireToBoard
map relating wire-id and board-id.
double getOutgoingTheta(const double alpha, const double theta) const
Converts incoming- to outgoing-theta.
double m_senseWireDiameter
The diameter of sense wires.
double offset(int layerID) const
Return wire offset in phi direction at endplate.
bool m_displacement
Switch for displacement.
int m_twParamMode
Mode for tw parameterization.
double senseWireBZ(int layerId) const
Returns backward z position of sense wire in each layer.
double m_dzSBackwardLayer[c_maxNSenseLayers]
Corrections for backward z position of sense wire layers.
double getMinDriftTime(unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI) const
Return the min.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
double fieldWireBZ(int layerId) const
Returns backward z position of field wire in each layer.
void getClosestThetaPoints(const double alpha, const double theta, double &wth, unsigned short points[2]) const
Returns the two closest theta points for the input track incident angle (theta).
double zOffsetInnerWall() const
Returns the offset of the outer wall in z direction.
double senseWireFZ(int layerId) const
Returns forward z position of sense wire in each layer.
void readPropSpeed(const GearDir &gbxParams, int mode=0)
Read the propagation speed along the sense wire.
double getBwdDeltaZ(unsigned short layerID) const
Return backward 'deltaZ'.
double innerRadiusInnerWall() const
Returns the inner radius of the inner wall.
DBObjPtr< CDCTimeZeros > * m_t0FromDB
t0s retrieved from DB.
ushort getMaxNumberOfCellsPerLayer() const
Get the maximum number of cells in one layer.
int m_xtFileFormat
Format of xt input file.
int m_sigmaFileFormat
Format of sigma input file.
void setSenseWireBZ(int layerId, double bz)
set backward z position of sense wires.
ushort m_firstSuperLayerOffset
Offset of the first super layer (for reduced CDC studies)
void setChMap()
Set channel map (from DB)
double getEDepToADCSigma(unsigned short layer, unsigned short cell)
Return sigma for extra smearing of edep to ADC conversion.
double getNominalDriftV() const
Return the nominal drift velocity of He-ethane gas (default: 4.0x10^-3 cm/nsec).
DBObjPtr< CDCFudgeFactorsForSigma > * m_fFactorFromDB
fudge factors retrieved from DB.
int m_nSLayer
The number of sense wire layer.
DBArray< CDCChannelMap > * m_chMapFromDB
channel map retrieved from DB.
void calcMeanT0(double minT0=3800, double maxT0=5800, int maxIt=10, double nStdv=3, double epsi=0.1)
Calculate mean t0 in ns (over all good wires)
double getMeanT0() const
Returns the mean t0 over all wires.
void readFromDB(const CDCGeometry &)
Gets geometry parameters from database.
DBObjPtr< CDCXtRelations > * m_xtRelFromDB
xt params.
double m_nominalDriftV
Nominal drift velocity (4.0x10^-3 cm/nsec).
float m_FWirPos[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
ushort getNumberOfSenseLayers() const
Get the number of sense layers.
float m_WireSagCoefAlign[c_maxNSenseLayers][c_maxNDriftCells]
Wire sag coefficient incl.
double m_zSForwardLayer[c_maxNSenseLayers]
The array to store forward z position of sense wire layers.
bool m_linearInterpolationOfSgm
Switch for linear interpolation of sigma.
DBObjPtr< CDCPropSpeeds > * m_propSpeedFromDB
prop.
double getPropSpeedInv(const unsigned int layerID) const
Get the inversel of propagation speed in the sense wire.
void setBadWire()
Set bad-wires (from DB)
int m_xtParamMode
Mode for xt parameterization.
float m_FWirPosAlign[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
CDCGeometryPar(const CDCGeometryPar &)
Singleton class.
double fieldWireFZ(int layerId) const
Returns forward z position of field wire in each layer.
double m_dzSForwardLayer[c_maxNSenseLayers]
Corrections for forward z position of sense wire layers.
double getEDepToADCConvFactor(unsigned short layer, unsigned short cell, double edep, double dx, double costh)
Return edep-to-ADC conversion factor.
double m_nominalDriftVInv
Inverse of the nominal drift velocity.
const double * innerRadiusWireLayer() const
Returns an array of inner radius of wire layers.
double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const
Return the drift time to the sense wire.
signed short getShiftInSuperLayer(unsigned short iSuperLayer, unsigned short iLayer) const
Returns shift in the super-layer.
double getWireSagCoef(EWirePosition set, uint layerId, int cellId) const
Returns coefficient for the sense wire sag.
void readChMap()
Read channel map between wire-id and electronics-id.
double m_zFForwardLayer[c_maxNFieldLayers]
The array to store forward z position of field wire layers.
double m_rSLayer[c_maxNSenseLayers]
The array to store radius of sense wire layers.
double m_fieldWireDiameter
The diameter of field wires.
double m_zFBackwardLayer[c_maxNFieldLayers]
The array to store backward z position of field wire layers.
ushort m_nFieldWires
Maximum number of Field Wires.
float m_WireSagCoefMisalign[c_maxNSenseLayers][c_maxNDriftCells]
Wire sag coefficient incl.
double getDriftLength(double dt, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI, bool calculateMinTime=true, double minTime=0.) const
Return the drift dength to the sense wire.
double m_cellSize[c_maxNSenseLayers]
The array to store cell size in each sense wire layer.
float m_BWirPosAlign[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
double outerRadiusOuterWall() const
Returns the outer radius of the outer wall.
float m_t0[c_maxNSenseLayers][c_maxNDriftCells]
t0 for each sense-wire (in nsec).
void setWirPosMisalignParams()
Set wire misalignment params.
double m_momZ[7]
Z-cordinates of the cdc mother volume (7 segments).
double m_momRmin[7]
R_min of the cdc mother volume (7 segments).
double m_offSet[c_maxNSenseLayers]
The array to store z offset of sense wire layers.
int getSenseWireZposMode() const
Return mode for sense wire z position.
void setTW()
Set time-walk parameters.
const B2Vector3D wireBackwardPosition(const WireID &wireID, EWirePosition set=c_Base) const
The same function but in a different input format.
void setSResol()
Set spatial resolution (from DB).
double m_zSBackwardLayer[c_maxNSenseLayers]
The array to store backward z position of sense wire layers.
unsigned short getOldLeftRight(const B2Vector3D &posOnWire, const B2Vector3D &posOnTrack, const B2Vector3D &momentum) const
Returns old left/right.
float m_propSpeedInv[c_maxNSenseLayers]
Inverse of propagation speed of the sense wire.
ushort m_maxNCellsPerLayer
Maximum number wires within a layer.
double m_zWall[4][2]
The array to store z position of inner wall and outer wall.
bool isBadWire(const WireID &wid)
Inquire if the wire is totally-dead.
ushort getNumberOfFieldLayers() const
Get the number of field layers.
const B2Vector3D wireBackwardPosition(const WireID &wireID, double z, EWirePosition set=c_Base) const
The same function but in a different input format.
DBObjPtr< CDCAlignment > * m_alignmentFromDB
alignment params.
ushort m_maxNFieldLayers
Maximum number of Field Wire Layers.
bool m_misalignment
Switch for misalignment.
int getMaterialDefinitionMode() const
Return mode for material definition.
double m_senseWireDensity
The density of sense wires.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
ushort m_firstLayerOffset
Offset of the first layer (for reduced CDC studies)
void Print() const
Print some debug information.
float m_timeWalkCoef[c_nBoards][2]
coefficients for time walk.
void readFFactor(const GearDir &gbxParams, int mode=0)
Read fudge factors.
unsigned short m_nThetaPoints
No.
ushort getOffsetOfFirstSuperLayer() const
Get the offset of the first super layer.
double m_maxSpaceResol
max space resolution allowed (cm).
double m_thresholdEnergyDeposit
Energy thresh.
float m_BWirPos[c_maxNSenseLayers][c_maxNDriftCells][3]
Wire position incl.
float m_Sigma[c_maxNSenseLayers][2][c_maxNAlphaPoints][c_maxNThetaPoints][c_nSigmaParams]
position resulution for each layer.
void readXT(const GearDir &gbxParams, int mode=0)
Read XT-relation table.
double m_rFLayer[c_maxNFieldLayers]
The array to store radius of field wire layers.
void newReadXT(const GearDir &gbxParams, int mode=0)
Read XT-relation table in new format.
unsigned short getChannelID(const WireID &wID) const
Returns frontend channel id. corresponding to the wire id.
double m_nominalSpaceResol
Nominal spacial resolution (0.0130 cm).
unsigned nWireLayers() const
Returns a number of wire layers.
unsigned short m_nAlphaPoints
No.
unsigned short getNewLeftRightRaw(const B2Vector3D &posOnWire, const B2Vector3D &posOnTrack, const B2Vector3D &momentum) const
Returns new left/right_raw.
int m_senseWireZposMode
Mode for sense wire z position corr.
double motherOuterR() const
The method to get cdc mother volume outer R.
double m_rWall[4]
The array to store radius of inner wall and outer wall.
double m_tdcBinWidth
TDC bin width (nsec/bin).
bool m_modLeftRightFlag
Switch for modified left/right flag.
void getClosestThetaPoints4Sgm(const double alpha, const double theta, double &wth, unsigned short points[2]) const
Returns the two closest theta points for sigma for the input track incident angle (theta).
bool isModifiedLeftRightFlagOn() const
Returns on/off for modified left/right calculation in FullSim.
DBObjPtr< CDCEDepToADCConversions > * m_eDepToADCConversionsFromDB
Pointer to edep-to-ADC conv.
const double * outerRadiusWireLayer() const
Returns an array of outer radius of wire layers.
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
ushort getNumberOfSenseWires() const
Get the number of sense wires.
double m_senseWireTension
The tension of sense wires.
double getEDepToADCMainFactor(unsigned short layer, unsigned short cell, double costh=0)
Return edep-to-ADC conversion main factor (in count/keV)
double zOffsetWireLayer(unsigned i) const
Returns the offset of z of the wire layer i.
void setFFactor()
Set fudge factors (from DB).
void setSenseWireFZ(int layerId, double fz)
Set forward z position of sense wires.
std::string version() const
Returns the version of cdc geometry parameters.
int momBound() const
to get the number of boundary position of the CDC mother volume
unsigned short getTdcOffset() const
Return TDC offset value (default = 0 ch).
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
unsigned short getIWire() const
Getter for wire within the layer.
Definition: WireID.h:145
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.