29 std::vector<std::pair<std::string, std::string>> hnames =
31 for (
unsigned int i = 0;
i < hnames.size();
i++) {
38 auto loc =
APVloc(thick,
id, side, plane,
s);
59 gainToken_ = esConsumes<edm::Transition::BeginRun>();
68 static constexpr
float defaultGainTick = 690. / 640.;
75 if (!gainHandle.isValid()) {
76 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
82 for (
unsigned int a = 0;
a <
histograms.APVsCollOrdered.size();
a++) {
88 APV->isMasked = siStripQuality.IsApvBad(
APV->DetId,
APV->APVId);
90 if (gainHandle->getNumberOfTags() != 2) {
91 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
95 float newPreviousGain = gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 1), 1);
96 if (
APV->PreviousGain != 1 and newPreviousGain !=
APV->PreviousGain)
97 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
98 APV->PreviousGain = newPreviousGain;
100 float newPreviousGainTick =
101 APV->isMasked ? defaultGainTick : gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 0), 0);
102 if (
APV->PreviousGainTick != 1 and newPreviousGainTick !=
APV->PreviousGainTick) {
104 <<
"WARNING: TickMarkGain in the global tag changed\n" 106 <<
" APV->SubDet: " <<
APV->SubDet <<
" APV->APVId:" <<
APV->APVId << std::endl
107 <<
" APV->PreviousGainTick: " <<
APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
110 APV->PreviousGainTick = newPreviousGainTick;
132 clusters.emplace_back(simple->geographicalId().rawId(), simple->cluster().get(),
nullptr);
133 }
else if (simple1d) {
134 clusters.emplace_back(simple1d->geographicalId().rawId(), simple1d->cluster().get(),
nullptr);
136 clusters.emplace_back(
pixel->geographicalId().rawId(),
nullptr,
pixel->cluster().get());
143 if ((!dynamic_cast<const StripGeomDetUnit*>(gdu)) && (!dynamic_cast<const PixelGeomDetUnit*>(gdu))) {
145 <<
"DetId " << detId <<
" does not seem to belong to the tracker";
148 const auto plane = gdu->surface();
152 static constexpr
double distFromBorder = 1.0;
153 double halfLength = 0.;
155 halfLength = trapBounds->parameters()[3];
156 }
else if (rectBounds) {
157 halfLength = .5 * gdu->surface().bounds().
length();
178 unsigned int eventnumber =
iEvent.id().event();
181 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " <<
runnumber <<
" and event " << eventnumber << std::endl;
193 LogDebug(
"SiStripGainsPCLWorker") << elem.first <<
" - " << elem.second.m_string <<
" " 194 << elem.second.m_subdetectorId <<
" " << elem.second.m_subdetectorSide <<
" " 195 << elem.second.m_subdetectorPlane << std::endl;
202 std::size_t nStoredClusters{0};
203 for (
const auto&
assoc : *trajTrackAssociations) {
204 const auto traj =
assoc.key.get();
213 for (
const auto& meas : traj->measurements()) {
214 const auto& trajState = meas.updatedState();
219 auto clusters = getClusters(meas.recHit()->hit());
220 for (
const auto hitCluster :
clusters) {
223 bool overlapping =
false;
227 if (hitCluster.strip) {
228 const auto& ampls = hitCluster.strip->amplitudes();
229 firstStrip = hitCluster.strip->firstStrip();
231 charge = hitCluster.strip->charge();
232 saturation = std::any_of(ampls.begin(), ampls.end(), [](uint8_t amp) {
return amp >= 254; });
234 overlapping = (((firstStrip % 128) == 0) || ((firstStrip / 128) != ((firstStrip +
int(
nStrips)) / 128)));
235 }
else if (hitCluster.pixel) {
236 const auto& ampls = hitCluster.pixel->pixelADC();
237 const int firstRow = hitCluster.pixel->minPixelRow();
238 const int firstCol = hitCluster.pixel->minPixelCol();
239 firstStrip = ((firstRow / 80) << 3 | (firstCol / 52)) * 128;
241 for (
const auto amp : ampls) {
248 std::shared_ptr<stAPVGain>
APV =
histograms.APVsColl.at((hitCluster.det << 4) | (firstStrip / 128));
250 const auto farFromEdge = (hitCluster.strip ?
isFarFromBorder(trajState, hitCluster.det, tGeom) :
true);
251 if ((
APV->SubDet > 2) &&
255 int clusterCharge = 0;
256 if (
APV->SubDet > 2) {
259 for (
const auto origCharge : hitCluster.strip->amplitudes()) {
263 stripCharge =
int(origCharge /
APV->CalibGain);
265 stripCharge =
int(origCharge * (
APV->PreviousGain /
APV->CalibGain));
269 stripCharge = origCharge;
271 stripCharge =
int(origCharge *
APV->PreviousGain);
274 if (stripCharge > 1024) {
277 }
else if (stripCharge > 254) {
281 clusterCharge += stripCharge;
289 clusterCharge =
charge / 265.0;
293 const auto path = (10. *
APV->Thickness) /
std::abs(trackDir.z() / trackDir.mag());
294 double ClusterChargeOverPath = ((double)clusterCharge) /
path;
295 if (
APV->SubDet > 2) {
297 ClusterChargeOverPath /=
APV->PreviousGain;
300 ClusterChargeOverPath *=
APV->PreviousGain;
309 histograms.Charge_Vs_Index[elepos]->Fill(
APV->Index, ClusterChargeOverPath);
312 <<
" i " << iCluster <<
" useCalibration " <<
useCalibration <<
" FirstSetOfConstants " 314 <<
" APV->DetId " <<
APV->DetId <<
" APV->Index " <<
APV->Index <<
" Charge " << clusterCharge <<
" Path " 315 <<
path <<
" ClusterChargeOverPath " << ClusterChargeOverPath << std::endl;
319 for (
const auto sCharge : hitCluster.strip->amplitudes()) {
327 int mCharge2 = mCharge1 *
APV->PreviousGain;
328 int mCharge3 = mCharge1 *
APV->PreviousGainTick;
329 int mCharge4 = mCharge1 *
APV->PreviousGain *
APV->PreviousGainTick;
331 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge " << mCharge1 <<
" remove G2 " << mCharge2 <<
" remove G1 " 332 << mCharge3 <<
" remove G1*G2 " << mCharge4 << std::endl;
346 histograms.Charge_Vs_PathlengthTIB[elepos]->Fill(
path, clusterCharge);
349 histograms.Charge_Vs_PathlengthTOB[elepos]->Fill(
path, clusterCharge);
353 histograms.Charge_Vs_PathlengthTIDM[elepos]->Fill(
path, clusterCharge);
355 else if (
APV->Eta > 0) {
356 histograms.Charge_Vs_PathlengthTIDP[elepos]->Fill(
path, clusterCharge);
361 if (
APV->Thickness < 0.04) {
362 histograms.Charge_Vs_PathlengthTECM1[elepos]->Fill(
path, clusterCharge);
364 else if (
APV->Thickness > 0.04) {
365 histograms.Charge_Vs_PathlengthTECM2[elepos]->Fill(
path, clusterCharge);
367 }
else if (
APV->Eta > 0) {
368 if (
APV->Thickness < 0.04) {
369 histograms.Charge_Vs_PathlengthTECP1[elepos]->Fill(
path, clusterCharge);
371 else if (
APV->Thickness > 0.04) {
372 histograms.Charge_Vs_PathlengthTECP2[elepos]->Fill(
path, clusterCharge);
382 histograms.EventStats->Fill(2., 0., nStoredClusters);
394 auto const&
Det = bareTkGeomPtr->
dets();
396 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct" << std::endl;
398 unsigned int Index = 0;
400 for (
unsigned int i = 0;
i <
Det.size();
i++) {
411 unsigned int NAPV = Topo.
nstrips() / 128;
413 for (
unsigned int j = 0;
j < NAPV;
j++) {
414 auto APV = std::make_shared<stAPVGain>();
423 APV->FitWidthErr = -1;
427 APV->PreviousGain = 1;
428 APV->PreviousGainTick = 1;
429 APV->x = DetUnit->position().basicVector().x();
430 APV->y = DetUnit->position().basicVector().y();
431 APV->z = DetUnit->position().basicVector().z();
432 APV->Eta = DetUnit->position().basicVector().eta();
433 APV->Phi = DetUnit->position().basicVector().phi();
434 APV->R = DetUnit->position().basicVector().transverse();
435 APV->Thickness = DetUnit->surface().bounds().thickness();
437 APV->isMasked =
false;
447 for (
unsigned int i = 0;
i <
Det.size();
457 unsigned int NROCRow = Topo.
nrows() / (80.);
458 unsigned int NROCCol = Topo.
ncolumns() / (52.);
460 for (
unsigned int j = 0;
j < NROCRow;
j++) {
461 for (
unsigned int i = 0;
i < NROCCol;
i++) {
462 auto APV = std::make_shared<stAPVGain>();
466 APV->APVId = (
j << 3 |
i);
471 APV->FitWidthErr = -1;
474 APV->PreviousGain = 1;
475 APV->PreviousGainTick = 1;
476 APV->x = DetUnit->position().basicVector().x();
477 APV->y = DetUnit->position().basicVector().y();
478 APV->z = DetUnit->position().basicVector().z();
479 APV->Eta = DetUnit->position().basicVector().eta();
480 APV->Phi = DetUnit->position().basicVector().phi();
481 APV->R = DetUnit->position().basicVector().transverse();
482 APV->Thickness = DetUnit->surface().bounds().thickness();
483 APV->isMasked =
false;
514 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " <<
tag 522 histograms.EventStats = ibooker.
book2I(
"EventStats",
"Statistics", 3, -0.5, 2.5, 1, 0, 1);
523 histograms.EventStats->setBinLabel(1,
"events count", 1);
524 histograms.EventStats->setBinLabel(2,
"tracks count", 1);
525 histograms.EventStats->setBinLabel(3,
"clusters count", 1);
528 if (!stag.empty() && stag[0] !=
'_')
529 stag.insert(0, 1,
'_');
561 std::vector<float> binXarray;
564 binXarray.push_back((
float)
a);
567 std::array<float, 688> binYarray;
569 double p1 = 0.002113;
570 double p2 = 69.01576;
572 for (
int b = 0;
b < 687;
b++) {
579 binYarray[687] = 4000.;
589 ibooker.
book2S(cvi.c_str(), cvi.c_str(),
histograms.NStripAPVs, &binXarray[0], 687, binYarray.data()));
591 it =
histograms.Charge_Vs_PathlengthTIB.begin();
592 histograms.Charge_Vs_PathlengthTIB.insert(it + elepos,
593 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
595 it =
histograms.Charge_Vs_PathlengthTOB.begin();
596 histograms.Charge_Vs_PathlengthTOB.insert(it + elepos,
597 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
599 it =
histograms.Charge_Vs_PathlengthTIDP.begin();
601 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
603 it =
histograms.Charge_Vs_PathlengthTIDM.begin();
605 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
607 it =
histograms.Charge_Vs_PathlengthTECP1.begin();
609 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
611 it =
histograms.Charge_Vs_PathlengthTECP2.begin();
613 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
615 it =
histograms.Charge_Vs_PathlengthTECM1.begin();
617 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
619 it =
histograms.Charge_Vs_PathlengthTECM2.begin();
621 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
623 std::vector<std::pair<std::string, std::string>> hnames =
625 for (
unsigned int i = 0;
i < hnames.size();
i++) {
631 for (
unsigned int i = 0;
i < hnames.size();
i++) {
637 for (
unsigned int i = 0;
i < hnames.size();
i++) {
643 for (
unsigned int i = 0;
i < hnames.size();
i++) {
static constexpr auto TEC
virtual int nstrips() const =0
T getParameter(std::string const &) const
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=nullptr)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const LocalTrajectoryError & localError() const
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
LocalPoint localPosition() const
virtual void setCurrentFolder(std::string const &fullpath)
virtual int ncolumns() const =0
int statCollectionFromMode(const char *tag) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
SiStripGainsPCLWorker(const edm::ParameterSet &)
virtual int nrows() const =0
int subdetectorPlane(uint32_t, const TrackerTopology *)
std::string m_calibrationMode
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Log< level::Error, false > LogError
edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
float length() const override
Lenght along local Y.
LocalError positionError() const
edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > dqm_tag_
bool doChargeMonitorPerPlane
U second(std::pair< T, U > const &p)
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, APVGain::APVGainHistograms const &) const override
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
void addDefault(ParameterSetDescription const &psetDescription)
void checkBookAPVColls(const TrackerGeometry *bareTkGeomPtr, APVGain::APVGainHistograms &histograms) const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomTokenBR_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
LocalVector localDirection() const
Abs< T >::type abs(const T &t)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
std::map< unsigned int, APVloc > theTopologyMap
static constexpr auto TOB
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Info, false > LogInfo
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
static constexpr auto TIB
auto const & tracks
cannot be loose
constexpr uint32_t rawId() const
get the raw id
int subdetectorSide(uint32_t, const TrackerTopology *)
std::vector< std::string > VChargeHisto
double MaxTrackChiOverNdf
Pixel cluster – collection of neighboring pixels above threshold.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Log< level::Warning, false > LogWarning
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
unsigned int MinTrackHits
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
static constexpr auto TID
int subdetectorId(uint32_t)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)