CMS 3D CMS Logo

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_ =
24  cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")));
26  }
27 
29 
31  // Get tTrig record from DB
33  tTrig = setup.getHandle(ttrigToken_);
34  tTrigMap_ = &*tTrig;
35 
36  // Get geometry from Event Setup
37  muonGeom_ = setup.getHandle(dtGeomToken_);
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;
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;
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
void setES(const edm::EventSetup &setup) override
struct dtCalibration::DTTTrigFillWithAverage::@65 initialTTrig_
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
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
HLT enums.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86