ATLAS Offline Software
Classes | Functions | Variables
PlotCalibrationGains Namespace Reference

Classes

class  EmPartitionPlots
 
class  GainReader
 
class  HadPartitionPlots
 
class  L1CaloGeometryConvertor
 
class  L1CaloMap
 

Functions

def PlotCalibrationGains (input_file_name="", reference_file_name="", isInputXml=False, isInputSqlite=False, isRefXml=False, isRefSqlite=False, isRefOracle=False)
 

Variables

 parser
 
 action
 
 type
 
 dest
 
 help
 
 options
 
 args
 

Function Documentation

◆ PlotCalibrationGains()

def PlotCalibrationGains.PlotCalibrationGains (   input_file_name = "",
  reference_file_name = "",
  isInputXml = False,
  isInputSqlite = False,
  isRefXml = False,
  isRefSqlite = False,
  isRefOracle = False 
)

Definition at line 610 of file PlotCalibrationGains.py.

610 def PlotCalibrationGains(input_file_name="",reference_file_name="",isInputXml=False,isInputSqlite=False,isRefXml=False,isRefSqlite=False,isRefOracle=False):
611 
612  ROOT.gStyle.SetPalette(1)
613  ROOT.gStyle.SetOptStat(111111)
614  ROOT.gStyle.SetCanvasColor(10)
615 
616  c1 = ROOT.TCanvas('c1','Example',200,10,700,500)
617  c2 = ROOT.TCanvas('c2','Example Partitions',200,10,700,500)
618  c2.Divide(3,2)
619 
620  h_gains_em = L1CaloMap("Eta-phi map of EM gains","#eta bin","#phi bin")
621  h_gains_had = L1CaloMap("Eta-phi map of HAD gains","#eta bin","#phi bin")
622 
623  h_gains_em_fselect = L1CaloMap("Eta-phi map of EM gains that failed selection","#eta bin","#phi bin")
624  h_gains_had_fselect = L1CaloMap("Eta-phi map of HAD gains that failed selection","#eta bin","#phi bin")
625 
626  h_chi2_em = L1CaloMap("Eta-phi map of EM Chi2","#eta bin","#phi bin")
627  h_chi2_had = L1CaloMap("Eta-phi map of HAD Chi2","#eta bin","#phi bin")
628 
629  h_offset_em = L1CaloMap("Eta-phi map of EM offsets","#eta bin","#phi bin")
630  h_offset_had = L1CaloMap("Eta-phi map of HAD offsets","#eta bin","#phi bin")
631 
632 
633  h_unfitted_em = L1CaloMap("Eta-phi map of EM failed fits","#eta bin","#phi bin")
634  h_unfitted_had = L1CaloMap("Eta-phi map of HAD failed fits","#eta bin","#phi bin")
635 
636  h_drifted_em = L1CaloMap("EM TTs that drifted more then 10 %","#eta bin","#phi bin")
637  h_drifted_had = L1CaloMap("HAD TTs that drifted more then 10 %","#eta bin","#phi bin")
638 
639 
640  h_gains_em_reference = L1CaloMap("Eta-phi map of EM gains (gain-reference)","#eta bin","#phi bin")
641  h_gains_had_reference = L1CaloMap("Eta-phi map of HAD gains (gain-reference)","#eta bin","#phi bin")
642 
643  h_gains_em_reference_rel = L1CaloMap("Eta-phi map of EM gains: (gain-reference)/reference","#eta bin","#phi bin")
644  h_gains_had_reference_rel = L1CaloMap("Eta-phi map of HAD gains: (gain-reference)/reference","#eta bin","#phi bin")
645 
646 
647  em_partition_gains = EmPartitionPlots(" EM gains",40,0.6,1.4,"gain","N")
648  had_partition_gains = HadPartitionPlots(" HAD gains",40,0.5,2.5,"gain","N")
649 
650  em_partition_gains_ref = EmPartitionPlots(" EM gains - reference",40,-0.2,0.2,"gain-reference","N")
651  had_partition_gains_ref = HadPartitionPlots(" HAD gains - reference",40,-1.,1.,"gain-reference","N")
652 
653  em_partition_gains_ref_rel = EmPartitionPlots(" EM gains-reference / reference",40,-0.2,0.2,"(gain-reference)/reference","N")
654  had_partition_gains_ref_rel = HadPartitionPlots(" HAD gains-reference / reference",40,-1.,1.,"(gain-reference)/reference","N")
655 
656  threshold_change = 0.1
657 
658  geometry_convertor = L1CaloGeometryConvertor()
659  receiver_gains = GainReader()
660 
661  bad_gain_file = open('bad_gains.txt','w')
662  drifted_towers_file = open('drifted_towers.txt','w')
663 
664  if isInputXml is True:
665  print ("Taking input from xml file: ", input_file_name)
666  receiver_gains.LoadGainsXml(input_file_name)
667  elif isInputSqlite is True:
668  print ("Taking input from Sqlite file: ", input_file_name)
669  receiver_gains.LoadGainsSqlite(input_file_name)
670  else:
671  print ("No option for input file selected, assuming sqlite file energyscanresults.sqlite")
672  receiver_gains.LoadGainsSqlite("energyscanresults.sqlite")
673 
674 
675  if isRefXml is True:
676  print ("Taking reference from Xml file: ",reference_file_name)
677  receiver_gains.LoadReferenceXml(reference_file_name)
678  elif isRefSqlite is True:
679  print ("Taking reference from Sqlite file: ",reference_file_name)
680  receiver_gains.LoadReferenceSqlite(reference_file_name)
681  elif isRefOracle is True:
682  print ("Taking reference from Oracle")
683  geometry_convertor.LoadReceiverPPMMap()
684  receiver_gains.LoadReferenceOracle(geometry_convertor)
685  else:
686  print (" No option for reference file, assuming Oracle")
687  geometry_convertor.LoadReceiverPPMMap()
688  receiver_gains.LoadReferenceOracle(geometry_convertor)
689 
690 
691  for i_eta in range(-49,45):
692  for i_phi in range(0,64):
693 
694  coolEm = geometry_convertor.getCoolEm(i_eta,i_phi)
695  coolHad = geometry_convertor.getCoolHad(i_eta,i_phi)
696 
697  if not coolEm == '': # there is a channel for this eta-phi
698 
699  gain = receiver_gains.getGain(coolEm)
700  chi2 = receiver_gains.getChi2(coolEm)
701  offset = receiver_gains.getOffset(coolEm)
702  reference_gain = receiver_gains.getReferenceGain(coolEm)
703  passes_selection = receiver_gains.passesSelection(coolEm)
704 
705  if (not gain == '') and (not reference_gain == ''): # both gains should be available
706 
707  if gain == -1. :
708  h_unfitted_em.Fill(i_eta,i_phi)
709  bad_gain_file.write('%i %i %s EM gain= %.3f \n' % (i_eta,i_phi,coolEm,float(gain)))
710  h_gains_em_reference.Fill(i_eta,i_phi,-100.)
711  h_gains_em_reference_rel.Fill(i_eta,i_phi,-100.)
712  else:
713  h_gains_em.Fill(i_eta,i_phi,gain)
714  h_chi2_em.Fill(i_eta,i_phi,chi2)
715  h_offset_em.Fill(i_eta,i_phi,offset)
716  em_partition_gains.Fill(i_eta,gain)
717  em_partition_gains_ref.Fill(i_eta,gain-reference_gain)
718  h_gains_em_reference.Fill(i_eta,i_phi,gain-reference_gain)
719 
720  if passes_selection is False:
721  h_gains_em_fselect.Fill(i_eta,i_phi)
722  bad_gain_file.write('%i %i %s EM gain= %.3f chi2= %.3f offset= %.3f \n' % (i_eta,i_phi,coolEm,float(gain),float(chi2),float(offset)))
723 # h_gains_em_reference.Fill(i_eta,i_phi,-100.)
724 # h_gains_em_reference_rel.Fill(i_eta,i_phi,-100.)
725 
726  if reference_gain > 0:
727  em_partition_gains_ref_rel.Fill(i_eta,(gain-reference_gain)/reference_gain)
728  h_gains_em_reference_rel.Fill(i_eta,i_phi,(gain-reference_gain)/reference_gain)
729  if fabs((gain-reference_gain)/reference_gain) > threshold_change:
730  h_drifted_em.Fill(i_eta,i_phi)
731  drifted_towers_file.write('%i %i %s EM gain= %.3f refGain= %.3f (%.3f %%) \n' % (i_eta,i_phi,coolEm,float(gain),float(reference_gain),(gain-reference_gain)*100/reference_gain))
732 
733 
734 
735 
736  if not coolHad == '': # there is a channel for this eta-phi
737 
738  gain = receiver_gains.getGain(coolHad)
739  chi2 = receiver_gains.getChi2(coolHad)
740  offset = receiver_gains.getOffset(coolHad)
741  reference_gain = receiver_gains.getReferenceGain(coolHad)
742  passes_selection = receiver_gains.passesSelection(coolHad)
743 
744  if (not gain == '') and (not reference_gain == ''): # both gains should be available
745 
746  if gain == -1. :
747  h_unfitted_had.Fill(i_eta,i_phi)
748  bad_gain_file.write('%i %i %s HAD gain= %.3f \n' % (i_eta,i_phi,coolHad,float(gain)))
749  h_gains_had_reference.Fill(i_eta,i_phi,-100.)
750  h_gains_had_reference_rel.Fill(i_eta,i_phi,-100.)
751  else:
752  h_gains_had.Fill(i_eta,i_phi,gain)
753  h_chi2_had.Fill(i_eta,i_phi,chi2)
754  h_offset_had.Fill(i_eta,i_phi,offset)
755  had_partition_gains.Fill(i_eta,gain)
756  had_partition_gains_ref.Fill(i_eta,gain-reference_gain)
757  h_gains_had_reference.Fill(i_eta,i_phi,gain-reference_gain)
758 
759  if passes_selection is False:
760  h_gains_had_fselect.Fill(i_eta,i_phi)
761  bad_gain_file.write( '%i %i %s HAD gain= %.3f chi2= %.3f offset= %.3f \n' % (i_eta,i_phi,coolHad,float(gain),float(chi2),float(offset)))
762 # h_gains_had_reference.Fill(i_eta,i_phi,-100.)
763 # h_gains_had_reference_rel.Fill(i_eta,i_phi,-100.)
764 
765  if reference_gain > 0:
766  had_partition_gains_ref_rel.Fill(i_eta,(gain-reference_gain)/reference_gain)
767  h_gains_had_reference_rel.Fill(i_eta,i_phi,(gain-reference_gain)/reference_gain)
768  if fabs((gain-reference_gain)/reference_gain) > threshold_change:
769  h_drifted_had.Fill(i_eta,i_phi)
770  drifted_towers_file.write('%i %i %s HAD gain= %.3f refGain= %.3f (%.3f %%) \n' % (i_eta,i_phi,coolHad,float(gain),float(reference_gain),(gain-reference_gain)*100/reference_gain))
771 
772 
773 
774 #print (measured_gains )
775  c1.cd()
776  ROOT.gPad.SetLogy(0)
777 
778  h_gains_em.SetMinimum(0.6)
779  h_gains_em.SetMaximum(1.4)
780 # h_gains_em.SetMaximum(2.1)
781  h_gains_em.Draw()
782  c1.Print("Gains.ps(")
783 
784  h_gains_had.SetMinimum(0.6)
785  h_gains_had.SetMaximum(1.4)
786  h_gains_had.Draw()
787  c1.Print("Gains.ps")
788 
789  h_drifted_em.Draw()
790  c1.Print("Gains.ps")
791 
792  h_drifted_had.Draw()
793  c1.Print("Gains.ps")
794 
795 
796  c1.cd()
797  ROOT.gPad.SetLogy(0)
798 
799  h_gains_em_reference_rel.SetMinimum(-0.5)
800  h_gains_em_reference_rel.SetMaximum(0.5)
801  h_gains_em_reference_rel.Draw()
802  c1.Print("Gains.ps")
803 
804  h_gains_had_reference_rel.SetMinimum(-0.5)
805  h_gains_had_reference_rel.SetMaximum(0.5)
806  h_gains_had_reference_rel.Draw()
807  c1.Print("Gains.ps")
808 
809 # ROOT.gPad.SetRightMargin(0.01)
810  h_gains_em_reference_rel.SetMinimum(-0.1)
811  h_gains_em_reference_rel.SetMaximum(0.1)
812  h_gains_em_reference_rel.Draw()
813  c1.Update()
814  palette = h_gains_em_reference_rel.h_1.GetListOfFunctions().FindObject("palette")
815  if palette:
816  palette.SetLabelSize(0.025)
817 
818  h_gains_em_reference_rel.Draw()
819  c1.Print("Gains.ps")
820 
821  h_gains_had_reference_rel.SetMinimum(-0.1)
822  h_gains_had_reference_rel.SetMaximum(0.1)
823  h_gains_had_reference_rel.Draw()
824  c1.Update()
825 
826  palette = h_gains_had_reference_rel.h_1.GetListOfFunctions().FindObject("palette")
827  if palette:
828  palette.SetLabelSize(0.025)
829 
830  h_gains_had_reference_rel.Draw()
831  c1.Print("Gains.ps")
832 
833 
834  c1.cd()
835  ROOT.gPad.SetLogy(0)
836 
837  h_gains_em_reference.SetMinimum(-0.5)
838  h_gains_em_reference.SetMaximum(0.5)
839 
840  h_gains_em_reference.Draw()
841  c1.Print("Gains.ps")
842 
843  h_gains_had_reference.SetMinimum(-0.5)
844  h_gains_had_reference.SetMaximum(0.5)
845 
846 # h_gains_had_reference.SetMinimum(-0.2)
847 # h_gains_had_reference.SetMaximum(0.2)
848 
849  h_gains_had_reference.Draw()
850  c1.Print("Gains.ps")
851 
852  c1.cd()
853  ROOT.gPad.SetLogy(0)
854  h_chi2_em.SetMinimum(0.1)
855  h_chi2_em.SetMaximum(100)
856  h_chi2_em.Draw()
857  c1.Print("Gains.ps")
858 
859  c1.cd()
860  ROOT.gPad.SetLogy(0)
861  h_chi2_had.SetMinimum(0.1)
862  h_chi2_had.SetMaximum(100)
863  h_chi2_had.Draw()
864  c1.Print("Gains.ps")
865 
866  c1.cd()
867  ROOT.gPad.SetLogy(0)
868  h_offset_em.SetMinimum(-1.)
869  h_offset_em.SetMaximum(1.)
870  h_offset_em.Draw()
871  c1.Print("Gains.ps")
872 
873  c1.cd()
874  ROOT.gPad.SetLogy(0)
875  h_offset_had.SetMinimum(-1.)
876  h_offset_had.SetMaximum(1.)
877  h_offset_had.Draw()
878  c1.Print("Gains.ps")
879 
880 
881  #c2.cd()
882  c2.Clear()
883  c2.Divide(3,2)
884  for i_p in range(0,em_partition_gains.nPartitions):
885  c2.cd(i_p+1)
886  if em_partition_gains.his_partitions[i_p].GetEntries() > 0:
887  ROOT.gPad.SetLogy()
888  else:
889  ROOT.gPad.SetLogy(0)
890  em_partition_gains.his_partitions[i_p].Draw()
891 
892  c2.Print("Gains.ps")
893 
894  #c2.cd()
895  c2.Clear()
896  c2.Divide(3,2)
897  for i_p in range(0,had_partition_gains.nPartitions):
898  c2.cd(i_p+1)
899  if had_partition_gains.his_partitions[i_p].GetEntries() > 0:
900  ROOT.gPad.SetLogy()
901  else:
902  ROOT.gPad.SetLogy(0)
903  had_partition_gains.his_partitions[i_p].Draw()
904 
905  c2.Print("Gains.ps")
906 
907 
908  #c2.cd()
909  c2.Clear()
910  c2.Divide(3,2)
911  for i_p in range(0,em_partition_gains_ref.nPartitions):
912  c2.cd(i_p+1)
913  if em_partition_gains_ref.his_partitions[i_p].GetEntries() > 0:
914  ROOT.gPad.SetLogy()
915  else:
916  ROOT.gPad.SetLogy(0)
917  em_partition_gains_ref.his_partitions[i_p].Draw()
918 
919  c2.Print("Gains.ps")
920 
921  #c2.cd()
922  c2.Clear()
923  c2.Divide(3,2)
924  for i_p in range(0,had_partition_gains_ref.nPartitions):
925  c2.cd(i_p+1)
926  if had_partition_gains_ref.his_partitions[i_p].GetEntries() > 0:
927  ROOT.gPad.SetLogy()
928  else:
929  ROOT.gPad.SetLogy(0)
930  had_partition_gains_ref.his_partitions[i_p].Draw()
931 
932  c2.Print("Gains.ps")
933 
934  #c2.cd()
935  c2.Clear()
936  c2.Divide(3,2)
937  for i_p in range(0,em_partition_gains_ref_rel.nPartitions):
938  c2.cd(i_p+1)
939  if em_partition_gains_ref_rel.his_partitions[i_p].GetEntries() > 0:
940  ROOT.gPad.SetLogy()
941  else:
942  ROOT.gPad.SetLogy(0)
943  em_partition_gains_ref_rel.his_partitions[i_p].Draw()
944 
945  c2.Print("Gains.ps")
946 
947  #c2.cd()
948  c2.Clear()
949  c2.Divide(3,2)
950  for i_p in range(0,had_partition_gains_ref_rel.nPartitions):
951  c2.cd(i_p+1)
952  if had_partition_gains_ref_rel.his_partitions[i_p].GetEntries() > 0:
953  ROOT.gPad.SetLogy()
954  else:
955  ROOT.gPad.SetLogy(0)
956  had_partition_gains_ref_rel.his_partitions[i_p].Draw()
957 
958  c2.Print("Gains.ps")
959 
960 
961  c1.cd()
962  ROOT.gPad.SetLogy(0)
963 
964  h_gains_em_fselect.Draw()
965  c1.Print("Gains.ps")
966 
967  h_gains_had_fselect.Draw()
968  c1.Print("Gains.ps")
969 
970 
971  h_unfitted_em.Draw()
972  c1.Print("Gains.ps")
973 
974  h_unfitted_had.Draw()
975  c1.Print("Gains.ps)")
976 
977  os.system("ps2pdf Gains.ps")
978 
979  bad_gain_file.close()
980  drifted_towers_file.close()
981 
982  print ("finished!")
983 

