CMS 3D CMS Logo

SiStripLorentzAngleCalibrationHelpers.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripLorentzAngle_SiStripLorentzAngleCalibrationHelper_h
2 #define CalibTracker_SiStripLorentzAngle_SiStripLorentzAngleCalibrationHelper_h
3 
4 // user includes
8 
9 // system includes
10 #include <string>
11 
12 // for ROOT
13 #include "TString.h"
14 #include "TFitResult.h"
15 #include "TF1.h"
16 
18 
19  inline std::string moduleLocationType(const uint32_t& mod, const TrackerTopology* tTopo) {
20  const SiStripDetId detid(mod);
21  std::string subdet = "";
22  unsigned int layer = 0;
23  if (detid.subDetector() == SiStripDetId::TIB) {
24  subdet = "TIB";
25  layer = tTopo->layer(mod);
26  }
27 
28  if (detid.subDetector() == SiStripDetId::TOB) {
29  subdet = "TOB";
30  layer = tTopo->layer(mod);
31  }
32 
33  std::string type = (detid.stereo() ? "s" : "a");
34  std::string d_l_t = Form("%s_L%d%s", subdet.c_str(), layer, type.c_str());
35 
36  if (layer == 0)
37  return subdet;
38  return d_l_t;
39  }
40 
41  // SiStripLatency::singleReadOutMode() returns
42  // 1: all in peak, 0: all in deco, -1: mixed state
43  enum { k_DeconvolutionMode = 0, k_PeakMode = 1 };
44 
45  //_____________________________________________________________________
46  inline const std::string fieldAsString(const float& inputField) {
47  std::string theMagFieldStr = std::to_string(inputField);
48  size_t dotPosition = theMagFieldStr.find('.');
49  if (dotPosition != std::string::npos) {
50  theMagFieldStr = theMagFieldStr.substr(0, dotPosition + 2); // +2 to include one decimal place
51  }
52  return theMagFieldStr;
53  }
54 
55  //_____________________________________________________________________
57  if (latency) {
58  switch (latency->singleReadOutMode()) {
59  case k_PeakMode:
60  return "PEAK"; // peak mode
62  return "DECO"; // deco mode
63  default:
64  return "UNDEF"; // undefined
65  }
66  } else {
67  return "UNDEF";
68  }
69  }
70 
71  //_____________________________________________________________________
72  inline double fitFunction(double* x, double* par) {
73  double a = par[0];
74  double thetaL = par[1];
75  double b = par[2];
76 
77  double tanThetaL = std::tan(thetaL);
78  double value = a * std::abs(std::tan(x[0]) - tanThetaL) + b;
79 
80  //TF1::RejectPoint(); // Reject points outside the fit range
81  return value;
82  }
83 } // namespace siStripLACalibration
84 #endif
double fitFunction(double *x, double *par)
SubDetector subDetector() const
Definition: SiStripDetId.h:105
static std::string to_string(const XMLCh *ch)
unsigned int layer(const DetId &id) const
uint32_t stereo() const
Definition: SiStripDetId.h:168
const std::string fieldAsString(const float &inputField)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
const std::string apvModeAsString(const SiStripLatency *latency)
static constexpr auto TOB
Definition: SiStripDetId.h:39
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
double b
Definition: hdecay.h:120
static constexpr auto TIB
Definition: SiStripDetId.h:37
double a
Definition: hdecay.h:121
float x
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::string moduleLocationType(const uint32_t &mod, const TrackerTopology *tTopo)