CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTT0WireInChamberReferenceCorrection.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 
12 
16 
20 
21 #include <string>
22 #include <sstream>
23 
24 using namespace std;
25 using namespace edm;
26 
27 namespace dtCalibration {
28 
29 DTT0WireInChamberReferenceCorrection::DTT0WireInChamberReferenceCorrection(const ParameterSet& pset):
30  calibChamber_( pset.getParameter<string>("calibChamber") ) {
31 
32  //DTChamberId chosenChamberId;
33  if( calibChamber_ != "" && calibChamber_ != "None" && calibChamber_ != "All" ){
34  stringstream linestr;
35  int selWheel, selStation, selSector;
36  linestr << calibChamber_;
37  linestr >> selWheel >> selStation >> selSector;
38  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
39  LogVerbatim("Calibration") << "[DTT0WireInChamberReferenceCorrection] Chosen chamber: " << chosenChamberId_ << endl;
40  }
41  //FIXME: Check if chosen chamber is valid.
42 }
43 
45 }
46 
48  // Get t0 record from DB
49  ESHandle<DTT0> t0H;
50  setup.get<DTT0Rcd>().get(t0H);
51  t0Map_ = &*t0H;
52  LogVerbatim("Calibration") << "[DTT0WireInChamberReferenceCorrection] T0 version: " << t0H->version();
53 
54  // Get geometry from Event Setup
55  setup.get<MuonGeometryRecord>().get(dtGeom_);
56 }
57 
59  // Compute for selected chamber (or All) correction using as reference chamber mean
60 
61  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
62 
63  if( calibChamber_ == "" || calibChamber_ == "None" ) return defaultT0(wireId);
64  if( calibChamber_ != "All" && chamberId != chosenChamberId_ ) return defaultT0(wireId);
65 
66  // Access DB
67  float t0Mean,t0RMS;
68  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
69  if(status != 0)
70  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
71  << wireId << endl;
72 
73  // Try to find t0 for reference wire in layer
74  DTSuperLayerId slId = wireId.layerId().superlayerId();
75  // Layers 1 and 2
76  DTLayerId layerRef1( slId,1 );
77  //DTLayerId layerRef2( slId,2 );
78 
79  const DTTopology& dtTopoLayerRef1 = dtGeom_->layer( layerRef1 )->specificTopology();
80  const int firstWireLayerRef1 = dtTopoLayerRef1.firstChannel();
81  const int refWireLayerRef1 = firstWireLayerRef1;
82  DTWireId wireIdRefLayerRef1( layerRef1,refWireLayerRef1 );
83 
84  float t0MeanRef1,t0RMSRef1;
85  int statusRef1 = t0Map_->get(wireIdRefLayerRef1,t0MeanRef1,t0RMSRef1,DTTimeUnits::counts);
86 
87  // Correct channels in a superlayer wrt t0 from first wire in first layer
88  if(!statusRef1){
89  float t0MeanNew = t0Mean - t0MeanRef1;
90  float t0RMSNew = t0RMS;
91  return DTT0Data(t0MeanNew,t0RMSNew);
92  } else{
93  // If reference wire not active could choose adjacent wire instead
94  //...
95  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
96  << wireIdRefLayerRef1 << endl;
97  }
98 }
99 
101  // Access default DB
102  float t0Mean,t0RMS;
103  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
104  if(!status){
105  return DTT0Data(t0Mean,t0RMS);
106  } else{
107  //...
108  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
109  << wireId << endl;
110  }
111 }
112 
113 } // namespace
DTChamberId chamberId() const
Return the corresponding ChamberId.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, float &t0mean, float &t0rms, DTTimeUnits::type unit) const
Definition: DTT0.cc:67
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
const T & get() const
Definition: EventSetup.h:56
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
tuple status
Definition: ntuplemaker.py:245
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")