CMS 3D CMS Logo

DTRunConditionVar.cc
Go to the documentation of this file.
1 
2 /******* \class DTRunConditionVar *******
3  *
4  * Description:
5  *
6  * detailed description
7  *
8  * \author : Paolo Bellan, Antonio Branca
9  * $date : 23/09/2011 15:42:04 CET $
10  *
11  * Modification:
12  *
13  *********************************/
14 
15 #include "DTRunConditionVar.h"
16 
21 
23 
25 
27 
29 
31 
35 
36 #include "TMath.h"
37 #include <cmath>
38 
39 using namespace std;
40 using namespace edm;
41 
43  : // Get the debug parameter for verbose output
44  debug(pSet.getUntrackedParameter<bool>("debug", false)),
45  nMinHitsPhi(pSet.getUntrackedParameter<int>("nMinHitsPhi")),
46  maxAnglePhiSegm(pSet.getUntrackedParameter<double>("maxAnglePhiSegm")),
47  dt4DSegmentsToken_(consumes<DTRecSegment4DCollection>(pSet.getParameter<InputTag>("recoSegments"))),
48  muonGeomToken_(esConsumes<edm::Transition::BeginRun>()),
49  mTimeToken_(esConsumes()) {}
50 
52  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: destructor called";
53 
54  // free memory
55 }
56 
58  edm::Run const& iRun,
59  edm::EventSetup const& /* iSetup */) {
60  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: bookHistograms";
61 
62  for (int wheel = -2; wheel <= 2; wheel++) {
63  for (int sec = 1; sec <= 14; sec++) {
64  for (int stat = 1; stat <= 4; stat++) {
65  bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "VDrift_FromSegm", 100, 0.0043, 0.0065);
66  bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "T0_FromSegm", 100, -25., 25.);
67  }
68  }
69  }
70 
71  return;
72 }
73 
75  // Get the DT Geometry
76  dtGeom = &setup.getData(muonGeomToken_);
77  return;
78 }
79 
80 void DTRunConditionVar::analyze(const Event& event, const EventSetup& eventSetup) {
81  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
82  << "--- [DTRunConditionVar] Event analysed #Run: " << event.id().run() << " #Event: " << event.id().event()
83  << endl;
84 
85  // Get the map of vdrift from the setup
86  mTime = &eventSetup.getData(mTimeToken_);
87  mTimeMap_ = &*mTime;
88 
89  // Get the segment collection from the event
91  event.getByToken(dt4DSegmentsToken_, all4DSegments);
92 
93  // Loop over the segments
94  for (DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin(); segment != all4DSegments->end();
95  ++segment) {
96  // Get the chamber from the setup
97  DTChamberId DTid = (DTChamberId)segment->chamberId();
98  uint32_t indexCh = DTid.rawId();
99 
100  // Fill v-drift values
101  if ((*segment).hasPhi()) {
102  int nHitsPhi = (*segment).phiSegment()->degreesOfFreedom() + 2;
103  double xdir = (*segment).phiSegment()->localDirection().x();
104  double zdir = (*segment).phiSegment()->localDirection().z();
105 
106  double anglePhiSegm = fabs(atan(xdir / zdir)) * 180. / TMath::Pi();
107 
108  if (nHitsPhi >= nMinHitsPhi && anglePhiSegm <= maxAnglePhiSegm) {
109  double segmentVDrift = segment->phiSegment()->vDrift();
110 
111  DTSuperLayerId indexSLPhi1(DTid, 1);
112  DTSuperLayerId indexSLPhi2(DTid, 3);
113 
114  float vDriftPhi1(0.), vDriftPhi2(0.);
115  float ResPhi1(0.), ResPhi2(0.);
116  int status1 = mTimeMap_->get(indexSLPhi1, vDriftPhi1, ResPhi1, DTVelocityUnits::cm_per_ns);
117  int status2 = mTimeMap_->get(indexSLPhi2, vDriftPhi2, ResPhi2, DTVelocityUnits::cm_per_ns);
118 
119  if (status1 != 0 || status2 != 0) {
120  DTSuperLayerId sl = (status1 != 0) ? indexSLPhi1 : indexSLPhi2;
121  throw cms::Exception("DTRunConditionVarClient") << "Could not find vDrift entry in DB for" << sl << endl;
122  }
123 
124  float vDriftMed = (vDriftPhi1 + vDriftPhi2) / 2.;
125 
126  segmentVDrift = vDriftMed * (1. - segmentVDrift);
127 
128  double segmentT0 = segment->phiSegment()->t0();
129 
130  if (segment->phiSegment()->ist0Valid())
131  (chamberHistos[indexCh])["T0_FromSegm"]->Fill(segmentT0);
132  if (segmentVDrift != vDriftMed)
133  (chamberHistos[indexCh])["VDrift_FromSegm"]->Fill(segmentVDrift);
134  }
135  }
136 
137  } //end loop on segment
138 
139 } //end analyze
140 
142  DQMStore::IBooker& ibooker, const DTChamberId& dtCh, string histoType, int nbins, float min, float max) {
143  int wh = dtCh.wheel();
144  int sc = dtCh.sector();
145  int st = dtCh.station();
146  stringstream wheel;
147  wheel << wh;
148  stringstream station;
149  station << st;
150  stringstream sector;
151  sector << sc;
152 
153  string bookingFolder = "DT/02-Segments/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
154  string histoTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
155 
156  ibooker.setCurrentFolder(bookingFolder);
157 
158  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
159  << "[DTRunConditionVar]: booking histos in " << bookingFolder << endl;
160 
161  string histoName = histoType + histoTag;
162  const string& histoLabel = histoType;
163 
164  (chamberHistos[dtCh.rawId()])[histoType] = ibooker.book1D(histoName, histoLabel, nbins, min, max);
165 }
166 
167 // Local Variables:
168 // show-trailing-whitespace: t
169 // truncate-lines: t
170 // End:
DTSuperLayerId
Definition: DTSuperLayerId.h:12
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTRunConditionVar::nMinHitsPhi
int nMinHitsPhi
Definition: DTRunConditionVar.h:65
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
DTRunConditionVar::dt4DSegmentsToken_
edm::EDGetTokenT< DTRecSegment4DCollection > dt4DSegmentsToken_
Definition: DTRunConditionVar.h:68
edm::Handle< DTRecSegment4DCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTRunConditionVar::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: DTRunConditionVar.cc:80
DTRunConditionVar::mTimeMap_
const DTMtime * mTimeMap_
Definition: DTRunConditionVar.h:75
DTRunConditionVar::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DTRunConditionVar.cc:57
debug
#define debug
Definition: HDRShower.cc:19
DTRunConditionVar::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DTRunConditionVar.cc:74
Service.h
IdealMagneticFieldRecord.h
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
DTRunConditionVar::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTRunConditionVar.h:70
DTRecSegment4DCollection
RefToBase.h
dtRunConditionVar_cfi.maxAnglePhiSegm
maxAnglePhiSegm
Definition: dtRunConditionVar_cfi.py:7
dtRunConditionVar_cfi.nMinHitsPhi
nMinHitsPhi
Definition: dtRunConditionVar_cfi.py:6
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
Event.h
DTVelocityUnits::cm_per_ns
Definition: DTVelocityUnits.h:32
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
DTRunConditionVar::maxAnglePhiSegm
double maxAnglePhiSegm
Definition: DTRunConditionVar.h:66
DTRunConditionVar::mTime
const DTMtime * mTime
Definition: DTRunConditionVar.h:74
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
dtResolutionTest_cfi.histoTag
histoTag
Definition: dtResolutionTest_cfi.py:21
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DTRunConditionVar.h
xdir
Definition: DeviationsFromFileSensor2D.cc:15
edm::EventSetup
Definition: EventSetup.h:58
MuonSubdetId.h
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:94
DTRunConditionVar::bookChamberHistos
void bookChamberHistos(DQMStore::IBooker &, const DTChamberId &dtCh, std::string histoType, int, float, float)
Definition: DTRunConditionVar.cc:141
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTRunConditionVar::chamberHistos
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
Definition: DTRunConditionVar.h:77
DetId.h
edm::Transition::BeginRun
Exception
Definition: hltDiff.cc:245
DTRunConditionVar::dtGeom
const DTGeometry * dtGeom
Definition: DTRunConditionVar.h:71
DetLayer.h
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
DTRunConditionVar::~DTRunConditionVar
~DTRunConditionVar() override
Definition: DTRunConditionVar.cc:51
ParameterSet.h
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
fftjetimagerecorder_cfi.histoLabel
histoLabel
Definition: fftjetimagerecorder_cfi.py:12
DTRunConditionVar::DTRunConditionVar
DTRunConditionVar(const edm::ParameterSet &pset)
Definition: DTRunConditionVar.cc:42
DTMtime::get
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
DirectMuonNavigation.h
DTRunConditionVar::mTimeToken_
edm::ESGetToken< DTMtime, DTMtimeRcd > mTimeToken_
Definition: DTRunConditionVar.h:73
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98