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";
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;
120 : det(detId), strip(strip), pixel(pixel) {}
129 clusters.emplace_back(matched->monoId(), &matched->monoCluster(),
nullptr);
130 clusters.emplace_back(matched->stereoId(), &matched->stereoCluster(),
nullptr);
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();
164 if (
std::abs(pos.y()) + posError.yy() >= (halfLength - distFromBorder))
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();
205 const auto track = assoc.val.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) {
222 bool saturation =
false;
223 bool overlapping =
false;
227 if (hitCluster.strip) {
228 const auto& ampls = hitCluster.strip->amplitudes();
229 firstStrip = hitCluster.strip->firstStrip();
230 nStrips = ampls.size();
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 "
313 <<
FirstSetOfConstants <<
" APV->PreviousGain " << APV->PreviousGain <<
" APV->CalibGain " << APV->CalibGain
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;
337 histograms.
Charge_1[elepos][
m]->Fill(((
double)mCharge1) /
path);
338 for (
auto m : indices)
339 histograms.
Charge_2[elepos][
m]->Fill(((
double)mCharge2) /
path);
340 for (
auto m : indices)
341 histograms.
Charge_3[elepos][
m]->Fill(((
double)mCharge3) /
path);
342 for (
auto m : indices)
343 histograms.
Charge_4[elepos][
m]->Fill(((
double)mCharge4) /
path);
355 else if (APV->Eta > 0) {
361 if (APV->Thickness < 0.04) {
364 else if (APV->Thickness > 0.04) {
367 }
else if (APV->Eta > 0) {
368 if (APV->Thickness < 0.04) {
371 else if (APV->Thickness > 0.04) {
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>();
426 APV->FitWidthErr = -1;
430 APV->PreviousGain = 1;
431 APV->PreviousGainTick = 1;
432 APV->x = DetUnit->position().basicVector().x();
433 APV->y = DetUnit->position().basicVector().y();
434 APV->z = DetUnit->position().basicVector().z();
435 APV->Eta = DetUnit->position().basicVector().eta();
436 APV->Phi = DetUnit->position().basicVector().phi();
437 APV->R = DetUnit->position().basicVector().transverse();
438 APV->Thickness = DetUnit->surface().bounds().thickness();
440 APV->isMasked =
false;
450 for (
unsigned int i = 0;
i <
Det.size();
460 unsigned int NROCRow = Topo.
nrows() / (80.);
461 unsigned int NROCCol = Topo.
ncolumns() / (52.);
463 for (
unsigned int j = 0;
j < NROCRow;
j++) {
464 for (
unsigned int i = 0;
i < NROCCol;
i++) {
465 auto APV = std::make_shared<stAPVGain>();
469 APV->APVId = (
j << 3 |
i);
474 APV->FitWidthErr = -1;
477 APV->PreviousGain = 1;
478 APV->PreviousGainTick = 1;
479 APV->x = DetUnit->position().basicVector().x();
480 APV->y = DetUnit->position().basicVector().y();
481 APV->z = DetUnit->position().basicVector().z();
482 APV->Eta = DetUnit->position().basicVector().eta();
483 APV->Phi = DetUnit->position().basicVector().phi();
484 APV->R = DetUnit->position().basicVector().transverse();
485 APV->Thickness = DetUnit->surface().bounds().thickness();
486 APV->isMasked =
false;
517 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " << tag
525 histograms.
EventStats = ibooker.
book2S(
"EventStats",
"Statistics", 3, -0.5, 2.5, 1, 0, 1);
531 if (!stag.empty() && stag[0] !=
'_')
532 stag.insert(0, 1,
'_');
564 std::vector<float> binXarray;
567 binXarray.push_back((
float)
a);
570 std::array<float, 688> binYarray;
572 double p1 = 0.002113;
573 double p2 = 69.01576;
575 for (
int b = 0;
b < 687;
b++) {
580 y = (p0 -
log(
exp(p0 - p1 * y) - p2 * p1)) / p1;
582 binYarray[687] = 4000.;
584 histograms.
Charge_1[elepos].clear();
585 histograms.
Charge_2[elepos].clear();
586 histograms.
Charge_3[elepos].clear();
587 histograms.
Charge_4[elepos].clear();
592 ibooker.
book2S(cvi.c_str(), cvi.c_str(), histograms.
NStripAPVs, &binXarray[0], 687, binYarray.data()));
596 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
600 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
604 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
608 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
612 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
616 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
620 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
624 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
626 std::vector<std::pair<std::string, std::string>> hnames =
628 for (
unsigned int i = 0;
i < hnames.size();
i++) {
630 histograms.
Charge_1[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
634 for (
unsigned int i = 0;
i < hnames.size();
i++) {
636 histograms.
Charge_2[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
640 for (
unsigned int i = 0;
i < hnames.size();
i++) {
642 histograms.
Charge_3[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
646 for (
unsigned int i = 0;
i < hnames.size();
i++) {
648 histograms.
Charge_4[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
EventNumber_t event() const
static constexpr auto TEC
virtual int nstrips() const =0
T getUntrackedParameter(std::string const &, T const &) const
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_4
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=nullptr)
static std::vector< std::string > checklist log
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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_
virtual void setCurrentFolder(std::string const &fullpath)
virtual int ncolumns() const =0
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< dqm::reco::MonitorElement * > Charge_Vs_Index
LocalVector localDirection() const
LocalPoint localPosition() const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
SiStripGainsPCLWorker(const edm::ParameterSet &)
constexpr uint32_t rawId() const
get the raw id
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTOB
virtual int nrows() const =0
int subdetectorPlane(uint32_t, const TrackerTopology *)
std::string m_calibrationMode
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIDP
auto const & tracks
cannot be loose
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Exp< T >::type exp(const T &t)
Log< level::Error, false > LogError
edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
float length() const override
Lenght along local Y.
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
LocalError positionError() const
edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIDM
std::vector< std::string > dqm_tag_
bool doChargeMonitorPerPlane
bool getData(T &iHolder) const
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())
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECP2
void addDefault(ParameterSetDescription const &psetDescription)
std::atomic< unsigned int > NPixelDets
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomTokenBR_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_3
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::atomic< unsigned int > NStripAPVs
Abs< T >::type abs(const T &t)
std::map< unsigned int, APVloc > theTopologyMap
const LocalTrajectoryError & localError() const
static constexpr auto TOB
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Log< level::Info, false > LogInfo
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
static constexpr auto TIB
void checkBookAPVColls(const TrackerGeometry *bareTkGeomPtr, APVGain::APVGainHistograms &histograms) const
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
int subdetectorSide(uint32_t, const TrackerTopology *)
T getParameter(std::string const &) const
std::vector< std::string > VChargeHisto
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
double MaxTrackChiOverNdf
Pixel cluster – collection of neighboring pixels above threshold.
dqm::reco::MonitorElement * EventStats
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_1
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECM2
int statCollectionFromMode(const char *tag) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_2
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECM1
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
unsigned int MinTrackHits
static constexpr auto TID
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIB
int subdetectorId(uint32_t)
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECP1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)