37 #include "TGraphErrors.h" 44 #include "TPaveStats.h" 56 SiStripNoisesTest() :
cond::payloadInspector::Histogram1D<
SiStripNoises>(
"SiStrip Noise test",
57 "SiStrip Noise test", 10,0.0,10.0),
63 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
64 for (
auto const & iov: iovs) {
71 ss <<
"Summary of strips noises:" << std::endl;
74 payload->printSummary(ss,&m_trackerTopo);
76 std::vector<uint32_t> detid;
77 payload->getDetIds(detid);
107 SiStripNoiseValue() :
cond::payloadInspector::Histogram1D<
SiStripNoises>(
"SiStrip Noise values",
108 "SiStrip Noise values", 100,0.0,10.0){
109 Base::setSingleIov(
true );
112 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
113 for (
auto const & iov: iovs) {
114 std::shared_ptr<SiStripNoises> payload = Base::fetchPayload( std::get<1>(iov) );
117 std::vector<uint32_t> detid;
118 payload->getDetIds(detid);
120 for (
const auto &
d : detid) {
122 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
123 auto noise = payload->getNoise(it,range);
125 fillWithValue(noise);
143 SiStripNoiseDistribution() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"SiStrip Noise values"){
144 setSingleIov(
true );
147 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
148 auto iov = iovs.front();
150 TGaxis::SetMaxDigits(3);
151 gStyle->SetOptStat(
"emr");
153 std::shared_ptr<SiStripNoises> payload = fetchPayload( std::get<1>(iov) );
157 Form(
"#LT Strip Noise #GT per %s for IOV [%s];#LTStrip Noise per %s#GT [ADC counts];n. %ss",
158 opType(op_mode_).c_str(),std::to_string(std::get<0>(iov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
161 unsigned int prev_det=0, prev_apv=0;
164 std::vector<uint32_t> detids;
165 payload->getDetIds(detids);
168 for (
const auto &
d : detids) {
171 unsigned int istrip=0;
173 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
174 auto noise = payload->getNoise(it,range);
178 flush = (prev_det != 0 && prev_apv != istrip/128);
181 flush = (prev_det != 0 && prev_det !=
d);
184 flush = (istrip != 0);
189 mon1D->Fill(prev_apv,prev_det,enoise.
mean());
193 enoise.
add(std::min<float>(noise, 30.5));
194 prev_apv = istrip/128;
201 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
203 canvas.SetBottomMargin(0.11);
204 canvas.SetTopMargin(0.07);
205 canvas.SetLeftMargin(0.13);
206 canvas.SetRightMargin(0.05);
209 auto hist = mon1D->getHist();
211 hist.SetStats(kTRUE);
212 hist.SetFillColorAlpha(kRed,0.35);
217 TPaveStats *st = (TPaveStats*)
hist.GetListOfFunctions()->FindObject(
"stats");
218 st->SetLineColor(kRed);
219 st->SetTextColor(kRed);
220 st->SetX1NDC(.75); st->SetX2NDC(.95);
221 st->SetY1NDC(.83); st->SetY2NDC(.93);
223 TLegend
legend = TLegend(0.13,0.83,0.43,0.93);
224 legend.SetHeader(Form(
"SiStrip Noise values per %s",opType(op_mode_).c_str()),
"C");
225 legend.AddEntry(&
hist,(
"IOV: "+std::to_string(std::get<0>(iov))).c_str(),
"F");
226 legend.SetTextSize(0.025);
243 typedef SiStripNoiseDistribution<SiStripPI::STRIP_BASED> SiStripNoiseValuePerStrip;
244 typedef SiStripNoiseDistribution<SiStripPI::APV_BASED> SiStripNoiseValuePerAPV;
245 typedef SiStripNoiseDistribution<SiStripPI::MODULE_BASED> SiStripNoiseValuePerModule;
255 SiStripNoiseDistributionComparison() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"SiStrip Noise values comparison"){
256 setSingleIov(
false );
259 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
261 std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
264 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
265 return std::get<0>(t1) < std::get<0>(t2);
268 auto firstiov = sorted_iovs.front();
269 auto lastiov = sorted_iovs.back();
271 std::shared_ptr<SiStripNoises> f_payload = fetchPayload( std::get<1>(firstiov) );
272 std::shared_ptr<SiStripNoises> l_payload = fetchPayload( std::get<1>(lastiov) );
276 Form(
"#LT Strip Noise #GT per %s for IOV [%s,%s];#LTStrip Noise per %s#GT [ADC counts];n. %ss",
277 opType(op_mode_).c_str(),std::to_string(std::get<0>(firstiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
282 Form(
"#LT Strip Noise #GT per %s for IOV [%s,%s];#LTStrip Noise per %s#GT [ADC counts];n. %ss",
283 opType(op_mode_).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
286 unsigned int prev_det=0, prev_apv=0;
289 std::vector<uint32_t> f_detid;
290 f_payload->getDetIds(f_detid);
293 for (
const auto &
d : f_detid) {
296 unsigned int istrip=0;
297 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
298 float noise = f_payload->getNoise(it,range);
304 flush = (prev_det != 0 && prev_apv != istrip/128);
307 flush = (prev_det != 0 && prev_det !=
d);
310 flush = (istrip != 0);
315 f_mon->Fill(prev_apv,prev_det,enoise.
mean());
318 enoise.
add(std::min<float>(noise, 30.5));
319 prev_apv = istrip/128;
325 prev_det=0, prev_apv=0;
328 std::vector<uint32_t> l_detid;
329 l_payload->getDetIds(l_detid);
332 for (
const auto &
d : l_detid) {
335 unsigned int istrip=0;
336 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
337 float noise = l_payload->getNoise(it,range);
342 flush = (prev_det != 0 && prev_apv != istrip/128);
345 flush = (prev_det != 0 && prev_det !=
d);
348 flush = (istrip != 0);
353 l_mon->Fill(prev_apv,prev_det,enoise.
mean());
357 enoise.
add(std::min<float>(noise, 30.5));
358 prev_apv = istrip/128;
364 auto h_first = f_mon->getHist();
365 h_first.SetStats(kFALSE);
366 auto h_last = l_mon->getHist();
367 h_last.SetStats(kFALSE);
372 h_first.GetYaxis()->CenterTitle(
true);
373 h_last.GetYaxis()->CenterTitle(
true);
375 h_first.GetXaxis()->CenterTitle(
true);
376 h_last.GetXaxis()->CenterTitle(
true);
378 h_first.SetLineWidth(2);
379 h_last.SetLineWidth(2);
381 h_first.SetLineColor(kBlack);
382 h_last.SetLineColor(kBlue);
385 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
387 canvas.SetBottomMargin(0.11);
388 canvas.SetLeftMargin(0.13);
389 canvas.SetRightMargin(0.05);
392 float theMax = (h_first.GetMaximum() > h_last.GetMaximum()) ? h_first.GetMaximum() : h_last.GetMaximum();
394 h_first.SetMaximum(theMax*1.30);
395 h_last.SetMaximum(theMax*1.30);
400 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
401 legend.SetHeader(
"SiStrip Noise comparison",
"C");
402 legend.AddEntry(&h_first,(
"IOV: "+std::to_string(std::get<0>(firstiov))).c_str(),
"F");
403 legend.AddEntry(&h_last, (
"IOV: "+std::to_string(std::get<0>(lastiov))).c_str(),
"F");
404 legend.SetTextSize(0.025);
421 typedef SiStripNoiseDistributionComparison<SiStripPI::STRIP_BASED> SiStripNoiseValueComparisonPerStrip;
422 typedef SiStripNoiseDistributionComparison<SiStripPI::APV_BASED> SiStripNoiseValueComparisonPerAPV;
423 typedef SiStripNoiseDistributionComparison<SiStripPI::MODULE_BASED> SiStripNoiseValueComparisonPerModule;
434 SiStripNoiseValueComparison() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"SiStrip Noise values comparison"){
435 setSingleIov(
false );
438 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
440 std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
443 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
444 return std::get<0>(t1) < std::get<0>(t2);
447 auto firstiov = sorted_iovs.front();
448 auto lastiov = sorted_iovs.back();
450 std::shared_ptr<SiStripNoises> f_payload = fetchPayload( std::get<1>(firstiov) );
451 std::shared_ptr<SiStripNoises> l_payload = fetchPayload( std::get<1>(lastiov) );
453 auto h_first = std::unique_ptr<TH1F>(
new TH1F(
"f_Noise",Form(
"Strip noise values comparison [%s,%s];Strip Noise [ADC counts];n. strips",std::to_string(std::get<0>(firstiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str()),100,0.1,10.));
454 h_first->SetStats(
false);
456 auto h_last = std::unique_ptr<TH1F>(
new TH1F(
"l_Noise",Form(
"Strip noise values comparison [%s,%s];Strip Noise [ADC counts];n. strips",std::to_string(std::get<0>(firstiov)).c_str(),std::to_string(std::get<0>(lastiov)).c_str()),100,0.1,10.));
457 h_last->SetStats(
false);
459 std::vector<uint32_t> f_detid;
460 f_payload->getDetIds(f_detid);
463 for (
const auto &
d : f_detid) {
465 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
466 float noise = f_payload->getNoise(it,range);
468 h_first->Fill(noise);
472 std::vector<uint32_t> l_detid;
473 l_payload->getDetIds(l_detid);
476 for (
const auto &
d : l_detid) {
478 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
479 float noise = l_payload->getNoise(it,range);
486 h_first->GetYaxis()->CenterTitle(
true);
487 h_last->GetYaxis()->CenterTitle(
true);
489 h_first->GetXaxis()->CenterTitle(
true);
490 h_last->GetXaxis()->CenterTitle(
true);
492 h_first->SetLineWidth(2);
493 h_last->SetLineWidth(2);
495 h_first->SetLineColor(kBlack);
496 h_last->SetLineColor(kBlue);
499 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
501 canvas.SetBottomMargin(0.11);
502 canvas.SetLeftMargin(0.13);
503 canvas.SetRightMargin(0.05);
506 float theMax = (h_first->GetMaximum() > h_last->GetMaximum()) ? h_first->GetMaximum() : h_last->GetMaximum();
508 h_first->SetMaximum(theMax*1.30);
509 h_last->SetMaximum(theMax*1.30);
512 h_last->Draw(
"same");
514 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
515 legend.SetHeader(
"SiStrip Noise comparison",
"C");
516 legend.AddEntry(h_first.get(),(
"IOV: "+std::to_string(std::get<0>(firstiov))).c_str(),
"F");
517 legend.AddEntry(h_last.get(), (
"IOV: "+std::to_string(std::get<0>(lastiov))).c_str(),
"F");
518 legend.SetTextSize(0.025);
538 setSingleIov(
true );
541 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
542 auto iov = iovs.front();
543 std::shared_ptr<SiStripNoises> payload = fetchPayload( std::get<1>(iov) );
547 std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(
new TrackerMap(
"SiStripNoises"));
548 tmap->setTitle(titleMap);
552 std::map<unsigned int,float> info_per_detid;
556 std::vector<float> vstripnoise;
558 for(;rit!=erit;++rit){
559 Nstrips = (rit->iend-rit->ibegin)*8/9;
560 vstripnoise.resize(Nstrips);
561 payload->allNoises(vstripnoise,make_pair(payload->getDataVectorBegin()+rit->ibegin,payload->getDataVectorBegin()+rit->iend));
562 mean=0; rms=0; min=10000; max=0;
564 DetId detId(rit->detid);
566 for(
size_t i=0;
i<Nstrips;++
i){
567 mean+=vstripnoise[
i];
568 rms+=vstripnoise[
i]*vstripnoise[
i];
569 if(vstripnoise[
i]<min) min=vstripnoise[
i];
570 if(vstripnoise[
i]>max) max=vstripnoise[
i];
574 if((rms/Nstrips-mean*mean)>0.){
575 rms =
sqrt(rms/Nstrips-mean*mean);
582 info_per_detid[rit->detid]=
min;
585 info_per_detid[rit->detid]=
max;
588 info_per_detid[rit->detid]=
mean;
591 info_per_detid[rit->detid]=
rms;
601 for (
const auto &item : info_per_detid){
602 tmap->fill(item.first,item.second);
611 tmap->save(
true,0.,range.second,
fileName);
613 tmap->save(
true,range.first,range.second,
fileName);
620 typedef SiStripNoiseTrackerMap<SiStripPI::min> SiStripNoiseMin_TrackerMap;
621 typedef SiStripNoiseTrackerMap<SiStripPI::max> SiStripNoiseMax_TrackerMap;
622 typedef SiStripNoiseTrackerMap<SiStripPI::mean> SiStripNoiseMean_TrackerMap;
623 typedef SiStripNoiseTrackerMap<SiStripPI::rms> SiStripNoiseRMS_TrackerMap;
632 SiStripNoiseRatioWithPreviousIOVTrackerMap() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"Tracker Map of ratio of SiStripNoises "+
estimatorType(est)+
"with previous IOV"){
633 setSingleIov(
false );
636 std::map<unsigned int,float>computeEstimator(std::shared_ptr<SiStripNoises> payload){
638 std::map<unsigned int,float> info_per_detid;
641 std::vector<float> vstripnoise;
643 for(;rit!=erit;++rit){
644 Nstrips = (rit->iend-rit->ibegin)*8/9;
645 vstripnoise.resize(Nstrips);
646 payload->allNoises(vstripnoise,make_pair(payload->getDataVectorBegin()+rit->ibegin,payload->getDataVectorBegin()+rit->iend));
647 mean=0; rms=0; min=10000; max=0;
649 DetId detId(rit->detid);
651 for(
size_t i=0;
i<Nstrips;++
i){
652 mean+=vstripnoise[
i];
653 rms+=vstripnoise[
i]*vstripnoise[
i];
654 if(vstripnoise[
i]<min) min=vstripnoise[
i];
655 if(vstripnoise[
i]>max) max=vstripnoise[
i];
659 if((rms/Nstrips-mean*mean)>0.){
660 rms =
sqrt(rms/Nstrips-mean*mean);
666 info_per_detid[rit->detid]=
min;
669 info_per_detid[rit->detid]=
max;
672 info_per_detid[rit->detid]=
mean;
675 info_per_detid[rit->detid]=
rms;
682 return info_per_detid;
687 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
689 std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
691 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
692 return std::get<0>(t1) < std::get<0>(t2);
695 auto firstiov = sorted_iovs.front();
696 auto lastiov = sorted_iovs.back();
698 std::shared_ptr<SiStripNoises> last_payload = fetchPayload( std::get<1>(lastiov) );
699 std::shared_ptr<SiStripNoises> first_payload = fetchPayload( std::get<1>(firstiov) );
703 titleMap+=std::to_string(std::get<0>(firstiov));
705 titleMap+=std::to_string(std::get<0>(lastiov));
708 titleMap+=+
" "+std::to_string(nsigma)+
" std. dev. saturation";
711 std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(
new TrackerMap(
"SiStripNoises"));
712 tmap->setTitle(titleMap);
716 std::map<unsigned int,float> map_first,map_second;
718 map_first = computeEstimator(first_payload);
719 map_second = computeEstimator(last_payload);
720 std::map<unsigned int,float> cachedRatio;
722 for (
auto entry : map_first){
723 auto it2 = map_second.find(
entry.first);
724 if (it2==map_second.end() || it2->second==0)
continue;
725 tmap->fill(
entry.first,
entry.second/it2->second);
726 cachedRatio[
entry.first]=(
entry.second/it2->second);
732 tmap->save(
true,0.,range.second,
fileName);
734 tmap->save(
true,range.first,range.second,
fileName);
742 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::min,1> SiStripNoiseMin_RatioWithPreviousIOV1sigmaTrackerMap;
743 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::max,1> SiStripNoiseMax_RatioWithPreviousIOV1sigmaTrackerMap;
744 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::mean,1> SiStripNoiseMean_RatioWithPreviousIOV1sigmaTrackerMap;
745 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::rms,1> SiStripNoiseRms_RatioWithPreviousIOV1sigmaTrackerMap;
746 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::min,2> SiStripNoiseMin_RatioWithPreviousIOV2sigmaTrackerMap;
747 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::max,2> SiStripNoiseMax_RatioWithPreviousIOV2sigmaTrackerMap;
748 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::mean,2> SiStripNoiseMean_RatioWithPreviousIOV2sigmaTrackerMap;
749 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::rms,2> SiStripNoiseRms_RatioWithPreviousIOV2sigmaTrackerMap;
750 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::min,3> SiStripNoiseMin_RatioWithPreviousIOV3sigmaTrackerMap;
751 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::max,3> SiStripNoiseMax_RatioWithPreviousIOV3sigmaTrackerMap;
752 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::mean,3> SiStripNoiseMean_RatioWithPreviousIOV3sigmaTrackerMap;
753 typedef SiStripNoiseRatioWithPreviousIOVTrackerMap<SiStripPI::rms,3> SiStripNoiseRms_RatioWithPreviousIOV3sigmaTrackerMap;
764 setSingleIov(
true );
767 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
768 auto iov = iovs.front();
769 std::shared_ptr<SiStripNoises> payload = fetchPayload( std::get<1>(iov) );
775 std::map<unsigned int, SiStripDetSummary::Values>
map = summaryNoise.getCounts();
778 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
780 auto h1 = std::unique_ptr<TH1F>(
new TH1F(
"byRegion",Form(
"Average by partition of %s SiStrip Noise per module;;average SiStrip Noise %s [ADC counts]",
estimatorType(est).c_str(),
estimatorType(est).c_str()),map.size(),0.,map.size()));
782 canvas.SetBottomMargin(0.18);
783 canvas.SetLeftMargin(0.17);
784 canvas.SetRightMargin(0.05);
787 std::vector<int> boundaries;
793 for (
const auto &element : map){
795 int count = element.second.count;
796 double mean = (element.second.mean)/count;
797 double rms = (element.second.rms)/count - mean*mean;
804 if(currentDetector.empty()) currentDetector=
"TIB";
806 switch ((element.first)/1000)
822 h1->SetBinContent(iBin,mean);
824 h1->GetXaxis()->LabelsOption(
"v");
826 if(detector!=currentDetector) {
827 boundaries.push_back(iBin);
832 h1->SetMarkerStyle(20);
833 h1->SetMarkerSize(1);
834 h1->SetMaximum(h1->GetMaximum()*1.1);
840 TLine
l[boundaries.size()];
842 for (
const auto &
line : boundaries){
844 l[
i].SetLineWidth(1);
845 l[
i].SetLineStyle(9);
846 l[
i].SetLineColor(2);
851 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
852 legend.SetHeader((std::get<1>(iov)).c_str(),
"C");
853 legend.AddEntry(h1.get(),(
"IOV: "+std::to_string(std::get<0>(iov))).c_str(),
"PL");
854 legend.SetTextSize(0.025);
866 typedef SiStripNoiseByRegion<SiStripPI::mean> SiStripNoiseMeanByRegion;
867 typedef SiStripNoiseByRegion<SiStripPI::min> SiStripNoiseMinByRegion;
868 typedef SiStripNoiseByRegion<SiStripPI::max> SiStripNoiseMaxByRegion;
869 typedef SiStripNoiseByRegion<SiStripPI::rms> SiStripNoiseRMSByRegion;
877 SiStripNoiseComparatorByRegion() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"SiStrip Noise "+
estimatorType(est)+
" comparator by Region" ),
880 setSingleIov(
false );
883 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
885 std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
888 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
889 return std::get<0>(t1) < std::get<0>(t2);
892 auto firstiov = sorted_iovs.front();
893 auto lastiov = sorted_iovs.back();
895 std::shared_ptr<SiStripNoises> f_payload = fetchPayload( std::get<1>(firstiov) );
896 std::shared_ptr<SiStripNoises> l_payload = fetchPayload( std::get<1>(lastiov) );
904 std::map<unsigned int, SiStripDetSummary::Values> f_map = f_summaryNoise.getCounts();
905 std::map<unsigned int, SiStripDetSummary::Values> l_map = l_summaryNoise.getCounts();
908 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
911 auto hfirst = std::unique_ptr<TH1F>(
new TH1F(
"f_byRegion",Form(
"Average by partition of %s SiStrip Noise per module;;average SiStrip Noise %s [ADC counts]",
estimatorType(est).c_str(),
estimatorType(est).c_str()),f_map.size(),0.,f_map.size()));
912 hfirst->SetStats(
false);
914 auto hlast = std::unique_ptr<TH1F>(
new TH1F(
"l_byRegion",Form(
"Average by partition of %s SiStrip Noise per module;;average SiStrip Noise %s [ADC counts]",
estimatorType(est).c_str(),
estimatorType(est).c_str()),l_map.size(),0.,l_map.size()));
915 hlast->SetStats(
false);
917 canvas.SetBottomMargin(0.18);
918 canvas.SetLeftMargin(0.17);
919 canvas.SetRightMargin(0.05);
922 std::vector<int> boundaries;
928 for (
const auto &element : f_map){
930 int count = element.second.count;
931 double mean = (element.second.mean)/count;
932 double rms = (element.second.rms)/count - mean*mean;
939 if(currentDetector.empty()) currentDetector=
"TIB";
941 switch ((element.first)/1000)
957 hfirst->SetBinContent(iBin,mean);
960 hfirst->GetXaxis()->LabelsOption(
"v");
962 if(detector!=currentDetector) {
963 boundaries.push_back(iBin);
971 for (
const auto &element : l_map){
973 int count = element.second.count;
974 double mean = (element.second.mean)/count;
975 double rms = (element.second.rms)/count - mean*mean;
982 hlast->SetBinContent(iBin,mean);
985 hlast->GetXaxis()->LabelsOption(
"v");
988 float theMax = (hfirst->GetMaximum() > hlast->GetMaximum()) ? hfirst->GetMaximum() : hlast->GetMaximum();
989 float theMin = (hfirst->GetMinimum() < hlast->GetMinimum()) ? hfirst->GetMinimum() : hlast->GetMinimum();
991 hfirst->SetMarkerStyle(20);
992 hfirst->SetMarkerSize(1);
993 hfirst->GetYaxis()->SetTitleOffset(1.3);
994 hfirst->GetYaxis()->SetRangeUser(theMin*0.9,theMax*1.1);
995 hfirst->Draw(
"HIST");
996 hfirst->Draw(
"Psame");
998 hlast->SetMarkerStyle(21);
999 hlast->SetMarkerSize(1);
1000 hlast->SetMarkerColor(kBlue);
1001 hlast->SetLineColor(kBlue);
1002 hlast->GetYaxis()->SetTitleOffset(1.3);
1003 hlast->GetYaxis()->SetRangeUser(theMin*0.9,theMax*1.1);
1004 hlast->Draw(
"HISTsame");
1005 hlast->Draw(
"Psame");
1009 TLine l[boundaries.size()];
1011 for (
const auto &
line : boundaries){
1012 l[
i] = TLine(hfirst->GetBinLowEdge(
line),
canvas.GetUymin(),hfirst->GetBinLowEdge(
line),
canvas.GetUymax());
1013 l[
i].SetLineWidth(1);
1014 l[
i].SetLineStyle(9);
1015 l[
i].SetLineColor(2);
1020 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
1021 legend.SetHeader((
"SiStrip Noise "+
estimatorType(est)+
" by region").c_str(),
"C");
1022 legend.AddEntry(hfirst.get(),(
"IOV: "+std::to_string(std::get<0>(firstiov))).c_str(),
"PL");
1023 legend.AddEntry(hlast.get(), (
"IOV: "+std::to_string(std::get<0>(lastiov))).c_str(),
"PL");
1024 legend.SetTextSize(0.025);
1025 legend.Draw(
"same");
1036 typedef SiStripNoiseComparatorByRegion<SiStripPI::mean> SiStripNoiseComparatorMeanByRegion;
1037 typedef SiStripNoiseComparatorByRegion<SiStripPI::min> SiStripNoiseComparatorMinByRegion;
1038 typedef SiStripNoiseComparatorByRegion<SiStripPI::max> SiStripNoiseComparatorMaxByRegion;
1039 typedef SiStripNoiseComparatorByRegion<SiStripPI::rms> SiStripNoiseComparatorRMSByRegion;
1046 SiStripNoiseLinearity() :
cond::payloadInspector::PlotImage<
SiStripNoises>(
"Linearity of Strip Noise as a fuction of strip length" ){
1047 setSingleIov(
true );
1050 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
1051 auto iov = iovs.front();
1052 std::shared_ptr<SiStripNoises> payload = fetchPayload( std::get<1>(iov) );
1057 std::vector<uint32_t> detid;
1058 payload->getDetIds(detid);
1060 std::map<float,std::tuple<int,float,float> > noisePerStripLength;
1062 for (
const auto &
d : detid) {
1064 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
1065 auto noise = payload->getNoise(it,range);
1068 std::get<0>(noisePerStripLength[stripL])+=1;
1069 std::get<1>(noisePerStripLength[stripL])+=noise;
1070 std::get<2>(noisePerStripLength[stripL])+=(noise*noise);
1074 TCanvas
canvas(
"Noise linearity",
"noise linearity",1200,1000);
1077 std::vector<float>
x; x.reserve(noisePerStripLength.size());
1078 std::vector<float>
y; y.reserve(noisePerStripLength.size());
1079 std::vector<float> ex; ex.reserve(noisePerStripLength.size());
1080 std::vector<float> ey; ey.reserve(noisePerStripLength.size());
1082 for (
const auto &element : noisePerStripLength ){
1083 x.push_back(element.first);
1085 float sum = std::get<1>(element.second);
1086 float sum2 = std::get<2>(element.second);
1087 float nstrips = std::get<0>(element.second);
1088 float mean = sum/nstrips;
1089 float rms = (sum2/nstrips-mean*
mean)>0. ?
sqrt(sum2/nstrips-mean*mean) : 0.;
1095 auto graph = std::unique_ptr<TGraphErrors>(
new TGraphErrors(noisePerStripLength.size(),&x[0], &y[0],&ex[0],&ey[0]));
1096 graph->SetTitle(
"SiStrip Noise Linearity");
1097 graph->GetXaxis()->SetTitle(
"Strip length [cm]");
1098 graph->GetYaxis()->SetTitle(
"Average Strip Noise [ADC counts]");
1099 graph->SetMarkerColor(kBlue);
1100 graph->SetMarkerStyle(20);
1101 graph->SetMarkerSize(1.5);
1102 canvas.SetBottomMargin(0.13);
1103 canvas.SetLeftMargin(0.17);
1104 canvas.SetTopMargin(0.08);
1105 canvas.SetRightMargin(0.05);
1109 graph->GetXaxis()->CenterTitle(
true);
1110 graph->GetYaxis()->CenterTitle(
true);
1111 graph->GetXaxis()->SetTitleFont(42);
1112 graph->GetYaxis()->SetTitleFont(42);
1113 graph->GetXaxis()->SetTitleSize(0.05);
1114 graph->GetYaxis()->SetTitleSize(0.05);
1115 graph->GetXaxis()->SetTitleOffset(1.1);
1116 graph->GetYaxis()->SetTitleOffset(1.3);
1117 graph->GetXaxis()->SetLabelFont(42);
1118 graph->GetYaxis()->SetLabelFont(42);
1119 graph->GetYaxis()->SetLabelSize(.05);
1120 graph->GetXaxis()->SetLabelSize(.05);
1125 TF1 *
f1 = graph->GetFunction(
"pol1");
1126 f1->SetLineWidth(2);
1127 f1->SetLineColor(kBlue);
1130 auto fits = std::unique_ptr<TPaveText>(
new TPaveText(0.2,0.72,0.6,0.9,
"NDC"));
1132 sprintf(buffer,
"fit function: p_{0} + p_{1} * l_{strip}");
1133 fits->AddText(buffer);
1134 sprintf(buffer,
"p_{0} : %5.2f [ADC counts]",f1->GetParameter(0));
1135 fits->AddText(buffer);
1136 sprintf(buffer,
"p_{1} : %5.2f [ADC counts/cm]",f1->GetParameter(1));
1137 fits->AddText(buffer);
1138 sprintf(buffer,
"#chi^{2}/ndf = %5.2f / %i ",f1->GetChisquare(),f1->GetNDF());
1139 fits->AddText(buffer);
1140 fits->SetTextFont(42);
1141 fits->SetTextColor(kBlue);
1142 fits->SetFillColor(0);
1143 fits->SetTextSize(0.03);
1144 fits->SetBorderSize(1);
1145 fits->SetLineColor(kBlue);
1146 fits->SetMargin(0.05);
1147 fits->SetTextAlign(12);
1169 std::pair<double,double> getFromPayload(
SiStripNoises& payload )
override{
1171 std::vector<uint32_t> detid;
1175 float sum=0., sum2=0.;
1176 for (
const auto &
d : detid) {
1178 if(subid!=sub)
continue;
1180 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
1182 auto noise = payload.
getNoise(it,range);
1184 sum2+=(noise*noise);
1188 float mean = sum/nStrips;
1189 float rms = (sum2/nStrips-mean*
mean)>0. ?
sqrt(sum2/nStrips-mean*mean) : 0.;
1191 return std::make_pair(mean,rms);
1196 typedef NoiseHistory<StripSubdetector::TIB> TIBNoiseHistory;
1197 typedef NoiseHistory<StripSubdetector::TOB> TOBNoiseHistory;
1198 typedef NoiseHistory<StripSubdetector::TID> TIDNoiseHistory;
1199 typedef NoiseHistory<StripSubdetector::TEC> TECNoiseHistory;
1211 std::pair<double,double> getFromPayload(
SiStripNoises& payload )
override{
1213 std::vector<uint32_t> detid;
1217 float sum=0., sum2=0.;
1218 for (
const auto &
d : detid) {
1220 if(subid!=sub)
continue;
1222 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
1224 auto noise = payload.
getNoise(it,range);
1226 sum2+=(noise*noise);
1230 float mean = sum/nStrips;
1231 float rms = (sum2/nStrips-mean*
mean)>0. ?
sqrt(sum2/nStrips-mean*mean) : 0.;
1233 return std::make_pair(mean,rms);
1238 typedef NoiseRunHistory<StripSubdetector::TIB> TIBNoiseRunHistory;
1239 typedef NoiseRunHistory<StripSubdetector::TOB> TOBNoiseRunHistory;
1240 typedef NoiseRunHistory<StripSubdetector::TID> TIDNoiseRunHistory;
1241 typedef NoiseRunHistory<StripSubdetector::TEC> TECNoiseRunHistory;
1252 std::pair<double,double> getFromPayload(
SiStripNoises& payload )
override{
1254 std::vector<uint32_t> detid;
1258 float sum=0., sum2=0.;
1259 for (
const auto &
d : detid) {
1261 if(subid!=sub)
continue;
1263 for(
int it=0; it < (range.second-range.first)*8/9; ++it ){
1265 auto noise = payload.
getNoise(it,range);
1267 sum2+=(noise*noise);
1271 float mean = sum/nStrips;
1272 float rms = (sum2/nStrips-mean*
mean)>0. ?
sqrt(sum2/nStrips-mean*mean) : 0.;
1274 return std::make_pair(mean,rms);
1279 typedef NoiseTimeHistory<StripSubdetector::TIB> TIBNoiseTimeHistory;
1280 typedef NoiseTimeHistory<StripSubdetector::TOB> TOBNoiseTimeHistory;
1281 typedef NoiseTimeHistory<StripSubdetector::TID> TIDNoiseTimeHistory;
1282 typedef NoiseTimeHistory<StripSubdetector::TEC> TECNoiseTimeHistory;
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void fillNoiseDetSummary(SiStripDetSummary &summaryNoise, std::shared_ptr< SiStripNoises > payload, SiStripPI::estimator est)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
static float getNoise(uint16_t strip, const Range &range)
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Registry::const_iterator RegistryIterator
void makeNicePlotStyle(TH1 *hist)
std::string getStringFromSubdet(StripSubdetector::SubDetector sub)
void fillWithValue(float value, float weight=1)
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
std::string estimatorType(SiStripPI::estimator e)
std::pair< int, const char * > regionType(int index)
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void setSingleIov(bool flag)
const Range getRange(const uint32_t detID) const
bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
std::string fullPath() const
std::pair< ContainerIterator, ContainerIterator > Range