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  * $Date: 2012/03/02 19:47:32 $
5  * $Revision: 1.4 $
6  * \author A. Vilela Pereira
7  */
8 
17 
18 using namespace std;
19 using namespace edm;
20 
21 namespace dtCalibration {
22 
23 DTTTrigFillWithAverage::DTTTrigFillWithAverage(const ParameterSet& pset):foundAverage_(false) {
24  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
25 }
26 
28 
30  // Get tTrig record from DB
31  ESHandle<DTTtrig> tTrig;
32  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
33  tTrigMap_ = &*tTrig;
34 
35  // Get geometry from Event Setup
36  setup.get<MuonGeometryRecord>().get(muonGeom_);
37 }
38 
40  float tTrigMean,tTrigSigma, kFactor;
41  int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
42  if(!status){
43  return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
44  } else {
46  float corrMean = initialTTrig_.aveMean;
47  float corrSigma = initialTTrig_.aveSigma;
48  float corrKFactor = initialTTrig_.aveKFactor;
49  return DTTTrigData(corrMean,corrSigma,corrKFactor); //FIXME: kFactor is not anymore a unique one
50  }
51 }
52 
54  //Get the superlayers list
55  vector<DTSuperLayer*> dtSupLylist = muonGeom_->superLayers();
56 
57  float aveMean = 0.;
58  float ave2Mean = 0.;
59  float aveSigma = 0.;
60  float ave2Sigma = 0.;
61  float aveKFactor = 0.;
62  int nIter = 0;
63 
64  for(vector<DTSuperLayer*>::const_iterator sl = muonGeom_->superLayers().begin();
65  sl != muonGeom_->superLayers().end(); ++sl) {
66  float tTrigMean,tTrigSigma,kFactor;
67  int status = tTrigMap_->get((*sl)->id(),tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
68  if(!status){
69  ++nIter;
70  aveMean += tTrigMean;
71  ave2Mean += tTrigMean*tTrigMean;
72  aveSigma += tTrigSigma;
73  ave2Sigma += tTrigSigma*tTrigSigma;
74  aveKFactor += kFactor;
75  }
76  }
77 
78  // Compute average
79  aveMean /= nIter;
80  float rmsMean = ave2Mean/(nIter - 1) - aveMean*aveMean;
81  rmsMean = sqrt(rmsMean);
82  aveSigma /= nIter;
83  float rmsSigma = ave2Sigma/(nIter - 1) - aveSigma*aveSigma;
84  rmsSigma = sqrt(rmsSigma);
85  aveKFactor /= nIter;
86 
87  initialTTrig_.aveMean = aveMean;
88  initialTTrig_.rmsMean = rmsMean;
89  initialTTrig_.aveSigma = aveSigma;
90  initialTTrig_.rmsSigma = rmsSigma;
91  initialTTrig_.aveKFactor = aveKFactor;
92 
93  LogVerbatim("Calibration") << "[DTTTrigFillWithAverage] Found from " << nIter << " SL's\n"
94  << " average tTrig mean: " << aveMean << "\n"
95  << " tTrig mean RMS: " << rmsMean << "\n"
96  << " average tTrig sigma: " << aveSigma << "\n"
97  << " tTrig sigma RMS: " << rmsSigma << "\n"
98  << " kFactor mean: " << aveKFactor;
99  foundAverage_ = true;
100 }
101 
102 } // namespace
T getUntrackedParameter(std::string const &, T const &) const
struct dtCalibration::DTTTrigFillWithAverage::@54 initialTTrig_
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:87
const T & get() const
Definition: EventSetup.h:55
tuple status
Definition: ntuplemaker.py:245
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual DTTTrigData correction(const DTSuperLayerId &)