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);
73 #ifdef ExtendedCALIBTree
105 gainToken_ = esConsumes<edm::Transition::BeginRun>();
114 static constexpr
float defaultGainTick = 690. / 640.;
121 if (!gainHandle.isValid()) {
122 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
128 for (
unsigned int a = 0;
a <
histograms.APVsCollOrdered.size();
a++) {
134 APV->isMasked = siStripQuality.IsApvBad(
APV->DetId,
APV->APVId);
136 if (gainHandle->getNumberOfTags() != 2) {
137 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
141 float newPreviousGain = gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 1), 1);
142 if (
APV->PreviousGain != 1 and newPreviousGain !=
APV->PreviousGain)
143 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
144 APV->PreviousGain = newPreviousGain;
146 float newPreviousGainTick =
147 APV->isMasked ? defaultGainTick : gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 0), 0);
148 if (
APV->PreviousGainTick != 1 and newPreviousGainTick !=
APV->PreviousGainTick) {
150 <<
"WARNING: TickMarkGain in the global tag changed\n"
152 <<
" APV->SubDet: " <<
APV->SubDet <<
" APV->APVId:" <<
APV->APVId << std::endl
153 <<
" APV->PreviousGainTick: " <<
APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
156 APV->PreviousGainTick = newPreviousGainTick;
167 unsigned int eventnumber =
iEvent.id().event();
170 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " <<
runnumber <<
" and event " << eventnumber << std::endl;
183 auto trackchi2ndof = handle01.
product();
187 auto trackp = handle02.
product();
191 auto tracketa = handle03.
product();
195 auto trackhitsvalid = handle04.
product();
199 auto trackalgo = handle05.
product();
204 auto trackindex = handle06.
product();
208 auto rawid = handle07.
product();
212 auto firststrip = handle08.
product();
216 auto nstrips = handle09.
product();
224 auto overlapping = handle11.
product();
228 auto farfromedge = handle12.
product();
238 #ifdef ExtendedCALIBTree
241 auto chargeoverpath = handle15.
product();
250 auto gainused = handle17.
product();
254 auto gainusedTick = handle18.
product();
257 LogDebug(
"SiStripGainsPCLWorker") << elem.first <<
" - " << elem.second.m_string <<
" "
258 << elem.second.m_subdetectorId <<
" " << elem.second.m_subdetectorSide <<
" "
259 << elem.second.m_subdetectorPlane << std::endl;
267 histograms.EventStats->Fill(1., 0., trackp->size());
270 unsigned int FirstAmplitude = 0;
271 for (
unsigned int i = 0;
i <
charge->size();
i++) {
272 FirstAmplitude += (*nstrips)[
i];
273 int TI = (*trackindex)[
i];
295 if (
APV->SubDet > 2 && (*farfromedge)[
i] ==
false)
297 if (
APV->SubDet > 2 && (*overlapping)[
i] ==
true)
306 bool Saturation =
false;
307 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
308 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
310 StripCharge = (
int)(StripCharge * (
APV->PreviousGain /
APV->CalibGain));
312 StripCharge = (
int)(StripCharge /
APV->CalibGain);
314 StripCharge = (
int)(StripCharge *
APV->PreviousGain);
316 if (StripCharge > 1024) {
319 }
else if (StripCharge > 254) {
327 }
else if (
APV->SubDet > 2) {
333 double ClusterChargeOverPath = ((double)
Charge) / (*path)[
i];
334 if (
APV->SubDet > 2) {
336 ClusterChargeOverPath /= (*gainused)[
i];
339 ClusterChargeOverPath *= (*gainused)[
i];
344 if (
APV->SubDet <= 2)
348 histograms.Charge_Vs_Index[elepos]->Fill(
APV->Index, ClusterChargeOverPath);
350 <<
" i " <<
i <<
" useCalibration " <<
useCalibration <<
" FirstSetOfConstants "
352 <<
" APV->CalibGain " <<
APV->CalibGain <<
" APV->DetId " <<
APV->DetId
353 <<
" APV->Index " <<
APV->Index <<
" Charge " <<
Charge <<
" Path " << (*path)[
i]
354 <<
" ClusterChargeOverPath " << ClusterChargeOverPath << std::endl;
361 if (
APV->SubDet > 2) {
362 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
363 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
364 if (StripCharge > 1024)
366 else if (StripCharge > 254)
368 mCharge1 += StripCharge;
369 mCharge2 += StripCharge;
370 mCharge3 += StripCharge;
371 mCharge4 += StripCharge;
374 mCharge2 *= (*gainused)[
i];
375 mCharge3 *= (*gainusedTick)[
i];
376 mCharge4 *= ((*gainused)[
i] * (*gainusedTick)[
i]);
379 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge " << mCharge1 <<
" remove G2 " << mCharge2 <<
" remove G1 "
380 << mCharge3 <<
" remove G1*G2 " << mCharge4 << std::endl;
403 else if (
APV->Eta > 0) {
409 if (
APV->Thickness < 0.04) {
412 else if (
APV->Thickness > 0.04) {
415 }
else if (
APV->Eta > 0) {
416 if (
APV->Thickness < 0.04) {
419 else if (
APV->Thickness > 0.04) {
440 auto const&
Det = bareTkGeomPtr->
dets();
442 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct" << std::endl;
444 unsigned int Index = 0;
446 for (
unsigned int i = 0;
i <
Det.size();
i++) {
452 auto DetUnit = dynamic_cast<const StripGeomDetUnit*>(
Det[
i]);
457 unsigned int NAPV = Topo.
nstrips() / 128;
459 for (
unsigned int j = 0;
j < NAPV;
j++) {
460 auto APV = std::make_shared<stAPVGain>();
469 APV->FitWidthErr = -1;
473 APV->PreviousGain = 1;
474 APV->PreviousGainTick = 1;
475 APV->x = DetUnit->position().basicVector().x();
476 APV->y = DetUnit->position().basicVector().y();
477 APV->z = DetUnit->position().basicVector().z();
478 APV->Eta = DetUnit->position().basicVector().eta();
479 APV->Phi = DetUnit->position().basicVector().phi();
480 APV->R = DetUnit->position().basicVector().transverse();
481 APV->Thickness = DetUnit->surface().bounds().thickness();
483 APV->isMasked =
false;
493 for (
unsigned int i = 0;
i <
Det.size();
498 auto DetUnit = dynamic_cast<const PixelGeomDetUnit*>(
Det[
i]);
503 unsigned int NROCRow = Topo.
nrows() / (80.);
504 unsigned int NROCCol = Topo.
ncolumns() / (52.);
506 for (
unsigned int j = 0;
j < NROCRow;
j++) {
507 for (
unsigned int i = 0;
i < NROCCol;
i++) {
508 auto APV = std::make_shared<stAPVGain>();
512 APV->APVId = (
j << 3 |
i);
517 APV->FitWidthErr = -1;
520 APV->PreviousGain = 1;
521 APV->PreviousGainTick = 1;
522 APV->x = DetUnit->position().basicVector().x();
523 APV->y = DetUnit->position().basicVector().y();
524 APV->z = DetUnit->position().basicVector().z();
525 APV->Eta = DetUnit->position().basicVector().eta();
526 APV->Phi = DetUnit->position().basicVector().phi();
527 APV->R = DetUnit->position().basicVector().transverse();
528 APV->Thickness = DetUnit->surface().bounds().thickness();
529 APV->isMasked =
false;
560 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " <<
tag
568 histograms.EventStats = ibooker.
book2S(
"EventStats",
"Statistics", 3, -0.5, 2.5, 1, 0, 1);
569 histograms.EventStats->setBinLabel(1,
"events count", 1);
570 histograms.EventStats->setBinLabel(2,
"tracks count", 1);
571 histograms.EventStats->setBinLabel(3,
"clusters count", 1);
574 if (!stag.empty() && stag[0] !=
'_')
575 stag.insert(0, 1,
'_');
607 std::vector<float> binXarray;
610 binXarray.push_back((
float)
a);
613 std::array<float, 688> binYarray;
615 double p1 = 0.002113;
616 double p2 = 69.01576;
618 for (
int b = 0;
b < 687;
b++) {
625 binYarray[687] = 4000.;
635 ibooker.
book2S(cvi.c_str(), cvi.c_str(),
histograms.NStripAPVs, &binXarray[0], 687, binYarray.data()));
637 it =
histograms.Charge_Vs_PathlengthTIB.begin();
638 histograms.Charge_Vs_PathlengthTIB.insert(it + elepos,
639 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
641 it =
histograms.Charge_Vs_PathlengthTOB.begin();
642 histograms.Charge_Vs_PathlengthTOB.insert(it + elepos,
643 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
645 it =
histograms.Charge_Vs_PathlengthTIDP.begin();
647 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
649 it =
histograms.Charge_Vs_PathlengthTIDM.begin();
651 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
653 it =
histograms.Charge_Vs_PathlengthTECP1.begin();
655 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
657 it =
histograms.Charge_Vs_PathlengthTECP2.begin();
659 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
661 it =
histograms.Charge_Vs_PathlengthTECM1.begin();
663 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
665 it =
histograms.Charge_Vs_PathlengthTECM2.begin();
667 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
669 std::vector<std::pair<std::string, std::string>> hnames =
671 for (
unsigned int i = 0;
i < hnames.size();
i++) {
677 for (
unsigned int i = 0;
i < hnames.size();
i++) {
683 for (
unsigned int i = 0;
i < hnames.size();
i++) {
689 for (
unsigned int i = 0;
i < hnames.size();
i++) {