12 #include "TPaveText.h" 50 else {
std::cout <<
"Too few arguments: " <<
argc << std::endl;
return -1; }
66 std::ostringstream oss;
70 std::vector< std::string > subDetName;
71 subDetName.push_back(
"TIB"); subDetName.push_back(
"TID+"); subDetName.push_back(
"TID-"); subDetName.push_back(
"TOB"); subDetName.push_back(
"TEC+"); subDetName.push_back(
"TEC-");
74 const bool stackHistograms =
true;
78 plotStackOptions =
"";
80 plotStackOptions =
"nostack p";
120 std::vector<TH1F*> hLayers;
123 for(std::vector< std::string >::iterator itPlot=
plotType.begin(); itPlot!=
plotType.end(); itPlot++)
130 hTracker->Scale(1/
findNormFactor(*itPlot,
"Tracker",stackHistograms));
164 c1 =
new TCanvas((
"c"+*itPlot+
"Tracker").c_str(),
"", 1200, 600);
171 histoStack->Add(hTIB);
176 histoStack->Add(hTID);
181 histoStack->Add(hTOB);
186 histoStack->Add(hTEC);
193 double histoStackMaximum = histoStack->GetMaximum();
194 if(histoStackMaximum==0)
198 histoStack->Draw(plotStackOptions.c_str());
199 if(histoStack->GetYaxis()->GetXmax() > 0.9)
200 histoStack->GetYaxis()->SetRangeUser(0.,0.1);
201 legend =
new TLegend(0.4,0.9,0.9,1);
202 legend->AddEntry(hTIB,
"TIB");
203 legend->AddEntry(hTID,
"TID");
204 legend->AddEntry(hTOB,
"TOB");
205 legend->AddEntry(hTEC,
"TEC");
208 textX =
new TPaveText();
209 textY =
new TPaveText();
214 gSystem->ProcessEvents();
218 c1->SaveAs((*itPlot+
"Tracker.png").c_str());
229 for(std::vector< std::string >::iterator itSub=subDetName.begin(); itSub!=subDetName.end(); itSub++)
238 legend =
new TLegend(0.4,0.9,0.9,1);
241 else if((*itSub)==
"TID+" || (*itSub)==
"TID-")
245 legend =
new TLegend(0.35,0.9,0.9,1);
248 else if((*itSub)==
"TOB")
252 legend =
new TLegend(0.35,0.9,0.9,1);
255 else if((*itSub)==
"TEC+" || (*itSub)==
"TEC-")
259 legend =
new TLegend(0.35,0.9,1,1);
263 c1 =
new TCanvas((
"c" + *itPlot + *itSub).c_str(),
"", 1200, 600);
278 for(
unsigned int iLayer = 1; iLayer<=
nLayers; iLayer++)
347 histoName =
"h" + *itPlot + *itSub + layerName + oss.str();
351 histo2 =
new TH1F(*
histo);
352 histo->Scale(1/
findNormFactor(*itPlot, *itSub +
" " + layerName +
" " + oss.str(),
false));
353 histo2->Scale(1/
findNormFactor(*itPlot, *itSub +
" " + layerName +
" " + oss.str(), stackHistograms));
356 c2 =
new TCanvas((
"c" + *itPlot + *itSub + layerName + oss.str()).c_str(),
"", 1200, 600);
358 histo->Draw(plotHistoOptions.c_str());
359 double histoMaximum =
histo->GetMaximum();
365 legend2 =
new TLegend(0.6,0.92,0.9,0.97);
366 legend2->AddEntry(
histo,(*itSub + layerName + oss.str()).c_str());
369 textX =
new TPaveText();
370 textY =
new TPaveText();
375 gSystem->ProcessEvents();
379 c2->SaveAs((*itPlot + *itSub + layerName + oss.str() +
".png").c_str());
387 hLayers.push_back(histo2);
389 histoStack->Add(hLayers.back());
390 entryLabel = *itSub +
" " + layerName +
" " + oss.str();
391 legend->AddEntry(hLayers.back(), entryLabel.c_str());
398 histoStack->Draw(plotStackOptions.c_str());
405 double histoStackMaximum = histoStack->GetMaximum();
406 if(histoStackMaximum==0)
410 if(histoStackMaximum > 0.01)
411 histoStack->SetMaximum(0.01);
412 textX =
new TPaveText();
413 textY =
new TPaveText();
419 gSystem->ProcessEvents();
423 c1->SaveAs((*itPlot + *itSub +
".png").c_str());
442 c->SetFrameBorderMode(0);
447 c->SetCanvasSize(1200,600);
448 c->SetWindowSize(1200,600);
456 h->SetMarkerStyle(3);
458 h->SetMarkerColor(1);
464 if(
h->GetNbinsX() > 25)
465 for(
int i = 1;
i <
h->GetNbinsX()-1;
i++)
466 if((
i%(
h->GetNbinsX()/25+1)))
467 h->GetXaxis()->SetBinLabel(
i+1,
"");
484 h->GetYaxis()->SetTitle(
"Fraction of total");
488 if(
h->GetNbinsX() > 25)
489 for(
int i = 1;
i <
h->GetNbinsX()-1;
i++)
490 if(
i%(
h->GetNbinsX()/25+1))
491 h->GetXaxis()->SetBinLabel(
i+1,
"");
498 l->SetNColumns(nColumns);
524 TText*
t1 =
t->AddText(
"Fraction of total");
525 t1->SetTextAngle(90.);
534 std::vector< std::string > tkParts;
535 tkParts.push_back(
"Tracker");
536 tkParts.push_back(
"TIB");
537 tkParts.push_back(
"TID");
538 tkParts.push_back(
"TOB");
539 tkParts.push_back(
"TEC");
540 tkParts.push_back(
"TIB Layer 1");
541 tkParts.push_back(
"TIB Layer 2");
542 tkParts.push_back(
"TIB Layer 3");
543 tkParts.push_back(
"TIB Layer 4");
544 tkParts.push_back(
"TID+ Disk 1");
545 tkParts.push_back(
"TID+ Disk 2");
546 tkParts.push_back(
"TID+ Disk 3");
547 tkParts.push_back(
"TID- Disk 1");
548 tkParts.push_back(
"TID- Disk 2");
549 tkParts.push_back(
"TID- Disk 3");
550 tkParts.push_back(
"TOB Layer 1");
551 tkParts.push_back(
"TOB Layer 2");
552 tkParts.push_back(
"TOB Layer 3");
553 tkParts.push_back(
"TOB Layer 4");
554 tkParts.push_back(
"TOB Layer 5");
555 tkParts.push_back(
"TOB Layer 6");
556 tkParts.push_back(
"TEC+ Disk 1");
557 tkParts.push_back(
"TEC+ Disk 2");
558 tkParts.push_back(
"TEC+ Disk 3");
559 tkParts.push_back(
"TEC+ Disk 4");
560 tkParts.push_back(
"TEC+ Disk 5");
561 tkParts.push_back(
"TEC+ Disk 6");
562 tkParts.push_back(
"TEC+ Disk 7");
563 tkParts.push_back(
"TEC+ Disk 8");
564 tkParts.push_back(
"TEC+ Disk 9");
565 tkParts.push_back(
"TEC- Disk 1");
566 tkParts.push_back(
"TEC- Disk 2");
567 tkParts.push_back(
"TEC- Disk 3");
568 tkParts.push_back(
"TEC- Disk 4");
569 tkParts.push_back(
"TEC- Disk 5");
570 tkParts.push_back(
"TEC- Disk 6");
571 tkParts.push_back(
"TEC- Disk 7");
572 tkParts.push_back(
"TEC- Disk 8");
573 tkParts.push_back(
"TEC- Disk 9");
575 std::vector<unsigned int> nModulesStack;
576 nModulesStack.push_back(15148);
577 nModulesStack.push_back(15148);
578 nModulesStack.push_back(15148);
579 nModulesStack.push_back(15148);
580 nModulesStack.push_back(15148);
581 nModulesStack.push_back(2724);
582 nModulesStack.push_back(2724);
583 nModulesStack.push_back(2724);
584 nModulesStack.push_back(2724);
585 nModulesStack.push_back(408);
586 nModulesStack.push_back(408);
587 nModulesStack.push_back(408);
588 nModulesStack.push_back(408);
589 nModulesStack.push_back(408);
590 nModulesStack.push_back(408);
591 nModulesStack.push_back(5208);
592 nModulesStack.push_back(5208);
593 nModulesStack.push_back(5208);
594 nModulesStack.push_back(5208);
595 nModulesStack.push_back(5208);
596 nModulesStack.push_back(5208);
597 nModulesStack.push_back(3200);
598 nModulesStack.push_back(3200);
599 nModulesStack.push_back(3200);
600 nModulesStack.push_back(3200);
601 nModulesStack.push_back(3200);
602 nModulesStack.push_back(3200);
603 nModulesStack.push_back(3200);
604 nModulesStack.push_back(3200);
605 nModulesStack.push_back(3200);
606 nModulesStack.push_back(3200);
607 nModulesStack.push_back(3200);
608 nModulesStack.push_back(3200);
609 nModulesStack.push_back(3200);
610 nModulesStack.push_back(3200);
611 nModulesStack.push_back(3200);
612 nModulesStack.push_back(3200);
613 nModulesStack.push_back(3200);
614 nModulesStack.push_back(3200);
616 std::vector<unsigned int> nModulesNoStack;
617 nModulesNoStack.push_back(15148);
618 nModulesNoStack.push_back(2724);
619 nModulesNoStack.push_back(816);
620 nModulesNoStack.push_back(5208);
621 nModulesNoStack.push_back(6400);
622 nModulesNoStack.push_back(672);
623 nModulesNoStack.push_back(864);
624 nModulesNoStack.push_back(540);
625 nModulesNoStack.push_back(648);
626 nModulesNoStack.push_back(136);
627 nModulesNoStack.push_back(136);
628 nModulesNoStack.push_back(136);
629 nModulesNoStack.push_back(136);
630 nModulesNoStack.push_back(136);
631 nModulesNoStack.push_back(136);
632 nModulesNoStack.push_back(1008);
633 nModulesNoStack.push_back(1152);
634 nModulesNoStack.push_back(648);
635 nModulesNoStack.push_back(720);
636 nModulesNoStack.push_back(792);
637 nModulesNoStack.push_back(888);
638 nModulesNoStack.push_back(408);
639 nModulesNoStack.push_back(408);
640 nModulesNoStack.push_back(408);
641 nModulesNoStack.push_back(360);
642 nModulesNoStack.push_back(360);
643 nModulesNoStack.push_back(360);
644 nModulesNoStack.push_back(312);
645 nModulesNoStack.push_back(312);
646 nModulesNoStack.push_back(272);
647 nModulesNoStack.push_back(408);
648 nModulesNoStack.push_back(408);
649 nModulesNoStack.push_back(408);
650 nModulesNoStack.push_back(360);
651 nModulesNoStack.push_back(360);
652 nModulesNoStack.push_back(360);
653 nModulesNoStack.push_back(312);
654 nModulesNoStack.push_back(312);
655 nModulesNoStack.push_back(272);
658 std::vector<unsigned int> nFibersStack;
659 nFibersStack.push_back(36392);
660 nFibersStack.push_back(36392);
661 nFibersStack.push_back(36392);
662 nFibersStack.push_back(36392);
663 nFibersStack.push_back(36392);
664 nFibersStack.push_back(6984);
665 nFibersStack.push_back(6984);
666 nFibersStack.push_back(6984);
667 nFibersStack.push_back(6984);
668 nFibersStack.push_back(1104);
669 nFibersStack.push_back(1104);
670 nFibersStack.push_back(1104);
671 nFibersStack.push_back(1104);
672 nFibersStack.push_back(1104);
673 nFibersStack.push_back(1104);
674 nFibersStack.push_back(12096);
675 nFibersStack.push_back(12096);
676 nFibersStack.push_back(12096);
677 nFibersStack.push_back(12096);
678 nFibersStack.push_back(12096);
679 nFibersStack.push_back(12096);
680 nFibersStack.push_back(7552);
681 nFibersStack.push_back(7552);
682 nFibersStack.push_back(7552);
683 nFibersStack.push_back(7552);
684 nFibersStack.push_back(7552);
685 nFibersStack.push_back(7552);
686 nFibersStack.push_back(7552);
687 nFibersStack.push_back(7552);
688 nFibersStack.push_back(7552);
689 nFibersStack.push_back(7552);
690 nFibersStack.push_back(7552);
691 nFibersStack.push_back(7552);
692 nFibersStack.push_back(7552);
693 nFibersStack.push_back(7552);
694 nFibersStack.push_back(7552);
695 nFibersStack.push_back(7552);
696 nFibersStack.push_back(7552);
697 nFibersStack.push_back(7552);
699 std::vector<unsigned int> nFibersNoStack;
700 nFibersNoStack.push_back(36392);
701 nFibersNoStack.push_back(6984);
702 nFibersNoStack.push_back(2208);
703 nFibersNoStack.push_back(12096);
704 nFibersNoStack.push_back(15104);
705 nFibersNoStack.push_back(2016);
706 nFibersNoStack.push_back(2592);
707 nFibersNoStack.push_back(1080);
708 nFibersNoStack.push_back(1296);
709 nFibersNoStack.push_back(368);
710 nFibersNoStack.push_back(368);
711 nFibersNoStack.push_back(368);
712 nFibersNoStack.push_back(368);
713 nFibersNoStack.push_back(368);
714 nFibersNoStack.push_back(368);
715 nFibersNoStack.push_back(2016);
716 nFibersNoStack.push_back(2304);
717 nFibersNoStack.push_back(1296);
718 nFibersNoStack.push_back(1440);
719 nFibersNoStack.push_back(2376);
720 nFibersNoStack.push_back(2664);
721 nFibersNoStack.push_back(992);
722 nFibersNoStack.push_back(992);
723 nFibersNoStack.push_back(992);
724 nFibersNoStack.push_back(848);
725 nFibersNoStack.push_back(848);
726 nFibersNoStack.push_back(848);
727 nFibersNoStack.push_back(704);
728 nFibersNoStack.push_back(704);
729 nFibersNoStack.push_back(624);
730 nFibersNoStack.push_back(992);
731 nFibersNoStack.push_back(992);
732 nFibersNoStack.push_back(992);
733 nFibersNoStack.push_back(848);
734 nFibersNoStack.push_back(848);
735 nFibersNoStack.push_back(848);
736 nFibersNoStack.push_back(704);
737 nFibersNoStack.push_back(704);
738 nFibersNoStack.push_back(624);
741 std::vector<unsigned int> nAPVsStack;
742 nAPVsStack.push_back(72784);
743 nAPVsStack.push_back(72784);
744 nAPVsStack.push_back(72784);
745 nAPVsStack.push_back(72784);
746 nAPVsStack.push_back(72784);
747 nAPVsStack.push_back(13968);
748 nAPVsStack.push_back(13968);
749 nAPVsStack.push_back(13968);
750 nAPVsStack.push_back(13968);
751 nAPVsStack.push_back(2208);
752 nAPVsStack.push_back(2208);
753 nAPVsStack.push_back(2208);
754 nAPVsStack.push_back(2208);
755 nAPVsStack.push_back(2208);
756 nAPVsStack.push_back(2208);
757 nAPVsStack.push_back(24192);
758 nAPVsStack.push_back(24192);
759 nAPVsStack.push_back(24192);
760 nAPVsStack.push_back(24192);
761 nAPVsStack.push_back(24192);
762 nAPVsStack.push_back(24192);
763 nAPVsStack.push_back(15104);
764 nAPVsStack.push_back(15104);
765 nAPVsStack.push_back(15104);
766 nAPVsStack.push_back(15104);
767 nAPVsStack.push_back(15104);
768 nAPVsStack.push_back(15104);
769 nAPVsStack.push_back(15104);
770 nAPVsStack.push_back(15104);
771 nAPVsStack.push_back(15104);
772 nAPVsStack.push_back(15104);
773 nAPVsStack.push_back(15104);
774 nAPVsStack.push_back(15104);
775 nAPVsStack.push_back(15104);
776 nAPVsStack.push_back(15104);
777 nAPVsStack.push_back(15104);
778 nAPVsStack.push_back(15104);
779 nAPVsStack.push_back(15104);
780 nAPVsStack.push_back(15104);
782 std::vector<unsigned int> nAPVsNoStack;
783 nAPVsNoStack.push_back(72784);
784 nAPVsNoStack.push_back(13968);
785 nAPVsNoStack.push_back(4416);
786 nAPVsNoStack.push_back(24192);
787 nAPVsNoStack.push_back(30208);
788 nAPVsNoStack.push_back(4032);
789 nAPVsNoStack.push_back(5184);
790 nAPVsNoStack.push_back(2160);
791 nAPVsNoStack.push_back(2592);
792 nAPVsNoStack.push_back(736);
793 nAPVsNoStack.push_back(736);
794 nAPVsNoStack.push_back(736);
795 nAPVsNoStack.push_back(736);
796 nAPVsNoStack.push_back(736);
797 nAPVsNoStack.push_back(736);
798 nAPVsNoStack.push_back(4032);
799 nAPVsNoStack.push_back(4608);
800 nAPVsNoStack.push_back(2592);
801 nAPVsNoStack.push_back(2880);
802 nAPVsNoStack.push_back(4752);
803 nAPVsNoStack.push_back(5328);
804 nAPVsNoStack.push_back(1984);
805 nAPVsNoStack.push_back(1984);
806 nAPVsNoStack.push_back(1984);
807 nAPVsNoStack.push_back(1696);
808 nAPVsNoStack.push_back(1696);
809 nAPVsNoStack.push_back(1696);
810 nAPVsNoStack.push_back(1408);
811 nAPVsNoStack.push_back(1408);
812 nAPVsNoStack.push_back(1248);
813 nAPVsNoStack.push_back(1984);
814 nAPVsNoStack.push_back(1984);
815 nAPVsNoStack.push_back(1984);
816 nAPVsNoStack.push_back(1696);
817 nAPVsNoStack.push_back(1696);
818 nAPVsNoStack.push_back(1696);
819 nAPVsNoStack.push_back(1408);
820 nAPVsNoStack.push_back(1408);
821 nAPVsNoStack.push_back(1248);
824 std::vector<unsigned int> nStripsStack;
825 nStripsStack.push_back(9316352);
826 nStripsStack.push_back(9316352);
827 nStripsStack.push_back(9316352);
828 nStripsStack.push_back(9316352);
829 nStripsStack.push_back(9316352);
830 nStripsStack.push_back(1787904);
831 nStripsStack.push_back(1787904);
832 nStripsStack.push_back(1787904);
833 nStripsStack.push_back(1787904);
834 nStripsStack.push_back(282624);
835 nStripsStack.push_back(282624);
836 nStripsStack.push_back(282624);
837 nStripsStack.push_back(282624);
838 nStripsStack.push_back(282624);
839 nStripsStack.push_back(282624);
840 nStripsStack.push_back(3096576);
841 nStripsStack.push_back(3096576);
842 nStripsStack.push_back(3096576);
843 nStripsStack.push_back(3096576);
844 nStripsStack.push_back(3096576);
845 nStripsStack.push_back(3096576);
846 nStripsStack.push_back(1933312);
847 nStripsStack.push_back(1933312);
848 nStripsStack.push_back(1933312);
849 nStripsStack.push_back(1933312);
850 nStripsStack.push_back(1933312);
851 nStripsStack.push_back(1933312);
852 nStripsStack.push_back(1933312);
853 nStripsStack.push_back(1933312);
854 nStripsStack.push_back(1933312);
855 nStripsStack.push_back(1933312);
856 nStripsStack.push_back(1933312);
857 nStripsStack.push_back(1933312);
858 nStripsStack.push_back(1933312);
859 nStripsStack.push_back(1933312);
860 nStripsStack.push_back(1933312);
861 nStripsStack.push_back(1933312);
862 nStripsStack.push_back(1933312);
863 nStripsStack.push_back(1933312);
865 std::vector<unsigned int> nStripsNoStack;
866 nStripsNoStack.push_back(9316352);
867 nStripsNoStack.push_back(1787904);
868 nStripsNoStack.push_back(565248);
869 nStripsNoStack.push_back(3096576);
870 nStripsNoStack.push_back(3866624);
871 nStripsNoStack.push_back(516096);
872 nStripsNoStack.push_back(663552);
873 nStripsNoStack.push_back(276480);
874 nStripsNoStack.push_back(331776);
875 nStripsNoStack.push_back(94208);
876 nStripsNoStack.push_back(94208);
877 nStripsNoStack.push_back(94208);
878 nStripsNoStack.push_back(94208);
879 nStripsNoStack.push_back(94208);
880 nStripsNoStack.push_back(94208);
881 nStripsNoStack.push_back(516096);
882 nStripsNoStack.push_back(589824);
883 nStripsNoStack.push_back(331776);
884 nStripsNoStack.push_back(368640);
885 nStripsNoStack.push_back(608256);
886 nStripsNoStack.push_back(681984);
887 nStripsNoStack.push_back(253952);
888 nStripsNoStack.push_back(253952);
889 nStripsNoStack.push_back(253952);
890 nStripsNoStack.push_back(217088);
891 nStripsNoStack.push_back(217088);
892 nStripsNoStack.push_back(217088);
893 nStripsNoStack.push_back(180224);
894 nStripsNoStack.push_back(180224);
895 nStripsNoStack.push_back(159744);
896 nStripsNoStack.push_back(253952);
897 nStripsNoStack.push_back(253952);
898 nStripsNoStack.push_back(253952);
899 nStripsNoStack.push_back(217088);
900 nStripsNoStack.push_back(217088);
901 nStripsNoStack.push_back(217088);
902 nStripsNoStack.push_back(180224);
903 nStripsNoStack.push_back(180224);
904 nStripsNoStack.push_back(159744);
906 for(
unsigned int i = 0;
i < tkParts.size();
i++)
936 if(currentPlotType ==
"BadModules")
940 else if(currentPlotType ==
"BadFibers")
944 else if(currentPlotType ==
"BadAPVs")
948 else if(currentPlotType ==
"AllBadStrips" ||
949 currentPlotType ==
"BadStripsFromAPVs" ||
950 currentPlotType ==
"BadStrips")
956 std::cout <<
"findNormFactor(): ERROR! Requested a non supported plot type: " << currentPlotType.c_str() << std::endl;
957 std::cout <<
" Add this to the function body or correct the error\n";
963 if(currentPlotType ==
"BadModules")
967 else if(currentPlotType ==
"BadFibers")
971 else if(currentPlotType ==
"BadAPVs")
975 else if(currentPlotType ==
"BadStrips" ||
976 currentPlotType ==
"BadStripsFromAPVs" ||
977 currentPlotType ==
"AllBadStrips")
983 std::cout <<
"findNormFactor(): ERROR! Requested a non supported plot type: \"" << currentPlotType.c_str() <<
"\"\n";
984 std::cout <<
" Add this to the function body or correct the error otherwise.\n";
static std::map< std::string, unsigned int > modulesStackNormFactors
int main(int argc, char *argv[])
double findNormFactor(const std::string currentPlotType, const std::string currentPart, const bool stackOption)
static std::map< std::string, unsigned int > APVsNoStackNormFactors
void fillNormFactorMaps()
static std::map< std::string, unsigned int > stripsNoStackNormFactors
void setCanvasStyle(TCanvas *c, const bool logScale)
static std::map< std::string, unsigned int > stripsStackNormFactors
void setLegendStyle(TLegend *l, const unsigned int nColumns)
static std::map< std::string, unsigned int > fibersStackNormFactors
void setPaveTextStyle(TPaveText *t, const bool isHorizontal=true)
static std::map< std::string, unsigned int > modulesNoStackNormFactors
void makePlots(std::string inputFileName, std::string outputFileName)
void setHistoStyle(TH1 *h)
static std::map< std::string, unsigned int > fibersNoStackNormFactors
void setHistoStackStyle(TH1 *h, const unsigned int lineColor)
static std::map< std::string, unsigned int > APVsStackNormFactors
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.