test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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):foundAverage_(false) {
22  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
23 }
24 
26 
28  // Get tTrig record from DB
29  ESHandle<DTTtrig> tTrig;
30  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
31  tTrigMap_ = &*tTrig;
32 
33  // Get geometry from Event Setup
34  setup.get<MuonGeometryRecord>().get(muonGeom_);
35 }
36 
38  float tTrigMean,tTrigSigma, kFactor;
39  int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
40  if(!status){
41  return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
42  } else {
44  float corrMean = initialTTrig_.aveMean;
45  float corrSigma = initialTTrig_.aveSigma;
46  float corrKFactor = initialTTrig_.aveKFactor;
47  return DTTTrigData(corrMean,corrSigma,corrKFactor); //FIXME: kFactor is not anymore a unique one
48  }
49 }
50 
52  //Get the superlayers list
53  vector<const DTSuperLayer*> dtSupLylist = muonGeom_->superLayers();
54 
55  float aveMean = 0.;
56  float ave2Mean = 0.;
57  float aveSigma = 0.;
58  float ave2Sigma = 0.;
59  float aveKFactor = 0.;
60  int nIter = 0;
61 
62  for(auto sl = muonGeom_->superLayers().begin();
63  sl != muonGeom_->superLayers().end(); ++sl) {
64  float tTrigMean,tTrigSigma,kFactor;
65  int status = tTrigMap_->get((*sl)->id(),tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
66  if(!status){
67  ++nIter;
68  aveMean += tTrigMean;
69  ave2Mean += tTrigMean*tTrigMean;
70  aveSigma += tTrigSigma;
71  ave2Sigma += tTrigSigma*tTrigSigma;
72  aveKFactor += kFactor;
73  }
74  }
75 
76  // Compute average
77  aveMean /= nIter;
78  float rmsMean = ave2Mean/(nIter - 1) - aveMean*aveMean;
79  rmsMean = sqrt(rmsMean);
80  aveSigma /= nIter;
81  float rmsSigma = ave2Sigma/(nIter - 1) - aveSigma*aveSigma;
82  rmsSigma = sqrt(rmsSigma);
83  aveKFactor /= nIter;
84 
85  initialTTrig_.aveMean = aveMean;
86  initialTTrig_.rmsMean = rmsMean;
87  initialTTrig_.aveSigma = aveSigma;
88  initialTTrig_.rmsSigma = rmsSigma;
89  initialTTrig_.aveKFactor = aveKFactor;
90 
91  LogVerbatim("Calibration") << "[DTTTrigFillWithAverage] Found from " << nIter << " SL's\n"
92  << " average tTrig mean: " << aveMean << "\n"
93  << " tTrig mean RMS: " << rmsMean << "\n"
94  << " average tTrig sigma: " << aveSigma << "\n"
95  << " tTrig sigma RMS: " << rmsSigma << "\n"
96  << " kFactor mean: " << aveKFactor;
97  foundAverage_ = true;
98 }
99 
100 } // namespace
T getUntrackedParameter(std::string const &, T const &) const
T sqrt(T t)
Definition: SSEVec.h:48
virtual void setES(const edm::EventSetup &setup)
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:85
const T & get() const
Definition: EventSetup.h:55
struct dtCalibration::DTTTrigFillWithAverage::@63 initialTTrig_
volatile std::atomic< bool > shutdown_flag false
tuple status
Definition: ntuplemaker.py:245
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual DTTTrigData correction(const DTSuperLayerId &)