29 std::vector<std::pair<std::string, std::string>> hnames =
31 for (
unsigned int i = 0;
i < hnames.size();
i++) {
37 auto loc =
APVloc(
id, side, plane,
s);
72 #ifdef ExtendedCALIBTree
108 static constexpr
float defaultGainTick = 690. / 640.;
119 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
126 for (
unsigned int a = 0;
a <
histograms.APVsCollOrdered.size();
a++) {
135 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
140 if (
APV->PreviousGain != 1 and newPreviousGain !=
APV->PreviousGain)
141 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
142 APV->PreviousGain = newPreviousGain;
144 float newPreviousGainTick =
146 if (
APV->PreviousGainTick != 1 and newPreviousGainTick !=
APV->PreviousGainTick) {
148 <<
"WARNING: TickMarkGain in the global tag changed\n"
150 <<
" APV->SubDet: " <<
APV->SubDet <<
" APV->APVId:" <<
APV->APVId << std::endl
151 <<
" APV->PreviousGainTick: " <<
APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
154 APV->PreviousGainTick = newPreviousGainTick;
165 unsigned int eventnumber =
iEvent.id().event();
168 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();
220 auto saturation = handle10.
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;
563 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " <<
tag
566 ibooker.setCurrentFolder(dqm_dir);
571 histograms.EventStats = ibooker.book2S(
"EventStats",
"Statistics", 3, -0.5, 2.5, 1, 0, 1);
572 histograms.EventStats->setBinLabel(1,
"events count", 1);
573 histograms.EventStats->setBinLabel(2,
"tracks count", 1);
574 histograms.EventStats->setBinLabel(3,
"clusters count", 1);
577 if (!stag.empty() && stag[0] !=
'_')
578 stag.insert(0, 1,
'_');
610 std::vector<float> binXarray;
613 binXarray.push_back((
float)
a);
616 std::array<float, 688> binYarray;
618 double p1 = 0.002113;
619 double p2 = 69.01576;
621 for (
int b = 0;
b < 687;
b++) {
628 binYarray[687] = 4000.;
638 ibooker.book2S(cvi.c_str(), cvi.c_str(),
histograms.NStripAPVs, &binXarray[0], 687, binYarray.data()));
640 it =
histograms.Charge_Vs_PathlengthTIB.begin();
641 histograms.Charge_Vs_PathlengthTIB.insert(it + elepos,
642 ibooker.book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
644 it =
histograms.Charge_Vs_PathlengthTOB.begin();
645 histograms.Charge_Vs_PathlengthTOB.insert(it + elepos,
646 ibooker.book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
648 it =
histograms.Charge_Vs_PathlengthTIDP.begin();
650 it + elepos, ibooker.book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
652 it =
histograms.Charge_Vs_PathlengthTIDM.begin();
654 it + elepos, ibooker.book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
656 it =
histograms.Charge_Vs_PathlengthTECP1.begin();
658 it + elepos, ibooker.book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
660 it =
histograms.Charge_Vs_PathlengthTECP2.begin();
662 it + elepos, ibooker.book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
664 it =
histograms.Charge_Vs_PathlengthTECM1.begin();
666 it + elepos, ibooker.book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
668 it =
histograms.Charge_Vs_PathlengthTECM2.begin();
670 it + elepos, ibooker.book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
672 std::vector<std::pair<std::string, std::string>> hnames =
674 for (
unsigned int i = 0;
i < hnames.size();
i++) {
676 histograms.Charge_1[elepos].push_back(ibooker.book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
680 for (
unsigned int i = 0;
i < hnames.size();
i++) {
682 histograms.Charge_2[elepos].push_back(ibooker.book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
686 for (
unsigned int i = 0;
i < hnames.size();
i++) {
688 histograms.Charge_3[elepos].push_back(ibooker.book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
692 for (
unsigned int i = 0;
i < hnames.size();
i++) {
694 histograms.Charge_4[elepos].push_back(ibooker.book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));