44 #include "TPaveStats.h" 55 SiStripPedestalsTest() :
cond::payloadInspector::Histogram1D<
SiStripPedestals>(
"SiStrip Pedestals test",
56 "SiStrip Pedestals test", 10,0.0,10.0),
62 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
63 for (
auto const & iov: iovs) {
70 ss <<
"Summary of strips pedestals:" << std::endl;
73 payload->printSummary(ss,&m_trackerTopo);
75 std::vector<uint32_t> detid;
76 payload->getDetIds(detid);
106 SiStripPedestalsValue() :
cond::payloadInspector::Histogram1D<
SiStripPedestals>(
"SiStrip Pedestals values",
107 "SiStrip Pedestals values", 300,0.0,300.0){
108 Base::setSingleIov(
true );
111 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
112 for (
auto const & iov: iovs) {
113 std::shared_ptr<SiStripPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
116 std::vector<uint32_t> detid;
117 payload->getDetIds(detid);
119 for (
const auto &
d : detid) {
121 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
122 auto ped = payload->getPed(it,range);
141 SiStripPedestalDistribution() :
cond::payloadInspector::PlotImage<
SiStripPedestals>(
"SiStrip Pedestal values"){
142 setSingleIov(
true );
145 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
146 auto iov = iovs.front();
148 TGaxis::SetMaxDigits(3);
149 gStyle->SetOptStat(
"emr");
151 std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
155 Form(
"#LT Pedestal #GT per %s for IOV [%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
156 opType(op_mode_).c_str(),std::to_string(std::get<0>(iov)).c_str(),opType(op_mode_).c_str(),opType(op_mode_).c_str())
159 unsigned int prev_det=0, prev_apv=0;
162 std::vector<uint32_t> detids;
163 payload->getDetIds(detids);
166 for (
const auto &
d : detids) {
169 unsigned int istrip=0;
171 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
172 auto pedestal = payload->getPed(it,range);
176 flush = (prev_det != 0 && prev_apv != istrip/128);
179 flush = (prev_det != 0 && prev_det !=
d);
182 flush = (istrip != 0);
187 mon1D->Fill(prev_apv,prev_det,epedestal.
mean());
192 prev_apv = istrip/128;
199 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
201 canvas.SetBottomMargin(0.11);
202 canvas.SetTopMargin(0.07);
203 canvas.SetLeftMargin(0.13);
204 canvas.SetRightMargin(0.05);
207 auto hist = mon1D->getHist();
209 hist.SetStats(kTRUE);
210 hist.SetFillColorAlpha(kRed,0.35);
215 TPaveStats *st = (TPaveStats*)
hist.GetListOfFunctions()->FindObject(
"stats");
216 st->SetLineColor(kRed);
217 st->SetTextColor(kRed);
218 st->SetX1NDC(.75); st->SetX2NDC(.95);
219 st->SetY1NDC(.83); st->SetY2NDC(.93);
221 TLegend
legend = TLegend(0.13,0.83,0.43,0.93);
222 legend.SetHeader(Form(
"SiStrip Pedestal values per %s",opType(op_mode_).c_str()),
"C");
223 legend.AddEntry(&
hist,(
"IOV: "+std::to_string(std::get<0>(iov))).c_str(),
"F");
224 legend.SetTextSize(0.025);
241 typedef SiStripPedestalDistribution<SiStripPI::STRIP_BASED> SiStripPedestalValuePerStrip;
242 typedef SiStripPedestalDistribution<SiStripPI::APV_BASED> SiStripPedestalValuePerAPV;
243 typedef SiStripPedestalDistribution<SiStripPI::MODULE_BASED> SiStripPedestalValuePerModule;
253 SiStripPedestalDistributionComparison() :
cond::payloadInspector::PlotImage<
SiStripPedestals>(
"SiStrip Pedestal values comparison"){
254 setSingleIov(
false );
257 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override{
259 std::vector<std::tuple<cond::Time_t,cond::Hash> > sorted_iovs = iovs;
262 std::sort(
begin(sorted_iovs),
end(sorted_iovs), [](
auto const &t1,
auto const &t2) {
263 return std::get<0>(t1) < std::get<0>(t2);
266 auto firstiov = sorted_iovs.front();
267 auto lastiov = sorted_iovs.back();
269 std::shared_ptr<SiStripPedestals> f_payload = fetchPayload( std::get<1>(firstiov) );
270 std::shared_ptr<SiStripPedestals> l_payload = fetchPayload( std::get<1>(lastiov) );
274 Form(
"#LT Strip Pedestal #GT per %s for IOV [%s,%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
275 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())
280 Form(
"#LT Strip Pedestal #GT per %s for IOV [%s,%s];#LTStrip Pedestal per %s#GT [ADC counts];n. %ss",
281 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())
284 unsigned int prev_det=0, prev_apv=0;
287 std::vector<uint32_t> f_detid;
288 f_payload->getDetIds(f_detid);
291 for (
const auto &
d : f_detid) {
294 unsigned int istrip=0;
295 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
296 float pedestal = f_payload->getPed(it,range);
302 flush = (prev_det != 0 && prev_apv != istrip/128);
305 flush = (prev_det != 0 && prev_det !=
d);
308 flush = (istrip != 0);
313 f_mon->Fill(prev_apv,prev_det,epedestal.
mean());
316 epedestal.
add(std::min<float>(pedestal, 300.));
317 prev_apv = istrip/128;
323 prev_det=0, prev_apv=0;
326 std::vector<uint32_t> l_detid;
327 l_payload->getDetIds(l_detid);
330 for (
const auto &
d : l_detid) {
333 unsigned int istrip=0;
334 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
335 float pedestal = l_payload->getPed(it,range);
340 flush = (prev_det != 0 && prev_apv != istrip/128);
343 flush = (prev_det != 0 && prev_det !=
d);
346 flush = (istrip != 0);
351 l_mon->Fill(prev_apv,prev_det,epedestal.
mean());
355 epedestal.
add(std::min<float>(pedestal, 300.));
356 prev_apv = istrip/128;
362 auto h_first = f_mon->getHist();
363 h_first.SetStats(kFALSE);
364 auto h_last = l_mon->getHist();
365 h_last.SetStats(kFALSE);
370 h_first.GetYaxis()->CenterTitle(
true);
371 h_last.GetYaxis()->CenterTitle(
true);
373 h_first.GetXaxis()->CenterTitle(
true);
374 h_last.GetXaxis()->CenterTitle(
true);
376 h_first.SetLineWidth(2);
377 h_last.SetLineWidth(2);
379 h_first.SetLineColor(kBlack);
380 h_last.SetLineColor(kBlue);
383 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
385 canvas.SetBottomMargin(0.11);
386 canvas.SetLeftMargin(0.13);
387 canvas.SetRightMargin(0.05);
390 float theMax = (h_first.GetMaximum() > h_last.GetMaximum()) ? h_first.GetMaximum() : h_last.GetMaximum();
392 h_first.SetMaximum(theMax*1.30);
393 h_last.SetMaximum(theMax*1.30);
398 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
399 legend.SetHeader(
"SiStrip Pedestal comparison",
"C");
400 legend.AddEntry(&h_first,(
"IOV: "+std::to_string(std::get<0>(firstiov))).c_str(),
"F");
401 legend.AddEntry(&h_last, (
"IOV: "+std::to_string(std::get<0>(lastiov))).c_str(),
"F");
402 legend.SetTextSize(0.025);
419 typedef SiStripPedestalDistributionComparison<SiStripPI::STRIP_BASED> SiStripPedestalValueComparisonPerStrip;
420 typedef SiStripPedestalDistributionComparison<SiStripPI::APV_BASED> SiStripPedestalValueComparisonPerAPV;
421 typedef SiStripPedestalDistributionComparison<SiStripPI::MODULE_BASED> SiStripPedestalValueComparisonPerModule;
432 SiStripZeroPedestalsFraction_TrackerMap() :
cond::payloadInspector::PlotImage<
SiStripPedestals> (
"Tracker Map of Zero SiStripPedestals fraction per module" )
434 setSingleIov(
true );
437 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override {
438 auto iov = iovs.front();
439 std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
444 std::string titleMap =
"Tracker Map of Zero SiStrip Pedestals fraction per module (payload : "+std::get<1>(iov)+
")";
446 std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(
new TrackerMap(
"SiStripPedestals"));
447 tmap->setTitle(titleMap);
450 std::vector<uint32_t> detid;
451 payload->getDetIds(detid);
453 std::map<uint32_t,int> zeropeds_per_detid;
455 for (
const auto &
d : detid) {
458 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
460 auto ped = payload->getPed(it,range);
462 zeropeds_per_detid[
d]+=1;
467 tmap->fill(
d,fraction);
468 std::cout<<
"detid: "<<
d <<
" (n. APVs="<< reader->
getNumberOfApvsAndStripLength(
d).first <<
") has " << std::setw(4) << zeropeds_per_detid[
d] <<
" zero-pedestals strips (i.e. a fraction:"<< std::setprecision(5) << fraction <<
")" << std::endl;
488 setSingleIov(
true );
491 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override {
492 auto iov = iovs.front();
493 std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
495 std::string titleMap =
"Tracker Map of SiStrip Pedestals "+
estimatorType(est)+
" per module (payload : "+std::get<1>(iov)+
")";
497 std::unique_ptr<TrackerMap> tmap = std::unique_ptr<TrackerMap>(
new TrackerMap(
"SiStripPedestals"));
498 tmap->setTitle(titleMap);
501 std::vector<uint32_t> detid;
502 payload->getDetIds(detid);
504 std::map<unsigned int,float> info_per_detid;
506 for (
const auto &
d : detid) {
510 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
512 auto ped = payload->getPed(it,range);
528 info_per_detid[
d]=
min;
531 info_per_detid[
d]=
max;
534 info_per_detid[
d]=
mean;
537 info_per_detid[
d]=
rms;
545 for(
const auto &
d : detid){
546 tmap->fill(
d,info_per_detid[
d]);
556 typedef SiStripPedestalsTrackerMap<SiStripPI::min> SiStripPedestalsMin_TrackerMap;
557 typedef SiStripPedestalsTrackerMap<SiStripPI::max> SiStripPedestalsMax_TrackerMap;
558 typedef SiStripPedestalsTrackerMap<SiStripPI::mean> SiStripPedestalsMean_TrackerMap;
559 typedef SiStripPedestalsTrackerMap<SiStripPI::rms> SiStripPedestalsRMS_TrackerMap;
570 setSingleIov(
true );
573 bool fill(
const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs )
override {
574 auto iov = iovs.front();
575 std::shared_ptr<SiStripPedestals> payload = fetchPayload( std::get<1>(iov) );
578 std::vector<uint32_t> detid;
579 payload->getDetIds(detid);
581 for (
const auto &
d : detid) {
585 for(
int it=0; it < (range.second-range.first)*8/10; ++it ){
587 auto ped = payload->getPed(it,range);
595 if((
rms/nstrips-mean*mean)>0.){
603 summaryPedestals.add(
d,
min);
606 summaryPedestals.add(
d,
max);
609 summaryPedestals.add(
d,mean);
612 summaryPedestals.add(
d,
rms);
620 std::map<unsigned int, SiStripDetSummary::Values>
map = summaryPedestals.getCounts();
623 TCanvas
canvas(
"Partion summary",
"partition summary",1200,1000);
625 auto h1 = std::unique_ptr<TH1F>(
new TH1F(
"byRegion",Form(
"Average by partition of %s SiStrip Pedestals per module;;average SiStrip Pedestals %s [ADC counts]",
estimatorType(est).c_str(),
estimatorType(est).c_str()),map.size(),0.,map.size()));
627 canvas.SetBottomMargin(0.18);
628 canvas.SetLeftMargin(0.17);
629 canvas.SetRightMargin(0.05);
632 std::vector<int> boundaries;
638 for (
const auto &element : map){
640 int count = element.second.count;
641 double mean = (element.second.mean)/count;
642 double rms = (element.second.rms)/count - mean*mean;
649 if(currentDetector.empty()) currentDetector=
"TIB";
651 switch ((element.first)/1000)
667 h1->SetBinContent(iBin,mean);
669 h1->GetXaxis()->LabelsOption(
"v");
671 if(detector!=currentDetector) {
672 boundaries.push_back(iBin);
677 h1->SetMarkerStyle(20);
678 h1->SetMarkerSize(1);
679 h1->SetMaximum(h1->GetMaximum()*1.1);
685 TLine
l[boundaries.size()];
687 for (
const auto &
line : boundaries){
689 l[
i].SetLineWidth(1);
690 l[
i].SetLineStyle(9);
691 l[
i].SetLineColor(2);
696 TLegend legend = TLegend(0.52,0.82,0.95,0.9);
697 legend.SetHeader((std::get<1>(iov)).c_str(),
"C");
698 legend.AddEntry(h1.get(),(
"IOV: "+std::to_string(std::get<0>(iov))).c_str(),
"PL");
699 legend.SetTextSize(0.025);
712 typedef SiStripPedestalsByRegion<SiStripPI::mean> SiStripPedestalsMeanByRegion;
713 typedef SiStripPedestalsByRegion<SiStripPI::min> SiStripPedestalsMinByRegion;
714 typedef SiStripPedestalsByRegion<SiStripPI::max> SiStripPedestalsMaxByRegion;
715 typedef SiStripPedestalsByRegion<SiStripPI::rms> SiStripPedestalsRMSByRegion;
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
std::pair< ContainerIterator, ContainerIterator > Range
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
void makeNicePlotStyle(TH1 *hist)
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)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
void setSingleIov(bool flag)
bool fill(const std::vector< std::tuple< cond::Time_t, cond::Hash > > &iovs) override
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
std::string fullPath() const