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);
60 gainToken_ = esConsumes<edm::Transition::BeginRun>();
69 static constexpr
float defaultGainTick = 690. / 640.;
77 if (!gainHandle.isValid()) {
78 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
84 for (
unsigned int a = 0;
a <
histograms.APVsCollOrdered.size();
a++) {
90 APV->isMasked = siStripQuality.IsApvBad(
APV->DetId,
APV->APVId);
92 if (gainHandle->getNumberOfTags() != 2) {
93 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
97 float newPreviousGain = gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 1), 1);
98 if (
APV->PreviousGain != 1 and newPreviousGain !=
APV->PreviousGain)
99 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
100 APV->PreviousGain = newPreviousGain;
102 float newPreviousGainTick =
103 APV->isMasked ? defaultGainTick : gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 0), 0);
104 if (
APV->PreviousGainTick != 1 and newPreviousGainTick !=
APV->PreviousGainTick) {
106 <<
"WARNING: TickMarkGain in the global tag changed\n" 108 <<
" APV->SubDet: " <<
APV->SubDet <<
" APV->APVId:" <<
APV->APVId << std::endl
109 <<
" APV->PreviousGainTick: " <<
APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
112 APV->PreviousGainTick = newPreviousGainTick;
134 clusters.emplace_back(simple->geographicalId().rawId(), simple->cluster().get(),
nullptr);
135 }
else if (simple1d) {
136 clusters.emplace_back(simple1d->geographicalId().rawId(), simple1d->cluster().get(),
nullptr);
138 clusters.emplace_back(
pixel->geographicalId().rawId(),
nullptr,
pixel->cluster().get());
145 if ((!dynamic_cast<const StripGeomDetUnit*>(gdu)) && (!dynamic_cast<const PixelGeomDetUnit*>(gdu))) {
147 <<
"DetId " <<
detId <<
" does not seem to belong to the tracker";
150 const auto plane = gdu->surface();
154 static constexpr
double distFromBorder = 1.0;
155 double halfLength = 0.;
157 halfLength = trapBounds->parameters()[3];
158 }
else if (rectBounds) {
159 halfLength = .5 * gdu->surface().bounds().
length();
180 unsigned int eventnumber =
iEvent.id().event();
183 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " <<
runnumber <<
" and event " << eventnumber << std::endl;
195 LogDebug(
"SiStripGainsPCLWorker") << elem.first <<
" - " << elem.second.m_string <<
" " 196 << elem.second.m_subdetectorId <<
" " << elem.second.m_subdetectorSide <<
" " 197 << elem.second.m_subdetectorPlane << std::endl;
204 std::size_t nStoredClusters{0};
205 for (
const auto&
assoc : *trajTrackAssociations) {
206 const auto traj =
assoc.key.get();
215 for (
const auto& meas : traj->measurements()) {
216 const auto& trajState = meas.updatedState();
221 auto clusters = getClusters(meas.recHit()->hit());
222 for (
const auto hitCluster :
clusters) {
225 bool overlapping =
false;
229 if (hitCluster.strip) {
230 const auto& ampls = hitCluster.strip->amplitudes();
231 firstStrip = hitCluster.strip->firstStrip();
233 charge = hitCluster.strip->charge();
234 saturation = std::any_of(ampls.begin(), ampls.end(), [](uint8_t amp) {
return amp >= 254; });
236 overlapping = (((firstStrip % 128) == 0) || ((firstStrip / 128) != ((firstStrip +
int(
nStrips)) / 128)));
237 }
else if (hitCluster.pixel) {
238 const auto& ampls = hitCluster.pixel->pixelADC();
239 const int firstRow = hitCluster.pixel->minPixelRow();
240 const int firstCol = hitCluster.pixel->minPixelCol();
241 firstStrip = ((firstRow / 80) << 3 | (firstCol / 52)) * 128;
243 for (
const auto amp : ampls) {
250 std::shared_ptr<stAPVGain>
APV =
histograms.APVsColl.at((hitCluster.det << 4) | (firstStrip / 128));
252 const auto farFromEdge = (hitCluster.strip ?
isFarFromBorder(trajState, hitCluster.det, tGeom) :
true);
253 if ((
APV->SubDet > 2) &&
257 int clusterCharge = 0;
258 if (
APV->SubDet > 2) {
261 for (
const auto origCharge : hitCluster.strip->amplitudes()) {
265 stripCharge =
int(origCharge /
APV->CalibGain);
267 stripCharge =
int(origCharge * (
APV->PreviousGain /
APV->CalibGain));
271 stripCharge = origCharge;
273 stripCharge =
int(origCharge *
APV->PreviousGain);
276 if (stripCharge > 1024) {
279 }
else if (stripCharge > 254) {
283 clusterCharge += stripCharge;
291 clusterCharge =
charge / 265.0;
295 const auto path = (10. *
APV->Thickness) /
std::abs(trackDir.z() / trackDir.mag());
296 double ClusterChargeOverPath = ((double)clusterCharge) /
path;
297 if (
APV->SubDet > 2) {
299 ClusterChargeOverPath /=
APV->PreviousGain;
302 ClusterChargeOverPath *=
APV->PreviousGain;
311 histograms.Charge_Vs_Index[elepos]->Fill(
APV->Index, ClusterChargeOverPath);
314 <<
" i " << iCluster <<
" useCalibration " <<
useCalibration <<
" FirstSetOfConstants " 316 <<
" APV->DetId " <<
APV->DetId <<
" APV->Index " <<
APV->Index <<
" Charge " << clusterCharge <<
" Path " 317 <<
path <<
" ClusterChargeOverPath " << ClusterChargeOverPath << std::endl;
321 for (
const auto sCharge : hitCluster.strip->amplitudes()) {
329 int mCharge2 = mCharge1 *
APV->PreviousGain;
330 int mCharge3 = mCharge1 *
APV->PreviousGainTick;
331 int mCharge4 = mCharge1 *
APV->PreviousGain *
APV->PreviousGainTick;
333 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge " << mCharge1 <<
" remove G2 " << mCharge2 <<
" remove G1 " 334 << mCharge3 <<
" remove G1*G2 " << mCharge4 << std::endl;
348 histograms.Charge_Vs_PathlengthTIB[elepos]->Fill(
path, clusterCharge);
351 histograms.Charge_Vs_PathlengthTOB[elepos]->Fill(
path, clusterCharge);
355 histograms.Charge_Vs_PathlengthTIDM[elepos]->Fill(
path, clusterCharge);
357 else if (
APV->Eta > 0) {
358 histograms.Charge_Vs_PathlengthTIDP[elepos]->Fill(
path, clusterCharge);
363 if (
APV->Thickness < 0.04) {
364 histograms.Charge_Vs_PathlengthTECM1[elepos]->Fill(
path, clusterCharge);
366 else if (
APV->Thickness > 0.04) {
367 histograms.Charge_Vs_PathlengthTECM2[elepos]->Fill(
path, clusterCharge);
369 }
else if (
APV->Eta > 0) {
370 if (
APV->Thickness < 0.04) {
371 histograms.Charge_Vs_PathlengthTECP1[elepos]->Fill(
path, clusterCharge);
373 else if (
APV->Thickness > 0.04) {
374 histograms.Charge_Vs_PathlengthTECP2[elepos]->Fill(
path, clusterCharge);
384 histograms.EventStats->Fill(2., 0., nStoredClusters);
397 auto const&
Det = bareTkGeomPtr->
dets();
399 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct" << std::endl;
401 unsigned int Index = 0;
403 for (
unsigned int i = 0;
i <
Det.size();
i++) {
414 unsigned int NAPV = Topo.
nstrips() / 128;
416 for (
unsigned int j = 0;
j < NAPV;
j++) {
417 auto APV = std::make_shared<stAPVGain>();
434 APV->FitWidthErr = -1;
438 APV->PreviousGain = 1;
439 APV->PreviousGainTick = 1;
440 APV->x = DetUnit->position().basicVector().x();
441 APV->y = DetUnit->position().basicVector().y();
442 APV->z = DetUnit->position().basicVector().z();
443 APV->Eta = DetUnit->position().basicVector().eta();
444 APV->Phi = DetUnit->position().basicVector().phi();
445 APV->R = DetUnit->position().basicVector().transverse();
446 APV->Thickness = DetUnit->surface().bounds().thickness();
448 APV->isMasked =
false;
458 for (
unsigned int i = 0;
i <
Det.size();
468 unsigned int NROCRow = Topo.
nrows() / (80.);
469 unsigned int NROCCol = Topo.
ncolumns() / (52.);
471 for (
unsigned int j = 0;
j < NROCRow;
j++) {
472 for (
unsigned int i = 0;
i < NROCCol;
i++) {
473 auto APV = std::make_shared<stAPVGain>();
478 APV->APVId = (
j << 3 |
i);
483 APV->FitWidthErr = -1;
486 APV->PreviousGain = 1;
487 APV->PreviousGainTick = 1;
488 APV->x = DetUnit->position().basicVector().x();
489 APV->y = DetUnit->position().basicVector().y();
490 APV->z = DetUnit->position().basicVector().z();
491 APV->Eta = DetUnit->position().basicVector().eta();
492 APV->Phi = DetUnit->position().basicVector().phi();
493 APV->R = DetUnit->position().basicVector().transverse();
494 APV->Thickness = DetUnit->surface().bounds().thickness();
495 APV->isMasked =
false;
526 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " <<
tag 534 histograms.EventStats = ibooker.
book2I(
"EventStats",
"Statistics", 3, -0.5, 2.5, 1, 0, 1);
535 histograms.EventStats->setBinLabel(1,
"events count", 1);
536 histograms.EventStats->setBinLabel(2,
"tracks count", 1);
537 histograms.EventStats->setBinLabel(3,
"clusters count", 1);
540 if (!stag.empty() && stag[0] !=
'_')
541 stag.insert(0, 1,
'_');
573 std::vector<float> binXarray;
576 binXarray.push_back((
float)
a);
579 std::array<float, 688> binYarray;
581 double p1 = 0.002113;
582 double p2 = 69.01576;
584 for (
int b = 0;
b < 687;
b++) {
591 binYarray[687] = 4000.;
601 ibooker.
book2S(cvi.c_str(), cvi.c_str(),
histograms.NStripAPVs, &binXarray[0], 687, binYarray.data()));
603 it =
histograms.Charge_Vs_PathlengthTIB.begin();
604 histograms.Charge_Vs_PathlengthTIB.insert(it + elepos,
605 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
607 it =
histograms.Charge_Vs_PathlengthTOB.begin();
608 histograms.Charge_Vs_PathlengthTOB.insert(it + elepos,
609 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
611 it =
histograms.Charge_Vs_PathlengthTIDP.begin();
613 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
615 it =
histograms.Charge_Vs_PathlengthTIDM.begin();
617 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
619 it =
histograms.Charge_Vs_PathlengthTECP1.begin();
621 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
623 it =
histograms.Charge_Vs_PathlengthTECP2.begin();
625 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
627 it =
histograms.Charge_Vs_PathlengthTECM1.begin();
629 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
631 it =
histograms.Charge_Vs_PathlengthTECM2.begin();
633 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
635 std::vector<std::pair<std::string, std::string>> hnames =
637 for (
unsigned int i = 0;
i < hnames.size();
i++) {
643 for (
unsigned int i = 0;
i < hnames.size();
i++) {
649 for (
unsigned int i = 0;
i < hnames.size();
i++) {
655 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)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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
unsigned int tidSide(const DetId &id) 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)
unsigned int tecSide(const DetId &id) 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) ...
std::map< unsigned int, APVloc > theTopologyMap
void checkBookAPVColls(const TrackerGeometry *bareTkGeomPtr, const TrackerTopology *bareTkTopoPtr, APVGain::APVGainHistograms &histograms) const
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
constexpr uint32_t rawId() const
get the raw id
int subdetectorSide(uint32_t, const TrackerTopology *)
std::vector< std::string > VChargeHisto
double MaxTrackChiOverNdf
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoTokenBR_
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)