Variable Documentation

◆ action

PlotCalibrationGains.action

Definition at line 990 of file PlotCalibrationGains.py.

◆ args

PlotCalibrationGains.args

Definition at line 1000 of file PlotCalibrationGains.py.

◆ dest

PlotCalibrationGains.dest

Definition at line 990 of file PlotCalibrationGains.py.

◆ help

PlotCalibrationGains.help

Definition at line 990 of file PlotCalibrationGains.py.

◆ options

PlotCalibrationGains.options

Definition at line 1000 of file PlotCalibrationGains.py.

◆ parser

PlotCalibrationGains.parser

Definition at line 988 of file PlotCalibrationGains.py.

◆ type

PlotCalibrationGains.type

Definition at line 990 of file PlotCalibrationGains.py.

PlotCalibrationGains.PlotCalibrationGains
def PlotCalibrationGains(input_file_name="", reference_file_name="", isInputXml=False, isInputSqlite=False, isRefXml=False, isRefSqlite=False, isRefOracle=False)
Definition: PlotCalibrationGains.py:610
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Trk::open
@ open
Definition: BinningType.h:40
generate::GetEntries
double GetEntries(TH1D *h, int ilow, int ihi)
Definition: rmsFrac.cxx:20
readCCLHist.float
float
Definition: readCCLHist.py:83