CMS 3D CMS Logo

DTLocalTriggerSynchTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTLocalTriggerSynchTask.cc
3  *
4  * \author C. Battilana - CIEMAT
5  *
6 */
7 
9 
10 // Framework
13 
14 // Geometry
20 
21 // tTrigs
24 
25 // DT Digi
28 
29 //Root
30 #include "TH1.h"
31 #include "TAxis.h"
32 
33 #include <sstream>
34 #include <iostream>
35 #include <fstream>
36 
37 using namespace edm;
38 using namespace std;
39 
41  : nevents(0),
42  tTrigSync{DTTTrigSyncFactory::get()->create(ps.getParameter<std::string>("tTrigMode"),
43  ps.getParameter<edm::ParameterSet>("tTrigModeConfig"))},
44  muonGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
45  edm::LogVerbatim("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: Constructor" << endl;
46  tm_Token_ = consumes<L1MuDTChambPhContainer>(ps.getParameter<edm::InputTag>("TMInputTag"));
47  seg_Token_ = consumes<DTRecSegment4DCollection>(ps.getParameter<edm::InputTag>("SEGInputTag"));
48 
49  bxTime = ps.getParameter<double>("bxTimeInterval"); // CB move this to static const or DB
50  rangeInBX = ps.getParameter<bool>("rangeWithinBX");
51  nBXLow = ps.getParameter<int>("nBXLow");
52  nBXHigh = ps.getParameter<int>("nBXHigh");
53  angleRange = ps.getParameter<double>("angleRange");
54  minHitsPhi = ps.getParameter<int>("minHitsPhi");
55  baseDirectory = ps.getParameter<string>("baseDir");
56 }
57 
59  edm::LogVerbatim("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: analyzed " << nevents << " events" << endl;
60 }
61 
63  edm::Run const& iRun,
64  edm::EventSetup const& context) {
65  edm::LogVerbatim("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: Book Histograms" << endl;
66 
67  ibooker.setCurrentFolder(baseDir());
68  ibooker.bookFloat("BXTimeSpacing")->Fill(bxTime);
69 
70  tTrigSync->setES(context);
71 
72  std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
73  std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
74 
75  for (; chambIt != chambEnd; ++chambIt) {
76  bookHistos(ibooker, (*chambIt)->id());
77  triggerHistos[(*chambIt)->id().rawId()]["tTrig_SL1"]->Fill(tTrigSync->offset(DTWireId((*chambIt)->id(), 1, 1, 2)));
78  triggerHistos[(*chambIt)->id().rawId()]["tTrig_SL3"]->Fill(tTrigSync->offset(DTWireId((*chambIt)->id(), 3, 1, 2)));
79  }
80 }
81 
83  muonGeom = &context.getData(muonGeomToken_);
84 }
85 
87  nevents++;
88 
89  for (int i = 0; i < 5; ++i) {
90  for (int j = 0; j < 6; ++j) {
91  for (int k = 0; k < 13; ++k) {
92  phCodeBestTM[j][i][k] = -1;
93  }
94  }
95  }
96 
97  // Get best TM triggers
99  event.getByToken(tm_Token_, l1DTTPGPh);
100  vector<L1MuDTChambPhDigi> const* phTrigs = l1DTTPGPh->getContainer();
101 
102  vector<L1MuDTChambPhDigi>::const_iterator iph = phTrigs->begin();
103  vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
104  for (; iph != iphe; ++iph) {
105  int phwheel = iph->whNum();
106  int phsec = iph->scNum() + 1; // DTTF[0-11] -> DT[1-12] Sector Numbering
107  int phst = iph->stNum();
108  int phcode = iph->code();
109 
110  if (phcode > phCodeBestTM[phwheel + 3][phst][phsec] && phcode < 7) {
111  phCodeBestTM[phwheel + 3][phst][phsec] = phcode;
112  }
113  }
114 
115  //Get best segments (highest number of phi hits)
116  vector<const DTRecSegment4D*> bestSegments4D;
118  event.getByToken(seg_Token_, segments4D);
121 
122  for (chambIdIt = segments4D->id_begin(); chambIdIt != segments4D->id_end(); ++chambIdIt) {
123  DTRecSegment4DCollection::range range = segments4D->get(*chambIdIt);
124  const DTRecSegment4D* best = nullptr;
125  int hitsBest = 0;
126  int hits = 0;
127 
128  for (track = range.first; track != range.second; ++track) {
129  if ((*track).hasPhi()) {
130  hits = (*track).phiSegment()->degreesOfFreedom() + 2;
131  if (hits > hitsBest) {
132  best = &(*track);
133  hitsBest = hits;
134  }
135  }
136  }
137  if (best) {
138  bestSegments4D.push_back(best);
139  }
140  }
141 
142  // Filling histos
143  vector<const DTRecSegment4D*>::const_iterator bestSegIt = bestSegments4D.begin();
144  vector<const DTRecSegment4D*>::const_iterator bestSegEnd = bestSegments4D.end();
145  for (; bestSegIt != bestSegEnd; ++bestSegIt) {
146  float dir = atan((*bestSegIt)->localDirection().x() / (*bestSegIt)->localDirection().z()) * 180 /
147  Geom::pi(); // CB cerca un modo migliore x farlo
148  const DTRecSegment2D* seg2D = (*bestSegIt)->phiSegment();
149  int nHitsPhi = seg2D->degreesOfFreedom() + 2;
150  DTChamberId chambId = (*bestSegIt)->chamberId();
151  map<string, MonitorElement*>& innerME = triggerHistos[chambId.rawId()];
152 
153  if (fabs(dir) < angleRange && nHitsPhi >= minHitsPhi && seg2D->ist0Valid()) {
154  float t0seg = (*bestSegIt)->phiSegment()->t0();
155  float tTrig = (tTrigSync->offset(DTWireId(chambId, 1, 1, 2)) + tTrigSync->offset(DTWireId(chambId, 3, 1, 2))) / 2;
156  float time = tTrig + t0seg;
157  float htime = rangeInBX ? time - int(time / bxTime) * bxTime : time - int(tTrig / bxTime) * bxTime;
158 
159  int wheel = chambId.wheel();
160  int sector = chambId.sector();
161  int station = chambId.station();
162  int scsector = sector > 12 ? sector == 13 ? 4 : 10 : sector;
163 
164  int qualTM = phCodeBestTM[wheel + 3][station][scsector];
165 
166  if (fabs(t0seg) > 0.01) {
167  innerME.find("SEG_TrackCrossingTime")->second->Fill(htime);
168  if (qualTM >= 0)
169  innerME.find("TM_TrackCrossingTimeAll")->second->Fill(htime);
170  if (qualTM == 6)
171  innerME.find("TM_TrackCrossingTimeHH")->second->Fill(htime);
172  }
173  }
174  }
175 }
176 
178  stringstream wheel;
179  wheel << dtChId.wheel();
180  stringstream station;
181  station << dtChId.station();
182  stringstream sector;
183  sector << dtChId.sector();
184  uint32_t chRawId = dtChId.rawId();
185 
186  ibooker.setCurrentFolder(baseDir() + "/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str());
187 
188  std::vector<string> histoTags = {"SEG_TrackCrossingTime", "TM_TrackCrossingTimeAll", "TM_TrackCrossingTimeHH"};
189 
190  float min = rangeInBX ? 0 : nBXLow * bxTime;
191  float max = rangeInBX ? bxTime : nBXHigh * bxTime;
192  int nbins = static_cast<int>(ceil(rangeInBX ? bxTime : (nBXHigh - nBXLow) * bxTime));
193 
194  for (const auto& histoTag : histoTags) {
195  string histoName =
196  histoTag + (rangeInBX ? "InBX" : "") + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
197  edm::LogVerbatim("DTLocalTriggerSynchTask")
198  << "[DTLocalTriggerSynchTask]: booking " << baseDir() + "/Wheel" << wheel.str() << "/Sector" << sector.str()
199  << "/Station" << station.str() << "/" << histoName << endl;
200 
201  triggerHistos[chRawId][histoTag] = ibooker.book1D(histoName.c_str(), "Track time distribution", nbins, min, max);
202  }
203 
204  string floatTag[2] = {"tTrig_SL1", "tTrig_SL3"};
205 
206  for (int iFloat = 0; iFloat < 2; ++iFloat) {
207  string floatName = floatTag[iFloat] + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
208  triggerHistos[chRawId][floatTag[iFloat]] = ibooker.bookFloat(floatName);
209  }
210 }
211 
212 // Local Variables:
213 // show-trailing-whitespace: t
214 // truncate-lines: t
215 // End:
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3176
DTRecSegment2D::ist0Valid
bool ist0Valid() const
Definition: DTRecSegment2D.h:115
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DTRecSegment4D
Definition: DTRecSegment4D.h:23
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
DTLocalTriggerSynchTask::analyze
void analyze(const edm::Event &event, const edm::EventSetup &context) override
Analyze.
Definition: DTLocalTriggerSynchTask.cc:86
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
DTLocalTriggerSynchTask::nBXLow
int nBXLow
Definition: DTLocalTriggerSynchTask.h:86
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
dttriganalyzer_cfi.tTrig
tTrig
Definition: dttriganalyzer_cfi.py:11
DTLocalTriggerSynchTask::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
Definition: DTLocalTriggerSynchTask.cc:82
DTLocalTriggerSynchTask::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTLocalTriggerSynchTask.h:95
dtLocalTriggerSynchTest_cfi.nBXLow
nBXLow
Definition: dtLocalTriggerSynchTest_cfi.py:19
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
protons_cff.time
time
Definition: protons_cff.py:35
DTLocalTriggerSynchTask::minHitsPhi
float minHitsPhi
Definition: DTLocalTriggerSynchTask.h:89
dtLocalTriggerSynchTest_cfi.nBXHigh
nBXHigh
Definition: dtLocalTriggerSynchTest_cfi.py:18
edm::Handle< L1MuDTChambPhContainer >
edm::RangeMap::id_iterator
identifier iterator
Definition: RangeMap.h:130
L1MuDTChambPhContainer::getContainer
Phi_Container const * getContainer() const
Definition: L1MuDTChambPhContainer.cc:41
dtTriggerSynchTask_cfi.minHitsPhi
minHitsPhi
Definition: dtTriggerSynchTask_cfi.py:14
DTLocalTriggerSynchTask::tTrigSync
std::unique_ptr< DTTTrigBaseSync > tTrigSync
Definition: DTLocalTriggerSynchTask.h:91
visDQMUpload.context
context
Definition: visDQMUpload.py:37
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
DTWireId
Definition: DTWireId.h:12
DTGeometry::chambers
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DTLocalTriggerSynchTask::nBXHigh
int nBXHigh
Definition: DTLocalTriggerSynchTask.h:87
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
Geom::pi
constexpr double pi()
Definition: Pi.h:31
DTLocalTriggerSynchTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Book the histograms.
Definition: DTLocalTriggerSynchTask.cc:62
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DTLayer.h
DTGeometry.h
DTLocalTriggerSynchTask::baseDir
std::string & baseDir()
Definition: DTLocalTriggerSynchTask.h:73
edm::ParameterSet
Definition: ParameterSet.h:47
DTLocalTriggerSynchTask::seg_Token_
edm::EDGetTokenT< DTRecSegment4DCollection > seg_Token_
Definition: DTLocalTriggerSynchTask.h:101
DTLocalTriggerSynchTask::DTLocalTriggerSynchTask
DTLocalTriggerSynchTask(const edm::ParameterSet &ps)
Constructor.
Definition: DTLocalTriggerSynchTask.cc:40
DTRecSegment2D
Definition: DTRecSegment2D.h:45
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Pi.h
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
DTLocalTriggerSynchTask::angleRange
float angleRange
Definition: DTLocalTriggerSynchTask.h:88
DTTTrigBaseSync.h
edm::EventSetup
Definition: EventSetup.h:58
DTLocalTriggerSynchTask::muonGeom
const DTGeometry * muonGeom
Definition: DTLocalTriggerSynchTask.h:96
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
DTLocalTriggerSynchTask::rangeInBX
bool rangeInBX
Definition: DTLocalTriggerSynchTask.h:85
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTLocalTriggerSynchTask::tm_Token_
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_Token_
Definition: DTLocalTriggerSynchTask.h:100
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
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
DTLocalTriggerSynchTask::phCodeBestTM
DTArr3int phCodeBestTM
Definition: DTLocalTriggerSynchTask.h:80
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTLocalTriggerSynchTask::nevents
int nevents
Definition: DTLocalTriggerSynchTask.h:78
DTTTrigSyncFactory.h
DTLocalTriggerSynchTask::bookHistos
void bookHistos(DQMStore::IBooker &, const DTChamberId &dtCh)
Book the histograms.
Definition: DTLocalTriggerSynchTask.cc:177
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DTLocalTriggerSynchTask::bxTime
float bxTime
Definition: DTLocalTriggerSynchTask.h:84
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTRecSegment2D::degreesOfFreedom
int degreesOfFreedom() const override
return the DOF of the segment
Definition: DTRecSegment2D.cc:78
DTDigi.h
DTDigiCollection.h
DTChamberId
Definition: DTChamberId.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
DTLocalTriggerSynchTask::~DTLocalTriggerSynchTask
~DTLocalTriggerSynchTask() override
Destructor.
Definition: DTLocalTriggerSynchTask.cc:58
dtTriggerSynchTask_cfi.angleRange
angleRange
Definition: dtTriggerSynchTask_cfi.py:13
DTTopology.h
DTLocalTriggerSynchTask.h
DTLocalTriggerSynchTask::triggerHistos
std::map< uint32_t, std::map< std::string, MonitorElement * > > triggerHistos
Definition: DTLocalTriggerSynchTask.h:97
DTSuperLayer.h
hgcalDigitizer_cfi.bxTime
bxTime
Definition: hgcalDigitizer_cfi.py:83
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
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23