CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTTrigMatchRPhi.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.3 $
6  * \author A. Vilela Pereira
7  */
8 
9 #include "DTTTrigMatchRPhi.h"
16 
17 #include <math.h>
18 
19 using namespace std;
20 using namespace edm;
21 
22 namespace dtCalibration {
23 
24 DTTTrigMatchRPhi::DTTTrigMatchRPhi(const ParameterSet& pset) {
25  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
26 }
27 
28 DTTTrigMatchRPhi::~DTTTrigMatchRPhi() {}
29 
30 void DTTTrigMatchRPhi::setES(const EventSetup& setup) {
31  // Get tTrig record from DB
32  ESHandle<DTTtrig> tTrig;
33  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
34  tTrigMap_ = &*tTrig;
35 }
36 
37 DTTTrigData DTTTrigMatchRPhi::correction(const DTSuperLayerId& slId) {
38 
39  float tTrigMean,tTrigSigma,kFactor;
40  int status = tTrigMap_->get(slId,tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
41  // RZ superlayers return the current value
42  if(slId.superLayer() == 2){
43  if(status != 0) throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
44  << slId << endl;
45  return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
46  } else{
47  DTSuperLayerId partnerSLId(slId.chamberId(),(slId.superLayer() == 1)?3:1);
48  float tTrigMeanNew,tTrigSigmaNew,kFactorNew;
49  if(!status){ // Gets average of both SuperLayer's
50  if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns)){
51  tTrigMeanNew = (tTrigMean + tTrigMeanNew)/2.;
52 // tTrigSigmaNew = sqrt(tTrigSigmaNew*tTrigSigmaNew + tTrigSigma*tTrigSigma)/2.;
53  tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma)/2.;
54 
55  kFactorNew = kFactor;
56  return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
57  } else return DTTTrigData(tTrigMean,tTrigSigma,kFactor);
58  } else{ // If there is no entry tries to find partner SL and retrieves its value
59  if(!tTrigMap_->get(partnerSLId,tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns))
60  return DTTTrigData(tTrigMeanNew,tTrigSigmaNew,kFactorNew);
61  else { // Both RPhi SL's not present in DB
62  throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for"
63  << slId << "\n" << partnerSLId << endl;
64  }
65  }
66  }
67 }
68 
69 } // namespace
T getUntrackedParameter(std::string const &, T const &) const
DTChamberId chamberId() const
Return the corresponding ChamberId.
int superLayer() const
Return the superlayer number.
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="")