CMS 3D CMS Logo

DTT0WireInChamberReferenceCorrection.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  */
5 
11 
15 
19 
20 #include <string>
21 #include <sstream>
22 
23 using namespace std;
24 using namespace edm;
25 
26 namespace dtCalibration {
27 
28 DTT0WireInChamberReferenceCorrection::DTT0WireInChamberReferenceCorrection(const ParameterSet& pset):
29  calibChamber_( pset.getParameter<string>("calibChamber") ) {
30 
31  //DTChamberId chosenChamberId;
32  if( calibChamber_ != "" && calibChamber_ != "None" && calibChamber_ != "All" ){
33  stringstream linestr;
34  int selWheel, selStation, selSector;
35  linestr << calibChamber_;
36  linestr >> selWheel >> selStation >> selSector;
37  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
38  LogVerbatim("Calibration") << "[DTT0WireInChamberReferenceCorrection] Chosen chamber: " << chosenChamberId_ << endl;
39  }
40  //FIXME: Check if chosen chamber is valid.
41 }
42 
44 }
45 
47  // Get t0 record from DB
48  ESHandle<DTT0> t0H;
49  setup.get<DTT0Rcd>().get(t0H);
50  t0Map_ = &*t0H;
51  LogVerbatim("Calibration") << "[DTT0WireInChamberReferenceCorrection] T0 version: " << t0H->version();
52 
53  // Get geometry from Event Setup
54  setup.get<MuonGeometryRecord>().get(dtGeom_);
55 }
56 
58  // Compute for selected chamber (or All) correction using as reference chamber mean
59 
60  DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
61 
62  if( calibChamber_ == "" || calibChamber_ == "None" ) return defaultT0(wireId);
63  if( calibChamber_ != "All" && chamberId != chosenChamberId_ ) return defaultT0(wireId);
64 
65  // Access DB
66  float t0Mean,t0RMS;
67  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
68  if(status != 0)
69  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
70  << wireId << endl;
71 
72  // Try to find t0 for reference wire in layer
73  DTSuperLayerId slId = wireId.layerId().superlayerId();
74  // Layers 1 and 2
75  DTLayerId layerRef1( slId,1 );
76  //DTLayerId layerRef2( slId,2 );
77 
78  const DTTopology& dtTopoLayerRef1 = dtGeom_->layer( layerRef1 )->specificTopology();
79  const int firstWireLayerRef1 = dtTopoLayerRef1.firstChannel();
80  const int refWireLayerRef1 = firstWireLayerRef1;
81  DTWireId wireIdRefLayerRef1( layerRef1,refWireLayerRef1 );
82 
83  float t0MeanRef1,t0RMSRef1;
84  int statusRef1 = t0Map_->get(wireIdRefLayerRef1,t0MeanRef1,t0RMSRef1,DTTimeUnits::counts);
85 
86  // Correct channels in a superlayer wrt t0 from first wire in first layer
87  if(!statusRef1){
88  float t0MeanNew = t0Mean - t0MeanRef1;
89  float t0RMSNew = t0RMS;
90  return DTT0Data(t0MeanNew,t0RMSNew);
91  } else{
92  // If reference wire not active could choose adjacent wire instead
93  //...
94  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
95  << wireIdRefLayerRef1 << endl;
96  }
97 }
98 
100  // Access default DB
101  float t0Mean,t0RMS;
102  int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
103  if(!status){
104  return DTT0Data(t0Mean,t0RMS);
105  } else{
106  //...
107  throw cms::Exception("[DTT0WireInChamberReferenceCorrection]") << "Could not find t0 entry in DB for"
108  << wireId << endl;
109  }
110 }
111 
112 } // namespace
DTChamberId chamberId() const
Return the corresponding ChamberId.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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 DTTopology & specificTopology() const
Definition: DTLayer.cc:42
Definition: DTT0Rcd.h:9
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
HLT enums.
T get() const
Definition: EventSetup.h:71
const std::string & version() const
access version
Definition: DTT0.cc:118
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:127