CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DTTTrigFillWithAverage.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author A. Vilela Pereira
5  */
6 
15 
16 using namespace std;
17 using namespace edm;
18 
19 namespace dtCalibration {
20 
21  DTTTrigFillWithAverage::DTTTrigFillWithAverage(const ParameterSet& pset, edm::ConsumesCollector cc)
22  : foundAverage_(false) {
23  ttrigToken_ =
26  }
27 
29 
31  // Get tTrig record from DB
32  ESHandle<DTTtrig> tTrig;
33  tTrig = setup.getHandle(ttrigToken_);
34  tTrigMap_ = &*tTrig;
35 
36  // Get geometry from Event Setup
38  }
39 
41  float tTrigMean, tTrigSigma, kFactor;
42  int status = tTrigMap_->get(slId, tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
43  if (!status) {
44  return DTTTrigData(tTrigMean, tTrigSigma, kFactor);
45  } else {
46  if (!foundAverage_)
47  getAverage();
48  float corrMean = initialTTrig_.aveMean;
49  float corrSigma = initialTTrig_.aveSigma;
50  float corrKFactor = initialTTrig_.aveKFactor;
51  return DTTTrigData(corrMean, corrSigma, corrKFactor); //FIXME: kFactor is not anymore a unique one
52  }
53  }
54 
56  //Get the superlayers list
57  vector<const DTSuperLayer*> dtSupLylist = muonGeom_->superLayers();
58 
59  float aveMean = 0.;
60  float ave2Mean = 0.;
61  float aveSigma = 0.;
62  float ave2Sigma = 0.;
63  float aveKFactor = 0.;
64  int nIter = 0;
65 
66  for (auto sl = muonGeom_->superLayers().begin(); sl != muonGeom_->superLayers().end(); ++sl) {
67  float tTrigMean, tTrigSigma, kFactor;
68  int status = tTrigMap_->get((*sl)->id(), tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
69  if (!status) {
70  ++nIter;
71  aveMean += tTrigMean;
72  ave2Mean += tTrigMean * tTrigMean;
73  aveSigma += tTrigSigma;
74  ave2Sigma += tTrigSigma * tTrigSigma;
75  aveKFactor += kFactor;
76  }
77  }
78 
79  // Compute average
80  aveMean /= nIter;
81  float rmsMean = ave2Mean / (nIter - 1) - aveMean * aveMean;
82  rmsMean = sqrt(rmsMean);
83  aveSigma /= nIter;
84  float rmsSigma = ave2Sigma / (nIter - 1) - aveSigma * aveSigma;
85  rmsSigma = sqrt(rmsSigma);
86  aveKFactor /= nIter;
87 
88  initialTTrig_.aveMean = aveMean;
89  initialTTrig_.rmsMean = rmsMean;
90  initialTTrig_.aveSigma = aveSigma;
91  initialTTrig_.rmsSigma = rmsSigma;
92  initialTTrig_.aveKFactor = aveKFactor;
93 
94  LogVerbatim("Calibration") << "[DTTTrigFillWithAverage] Found from " << nIter << " SL's\n"
95  << " average tTrig mean: " << aveMean << "\n"
96  << " tTrig mean RMS: " << rmsMean << "\n"
97  << " average tTrig sigma: " << aveSigma << "\n"
98  << " tTrig sigma RMS: " << rmsSigma << "\n"
99  << " kFactor mean: " << aveKFactor;
100  foundAverage_ = true;
101  }
102 
103 } // namespace dtCalibration
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
void setES(const edm::EventSetup &setup) override
list status
Definition: mps_update.py:107
T sqrt(T t)
Definition: SSEVec.h:19
DTTTrigData correction(const DTSuperLayerId &) override
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
struct dtCalibration::DTTTrigFillWithAverage::@63 initialTTrig_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_