Belle II Software  release-06-02-00
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 
16 #include <cdc/dataobjects/WireID.h>
17 #include <cdc/dbobjects/CDCTimeZeros.h>
18 #include <cdc/dbobjects/CDCBadWires.h>
19 #include <cdc/dbobjects/CDCPropSpeeds.h>
20 #include <cdc/dbobjects/CDCTimeWalks.h>
21 #include <cdc/dbobjects/CDCXtRelations.h>
22 #include <cdc/dbobjects/CDCSpaceResols.h>
23 #include <cdc/dbobjects/CDCFudgeFactorsForSigma.h>
24 #include <cdc/dbobjects/CDCChannelMap.h>
25 #include <cdc/dbobjects/CDCDisplacement.h>
26 #include <cdc/dbobjects/CDCAlignment.h>
27 #include <cdc/dbobjects/CDCMisalignment.h>
28 #include <cdc/dbobjects/CDCGeometry.h>
29 #include <cdc/dbobjects/CDCEDepToADCConversions.h>
30 
31 #include <vector>
32 #include <string>
33 #include <map>
34 //#include <fstream>
35 
36 #include "TVector3.h"
37 
38 const unsigned MAX_N_SLAYERS = 56;
39 const unsigned MAX_N_SCELLS = 384;
40 const unsigned MAX_N_FLAYERS = 55;
41 const unsigned nSenseWires = 14336;
42 const unsigned nSuperLayers = 9;
43 const unsigned nBoards = 300;
44 //const unsigned nAlphaPoints = 19;
45 const unsigned maxNAlphaPoints = 18;
46 const unsigned maxNThetaPoints = 7;
47 const unsigned nXTParams = 9; //#fit params + 1
48 const unsigned nSigmaParams = 9; //7 is used now; 2 for spare
49 
50 namespace Belle2 {
55  namespace CDC {
56  /*
57  const unsigned MAX_N_SLAYERS = 56;
58  const unsigned MAX_N_SCELLS = 384;
59  const unsigned MAX_N_FLAYERS = 55;
60  const unsigned nSenseWires = 14336;
61  const unsigned nSuperLayers = 9;
62  const unsigned nBoards = 300;
63  const unsigned maxNAlphaPoints = 18;
64  const unsigned maxNThetaPoints = 7;
65  const unsigned nXTParams = 9; //#fit params + 1
66  const unsigned nSigmaParams = 9; //7 is used now; 2 for spare
67  */
68 
70 
74 
75  public:
76 
78  enum EWirePosition {c_Base = 0, c_Misaligned, c_Aligned};
79 
81  virtual ~CDCGeometryPar();
82 
84 
87  static CDCGeometryPar& Instance(const CDCGeometry* = nullptr);
88 
90  void clear();
91 
93  void Print() const;
94 
96  void readFromDB(const CDCGeometry&);
97 
98  // /**
99  // * Read z-corrections.
100  // * @param GearDir Gear Dir.
101  // */
102  // void readDeltaz(const GearDir);
103  //
104  // /**
105  // * Read z-corrections from DB.
106  // *
107  // */
108  // void readDeltaz(const CDCGeometry&);
109 
110  // /**
111  // * Open a file
112  // * @param[in] ifs input file-stream
113  // * @param[in] fileName0 file-name on cdc/data directory
114  // */
115  // void openFile(std::ifstream& ifs, const std::string& fileName0) const;
116 
122  // void readWirePositionParams(EWirePosition set, const CDCGeometry*, const GearDir);
123  void readWirePositionParams(EWirePosition set, const CDCGeometry* geom);
124 
128  void setWirPosAlignParams();
129 
134 
140  void readXT(const GearDir& gbxParams, int mode = 0);
141 
147  void newReadXT(const GearDir& gbxParams, int mode = 0);
148 
152  void setXT();
153 
157  void setXtRel();
158 
164  void readSigma(const GearDir& gbxParams, int mode = 0);
165 
171  void newReadSigma(const GearDir& gbxParams, int mode = 0);
172 
178  void readFFactor(const GearDir& gbxParams, int mode = 0);
179 
183  void setSResol();
184 
188  void setFFactor();
189 
195  void readPropSpeed(const GearDir& gbxParams, int mode = 0);
196 
200  void setPropSpeed();
201 
207  void readT0(const GearDir& gbxParams, int mode = 0);
208 
212  void setT0();
213 
222  void calcMeanT0(double minT0 = 3800, double maxT0 = 5800, int maxIt = 10, double nStdv = 3, double epsi = 0.1);
223 
224  // /**
225  // * Read bad-wires (from a file).
226  // * @param GearDir Gear Dir.
227  // * @param mode 0: read simulation file, 1: read reconstruction file.
228  // */
229  // void readBadWire(const GearDir, int mode = 0);
230 
234  void setBadWire();
235 
239  // void readChMap(const GearDir);
240  void readChMap();
241 
245  void setChMap();
246 
252  void readTW(const GearDir& gbxParams, int mode = 0);
253 
259  void readEDepToADC(const GearDir& gbxParams, int mode = 0);
260 
264  void setTW();
265 
268 
276  double getEDepToADCConvFactor(unsigned short layer, unsigned short cell, double edep, double dx, double costh);
277 
278 
284  double getEDepToADCMainFactor(unsigned short layer, unsigned short cell, double costh = 0)
285  {
286  return m_eDepToADCParams[layer][cell][0] + m_eDepToADCParams[layer][cell][4] * (costh - m_eDepToADCParams[layer][cell][5]);
287  };
288 
293  double getEDepToADCSigma(unsigned short layer, unsigned short cell)
294  {
295  return m_eDepToADCParams[layer][cell][6];
296  };
297 
299 
302  void generateXML(const std::string& of);
303 
305 
308  std::string version() const;
309 
311 
314  double motherInnerR() const;
315 
317 
320  double motherOuterR() const;
321 
323 
326  double motherLength() const;
327 
329 
332  int momBound() const;
333 
335 
339  double momZ(int iBound) const;
340 
342 
346  double momRmin(int iBound) const;
347 
349 
354  unsigned cellId(unsigned layerId, const TVector3& position) const;
355 
357 
360  double innerRadiusOuterWall() const;
361 
363 
366  double outerRadiusOuterWall() const;
367 
369 
372  double zOuterWall() const;
373 
375 
378  double zOffsetOuterWall() const;
379 
381 
384  double innerRadiusInnerWall() const;
385 
387 
390  double outerRadiusInnerWall() const;
391 
393 
396  double zInnerWall() const;
397 
399 
402  double zOffsetInnerWall() const;
403 
405 
408  double senseWireDiameter() const;
409 
411 
414  double fieldWireDiameter() const;
415 
417 
420  unsigned nWireLayers() const;
421 
423 
427  unsigned nWiresInLayer(int layerId) const;
428 
430 
433  const double* innerRadiusWireLayer() const;
434 
436 
439  const double* outerRadiusWireLayer() const;
440 
442 
445  const double* zForwardWireLayer() const;
446 
448 
451  const double* zBackwardWireLayer() const;
452 
454 
458  double zOffsetWireLayer(unsigned i) const;
459 
461 
464  double getMeanT0() const;
465 
467 
473  const TVector3 wireForwardPosition(int layerId, int cellId, EWirePosition set = c_Base) const;
474 
476  const TVector3 wireForwardPosition(const WireID& wireID, EWirePosition set = c_Base) const
477  {
478  return wireForwardPosition(wireID.getICLayer(), wireID.getIWire(), set);
479  }
480 
482 
489  const TVector3 wireForwardPosition(int layerId, int cellId, double z, EWirePosition set = c_Base) const;
491  const TVector3 wireForwardPosition(const WireID& wireID, double z,
492  EWirePosition set = c_Base) const
493  {
494  return wireForwardPosition(wireID.getICLayer(), wireID.getIWire(), z, set);
495  }
496 
498 
504  const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set = c_Base) const;
505 
507  const TVector3 wireBackwardPosition(const WireID& wireID, EWirePosition set = c_Base) const
508  {
509  return wireBackwardPosition(wireID.getICLayer(), wireID.getIWire(), set);
510  }
511 
513 
520  const TVector3 wireBackwardPosition(int layerId, int cellId, double z, EWirePosition set = c_Base) const;
522  const TVector3 wireBackwardPosition(const WireID& wireID, double z, EWirePosition set = c_Base) const
523  {
524  return wireBackwardPosition(wireID.getICLayer(), wireID.getIWire(), z, set);
525  }
526 
528 
534  double getWireSagCoef(EWirePosition set, int layerId, int cellId) const;
535 
536 
538 
542  {
544  }
545 
547 
550  double getMinTrackLength() const
551  {
552  return m_minTrackLength;
553  }
554 
556 
558  bool isWireSagOn() const
559  {
560  return m_wireSag;
561  }
562 
564 
567  {
568  return m_modLeftRightFlag;
569  }
570 
571 
573 
577  float getT0(const WireID& wireID) const
578  {
579  // std::cout << wireID.getICLayer() <<" "<< wireID.getIWire() << std::endl;
580  return m_t0[wireID.getICLayer()][wireID.getIWire()];
581  }
582 
584 
588  unsigned short getBoardID(const WireID& wID) const
589  {
590  std::map<WireID, unsigned short>::const_iterator it = m_wireToBoard.find(wID);
591  unsigned short iret = (it != m_wireToBoard.end()) ? it->second : -999;
592  return iret;
593  }
594 
596 
600  unsigned short getChannelID(const WireID& wID) const
601  {
602  std::map<WireID, unsigned short>::const_iterator it = m_wireToChannel.find(wID);
603  unsigned short iret = (it != m_wireToChannel.end()) ? it->second : -999;
604  return iret;
605  }
606 
608 
613  const WireID getWireID(unsigned short bd, unsigned short ch) const
614  {
615  return WireID(m_boardAndChannelToWire[bd][ch]);
616  }
617 
619 
624  double getTimeWalk(const WireID& wID, unsigned short adcCount) const
625  {
626  std::map<WireID, unsigned short>::const_iterator it = m_wireToBoard.find(wID);
627  // std::cout <<"SL,L,W, bd#= " << wID.getISuperLayer() <<" "<< wID.getILayer() <<" "<< wID.getIWire() <<" "<< it->second << std::endl;
628  double tw = 0.;
629  if (it != m_wireToBoard.end() && adcCount > 0) {
630  if (m_twParamMode == 0) {
631  tw = m_timeWalkCoef[it->second][0] / sqrt(adcCount);
632  } else if (m_twParamMode == 1) {
633  double p0 = m_timeWalkCoef[it->second][0];
634  double p1 = m_timeWalkCoef[it->second][1];
635  tw = p0 * exp(-p1 * adcCount);
636  }
637  }
638  // std::cout <<"bd#,coef,adc,tw= " << it->second <<" "<< m_timeWalkCoef[it->second] <<" "<< adcCount <<" "<< tw << std::endl;
639  return tw;
640  }
641 
643 
645  void setShiftInSuperLayer();
646 
648 
652  signed short getShiftInSuperLayer(unsigned short iSuperLayer, unsigned short iLayer) const;
653 
655 
659  double senseWireR(int layerId) const;
660 
662 
666  double senseWireFZ(int layerId) const;
667 
669 
673  double senseWireBZ(int layerId) const;
674 
676 
680  double fieldWireR(int layerId) const;
681 
683 
687  double fieldWireFZ(int layerId) const;
688 
690 
694  double fieldWireBZ(int layerId) const;
695 
697 
701  int nShifts(int layerId) const;
702 
708  double offset(int layerID) const;
709 
711 
715  void setSenseWireR(int layerId, double r);
716 
718 
722  void setSenseWireFZ(int layerId, double fz);
723 
725 
729  void setSenseWireBZ(int layerId, double bz);
730 
735  inline unsigned short getTdcOffset() const
736  {
737  return m_tdcOffset;
738  }
739 
744  inline double getTdcBinWidth() const
745  {
746  return m_tdcBinWidth;
747  }
748 
754  inline double getNominalDriftV() const
755  {
756  return m_nominalDriftV;
757  }
758 
764  inline double getNominalPropSpeed() const
765  {
766  return m_nominalPropSpeed;
767  }
768 
774  inline double getNominalSpaceResol() const
775  {
776  return m_nominalSpaceResol;
777  }
778 
789  inline int getMaterialDefinitionMode() const
790  {
792  }
793 
802  inline int getSenseWireZposMode() const
803  {
804  return m_senseWireZposMode;
805  }
806 
812  inline double getBwdDeltaZ(unsigned short layerID) const
813  {
814  return m_dzSBackwardLayer[layerID];
815  }
816 
822  inline double getFwdDeltaZ(unsigned short layerID) const
823  {
824  return m_dzSForwardLayer[layerID];
825  }
826 
833  inline void setNominalSpaceResol(double resol)
834  {
835  m_nominalSpaceResol = resol;
836  }
837 
844  inline double getPropSpeedInv(const unsigned int layerID) const
845  {
846  return m_propSpeedInv[layerID];
847  }
848 
852  inline bool isBadWire(const WireID& wid)
853  {
854  // std::map<unsigned short, float>::iterator it = m_badWire.find(wid.getEWire());
855  // bool torf = (it != m_badWire.end()) ? true : false;
856  // return torf;
857  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isBadWire(wid) : false;
858  return torf;
859 
860  }
861 
865  inline bool isDeadWire(const WireID& wid, double& eff)
866  {
867  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isDeadWire(wid, eff) : false;
868  return torf;
869  }
870 
874  inline bool isHotWire(const WireID& wid)
875  {
876  bool torf = *m_badWireFromDB ? (*m_badWireFromDB)->isHotWire(wid) : false;
877  return torf;
878  }
879 
893  void getWireSagEffect(EWirePosition set, unsigned layerID, unsigned cellID, double zw, double& ywb_sag, double& ywf_sag) const;
894 
905  double getDriftV(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
906 
918  double getDriftLength(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI,
919  bool calculateMinTime = true, double minTime = 0.) const;
920 
929  double getDriftLength0(double dt, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
930 
938  double getMinDriftTime(unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
939 
949  double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const;
950 
959  double getSigma(double dist, unsigned short layer, unsigned short lr, double alpha = 0., double theta = 0.5 * M_PI) const;
960 
965  double getFudgeFactorForSigma(unsigned short target) const
966  {
967  return m_fudgeFactorForSigma[target];
968  }
969 
976  unsigned short getOldLeftRight(const TVector3& posOnWire, const TVector3& posOnTrack, const TVector3& momentum) const;
977 
985  unsigned short getNewLeftRightRaw(const TVector3& posOnWire, const TVector3& posOnTrack, const TVector3& momentum) const;
986 
993  double getAlpha(const TVector3& posOnWire, const TVector3& momentum) const;
994 
999  double getTheta(const TVector3& momentum) const;
1000 
1001 
1007  unsigned short getOutgoingLR(const unsigned short lr, const double alpha) const;
1008 
1009 
1014  double getOutgoingAlpha(const double alpha) const;
1015 
1016 
1022  double getOutgoingTheta(const double alpha, const double theta) const;
1023 
1024 
1028  void getClosestAlphaPoints(const double alpha, double& wal, unsigned short points[2], unsigned short lrs[2]) const;
1029 
1033  void getClosestAlphaPoints4Sgm(const double alpha, double& wal, unsigned short points[2], unsigned short lrs[2]) const;
1034 
1038  void getClosestThetaPoints(const double alpha, const double theta, double& wth, unsigned short points[2]) const;
1039 
1043  void getClosestThetaPoints4Sgm(const double alpha, const double theta, double& wth, unsigned short points[2]) const;
1044 
1050  void setDesignWirParam(unsigned layerID, unsigned cellID);
1051 
1057  void outputDesignWirParam(unsigned layerID, unsigned cellID) const;
1058 
1062  void setDisplacement();
1063 
1064  private:
1066  CDCGeometryPar(const CDCGeometry* = nullptr);
1071 
1072  bool m_debug;
1075  bool m_XTetc;
1081  bool m_wireSag;
1084  std::string m_version;
1094  unsigned short m_nAlphaPoints;
1095  unsigned short m_nThetaPoints;
1096  unsigned short m_nAlphaPoints4Sgm;
1097  unsigned short m_nThetaPoints4Sgm;
1098  signed short m_shiftInSuperLayer[nSuperLayers][8];
1100  double m_rWall[4];
1101  double m_zWall[4][2];
1103  double m_rSLayer[MAX_N_SLAYERS];
1104  double m_zSForwardLayer[MAX_N_SLAYERS];
1105  double m_dzSForwardLayer[MAX_N_SLAYERS];
1106  double m_zSBackwardLayer[MAX_N_SLAYERS];
1107  double m_dzSBackwardLayer[MAX_N_SLAYERS];
1108  double m_rFLayer[MAX_N_FLAYERS];
1109  double m_zFForwardLayer[MAX_N_FLAYERS];
1110  double m_zFBackwardLayer[MAX_N_FLAYERS];
1111  double m_offSet[MAX_N_SLAYERS];
1112  double m_cellSize[MAX_N_SLAYERS];
1113  int m_nShifts[MAX_N_SLAYERS];
1114  unsigned m_nWires[MAX_N_SLAYERS];
1123  double m_momZ[7];
1124  double m_momRmin[7];
1126  // double m_bwdDz[MAX_N_SLAYERS]; /*!< Tentative backward z-corrections.*/
1127  // double m_fwdDz[MAX_N_SLAYERS]; /*!< Tentative forward z-corrections.*/
1128 
1132  float m_FWirPos[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1133  float m_BWirPos[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1134  float m_WireSagCoef[MAX_N_SLAYERS][MAX_N_SCELLS];
1136  float m_FWirPosMisalign[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1137  float m_BWirPosMisalign[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1138  float m_WireSagCoefMisalign[MAX_N_SLAYERS][MAX_N_SCELLS];
1140  float m_FWirPosAlign[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1141  float m_BWirPosAlign[MAX_N_SLAYERS][MAX_N_SCELLS][3];
1142  float m_WireSagCoefAlign[MAX_N_SLAYERS][MAX_N_SCELLS];
1143  float m_eDepToADCParams[MAX_N_SLAYERS][MAX_N_SCELLS][7] = {0};
1145  float m_alphaPoints[maxNAlphaPoints];
1146  float m_thetaPoints[maxNThetaPoints];
1147  float m_alphaPoints4Sgm[maxNAlphaPoints];
1148  float m_thetaPoints4Sgm[maxNThetaPoints];
1150  float m_XT[MAX_N_SLAYERS][2][maxNAlphaPoints][maxNThetaPoints][nXTParams];
1151  float m_Sigma[MAX_N_SLAYERS][2][maxNAlphaPoints][maxNThetaPoints][nSigmaParams];
1152  float m_propSpeedInv[MAX_N_SLAYERS];
1153  float m_t0[MAX_N_SLAYERS][MAX_N_SCELLS] = {0};
1154  float m_timeWalkCoef[nBoards][2];
1156  // float m_meanT0; /*!< mean t0 over all wires. */
1157  double m_meanT0;
1159  std::map<WireID, unsigned short> m_wireToBoard;
1160  std::map<WireID, unsigned short> m_wireToChannel;
1161  unsigned short m_boardAndChannelToWire[nBoards][48];
1163  // std::map<unsigned short, float> m_badWire; /*!< list of bad-wires. */
1164 
1165  unsigned short m_tdcOffset;
1167  double m_tdcBinWidth;
1192  };
1193 
1194 //-----------------------------------------------------------------------------
1195 // Inline functions
1196 //-----------------------------------------------------------------------------
1197  inline std::string CDCGeometryPar::version() const
1198  {
1199  return m_version;
1200  }
1201 
1202  inline double CDCGeometryPar::momZ(int iBound) const
1203  {
1204  return m_momZ[iBound];
1205  }
1206 
1207  inline double CDCGeometryPar::momRmin(int iBound) const
1208  {
1209  return m_momRmin[iBound];
1210  }
1211 
1212  inline int CDCGeometryPar::nShifts(int layerID) const
1213  {
1214  return m_nShifts[layerID];
1215  }
1216 
1217  inline double CDCGeometryPar::offset(int layerID) const
1218  {
1219  return m_offSet[layerID];
1220  }
1221 
1222  inline unsigned CDCGeometryPar::nWiresInLayer(int layerID) const
1223  {
1224  return m_nWires[layerID];
1225  }
1226 
1227  inline void CDCGeometryPar::setSenseWireR(int layerId, double r)
1228  {
1229  m_rSLayer[layerId] = r;
1230  }
1231 
1232  inline void CDCGeometryPar::setSenseWireFZ(int layerId, double fz)
1233  {
1234  m_zSForwardLayer[layerId] = fz;
1235  }
1236 
1237  inline void CDCGeometryPar::setSenseWireBZ(int layerId, double bz)
1238  {
1239  m_zSBackwardLayer[layerId] = bz;
1240  }
1241 
1242  inline double CDCGeometryPar::senseWireR(int layerID) const
1243  {
1244  return m_rSLayer[layerID];
1245  }
1246 
1247  inline double CDCGeometryPar::senseWireFZ(int layerID) const
1248  {
1249  return m_zSForwardLayer[layerID];
1250  }
1251 
1252  inline double CDCGeometryPar::senseWireBZ(int layerID) const
1253  {
1254  return m_zSBackwardLayer[layerID];
1255  }
1256 
1257  inline double CDCGeometryPar::fieldWireR(int layerID) const
1258  {
1259  return m_rFLayer[layerID];
1260  }
1261 
1262  inline double CDCGeometryPar::fieldWireFZ(int layerID) const
1263  {
1264  return m_zFForwardLayer[layerID];
1265  }
1266 
1267  inline double CDCGeometryPar::fieldWireBZ(int layerID) const
1268  {
1269  return m_zFBackwardLayer[layerID];
1270  }
1271 
1273  {
1274  return m_rWall[2];
1275  }
1276 
1278  {
1279  return m_rWall[3];
1280  }
1281 
1282  inline double CDCGeometryPar::zOuterWall() const
1283  {
1284  return (m_zWall[2][1] - m_zWall[2][0]);
1285  }
1286 
1288  {
1289  return m_rWall[0];
1290  }
1291 
1293  {
1294  return m_rWall[1];
1295  }
1296 
1297  inline double CDCGeometryPar::zInnerWall() const
1298  {
1299  return (m_zWall[0][1] - m_zWall[0][0]);
1300  }
1301 
1302  inline double CDCGeometryPar::zOffsetOuterWall() const
1303  {
1304  return (m_zWall[2][0] + zOuterWall() / 2);
1305  }
1306 
1307  inline double CDCGeometryPar::zOffsetInnerWall() const
1308  {
1309  return (m_zWall[0][0] + zInnerWall() / 2);
1310  }
1311 
1313  {
1314  return m_senseWireDiameter;
1315  }
1316 
1318  {
1319  return m_fieldWireDiameter;
1320  }
1321 
1322  inline unsigned CDCGeometryPar::nWireLayers() const
1323  {
1324  return MAX_N_SLAYERS;
1325  }
1326 
1327  inline const double* CDCGeometryPar::zForwardWireLayer() const
1328  {
1329  return m_zSForwardLayer;
1330  }
1331 
1332  inline const double* CDCGeometryPar::zBackwardWireLayer() const
1333  {
1334  return m_zSBackwardLayer;
1335  }
1336 
1337  inline double CDCGeometryPar::zOffsetWireLayer(unsigned i) const
1338  {
1339  return (m_zSBackwardLayer[i] + (m_zSForwardLayer[i] - m_zSBackwardLayer[i]) / 2);
1340  }
1341 
1342  inline double CDCGeometryPar::getMeanT0() const
1343  {
1344  return m_meanT0;
1345  }
1346 
1347  } // end of namespace CDC
1349 } // 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.
signed short m_shiftInSuperLayer[nSuperLayers][8]
shift in phi-direction wrt the 1st layer in each super layer
void readTW(const GearDir &gbxParams, int mode=0)
Read time-walk parameter.
double m_cellSize[MAX_N_SLAYERS]
The array to store cell size in each sense wire layer.
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_BWirPos[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
DBObjPtr< CDCBadWires > * m_badWireFromDB
bad-wires retrieved from DB.
float m_FWirPos[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
double motherLength() const
The method to get cdc mother volume length.
double getWireSagCoef(EWirePosition set, int layerId, int cellId) const
Returns coefficient for the sense wire sag.
void readT0(const GearDir &gbxParams, int mode=0)
Read t0 parameters (from a file).
void setT0()
Set t0 parameters (from DB)
virtual ~CDCGeometryPar()
Destructor.
double fieldWireDiameter() const
Returns diameter of the field wire.
double m_dzSBackwardLayer[MAX_N_SLAYERS]
Corrections for backward z position of sense wire layers.
double m_fudgeFactorForSigma[3]
Fuge factor for space resol.
double outerRadiusInnerWall() const
Returns the outer radius of the inner wall.
float m_FWirPosAlign[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
double zOuterWall() const
Returns the length of the outer wall in Z.
unsigned short getOldLeftRight(const TVector3 &posOnWire, const TVector3 &posOnTrack, const TVector3 &momentum) const
Returns old left/right.
int m_sigmaParamMode
Mode for sigma parameterization.
bool m_alignment
Switch for alignment.
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.
int m_nShifts[MAX_N_SLAYERS]
The array to store shifted cell number in each sense wire layer.
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.
void newReadSigma(const GearDir &gbxParams, int mode=0)
Read spatial resolution table in new format.
const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
void setEDepToADCConversions()
Set edep-to-ADC conversion params.
double m_nominalPropSpeed
Nominal propagation speed of the sense wire (27.25 cm/nsec).
unsigned short getNewLeftRightRaw(const TVector3 &posOnWire, const TVector3 &posOnTrack, const TVector3 &momentum) const
Returns new left/right_raw.
void setNominalSpaceResol(double resol)
Set the nominal spacial resolution in the unit of um.
int nShifts(int layerId) const
Returns number shift.
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.
float m_WireSagCoef[MAX_N_SLAYERS][MAX_N_SCELLS]
Wire sag coefficient for each cell; ibid.
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)
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'.
const TVector3 wireForwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
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.
double m_offSet[MAX_N_SLAYERS]
The array to store z offset of sense wire layers.
const TVector3 wireBackwardPosition(const WireID &wireID, double z, EWirePosition set=c_Base) const
The same function but in a different input format.
float m_FWirPosMisalign[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
unsigned short m_nThetaPoints4Sgm
No.
CDCGeometryPar & operator=(const CDCGeometryPar &)
Singleton class.
void generateXML(const std::string &of)
Generate an xml file used in gearbox.
float m_WireSagCoefMisalign[MAX_N_SLAYERS][MAX_N_SCELLS]
Wire sag coefficient incl.
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).
float m_thetaPoints[maxNThetaPoints]
theta sampling points for xt (rad)
DBObjPtr< HardwareClockSettings > m_clockSettings
hardware clock settings
double getNominalSpaceResol() const
Return the nominal spacial resolution.
double getThresholdEnerguDeposit() const
Returns threshold for energy deposit in one G4 step.
double m_minTrackLength
Minimum track length for G4 step.
double fieldWireR(int layerId) const
Returns radius of field wire in each layer.
double getMinTrackLength() const
Returns the minimum track length required in one G4 step (only secondary particles which pass this cr...
bool isDeadWire(const WireID &wid, double &eff)
Inquire if the wire is dead.
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 m_zSForwardLayer[MAX_N_SLAYERS]
The array to store forward z position of sense wire layers.
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.
unsigned m_nWires[MAX_N_SLAYERS]
The array to store the wire number in each sense wire layre.
double m_clockFreq4TDC
Clock frequency used for TDC (GHz).
bool isWireSagOn() const
Returns on/off for sense wire sag in FullSim.
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.
const TVector3 wireForwardPosition(const WireID &wireID, double z, EWirePosition set=c_Base) const
The same function but in a different input format.
void setSenseWireR(int layerId, double r)
Set radius of sense wire in each layer.
double m_zFForwardLayer[MAX_N_FLAYERS]
The array to store forward z position of field wire layers.
std::string m_version
The version of geometry parameters.
double senseWireDiameter() const
Returns diameter of the sense wire.
bool m_linearInterpolationOfXT
Switch for linear interpolation of xt.
double m_zFBackwardLayer[MAX_N_FLAYERS]
The array to store backward z position of field wire layers.
double getAlpha(const TVector3 &posOnWire, const TVector3 &momentum) const
Returns track incident angle in rphi plane (alpha in rad.).
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.
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).
float m_BWirPosMisalign[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
CDCGeometryPar(const CDCGeometry *=nullptr)
Singleton class.
unsigned short getOutgoingLR(const unsigned short lr, const double alpha) const
Converts incoming-lr to outgoing-lr.
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.
double zInnerWall() const
Returns the length of the inner wall in Z.
double m_zSBackwardLayer[MAX_N_SLAYERS]
The array to store backward z position of sense wire layers.
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 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.
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.
float m_Sigma[MAX_N_SLAYERS][2][maxNAlphaPoints][maxNThetaPoints][nSigmaParams]
position resulution for each layer.
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.
unsigned short m_boardAndChannelToWire[nBoards][48]
array relating board-channel-id and wire-id.
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.
double getTheta(const TVector3 &momentum) const
Returns track incident angle (theta in rad.).
float m_eDepToADCParams[MAX_N_SLAYERS][MAX_N_SCELLS][7]
edep-to-ADC conv.
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).
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)
float m_alphaPoints[maxNAlphaPoints]
alpha sampling points for xt (rad)
const TVector3 wireBackwardPosition(const WireID &wireID, EWirePosition set=c_Base) const
The same function but in a different input format.
int m_xtParamMode
Mode for xt parameterization.
CDCGeometryPar(const CDCGeometryPar &)
Singleton class.
float m_alphaPoints4Sgm[maxNAlphaPoints]
alpha sampling points for sigma (rad)
double fieldWireFZ(int layerId) const
Returns forward z position of field wire in each layer.
float m_timeWalkCoef[nBoards][2]
coefficients for time walk.
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.
void readChMap()
Read channel map between wire-id and electronics-id.
double m_fieldWireDiameter
The diameter of field wires.
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 outerRadiusOuterWall() const
Returns the outer radius of the outer wall.
void setWirPosMisalignParams()
Set wire misalignment params.
double m_momZ[7]
Z-cordinates of the cdc mother volume (7 segments).
double m_dzSForwardLayer[MAX_N_SLAYERS]
Corrections for forward z position of sense wire layers.
double m_momRmin[7]
R_min of the cdc mother volume (7 segments).
int getSenseWireZposMode() const
Return mode for sense wire z position.
double m_rSLayer[MAX_N_SLAYERS]
The array to store radius of sense wire layers.
void setTW()
Set time-walk parameters.
void setSResol()
Set spatial resolution (from DB).
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.
DBObjPtr< CDCAlignment > * m_alignmentFromDB
alignment params.
float m_thetaPoints4Sgm[maxNThetaPoints]
theta sampling points for sigma (rad)
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.
void Print() const
Print some debug information.
double m_rFLayer[MAX_N_FLAYERS]
The array to store radius of field wire layers.
const TVector3 wireForwardPosition(const WireID &wireID, EWirePosition set=c_Base) const
The same function but in a different input format.
void readFFactor(const GearDir &gbxParams, int mode=0)
Read fudge factors.
unsigned short m_nThetaPoints
No.
float m_XT[MAX_N_SLAYERS][2][maxNAlphaPoints][maxNThetaPoints][nXTParams]
XT-relation coefficients for each layer, Left/Right, entrance angle and polar angle.
double m_maxSpaceResol
max space resolution allowed (cm).
float m_WireSagCoefAlign[MAX_N_SLAYERS][MAX_N_SCELLS]
Wire sag coefficient incl.
double m_thresholdEnergyDeposit
Energy thresh.
void readXT(const GearDir &gbxParams, int mode=0)
Read XT-relation table.
float m_BWirPosAlign[MAX_N_SLAYERS][MAX_N_SCELLS][3]
Wire position incl.
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.
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.
float m_t0[MAX_N_SLAYERS][MAX_N_SCELLS]
t0 for each sense-wire (in nsec).
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.
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).
unsigned cellId(unsigned layerId, const TVector3 &position) const
The method to get cell id based on given layer id and the position.
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).
float m_propSpeedInv[MAX_N_SLAYERS]
Inverse of propagation speed of the sense wire.
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
Abstract base class for different kinds of events.