Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:35:35

0001 #ifndef CalibTracker_SiStripLorentzAngle_SiStripLorentzAngleCalibrationHelper_h
0002 #define CalibTracker_SiStripLorentzAngle_SiStripLorentzAngleCalibrationHelper_h
0003 
0004 // user includes
0005 #include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
0006 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
0007 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0008 
0009 // system includes
0010 #include <string>
0011 
0012 // for ROOT
0013 #include "TString.h"
0014 #include "TFitResult.h"
0015 #include "TF1.h"
0016 
0017 namespace siStripLACalibration {
0018 
0019   inline std::string moduleLocationType(const uint32_t& mod, const TrackerTopology* tTopo) {
0020     const SiStripDetId detid(mod);
0021     std::string subdet = "";
0022     unsigned int layer = 0;
0023     if (detid.subDetector() == SiStripDetId::TIB) {
0024       subdet = "TIB";
0025       layer = tTopo->layer(mod);
0026     } else if (detid.subDetector() == SiStripDetId::TOB) {
0027       subdet = "TOB";
0028       layer = tTopo->layer(mod);
0029     }
0030 
0031     if (layer == 0)
0032       return subdet;
0033 
0034     std::string type = (detid.stereo() ? "s" : "a");
0035     std::string d_l_t = Form("%s_L%d%s", subdet.c_str(), layer, type.c_str());
0036     return d_l_t;
0037   }
0038 
0039   // SiStripLatency::singleReadOutMode() returns
0040   // 1: all in peak, 0: all in deco, -1: mixed state
0041   enum { k_DeconvolutionMode = 0, k_PeakMode = 1 };
0042 
0043   //_____________________________________________________________________
0044   inline const std::string fieldAsString(const float& inputField) {
0045     std::string theMagFieldStr = std::to_string(inputField);
0046     size_t dotPosition = theMagFieldStr.find('.');
0047     if (dotPosition != std::string::npos) {
0048       theMagFieldStr = theMagFieldStr.substr(0, dotPosition + 2);  // +2 to include one decimal place
0049     }
0050     return theMagFieldStr;
0051   }
0052 
0053   //_____________________________________________________________________
0054   inline const std::string apvModeAsString(const SiStripLatency* latency) {
0055     if (latency) {
0056       switch (latency->singleReadOutMode()) {
0057         case k_PeakMode:
0058           return "PEAK";  // peak mode
0059         case k_DeconvolutionMode:
0060           return "DECO";  // deco mode
0061         default:
0062           return "UNDEF";  // undefined
0063       }
0064     } else {
0065       return "UNDEF";
0066     }
0067   }
0068 
0069   //_____________________________________________________________________
0070   inline double fitFunction(double* x, double* par) {
0071     double a = par[0];
0072     double thetaL = par[1];
0073     double b = par[2];
0074 
0075     double tanThetaL = std::tan(thetaL);
0076     double value = a * std::abs(std::tan(x[0]) - tanThetaL) + b;
0077 
0078     //TF1::RejectPoint();  // Reject points outside the fit range
0079     return value;
0080   }
0081 }  // namespace siStripLACalibration
0082 #endif