19 template<TrackerType pixel_or_strip>
21 : conf_(iConfig), m_cacheID_(0)
23 , avalidator_(iConfig, consumesCollector()) {
28 template<TrackerType pixel_or_strip>
30 if (genTriggerEventFlag_)
delete genTriggerEventFlag_;
33 template<TrackerType pixel_or_strip>
37 if (m_cacheID_ != cacheID) {
39 this->createMEs( ibooker , iSetup);
43 template<TrackerType pixel_or_strip>
47 if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( run, iSetup );
50 template<TrackerType pixel_or_strip>
54 auto id =
DetId(ModuleID);
55 switch (
id.subdetId()) {
63 layer = tTopo->
pxfDisk(
id) * ( tTopo->
pxfSide(ModuleID)==1 ? -1 : +1);
87 return std::make_pair(subdet, layer);
91 template<TrackerType pixel_or_strip>
104 double d_residual_xmin =
Parameters.getParameter<
double>(
"xmin");
105 double d_residual_xmax =
Parameters.getParameter<
double>(
"xmax");
107 int32_t i_normres_Nbins = Parameters.
getParameter<int32_t>(
"Nbinx");
108 double d_normres_xmin = Parameters.getParameter<
double>(
"xmin");
109 double d_normres_xmax = Parameters.getParameter<
double>(
"xmax");
120 auto ids = TG->detIds();
123 auto ModuleID =
id.rawId();
124 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
129 switch (
id.subdetId()) {
130 case 1: pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
break;
131 case 2: pixel_organizer.setModuleFolder(ibooker, ModuleID, 0);
break;
136 std::string hid = hidmanager.createHistoId(
"HitResidualsX",
"det",ModuleID);
137 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsX",
"det",ModuleID);
138 auto&
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
139 histos.x.base = ibooker.
book1D(hid, hid, i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
140 histos.x.base->setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
141 histos.x.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins,d_normres_xmin,d_normres_xmax);
142 histos.x.normed->setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
144 std::string hid = hidmanager.createHistoId(
"HitResidualsY",
"det",ModuleID);
145 std::string normhid = hidmanager.createHistoId(
"NormalizedHitResidualsY",
"det",ModuleID);
146 auto&
histos = m_ModuleResiduals[std::make_pair(
"", ModuleID)];
147 histos.y.base = ibooker.
book1D(hid, hid, i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
148 histos.y.base->setAxisTitle(
"(y_{pred} - y_{rec})' [cm]");
149 histos.y.normed = ibooker.
book1D(normhid, normhid, i_normres_Nbins,d_normres_xmin,d_normres_xmax);
150 histos.y.normed->setAxisTitle(
"(y_{pred} - y_{rec})'/#sigma");
154 auto subdetandlayer = findSubdetAndLayer(ModuleID, tTopo);
155 if(m_SubdetLayerResiduals.find(subdetandlayer) == m_SubdetLayerResiduals.end()) {
157 auto&
histos = m_SubdetLayerResiduals[subdetandlayer];
158 switch (
id.subdetId()) {
164 default: strip_organizer.
setLayerFolder(ModuleID,tTopo,subdetandlayer.second);
167 auto isBarrel = subdetandlayer.first.find(
"B") != std::string::npos;
169 auto xy = std::vector<std::pair<HistoPair&, const char*> >
170 { std::make_pair(std::ref(
histos.x),
"X"),
171 std::make_pair(std::ref(
histos.y),
"Y") };
172 for (
auto& histopair :
xy) {
176 if (!
isPixel && histopair.second[0] ==
'Y')
continue;
179 Form(
"HitResiduals%s_%s%d",
181 isBarrel ?
"L" : (subdetandlayer.second > 0 ?
"Dp" :
"Dm"),
183 : (Form(
"HitResiduals_%s__%s__%d",
184 subdetandlayer.first.c_str(),
188 std::string histotitle = Form(
"HitResiduals %s on %s%s full %s %d",
190 subdetandlayer.first.c_str(),
191 isBarrel ?
"" : (subdetandlayer.second > 0 ?
"+" :
"-"),
196 std::string normhistoname = Form(
"Normalized%s", histoname.c_str());
197 std::string normhistotitle = Form(
"Normalized%s", histotitle.c_str());
201 histopair.first.base =
202 ibooker.
book1D(histoname.c_str(),histotitle.c_str(),
203 i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
204 histopair.first.base->
setAxisTitle(
"(x_{pred} - x_{rec})' [cm]");
206 histopair.first.normed =
207 ibooker.
book1D(normhistoname.c_str(),normhistotitle.c_str(),
208 i_normres_Nbins,d_normres_xmin,d_normres_xmax);
209 histopair.first.normed->
setAxisTitle(
"(x_{pred} - x_{rec})'/#sigma");
215 template<TrackerType pixel_or_strip>
218 auto vtracks = std::vector<TrackerValidationVariables::AVTrackStruct>();
220 if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) )
return;
223 iEvent.
getByToken(offlinePrimaryVerticesToken_, vertices);
224 if (!vertices.
isValid() || vertices->size() == 0)
return;
232 avalidator_.fillTrackQuantities(iEvent, iSetup,
235 return track.
pt() > 0.75
239 for (
auto& track : vtracks) {
240 for (
auto& it : track.hits) {
241 uint RawId = it.rawDetId;
243 auto id =
DetId(RawId);
244 auto isPixel =
id.subdetId() == 1 ||
id.subdetId() == 2;
249 auto& mod_histos = m_ModuleResiduals[std::make_pair(
"",RawId)];
250 mod_histos.x.base->Fill(it.resXprime);
251 mod_histos.x.normed->Fill(it.resXprime/it.resXprimeErr);
252 mod_histos.y.base->Fill(it.resYprime);
253 mod_histos.y.normed->Fill(it.resYprime/it.resYprimeErr);
256 auto subdetandlayer = findSubdetAndLayer(RawId, tTopo);
257 auto histos = m_SubdetLayerResiduals[subdetandlayer];
259 if(it.resXprimeErr != 0 &&
histos.x.base) {
260 histos.x.base->Fill(it.resXprime);
261 histos.x.normed->Fill(it.resXprime/it.resXprimeErr);
263 if(it.resYprimeErr != 0 &&
histos.y.base) {
264 histos.y.base->Fill(it.resYprime);
265 histos.y.normed->Fill(it.resYprime/it.resYprimeErr);
T getParameter(std::string const &) const
unsigned int tibLayer(const DetId &id) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dxyError() const
error on dxy
#define DEFINE_FWK_MODULE(type)
unsigned int pxfDisk(const DetId &id) const
bool isBarrel(GeomDetEnumerators::SubDetector m)
unsigned int tidWheel(const DetId &id) const
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
edm::EDGetTokenT< reco::VertexCollection > offlinePrimaryVerticesToken_
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
unsigned int tidSide(const DetId &id) const
vector< ParameterSet > Parameters
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
double pt() const
track transverse momentum
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
MonitorTrackResidualsBase(const edm::ParameterSet &)
unsigned int pxbLayer(const DetId &id) const
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=0)
void setCurrentFolder(const std::string &fullpath)
T const * product() const
void createMEs(DQMStore::IBooker &, const edm::EventSetup &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool isPixel(HitType hitType)
unsigned int pxfSide(const DetId &id) const
~MonitorTrackResidualsBase()
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
std::pair< std::string, int32_t > findSubdetAndLayer(uint32_t ModuleID, const TrackerTopology *tTopo)
unsigned int tecWheel(const DetId &id) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const