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  } else if (detid.subDetector() == SiStripDetId::TOB) {
27  subdet = "TOB";
28  layer = tTopo->layer(mod);
29  }
30 
31  if (layer == 0)
32  return subdet;
33 
34  std::string type = (detid.stereo() ? "s" : "a");
35  std::string d_l_t = Form("%s_L%d%s", subdet.c_str(), layer, type.c_str());
36  return d_l_t;
37  }
38 
39  // SiStripLatency::singleReadOutMode() returns
40  // 1: all in peak, 0: all in deco, -1: mixed state
41  enum { k_DeconvolutionMode = 0, k_PeakMode = 1 };
42 
43  //_____________________________________________________________________
44  inline const std::string fieldAsString(const float& inputField) {
45  std::string theMagFieldStr = std::to_string(inputField);
46  size_t dotPosition = theMagFieldStr.find('.');
47  if (dotPosition != std::string::npos) {
48  theMagFieldStr = theMagFieldStr.substr(0, dotPosition + 2); // +2 to include one decimal place
49  }
50  return theMagFieldStr;
51  }
52 
53  //_____________________________________________________________________
55  if (latency) {
56  switch (latency->singleReadOutMode()) {
57  case k_PeakMode:
58  return "PEAK"; // peak mode
60  return "DECO"; // deco mode
61  default:
62  return "UNDEF"; // undefined
63  }
64  } else {
65  return "UNDEF";
66  }
67  }
68 
69  //_____________________________________________________________________
70  inline double fitFunction(double* x, double* par) {
71  double a = par[0];
72  double thetaL = par[1];
73  double b = par[2];
74 
75  double tanThetaL = std::tan(thetaL);
76  double value = a * std::abs(std::tan(x[0]) - tanThetaL) + b;
77 
78  //TF1::RejectPoint(); // Reject points outside the fit range
79  return value;
80  }
81 } // namespace siStripLACalibration
82 #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)