Index: trunk/HiggsSignals/example_programs/HSwithToys.f90
===================================================================
--- trunk/HiggsSignals/example_programs/HSwithToys.f90	(revision 505)
+++ trunk/HiggsSignals/example_programs/HSwithToys.f90	(revision 506)
@@ -1,198 +1,198 @@
 !--------------------------------------------------------------------------------------
 program HSwithToys
 !
 ! This example program is part of HiggsSignals (TS 25/01/2013).
 !--------------------------------------------------------------------------------------
 ! This example program shows how HiggsSignals (HS) can be run on toy experiments. We
 ! first run HS with SM input with a Higgs mass of 126 GeV. From the result of this
 ! run we can obtain the predicted signal strength modifiers for each peak observable
 ! directly from HiggsSignals. As a demonstration, these are then set as observed (toy)
 ! signal rates of the various observables. We then re-run HiggsSignals on the new
 ! observables on the same model, i.e. observed and predicted signal rates are equal,
 ! thus the resulting chi^2 should be zero.
 !--------------------------------------------------------------------------------------
  use theory_colliderSfunctions
  use usefulbits, only : vsmall 
  use usefulbits_hs,only : analyses
  use pc_chisq, only : print_peaks_to_LaTeX,print_cov_mu_to_file
  use io, only : get_peakinfo_from_HSresults, get_number_of_observables,&
  &              get_ID_of_peakobservable, HiggsSignals_create_SLHA_output,&
  &              HiggsSignals_create_SLHA_output_default
   	  
  implicit none
  integer :: nH,nHplus,ndf, ii, jj, kk
  double precision :: Chisq, Chisq_mu, Chisq_mh, Pvalue
  double precision, allocatable :: dMh(:)
  double precision :: dCS(5),dBR(5),dggh, dbbh
   double precision :: SMGamma_h
   double precision :: Mh,GammaTotal,g2hjss_s,g2hjss_p,g2hjcc_s,g2hjcc_p,&
 &                     g2hjbb_s,g2hjbb_p,g2hjtt_s,g2hjtt_p,&
 &                     g2hjmumu_s,g2hjmumu_p,g2hjtautau_s,g2hjtautau_p,&
 &                     g2hjWW,g2hjZZ,g2hjZga,g2hjgaga,g2hjgg,g2hjggZ,&
 &                     g2hjhiZ,BR_hjhihi,BR_hjinvisible  
   double precision :: mupred
   integer :: domH, nHcomb
   integer :: ntotal, npeakmu, npeakmh, nmpred, nanalyses, ID
   integer :: i,npoints
   character(len=8) :: istring
   character(len=300) :: inputfilename,outputfilename
   character(len=300) :: stem
   character(LEN=300) :: temp
   integer :: number_args, stat
 
 !---Note here: We only run HiggsSignals on the lightest Higgs boson. This can be easily
 !---extended to all 3 MSSM neutral Higgs bosons. In that case, the effective couplings
 !---and mass uncertainties have to be given as arrays of size=nH (Cf. the Higgsbounds
 !---manual for HB-3.x.x for how to call HiggsBounds_neutral_input_effC correctly!)
   nH=1
   nHplus=0
 
   allocate(dMh(nH))
 !--Set the (relative!) rate uncertainties for your model:
 !  dCS(1) - singleH				dBR(1) - gamma gamma
 !  dCS(2) - VBF					dBR(2) - W W
 !  dCS(3) - HW					dBR(3) - Z Z
 !  dCS(4) - HZ					dBR(4) - tau tau
 !  dCS(5) - ttH					dBR(5) - b bbar
 !--Here, we first set them to the SM. Later, we determine the uncertainty of singleH
 !--production, dCS(1), from the effective couplings. SM values are taken from
 !--https://twiki.cern.ch/twiki/bin/view/LHCPhysics/CrossSections
 ! dCS = (/ 0.147D0, 0.028D0, 0.037D0, 0.051D0, 0.12D0 /)
 ! dBR = (/ 0.054D0, 0.048D0, 0.048D0, 0.061D0, 0.028D0 /)
 !!--Set the rate uncertainties of gluon-gluon fusion and bb->H here:
 ! dggh = 0.147D0
 ! dbbh = 0.200D0
 !--n.b. have to set theoretical uncertainties on Higgs mass dMh (in GeV):
   dMh = (/ 0.0D0 /)
 !-------------------------- HiggsSignals ------------------------------!
 
 !---- Initialize HiggsSignals and pass the name of the experimental analysis folder  ----!
 !  call initialize_HiggsSignals(nH,nHplus,"latestresults") 
-  call initialize_HiggsSignals(nH,nHplus,"Feb2014_veryincl")   
+  call initialize_HiggsSignals(nH,nHplus,"latestresults")   
 !  call setup_thu_observables(1)   
 !---- Set the Higgs mass parametrization (1: box, 2:gaussian, 3:box+gaussian)	 	 ----!
   call setup_pdf(2)
 !---- Set the output level (0: silent, 1: screen output, 2: even more output,...) 	 ----!
   call setup_output_level(0)
 !---- Pass the Higgs mass uncertainty to HiggsSignals							 	 ----!
   call HiggsSignals_neutral_input_MassUncertainty(dMh)
 !---- Use symmetric rate errors? (0: original(default), 1: averaged-symmetrical)     ----!
 ! call setup_symmetricerrors(0)
 !---- Allow anti-correlated signal strength measurements? (0: no, 1: yes(default) )  ----!
 ! call setup_anticorrelations_in_mu(1)
 !---- Setup a wider assignment range                                                 ----!
- call setup_assignmentrange(2.0D0)
+ call setup_assignmentrange(1.0D0)
 ! call setup_assignmentrange_massobservables(2.0D0)
 
 !----HiggsBounds/Signals effective couplings input. 
 !  	 These have to be inserted for the model which we want to test, i.e. we would have
 !    to write an interface to set via arguments in the executables call, or reading
 !    in a text file, etc.
 !----For now, we set them by hand to the SM values (for demonstration):
   g2hjss_s=1d0
   g2hjss_p=0d0
   g2hjcc_s=1d0
   g2hjcc_p=0d0
   g2hjbb_s=1d0
   g2hjbb_p=0d0
   g2hjtt_s=1d0
   g2hjtt_p=0d0         
   g2hjmumu_s=1d0
   g2hjmumu_p=0d0  
   g2hjtautau_s=1d0
   g2hjtautau_p=0d0
   g2hjWW=1d0
   g2hjZZ=1d0
   g2hjZga=1d0
   g2hjgaga=1d0
   g2hjgg=1d0
   g2hjggZ=1d0
   g2hjhiZ=0d0
   BR_hjhihi=0d0
   BR_hjinvisible=0d0
   Mh=dble(125.8)
   GammaTotal=SMGamma_h(Mh)
 	  
 !-Calculate theoretical uncertainties of singleH production from ggh and bbh effective couplings. 
 !  dCS(1) = get_singleH_uncertainty(dggh, dbbh, g2hjgg, g2hjbb_s+g2hjbb_p, mh)	
 !  call setup_rate_uncertainties(dCS, dBR)
 
 !-Set the HiggsSignals input
   call HiggsBounds_neutral_input_effC(Mh,GammaTotal,&
 &    g2hjss_s,g2hjss_p,g2hjcc_s,g2hjcc_p,g2hjbb_s,g2hjbb_p,&
 &    g2hjtt_s,g2hjtt_p,&
 &    g2hjmumu_s,g2hjmumu_p,g2hjtautau_s,g2hjtautau_p,&
 &    g2hjWW,g2hjZZ,g2hjZga,g2hjgaga,g2hjgg,g2hjggZ,&
 &    g2hjhiZ, BR_hjinvisible,BR_hjhihi)
 
 !-Run HS on the original experimental data in order to evaluate the model predictions	  
   call run_HiggsSignals(1, Chisq_mu, Chisq_mh, Chisq, ndf, Pvalue)
 !-Print out the observables to a LaTeX table
 !  call print_peaks_to_LaTeX
   call print_cov_mu_to_file
 
 !-Get the number of the peak-observables (Don't care about ntotal, npeakmh, nmpred, nanalyses)
   call get_number_of_observables(ntotal, npeakmu, npeakmh, nmpred, nanalyses)
 
 !-We now want to set the measurements to those values predicted by the model.
 !-The mass measurement for each peak observable will be set to Mh here.
 
 !-Loop over the number of peak observables
   do kk=1,npeakmu
 !--Get for each peak observable its unique ID:
    call get_ID_of_peakobservable(kk, ID)
 !--Get the predicted signal strength modifier (mupred) for this peak observable:
    call get_peakinfo_from_HSresults(ID, mupred, domH, nHcomb)
 !--Assign this value as (toy) measurement for this peak observable:
    call assign_toyvalues_to_peak(ID, mupred, Mh)
   enddo
   
   call setup_output_level(0)	!-Do a print-out to the screen
     
 !-Set the HiggsSignals input (again!)
   call HiggsBounds_neutral_input_effC(Mh,GammaTotal,&
 &    g2hjss_s,g2hjss_p,g2hjcc_s,g2hjcc_p,g2hjbb_s,g2hjbb_p,&
 &    g2hjtt_s,g2hjtt_p,&
 &    g2hjmumu_s,g2hjmumu_p,g2hjtautau_s,g2hjtautau_p,&
 &    g2hjWW,g2hjZZ,g2hjZga,g2hjgaga,g2hjgg,g2hjggZ,&
 &    g2hjhiZ, BR_hjinvisible,BR_hjhihi)
 
 !-Now, we run on the toy observables with the same input, i.e. model predictions and
 !-measurements are equal and thus the chi^2 should be zero.	  
   call run_HiggsSignals(1, Chisq_mu, Chisq_mh, Chisq, ndf, Pvalue)
 
 !-Create a new SLHA file with the HiggsSignals output blocks.
 !-The second argument controls how much is written
 !  (0: only the BLOCK 'HiggsSignalsResults', 1: full HiggsSignals SLHA output)
 !-The new file must not exist:
 ! (note: this system call does not work with ifort)
 !  call system('rm -f results/HSwithToys.slha',status=stat)
   call HiggsSignals_create_SLHA_output("results/HSwithToys.slha",0)
 !-Alternatively, we could use
 !  call HiggsSignals_create_SLHA_output_default(0)
 !-where the filename is set to "HS-output.slha".
 
   call finish_HiggsSignals
  
  contains
 !--------------------------------------------------------------------------------------
  function get_singleH_uncertainty(dggh, dbbh, g2hgg, g2hbb, mh)
  ! This function evaluates the uncertainty of single Higgs production from an interpolation
  ! of the uncertainties on gg->H and bb->H, using the squared effective couplings g2hgg and
  ! g2hbb. It uses internal HiggsBounds functions from the module theory_colliderSfunctions.
 !--------------------------------------------------------------------------------------
 
  double precision, intent(in) :: dggh, dbbh, g2hgg, g2hbb, mh
  double precision :: get_singleH_uncertainty
  
  if(g2hgg.le.vsmall.and.g2hbb.le.vsmall) then
   get_singleH_uncertainty = 0.0D0
  else 
   get_singleH_uncertainty = ( g2hgg*LHC8_rH_gg(mh)*dggh + g2hbb*LHC8_rH_bb(mh)*dbbh )/ &
  & 	                        ( g2hgg*LHC8_rH_gg(mh)      + g2hbb*LHC8_rH_bb(mh)      )
  endif
  
  end function get_singleH_uncertainty
 !--------------------------------------------------------------------------------------
 end program HSwithToys
 !--------------------------------------------------------------------------------------
Index: trunk/HiggsSignals/usefulbits_HS.f90
===================================================================
--- trunk/HiggsSignals/usefulbits_HS.f90	(revision 505)
+++ trunk/HiggsSignals/usefulbits_HS.f90	(revision 506)
@@ -1,496 +1,496 @@
 !--------------------------------------------------------------------
 ! This file is part of HiggsSignals (TS 03/03/2013)
 !--------------------------------------------------------------------
 module usefulbits_HS
 !--------------------------------------------------------------------
  implicit none
 
- character(LEN=9),parameter :: HSvers='1.3.0'
+ character(LEN=9),parameter :: HSvers='1.3.1'
  integer,parameter :: f_dmh=94
  character(LEN=4) :: runmode
  character(LEN=100) :: Exptdir
 !--------------------------------------------------------------------
 !--IN TESTING PHASE: (do not change this in official version)
  logical :: withcorrexpsyst = .True. !(correlated experimental systematics)
  logical :: additional_output = .False.
 !--END 
 !------------------------Control parameters -------------------------
 ! Values can be changes with specific user subroutines.
  logical :: usetoys = .False.
  logical :: usescalefactor = .False.
  logical :: useSMweights = .False.
  logical :: correlations_mu = .True.
  logical :: correlations_mh = .True. 
  logical :: minimalchisq = .False.
  logical :: maximalchisq = .False.
  logical :: useSMtest = .False.
  logical :: SLHAdetailed = .True.
  logical :: newSLHAfile = .False.
  logical :: symmetricerrors = .False.
  logical :: anticorrmu = .True.
  logical :: anticorrmh = .True.
  logical :: absolute_errors = .False.
  logical :: THU_included = .True.
  logical :: useaveragemass = .True.
  logical :: normalize_rates_to_reference_position = .False.
 
  double precision :: eps 
  double precision :: assignmentrange = 1.0D0  ! This gives the mass range
                                               ! (in standard deviations), in which
                                               ! the Higgs is forced to be assigned to
                                               ! a peak observable.
  double precision :: assignmentrange_massobs = 1.0D0  
                                               ! This gives the mass range
                                               ! (in standard deviations), in which
                                               ! the Higgs is forced to be assigned to
                                               ! peak observables, which have a mass
                                               ! measurement.
 
  integer :: output_level = 0
  integer :: iterations = 0		! default value: 0
  								! 1 -> try to assign as many Higgs bosons as possible to
  								! the observable, Higgs-to-peak assignment is based on
  								! Higg mass covariance matrices with maximal
  								! correlations.
  								! >1 -> use the covariance matrix of previous iteration.
  integer :: pdf	= 2				! default value: 2
  								! will automatically be set to 2 if not changed by the user
  								! via using subroutine set_pdf before.
  								! (1,2,3) = (box, gaussian, theory-box + exp-gaussian)
  integer :: Nparam = 0			! Number of free model parameters (entering the Pvalue)
  								! Can be specified directly here or via the subroutine
  								! setup_nparam 								
 !-------------------------------------------------------------------- 								
  integer :: nanalys 			!Total number of relevant analyses                       
  double precision, parameter :: vlarge=1000000000000.0D0
 !--------------------- Default rate uncertainties -------------------
 
  type rate_uncertainties 
 !- dCS_SM and dBR_SM for the SM 
 !- (from LHC HXSWG Yellow Report 3, arXiv:1307.1347)
 !- dCS and dBR hold the model's rate uncertainties. Can be changed by user
 !- with subroutine setup_rate_uncertainties. Default values are those of the SM.
   double precision :: dCS_SM(5) = (/ 0.147D0, 0.028D0, 0.037D0, 0.060D0, 0.12D0 /)  
   double precision :: dCS(5) = (/ 0.147D0, 0.028D0, 0.037D0, 0.060D0, 0.12D0 /)  
 !  double precision :: dBR_SM(5) = (/ 0.054D0, 0.048D0, 0.048D0, 0.061D0, 0.028D0 /)
 !  double precision :: dBR(5) = (/ 0.054D0, 0.048D0, 0.048D0, 0.061D0, 0.028D0 /)
 !- EDIT (TS 21/06/2013): Add new decay modes:
 !- Channels: gammagamma, WW, ZZ, tautau, bb, Zgamma, cc, mumu, gg
   double precision :: dBR_SM(9) = (/ 0.054D0, 0.048D0, 0.048D0, 0.061D0, 0.028D0,&
 &                                    0.090D0, 0.122D0, 0.060D0, 0.100D0 /)  
   double precision :: dBR(9) = (/ 0.054D0, 0.048D0, 0.048D0, 0.061D0, 0.028D0,&
 &                                    0.090D0, 0.122D0, 0.060D0, 0.100D0 /)
 !--- IMPORTANT NOTE:
 !-
 !- The arrays dCS_SM, dCS, dBR_SM, dBR have been introduced in HiggsSignals-1.0.0
 !- to hold the estimated theoretical uncertainties. These do not include correlations
 !- via parametric uncertainties (e.g. scale, PDFs,...) or correlations in the BRs introduced
 !- by the uncertainty of the total widths.
 !-
 !- Since HiggsSignals-1.1.0 the theoretical uncertainties for the cross sections and
 !- branching ratios are evaluated with toy MC scripts including the correlations of
 !- parametric error sources. The resulting covariance matrices are included per default
 !- if the files "BRcov.in" and "XScov.in" are present in the main HiggsSignals directory.
 !- If not, HiggsSignals will give a warning and use the old method.
 !- The covariance matrices can also be re-evaluated by the user with the scripts
 !- "smearErrorsBR.cpp" and "smearErrorsXS.cpp", which can be found in the directory
 !- <HiggsSignals-main-directory>/supplements/
 !-
 !---
   logical :: BRcov_ok=.False.
   logical :: CScov_ok=.False.
   logical :: usecov =.True.
   
   double precision, dimension(9,9) :: BRcovSM = 0.0D0
   double precision, dimension(9,9) :: BRcov = 0.0D0
   double precision, dimension(5,5) :: CScovSM = 0.0D0
   double precision, dimension(5,5) :: CScov = 0.0D0
     
 !--- ILC cross section uncertainties (under development)  
 !--- (none, none, WBF, ZH, ttH)
   double precision :: dCS_ILC_SM(5) = (/ 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0 /)  
   double precision :: dCS_ILC(5) = (/ 0.0D0, 0.0D0, 0.01D0, 0.005D0, 0.01D0 /)  
 
 
  end type  
  type(rate_uncertainties), save :: delta_rate 
  
 !-------------- Type definitions of internal structures --------------
  type neutHiggs
   double precision :: m, dm, mu
   integer :: mp_test	! This variable is set to 1 (0) if the Higgs is (not) being tested in the m-pred chi^2 method.
   integer :: id
  end type
  !-Will contain info about all neutral Higgs for every considered observable, i.e.
 !-neutHiggses has dimensions (number(observables),nH)
  type(neutHiggs), allocatable :: neutHiggses(:,:)
 
 type mutable
   integer :: id,nx,particle_x !see usefulbits.f90 for key to particle codes n.b. they're NOT pdg
   character(LEN=45) :: label
   character(LEN=100) :: desc
   character(LEN=3) :: expt  
   character(LEN=10) :: collider 
   character(LEN=10) :: collaboration   
   double precision :: lumi,dlumi,energy			! dlumi in %
 !--TESTING correlated experimental systematics:
 !  double precision, dimension(4) :: correxpsyst
 !--END  
   double precision :: xmax,xmin,sep,deltax
   double precision :: deltam
   character(LEN=100) :: assignmentgroup
   integer :: mhchisq
   double precision, allocatable :: mass(:)
   double precision, allocatable :: mu(:,:) ! in mu(a,b), a=row, b=1,2,3 for low,obs,up 
   integer :: Nc								  ! Number of channels
   integer, allocatable :: channel_id(:)		  ! Considered channels array, dim(Nc)
   character(LEN=10),allocatable :: channel_description(:,:)  
   double precision, allocatable :: channel_eff(:) 	  ! Channel efficiencies, dim(Nc) 
   double precision, allocatable :: channel_eff_ratios(:) 	  ! Channel efficiency ratios (model vs. SM), dim(Nc)   
   double precision, allocatable :: channel_w(:,:) ! Channel weights, dim(Nc, NHiggs)
   double precision, allocatable :: channel_w_corrected_eff(:,:) ! Channel weights, dim(Nc, NHiggs)  
   double precision, allocatable :: channel_systSM(:,:) ! Channel systematics of SM, dim(Nc, NHiggs)  
   double precision, allocatable :: channel_syst(:,:) ! Channel systematics, dim(Nc, NHiggs)
   double precision, allocatable :: channel_mu(:,:) ! SM normalized channel rates, dim(Nc, NHiggs)											  
   double precision :: eff_ref_mass			  ! Reference Higgs mass for quoted efficiency
   integer :: npeaks
   double precision, allocatable :: Toys_mhobs(:)
   double precision, allocatable :: Toys_muobs(:)
   double precision :: scale_mu
  end type
 
  type mupeak
   integer :: id      
   integer :: ilow,iup,ipeak
   double precision :: mpeak
   double precision :: dm
   double precision :: mu
   double precision :: mu_original  
   double precision :: scale_mu!, scale_mh  
   double precision :: dmuup,dmulow			  ! Upper and lower cyan band 	
   double precision :: dmuup0sq, dmulow0sq	  ! Cyan band squared subtracted by correlated uncertainties
   !-Peak object should contain everything needed for constructing the covariance matrices
   integer :: Nc								  ! Number of channels
   integer, allocatable :: channel_id(:)		  ! Considered channels array, dim(Nc)
   double precision, allocatable :: channel_eff(:) 	  ! Channel efficiencies, dim(Nc)   
   integer, allocatable :: Higgs_comb(:)		  ! Assigned Higgs combination, dim(NHiggs)
   character(LEN=100) :: assignmentgroup  
   type(neutHiggs), allocatable :: Higgses(:)
   integer :: domH							  !	index of dominantly contributing Higgs
   integer :: NHiggs_comb					  ! Number of combined Higgses
   integer :: Higgs_assignment_forced
   integer :: undo_assignment
   !--These arrays contain only the information about all Higgs bosons
   !--(need to have this for every peak separately because it can depend on the efficiencies
   !-- which are given for each peak separately)
   double precision, allocatable :: channel_w_allH(:,:)      ! Channel weights, dim(Nc, NHiggs)
   double precision, allocatable :: channel_w_corrected_eff_allH(:,:) ! Channel weights with corrected efficiencies, dim(Nc, NHiggs)  
   double precision, allocatable :: channel_systSM_allH(:,:) ! Channel systematics of SM, dim(Nc, NHiggs)  
   double precision, allocatable :: channel_syst_allH(:,:)   ! Channel systematics, dim(Nc, NHiggs)
   double precision, allocatable :: channel_mu_allH(:,:)     ! SM normalized channel rates, dim(Nc, NHiggs)											  	
   !--These arrays contain only the information about the chosen Higgs combination:
   double precision, allocatable :: channel_w(:)             ! Channel weights, dim(Nc)
   double precision, allocatable :: channel_w_corrected_eff(:) ! Channel weights with corrected efficencies, dim(Nc)
   double precision, allocatable :: channel_systSM(:)        ! Channel systematics, dim(Nc)  
   double precision, allocatable :: channel_syst(:)          ! Channel systematics, dim(Nc)
   double precision, allocatable :: channel_mu(:)            ! SM normalized channel rates, dim(Nc)
   double precision, allocatable :: channel_w_model(:)
   double precision :: total_mu
   double precision :: dlumi
   !-- Chisq values (mu and mh parts, total) after taking into account correlations with
   !-- other peaks:
   double precision :: chisq_mu
   double precision :: chisq_mh  
   double precision :: chisq_tot
   double precision :: chisq_max
   integer :: internalnumber
  end type
 
 type mp_neutHiggs
 !-This object is a Higgs or Higgscluster which are separately
 !-tested with the predicted mass chi^2 method.
  type(neutHiggs), allocatable :: Higgses(:)
  double precision :: m, dm, mu
  integer :: mp_test
  double precision :: mu_obs, dmu_low_obs, dmu_up_obs, dmu_low0_obs, dmu_up0_obs, m_obs
  double precision, allocatable :: channel_w_model(:)
  double precision, allocatable :: channel_mu(:)
  double precision :: total_mu
  integer :: Higgscomb
  integer :: domH
  double precision :: chisq 
 !-n.b. these are the smeared observed signal strengths for this Higgs boson
 end type
 
 type mpred
  type(mp_neutHiggs), allocatable :: mp_Higgses(:) 
  double precision :: mupred
 end type
 
 type observable
  integer :: id
  integer :: obstype
  type(mupeak) :: peak
  type(mutable) :: table
  type(neutHiggs), allocatable :: Higgses(:)
 end type
 type(observable), allocatable :: obs(:)
 
 type tablelist
  integer :: Npeaks
  integer :: id
  type(mutable) :: table
  type(mupeak), allocatable :: peaks(:)
  type(mpred) :: mpred
  type(neutHiggs), allocatable :: Higgses(:)	
 	! This object holds primarily the Higgs boson predictions
  	! corresponding to tablelist%table. It corresponds to the full 
  	! muplot if it is implemented (to enable the mpred-method).
 end type
 type(tablelist), allocatable :: analyses(:)
 
 type HSresults                  
  double precision :: Pvalue = -1.0D0           
  double precision :: Chisq
  double precision :: Chisq_mu, Chisq_mpred, Chisq_peak_mu
  double precision :: Chisq_mh
  double precision, allocatable :: mupred(:)
  integer, allocatable :: domH(:)    
  integer, allocatable :: nH(:)  
  integer, allocatable :: obsID(:)  
  integer :: nobs, nobs_mpred, nobs_peak_mu, nobs_peak_mh, nanalysis
 end type            
 type(HSresults), allocatable :: HSres(:)
 
 !----------------------- Covariance matrices ----------------------
  double precision, allocatable :: cov(:,:)
  double precision, allocatable :: cov_mhneut(:,:,:)
  double precision, allocatable :: cov_mhneut_max(:,:,:)
  double precision, allocatable :: cov_mh_av(:,:)
  double precision, allocatable :: cov_mh_av_max(:,:)
  double precision, allocatable :: cov_mp(:,:)
  double precision, allocatable :: cov_mu_tot(:,:)
  double precision, allocatable :: mu_vector(:)
 !--------------------------------------------------------------------  
  contains
 !--------------------------------------------------------------------
  subroutine HiggsSignals_info
 !--------------------------------------------------------------------
   implicit none
 
   write(*,*)
   write(*,*)"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
   write(*,*)"~                                                        ~"
   write(*,*)"~      	      HiggsSignals "//adjustl(HSvers)//"	          ~"
   write(*,*)"~                                                        ~"
   write(*,*)"~      Philip Bechtle, Sven Heinemeyer, Oscar Stål,      ~"
   write(*,*)"~              Tim Stefaniak, Georg Weiglein             ~"
   write(*,*)"~                                                        ~"
   write(*,*)"~       arXiv:1305.1933 (Manual)                         ~"
   write(*,*)"~       arXiv:1403.1582 (application + more details)     ~"
   write(*,*)"~                                                        ~"  
   write(*,*)"~ It is based on the HiggsBounds-4 Fortran library.      ~"
   write(*,*)"~ Please consult and cite also the following references  ~"
   write(*,*)"~ for the HiggsBounds program                            ~"
   write(*,*)"~                                                        ~"  
   write(*,*)"~    arXiv:0811.4169, arXiv:1102.1898, arXiv:1311.0055   ~"  
   write(*,*)"~                                                        ~"    
   write(*,*)"~ For updates, additional material, release notes, see:  ~"    
   write(*,*)"~            http://higgsbounds.hepforge.org             ~"
   write(*,*)"~                                                        ~"
   write(*,*)"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
   write(*,*)
   write(*,*)" HiggsSignals collects together results from "
   write(*,*)
   write(*,*)"    * the ATLAS and CMS Collaborations"
   write(*,*)"    * the CDF and D0 Collaborations"
   write(*,*)"    * the program HDECAY (arXiv:hep-ph/9704448)"  
   write(*,*)"    * LHC Higgs Cross Section Working Group"
   write(*,*)"      (arXiv:1101.0593, arXiv:1201.3084, "
   write(*,*)"       arXiv:1307.1347 and ref. therein)"
   write(*,*)
   
   
  end subroutine HiggsSignals_info
 !--------------------------------------------------------------------
  subroutine print_dble_matrix(mat, title)
  !--------------------------------------------------------------------
   implicit none
   double precision, dimension(:,:), intent(in) :: mat(:,:)
   character(LEN=50), intent(in), optional :: title
   integer :: i
   
   if(present(title)) then
    write(*,*)"#*************************************************************************#"
    write(*,*)"# ",trim(title)
   endif 
   write(*,*) "#*************************************************************************#"
   do i=lbound(mat,dim=1),ubound(mat,dim=1)
 	write(*,*) mat(i,:)
   enddo	
   write(*,*) "#*************************************************************************#"
  end subroutine print_dble_matrix
 !--------------------------------------------------------------------
  subroutine deallocate_usefulbits_HS
 !--------------------------------------------------------------------  
   implicit none
   integer :: i
 !  deallocate(neutHiggses)
   if(allocated(HSres)) then
    do i=lbound(HSres, dim=1), ubound(HSres, dim=1)
     if(allocated(HSres(i)%mupred)) deallocate(HSres(i)%mupred)
     if(allocated(HSres(i)%domH)) deallocate(HSres(i)%domH)
     if(allocated(HSres(i)%nH)) deallocate(HSres(i)%nH)   
    enddo 
    deallocate(HSres)
   endif	
 
   call deallocate_covariance_matrices
   
  end subroutine deallocate_usefulbits_HS
 !--------------------------------------------------------------------  
  subroutine deallocate_covariance_matrices
 !--------------------------------------------------------------------  
   implicit none
   
   if(allocated(cov)) deallocate(cov)
   if(allocated(cov_mhneut)) deallocate(cov_mhneut)
   if(allocated(cov_mhneut_max)) deallocate(cov_mhneut_max)
   if(allocated(cov_mh_av)) deallocate(cov_mh_av)
   if(allocated(cov_mh_av_max)) deallocate(cov_mh_av_max)
   if(allocated(cov_mp)) deallocate(cov_mp)
   if(allocated(cov_mu_tot)) deallocate(cov_mu_tot)
   if(allocated(mu_vector)) deallocate(mu_vector)
   
  end subroutine deallocate_covariance_matrices
 !--------------------------------------------------------------------
 function int_in_array(number, array) 
  integer, intent(in) :: number
  integer, dimension(:), intent(in) :: array
  logical :: int_in_array
  
  integer :: i
  
  int_in_array = .False.
  
  do i=lbound(array,dim=1),ubound(array,dim=1)
   if(number.eq.array(i)) int_in_array = .True.
  enddo 
  
 end function int_in_array
 !------------------------------------------------------------------------------------   
 
 
 
 !--------------------------------------------------------------------
 !:sdoc+:
 !
 ! NAME:
 !       StrCompress
 !
 ! PURPOSE:
 !       Subroutine to return a copy of an input string with all whitespace
 !       (spaces and tabs) removed.
 !
 ! CALLING SEQUENCE:
 !       Result = StrCompress( String,  &  ! Input
 !                             n = n    )  ! Optional Output
 !
 ! INPUT ARGUMENTS:
 !       String:         Character string to be compressed.
 !                       UNITS:      N/A
 !                       TYPE:       CHARACTER(*)
 !                       DIMENSION:  Scalar
 !                       ATTRIBUTES: INTENT(IN)
 !
 ! OPTIONAL OUTPUT ARGUMENTS:
 !       n:              Number of useful characters in output string
 !                       after compression. From character n+1 -> LEN(Input_String)
 !                       the output is padded with blanks.
 !                       UNITS:      N/A
 !                       TYPE:       INTEGER
 !                       DIMENSION:  Scalar
 !                       ATTRIBUTES: INTENT(OUT), OPTIONAL
 !
 ! FUNCTION RESULT:
 !       Result:         Input string with all whitespace removed before the
 !                       first non-whitespace character, and from in-between 
 !                       non-whitespace characters.
 !                       UNITS:      N/A
 !                       TYPE:       CHARACTER(LEN(String))
 !                       DIMENSION:  Scalar
 !
 ! EXAMPLE:
 !       Input_String = '  This is a string with spaces in it.'
 !       Output_String = StrCompress( Input_String, n=n )
 !       WRITE( *, '( a )' ) '>',Output_String( 1:n ),'<'
 !   >Thisisastringwithspacesinit.<
 !
 !       or
 !
 !       WRITE( *, '( a )' ) '>',TRIM( Output_String ),'<'
 !   >Thisisastringwithspacesinit.<
 !
 ! PROCEDURE:
 !       Definitions of a space and a tab character are made for the
 !       ASCII collating sequence. Each single character of the input
 !       string is checked against these definitions using the IACHAR()
 !       intrinsic. If the input string character DOES NOT correspond 
 !       to a space or tab, it is not copied to the output string.
 !
 !       Note that for input that ONLY has spaces or tabs BEFORE the first
 !       useful character, the output of this function is the same as the
 !       ADJUSTL() instrinsic.
 !
 ! CREATION HISTORY:
 !       Written by:     Paul van Delst, CIMSS/SSEC 18-Oct-1999
 !                       paul.vandelst@ssec.wisc.edu
 !
 !:sdoc-:
 !--------------------------------------------------------------------
  FUNCTION StrCompress( Input_String, n ) RESULT( Output_String )
     ! Arguments
     CHARACTER(*),      INTENT(IN)  :: Input_String
     INTEGER, OPTIONAL, INTENT(OUT) :: n
     ! Function result
     CHARACTER(LEN(Input_String)) :: Output_String
     ! Local parameters
     INTEGER, PARAMETER :: IACHAR_SPACE = 32
     INTEGER, PARAMETER :: IACHAR_TAB   = 9
     ! Local variables
     INTEGER :: i, j
     INTEGER :: IACHAR_Character
 
     ! Setup
     ! -----
     ! Initialise output string
     Output_String = ' '
     ! Initialise output string "useful" length counter
     j = 0
 
     ! Loop over string contents character by character
     ! ------------------------------------------------
     DO i = 1, LEN(Input_String)
 
       ! Convert the current character to its position
       ! in the ASCII collating sequence
       IACHAR_Character = IACHAR(Input_String(i:i))
 
       ! If the character is NOT a space ' ' or a tab '->|'
       ! copy it to the output string.
       IF ( IACHAR_Character /= IACHAR_SPACE .AND. &
            IACHAR_Character /= IACHAR_TAB         ) THEN
         j = j + 1
         Output_String(j:j) = Input_String(i:i)
       END IF
 
     END DO
 
     ! Save the non-whitespace count
     ! -----------------------------
     IF ( PRESENT(n) ) n = j
 
   END FUNCTION StrCompress
 !--------------------------------------------------------------------            
 end module usefulbits_HS                        
 !--------------------------------------------------------------------
\ No newline at end of file
Index: trunk/HiggsSignals/HiggsSignals_subroutines.F90
===================================================================
--- trunk/HiggsSignals/HiggsSignals_subroutines.F90	(revision 505)
+++ trunk/HiggsSignals/HiggsSignals_subroutines.F90	(revision 506)
@@ -1,1602 +1,1605 @@
 !------------------------------------------------------------
 ! This file is part of HiggsSignals (TS 03/03/2013).
 !------------------------------------------------------------
 subroutine initialize_HiggsSignals_latestresults(nHiggsneut,nHiggsplus)
 !------------------------------------------------------------
 ! Wrapper subroutine to intitialize HiggsSignals with the experimental
 ! dataset "latestresults", avoiding to specify this via a string argument.
 !------------------------------------------------------------
  implicit none
  !--------------------------------------input
  integer,intent(in) :: nHiggsneut
  integer,intent(in) :: nHiggsplus
  character(LEN=13) :: Expt_string
  
  Expt_string = "latestresults"
 
  call initialize_HiggsSignals(nHiggsneut,nHiggsplus,Expt_string)
  
 end subroutine initialize_HiggsSignals_latestresults
 !------------------------------------------------------------
 subroutine initialize_HiggsSignals(nHiggsneut,nHiggsplus,Expt_string)
 !------------------------------------------------------------
 ! This the first HiggsSignals subroutine that should be called
 ! by the user.
 ! It calls subroutines to read in the tables of Standard Model 
 ! decay and production rates from HiggsBounds, sets up the 
 ! experimental data from Tevatron and LHC, allocate arrays, etc.
 ! Arguments (input):
 !   * nHiggs = number of neutral Higgs in the model 
 !   * nHiggsplus = number of singly, positively charged Higgs in the model
 !   * Expt_string = name of experimental dataset to be used
 !------------------------------------------------------------
  use usefulbits, only : np,Hneut,Hplus,Chineut,Chiplus,debug,inputmethod,&
   &   inputsub,theo,whichanalyses,just_after_run,&
   &   file_id_debug1,file_id_debug2,allocate_if_stats_required
  use usefulbits_HS, only : HiggsSignals_info, nanalys, eps, Exptdir, obs
  use datatables, only: setup_observables
  use input, only : check_number_of_particles,check_whichanalyses
  use io, only : setup_input_for_hs, setup_output_for_hs
  use theory_BRfunctions, only : setup_BRSM, BRSM
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
  !--------------------------------------input
  integer,intent(in) :: nHiggsneut
  integer,intent(in) :: nHiggsplus
  character(LEN=*), intent(in) :: Expt_string
  !-----------------------------------internal
  integer :: i
  !----------------------------------parameter
  eps=5.0D0
  np(Hneut)=nHiggsneut
 
  np(Hplus)=nHiggsplus
  
  Exptdir = Expt_string
  
  np(Chineut)=0! not considering bounds on neutralinos here
  np(Chiplus)=0! not considering bounds on charginos here
         
  debug=.False.
 
  select case(whichanalyses)
   case('onlyL')
    whichanalyses='LandH'
   case('onlyH','onlyP','list ','LandH')
   case default
    whichanalyses='onlyH'
  end select 
 
  call HiggsSignals_info 
  if(inputmethod=='subrout') then 
   if(allocated(theo))then
    if(debug) write(*,*) "HiggsBounds/HiggsSignals internal structure already initialized!"
   else
    if(debug)write(*,*)'doing other preliminary tasks...'      ; call flush(6)
    call setup_input_for_hs
 
    allocate(inputsub( 2 )) !(1)np(Hneut)>0 (2)np(Hplus)>0
    inputsub(1)%desc='HiggsBounds_neutral_input_*'    ; inputsub(1)%req=req(   0,   1)
    inputsub(2)%desc='HiggsBounds_charged_input'      ; inputsub(2)%req=req(   1,   0)
  
    do i=1,ubound(inputsub,dim=1)
     inputsub(i)%stat=0
    enddo
   endif
  endif 
  
  if(debug)write(*,*)'reading in Standard Model tables...'   ; call flush(6) 
  if(.not.allocated(BRSM)) call setup_BRSM 
  call setup_uncertainties
              
  if(debug)write(*,*)'reading in experimental data...'       ; call flush(6)
  call setup_observables
 
  if(debug)write(*,*)'sorting out processes to be checked...'; call flush(6)
  nanalys = size(obs)
 
  if(debug)write(*,*)'preparing output arrays...'            ; call flush(6)
  call setup_output_for_hs
 
  if(debug)write(*,*)'HiggsSignals has been initialized...'  ; call flush(6)
 
  just_after_run=.False.
   
  contains 
    !         |   np
    !         |Hneu Hcha 
    !         | ==0  ==0 
  function req(Hneu,Hcha)
   integer, intent(in) ::Hneu,Hcha
   integer :: req
   
   req=1
   if(np(Hneut)==0)  req= Hneu  * req
   if(np(Hplus)==0)  req= Hcha  * req
 
  end function req 
 
 end subroutine initialize_HiggsSignals
 !------------------------------------------------------------
 subroutine HiggsSignals_neutral_input_MassUncertainty(dMh)
 ! Sets the theoretical mass uncertainty of the Higgs bosons.
 !------------------------------------------------------------
  use usefulbits, only: theo,np,Hneut
  
  implicit none
  double precision,intent(in) :: dMh(np(Hneut))
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsSignals_initialize must be called first'
  endif
  if(np(Hneut).eq.0)then
   write(*,*)'subroutine HiggsSignal_neutral_input_MassUncertainty should'
   write(*,*)'only be called if np(Hneut)>0'
   stop 'error in subroutine HiggsSignal_neutral_input_MassUncertainty'
  endif
  
  theo(1)%particle(Hneut)%dM = dMh
  
 end subroutine HiggsSignals_neutral_input_MassUncertainty
 !------------------------------------------------------------
 subroutine setup_uncertainties
 !------------------------------------------------------------
  use usefulbits, only : file_id_common3
  use store_pathname_hs, only : pathname_HS
  use usefulbits_hs, only : delta_rate
  use io, only : read_matrix_from_file
  
  logical :: BRmodel, BRSM, XSmodel, XSSM
 
  call read_matrix_from_file(9,pathname_HS//"BRcov.in",delta_rate%BRcov, BRmodel)
  call read_matrix_from_file(9,pathname_HS//"BRcovSM.in",delta_rate%BRcovSM, BRSM)
  call read_matrix_from_file(5,pathname_HS//"XScov.in",delta_rate%CScov, XSmodel)
  call read_matrix_from_file(5,pathname_HS//"XScovSM.in",delta_rate%CScovSM, XSSM)
 
  if(BRmodel.and.BRSM) then
   delta_rate%BRcov_ok=.True.
   write(*,*) "Covariance matrix for relative branching ratio uncertainties read in successfully."
  else
   write(*,*) "Covariance matrix for relative branching ratio uncertainties not provided. Using default values."
  endif
  if(XSmodel.and.XSSM) then
   delta_rate%CScov_ok=.True.
   write(*,*) "Covariance matrix for relative cross section uncertainties read in successfully."
  else
   write(*,*) "Covariance matrix for relative cross section uncertainties not provided. Using default values."
  endif
     
 end subroutine setup_uncertainties
 !------------------------------------------------------------
 subroutine setup_rate_uncertainties( dCS, dBR )
 !------------------------------------------------------------
 ! Sets (relative) systematic uncertainties of the model for:
 !  dCS(1) - singleH				dBR(1) - gamma gamma
 !  dCS(2) - VBF					dBR(2) - W W
 !  dCS(3) - HW					dBR(3) - Z Z
 !  dCS(4) - HZ					dBR(4) - tau tau
 !  dCS(5) - ttH					dBR(5) - b bbar
 !------------------------------------------------------------
  use usefulbits_hs, only : delta_rate
  implicit none
  
  double precision, intent(in) :: dCS(5)
  double precision, intent(in) :: dBR(5)
  integer :: i
    
  delta_rate%dCS = dCS
 
  do i=lbound(dBR,dim=1),ubound(dBR,dim=1) 
   call setup_dbr(i,dBR(i))
  enddo
  
 end subroutine setup_rate_uncertainties
 !------------------------------------------------------------
 subroutine setup_dbr(BRid, value)
 !------------------------------------------------------------
  use usefulbits_hs, only : delta_rate
 
  integer,intent(in) :: BRid
  double precision, intent(in) :: value
 
  if(BRid.gt.0.and.BRid.lt.10) then
   delta_rate%dBR(BRid) = value
  else
   write(*,*) "Warning in setup_dbr: Unknown decay mode."
  endif
    
 end subroutine setup_dbr
 !------------------------------------------------------------
 subroutine setup_correlations(corr_mu, corr_mh)
 !------------------------------------------------------------
 ! With this subroutine the user may switch off/on correlations
 ! (default=on) by setting corr = 0/1.
 !------------------------------------------------------------
  use usefulbits_hs, only : correlations_mu, correlations_mh
  implicit none
  
  integer, intent(in) :: corr_mu, corr_mh
  if(corr_mu.eq.0) then
   correlations_mu = .False.
   write(*,*) 'Correlations in signal strength observables are switched off.'
  elseif(corr_mu.eq.1) then
   correlations_mu = .True.
  else
   stop 'Error: Correlations must be switched on/off by an integer value of 0 or 1.' 
  endif
  if(corr_mh.eq.0) then
   correlations_mh = .False.
   write(*,*) 'Correlations in Higgs mass observables are switched off.'
  elseif(corr_mh.eq.1) then
   correlations_mh = .True.
  else
   stop 'Error: Correlations must be switched on/off by an integer value of 0 or 1.' 
  endif
 end subroutine setup_correlations
 !------------------------------------------------------------
 subroutine setup_symmetricerrors(symm)
 ! Sets the measured rate uncertainties to either a symmetrical average
 ! of the upper and lower cyan band widths (symm==1) or else uses the 
 ! original (asymmetrical) errors.
 !------------------------------------------------------------
  use usefulbits_hs, only : symmetricerrors
  implicit none
 
  integer, intent(in) :: symm
  if(symm.eq.1) then
   write(*,*) "Using averaged (symmetrical) experimental rate uncertainties."
   symmetricerrors = .True.
  else
   write(*,*) "Using original (asymmetrical) experimental rate uncertainties."
   symmetricerrors = .False.
  endif
   
 end subroutine setup_symmetricerrors
 !------------------------------------------------------------
 subroutine setup_absolute_errors(absol)
 ! Treats the measured rate uncertainties as either absolute
 ! uncertainties (1) or relative (0). By default, they are
 ! treated as relative uncertainties.
 !------------------------------------------------------------
  use usefulbits_hs, only : absolute_errors
  implicit none
 
  integer, intent(in) :: absol
  if(absol.eq.1) then
   write(*,*) "Using absolute experimental rate uncertainties."
   absolute_errors = .True.
  else
   write(*,*) "Using relative experimental rate uncertainties."
   absolute_errors = .False.
  endif
   
 end subroutine setup_absolute_errors
 !------------------------------------------------------------
 subroutine setup_correlated_rate_uncertainties(corr)
 !------------------------------------------------------------
 use usefulbits_hs, only : delta_rate
 integer, intent(in) :: corr
 
 if(corr.eq.0) then
  delta_rate%usecov = .False.
  write(*,*) "Deactivated correlated CS and BR uncertainties. Using approximated maximum error."
 elseif(corr.eq.1) then
  delta_rate%usecov = .True.
  write(*,*) "Activated correlated CS and BR uncertainties. Using them if covariance matrices are present."
 else
  write(*,*) "Warning in subroutine setup_correlated_rate_uncertainties: Argument ",corr," is not equal to 0 or 1."
 endif
 end subroutine setup_correlated_rate_uncertainties
 !------------------------------------------------------------
 subroutine setup_SMweights(useweight)
 ! If set to 1 (true), HiggsSignals assumes the same signal decomposition
 ! (weights) as in the SM for the given model. This will enter the determination
 ! of the theoretical rate uncertainty.
 !------------------------------------------------------------
  use usefulbits_hs, only : useSMweights
  implicit none
 
  integer, intent(in) :: useweight
  if(useweight.eq.1) then
   write(*,*) "Using SM weights for theoretical rate uncertainties of the model."
   useSMweights = .True.
  else
   write(*,*) "Using true model weights for theoretical rate uncertainties of the model."
   useSMweights = .False.
  endif
   
 end subroutine setup_SMweights
 !------------------------------------------------------------
 subroutine setup_anticorrelations_in_mu(acorr)
 ! Allows for anti-correlations in the signal strength covariance
 ! matrix if there is a relative sign difference in two mu measurements
 ! (acorr==1) or else uses only correlations irrespective of the relative
 ! (acorr==0).
 !------------------------------------------------------------
  use usefulbits_hs, only : anticorrmu
  implicit none
 
  integer, intent(in) :: acorr
  if(acorr.eq.1) then
   write(*,*) "Allow anti-correlated signal strength measurements."
   anticorrmu = .True.
  else
   write(*,*) "Prohibit anti-correlated signal strength measurements."
   anticorrmu = .False.
  endif
   
 end subroutine setup_anticorrelations_in_mu
 !------------------------------------------------------------
 subroutine setup_anticorrelations_in_mh(acorr)
 ! Allows for anti-correlations in the mass covariance
 ! matrix if there is a relative sign difference in two mu measurements
 ! (acorr==1) or else uses only correlations irrespective of the relative
 ! (acorr==0).
 !------------------------------------------------------------
  use usefulbits_hs, only : anticorrmh
  implicit none
 
  integer, intent(in) :: acorr
  if(acorr.eq.1) then
   write(*,*) "Allow anti-correlated mass measurements."
   anticorrmh = .True.
  else
   write(*,*) "Prohibit anti-correlated mass measurements."
   anticorrmh = .False.
  endif
   
 end subroutine setup_anticorrelations_in_mh
 !------------------------------------------------------------
 subroutine setup_assignmentrange(range)
 !------------------------------------------------------------
 ! This sets up the mass range (in standard deviations) in which
 ! the Higgs is forced to be assigned to the peak observables.
 !------------------------------------------------------------
  use usefulbits_hs, only : assignmentrange,assignmentrange_massobs, pdf
  implicit none
  
  double precision, intent(in) :: range
  
  if(range.le.0.0D0) then
   write(*,*) "Error: Bad assignment range ",range
   write(*,*) "Keeping the value ",assignmentrange  
  else
   assignmentrange = range
   assignmentrange_massobs = range
  endif 
 
  if(assignmentrange.ne.1.0D0.and.pdf.eq.1) then
   write(*,*) "Note: For a box pdf, only 1s mass range is used to force the Higgs-to-peak assignment."
  endif
  
 end subroutine setup_assignmentrange
 !------------------------------------------------------------
 subroutine setup_assignmentrange_massobservables(range)
 !------------------------------------------------------------
 ! This sets up the mass range (in standard deviations) in which
 ! the Higgs is forced to be assigned to the peak observables.
 !------------------------------------------------------------
  use usefulbits_hs, only : assignmentrange_massobs, pdf
  implicit none
  
  double precision, intent(in) :: range
  
  if(range.le.0.0D0) then
   write(*,*) "Error: Bad assignment range ",range
   write(*,*) "Keeping the value ",assignmentrange_massobs
  else
   assignmentrange_massobs = range
  endif 
 
  if(assignmentrange_massobs.ne.1.0D0.and.pdf.eq.1) then
   write(*,*) "Note: For a box pdf, only 1s mass range is used to force the Higgs-to-peak assignment."
  endif
  
 end subroutine setup_assignmentrange_massobservables
 !------------------------------------------------------------
 subroutine setup_nparam(Np)
 !------------------------------------------------------------
  use usefulbits_hs, only : Nparam
  implicit none 
  integer, intent(in) :: Np
  Nparam = Np
 end subroutine setup_nparam
 !------------------------------------------------------------
 subroutine setup_Higgs_to_peaks_assignment_iterations(iter)
 ! Sets the number of iterations for the Higgs-to-peak-assignment.
 !------------------------------------------------------------
  use usefulbits_hs, only : iterations
  implicit none
  integer, intent(in) :: iter 
  iterations = iter 
  
 end subroutine setup_Higgs_to_peaks_assignment_iterations
 !------------------------------------------------------------
 subroutine setup_mcmethod_dm_theory(mode)
  use mc_chisq, only : mc_mode
  implicit none
  integer, intent(in) :: mode
  character(LEN=14) :: mode_desc(2) = (/'mass variation','convolution   '/)
 
  if(mode.eq.1.or.mode.eq.2) then
   mc_mode = mode
   write(*,'(1X,A,A)') 'The mass-centered chi^2 method will treat the Higgs',&
 & ' boson mass theory uncertainty by '//trim(mode_desc(mode))//'.'
  else
   stop 'Error in subroutine setup_mcmethod_dm_theory: Unknown mode (1 or 2 possible)!'
  endif 
 end subroutine setup_mcmethod_dm_theory
 !------------------------------------------------------------
 subroutine setup_sm_test(int_SMtest,epsilon)
 ! With this subroutine the user may switch off the SM likeness test
 ! (default=on) or change the maximal deviation epsilon (default=5.0D-2)
 !------------------------------------------------------------
  use usefulbits_hs, only : useSMtest, eps
  implicit none
  
  integer, intent(in) :: int_SMtest
  double precision, intent(in) :: epsilon
  
  if(int_SMtest.eq.0) then
   useSMtest = .False.
   write(*,*) 'SM likeness test has been switched off.'
  elseif(int_SMtest.eq.1) then
   useSMtest = .True.
   write(*,*) 'SM likeness test has been switched on.'  
  else
   stop 'Error: SM test must be switched on/off by an integer value of 0 or 1.' 
  endif
  eps = epsilon
 end subroutine setup_sm_test
 !------------------------------------------------------------
 subroutine setup_thu_observables(thuobs)
  use usefulbits_hs, only : THU_included
  integer, intent(in) :: thuobs
 
  if(thuobs.eq.0) then
   THU_included = .False.
   write(*,*) 'Observables are assumed to NOT include theory errors.'
  else
   THU_included = .True.
   write(*,*) 'Observables are assumed to include theory errors.'  
  endif
   
 end subroutine setup_thu_observables
 !------------------------------------------------------------
 subroutine setup_output_level(level)
 ! Controls the level of information output:
 ! 0 : silent mode
 ! 1 : screen output for each analysis with its peak/mass-centered observables and
 !     their respective values predicted by the model
 ! 2 : screen output of detailed information on each analysis with its 
 !     peak/mass-centered observables
 ! 3 : creates the files peak_information.txt and peak_massesandrates.txt
 !------------------------------------------------------------
  use usefulbits_hs, only : output_level, additional_output
  implicit none
  integer, intent(in) :: level
 
  if(level.eq.0.or.level.eq.1.or.level.eq.2.or.level.eq.3) then
   output_level = level
  else
   stop 'Error in subroutine setup_output_level: level not equal to 0,1,2 or 3.' 
  endif
  if(level.eq.3) additional_output = .True.
  
 end subroutine setup_output_level 
 !------------------------------------------------------------
 subroutine setup_pdf(pdf_in)
 ! Sets the probability density function for the Higgs mass uncertainty parametrization:
 ! 1 : box-shaped pdf
 ! 2 : Gaussian pdf
 ! 3 : box-shaped theory error + Gaussian experimental pdf
 !------------------------------------------------------------
  use usefulbits_hs, only : pdf, assignmentrange
 
  implicit none
  integer, intent(in) :: pdf_in
  character(LEN=13) :: pdf_desc(3) = (/'box         ','Gaussian    ','box+Gaussian'/)
  
  pdf=pdf_in
  if((pdf.eq.1).or.(pdf.eq.2).or.(pdf.eq.3)) then
   write(*,'(1X,A,A,1I1,A)') 'Use a '//trim(pdf_desc(pdf))//' probability density function ',&
 &  'for the Higgs mass(es) (pdf=',pdf,')'
  endif
    
  if(assignmentrange.ne.1.0D0.and.pdf.eq.1) then
   write(*,*) "Note: For a box pdf, only 1s mass range is used to force the Higgs-to-peak assignment."
  endif
    
 end subroutine setup_pdf
 !------------------------------------------------------------
 !subroutine assign_toyvalues_to_observables(ii, peakindex, npeaks, mu_obs, mh_obs)
 !! Assigns toy values to the peak's mass and mu value for analysis ii.
 !! ii           :: analysis number (entry in mutables)
 !! peakindex    :: index of the peak of analysis ii
 !! npeaks 	   :: number of peaks found in analysis ii
 !! mu_obs       :: toy value for mu to be given to the peak with peakindex
 !! mh_obs       :: toy value for mh to be given to the peak with peakindex
 !------------------------------------------------------------
 ! use usefulbits_hs, only: obs, usetoys
 ! 
 ! integer, intent(in) :: ii, peakindex, npeaks
 ! double precision, intent(in) :: mh_obs, mu_obs
 !  
 ! if(peakindex.gt.npeaks) then
 !  stop 'Error in subroutine assign_toyvalues_to_observables: Observable does not exist!'
 ! endif
 !   
 ! obs(ii)%table%npeaks = npeaks
 ! if(.not.allocated(obs(ii)%table%Toys_muobs)) allocate(obs(ii)%table%Toys_muobs(npeaks))
 ! if(.not.allocated(obs(ii)%table%Toys_mhobs)) allocate(obs(ii)%table%Toys_mhobs(npeaks)) 
 !
 ! obs(ii)%table%Toys_muobs(peakindex) = mu_obs
 ! obs(ii)%table%Toys_mhobs(peakindex) = mh_obs
 ! 
 ! usetoys = .True.
 ! 
 !end subroutine assign_toyvalues_to_observables
 !------------------------------------------------------------
 subroutine assign_toyvalues_to_peak(ID, mu_obs, mh_obs)
 ! Assigns toy values to the peak's mass and mu value to a peak observable.
 ! ID           :: observable ID
 ! mu_obs       :: toy value for mu to be given to the peak
 ! mh_obs       :: toy value for mh to be given to the peak
 !
 ! n.B.: Do we also want to set mu uncertainties here?
 !------------------------------------------------------------
  use usefulbits_hs, only: obs, usetoys
  implicit none
 
  integer, intent(in) :: ID
  double precision, intent(in) :: mh_obs, mu_obs
  integer :: pos, ii
  
  pos = -1
  do ii=lbound(obs,dim=1),ubound(obs,dim=1)
   if(obs(ii)%id.eq.ID) then
    pos = ii
    exit   	
   endif
  enddo
   
  if(pos.ne.-1) then    
   obs(pos)%peak%mpeak = mh_obs
   obs(pos)%peak%mu = mu_obs
   usetoys = .True.
  else
   write(*,*) "WARNING in assign_toyvalues_to_peak: ID unknown."
  endif
   
 end subroutine assign_toyvalues_to_peak
 !------------------------------------------------------------
 subroutine assign_modelefficiencies_to_peak(ID, Nc, eff_ratios)
 ! Assigns to each channel of the observable the efficiency in the model 
 ! w.r.t the SM efficiency (as a ratio!)
 ! 
 ! ID           :: observable ID
 ! Nc			:: number of channels
 ! eff_ratios    :: array of length (Number of channels) giving the efficiency ratios
 !
 ! Note: You can first employ the subroutine get_peak_channels (io module) to obtain
 !       the relevant channel information of the observable.
 !------------------------------------------------------------
  use usefulbits_hs, only: obs
  implicit none
 
  integer, intent(in) :: ID, Nc
  double precision, dimension(Nc), intent(in) :: eff_ratios
  integer :: pos, ii
  
  pos = -1
  do ii=lbound(obs,dim=1),ubound(obs,dim=1)
   if(obs(ii)%id.eq.ID) then
    pos = ii
    exit   	
   endif
  enddo
   
  if(pos.ne.-1) then    
   if(size(eff_ratios,dim=1).ne.obs(pos)%table%Nc) then
    write(*,*) "WARNING in assign modelefficiencies_to_peak: Number of channels (",&
 &  size(eff_ratios,dim=1),"!=",obs(pos)%table%Nc,"does not match for observable ID = ",ID
   else
    obs(pos)%table%channel_eff_ratios = eff_ratios
   endif 
  else
   write(*,*) "WARNING in assign_modelefficiencies_to_peak: ID unknown."
  endif
   
 end subroutine assign_modelefficiencies_to_peak
 !------------------------------------------------------------
 subroutine assign_rate_uncertainty_scalefactor_to_peak(ID, scale_mu)
 ! Assigns a rate uncertainty scalefactor to the peak specified by ID.
 ! This scalefactor will only scale the experimental rate uncertainties.
 ! The theory rate uncertainties must be given manually via setup_rate_uncertainties.
 !
 ! ID       :: observable ID of the peak observable
 ! scale_mu :: scale_mu by which the mu uncertainty is scaled
 !------------------------------------------------------------
  use usefulbits_hs, only: obs, usescalefactor
  implicit none
  
  integer, intent(in) :: ID
  double precision, intent(in) :: scale_mu
  integer :: pos, ii
  
  pos = -1
  do ii=lbound(obs,dim=1),ubound(obs,dim=1)
   if(obs(ii)%id.eq.ID) then
    pos = ii
    exit   	
   endif
  enddo
   
  if(pos.ne.-1) then
   obs(pos)%peak%scale_mu = scale_mu
  else
   write(*,*) "WARNING in assign_uncertainty_scalefactors_to_peak: ID unknown."
  endif
  usescalefactor = .True.
  
 end subroutine assign_rate_uncertainty_scalefactor_to_peak
 !------------------------------------------------------------
 subroutine run_HiggsSignals(mode, Chisq_mu, Chisq_mh, Chisq, nobs, Pvalue)
 !------------------------------------------------------------
 ! This subroutine can be called by the user after HiggsSignals_initialize has been called.
 ! The input routines, where required, should be called before calling run_HiggsSignals.
 ! It takes theoretical predictions for a particular parameter point 
 ! in the model and calls subroutines which compare these predictions 
 ! to the experimental results.
 ! Arguments (output):
 !   * mode = 1,2 or 3 for peak-centered, mass-centered chi^2 method or both, respectively. 
 !   * Chisq_mu = total chi^2 contribution from signal strength measurements
 !   * Chisq_mh = total chi^2 contribution from Higgs mass measurements
 !   * Chisq = total chi^2 value for the combination of the considered Higgs signals
 !   * nobs = total number of observables
 !   * Pvalue = total chi^2 probability for the agreement between model and data,
 !              assuming number of observables == number of degrees of freedom
 !    (see manual for more precise definitions))
 !------------------------------------------------------------
  use usefulbits, only : theo,inputsub,just_after_run, inputmethod, ndat
  use usefulbits_HS, only : HSres, runmode, output_level, usescalefactor, Nparam
  use channels, only : check_channels
  use theo_manip, only : complete_theo, recalculate_theo_for_datapoint
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none               
  integer,intent(in) :: mode 
  !----------------------------------------output
  integer,intent(out) ::           nobs
  double precision,intent(out) ::  Pvalue, Chisq, Chisq_mu, Chisq_mh
  !-------------------------------------internal
  integer :: n,i
  logical :: debug=.False.
  !---------------------------------------------
  
 if(mode.eq.1) then
  runmode="peak"
 else if(mode.eq.2) then
  runmode="mass"
 else if(mode.eq.3) then
- runmode="both"
+! runmode="both"
+ write(*,*) "Warning: The 'both' method (runmode = 3) is currently under development."
+ write(*,*) "         The peak-centered chi^2 method will be used instead."
+ runmode="peak"
 else 
  stop'Error in subroutine run_HiggsSignals: mode unknown'
 endif
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsSignals_initialize must be called first'
  endif
  if(inputmethod.eq.'subrout') then
   do i=1,ubound(inputsub,dim=1)
    if(  inputsub(i)%req .ne. inputsub(i)%stat  )then
 !    write(*,*) inputsub(i)%req, inputsub(i)%stat
 !    write(*,*)'subroutine '//trim(adjustl(inputsub(i)%desc))
 !    write(*,*)'should be called once and only once before each call to'
 !    write(*,*)'subroutine run_HiggsSignals.'
 !    stop'error in subroutine run_HiggsSignals'
    endif
 ! TS: Have to work on this bit to make it run simultaneously with HiggsBounds. Now,
 !     commented out the =0 statement. HS thus has to be run before HB.   
   inputsub(i)%stat=0!now we have used this input, set back to zero   
   enddo
  endif 
 
  if(debug)write(*,*)'manipulating input...'                 ; call flush(6)
 
  call complete_theo       
 
  if(debug)write(*,*)'compare each model to the experimental data...' ; call flush(6)                  
 
  do n=1,ndat
 
 !  call recalculate_theo_for_datapoint(n)
 
   call evaluate_model(theo(n),HSres(n))       
       
   Pvalue  = HSres(n)%Pvalue
   Chisq   = HSres(n)%Chisq       
   Chisq_mu   = HSres(n)%Chisq_mu       
   Chisq_mh   = HSres(n)%Chisq_mh         
   nobs = HSres(n)%nobs
 
  if(output_level.ne.0) then    
   write(*,*)
   write(*,*) '#*************************************************************************#' 
   write(*,*) '#                         HIGGSSIGNALS RESULTS                            #'
   write(*,*) '#*************************************************************************#' 
   write(*,'(A55,F21.8)') 'chi^2 from signal strength peak observables = ',&
  &  HSres(n)%Chisq_peak_mu
   write(*,'(A55,F21.8)') 'chi^2 from Higgs mass peak observables = ',HSres(n)%Chisq_mh
   write(*,'(A55,F21.8)') 'chi^2 from mass-centered observables = ',HSres(n)%Chisq_mpred
   write(*,'(A55,F21.8)') 'chi^2 from signal strength (total) = ',HSres(n)%Chisq_mu
   write(*,'(A55,F21.8)') 'chi^2 (total) = ',HSres(n)%Chisq
   write(*,'(A55,I21)') 'Number of signal strength peak observables = ',&
  &  HSres(n)%nobs_peak_mu
   write(*,'(A55,I21)') 'Number of Higgs mass peak observables = ',HSres(n)%nobs_peak_mh
   write(*,'(A55,I21)') 'Number of mass-centered observables = ',HSres(n)%nobs_mpred
   write(*,'(A55,I21)') 'Number of observables (total) = ',HSres(n)%nobs
   write(*,'(A48,I3,A4,F21.8)') 'Probability (ndf =',HSres(n)%nobs-Nparam,') = ',HSres(n)%Pvalue
   write(*,*) '#*************************************************************************#' 
   write(*,*)
  endif
 
  enddo
 
  just_after_run=.True.
  usescalefactor=.False.
  
 
 end subroutine run_HiggsSignals
 !------------------------------------------------------------
 subroutine evaluate_model( t , r )
 !------------------------------------------------------------
 ! This subroutine evaluates the signal strength modifier for every Higgs boson and
 ! considered analysis. It fills a matrix neutHiggs(:,:) of type neutHiggs with dimensions
 ! (number(considered analyses),nH).
 !------------------------------------------------------------
  use usefulbits, only : np,Hneut,Hplus,dataset,results, vsmall
  use usefulbits_hs, only : neutHiggses, nanalys, runmode, HSresults, cov, obs, analyses,&
  &						   cov_mhneut, iterations, deallocate_covariance_matrices, &
  &						   output_level, Nparam, nanalys
  use datatables, only : setup_tablelist, check_available_Higgses
  use pc_chisq
  use mc_chisq
  use all_chisq
  use numerics
  implicit none
  !--------------------------------------input      
  type(dataset), intent(in) :: t      
  !-------------------------------------output
  type(HSresults), intent(out) :: r
 
  integer :: ii, jj, iii, jjj
  
  double precision :: totchisq, muchisq, mhchisq, mpchisq, mpredchisq
  integer :: nobs, Nmu, Nmh, Nmpred
  character(LEN=100), allocatable :: assignmentgroups(:)
  integer, allocatable :: assignmentgroups_domH(:)
  integer, allocatable :: assignmentgroups_Higgs_comb(:,:)
 
  allocate(assignmentgroups(nanalys),assignmentgroups_domH(nanalys))
  allocate(assignmentgroups_Higgs_comb(nanalys,np(Hneut))) 
 
 !---Initialize assignmentgroups arrays with default values
 do ii=lbound(assignmentgroups_domH,dim=1),ubound(assignmentgroups_domH,dim=1)
  assignmentgroups_domH(ii) = 0
  assignmentgroups_Higgs_comb(ii,:) = 0
 enddo    
   
 !---First, evaluate the model predictions  
  allocate(neutHiggses(nanalys,np(Hneut)))
 !-Loop over considered analyses  
  do ii=lbound(neutHiggses,dim=1),ubound(neutHiggses,dim=1)
 !-Loop over the neutral Higgs bosons of the model 
   do jj=lbound(neutHiggses,dim=2),ubound(neutHiggses,dim=2)
 !!   write(*,*) "hello evaluate model:", ii, jj
    call calc_mupred(jj, t, obs(ii)%table, neutHiggses(ii,jj))
   enddo
   if(.not.allocated(obs(ii)%Higgses)) allocate(obs(ii)%Higgses(np(Hneut)))
   obs(ii)%Higgses(:) = neutHiggses(ii,:)  
  enddo
 
 !-Pass the observables and their predicted Higgs properties (obs%Higgses)
 !-to the tablelist "analyses"
  call setup_tablelist
 
  select case(runmode)
  
  case('peak')
 !-Peak-centered chisq method 
   jjj=0
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    call deallocate_covariance_matrices
    call assign_Higgs_to_peaks(analyses(ii)%table, analyses(ii)%peaks,0)
    do iii=lbound(analyses(ii)%peaks,dim=1),ubound(analyses(ii)%peaks,dim=1)  
     if(analyses(ii)%table%mhchisq.eq.1.and.&
 &      len(trim(adjustl(analyses(ii)%peaks(iii)%assignmentgroup))).ne.0) then
      jjj=jjj+1
      assignmentgroups(jjj)=analyses(ii)%peaks(iii)%assignmentgroup
      assignmentgroups_Higgs_comb(jjj,:)=analyses(ii)%peaks(iii)%Higgs_comb
      assignmentgroups_domH(jjj)=analyses(ii)%peaks(iii)%domH     
 !!     write(*,*) "Found leader of group ",assignmentgroups(jjj)
 !!     write(*,*) "ID ",analyses(ii)%peaks(iii)%id
 !!     write(*,*) "with Higgs combination ",assignmentgroups_Higgs_comb(jjj,:)  
 !!     write(*,*) "and dominant Higgs boson ",assignmentgroups_domH(jjj)          
     endif   
    enddo 
   enddo
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    do iii=lbound(analyses(ii)%peaks,dim=1),ubound(analyses(ii)%peaks,dim=1)  
     if(analyses(ii)%table%mhchisq.eq.0.and.&
 &     len(trim(adjustl(analyses(ii)%peaks(iii)%assignmentgroup))).ne.0) then
       !SELECT ASSIGNMENT GROUP FOLLOWERS
       do jjj=lbound(assignmentgroups,dim=1),ubound(assignmentgroups,dim=1)
        if(analyses(ii)%peaks(iii)%assignmentgroup.eq.assignmentgroups(jjj)) then
         !TAKE OVER THE HIGGS ASSIGNMENT OF THE LEADING PEAK
         analyses(ii)%peaks(iii)%Higgs_comb=assignmentgroups_Higgs_comb(jjj,:)
         analyses(ii)%peaks(iii)%domH=assignmentgroups_domH(jjj)
         if(assignmentgroups_domH(jjj).ne.0) then
          analyses(ii)%peaks(iii)%Higgs_assignment_forced=1
         endif 
         call evaluate_peak(analyses(ii)%peaks(iii),analyses(ii)%table)
        endif
       enddo
     endif
    enddo
   enddo     
 
 ! Do the iterative Higgs-to-peak-assignment here:
   call assign_Higgs_to_peaks_with_correlations(iterations)
   call calculate_total_pc_chisq(totchisq, muchisq, mhchisq, nobs, Nmu, Nmh)
 
   if(output_level.eq.1) call print_peakinformation
   if(output_level.eq.2) call print_peakinformation_essentials
   if(output_level.eq.3) then
    call print_peaks_to_file
    call print_peaks_signal_rates_to_file
   endif 
 
   call add_peaks_to_HSresults(r)
     
   r%Chisq=totchisq
   r%Chisq_peak_mu = muchisq
   r%Chisq_mpred = 0.0D0
   r%Chisq_mu=muchisq
   r%Chisq_mh=mhchisq  
   r%nobs_mpred=0
   r%nobs_peak_mu=Nmu
   r%nobs_peak_mh=Nmh
   r%nanalysis=size(analyses)
   r%nobs=nobs
   if(r%Chisq.gt.vsmall.and.(r%nobs-Nparam).gt.0) then
    r%Pvalue=1 - gammp(dble(r%nobs-Nparam)/2,r%Chisq/2)
   endif
   
  case('mass')  
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    call fill_mp_obs(ii)
   enddo
   if(mc_mode.eq.1) call mass_variation_by_theory_uncertainty
   call create_covariance_matrix_mp
   call calculate_mpred_chisq(mpchisq, nobs)
 
   if(output_level.eq.1) call print_mc_observables
   if(output_level.eq.2) call print_mc_observables_essentials
   if(output_level.eq.3) then
    call print_mc_tables_to_file
    call print_mc_observables_to_file   
   endif
   
   r%Chisq=mpchisq
   r%Chisq_peak_mu = 0.0D0
   r%Chisq_mpred = mpchisq 
   r%Chisq_mu=mpchisq
   r%Chisq_mh=0.0D0
   r%nobs_mpred=nobs
   r%nobs_peak_mu=0
   r%nobs_peak_mh=0
   r%nanalysis=size(analyses)  
   r%nobs=nobs    
   if(r%Chisq.gt.vsmall.and.(r%nobs-Nparam).gt.0) then
    r%Pvalue=1 - gammp(dble(r%nobs-Nparam)/2,r%Chisq/2)
   endif
 
  case('both')
  jjj=0
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    call deallocate_covariance_matrices
    call assign_Higgs_to_peaks(analyses(ii)%table, analyses(ii)%peaks,0)
    do iii=lbound(analyses(ii)%peaks,dim=1),ubound(analyses(ii)%peaks,dim=1)  
     if(analyses(ii)%table%mhchisq.eq.1.and.&
 &      len(trim(analyses(ii)%peaks(iii)%assignmentgroup)).ne.0) then
      jjj=jjj+1
      assignmentgroups(jjj)=analyses(ii)%peaks(iii)%assignmentgroup
      assignmentgroups_Higgs_comb(jjj,:)=analyses(ii)%peaks(iii)%Higgs_comb
      assignmentgroups_domH(jjj)=analyses(ii)%peaks(iii)%domH     
     endif   
    enddo    
   enddo
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    do iii=lbound(analyses(ii)%peaks,dim=1),ubound(analyses(ii)%peaks,dim=1)  
     if(analyses(ii)%table%mhchisq.eq.0.and.&
 &     len(trim(analyses(ii)%peaks(iii)%assignmentgroup)).ne.0) then
       do jjj=lbound(assignmentgroups,dim=1),ubound(assignmentgroups,dim=1)
        if(analyses(ii)%peaks(iii)%assignmentgroup.eq.assignmentgroups(jjj)) then
         !TAKE OVER THE HIGGS ASSIGNMENT OF THE LEADING PEAK
         analyses(ii)%peaks(iii)%Higgs_comb=assignmentgroups_Higgs_comb(jjj,:)
         analyses(ii)%peaks(iii)%domH=assignmentgroups_domH(jjj)
         if(assignmentgroups_domH(jjj).ne.0) then
          analyses(ii)%peaks(iii)%Higgs_assignment_forced=1
         endif 
         ! TODO: Need to evaluate everything else here!
         call evaluate_peak(analyses(ii)%peaks(iii),analyses(ii)%table)
        endif
       enddo
     endif
    enddo
   enddo     
   
   call assign_Higgs_to_peaks_with_correlations(iterations) 
   
   do ii=lbound(analyses,dim=1),ubound(analyses,dim=1)
    call check_available_Higgses(ii)
    call fill_mp_obs(ii)
   enddo  
   if(mc_mode.eq.1) call mass_variation_by_theory_uncertainty
  
   call calculate_total_chisq(totchisq, muchisq, mhchisq, mpredchisq, nobs, Nmu, Nmh, Nmpred)
  
  !Have to write a new print method
   if(output_level.eq.1)  call print_all_observables
   if(output_level.eq.2) call print_peakinformation_essentials
   if(output_level.eq.3) then
    call print_peaks_to_file
    call print_peaks_signal_rates_to_file
   endif 
 
   call add_peaks_to_HSresults(r)
  
   r%Chisq=totchisq
   r%Chisq_peak_mu = muchisq
   r%Chisq_mpred = mpredchisq 
   r%Chisq_mu=muchisq + mpredchisq
   r%Chisq_mh=mhchisq  
   r%nobs_mpred=Nmpred
   r%nobs_peak_mu=Nmu
   r%nobs_peak_mh=Nmh
   r%nanalysis=size(analyses)
   r%nobs=nobs
   if(r%Chisq.gt.vsmall.and.(r%nobs-Nparam).gt.0) then
    r%Pvalue=1 - gammp(dble(r%nobs-Nparam)/2,r%Chisq/2)
   endif
   
  case default
   stop "Error in subroutine evaluate_model: Please specify runmode!"
   
  end select
 
  deallocate(neutHiggses)
  deallocate(assignmentgroups, assignmentgroups_domH, assignmentgroups_Higgs_comb)   
 end subroutine evaluate_model
 !------------------------------------------------------------
 subroutine calc_mupred( j, t, mutab, Higgs )
 ! Calculates the model-predicted signal strength modifier
 !------------------------------------------------------------
  use usefulbits, only : dataset, div, vsmall
  use usefulbits_HS, only : neutHiggs, mutable, useSMtest, eps
  implicit none
  
  integer, intent(in) :: j					! Higgs index
  type(dataset), intent(in) :: t
  type(mutable), intent(inout) :: mutab
  type(neutHiggs), intent(inout) :: Higgs
 
  integer :: i
  double precision :: c, dcbyc
  integer :: testSMratios 
  logical :: correct_properties
 
  Higgs%m = t%particle(mutab%particle_x)%M(j)
  Higgs%dm = t%particle(mutab%particle_x)%dM(j)
  Higgs%id = j
   
  call get_channelrates( j, t, mutab )
 
  correct_properties=.True.
 
 !--Evaluate the predicted signal strength modifier c of the model
  c=0. 
  do i=1,mutab%Nc
 !----use a weighted average of the channel rate ratios     
   c=c+mutab%channel_w(i,j)*mutab%channel_mu(i,j)
  enddo
 
 !--Evaluate the deviation of each channel rate ratio to the signal
 !--strength modifier c and test SM likeness criterium, if this is
 !--activated.
  testSMratios= 1  !passes the SM-like ratios test 
  do i=1,mutab%Nc
   dcbyc=div((mutab%channel_mu(i,j)-c),c,0.0D0,1.0D9)
   if(dcbyc*mutab%channel_w(i,j).gt.eps.and.useSMtest) then
    testSMratios= -1  !fails the SM-like ratios test
   endif     
  enddo
 
  if(testSMratios.lt.0) correct_properties=.False.
   
  if(correct_properties) then
   Higgs%mu=c
  else
   Higgs%mu=0.0D0
  endif
   
 end subroutine calc_mupred
 !------------------------------------------------------------
 subroutine get_channelrates( j, t, mutab )
 ! This subroutine assignes the rates, weights and systematic rate uncertainty of
 ! the Higgs boson (j) for the channels considered by the analysis (mutab).
 !
 ! WARNING: if normalize_rates_to_reference_position is true -> Still in TESTING PHASE!
 ! The rates are normalized w.r.t. a reference rate at the (peak) mass position.
 ! This does not work with the mass-centered chi^2 method.
 ! Also, theoretical mass uncertainties are problematic!
 !------------------------------------------------------------
  use usefulbits, only : dataset, div, small
  use usefulbits_HS, only : neutHiggs, mutable, delta_rate, normalize_rates_to_reference_position
  use theory_XS_SM_functions
  use theory_BRfunctions
  
  integer, intent(in) :: j
  type(dataset), intent(in) :: t
  type(mutable), intent(inout) :: mutab
 
 
  integer :: i, id, p, d
  integer :: ii, id1, id2, p1, p2, d1, d2
  double precision :: rate, SMrate, modelrate, drsq_SM, drsq, dBR, dBRSM
  
 !!NEW:
  double precision :: rate_SMref,refmass
 
  if(size(mutab%mass,dim=1).eq.1) then
   refmass = mutab%mass(1)
  else
 !  write(*,*) "mutab%id", mutab%id, "Mass measurements: ",size(mutab%mass,dim=1)
 !  write(*,*) "mutab%particle_x = ", mutab%particle_x, " j= ", j
   refmass = t%particle(mutab%particle_x)%M(j)
  endif
 
 !write(*,*) 'DEBUG HS: id = ', mutab%id
 !write(*,*) 'DEBUG HS, m = ', t%particle(mutab%particle_x)%M(j)
 
  do i=1,mutab%Nc
   id = mutab%channel_id(i)
   p = int((id-modulo(id,10))/dble(10))
   d = modulo(id,10)
 
 !--Do the production rate for the relevant experiment and cms-energy 
   if(mutab%collider.eq.'LHC') then
    if(abs(mutab%energy-7.0D0).le.small) then
     if(p.eq.1) then 
      rate=t%lhc7%XS_hj_ratio(j)
      SMrate=t%lhc7%XS_H_SM(j)
      rate_SMref=XS_lhc7_gg_H_SM(refmass)
      mutab%channel_description(i,1)='singleH'
     else if(p.eq.2) then
      rate=t%lhc7%XS_vbf_ratio(j)
      SMrate=t%lhc7%XS_vbf_SM(j)
      rate_SMref=XS_lhc7_vbf_SM(refmass)
      mutab%channel_description(i,1)='VBF'     
     else if(p.eq.3) then
      rate=t%lhc7%XS_hjW_ratio(j)
      SMrate=t%lhc7%XS_HW_SM(j) 
      rate_SMref=XS_lhc7_HW_SM(refmass)
      mutab%channel_description(i,1)='HW'     
     else if(p.eq.4) then
      rate=t%lhc7%XS_hjZ_ratio(j)  
      SMrate=t%lhc7%XS_HZ_SM(j)
      rate_SMref=XS_lhc7_HZ_SM(refmass)
      mutab%channel_description(i,1)='HZ'       
     else if(p.eq.5) then
      rate=t%lhc7%XS_tthj_ratio(j)
      SMrate=t%lhc7%XS_ttH_SM(j)
      rate_SMref=XS_lhc7_ttH_SM(refmass)
      mutab%channel_description(i,1)='ttH'     
     else if(p.eq.0) then
      rate=1.0D0
      SMrate=1.0D0
      rate_SMref=1.0D0
      mutab%channel_description(i,1)='none'
     endif 
    else if(abs(mutab%energy-8.0D0).le.small) then
     if(p.eq.1) then 
      rate=t%lhc8%XS_hj_ratio(j)
      SMrate=t%lhc8%XS_H_SM(j)
      rate_SMref=XS_lhc8_gg_H_SM(refmass)     
      mutab%channel_description(i,1)='singleH'
     else if(p.eq.2) then
      rate=t%lhc8%XS_vbf_ratio(j)
      SMrate=t%lhc8%XS_vbf_SM(j)
      rate_SMref=XS_lhc8_vbf_SM(refmass)     
      mutab%channel_description(i,1)='VBF'     
     else if(p.eq.3) then
      rate=t%lhc8%XS_hjW_ratio(j)
      SMrate=t%lhc8%XS_HW_SM(j) 
      rate_SMref=XS_lhc8_HW_SM(refmass)     
      mutab%channel_description(i,1)='HW'     
     else if(p.eq.4) then
      rate=t%lhc8%XS_hjZ_ratio(j)  
      SMrate=t%lhc8%XS_HZ_SM(j)
      rate_SMref=XS_lhc8_HZ_SM(refmass)     
      mutab%channel_description(i,1)='HZ'       
     else if(p.eq.5) then
      rate=t%lhc8%XS_tthj_ratio(j)
      SMrate=t%lhc8%XS_ttH_SM(j)
      rate_SMref=XS_lhc8_ttH_SM(refmass)     
      mutab%channel_description(i,1)='ttH' 
     else if(p.eq.0) then
      rate=1.0D0
      SMrate=1.0D0
      rate_SMref=1.0D0     
      mutab%channel_description(i,1)='none'         
     endif  
    endif 
   else if(mutab%collider.eq.'TEV') then
     if(p.eq.1) then 
      rate=t%tev%XS_hj_ratio(j)
      SMrate=t%tev%XS_H_SM(j)
      rate_SMref=XS_tev_gg_H_SM(refmass)     
      mutab%channel_description(i,1)='singleH'
     else if(p.eq.2) then
      rate=t%tev%XS_vbf_ratio(j)
      SMrate=t%tev%XS_vbf_SM(j)
      rate_SMref=XS_tev_vbf_SM(refmass)     
      mutab%channel_description(i,1)='VBF'     
     else if(p.eq.3) then
      rate=t%tev%XS_hjW_ratio(j)
      SMrate=t%tev%XS_HW_SM(j) 
      rate_SMref=XS_tev_HW_SM(refmass)
      mutab%channel_description(i,1)='HW'     
     else if(p.eq.4) then
      rate=t%tev%XS_hjZ_ratio(j)  
      SMrate=t%tev%XS_HZ_SM(j)
      rate_SMref=XS_tev_HZ_SM(refmass)
      mutab%channel_description(i,1)='HZ'       
     else if(p.eq.5) then
      rate=t%tev%XS_tthj_ratio(j)
      SMrate=t%tev%XS_ttH_SM(j)
      rate_SMref=XS_tev_ttH_SM(refmass)
      mutab%channel_description(i,1)='ttH' 
     else if(p.eq.0) then
      rate=1.0D0
      SMrate=1.0D0
      rate_SMref=1.0D0     
      mutab%channel_description(i,1)='none'         
     endif       
   else if(mutab%collider.eq.'ILC') then
 !--n.B.: As a first attempt, we use the LHC8 normalized cross sections for ZH, VBF, ttH.
 !        In order to do this properly, a separate input for the ILC cross sections
 !        has to be provided! It works only for single production mode observables (no
 !        correct weighting of channels included!)Then, at least in the effective coupling
 !        approximation, there is no difference to a full implementation.
 !        The theoretical uncertainty of the ILC production modes will are defined in
 !        usefulbits_HS.f90.
     if(p.eq.1.or.p.eq.2) then 
      write(*,*) 'Warning: Unknown ILC production mode (',p,') in table ',mutab%id
      rate=0.0D0
      SMrate=1.0D0
      rate_SMref=1.0D0     
      mutab%channel_description(i,1)='unknown'
     else if(p.eq.3) then
      rate=t%lhc8%XS_hjW_ratio(j)
      SMrate=t%lhc8%XS_HW_SM(j)
      rate_SMref=XS_lhc8_HW_SM(refmass)          
      mutab%channel_description(i,1)='WBF'     
     else if(p.eq.4) then
      rate=t%lhc8%XS_hjZ_ratio(j)  
      SMrate=t%lhc8%XS_HZ_SM(j)
      rate_SMref=XS_lhc8_HZ_SM(refmass)     
      mutab%channel_description(i,1)='HZ'       
     else if(p.eq.5) then
      rate=t%lhc8%XS_tthj_ratio(j)
      SMrate=t%lhc8%XS_ttH_SM(j)
      rate_SMref=XS_lhc8_ttH_SM(refmass)
      mutab%channel_description(i,1)='ttH' 
     else if(p.eq.0) then
      rate=1.0D0
      SMrate=1.0D0
      rate_SMref=1.0D0     
      mutab%channel_description(i,1)='none'         
     endif           
    endif
 !--Multiply now by the decay rate
   if(d.eq.1) then
    rate=rate*div(t%BR_hjgaga(j),t%BR_Hgaga_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Hgaga_SM(j)
    rate_SMref = rate_SMref*BRSM_Hgaga(refmass)
    mutab%channel_description(i,2)='gammagamma'   
   else if(d.eq.2) then
    rate=rate*div(t%BR_hjWW(j),t%BR_HWW_SM(j),0.0D0,1.0D0)   
    SMrate=SMrate*t%BR_HWW_SM(j)
    rate_SMref = rate_SMref*BRSM_HWW(refmass)
    mutab%channel_description(i,2)='WW'   
   else if(d.eq.3) then
    rate=rate*div(t%BR_hjZZ(j),t%BR_HZZ_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_HZZ_SM(j)
    rate_SMref = rate_SMref*BRSM_HZZ(refmass)   
    mutab%channel_description(i,2)='ZZ'
   else if(d.eq.4) then
    rate=rate*div(t%BR_hjtautau(j),t%BR_Htautau_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Htautau_SM(j)
    rate_SMref = rate_SMref*BRSM_Htautau(refmass)
    mutab%channel_description(i,2)='tautau'
   else if(d.eq.5) then
    rate=rate*div(t%BR_hjbb(j),t%BR_Hbb_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Hbb_SM(j)
    rate_SMref = rate_SMref*BRSM_Hbb(refmass)
    mutab%channel_description(i,2)='bb'  
   else if(d.eq.6) then
    rate=rate*div(t%BR_hjZga(j),t%BR_HZga_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_HZga_SM(j)
    rate_SMref = rate_SMref*BRSM_HZga(refmass)   
    mutab%channel_description(i,2)='Zgamma'
   else if(d.eq.7) then
    rate=rate*div(t%BR_hjcc(j),t%BR_Hcc_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Hcc_SM(j)
    rate_SMref = rate_SMref*BRSM_Hcc(refmass)
    mutab%channel_description(i,2)='cc'
   else if(d.eq.8) then
    rate=rate*div(t%BR_hjmumu(j),t%BR_Hmumu_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Hmumu_SM(j)
    rate_SMref = rate_SMref*BRSM_Hmumu(refmass)
    mutab%channel_description(i,2)='mumu'
   else if(d.eq.9) then
    rate=rate*div(t%BR_hjgg(j),t%BR_Hgg_SM(j),0.0D0,1.0D0)
    SMrate=SMrate*t%BR_Hgg_SM(j)
    rate_SMref = rate_SMref*BRSM_Hgg(refmass)
    mutab%channel_description(i,2)='gg'
   else if(d.eq.0) then
    rate=rate*1.0D0
    SMrate=SMrate*1.0D0
    rate_SMref = rate_SMref*1.0D0
    mutab%channel_description(i,2)='none'
   endif
   
 ! write(*,*) 'DEBUG HS: SM BRs = ', t%BR_HWW_SM(j), t%BR_HZZ_SM(j), t%BR_Hgaga_SM(j)  
 ! write(*,*) 'DEBUG HS: rate, SMrate(i) = ', rate, SMrate
 ! write(*,*) 'DEBUG HS: eff(i) = ', mutab%channel_eff(i) 
   
   
  if(normalize_rates_to_reference_position) then 
 !! THIS IS STILL IN TESTING PHASE !!  
   mutab%channel_mu(i,j)=rate*SMrate/(rate_SMref)
  else
   mutab%channel_mu(i,j)=rate  !! OLD WAY 
  endif
   
   mutab%channel_w(i,j)=mutab%channel_eff(i)*SMrate 
 !  mutab%channel_w_corrected_eff(i,j)=mutab%channel_eff_ratios(i)*mutab%channel_eff(i)*SMrate   
  enddo
 
 
 ! write(*,*) 'DEBUG HS: BRs = ', t%BR_hjWW, t%BR_hjZZ, t%BR_hjgaga  
 ! write(*,*) 'DEBUG HS: LHC8 = ', t%lhc8%XS_hj_ratio, t%lhc8%XS_vbf_ratio, t%lhc8%XS_hjW_ratio,&
 !                                 t%lhc8%XS_hjZ_ratio, t%lhc8%XS_tthj_ratio
 
 
  SMrate=sum(mutab%channel_w(:,j))
 ! write(*,*) 'DEBUG HS: SMrate = ', SMrate
 ! modelrate=sum(mutab%channel_w_corrected_eff(:,j))
  
  do i=1,mutab%Nc
   mutab%channel_w(i,j)=div(mutab%channel_w(i,j),SMrate,0.0D0,1.0D9)
 !  mutab%channel_w_corrected_eff(i,j)=div(mutab%channel_w_corrected_eff(i,j),modelrate,0.0D0,1.0D9)
  enddo
  
 ! (TS 30/10/2013):
 ! write(*,*) "get_channelrates (mu, w, weff):" 
 ! write(*,*) mutab%channel_mu
 ! write(*,*)  mutab%channel_w
 ! write(*,*) mutab%channel_eff_ratios
  do i=1,mutab%Nc
   mutab%channel_w_corrected_eff(i,j)=mutab%channel_eff_ratios(i)*mutab%channel_w(i,j)
 ! n.b.: model weights are not normalized to 1!
  enddo
  
 ! write(*,*) j,mutab%id, "SM         = ", mutab%channel_w(:,j)
 ! write(*,*) j,mutab%id, "SM effcorr = ",mutab%channel_w_corrected_eff(:,j) 
  
  do i=1,mutab%Nc
   drsq_SM = 0.0D0
   drsq = 0.0D0
 
   id1 = mutab%channel_id(i)
   p1 = int((id1-modulo(id1,10))/dble(10))
   d1 = modulo(id1,10)
   if(mutab%collider.ne.'ILC') then
    do ii=1,mutab%Nc 
     id2 = mutab%channel_id(ii)
     p2 = int((id2-modulo(id2,10))/dble(10))
     d2 = modulo(id2,10)
     if(p1.eq.p2.and.p1.ne.0) then
      if(delta_rate%CScov_ok.and.delta_rate%usecov) then
       drsq=drsq+delta_rate%CScov(p1,p1)*mutab%channel_w_corrected_eff(i,j)*mutab%channel_w_corrected_eff(ii,j)
       drsq_SM=drsq_SM+delta_rate%CScovSM(p1,p1)*mutab%channel_w(i,j)*mutab%channel_w(ii,j)     
      else
       drsq=drsq+delta_rate%dCS(p1)**2*mutab%channel_w_corrected_eff(i,j)*mutab%channel_w_corrected_eff(ii,j)
       drsq_SM=drsq_SM+delta_rate%dCS_SM(p1)**2*mutab%channel_w(i,j)*mutab%channel_w(ii,j)
      endif
     endif 
     if(d1.eq.d2.and.d1.ne.0) then
      if(delta_rate%BRcov_ok.and.delta_rate%usecov) then
       dBRSM = delta_rate%BRcovSM(d1,d1)
       dBR = delta_rate%BRcov(d1,d1)
      else
       dBRSM = delta_rate%dBR_SM(d1)**2
       dBR = delta_rate%dBR(d1)**2
      endif 
      drsq=drsq+dBR*mutab%channel_w_corrected_eff(i,j)*mutab%channel_w_corrected_eff(ii,j)
      drsq_SM=drsq_SM+dBRSM*mutab%channel_w(i,j)*mutab%channel_w(ii,j)   
     endif 
    enddo 
   endif 
   mutab%channel_syst(i,j)=sqrt(drsq)
   mutab%channel_systSM(i,j)=sqrt(drsq_SM)
  enddo
    
 
 !write(*,*) 'DEBUG HS: mu = ', mutab%channel_mu  
 !write(*,*) 'DEBUG HS: w = ', mutab%channel_w
 !write(*,*) 'DEBUG HS: eff = ', mutab%channel_eff
    
 end subroutine get_channelrates
 !------------------------------------------------------------
 subroutine get_Rvalues(ii,collider,R_H_WW, R_H_ZZ, R_H_gaga, R_H_tautau, R_H_bb, R_VH_bb)
 ! Returns SM normalized signal rates of some relevant channels (w/o efficiencies) 
 ! for Higgs boson "ii" for a specific collider (see subroutine get_rates).
 !------------------------------------------------------------
 ! use usefulbits, only : theo, np,Hneut
 ! use usefulbits_HS, only : mutable
 
  integer, intent(in) :: ii, collider
  double precision, intent(out) :: R_H_WW, R_H_ZZ, R_H_gaga, R_H_tautau, R_H_bb, R_VH_bb
 ! type(mutable) :: dummytable
 ! integer :: i
  
  call get_rates(ii,collider,5,(/ 12, 22, 32, 42, 52 /),R_H_WW)
  call get_rates(ii,collider,5,(/ 13, 23, 33, 43, 53 /),R_H_ZZ)
  call get_rates(ii,collider,5,(/ 11, 21, 31, 41, 51 /),R_H_gaga)
  call get_rates(ii,collider,5,(/ 14, 24, 34, 44, 54 /),R_H_tautau)
  call get_rates(ii,collider,5,(/ 15, 25, 35, 45, 55 /),R_H_bb)
  call get_rates(ii,collider,2,(/ 35, 45 /),R_VH_bb)
 
 end subroutine get_Rvalues
 !************************************************************
 subroutine get_rates(ii,collider,Nchannels,IDchannels,rate)
 ! Returns SM normalized signal rates (w/o efficiencies) for Higgs boson "ii" and collider
 ! experiment "collider"(=1,2,3 for TEV, LHC7, LHC8). "Nchannels" gives the total number
 ! and IDchannels the two-digit ID of the subchannels, which should be included in the rates.
 ! IDchannels is an array of size(Nchannels).
 !------------------------------------------------------------
  use usefulbits, only : theo, np,Hneut
  use usefulbits_HS, only : mutable
 
  integer, intent(in) :: ii, collider, Nchannels
  integer, dimension(Nchannels), intent(in) :: IDchannels
  double precision, intent(out) :: rate
 !-Internal 
  type(mutable) :: dummytable
  integer :: i
  
 !-Initialize a dummy mutable in order to run get_channelrates for the channels we want.  
  if(collider.eq.1) then
   dummytable%collider = 'TEV'
  else if(collider.eq.2) then
   dummytable%collider = 'LHC'
   dummytable%energy = 7.0D0
  else if(collider.eq.3) then
   dummytable%collider = 'LHC'
   dummytable%energy = 8.0D0
  else
   write(*,*) 'WARNING: collider experiment for get_rates unknown.'
   continue
  endif 
 
  dummytable%id = 999999
  dummytable%particle_x = 1
  dummytable%Nc=Nchannels
  allocate(dummytable%mass(10))
  allocate(dummytable%channel_id(Nchannels))
  allocate(dummytable%channel_eff(Nchannels))
  allocate(dummytable%channel_eff_ratios(Nchannels))
 !-Set all efficiencies equal: 
  dummytable%channel_eff = 1.0D0
  dummytable%channel_eff_ratios = 1.0D0
  allocate(dummytable%channel_description(Nchannels,2))
  allocate(dummytable%channel_w(Nchannels,np(Hneut)))
  allocate(dummytable%channel_w_corrected_eff(Nchannels,np(Hneut)))
  allocate(dummytable%channel_systSM(Nchannels,np(Hneut))) 
  allocate(dummytable%channel_syst(Nchannels,np(Hneut))) 
  allocate(dummytable%channel_mu(Nchannels,np(Hneut)))
  dummytable%channel_id = IDchannels
 
  call get_channelrates(ii, theo(1), dummytable)
  rate=0.0D0
  do i=lbound(dummytable%channel_mu,dim=1),ubound(dummytable%channel_mu,dim=1)
   rate = rate + dummytable%channel_mu(i,ii)*dummytable%channel_w(i,ii)
  enddo
 
  deallocate(dummytable%channel_id,dummytable%channel_eff,dummytable%channel_description,&
 &           dummytable%channel_w,dummytable%channel_systSM,dummytable%channel_syst,		&
 &           dummytable%channel_mu,dummytable%channel_eff_ratios, &
 &           dummytable%channel_w_corrected_eff,dummytable%mass)
 
 end subroutine get_rates
 !------------------------------------------------------------
 subroutine get_Pvalue(nparam, Pvalue)
 ! Calculates the Chi^2 probability for the total Chi^2 value
 ! and the number of degrees of freedom given by the
 ! number of observables - nparam
 !------------------------------------------------------------
  use usefulbits, only : vsmall
  use usefulbits_hs, only: HSres
  use numerics 
  implicit none
  integer, intent(in) :: nparam
  double precision, intent(out) :: Pvalue
  
  if(allocated(HSres)) then
   if(HSres(1)%Chisq.gt.vsmall.and.(HSres(1)%nobs-nparam).gt.0) then
    HSres(1)%Pvalue = 1 - gammp(dble(HSres(1)%nobs-nparam)/2,HSres(1)%Chisq/2)
   endif
  else
   write(*,*) "Warning: subroutine get_Pvalue should be called after run_HiggsSignals." 
  endif
  
  Pvalue = HSres(1)%Pvalue
 
 end subroutine get_Pvalue
 !------------------------------------------------------------
 subroutine get_neutral_Higgs_masses(Mh, dMh)
 ! Sets the theoretical mass uncertainty of the Higgs bosons.
 !------------------------------------------------------------
  use usefulbits, only: theo,np,Hneut
  
  implicit none
  double precision,intent(out) :: Mh(np(Hneut)), dMh(np(Hneut))
 
  if(.not.allocated(theo))then
   stop 'No model information given!'
  endif
  if(np(Hneut).eq.0)then
   write(*,*)'Cannot access the neutral Higgs boson masses'
   write(*,*)'because np(Hneut) == 0.'
   stop 'error in subroutine get_neutral_Higgs_masses'
  endif
 
  Mh = theo(1)%particle(Hneut)%M 
  dMh = theo(1)%particle(Hneut)%dM
  
 end subroutine get_neutral_Higgs_masses
 !------------------------------------------------------------
 subroutine finish_HiggsSignals
 ! This subroutine needs to be called right at the end, to close files
 ! and deallocate arrays
 !------------------------------------------------------------
  use usefulbits, only : deallocate_usefulbits,debug,theo,debug,inputsub, &
    & file_id_debug1,file_id_debug2
  use S95tables, only : deallocate_Exptranges
  use theory_BRfunctions, only : deallocate_BRSM
  use datatables, only : deallocate_observables
  use usefulbits_HS, only : deallocate_usefulbits_HS, analyses
  use mc_chisq, only : deallocate_mc_observables
  use store_pathname_HS
  
 !#if defined(NAGf90Fortran)
 ! use F90_UNIX_IO, only : flush
 !#endif
       
  if(debug)then
   close(file_id_debug2)
   close(file_id_debug1)
  endif
 
  if(debug) write(*,*)'finishing off...'                      ; call flush(6)
  if(.not.allocated(theo))then
 !  stop 'HiggsBounds_initialize  should be called first'
  if(debug) write(*,*) "HiggsBounds/HiggsSignals internal structure already deallocated!"
  else
   call deallocate_BRSM
   call deallocate_Exptranges
   call deallocate_usefulbits
   if (allocated(inputsub)) deallocate(inputsub)
  endif 
  call deallocate_mc_observables
  call deallocate_observables
  if(allocated(analyses)) deallocate(analyses)
  call deallocate_usefulbits_HS
 ! call system('rm -f '//trim(adjustl(pathname_HS))//'Expt_tables/analyses.txt')
  call system('rm -f HS_analyses.txt')
   
  if(debug) write(*,*)'finished'                              ; call flush(6)
  
 end subroutine finish_HiggsSignals
 !------------------------------------------------------------
 ! SOME HANDY WRAPPER SUBROUTINES
 !------------------------------------------------------------
 subroutine initialize_HiggsSignals_for_Fittino(nHiggsneut,nHiggsplus)
 !------------------------------------------------------------
 ! Wrapper subroutine to intitialize HiggsSignals with the experimental
 ! dataset "latestresults", avoiding to specify this via a string argument.
 !------------------------------------------------------------
  implicit none
  !--------------------------------------input
  integer,intent(in) :: nHiggsneut
  integer,intent(in) :: nHiggsplus
 ! character(LEN=19) :: Expt_string
  character(LEN=33) :: Expt_string 
 ! Expt_string = "Moriond2013_Fittino"
  Expt_string = "latestresults_April2013_inclusive"
  
  call initialize_HiggsSignals(nHiggsneut,nHiggsplus,Expt_string)
  
 end subroutine initialize_HiggsSignals_for_Fittino
 !------------------------------------------------------------
 subroutine get_number_of_observables_wrapper(ntotal, npeakmu, npeakmh, nmpred, nanalyses)
 !------------------------------------------------------------
  use io, only : get_number_of_observables
  
  implicit none
  integer, intent(out) :: ntotal, npeakmu, npeakmh, nmpred, nanalyses
  
  call get_number_of_observables(ntotal, npeakmu, npeakmh, nmpred, nanalyses) 
 end subroutine get_number_of_observables_wrapper
 !------------------------------------------------------------
 subroutine get_ID_of_peakobservable_wrapper(ii, ID)
 !------------------------------------------------------------
  use io, only : get_ID_of_peakobservable 
  implicit none
  integer, intent(in) :: ii
  integer, intent(out) :: ID
 
  call get_ID_of_peakobservable(ii, ID)
 end subroutine get_ID_of_peakobservable_wrapper
 !------------------------------------------------------------
 subroutine get_peakinfo_from_HSresults_wrapper(obsID, mupred, domH, nHcomb)
 !--------------------------------------------------------------------
  use io, only : get_peakinfo_from_HSresults
  
  implicit none
  integer, intent(in) :: obsID
  double precision, intent(out) :: mupred
  integer, intent(out) :: domH, nHcomb
 
  call get_peakinfo_from_HSresults(obsID, mupred, domH, nHcomb)
 end subroutine get_peakinfo_from_HSresults_wrapper
 !------------------------------------------------------------
 subroutine print_cov_mh_to_file_wrapper(Hindex)
 !------------------------------------------------------------
  use pc_chisq, only : print_cov_mh_to_file
 
  implicit none
  integer, intent(in) :: Hindex
  
  call print_cov_mh_to_file(Hindex)
 end subroutine print_cov_mh_to_file_wrapper
 !------------------------------------------------------------
 subroutine print_cov_mu_to_file_wrapper
 !------------------------------------------------------------
  use pc_chisq, only : print_cov_mu_to_file
 
  implicit none
  call print_cov_mu_to_file
 end subroutine print_cov_mu_to_file_wrapper
 !------------------------------------------------------------
Index: trunk/HiggsSignals/example_data/SLHA/SLHA_FHexample.fh.1
===================================================================
--- trunk/HiggsSignals/example_data/SLHA/SLHA_FHexample.fh.1	(revision 505)
+++ trunk/HiggsSignals/example_data/SLHA/SLHA_FHexample.fh.1	(revision 506)
@@ -1,1984 +1,1991 @@
 BLOCK SPINFO
      1   FeynHiggs
      2   2.8.6
      2   built on Feb 23, 2012
 BLOCK MODSEL
          1                  1   # Model
          3                  0   # Content
          4                  0   # RPV
          5                  2   # CPV
          6                  0   # FV
 BLOCK SMINPUTS
          1     1.28936827E+02   # invAlfaMZ
          2     1.16639000E-05   # GF
          3     1.18000000E-01   # AlfasMZ
          4     9.11870000E+01   # MZ
          5     4.25000000E+00   # Mb
          6     1.75000000E+02   # Mt
          7     1.77703000E+00   # Mtau
         11     5.10998902E-04   # Me
         13     1.05658357E-01   # Mmu
         21     6.00000000E-03   # Md
         22     3.00000000E-03   # Mu
         23     9.50000000E-02   # Ms
         24     1.28600000E+00   # Mc
 BLOCK MINPAR
          1     0.00000000E+00   # M0
          2     0.00000000E+00   # M12
          3     1.00000000E+01   # TB
          4     1.00000000E+00   # signMUE
          5    -0.00000000E+00   # A
 BLOCK EXTPAR
          0     4.84786694E+02   # Q
          1     3.00000000E+02   # M1
          2     6.00000000E+02   # M2
          3     1.00000000E+03   # M3
         11     1.00000000E+03   # At
         12     3.00000000E+02   # Ab
         13     2.00000000E+02   # Atau
         23     1.00000000E+02   # MUE
         24     1.40000000E+05   # MA02
         25     1.00000000E+01   # TB
         26     3.74165739E+02   # MA0
         27     3.82704682E+02   # MHp
         31     2.06630723E+02   # MSL(1)
         32     2.06645846E+02   # MSL(2)
         33     1.34514453E+02   # MSL(3)
         34     1.43872558E+02   # MSE(1)
         35     1.43838140E+02   # MSE(2)
         36     2.10401949E+02   # MSE(3)
         41     5.64892619E+02   # MSQ(1)
         42     5.64902784E+02   # MSQ(2)
         43     4.58749215E+02   # MSQ(3)
         44     5.47790210E+02   # MSU(1)
         45     5.47775859E+02   # MSU(2)
         46     5.89079372E+02   # MSU(3)
         47     5.47601268E+02   # MSD(1)
         48     5.47594947E+02   # MSD(2)
         49     5.47471349E+02   # MSD(3)
 BLOCK MASS
    1000012     1.96522387E+02   # MSf(1,1,1)
    2000012     1.00000000+123   # MSf(2,1,1)
    1000011     1.50049429E+02   # MSf(1,2,1)
    2000011     2.12028169E+02   # MSf(2,2,1)
    1000002     5.46684341E+02   # MSf(1,3,1)
    2000002     5.62350503E+02   # MSf(2,3,1)
    1000001     5.48153556E+02   # MSf(1,4,1)
    2000001     5.67955726E+02   # MSf(2,4,1)
    1000014     1.96538288E+02   # MSf(1,1,2)
    2000014     1.00000000+123   # MSf(2,1,2)
    1000013     1.50015405E+02   # MSf(1,2,2)
    2000013     2.12043684E+02   # MSf(2,2,2)
    1000004     5.46585835E+02   # MSf(1,3,2)
    2000004     5.62283026E+02   # MSf(2,3,2)
    1000003     5.48147074E+02   # MSf(1,4,2)
    2000003     5.67966013E+02   # MSf(2,4,2)
    1000016     1.18401567E+02   # MSf(1,1,3)
    2000016     1.00000000+123   # MSf(2,1,3)
    1000015     1.42403224E+02   # MSf(1,2,3)
    2000015     2.14862660E+02   # MSf(2,2,3)
    1000006     3.29129281E+02   # MSf(1,3,3)
    2000006     6.76789745E+02   # MSf(2,3,3)
    1000005     4.50942677E+02   # MSf(1,4,3)
    2000005     5.51183125E+02   # MSf(2,4,3)
         25     1.22651152E+02   # Mh0
         35     3.74749649E+02   # MHH
         36     3.74165739E+02   # MA0
         37     3.82764933E+02   # MHp
    1000022     8.77717849E+01   # MNeu(1)
    1000023     1.05731705E+02   # MNeu(2)
    1000025     3.06628639E+02   # MNeu(3)
    1000035     6.11331282E+02   # MNeu(4)
    1000024     9.60565070E+01   # MCha(1)
    1000037     6.11309165E+02   # MCha(2)
    1000021     1.00000000E+03   # MGl
 BLOCK DMASS
          0     1.75000000E+02   # Q
         25     9.72174332E-01   # Delta Mh0
         35     1.06946442E-02   # Delta MHH
         36     0.00000000E+00   # Delta MA0
         37     8.06715487E-02   # Delta MHp
 BLOCK NMIX
      1   1     1.47271688E-01   # ZNeu(1,1)
      1   2    -1.13979916E-01   # ZNeu(1,2)
      1   3     7.30717872E-01   # ZNeu(1,3)
      1   4    -6.56788414E-01   # ZNeu(1,4)
      2   1    -0.00000000E+00   # ZNeu(2,1)
      2   2     0.00000000E+00   # ZNeu(2,2)
      2   3     0.00000000E+00   # ZNeu(2,3)
      2   4     0.00000000E+00   # ZNeu(2,4)
      3   1     9.86458640E-01   # ZNeu(3,1)
      3   2     4.16346543E-02   # ZNeu(3,2)
      3   3    -6.05146385E-02   # ZNeu(3,3)
      3   4     1.46642030E-01   # ZNeu(3,4)
      4   1    -1.92855611E-02   # ZNeu(4,1)
      4   2     9.89795429E-01   # ZNeu(4,2)
      4   3     3.54417152E-02   # ZNeu(4,3)
      4   4    -1.36663681E-01   # ZNeu(4,4)
 BLOCK IMNMIX
      1   1     0.00000000E+00   # ZNeu(1,1)
      1   2     0.00000000E+00   # ZNeu(1,2)
      1   3     0.00000000E+00   # ZNeu(1,3)
      1   4     0.00000000E+00   # ZNeu(1,4)
      2   1    -6.95590979E-02   # ZNeu(2,1)
      2   2     7.47003613E-02   # ZNeu(2,2)
      2   3     6.79067931E-01   # ZNeu(2,3)
      2   4     7.26944381E-01   # ZNeu(2,4)
      3   1     0.00000000E+00   # ZNeu(3,1)
      3   2     0.00000000E+00   # ZNeu(3,2)
      3   3     0.00000000E+00   # ZNeu(3,3)
      3   4     0.00000000E+00   # ZNeu(3,4)
      4   1     0.00000000E+00   # ZNeu(4,1)
      4   2     0.00000000E+00   # ZNeu(4,2)
      4   3     0.00000000E+00   # ZNeu(4,3)
      4   4     0.00000000E+00   # ZNeu(4,4)
 BLOCK UMIX
      1   1    -4.97233578E-02   # UCha(1,1)
      1   2     9.98763029E-01   # UCha(1,2)
      2   1     9.98763029E-01   # UCha(2,1)
      2   2     4.97233578E-02   # UCha(2,2)
 BLOCK VMIX
      1   1    -1.92962310E-01   # VCha(1,1)
      1   2     9.81206170E-01   # VCha(1,2)
      2   1     9.81206170E-01   # VCha(2,1)
      2   2     1.92962310E-01   # VCha(2,2)
 BLOCK STAUMIX
      1   1     9.98486400E-01   # USf(1,1)
      1   2     5.49991646E-02   # USf(1,2)
      2   1    -5.49991646E-02   # USf(2,1)
      2   2     9.98486400E-01   # USf(2,2)
 BLOCK STOPMIX
      1   1     8.23605275E-01   # USf(1,1)
      1   2    -5.67163425E-01   # USf(1,2)
      2   1     5.67163425E-01   # USf(2,1)
      2   2     8.23605275E-01   # USf(2,2)
 BLOCK SBOTMIX
      1   1     9.99954439E-01   # USf(1,1)
      1   2     9.54568581E-03   # USf(1,2)
      2   1    -9.54568581E-03   # USf(2,1)
      2   2     9.99954439E-01   # USf(2,2)
 BLOCK ALPHA
               -1.17451823E-01   # Alpha
 BLOCK DALPHA
                1.46801249E-03   # Delta Alpha
 BLOCK VCKMIN
          1     2.25300000E-01   # lambda
          2     8.08000000E-01   # A
          3     1.32000000E-01   # rhobar
          4     3.41000000E-01   # etabar
 BLOCK MSL2IN
      1   1     4.26962557E+04   # MSL2(1,1)
      2   2     4.27025057E+04   # MSL2(2,2)
      3   3     1.80941381E+04   # MSL2(3,3)
 BLOCK MSE2IN
      1   1     2.06993129E+04   # MSE2(1,1)
      2   2     2.06894105E+04   # MSE2(2,2)
      3   3     4.42689801E+04   # MSE2(3,3)
 BLOCK MSQ2IN
      1   1     3.19103671E+05   # MSQ2(1,1)
      2   2     3.19115155E+05   # MSQ2(2,2)
      3   3     1.99881446E+05   # MSQ2(3,3)
 BLOCK MSU2IN
      1   1     3.00074114E+05   # MSU2(1,1)
      2   2     3.00058392E+05   # MSU2(2,2)
      3   3     3.16134306E+05   # MSU2(3,3)
 BLOCK MSD2IN
      1   1     2.99867149E+05   # MSD2(1,1)
      2   2     2.99860226E+05   # MSD2(2,2)
      3   3     3.03181540E+05   # MSD2(3,3)
 BLOCK TEIN
      1   1     5.89936191E-04   # Tf(1,1)
      2   2     1.21980083E-01   # Tf(2,2)
      3   3     2.05153926E+00   # Tf(3,3)
 BLOCK TUIN
      1   1     1.73171465E-01   # Tf(1,1)
      2   2     7.42328349E+01   # Tf(2,2)
      3   3     9.53077892E+03   # Tf(3,3)
 BLOCK TDIN
      1   1     1.03902879E-02   # Tf(1,1)
      2   2     1.64512892E-01   # Tf(2,2)
      3   3     1.56232003E+01   # Tf(3,3)
 BLOCK CVHMIX
      1   1     9.99984377E-01   # UH(1,1)
      1   2     5.58985436E-03   # UH(1,2)
      1   3     0.00000000E+00   # UH(1,3)
      2   1    -5.58985436E-03   # UH(2,1)
      2   2     9.99984377E-01   # UH(2,2)
      2   3     0.00000000E+00   # UH(2,3)
      3   1     0.00000000E+00   # UH(3,1)
      3   2     0.00000000E+00   # UH(3,2)
      3   3     1.00000000E+00   # UH(3,3)
 BLOCK PRECOBS
          1     4.58620642E-04   # DeltaRho
          2     8.03985711E+01   # MWMSSM
          3     8.03727370E+01   # MWSM
          4     2.31309273E-01   # SW2effMSSM
          5     2.31452470E-01   # SW2effSM
         11     1.47612393E-09   # gminus2mu
         21     0.00000000E+00   # EDMeTh
         22     0.00000000E+00   # EDMn
         23     0.00000000E+00   # EDMHg
         31     7.83340682E-04   # bsgammaMSSM
         32     3.84151628E-04   # bsgammaSM
         33     2.29365346E+01   # DeltaMsMSSM
         34     2.19915791E+01   # DeltaMsSM
 DECAY        25     4.66729789E-03   # Gamma(h0)
      1.67729727E-03   2        22        22   # BR(h0 -> photon photon)
      1.72630719E-02   2        23        23   # BR(h0 -> Z Z)
      1.49508769E-01   2       -24        24   # BR(h0 -> W W)
      4.98888879E-02   2        21        21   # BR(h0 -> gluon gluon)
      5.91016012E-09   2       -11        11   # BR(h0 -> Electron electron)
      2.62892978E-04   2       -13        13   # BR(h0 -> Muon muon)
      7.57524936E-02   2       -15        15   # BR(h0 -> Tau tau)
      1.71225452E-07   2        -2         2   # BR(h0 -> Up up)
      2.39510771E-02   2        -4         4   # BR(h0 -> Charm charm)
      9.86900853E-07   2        -1         1   # BR(h0 -> Down down)
      2.47844298E-04   2        -3         3   # BR(h0 -> Strange strange)
      6.81446502E-01   2        -5         5   # BR(h0 -> Bottom bottom)
 DECAY        35     7.83706554E-01   # Gamma(HH)
      3.06707834E-06   2        22        22   # BR(HH -> photon photon)
      1.74379832E-03   2        23        23   # BR(HH -> Z Z)
      3.80819738E-03   2       -24        24   # BR(HH -> W W)
      6.56064077E-04   2        21        21   # BR(HH -> gluon gluon)
      7.54257349E-09   2       -11        11   # BR(HH -> Electron electron)
      3.35617824E-04   2       -13        13   # BR(HH -> Muon muon)
      9.73136619E-02   2       -15        15   # BR(HH -> Tau tau)
      3.26751691E-11   2        -2         2   # BR(HH -> Up up)
      4.57357974E-06   2        -4         4   # BR(HH -> Charm charm)
      2.51100369E-02   2        -6         6   # BR(HH -> Top top)
      1.00572923E-06   2        -1         1   # BR(HH -> Down down)
      2.52571792E-04   2        -3         3   # BR(HH -> Strange strange)
      6.71514561E-01   2        -5         5   # BR(HH -> Bottom bottom)
      8.67236607E-02   2  -1000024   1000024   # BR(HH -> Chargino1 chargino1)
      4.30707320E-02   2   1000022   1000022   # BR(HH -> neutralino1 neutralino1)
      9.07746163E-03   2   1000022   1000023   # BR(HH -> neutralino1 neutralino2)
      1.60515467E-02   2   1000023   1000023   # BR(HH -> neutralino2 neutralino2)
      3.42640993E-02   2        25        25   # BR(HH -> h0 h0)
      4.05662328E-04   2  -1000011   1000011   # BR(HH -> Selectron1 selectron1)
      3.21302032E-10   2  -1000011   2000011   # BR(HH -> Selectron1 selectron2)
      3.21302032E-10   2  -2000011   1000011   # BR(HH -> Selectron2 selectron1)
      4.03871097E-04   2  -1000013   1000013   # BR(HH -> Smuon1 smuon1)
      1.37454954E-05   2  -1000013   2000013   # BR(HH -> Smuon1 smuon2)
      1.37454954E-05   2  -2000013   1000013   # BR(HH -> Smuon2 smuon1)
      1.80571224E-04   2  -1000015   1000015   # BR(HH -> Stau1 stau1)
      4.52587015E-03   2  -1000015   2000015   # BR(HH -> Stau1 stau2)
      4.52587015E-03   2  -2000015   1000015   # BR(HH -> Stau2 stau1)
 DECAY        36     8.89538917E-01   # Gamma(A0)
      6.11274373E-06   2        22        22   # BR(A0 -> photon photon)
      6.30977419E-04   2        21        21   # BR(A0 -> gluon gluon)
      6.58260322E-09   2       -11        11   # BR(A0 -> Electron electron)
      2.92902511E-04   2       -13        13   # BR(A0 -> Muon muon)
      8.49304516E-02   2       -15        15   # BR(A0 -> Tau tau)
      1.88836298E-11   2        -2         2   # BR(A0 -> Up up)
      2.64328808E-06   2        -4         4   # BR(A0 -> Charm charm)
      1.16717546E-01   2        -6         6   # BR(A0 -> Top top)
      8.77995484E-07   2        -1         1   # BR(A0 -> Down down)
      2.20493704E-04   2        -3         3   # BR(A0 -> Strange strange)
      5.86468722E-01   2        -5         5   # BR(A0 -> Bottom bottom)
      1.14286977E-01   2  -1000024   1000024   # BR(A0 -> Chargino1 chargino1)
      7.10303312E-02   2   1000022   1000022   # BR(A0 -> neutralino1 neutralino1)
      8.23874194E-04   2   1000022   1000023   # BR(A0 -> neutralino1 neutralino2)
      1.29641313E-02   2   1000023   1000023   # BR(A0 -> neutralino2 neutralino2)
      3.87218821E-03   2        23        25   # BR(A0 -> Z h0)
      6.41227277E-35   2        25        25   # BR(A0 -> h0 h0)
      2.72541936E-10   2  -1000011   2000011   # BR(A0 -> Selectron1 selectron2)
      2.72541936E-10   2  -2000011   1000011   # BR(A0 -> Selectron2 selectron1)
      1.16605248E-05   2  -1000013   2000013   # BR(A0 -> Smuon1 smuon2)
      1.16605248E-05   2  -2000013   1000013   # BR(A0 -> Smuon2 smuon1)
      3.86422166E-03   2  -1000015   2000015   # BR(A0 -> Stau1 stau2)
      3.86422166E-03   2  -2000015   1000015   # BR(A0 -> Stau2 stau1)
 DECAY        37     5.77103523E-01   # Gamma(Hp)
      1.09735497E-08   2       -11        12   # BR(Hp -> Electron nu_e)
      4.69153370E-04   2       -13        14   # BR(Hp -> Muon nu_mu)
      1.32702162E-01   2       -15        16   # BR(Hp -> Tau nu_tau)
      1.30918860E-06   2        -1         2   # BR(Hp -> Down up)
      3.32233240E-04   2        -3         4   # BR(Hp -> Strange charm)
      8.18940930E-01   2        -5         6   # BR(Hp -> Bottom top)
      1.11828834E-03   2   1000022   1000024   # BR(Hp -> neutralino1 chargino1)
      1.56473147E-02   2   1000023   1000024   # BR(Hp -> neutralino2 chargino1)
      6.98960586E-03   2       -25        24   # BR(Hp -> H0 W)
      7.69953813E-08   2       -35        24   # BR(Hp -> HH W)
      1.07948719E-07   2       -36        24   # BR(Hp -> A0 W)
      1.33187463E-09   2  -1000011   1000012   # BR(Hp -> Selectron1 snu_e1)
      5.69556904E-05   2  -1000013   1000014   # BR(Hp -> Smuon1 snu_mu1)
      2.27100515E-03   2  -1000015   1000016   # BR(Hp -> Stau1 snu_tau1)
      1.96608875E-02   2  -2000015   1000016   # BR(Hp -> Stau2 snu_tau1)
 DECAY         6     1.42276225E+00   # Gamma(top)
      1.00000000E+00   2         5        24   # BR(top -> bottom W)
 #
 Block HiggsBoundsInputHiggsCouplingsBosons
 # For exact definitions of NormEffCoupSq see HiggsBounds manual
      1.01380         3    25    24    24 # higgs-W-W effective coupling^2, normalised to SM
     0.224092E-03     3    35    24    24 # higgs-W-W effective coupling^2, normalised to SM
      0.00000         3    36    24    24 # higgs-W-W effective coupling^2, normalised to SM
      1.01380         3    25    23    23 # higgs-Z-Z effective coupling^2, normalised to SM
     0.224092E-03     3    35    23    23 # higgs-Z-Z effective coupling^2, normalised to SM
      0.00000         3    36    23    23 # higgs-Z-Z effective coupling^2, normalised to SM
     0.842307         3    25    21    21 # higgs-gluon-gluon effective coupling^2, normalised to SM
     0.303613E-01     3    35    21    21 # higgs-gluon-gluon effective coupling^2, normalised to SM
     0.415637E-01     3    36    21    21 # higgs-gluon-gluon effective coupling^2, normalised to SM
      0.00000         3    25    25    23 # higgs-higgs-Z effective coupling^2, normalised
      0.00000         3    35    25    23 # higgs-higgs-Z effective coupling^2, normalised
      0.00000         3    35    35    23 # higgs-higgs-Z effective coupling^2, normalised
     0.344859E-03     3    36    25    23 # higgs-higgs-Z effective coupling^2, normalised
     0.952528         3    36    35    23 # higgs-higgs-Z effective coupling^2, normalised
      0.00000         3    36    36    23 # higgs-higgs-Z effective coupling^2, normalised
      0.00000         4    25    21    21    23 # higgs-gluon-gluon-Z effective coupling^2, normalised to SM
      0.00000         4    35    21    21    23 # higgs-gluon-gluon-Z effective coupling^2, normalised to SM
      0.00000         4    36    21    21    23 # higgs-gluon-gluon-Z effective coupling^2, normalised to SM
 #
 Block HiggsBoundsInputHiggsCouplingsFermions
 # For exact definitions of NormEffCoupSq see HiggsBounds manual
 # ScalarNormEffCoupSq PseudoSNormEffCoupSq    NP    IP1      IP2      IP3 # Scalar, Pseudoscalar Normalised Effective Coupling Squared
    1.4201311968339043        0.0000000000000000                3          25           5           5 # higgs-b-b eff. coupling^2, normalised to SM
    94.055378696286240        0.0000000000000000                3          35           5           5 # higgs-b-b eff. coupling^2, normalised to SM
   2.11691722613467644E-042   93.199701998261276                3          36           5           5 # higgs-b-b eff. coupling^2, normalised to SM
    1.0099456255672334        0.0000000000000000                3          25           6           6 # higgs-top-top eff. coupling^2, normalised to SM
   1.33592532043404228E-002   0.0000000000000000                3          35           6           6 # higgs-top-top eff. coupling^2, normalised to SM
    0.0000000000000000       1.00000000000000019E-002           3          36           6           6 # higgs-top-top eff. coupling^2, normalised to SM
    1.4359623579970071        0.0000000000000000                3          25          15          15 # higgs-tau-tau eff. coupling^2, normalised to SM
    100.92889030196287        0.0000000000000000                3          35          15          15 # higgs-tau-tau eff. coupling^2, normalised to SM
    0.0000000000000000        100.00000000000000                3          36          15          15 # higgs-tau-tau eff. coupling^2, normalised to SM
 Block HiggsBoundsResults      # results from HiggsBounds http://projects.hepforge.org/higgsbounds
 # HBresult   : scenario allowed flag (1: allowed, 0: excluded, -1: unphysical)
 # chan id number: most sensitive channel (see below). chan=0 if no channel applies
 # obsratio   : ratio [sig x BR]_model/[sig x BR]_limit (<1: allowed, >1: excluded)
 # ncomb      : number of Higgs bosons combined in most sensitive channel
 # Note that the HB channel id number varies depending on the HB version and setting "whichanalyses"
 #
-    0    4.2.0beta     ||LandH||            # version of HB used to produce these results,the HB setting "whichanalyses"
+    0    4.2.0     ||LandH||            # version of HB used to produce these results,the HB setting "whichanalyses"
+#
+#CHANNELTYPE 1: channel with the highest statistical sensitivity
+    1           1         509                  # channel id number
+    1           2           1                  # HBresult
+    1           3  0.54906166219839148         # obsratio
+    1           4           2                  # ncombined
+    1           5 ||(pp)->h3->tautau, using -2ln(L) reconstruction  ([hep-ex] arXiv:1408.3316 (CMS))|| # text description of channel
 #
 BLOCK HiggsSignalsResults
-    0                 ||1.3.0beta||               # HiggsSignals version
+    0                 ||1.3.1||               # HiggsSignals version
     1         ||latestresults||               # experimental data set
     2                         1               # Chi-squared method ("peak"(1) or "mass"(2)-centered or "both"(3))
     3                         2               # Parametrization of Higgs mass uncertainty (1:box, 2:gaussian, 3:box+gaussian)
     4                        77               # Number of signal strength peak observables
     5                         4               # Number of Higgs mass peak observables
     6                         0               # Number of mass-centered observables
     7                        81               # Number of observables (total)
     8              112.37328414               # chi^2 from signal strength peak observables
     9                3.96043659               # chi^2 from Higgs mass peak observables
    10                0.00000000               # chi^2 from mass-centered observables
    11              112.37328414               # chi^2 from signal strength (total)
    12              116.33372072               # chi^2 (total)
    13                0.00616809               # Probability (total chi^2, total number observables)
 BLOCK HiggsSignalsPeakObservables
 #  OBS   FLAG                         VALUE   # DESCRIPTION
      1     1                      201406002   # Analysis ID
      1     2     ||ATL-CONF-2014-060||        # Reference to publication
      1     3     ||(pp)->h->WW->lnulnu(VBFenhanced)||      # Description (Search channel)
      1     4                           8.00   # Center-of-mass energy
      1     5                          24.80   # Luminosity
      1     6                           2.80   # Luminosity uncertainty (in %)
      1     7                           8.00   # Mass resolution (GeV)
      1     8                         125.36   # Mass value at peak position (in GeV)
      1     9                         1.2700   # Observed signal strength modifier (mu)
      1    10                         0.4500   # Lower 68%C.L. uncertainty on observed mu
      1    11                         0.5300   # Upper 68%C.L. uncertainty on observed mu
      1    12                            001   # Assigned Higgs combination
      1    13                              1   # Index of dominant Higgs boson
      1    14                             25   # pdg number of dominant Higgs boson
      1    15                       122.6512   # Mass of dominant Higgs boson
      1    16                         0.8080   # Signal strength modifier of dominant Higgs boson
      1    17                         0.8080   # Total predicted signal strength modifier mu
      1    18                         0.9060   # Chi-squared value (mu-part)
      1    19                         0.0000   # Chi-squared value (mh-part)
      1    20                         0.9060   # Chi-squared value (total)
      1    21                         8.0463   # Chi-squared value for no predicted signal (mu=0)
      2     1                      201406001   # Analysis ID
      2     2     ||ATL-CONF-2014-060||        # Reference to publication
      2     3     ||(pp)->h->WW->lnulnu(ggFenhanced)||      # Description (Search channel)
      2     4                           8.00   # Center-of-mass energy
      2     5                          24.80   # Luminosity
      2     6                           2.80   # Luminosity uncertainty (in %)
      2     7                           8.00   # Mass resolution (GeV)
      2     8                         125.36   # Mass value at peak position (in GeV)
      2     9                         1.0100   # Observed signal strength modifier (mu)
      2    10                         0.2500   # Lower 68%C.L. uncertainty on observed mu
      2    11                         0.2700   # Upper 68%C.L. uncertainty on observed mu
      2    12                            001   # Assigned Higgs combination
      2    13                              1   # Index of dominant Higgs boson
      2    14                             25   # pdg number of dominant Higgs boson
      2    15                       122.6512   # Mass of dominant Higgs boson
      2    16                         0.7074   # Signal strength modifier of dominant Higgs boson
      2    17                         0.7074   # Total predicted signal strength modifier mu
      2    18                         1.1159   # Chi-squared value (mu-part)
      2    19                         0.0000   # Chi-squared value (mh-part)
      2    20                         1.1159   # Chi-squared value (total)
      2    21                        17.9750   # Chi-squared value for no predicted signal (mu=0)
      3     1                         519103   # Analysis ID
      3     2     ||arXiv:1408.5191||        # Reference to publication
      3     3     ||(pp)->h->ZZ->4l(VBF/VH-like)||      # Description (Search channel)
      3     4                           8.00   # Center-of-mass energy
      3     5                          25.30   # Luminosity
      3     6                           2.80   # Luminosity uncertainty (in %)
      3     7                           2.00   # Mass resolution (GeV)
      3     8                         125.36   # Mass value at peak position (in GeV)
      3     9                         0.2600   # Observed signal strength modifier (mu)
      3    10                         0.9400   # Lower 68%C.L. uncertainty on observed mu
      3    11                         1.6400   # Upper 68%C.L. uncertainty on observed mu
      3    12                            001   # Assigned Higgs combination
      3    13                              1   # Index of dominant Higgs boson
      3    14                             25   # pdg number of dominant Higgs boson
      3    15                       122.6512   # Mass of dominant Higgs boson
      3    16                         0.7654   # Signal strength modifier of dominant Higgs boson
      3    17                         0.7654   # Total predicted signal strength modifier mu
      3    18                         0.1028   # Chi-squared value (mu-part)
      3    19                         0.0000   # Chi-squared value (mh-part)
      3    20                         0.1028   # Chi-squared value (total)
      3    21                         0.0764   # Chi-squared value for no predicted signal (mu=0)
      4     1                         519102   # Analysis ID
      4     2     ||arXiv:1408.5191||        # Reference to publication
      4     3     ||(pp)->h->ZZ->4l(ggH-like)||      # Description (Search channel)
      4     4                           8.00   # Center-of-mass energy
      4     5                          24.80   # Luminosity
      4     6                           2.80   # Luminosity uncertainty (in %)
      4     7                           0.52   # Mass resolution (GeV)
      4     8                         124.51   # Mass value at peak position (in GeV)
      4     9                         1.6600   # Observed signal strength modifier (mu)
      4    10                         0.4400   # Lower 68%C.L. uncertainty on observed mu
      4    11                         0.5100   # Upper 68%C.L. uncertainty on observed mu
      4    12                            001   # Assigned Higgs combination
      4    13                              1   # Index of dominant Higgs boson
      4    14                             25   # pdg number of dominant Higgs boson
      4    15                       122.6512   # Mass of dominant Higgs boson
      4    16                         0.6939   # Signal strength modifier of dominant Higgs boson
      4    17                         0.6939   # Total predicted signal strength modifier mu
      4    18                         4.8733   # Chi-squared value (mu-part)
      4    19                         0.1657   # Chi-squared value (mh-part)
      4    20                         5.0390   # Chi-squared value (total)
      4    21                        16.0800   # Chi-squared value for no predicted signal (mu=0)
      5     1                         708405   # Analysis ID
      5     2     ||arXiv:1408.7084||        # Reference to publication
      5     3     ||(pp)->h->gammagamma(VBF-loose)||      # Description (Search channel)
      5     4                           8.00   # Center-of-mass energy
      5     5                          20.30   # Luminosity
      5     6                           2.80   # Luminosity uncertainty (in %)
      5     7                           2.00   # Mass resolution (GeV)
      5     8                         125.40   # Mass value at peak position (in GeV)
      5     9                         1.3270   # Observed signal strength modifier (mu)
      5    10                         0.7732   # Lower 68%C.L. uncertainty on observed mu
      5    11                         0.9150   # Upper 68%C.L. uncertainty on observed mu
      5    12                            000   # Assigned Higgs combination
      5    13                              0   # Index of dominant Higgs boson
      5    14                            NaN   # pdg number of dominant Higgs boson
      5    15                            NaN   # Mass of the dominant Higgs boson
      5    16                            NaN   # Signal strength modifier of the dominant Higgs boson
      5    17                         0.0000   # Total predicted signal strength modifier mu
      5    18                         2.9708   # Chi-squared value (mu-part)
      5    19                         0.0000   # Chi-squared value (mh-part)
      5    20                         2.9708   # Chi-squared value (total)
      5    21                         2.9708   # Chi-squared value for no predicted signal (mu=0)
      6     1                         708406   # Analysis ID
      6     2     ||arXiv:1408.7084||        # Reference to publication
      6     3     ||(pp)->h->gammagamma(VBF-tight)||      # Description (Search channel)
      6     4                           8.00   # Center-of-mass energy
      6     5                          20.30   # Luminosity
      6     6                           2.80   # Luminosity uncertainty (in %)
      6     7                           2.00   # Mass resolution (GeV)
      6     8                         125.40   # Mass value at peak position (in GeV)
      6     9                         0.6820   # Observed signal strength modifier (mu)
      6    10                         0.5082   # Lower 68%C.L. uncertainty on observed mu
      6    11                         0.6670   # Upper 68%C.L. uncertainty on observed mu
      6    12                            000   # Assigned Higgs combination
      6    13                              0   # Index of dominant Higgs boson
      6    14                            NaN   # pdg number of dominant Higgs boson
      6    15                            NaN   # Mass of the dominant Higgs boson
      6    16                            NaN   # Signal strength modifier of the dominant Higgs boson
      6    17                         0.0000   # Total predicted signal strength modifier mu
      6    18                         1.8075   # Chi-squared value (mu-part)
      6    19                         0.0000   # Chi-squared value (mh-part)
      6    20                         1.8075   # Chi-squared value (total)
      6    21                         1.8075   # Chi-squared value for no predicted signal (mu=0)
      7     1                         708408   # Analysis ID
      7     2     ||arXiv:1408.7084||        # Reference to publication
      7     3     ||(pp)->h->gammagamma(VH-ETmiss)||      # Description (Search channel)
      7     4                           8.00   # Center-of-mass energy
      7     5                          20.30   # Luminosity
      7     6                           2.80   # Luminosity uncertainty (in %)
      7     7                           1.56   # Mass resolution (GeV)
      7     8                         125.40   # Mass value at peak position (in GeV)
      7     9                         3.5100   # Observed signal strength modifier (mu)
      7    10                         2.4170   # Lower 68%C.L. uncertainty on observed mu
      7    11                         3.3040   # Upper 68%C.L. uncertainty on observed mu
      7    12                            000   # Assigned Higgs combination
      7    13                              0   # Index of dominant Higgs boson
      7    14                            NaN   # pdg number of dominant Higgs boson
      7    15                            NaN   # Mass of the dominant Higgs boson
      7    16                            NaN   # Signal strength modifier of the dominant Higgs boson
      7    17                         0.0000   # Total predicted signal strength modifier mu
      7    18                         2.1147   # Chi-squared value (mu-part)
      7    19                         0.0000   # Chi-squared value (mh-part)
      7    20                         2.1147   # Chi-squared value (total)
      7    21                         2.1147   # Chi-squared value for no predicted signal (mu=0)
      8     1                         708407   # Analysis ID
      8     2     ||arXiv:1408.7084||        # Reference to publication
      8     3     ||(pp)->h->gammagamma(VH-dijet)||      # Description (Search channel)
      8     4                           8.00   # Center-of-mass energy
      8     5                          20.30   # Luminosity
      8     6                           2.80   # Luminosity uncertainty (in %)
      8     7                           2.00   # Mass resolution (GeV)
      8     8                         125.40   # Mass value at peak position (in GeV)
      8     9                         0.2268   # Observed signal strength modifier (mu)
      8    10                         1.3878   # Lower 68%C.L. uncertainty on observed mu
      8    11                         1.6742   # Upper 68%C.L. uncertainty on observed mu
      8    12                            000   # Assigned Higgs combination
      8    13                              0   # Index of dominant Higgs boson
      8    14                            NaN   # pdg number of dominant Higgs boson
      8    15                            NaN   # Mass of the dominant Higgs boson
      8    16                            NaN   # Signal strength modifier of the dominant Higgs boson
      8    17                         0.0000   # Total predicted signal strength modifier mu
      8    18                         0.0267   # Chi-squared value (mu-part)
      8    19                         0.0000   # Chi-squared value (mh-part)
      8    20                         0.0267   # Chi-squared value (total)
      8    21                         0.0267   # Chi-squared value for no predicted signal (mu=0)
      9     1                         708409   # Analysis ID
      9     2     ||arXiv:1408.7084||        # Reference to publication
      9     3     ||(pp)->h->gammagamma(VH-onelepton)||      # Description (Search channel)
      9     4                           8.00   # Center-of-mass energy
      9     5                          20.30   # Luminosity
      9     6                           2.80   # Luminosity uncertainty (in %)
      9     7                           2.00   # Mass resolution (GeV)
      9     8                         125.40   # Mass value at peak position (in GeV)
      9     9                         0.4080   # Observed signal strength modifier (mu)
      9    10                         1.0560   # Lower 68%C.L. uncertainty on observed mu
      9    11                         1.4270   # Upper 68%C.L. uncertainty on observed mu
      9    12                            000   # Assigned Higgs combination
      9    13                              0   # Index of dominant Higgs boson
      9    14                            NaN   # pdg number of dominant Higgs boson
      9    15                            NaN   # Mass of the dominant Higgs boson
      9    16                            NaN   # Signal strength modifier of the dominant Higgs boson
      9    17                         0.0000   # Total predicted signal strength modifier mu
      9    18                         0.1493   # Chi-squared value (mu-part)
      9    19                         0.0000   # Chi-squared value (mh-part)
      9    20                         0.1493   # Chi-squared value (total)
      9    21                         0.1493   # Chi-squared value for no predicted signal (mu=0)
     10     1                         708402   # Analysis ID
     10     2     ||arXiv:1408.7084||        # Reference to publication
     10     3     ||(pp)->h->gammagamma(central-highpT)||      # Description (Search channel)
     10     4                           8.00   # Center-of-mass energy
     10     5                          20.30   # Luminosity
     10     6                           2.80   # Luminosity uncertainty (in %)
     10     7                           2.00   # Mass resolution (GeV)
     10     8                         125.40   # Mass value at peak position (in GeV)
     10     9                         1.6190   # Observed signal strength modifier (mu)
     10    10                         0.8311   # Lower 68%C.L. uncertainty on observed mu
     10    11                         1.0030   # Upper 68%C.L. uncertainty on observed mu
     10    12                            000   # Assigned Higgs combination
     10    13                              0   # Index of dominant Higgs boson
     10    14                            NaN   # pdg number of dominant Higgs boson
     10    15                            NaN   # Mass of the dominant Higgs boson
     10    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     10    17                         0.0000   # Total predicted signal strength modifier mu
     10    18                         3.8902   # Chi-squared value (mu-part)
     10    19                         0.0000   # Chi-squared value (mh-part)
     10    20                         3.8902   # Chi-squared value (total)
     10    21                         3.8902   # Chi-squared value for no predicted signal (mu=0)
     11     1                         708401   # Analysis ID
     11     2     ||arXiv:1408.7084||        # Reference to publication
     11     3     ||(pp)->h->gammagamma(central-lowpT)||      # Description (Search channel)
     11     4                           8.00   # Center-of-mass energy
     11     5                          20.30   # Luminosity
     11     6                           2.80   # Luminosity uncertainty (in %)
     11     7                           0.50   # Mass resolution (GeV)
     11     8                         125.98   # Mass value at peak position (in GeV)
     11     9                         0.6244   # Observed signal strength modifier (mu)
     11    10                         0.3976   # Lower 68%C.L. uncertainty on observed mu
     11    11                         0.4246   # Upper 68%C.L. uncertainty on observed mu
     11    12                            000   # Assigned Higgs combination
     11    13                              0   # Index of dominant Higgs boson
     11    14                            NaN   # pdg number of dominant Higgs boson
     11    15                            NaN   # Mass of the dominant Higgs boson
     11    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     11    17                         0.0000   # Total predicted signal strength modifier mu
     11    18                         2.5294   # Chi-squared value (mu-part)
     11    19                         0.0000   # Chi-squared value (mh-part)
     11    20                         2.5294   # Chi-squared value (total)
     11    21                         2.5294   # Chi-squared value for no predicted signal (mu=0)
     12     1                         708404   # Analysis ID
     12     2     ||arXiv:1408.7084||        # Reference to publication
     12     3     ||(pp)->h->gammagamma(forward-highpT)||      # Description (Search channel)
     12     4                           8.00   # Center-of-mass energy
     12     5                          20.30   # Luminosity
     12     6                           2.80   # Luminosity uncertainty (in %)
     12     7                           2.00   # Mass resolution (GeV)
     12     8                         125.40   # Mass value at peak position (in GeV)
     12     9                         1.7290   # Observed signal strength modifier (mu)
     12    10                         1.1800   # Lower 68%C.L. uncertainty on observed mu
     12    11                         1.3430   # Upper 68%C.L. uncertainty on observed mu
     12    12                            000   # Assigned Higgs combination
     12    13                              0   # Index of dominant Higgs boson
     12    14                            NaN   # pdg number of dominant Higgs boson
     12    15                            NaN   # Mass of the dominant Higgs boson
     12    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     12    17                         0.0000   # Total predicted signal strength modifier mu
     12    18                         2.1763   # Chi-squared value (mu-part)
     12    19                         0.0000   # Chi-squared value (mh-part)
     12    20                         2.1763   # Chi-squared value (total)
     12    21                         2.1763   # Chi-squared value for no predicted signal (mu=0)
     13     1                         708403   # Analysis ID
     13     2     ||arXiv:1408.7084||        # Reference to publication
     13     3     ||(pp)->h->gammagamma(forward-lowpT)||      # Description (Search channel)
     13     4                           8.00   # Center-of-mass energy
     13     5                          20.30   # Luminosity
     13     6                           2.80   # Luminosity uncertainty (in %)
     13     7                           2.00   # Mass resolution (GeV)
     13     8                         125.40   # Mass value at peak position (in GeV)
     13     9                         2.0340   # Observed signal strength modifier (mu)
     13    10                         0.5260   # Lower 68%C.L. uncertainty on observed mu
     13    11                         0.5700   # Upper 68%C.L. uncertainty on observed mu
     13    12                            000   # Assigned Higgs combination
     13    13                              0   # Index of dominant Higgs boson
     13    14                            NaN   # pdg number of dominant Higgs boson
     13    15                            NaN   # Mass of the dominant Higgs boson
     13    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     13    17                         0.0000   # Total predicted signal strength modifier mu
     13    18                        17.5779   # Chi-squared value (mu-part)
     13    19                         0.0000   # Chi-squared value (mh-part)
     13    20                        17.5779   # Chi-squared value (total)
     13    21                        17.5779   # Chi-squared value for no predicted signal (mu=0)
     14     1                         708410   # Analysis ID
     14     2     ||arXiv:1408.7084||        # Reference to publication
     14     3     ||(pp)->h->gammagamma(ttH-hadronic)||      # Description (Search channel)
     14     4                           8.00   # Center-of-mass energy
     14     5                          20.30   # Luminosity
     14     6                           2.80   # Luminosity uncertainty (in %)
     14     7                           2.00   # Mass resolution (GeV)
     14     8                         125.40   # Mass value at peak position (in GeV)
     14     9                        -0.8424   # Observed signal strength modifier (mu)
     14    10                         1.2503   # Lower 68%C.L. uncertainty on observed mu
     14    11                         3.2294   # Upper 68%C.L. uncertainty on observed mu
     14    12                            000   # Assigned Higgs combination
     14    13                              0   # Index of dominant Higgs boson
     14    14                            NaN   # pdg number of dominant Higgs boson
     14    15                            NaN   # Mass of the dominant Higgs boson
     14    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     14    17                         0.0000   # Total predicted signal strength modifier mu
     14    18                         0.0681   # Chi-squared value (mu-part)
     14    19                         0.0000   # Chi-squared value (mh-part)
     14    20                         0.0681   # Chi-squared value (total)
     14    21                         0.0681   # Chi-squared value for no predicted signal (mu=0)
     15     1                         708411   # Analysis ID
     15     2     ||arXiv:1408.7084||        # Reference to publication
     15     3     ||(pp)->h->gammagamma(ttH-leptonic)||      # Description (Search channel)
     15     4                           8.00   # Center-of-mass energy
     15     5                          20.30   # Luminosity
     15     6                           2.80   # Luminosity uncertainty (in %)
     15     7                           2.00   # Mass resolution (GeV)
     15     8                         125.40   # Mass value at peak position (in GeV)
     15     9                         2.4230   # Observed signal strength modifier (mu)
     15    10                         2.0681   # Lower 68%C.L. uncertainty on observed mu
     15    11                         3.2120   # Upper 68%C.L. uncertainty on observed mu
     15    12                            000   # Assigned Higgs combination
     15    13                              0   # Index of dominant Higgs boson
     15    14                            NaN   # pdg number of dominant Higgs boson
     15    15                            NaN   # Mass of the dominant Higgs boson
     15    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     15    17                         0.0000   # Total predicted signal strength modifier mu
     15    18                         1.3851   # Chi-squared value (mu-part)
     15    19                         0.0000   # Chi-squared value (mh-part)
     15    20                         1.3851   # Chi-squared value (total)
     15    21                         1.3851   # Chi-squared value for no predicted signal (mu=0)
     16     1                      201406106   # Analysis ID
     16     2     ||ATLAS-CONF-2014-061||        # Reference to publication
     16     3     ||(pp)->h->tautau(VBF,hadhad)||      # Description (Search channel)
     16     4                           8.00   # Center-of-mass energy
     16     5                          24.80   # Luminosity
     16     6                           2.80   # Luminosity uncertainty (in %)
     16     7                          20.00   # Mass resolution (GeV)
     16     8                         125.36   # Mass value at peak position (in GeV)
     16     9                         1.4000   # Observed signal strength modifier (mu)
     16    10                         0.7000   # Lower 68%C.L. uncertainty on observed mu
     16    11                         0.9000   # Upper 68%C.L. uncertainty on observed mu
     16    12                            001   # Assigned Higgs combination
     16    13                              1   # Index of dominant Higgs boson
     16    14                             25   # pdg number of dominant Higgs boson
     16    15                       122.6512   # Mass of dominant Higgs boson
     16    16                         1.0965   # Signal strength modifier of dominant Higgs boson
     16    17                         1.0965   # Total predicted signal strength modifier mu
     16    18                         0.0676   # Chi-squared value (mu-part)
     16    19                         0.0000   # Chi-squared value (mh-part)
     16    20                         0.0676   # Chi-squared value (total)
     16    21                         4.0180   # Chi-squared value for no predicted signal (mu=0)
     17     1                      201406105   # Analysis ID
     17     2     ||ATLAS-CONF-2014-061||        # Reference to publication
     17     3     ||(pp)->h->tautau(boosted,hadhad)||      # Description (Search channel)
     17     4                           8.00   # Center-of-mass energy
     17     5                          24.80   # Luminosity
     17     6                           2.80   # Luminosity uncertainty (in %)
     17     7                          20.00   # Mass resolution (GeV)
     17     8                         125.36   # Mass value at peak position (in GeV)
     17     9                         3.6000   # Observed signal strength modifier (mu)
     17    10                         1.6000   # Lower 68%C.L. uncertainty on observed mu
     17    11                         2.0000   # Upper 68%C.L. uncertainty on observed mu
     17    12                            001   # Assigned Higgs combination
     17    13                              1   # Index of dominant Higgs boson
     17    14                             25   # pdg number of dominant Higgs boson
     17    15                       122.6512   # Mass of dominant Higgs boson
     17    16                         1.0235   # Signal strength modifier of dominant Higgs boson
     17    17                         1.0235   # Total predicted signal strength modifier mu
     17    18                         2.3090   # Chi-squared value (mu-part)
     17    19                         0.0000   # Chi-squared value (mh-part)
     17    20                         2.3090   # Chi-squared value (total)
     17    21                         5.2142   # Chi-squared value for no predicted signal (mu=0)
     18     1                      201406104   # Analysis ID
     18     2     ||ATLAS-CONF-2014-061||        # Reference to publication
     18     3     ||(pp)->h->tautau(VBF,lephad)||      # Description (Search channel)
     18     4                           8.00   # Center-of-mass energy
     18     5                          24.80   # Luminosity
     18     6                           2.80   # Luminosity uncertainty (in %)
     18     7                          20.00   # Mass resolution (GeV)
     18     8                         125.36   # Mass value at peak position (in GeV)
     18     9                         1.0000   # Observed signal strength modifier (mu)
     18    10                         0.5000   # Lower 68%C.L. uncertainty on observed mu
     18    11                         0.6000   # Upper 68%C.L. uncertainty on observed mu
     18    12                            001   # Assigned Higgs combination
     18    13                              1   # Index of dominant Higgs boson
     18    14                             25   # pdg number of dominant Higgs boson
     18    15                       122.6512   # Mass of dominant Higgs boson
     18    16                         1.1211   # Signal strength modifier of dominant Higgs boson
     18    17                         1.1211   # Total predicted signal strength modifier mu
     18    18                         0.0956   # Chi-squared value (mu-part)
     18    19                         0.0000   # Chi-squared value (mh-part)
     18    20                         0.0956   # Chi-squared value (total)
     18    21                         3.9914   # Chi-squared value for no predicted signal (mu=0)
     19     1                      201406103   # Analysis ID
     19     2     ||ATL-CONF-2014-061||        # Reference to publication
     19     3     ||(pp)->h->tautau(boosted,lephad)||      # Description (Search channel)
     19     4                           8.00   # Center-of-mass energy
     19     5                          24.80   # Luminosity
     19     6                           2.80   # Luminosity uncertainty (in %)
     19     7                          20.00   # Mass resolution (GeV)
     19     8                         125.36   # Mass value at peak position (in GeV)
     19     9                         0.9000   # Observed signal strength modifier (mu)
     19    10                         0.9000   # Lower 68%C.L. uncertainty on observed mu
     19    11                         1.0000   # Upper 68%C.L. uncertainty on observed mu
     19    12                            001   # Assigned Higgs combination
     19    13                              1   # Index of dominant Higgs boson
     19    14                             25   # pdg number of dominant Higgs boson
     19    15                       122.6512   # Mass of dominant Higgs boson
     19    16                         1.0168   # Signal strength modifier of dominant Higgs boson
     19    17                         1.0168   # Total predicted signal strength modifier mu
     19    18                         0.0537   # Chi-squared value (mu-part)
     19    19                         0.0000   # Chi-squared value (mh-part)
     19    20                         0.0537   # Chi-squared value (total)
     19    21                         0.9988   # Chi-squared value for no predicted signal (mu=0)
     20     1                      201406102   # Analysis ID
     20     2     ||ATL-CONF-2014-061||        # Reference to publication
     20     3     ||(pp)->h->tautau(VBF,leplep)||      # Description (Search channel)
     20     4                           8.00   # Center-of-mass energy
     20     5                          24.80   # Luminosity
     20     6                           2.80   # Luminosity uncertainty (in %)
     20     7                          20.00   # Mass resolution (GeV)
     20     8                         125.36   # Mass value at peak position (in GeV)
     20     9                         1.8000   # Observed signal strength modifier (mu)
     20    10                         0.9000   # Lower 68%C.L. uncertainty on observed mu
     20    11                         1.1000   # Upper 68%C.L. uncertainty on observed mu
     20    12                            001   # Assigned Higgs combination
     20    13                              1   # Index of dominant Higgs boson
     20    14                             25   # pdg number of dominant Higgs boson
     20    15                       122.6512   # Mass of dominant Higgs boson
     20    16                         1.1245   # Signal strength modifier of dominant Higgs boson
     20    17                         1.1245   # Total predicted signal strength modifier mu
     20    18                         0.4413   # Chi-squared value (mu-part)
     20    19                         0.0000   # Chi-squared value (mh-part)
     20    20                         0.4413   # Chi-squared value (total)
     20    21                         4.0219   # Chi-squared value for no predicted signal (mu=0)
     21     1                      201406101   # Analysis ID
     21     2     ||ATL-CONF-2014-061||        # Reference to publication
     21     3     ||(pp)->h->tautau(boosted,leplep)||      # Description (Search channel)
     21     4                           8.00   # Center-of-mass energy
     21     5                          24.80   # Luminosity
     21     6                           2.80   # Luminosity uncertainty (in %)
     21     7                          20.00   # Mass resolution (GeV)
     21     8                         125.36   # Mass value at peak position (in GeV)
     21     9                         3.0000   # Observed signal strength modifier (mu)
     21    10                         1.7000   # Lower 68%C.L. uncertainty on observed mu
     21    11                         1.9000   # Upper 68%C.L. uncertainty on observed mu
     21    12                            001   # Assigned Higgs combination
     21    13                              1   # Index of dominant Higgs boson
     21    14                             25   # pdg number of dominant Higgs boson
     21    15                       122.6512   # Mass of dominant Higgs boson
     21    16                         1.0204   # Signal strength modifier of dominant Higgs boson
     21    17                         1.0204   # Total predicted signal strength modifier mu
     21    18                         1.0228   # Chi-squared value (mu-part)
     21    19                         0.0000   # Chi-squared value (mh-part)
     21    20                         1.0228   # Chi-squared value (total)
     21    21                         3.1714   # Chi-squared value for no predicted signal (mu=0)
     22     1                         621201   # Analysis ID
     22     2     ||arXiv:1409.6212||        # Reference to publication
     22     3     ||(pp)->Vh->Vbb(0lepton)||      # Description (Search channel)
     22     4                           8.00   # Center-of-mass energy
     22     5                          25.00   # Luminosity
     22     6                           2.80   # Luminosity uncertainty (in %)
     22     7                          15.00   # Mass resolution (GeV)
     22     8                         125.00   # Mass value at peak position (in GeV)
     22     9                        -0.3500   # Observed signal strength modifier (mu)
     22    10                         0.5200   # Lower 68%C.L. uncertainty on observed mu
     22    11                         0.5500   # Upper 68%C.L. uncertainty on observed mu
     22    12                            001   # Assigned Higgs combination
     22    13                              1   # Index of dominant Higgs boson
     22    14                             25   # pdg number of dominant Higgs boson
     22    15                       122.6512   # Mass of dominant Higgs boson
     22    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     22    17                         1.1325   # Total predicted signal strength modifier mu
     22    18                         7.1209   # Chi-squared value (mu-part)
     22    19                         0.0000   # Chi-squared value (mh-part)
     22    20                         7.1209   # Chi-squared value (total)
     22    21                         0.4020   # Chi-squared value for no predicted signal (mu=0)
     23     1                         621202   # Analysis ID
     23     2     ||arXiv:1409.6212||        # Reference to publication
     23     3     ||(pp)->Vh->Vbb(1lepton)||      # Description (Search channel)
     23     4                           8.00   # Center-of-mass energy
     23     5                          25.00   # Luminosity
     23     6                           2.60   # Luminosity uncertainty (in %)
     23     7                          15.00   # Mass resolution (GeV)
     23     8                         125.00   # Mass value at peak position (in GeV)
     23     9                         1.1700   # Observed signal strength modifier (mu)
     23    10                         0.6000   # Lower 68%C.L. uncertainty on observed mu
     23    11                         0.6600   # Upper 68%C.L. uncertainty on observed mu
     23    12                            001   # Assigned Higgs combination
     23    13                              1   # Index of dominant Higgs boson
     23    14                             25   # pdg number of dominant Higgs boson
     23    15                       122.6512   # Mass of dominant Higgs boson
     23    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     23    17                         1.1325   # Total predicted signal strength modifier mu
     23    18                         0.0009   # Chi-squared value (mu-part)
     23    19                         0.0000   # Chi-squared value (mh-part)
     23    20                         0.0009   # Chi-squared value (total)
     23    21                         3.8027   # Chi-squared value for no predicted signal (mu=0)
     24     1                         621203   # Analysis ID
     24     2     ||arXiv:1409.6212||        # Reference to publication
     24     3     ||(pp)->Vh->Vbb(2lepton)||      # Description (Search channel)
     24     4                           8.00   # Center-of-mass energy
     24     5                          25.00   # Luminosity
     24     6                           2.80   # Luminosity uncertainty (in %)
     24     7                          15.00   # Mass resolution (GeV)
     24     8                         125.00   # Mass value at peak position (in GeV)
     24     9                         0.9400   # Observed signal strength modifier (mu)
     24    10                         0.7900   # Lower 68%C.L. uncertainty on observed mu
     24    11                         0.8800   # Upper 68%C.L. uncertainty on observed mu
     24    12                            001   # Assigned Higgs combination
     24    13                              1   # Index of dominant Higgs boson
     24    14                             25   # pdg number of dominant Higgs boson
     24    15                       122.6512   # Mass of dominant Higgs boson
     24    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     24    17                         1.1325   # Total predicted signal strength modifier mu
     24    18                         0.0528   # Chi-squared value (mu-part)
     24    19                         0.0000   # Chi-squared value (mh-part)
     24    20                         0.0528   # Chi-squared value (total)
     24    21                         1.4138   # Chi-squared value for no predicted signal (mu=0)
     25     1                      201307501   # Analysis ID
     25     2     ||ATL-CONF-2013-075||        # Reference to publication
     25     3     ||(pp)->Vh->VWW||      # Description (Search channel)
     25     4                           8.00   # Center-of-mass energy
     25     5                          25.40   # Luminosity
     25     6                           4.40   # Luminosity uncertainty (in %)
     25     7                          25.00   # Mass resolution (GeV)
     25     8                         125.00   # Mass value at peak position (in GeV)
     25     9                         3.7000   # Observed signal strength modifier (mu)
     25    10                         2.0000   # Lower 68%C.L. uncertainty on observed mu
     25    11                         1.9000   # Upper 68%C.L. uncertainty on observed mu
     25    12                            001   # Assigned Higgs combination
     25    13                              1   # Index of dominant Higgs boson
     25    14                             25   # pdg number of dominant Higgs boson
     25    15                       122.6512   # Mass of dominant Higgs boson
     25    16                         0.8413   # Signal strength modifier of dominant Higgs boson
     25    17                         0.8413   # Total predicted signal strength modifier mu
     25    18                         1.8960   # Chi-squared value (mu-part)
     25    19                         0.0000   # Chi-squared value (mh-part)
     25    20                         1.8960   # Chi-squared value (total)
     25    21                         3.4351   # Chi-squared value for no predicted signal (mu=0)
     26     1                      130166683   # Analysis ID
     26     2     ||arXiv:1301.6668||        # Reference to publication
     26     3     ||(ppbar)->h->WW||      # Description (Search channel)
     26     4                           1.96   # Center-of-mass energy
     26     5                           9.70   # Luminosity
     26     6                           6.00   # Luminosity uncertainty (in %)
     26     7                          30.00   # Mass resolution (GeV)
     26     8                         125.00   # Mass value at peak position (in GeV)
     26     9                         0.0000   # Observed signal strength modifier (mu)
     26    10                         1.7800   # Lower 68%C.L. uncertainty on observed mu
     26    11                         1.7800   # Upper 68%C.L. uncertainty on observed mu
     26    12                            001   # Assigned Higgs combination
     26    13                              1   # Index of dominant Higgs boson
     26    14                             25   # pdg number of dominant Higgs boson
     26    15                       122.6512   # Mass of dominant Higgs boson
     26    16                         0.7351   # Signal strength modifier of dominant Higgs boson
     26    17                         0.7351   # Total predicted signal strength modifier mu
     26    18                         0.1848   # Chi-squared value (mu-part)
     26    19                         0.0000   # Chi-squared value (mh-part)
     26    20                         0.1848   # Chi-squared value (total)
     26    21                         0.0000   # Chi-squared value for no predicted signal (mu=0)
     27     1                      130166682   # Analysis ID
     27     2     ||arXiv:1301.6668||        # Reference to publication
     27     3     ||(ppbar)->h->gammagamma||      # Description (Search channel)
     27     4                           1.96   # Center-of-mass energy
     27     5                           9.70   # Luminosity
     27     6                           6.00   # Luminosity uncertainty (in %)
     27     7                           5.00   # Mass resolution (GeV)
     27     8                         125.00   # Mass value at peak position (in GeV)
     27     9                         7.8100   # Observed signal strength modifier (mu)
     27    10                         4.4200   # Lower 68%C.L. uncertainty on observed mu
     27    11                         4.6100   # Upper 68%C.L. uncertainty on observed mu
     27    12                            001   # Assigned Higgs combination
     27    13                              1   # Index of dominant Higgs boson
     27    14                             25   # pdg number of dominant Higgs boson
     27    15                       122.6512   # Mass of dominant Higgs boson
     27    16                         0.6591   # Signal strength modifier of dominant Higgs boson
     27    17                         0.6591   # Total predicted signal strength modifier mu
     27    18                         2.6223   # Chi-squared value (mu-part)
     27    19                         0.0000   # Chi-squared value (mh-part)
     27    20                         2.6223   # Chi-squared value (total)
     27    21                         3.1939   # Chi-squared value for no predicted signal (mu=0)
     28     1                      130166684   # Analysis ID
     28     2     ||arXiv:1301.6668||        # Reference to publication
     28     3     ||(ppbar)->h->tautau||      # Description (Search channel)
     28     4                           1.96   # Center-of-mass energy
     28     5                           9.70   # Luminosity
     28     6                           6.00   # Luminosity uncertainty (in %)
     28     7                          25.00   # Mass resolution (GeV)
     28     8                         125.00   # Mass value at peak position (in GeV)
     28     9                         0.0000   # Observed signal strength modifier (mu)
     28    10                         8.4400   # Lower 68%C.L. uncertainty on observed mu
     28    11                         8.4400   # Upper 68%C.L. uncertainty on observed mu
     28    12                            001   # Assigned Higgs combination
     28    13                              1   # Index of dominant Higgs boson
     28    14                             25   # pdg number of dominant Higgs boson
     28    15                       122.6512   # Mass of dominant Higgs boson
     28    16                         1.0080   # Signal strength modifier of dominant Higgs boson
     28    17                         1.0080   # Total predicted signal strength modifier mu
     28    18                         0.0154   # Chi-squared value (mu-part)
     28    19                         0.0000   # Chi-squared value (mh-part)
     28    20                         0.0154   # Chi-squared value (total)
     28    21                         0.0000   # Chi-squared value for no predicted signal (mu=0)
     29     1                      130166685   # Analysis ID
     29     2     ||arXiv:1301.6668||        # Reference to publication
     29     3     ||(ppbar)->Vh->Vbb||      # Description (Search channel)
     29     4                           1.96   # Center-of-mass energy
     29     5                           9.70   # Luminosity
     29     6                           6.00   # Luminosity uncertainty (in %)
     29     7                          20.00   # Mass resolution (GeV)
     29     8                         125.00   # Mass value at peak position (in GeV)
     29     9                         1.7200   # Observed signal strength modifier (mu)
     29    10                         0.8700   # Lower 68%C.L. uncertainty on observed mu
     29    11                         0.9200   # Upper 68%C.L. uncertainty on observed mu
     29    12                            001   # Assigned Higgs combination
     29    13                              1   # Index of dominant Higgs boson
     29    14                             25   # pdg number of dominant Higgs boson
     29    15                       122.6512   # Mass of dominant Higgs boson
     29    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     29    17                         1.1325   # Total predicted signal strength modifier mu
     29    18                         0.4462   # Chi-squared value (mu-part)
     29    19                         0.0000   # Chi-squared value (mh-part)
     29    20                         0.4462   # Chi-squared value (total)
     29    21                         3.9140   # Chi-squared value for no predicted signal (mu=0)
     30     1                      130166681   # Analysis ID
     30     2     ||arXiv:1301.6668||        # Reference to publication
     30     3     ||(ppbar)->tth->ttbb||      # Description (Search channel)
     30     4                           1.96   # Center-of-mass energy
     30     5                           9.70   # Luminosity
     30     6                           6.00   # Luminosity uncertainty (in %)
     30     7                          30.00   # Mass resolution (GeV)
     30     8                         125.00   # Mass value at peak position (in GeV)
     30     9                         9.4900   # Observed signal strength modifier (mu)
     30    10                         6.2800   # Lower 68%C.L. uncertainty on observed mu
     30    11                         6.6000   # Upper 68%C.L. uncertainty on observed mu
     30    12                            001   # Assigned Higgs combination
     30    13                              1   # Index of dominant Higgs boson
     30    14                             25   # pdg number of dominant Higgs boson
     30    15                       122.6512   # Mass of dominant Higgs boson
     30    16                         1.1282   # Signal strength modifier of dominant Higgs boson
     30    17                         1.1282   # Total predicted signal strength modifier mu
     30    18                         1.7735   # Chi-squared value (mu-part)
     30    19                         0.0000   # Chi-squared value (mh-part)
     30    20                         1.7735   # Chi-squared value (total)
     30    21                         2.3432   # Chi-squared value for no predicted signal (mu=0)
     31     1                      131211291   # Analysis ID
     31     2     ||arXiv:1312.1129||        # Reference to publication
     31     3     ||(pp)->h->WW->2l2nu(0/1jet)||      # Description (Search channel)
     31     4                           8.00   # Center-of-mass energy
     31     5                          25.30   # Luminosity
     31     6                           2.60   # Luminosity uncertainty (in %)
     31     7                          20.00   # Mass resolution (GeV)
     31     8                         125.60   # Mass value at peak position (in GeV)
     31     9                         0.7400   # Observed signal strength modifier (mu)
     31    10                         0.2000   # Lower 68%C.L. uncertainty on observed mu
     31    11                         0.2200   # Upper 68%C.L. uncertainty on observed mu
     31    12                            001   # Assigned Higgs combination
     31    13                              1   # Index of dominant Higgs boson
     31    14                             25   # pdg number of dominant Higgs boson
     31    15                       122.6512   # Mass of dominant Higgs boson
     31    16                         0.7238   # Signal strength modifier of dominant Higgs boson
     31    17                         0.7238   # Total predicted signal strength modifier mu
     31    18                        -0.0361   # Chi-squared value (mu-part)
     31    19                         0.0000   # Chi-squared value (mh-part)
     31    20                        -0.0361   # Chi-squared value (total)
     31    21                        13.8348   # Chi-squared value for no predicted signal (mu=0)
     32     1                      131211292   # Analysis ID
     32     2     ||arXiv:1312.1129||        # Reference to publication
     32     3     ||(pp)->h->WW->2l2nu(VBF)||      # Description (Search channel)
     32     4                           8.00   # Center-of-mass energy
     32     5                          25.30   # Luminosity
     32     6                           2.60   # Luminosity uncertainty (in %)
     32     7                          20.00   # Mass resolution (GeV)
     32     8                         125.60   # Mass value at peak position (in GeV)
     32     9                         0.6000   # Observed signal strength modifier (mu)
     32    10                         0.4600   # Lower 68%C.L. uncertainty on observed mu
     32    11                         0.5700   # Upper 68%C.L. uncertainty on observed mu
     32    12                            001   # Assigned Higgs combination
     32    13                              1   # Index of dominant Higgs boson
     32    14                             25   # pdg number of dominant Higgs boson
     32    15                       122.6512   # Mass of dominant Higgs boson
     32    16                         0.8080   # Signal strength modifier of dominant Higgs boson
     32    17                         0.8080   # Total predicted signal strength modifier mu
     32    18                         0.1624   # Chi-squared value (mu-part)
     32    19                         0.0000   # Chi-squared value (mh-part)
     32    20                         0.1624   # Chi-squared value (total)
     32    21                         1.6969   # Chi-squared value for no predicted signal (mu=0)
     33     1                        1400901   # Analysis ID
     33     2     ||CMS-PAS-HIG-14-009,arXiv:1312.5353||        # Reference to publication
     33     3     ||(pp)->h->ZZ->4l(0/1jet)||      # Description (Search channel)
     33     4                           8.00   # Center-of-mass energy
     33     5                          24.70   # Luminosity
     33     6                           2.80   # Luminosity uncertainty (in %)
     33     7                           0.45   # Mass resolution (GeV)
     33     8                         125.63   # Mass value at peak position (in GeV)
     33     9                         0.8830   # Observed signal strength modifier (mu)
     33    10                         0.2720   # Lower 68%C.L. uncertainty on observed mu
     33    11                         0.3360   # Upper 68%C.L. uncertainty on observed mu
     33    12                            000   # Assigned Higgs combination
     33    13                              0   # Index of dominant Higgs boson
     33    14                            NaN   # pdg number of dominant Higgs boson
     33    15                            NaN   # Mass of the dominant Higgs boson
     33    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     33    17                         0.0000   # Total predicted signal strength modifier mu
     33    18                        11.7565   # Chi-squared value (mu-part)
     33    19                         0.0000   # Chi-squared value (mh-part)
     33    20                        11.7565   # Chi-squared value (total)
     33    21                        11.7565   # Chi-squared value for no predicted signal (mu=0)
     34     1                        1400902   # Analysis ID
     34     2     ||CMS-PAS-HIG-14-009,arXiv:1312.5353||        # Reference to publication
     34     3     ||(pp)->h->ZZ->4l(2jet)||      # Description (Search channel)
     34     4                           8.00   # Center-of-mass energy
     34     5                          24.70   # Luminosity
     34     6                           4.40   # Luminosity uncertainty (in %)
     34     7                           2.00   # Mass resolution (GeV)
     34     8                         125.00   # Mass value at peak position (in GeV)
     34     9                         1.5490   # Observed signal strength modifier (mu)
     34    10                         0.6610   # Lower 68%C.L. uncertainty on observed mu
     34    11                         0.9530   # Upper 68%C.L. uncertainty on observed mu
     34    12                            000   # Assigned Higgs combination
     34    13                              0   # Index of dominant Higgs boson
     34    14                            NaN   # pdg number of dominant Higgs boson
     34    15                            NaN   # Mass of the dominant Higgs boson
     34    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     34    17                         0.0000   # Total predicted signal strength modifier mu
     34    18                         5.7125   # Chi-squared value (mu-part)
     34    19                         0.0000   # Chi-squared value (mh-part)
     34    20                         5.7125   # Chi-squared value (total)
     34    21                         5.7125   # Chi-squared value for no predicted signal (mu=0)
     35     1                          55805   # Analysis ID
     35     2     ||arXiv:1407.0558||        # Reference to publication
     35     3     ||(pp)->h->gammagamma(VBFdijet0)||      # Description (Search channel)
     35     4                           7.00   # Center-of-mass energy
     35     5                           5.10   # Luminosity
     35     6                           2.20   # Luminosity uncertainty (in %)
     35     7                           2.00   # Mass resolution (GeV)
     35     8                         124.70   # Mass value at peak position (in GeV)
     35     9                         4.8470   # Observed signal strength modifier (mu)
     35    10                         1.7590   # Lower 68%C.L. uncertainty on observed mu
     35    11                         2.1700   # Upper 68%C.L. uncertainty on observed mu
     35    12                            001   # Assigned Higgs combination
     35    13                              1   # Index of dominant Higgs boson
     35    14                             25   # pdg number of dominant Higgs boson
     35    15                       122.6512   # Mass of dominant Higgs boson
     35    16                         0.7296   # Signal strength modifier of dominant Higgs boson
     35    17                         0.7296   # Total predicted signal strength modifier mu
     35    18                         4.9774   # Chi-squared value (mu-part)
     35    19                         0.0000   # Chi-squared value (mh-part)
     35    20                         4.9774   # Chi-squared value (total)
     35    21                         7.7092   # Chi-squared value for no predicted signal (mu=0)
     36     1                          55816   # Analysis ID
     36     2     ||arXiv:1407.0558||        # Reference to publication
     36     3     ||(pp)->h->gammagamma(VBFdijet0)||      # Description (Search channel)
     36     4                           8.00   # Center-of-mass energy
     36     5                          19.60   # Luminosity
     36     6                           2.60   # Luminosity uncertainty (in %)
     36     7                           2.00   # Mass resolution (GeV)
     36     8                         124.70   # Mass value at peak position (in GeV)
     36     9                         0.8170   # Observed signal strength modifier (mu)
     36    10                         0.5780   # Lower 68%C.L. uncertainty on observed mu
     36    11                         0.7520   # Upper 68%C.L. uncertainty on observed mu
     36    12                            001   # Assigned Higgs combination
     36    13                              1   # Index of dominant Higgs boson
     36    14                             25   # pdg number of dominant Higgs boson
     36    15                       122.6512   # Mass of dominant Higgs boson
     36    16                         0.7323   # Signal strength modifier of dominant Higgs boson
     36    17                         0.7323   # Total predicted signal strength modifier mu
     36    18                         0.0211   # Chi-squared value (mu-part)
     36    19                         0.0000   # Chi-squared value (mh-part)
     36    20                         0.0211   # Chi-squared value (total)
     36    21                         1.9996   # Chi-squared value for no predicted signal (mu=0)
     37     1                          55806   # Analysis ID
     37     2     ||arXiv:1407.0558||        # Reference to publication
     37     3     ||(pp)->h->gammagamma(VBFdijet1)||      # Description (Search channel)
     37     4                           7.00   # Center-of-mass energy
     37     5                           5.10   # Luminosity
     37     6                           2.20   # Luminosity uncertainty (in %)
     37     7                           2.00   # Mass resolution (GeV)
     37     8                         124.70   # Mass value at peak position (in GeV)
     37     9                         2.6000   # Observed signal strength modifier (mu)
     37    10                         1.7570   # Lower 68%C.L. uncertainty on observed mu
     37    11                         2.1610   # Upper 68%C.L. uncertainty on observed mu
     37    12                            001   # Assigned Higgs combination
     37    13                              1   # Index of dominant Higgs boson
     37    14                             25   # pdg number of dominant Higgs boson
     37    15                       122.6512   # Mass of dominant Higgs boson
     37    16                         0.7059   # Signal strength modifier of dominant Higgs boson
     37    17                         0.7059   # Total predicted signal strength modifier mu
     37    18                         0.8237   # Chi-squared value (mu-part)
     37    19                         0.0000   # Chi-squared value (mh-part)
     37    20                         0.8237   # Chi-squared value (total)
     37    21                         2.2027   # Chi-squared value for no predicted signal (mu=0)
     38     1                          55817   # Analysis ID
     38     2     ||arXiv:1407.0558||        # Reference to publication
     38     3     ||(pp)->h->gammagamma(VBFdijet1)||      # Description (Search channel)
     38     4                           8.00   # Center-of-mass energy
     38     5                          19.60   # Luminosity
     38     6                           2.60   # Luminosity uncertainty (in %)
     38     7                           2.00   # Mass resolution (GeV)
     38     8                         124.70   # Mass value at peak position (in GeV)
     38     9                        -0.2090   # Observed signal strength modifier (mu)
     38    10                         0.6890   # Lower 68%C.L. uncertainty on observed mu
     38    11                         0.7460   # Upper 68%C.L. uncertainty on observed mu
     38    12                            001   # Assigned Higgs combination
     38    13                              1   # Index of dominant Higgs boson
     38    14                             25   # pdg number of dominant Higgs boson
     38    15                       122.6512   # Mass of dominant Higgs boson
     38    16                         0.7190   # Signal strength modifier of dominant Higgs boson
     38    17                         0.7190   # Total predicted signal strength modifier mu
     38    18                         1.7406   # Chi-squared value (mu-part)
     38    19                         0.0000   # Chi-squared value (mh-part)
     38    20                         1.7406   # Chi-squared value (total)
     38    21                         0.0783   # Chi-squared value for no predicted signal (mu=0)
     39     1                          55818   # Analysis ID
     39     2     ||arXiv:1407.0558||        # Reference to publication
     39     3     ||(pp)->h->gammagamma(VBFdijet2)||      # Description (Search channel)
     39     4                           8.00   # Center-of-mass energy
     39     5                          19.60   # Luminosity
     39     6                           2.60   # Luminosity uncertainty (in %)
     39     7                           2.00   # Mass resolution (GeV)
     39     8                         124.70   # Mass value at peak position (in GeV)
     39     9                         2.5960   # Observed signal strength modifier (mu)
     39    10                         0.9940   # Lower 68%C.L. uncertainty on observed mu
     39    11                         1.3260   # Upper 68%C.L. uncertainty on observed mu
     39    12                            001   # Assigned Higgs combination
     39    13                              1   # Index of dominant Higgs boson
     39    14                             25   # pdg number of dominant Higgs boson
     39    15                       122.6512   # Mass of dominant Higgs boson
     39    16                         0.7002   # Signal strength modifier of dominant Higgs boson
     39    17                         0.7002   # Total predicted signal strength modifier mu
     39    18                         3.5806   # Chi-squared value (mu-part)
     39    19                         0.0000   # Chi-squared value (mh-part)
     39    20                         3.5806   # Chi-squared value (total)
     39    21                         6.9631   # Chi-squared value for no predicted signal (mu=0)
     40     1                          55808   # Analysis ID
     40     2     ||arXiv:1407.0558||        # Reference to publication
     40     3     ||(pp)->h->gammagamma(VHETmiss)||      # Description (Search channel)
     40     4                           7.00   # Center-of-mass energy
     40     5                           5.10   # Luminosity
     40     6                           2.20   # Luminosity uncertainty (in %)
     40     7                           2.00   # Mass resolution (GeV)
     40     8                         124.70   # Mass value at peak position (in GeV)
     40     9                         4.3240   # Observed signal strength modifier (mu)
     40    10                         4.1520   # Lower 68%C.L. uncertainty on observed mu
     40    11                         6.7180   # Upper 68%C.L. uncertainty on observed mu
     40    12                            001   # Assigned Higgs combination
     40    13                              1   # Index of dominant Higgs boson
     40    14                             25   # pdg number of dominant Higgs boson
     40    15                       122.6512   # Mass of dominant Higgs boson
     40    16                         0.7482   # Signal strength modifier of dominant Higgs boson
     40    17                         0.7482   # Total predicted signal strength modifier mu
     40    18                         0.7141   # Chi-squared value (mu-part)
     40    19                         0.0000   # Chi-squared value (mh-part)
     40    20                         0.7141   # Chi-squared value (total)
     40    21                         1.0860   # Chi-squared value for no predicted signal (mu=0)
     41     1                          55821   # Analysis ID
     41     2     ||arXiv:1407.0558||        # Reference to publication
     41     3     ||(pp)->h->gammagamma(VHETmiss)||      # Description (Search channel)
     41     4                           8.00   # Center-of-mass energy
     41     5                          19.60   # Luminosity
     41     6                           2.60   # Luminosity uncertainty (in %)
     41     7                           2.00   # Mass resolution (GeV)
     41     8                         124.70   # Mass value at peak position (in GeV)
     41     9                         0.0760   # Observed signal strength modifier (mu)
     41    10                         1.2770   # Lower 68%C.L. uncertainty on observed mu
     41    11                         1.8620   # Upper 68%C.L. uncertainty on observed mu
     41    12                            001   # Assigned Higgs combination
     41    13                              1   # Index of dominant Higgs boson
     41    14                             25   # pdg number of dominant Higgs boson
     41    15                       122.6512   # Mass of dominant Higgs boson
     41    16                         0.7341   # Signal strength modifier of dominant Higgs boson
     41    17                         0.7341   # Total predicted signal strength modifier mu
     41    18                         0.1265   # Chi-squared value (mu-part)
     41    19                         0.0000   # Chi-squared value (mh-part)
     41    20                         0.1265   # Chi-squared value (total)
     41    21                         0.0035   # Chi-squared value for no predicted signal (mu=0)
     42     1                          55809   # Analysis ID
     42     2     ||arXiv:1407.0558||        # Reference to publication
     42     3     ||(pp)->h->gammagamma(VHdijet)||      # Description (Search channel)
     42     4                           7.00   # Center-of-mass energy
     42     5                           5.10   # Luminosity
     42     6                           2.20   # Luminosity uncertainty (in %)
     42     7                           2.00   # Mass resolution (GeV)
     42     8                         124.70   # Mass value at peak position (in GeV)
     42     9                         7.8550   # Observed signal strength modifier (mu)
     42    10                         6.3990   # Lower 68%C.L. uncertainty on observed mu
     42    11                         8.8550   # Upper 68%C.L. uncertainty on observed mu
     42    12                            001   # Assigned Higgs combination
     42    13                              1   # Index of dominant Higgs boson
     42    14                             25   # pdg number of dominant Higgs boson
     42    15                       122.6512   # Mass of dominant Higgs boson
     42    16                         0.7197   # Signal strength modifier of dominant Higgs boson
     42    17                         0.7197   # Total predicted signal strength modifier mu
     42    18                         1.1502   # Chi-squared value (mu-part)
     42    19                         0.0000   # Chi-squared value (mh-part)
     42    20                         1.1502   # Chi-squared value (total)
     42    21                         1.5109   # Chi-squared value for no predicted signal (mu=0)
     43     1                          55822   # Analysis ID
     43     2     ||arXiv:1407.0558||        # Reference to publication
     43     3     ||(pp)->h->gammagamma(VHdijet)||      # Description (Search channel)
     43     4                           8.00   # Center-of-mass energy
     43     5                          19.60   # Luminosity
     43     6                           2.60   # Luminosity uncertainty (in %)
     43     7                           2.00   # Mass resolution (GeV)
     43     8                         124.70   # Mass value at peak position (in GeV)
     43     9                         0.3920   # Observed signal strength modifier (mu)
     43    10                         1.4820   # Lower 68%C.L. uncertainty on observed mu
     43    11                         2.1580   # Upper 68%C.L. uncertainty on observed mu
     43    12                            001   # Assigned Higgs combination
     43    13                              1   # Index of dominant Higgs boson
     43    14                             25   # pdg number of dominant Higgs boson
     43    15                       122.6512   # Mass of dominant Higgs boson
     43    16                         0.7175   # Signal strength modifier of dominant Higgs boson
     43    17                         0.7175   # Total predicted signal strength modifier mu
     43    18                         0.0269   # Chi-squared value (mu-part)
     43    19                         0.0000   # Chi-squared value (mh-part)
     43    20                         0.0269   # Chi-squared value (total)
     43    21                         0.0699   # Chi-squared value for no predicted signal (mu=0)
     44     1                          55807   # Analysis ID
     44     2     ||arXiv:1407.0558||        # Reference to publication
     44     3     ||(pp)->h->gammagamma(VHloose)||      # Description (Search channel)
     44     4                           7.00   # Center-of-mass energy
     44     5                           5.10   # Luminosity
     44     6                           2.20   # Luminosity uncertainty (in %)
     44     7                           2.00   # Mass resolution (GeV)
     44     8                         124.70   # Mass value at peak position (in GeV)
     44     9                         3.1000   # Observed signal strength modifier (mu)
     44    10                         5.3420   # Lower 68%C.L. uncertainty on observed mu
     44    11                         8.2890   # Upper 68%C.L. uncertainty on observed mu
     44    12                            001   # Assigned Higgs combination
     44    13                              1   # Index of dominant Higgs boson
     44    14                             25   # pdg number of dominant Higgs boson
     44    15                       122.6512   # Mass of dominant Higgs boson
     44    16                         0.7497   # Signal strength modifier of dominant Higgs boson
     44    17                         0.7497   # Total predicted signal strength modifier mu
     44    18                         0.1855   # Chi-squared value (mu-part)
     44    19                         0.0000   # Chi-squared value (mh-part)
     44    20                         0.1855   # Chi-squared value (total)
     44    21                         0.3369   # Chi-squared value for no predicted signal (mu=0)
     45     1                          55820   # Analysis ID
     45     2     ||arXiv:1407.0558||        # Reference to publication
     45     3     ||(pp)->h->gammagamma(VHloose)||      # Description (Search channel)
     45     4                           8.00   # Center-of-mass energy
     45     5                          19.60   # Luminosity
     45     6                           2.60   # Luminosity uncertainty (in %)
     45     7                           2.00   # Mass resolution (GeV)
     45     8                         124.70   # Mass value at peak position (in GeV)
     45     9                         1.2430   # Observed signal strength modifier (mu)
     45    10                         2.6240   # Lower 68%C.L. uncertainty on observed mu
     45    11                         3.6940   # Upper 68%C.L. uncertainty on observed mu
     45    12                            001   # Assigned Higgs combination
     45    13                              1   # Index of dominant Higgs boson
     45    14                             25   # pdg number of dominant Higgs boson
     45    15                       122.6512   # Mass of dominant Higgs boson
     45    16                         0.7510   # Signal strength modifier of dominant Higgs boson
     45    17                         0.7510   # Total predicted signal strength modifier mu
     45    18                         0.0326   # Chi-squared value (mu-part)
     45    19                         0.0000   # Chi-squared value (mh-part)
     45    20                         0.0326   # Chi-squared value (total)
     45    21                         0.2244   # Chi-squared value for no predicted signal (mu=0)
     46     1                          55819   # Analysis ID
     46     2     ||arXiv:1407.0558||        # Reference to publication
     46     3     ||(pp)->h->gammagamma(VHtight)||      # Description (Search channel)
     46     4                           8.00   # Center-of-mass energy
     46     5                          19.60   # Luminosity
     46     6                           2.60   # Luminosity uncertainty (in %)
     46     7                           2.00   # Mass resolution (GeV)
     46     8                         124.70   # Mass value at peak position (in GeV)
     46     9                        -0.3430   # Observed signal strength modifier (mu)
     46    10                         0.6290   # Lower 68%C.L. uncertainty on observed mu
     46    11                         1.3000   # Upper 68%C.L. uncertainty on observed mu
     46    12                            001   # Assigned Higgs combination
     46    13                              1   # Index of dominant Higgs boson
     46    14                             25   # pdg number of dominant Higgs boson
     46    15                       122.6512   # Mass of dominant Higgs boson
     46    16                         0.7539   # Signal strength modifier of dominant Higgs boson
     46    17                         0.7539   # Total predicted signal strength modifier mu
     46    18                         0.7796   # Chi-squared value (mu-part)
     46    19                         0.0000   # Chi-squared value (mh-part)
     46    20                         0.7796   # Chi-squared value (total)
     46    21                         0.0696   # Chi-squared value for no predicted signal (mu=0)
     47     1                          55824   # Analysis ID
     47     2     ||arXiv:1407.0558||        # Reference to publication
     47     3     ||(pp)->h->gammagamma(ttHmultijet)||      # Description (Search channel)
     47     4                           8.00   # Center-of-mass energy
     47     5                          19.60   # Luminosity
     47     6                           2.60   # Luminosity uncertainty (in %)
     47     7                           2.00   # Mass resolution (GeV)
     47     8                         124.70   # Mass value at peak position (in GeV)
     47     9                         1.2430   # Observed signal strength modifier (mu)
     47    10                         2.6970   # Lower 68%C.L. uncertainty on observed mu
     47    11                         4.2350   # Upper 68%C.L. uncertainty on observed mu
     47    12                            001   # Assigned Higgs combination
     47    13                              1   # Index of dominant Higgs boson
     47    14                             25   # pdg number of dominant Higgs boson
     47    15                       122.6512   # Mass of dominant Higgs boson
     47    16                         0.7466   # Signal strength modifier of dominant Higgs boson
     47    17                         0.7466   # Total predicted signal strength modifier mu
     47    18                         0.0264   # Chi-squared value (mu-part)
     47    19                         0.0000   # Chi-squared value (mh-part)
     47    20                         0.0264   # Chi-squared value (total)
     47    21                         0.2127   # Chi-squared value for no predicted signal (mu=0)
     48     1                          55823   # Analysis ID
     48     2     ||arXiv:1407.0558||        # Reference to publication
     48     3     ||(pp)->h->gammagamma(ttHlepton)||      # Description (Search channel)
     48     4                           8.00   # Center-of-mass energy
     48     5                          19.60   # Luminosity
     48     6                           2.60   # Luminosity uncertainty (in %)
     48     7                           2.00   # Mass resolution (GeV)
     48     8                         124.70   # Mass value at peak position (in GeV)
     48     9                         3.5210   # Observed signal strength modifier (mu)
     48    10                         2.4500   # Lower 68%C.L. uncertainty on observed mu
     48    11                         3.8920   # Upper 68%C.L. uncertainty on observed mu
     48    12                            001   # Assigned Higgs combination
     48    13                              1   # Index of dominant Higgs boson
     48    14                             25   # pdg number of dominant Higgs boson
     48    15                       122.6512   # Mass of dominant Higgs boson
     48    16                         0.7515   # Signal strength modifier of dominant Higgs boson
     48    17                         0.7515   # Total predicted signal strength modifier mu
     48    18                         0.7731   # Chi-squared value (mu-part)
     48    19                         0.0000   # Chi-squared value (mh-part)
     48    20                         0.7731   # Chi-squared value (total)
     48    21                         2.1101   # Chi-squared value for no predicted signal (mu=0)
     49     1                          55810   # Analysis ID
     49     2     ||arXiv:1407.0558||        # Reference to publication
     49     3     ||(pp)->h->gammagamma(ttHtags)||      # Description (Search channel)
     49     4                           7.00   # Center-of-mass energy
     49     5                           5.10   # Luminosity
     49     6                           2.20   # Luminosity uncertainty (in %)
     49     7                           2.00   # Mass resolution (GeV)
     49     8                         124.70   # Mass value at peak position (in GeV)
     49     9                         0.7140   # Observed signal strength modifier (mu)
     49    10                         3.5630   # Lower 68%C.L. uncertainty on observed mu
     49    11                         6.1970   # Upper 68%C.L. uncertainty on observed mu
     49    12                            001   # Assigned Higgs combination
     49    13                              1   # Index of dominant Higgs boson
     49    14                             25   # pdg number of dominant Higgs boson
     49    15                       122.6512   # Mass of dominant Higgs boson
     49    16                         0.7465   # Signal strength modifier of dominant Higgs boson
     49    17                         0.7465   # Total predicted signal strength modifier mu
     49    18                         0.0001   # Chi-squared value (mu-part)
     49    19                         0.0000   # Chi-squared value (mh-part)
     49    20                         0.0001   # Chi-squared value (total)
     49    21                         0.0402   # Chi-squared value for no predicted signal (mu=0)
     50     1                          55801   # Analysis ID
     50     2     ||arXiv:1407.0558||        # Reference to publication
     50     3     ||(pp)->h->gammagamma(untagged0)||      # Description (Search channel)
     50     4                           7.00   # Center-of-mass energy
     50     5                           5.10   # Luminosity
     50     6                           2.20   # Luminosity uncertainty (in %)
     50     7                           2.00   # Mass resolution (GeV)
     50     8                         124.70   # Mass value at peak position (in GeV)
     50     9                         1.9730   # Observed signal strength modifier (mu)
     50    10                         1.2500   # Lower 68%C.L. uncertainty on observed mu
     50    11                         1.5050   # Upper 68%C.L. uncertainty on observed mu
     50    12                            001   # Assigned Higgs combination
     50    13                              1   # Index of dominant Higgs boson
     50    14                             25   # pdg number of dominant Higgs boson
     50    15                       122.6512   # Mass of dominant Higgs boson
     50    16                         0.6551   # Signal strength modifier of dominant Higgs boson
     50    17                         0.6551   # Total predicted signal strength modifier mu
     50    18                         1.1040   # Chi-squared value (mu-part)
     50    19                         0.0000   # Chi-squared value (mh-part)
     50    20                         1.1040   # Chi-squared value (total)
     50    21                         2.5354   # Chi-squared value for no predicted signal (mu=0)
     51     1                          55811   # Analysis ID
     51     2     ||arXiv:1407.0558||        # Reference to publication
     51     3     ||(pp)->h->gammagamma(untagged0)||      # Description (Search channel)
     51     4                           8.00   # Center-of-mass energy
     51     5                          19.60   # Luminosity
     51     6                           2.60   # Luminosity uncertainty (in %)
     51     7                           2.00   # Mass resolution (GeV)
     51     8                         124.70   # Mass value at peak position (in GeV)
     51     9                         0.1300   # Observed signal strength modifier (mu)
     51    10                         0.7440   # Lower 68%C.L. uncertainty on observed mu
     51    11                         1.0940   # Upper 68%C.L. uncertainty on observed mu
     51    12                            001   # Assigned Higgs combination
     51    13                              1   # Index of dominant Higgs boson
     51    14                             25   # pdg number of dominant Higgs boson
     51    15                       122.6512   # Mass of dominant Higgs boson
     51    16                         0.6614   # Signal strength modifier of dominant Higgs boson
     51    17                         0.6614   # Total predicted signal strength modifier mu
     51    18                         0.2602   # Chi-squared value (mu-part)
     51    19                         0.0000   # Chi-squared value (mh-part)
     51    20                         0.2602   # Chi-squared value (total)
     51    21                         0.0304   # Chi-squared value for no predicted signal (mu=0)
     52     1                          55802   # Analysis ID
     52     2     ||arXiv:1407.0558||        # Reference to publication
     52     3     ||(pp)->h->gammagamma(untagged1)||      # Description (Search channel)
     52     4                           7.00   # Center-of-mass energy
     52     5                           5.10   # Luminosity
     52     6                           2.20   # Luminosity uncertainty (in %)
     52     7                           2.00   # Mass resolution (GeV)
     52     8                         124.70   # Mass value at peak position (in GeV)
     52     9                         1.2330   # Observed signal strength modifier (mu)
     52    10                         0.8800   # Lower 68%C.L. uncertainty on observed mu
     52    11                         0.9790   # Upper 68%C.L. uncertainty on observed mu
     52    12                            001   # Assigned Higgs combination
     52    13                              1   # Index of dominant Higgs boson
     52    14                             25   # pdg number of dominant Higgs boson
     52    15                       122.6512   # Mass of dominant Higgs boson
     52    16                         0.6409   # Signal strength modifier of dominant Higgs boson
     52    17                         0.6409   # Total predicted signal strength modifier mu
     52    18                         0.4934   # Chi-squared value (mu-part)
     52    19                         0.0000   # Chi-squared value (mh-part)
     52    20                         0.4934   # Chi-squared value (total)
     52    21                         1.9918   # Chi-squared value for no predicted signal (mu=0)
     53     1                          55812   # Analysis ID
     53     2     ||arXiv:1407.0558||        # Reference to publication
     53     3     ||(pp)->h->gammagamma(untagged1)||      # Description (Search channel)
     53     4                           8.00   # Center-of-mass energy
     53     5                          19.60   # Luminosity
     53     6                           2.60   # Luminosity uncertainty (in %)
     53     7                           2.00   # Mass resolution (GeV)
     53     8                         124.70   # Mass value at peak position (in GeV)
     53     9                         0.9190   # Observed signal strength modifier (mu)
     53    10                         0.4870   # Lower 68%C.L. uncertainty on observed mu
     53    11                         0.5670   # Upper 68%C.L. uncertainty on observed mu
     53    12                            001   # Assigned Higgs combination
     53    13                              1   # Index of dominant Higgs boson
     53    14                             25   # pdg number of dominant Higgs boson
     53    15                       122.6512   # Mass of dominant Higgs boson
     53    16                         0.6498   # Signal strength modifier of dominant Higgs boson
     53    17                         0.6498   # Total predicted signal strength modifier mu
     53    18                         0.3093   # Chi-squared value (mu-part)
     53    19                         0.0000   # Chi-squared value (mh-part)
     53    20                         0.3093   # Chi-squared value (total)
     53    21                         3.6185   # Chi-squared value for no predicted signal (mu=0)
     54     1                          55803   # Analysis ID
     54     2     ||arXiv:1407.0558||        # Reference to publication
     54     3     ||(pp)->h->gammagamma(untagged2)||      # Description (Search channel)
     54     4                           7.00   # Center-of-mass energy
     54     5                           5.10   # Luminosity
     54     6                           2.20   # Luminosity uncertainty (in %)
     54     7                           2.00   # Mass resolution (GeV)
     54     8                         124.70   # Mass value at peak position (in GeV)
     54     9                         1.6020   # Observed signal strength modifier (mu)
     54    10                         1.1740   # Lower 68%C.L. uncertainty on observed mu
     54    11                         1.2460   # Upper 68%C.L. uncertainty on observed mu
     54    12                            001   # Assigned Higgs combination
     54    13                              1   # Index of dominant Higgs boson
     54    14                             25   # pdg number of dominant Higgs boson
     54    15                       122.6512   # Mass of dominant Higgs boson
     54    16                         0.6409   # Signal strength modifier of dominant Higgs boson
     54    17                         0.6409   # Total predicted signal strength modifier mu
     54    18                         0.7373   # Chi-squared value (mu-part)
     54    19                         0.0000   # Chi-squared value (mh-part)
     54    20                         0.7373   # Chi-squared value (total)
     54    21                         1.8916   # Chi-squared value for no predicted signal (mu=0)
     55     1                          55813   # Analysis ID
     55     2     ||arXiv:1407.0558||        # Reference to publication
     55     3     ||(pp)->h->gammagamma(untagged2)||      # Description (Search channel)
     55     4                           8.00   # Center-of-mass energy
     55     5                          19.60   # Luminosity
     55     6                           2.60   # Luminosity uncertainty (in %)
     55     7                           0.34   # Mass resolution (GeV)
     55     8                         124.70   # Mass value at peak position (in GeV)
     55     9                         1.1020   # Observed signal strength modifier (mu)
     55    10                         0.4400   # Lower 68%C.L. uncertainty on observed mu
     55    11                         0.4770   # Upper 68%C.L. uncertainty on observed mu
     55    12                            001   # Assigned Higgs combination
     55    13                              1   # Index of dominant Higgs boson
     55    14                             25   # pdg number of dominant Higgs boson
     55    15                       122.6512   # Mass of dominant Higgs boson
     55    16                         0.6424   # Signal strength modifier of dominant Higgs boson
     55    17                         0.6424   # Total predicted signal strength modifier mu
     55    18                         1.0220   # Chi-squared value (mu-part)
     55    19                         3.7947   # Chi-squared value (mh-part)
     55    20                         4.8167   # Chi-squared value (total)
     55    21                         6.5393   # Chi-squared value for no predicted signal (mu=0)
     56     1                          55804   # Analysis ID
     56     2     ||arXiv:1407.0558||        # Reference to publication
     56     3     ||(pp)->h->gammagamma(untagged3)||      # Description (Search channel)
     56     4                           7.00   # Center-of-mass energy
     56     5                           5.10   # Luminosity
     56     6                           2.20   # Luminosity uncertainty (in %)
     56     7                           2.00   # Mass resolution (GeV)
     56     8                         124.70   # Mass value at peak position (in GeV)
     56     9                         2.6120   # Observed signal strength modifier (mu)
     56    10                         1.6530   # Lower 68%C.L. uncertainty on observed mu
     56    11                         1.7380   # Upper 68%C.L. uncertainty on observed mu
     56    12                            001   # Assigned Higgs combination
     56    13                              1   # Index of dominant Higgs boson
     56    14                             25   # pdg number of dominant Higgs boson
     56    15                       122.6512   # Mass of dominant Higgs boson
     56    16                         0.6406   # Signal strength modifier of dominant Higgs boson
     56    17                         0.6406   # Total predicted signal strength modifier mu
     56    18                         1.4492   # Chi-squared value (mu-part)
     56    19                         0.0000   # Chi-squared value (mh-part)
     56    20                         1.4492   # Chi-squared value (total)
     56    21                         2.5569   # Chi-squared value for no predicted signal (mu=0)
     57     1                          55814   # Analysis ID
     57     2     ||arXiv:1407.0558||        # Reference to publication
     57     3     ||(pp)->h->gammagamma(untagged3)||      # Description (Search channel)
     57     4                           8.00   # Center-of-mass energy
     57     5                          19.60   # Luminosity
     57     6                           2.60   # Luminosity uncertainty (in %)
     57     7                           2.00   # Mass resolution (GeV)
     57     8                         124.70   # Mass value at peak position (in GeV)
     57     9                         0.6480   # Observed signal strength modifier (mu)
     57    10                         0.8870   # Lower 68%C.L. uncertainty on observed mu
     57    11                         0.6530   # Upper 68%C.L. uncertainty on observed mu
     57    12                            001   # Assigned Higgs combination
     57    13                              1   # Index of dominant Higgs boson
     57    14                             25   # pdg number of dominant Higgs boson
     57    15                       122.6512   # Mass of dominant Higgs boson
     57    16                         0.6420   # Signal strength modifier of dominant Higgs boson
     57    17                         0.6420   # Total predicted signal strength modifier mu
     57    18                        -0.0000   # Chi-squared value (mu-part)
     57    19                         0.0000   # Chi-squared value (mh-part)
     57    20                        -0.0000   # Chi-squared value (total)
     57    21                         0.5338   # Chi-squared value for no predicted signal (mu=0)
     58     1                          55815   # Analysis ID
     58     2     ||arXiv:1407.0558||        # Reference to publication
     58     3     ||(pp)->h->gammagamma(untagged4)||      # Description (Search channel)
     58     4                           8.00   # Center-of-mass energy
     58     5                          19.60   # Luminosity
     58     6                           2.60   # Luminosity uncertainty (in %)
     58     7                           2.00   # Mass resolution (GeV)
     58     8                         124.70   # Mass value at peak position (in GeV)
     58     9                         1.4570   # Observed signal strength modifier (mu)
     58    10                         1.2380   # Lower 68%C.L. uncertainty on observed mu
     58    11                         1.2890   # Upper 68%C.L. uncertainty on observed mu
     58    12                            001   # Assigned Higgs combination
     58    13                              1   # Index of dominant Higgs boson
     58    14                             25   # pdg number of dominant Higgs boson
     58    15                       122.6512   # Mass of dominant Higgs boson
     58    16                         0.6400   # Signal strength modifier of dominant Higgs boson
     58    17                         0.6400   # Total predicted signal strength modifier mu
     58    18                         0.3786   # Chi-squared value (mu-part)
     58    19                         0.0000   # Chi-squared value (mh-part)
     58    20                         0.3786   # Chi-squared value (total)
     58    21                         1.4010   # Chi-squared value for no predicted signal (mu=0)
     59     1                        1300701   # Analysis ID
     59     2     ||CMS-PAS-HIG-13-007||        # Reference to publication
     59     3     ||(pp)->h->mumu||      # Description (Search channel)
     59     4                           8.00   # Center-of-mass energy
     59     5                          25.40   # Luminosity
     59     6                           2.60   # Luminosity uncertainty (in %)
     59     7                           2.00   # Mass resolution (GeV)
     59     8                         125.70   # Mass value at peak position (in GeV)
     59     9                         2.9000   # Observed signal strength modifier (mu)
     59    10                         2.7000   # Lower 68%C.L. uncertainty on observed mu
     59    11                         2.8000   # Upper 68%C.L. uncertainty on observed mu
     59    12                            000   # Assigned Higgs combination
     59    13                              0   # Index of dominant Higgs boson
     59    14                            NaN   # pdg number of dominant Higgs boson
     59    15                            NaN   # Mass of the dominant Higgs boson
     59    16                            NaN   # Signal strength modifier of the dominant Higgs boson
     59    17                         0.0000   # Total predicted signal strength modifier mu
     59    18                         1.1680   # Chi-squared value (mu-part)
     59    19                         0.0000   # Chi-squared value (mh-part)
     59    20                         1.1680   # Chi-squared value (total)
     59    21                         1.1680   # Chi-squared value for no predicted signal (mu=0)
     60     1                        1300401   # Analysis ID
     60     2     ||CMS-PAS-HIG-13-004||        # Reference to publication
     60     3     ||(pp)->h->tautau(0jet)||      # Description (Search channel)
     60     4                           8.00   # Center-of-mass energy
     60     5                          24.30   # Luminosity
     60     6                           2.60   # Luminosity uncertainty (in %)
     60     7                          25.00   # Mass resolution (GeV)
     60     8                         125.00   # Mass value at peak position (in GeV)
     60     9                         0.4000   # Observed signal strength modifier (mu)
     60    10                         1.1300   # Lower 68%C.L. uncertainty on observed mu
     60    11                         0.7300   # Upper 68%C.L. uncertainty on observed mu
     60    12                            001   # Assigned Higgs combination
     60    13                              1   # Index of dominant Higgs boson
     60    14                             25   # pdg number of dominant Higgs boson
     60    15                       122.6512   # Mass of dominant Higgs boson
     60    16                         0.9686   # Signal strength modifier of dominant Higgs boson
     60    17                         0.9686   # Total predicted signal strength modifier mu
     60    18                         0.7361   # Chi-squared value (mu-part)
     60    19                         0.0000   # Chi-squared value (mh-part)
     60    20                         0.7361   # Chi-squared value (total)
     60    21                         0.1244   # Chi-squared value for no predicted signal (mu=0)
     61     1                        1300402   # Analysis ID
     61     2     ||CMS-PAS-HIG-13-004||        # Reference to publication
     61     3     ||(pp)->h->tautau(1jet)||      # Description (Search channel)
     61     4                           8.00   # Center-of-mass energy
     61     5                          24.30   # Luminosity
     61     6                           2.60   # Luminosity uncertainty (in %)
     61     7                          25.00   # Mass resolution (GeV)
     61     8                         125.00   # Mass value at peak position (in GeV)
     61     9                         1.0600   # Observed signal strength modifier (mu)
     61    10                         0.4700   # Lower 68%C.L. uncertainty on observed mu
     61    11                         0.4700   # Upper 68%C.L. uncertainty on observed mu
     61    12                            001   # Assigned Higgs combination
     61    13                              1   # Index of dominant Higgs boson
     61    14                             25   # pdg number of dominant Higgs boson
     61    15                       122.6512   # Mass of dominant Higgs boson
     61    16                         1.0040   # Signal strength modifier of dominant Higgs boson
     61    17                         1.0040   # Total predicted signal strength modifier mu
     61    18                        -0.0178   # Chi-squared value (mu-part)
     61    19                         0.0000   # Chi-squared value (mh-part)
     61    20                        -0.0178   # Chi-squared value (total)
     61    21                         5.1188   # Chi-squared value for no predicted signal (mu=0)
     62     1                        1300404   # Analysis ID
     62     2     ||CMS-PAS-HIG-13-004||        # Reference to publication
     62     3     ||(pp)->h->tautau(VBF)||      # Description (Search channel)
     62     4                           8.00   # Center-of-mass energy
     62     5                          24.50   # Luminosity
     62     6                           2.60   # Luminosity uncertainty (in %)
     62     7                          20.00   # Mass resolution (GeV)
     62     8                         125.00   # Mass value at peak position (in GeV)
     62     9                         0.9300   # Observed signal strength modifier (mu)
     62    10                         0.4100   # Lower 68%C.L. uncertainty on observed mu
     62    11                         0.4100   # Upper 68%C.L. uncertainty on observed mu
     62    12                            001   # Assigned Higgs combination
     62    13                              1   # Index of dominant Higgs boson
     62    14                             25   # pdg number of dominant Higgs boson
     62    15                       122.6512   # Mass of dominant Higgs boson
     62    16                         1.1139   # Signal strength modifier of dominant Higgs boson
     62    17                         1.1139   # Total predicted signal strength modifier mu
     62    18                         0.2726   # Chi-squared value (mu-part)
     62    19                         0.0000   # Chi-squared value (mh-part)
     62    20                         0.2726   # Chi-squared value (total)
     62    21                         5.1208   # Chi-squared value for no predicted signal (mu=0)
     63     1                      131211293   # Analysis ID
     63     2     ||arXiv:1312.1129||        # Reference to publication
     63     3     ||(pp)->h->WW->2l2nu(VH)||      # Description (Search channel)
     63     4                           8.00   # Center-of-mass energy
     63     5                          25.30   # Luminosity
     63     6                           2.60   # Luminosity uncertainty (in %)
     63     7                          20.00   # Mass resolution (GeV)
     63     8                         125.60   # Mass value at peak position (in GeV)
     63     9                         0.3900   # Observed signal strength modifier (mu)
     63    10                         1.8700   # Lower 68%C.L. uncertainty on observed mu
     63    11                         1.9700   # Upper 68%C.L. uncertainty on observed mu
     63    12                            001   # Assigned Higgs combination
     63    13                              1   # Index of dominant Higgs boson
     63    14                             25   # pdg number of dominant Higgs boson
     63    15                       122.6512   # Mass of dominant Higgs boson
     63    16                         0.7597   # Signal strength modifier of dominant Higgs boson
     63    17                         0.7597   # Total predicted signal strength modifier mu
     63    18                         0.0411   # Chi-squared value (mu-part)
     63    19                         0.0000   # Chi-squared value (mh-part)
     63    20                         0.0411   # Chi-squared value (total)
     63    21                         0.0435   # Chi-squared value for no predicted signal (mu=0)
     64     1                        1301701   # Analysis ID
     64     2     ||CMS-PAS-HIG-13-017||        # Reference to publication
     64     3     ||(pp)->Vh->VWW(hadronicV)||      # Description (Search channel)
     64     4                           8.00   # Center-of-mass energy
     64     5                          25.40   # Luminosity
     64     6                           4.40   # Luminosity uncertainty (in %)
     64     7                          20.00   # Mass resolution (GeV)
     64     8                         125.00   # Mass value at peak position (in GeV)
     64     9                         1.0000   # Observed signal strength modifier (mu)
     64    10                         2.0000   # Lower 68%C.L. uncertainty on observed mu
     64    11                         2.0000   # Upper 68%C.L. uncertainty on observed mu
     64    12                            001   # Assigned Higgs combination
     64    13                              1   # Index of dominant Higgs boson
     64    14                             25   # pdg number of dominant Higgs boson
     64    15                       122.6512   # Mass of dominant Higgs boson
     64    16                         0.7548   # Signal strength modifier of dominant Higgs boson
     64    17                         0.7548   # Total predicted signal strength modifier mu
     64    18                         0.0083   # Chi-squared value (mu-part)
     64    19                         0.0000   # Chi-squared value (mh-part)
     64    20                         0.0083   # Chi-squared value (total)
     64    21                         0.2502   # Chi-squared value for no predicted signal (mu=0)
     65     1                        1301201   # Analysis ID
     65     2     ||CMS-PAS-HIG-13-012||        # Reference to publication
     65     3     ||(pp)->Vh->Vbb||      # Description (Search channel)
     65     4                           8.00   # Center-of-mass energy
     65     5                          24.00   # Luminosity
     65     6                           4.40   # Luminosity uncertainty (in %)
     65     7                          12.50   # Mass resolution (GeV)
     65     8                         125.70   # Mass value at peak position (in GeV)
     65     9                         1.0000   # Observed signal strength modifier (mu)
     65    10                         0.4857   # Lower 68%C.L. uncertainty on observed mu
     65    11                         0.5070   # Upper 68%C.L. uncertainty on observed mu
     65    12                            001   # Assigned Higgs combination
     65    13                              1   # Index of dominant Higgs boson
     65    14                             25   # pdg number of dominant Higgs boson
     65    15                       122.6512   # Mass of dominant Higgs boson
     65    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     65    17                         1.1325   # Total predicted signal strength modifier mu
     65    18                         0.0923   # Chi-squared value (mu-part)
     65    19                         0.0000   # Chi-squared value (mh-part)
     65    20                         0.0923   # Chi-squared value (total)
     65    21                         4.2236   # Chi-squared value for no predicted signal (mu=0)
     66     1                        1300403   # Analysis ID
     66     2     ||CMS-PAS-HIG-13-004||        # Reference to publication
     66     3     ||(pp)->Vh->tautau||      # Description (Search channel)
     66     4                           8.00   # Center-of-mass energy
     66     5                          24.30   # Luminosity
     66     6                           4.40   # Luminosity uncertainty (in %)
     66     7                          20.00   # Mass resolution (GeV)
     66     8                         125.70   # Mass value at peak position (in GeV)
     66     9                         0.9810   # Observed signal strength modifier (mu)
     66    10                         1.4960   # Lower 68%C.L. uncertainty on observed mu
     66    11                         1.6800   # Upper 68%C.L. uncertainty on observed mu
     66    12                            001   # Assigned Higgs combination
     66    13                              1   # Index of dominant Higgs boson
     66    14                             25   # pdg number of dominant Higgs boson
     66    15                       122.6512   # Mass of dominant Higgs boson
     66    16                         1.0871   # Signal strength modifier of dominant Higgs boson
     66    17                         1.0871   # Total predicted signal strength modifier mu
     66    18                         0.0063   # Chi-squared value (mu-part)
     66    19                         0.0000   # Chi-squared value (mh-part)
     66    20                         0.0063   # Chi-squared value (total)
     66    21                         0.4298   # Chi-squared value for no predicted signal (mu=0)
     67     1                      131211294   # Analysis ID
     67     2     ||arXiv:1312.1129||        # Reference to publication
     67     3     ||(pp)->h->WW->3l3nu(WH)||      # Description (Search channel)
     67     4                           8.00   # Center-of-mass energy
     67     5                          25.30   # Luminosity
     67     6                           2.60   # Luminosity uncertainty (in %)
     67     7                          20.00   # Mass resolution (GeV)
     67     8                         125.60   # Mass value at peak position (in GeV)
     67     9                         0.5600   # Observed signal strength modifier (mu)
     67    10                         0.9500   # Lower 68%C.L. uncertainty on observed mu
     67    11                         1.2700   # Upper 68%C.L. uncertainty on observed mu
     67    12                            001   # Assigned Higgs combination
     67    13                              1   # Index of dominant Higgs boson
     67    14                             25   # pdg number of dominant Higgs boson
     67    15                       122.6512   # Mass of dominant Higgs boson
     67    16                         0.8413   # Signal strength modifier of dominant Higgs boson
     67    17                         0.8413   # Total predicted signal strength modifier mu
     67    18                         0.0534   # Chi-squared value (mu-part)
     67    19                         0.0000   # Chi-squared value (mh-part)
     67    20                         0.0534   # Chi-squared value (total)
     67    21                         0.3473   # Chi-squared value for no predicted signal (mu=0)
     68     1                         168204   # Analysis ID
     68     2     ||arXiv:1408.1682||        # Reference to publication
     68     3     ||(pp)->tth->2leptons(samesign)||      # Description (Search channel)
     68     4                           8.00   # Center-of-mass energy
     68     5                          19.60   # Luminosity
     68     6                           2.60   # Luminosity uncertainty (in %)
     68     7                          25.00   # Mass resolution (GeV)
     68     8                         125.60   # Mass value at peak position (in GeV)
     68     9                         5.3000   # Observed signal strength modifier (mu)
     68    10                         1.8000   # Lower 68%C.L. uncertainty on observed mu
     68    11                         2.1000   # Upper 68%C.L. uncertainty on observed mu
     68    12                            001   # Assigned Higgs combination
     68    13                              1   # Index of dominant Higgs boson
     68    14                             25   # pdg number of dominant Higgs boson
     68    15                       122.6512   # Mass of dominant Higgs boson
     68    16                         0.9231   # Signal strength modifier of dominant Higgs boson
     68    17                         0.9231   # Total predicted signal strength modifier mu
     68    18                         6.1994   # Chi-squared value (mu-part)
     68    19                         0.0000   # Chi-squared value (mh-part)
     68    20                         6.1994   # Chi-squared value (total)
     68    21                         9.5729   # Chi-squared value for no predicted signal (mu=0)
     69     1                         168205   # Analysis ID
     69     2     ||arXiv:1408.1682||        # Reference to publication
     69     3     ||(pp)->tth->3leptons||      # Description (Search channel)
     69     4                           8.00   # Center-of-mass energy
     69     5                          19.60   # Luminosity
     69     6                           2.60   # Luminosity uncertainty (in %)
     69     7                          25.00   # Mass resolution (GeV)
     69     8                         125.60   # Mass value at peak position (in GeV)
     69     9                         3.1000   # Observed signal strength modifier (mu)
     69    10                         2.0000   # Lower 68%C.L. uncertainty on observed mu
     69    11                         2.4000   # Upper 68%C.L. uncertainty on observed mu
     69    12                            001   # Assigned Higgs combination
     69    13                              1   # Index of dominant Higgs boson
     69    14                             25   # pdg number of dominant Higgs boson
     69    15                       122.6512   # Mass of dominant Higgs boson
     69    16                         0.9256   # Signal strength modifier of dominant Higgs boson
     69    17                         0.9256   # Total predicted signal strength modifier mu
     69    18                         1.1139   # Chi-squared value (mu-part)
     69    19                         0.0000   # Chi-squared value (mh-part)
     69    20                         1.1139   # Chi-squared value (total)
     69    21                         2.4628   # Chi-squared value for no predicted signal (mu=0)
     70     1                         168206   # Analysis ID
     70     2     ||arXiv:1408.1682||        # Reference to publication
     70     3     ||(pp)->tth->4leptons||      # Description (Search channel)
     70     4                           8.00   # Center-of-mass energy
     70     5                          19.60   # Luminosity
     70     6                           2.60   # Luminosity uncertainty (in %)
     70     7                          25.00   # Mass resolution (GeV)
     70     8                         125.60   # Mass value at peak position (in GeV)
     70     9                        -4.7000   # Observed signal strength modifier (mu)
     70    10                         1.3000   # Lower 68%C.L. uncertainty on observed mu
     70    11                         5.0000   # Upper 68%C.L. uncertainty on observed mu
     70    12                            001   # Assigned Higgs combination
     70    13                              1   # Index of dominant Higgs boson
     70    14                             25   # pdg number of dominant Higgs boson
     70    15                       122.6512   # Mass of dominant Higgs boson
     70    16                         0.9447   # Signal strength modifier of dominant Higgs boson
     70    17                         0.9447   # Total predicted signal strength modifier mu
     70    18                         1.2673   # Chi-squared value (mu-part)
     70    19                         0.0000   # Chi-squared value (mh-part)
     70    20                         1.2673   # Chi-squared value (total)
     70    21                         0.8920   # Chi-squared value for no predicted signal (mu=0)
     71     1                         168202   # Analysis ID
     71     2     ||arXiv:1408.1682||        # Reference to publication
     71     3     ||(pp)->tth->tt(bb)||      # Description (Search channel)
     71     4                           8.00   # Center-of-mass energy
     71     5                          24.50   # Luminosity
     71     6                           2.60   # Luminosity uncertainty (in %)
     71     7                          25.00   # Mass resolution (GeV)
     71     8                         125.60   # Mass value at peak position (in GeV)
     71     9                         0.7000   # Observed signal strength modifier (mu)
     71    10                         1.9000   # Lower 68%C.L. uncertainty on observed mu
     71    11                         1.9000   # Upper 68%C.L. uncertainty on observed mu
     71    12                            001   # Assigned Higgs combination
     71    13                              1   # Index of dominant Higgs boson
     71    14                             25   # pdg number of dominant Higgs boson
     71    15                       122.6512   # Mass of dominant Higgs boson
     71    16                         1.1282   # Signal strength modifier of dominant Higgs boson
     71    17                         1.1282   # Total predicted signal strength modifier mu
     71    18                         0.0622   # Chi-squared value (mu-part)
     71    19                         0.0000   # Chi-squared value (mh-part)
     71    20                         0.0622   # Chi-squared value (total)
     71    21                         0.1354   # Chi-squared value for no predicted signal (mu=0)
     72     1                         168201   # Analysis ID
     72     2     ||arXiv:1408.1682||        # Reference to publication
     72     3     ||(pp)->tth->tt(gammagamma)||      # Description (Search channel)
     72     4                           8.00   # Center-of-mass energy
     72     5                          19.60   # Luminosity
     72     6                           2.60   # Luminosity uncertainty (in %)
     72     7                          15.00   # Mass resolution (GeV)
     72     8                         125.60   # Mass value at peak position (in GeV)
     72     9                         2.7000   # Observed signal strength modifier (mu)
     72    10                         1.8000   # Lower 68%C.L. uncertainty on observed mu
     72    11                         2.6000   # Upper 68%C.L. uncertainty on observed mu
     72    12                            001   # Assigned Higgs combination
     72    13                              1   # Index of dominant Higgs boson
     72    14                             25   # pdg number of dominant Higgs boson
     72    15                       122.6512   # Mass of dominant Higgs boson
     72    16                         0.7514   # Signal strength modifier of dominant Higgs boson
     72    17                         0.7514   # Total predicted signal strength modifier mu
     72    18                         1.1084   # Chi-squared value (mu-part)
     72    19                         0.0000   # Chi-squared value (mh-part)
     72    20                         1.1084   # Chi-squared value (total)
     72    21                         2.3054   # Chi-squared value for no predicted signal (mu=0)
     73     1                         168203   # Analysis ID
     73     2     ||arXiv:1408.1682||        # Reference to publication
     73     3     ||(pp)->tth->tt(tautau)||      # Description (Search channel)
     73     4                           8.00   # Center-of-mass energy
     73     5                          24.50   # Luminosity
     73     6                           2.60   # Luminosity uncertainty (in %)
     73     7                          25.00   # Mass resolution (GeV)
     73     8                         125.60   # Mass value at peak position (in GeV)
     73     9                        -1.3000   # Observed signal strength modifier (mu)
     73    10                         5.5000   # Lower 68%C.L. uncertainty on observed mu
     73    11                         6.3000   # Upper 68%C.L. uncertainty on observed mu
     73    12                            001   # Assigned Higgs combination
     73    13                              1   # Index of dominant Higgs boson
     73    14                             25   # pdg number of dominant Higgs boson
     73    15                       122.6512   # Mass of dominant Higgs boson
     73    16                         1.1492   # Signal strength modifier of dominant Higgs boson
     73    17                         1.1492   # Total predicted signal strength modifier mu
     73    18                         0.1540   # Chi-squared value (mu-part)
     73    19                         0.0000   # Chi-squared value (mh-part)
     73    20                         0.1540   # Chi-squared value (total)
     73    21                         0.0426   # Chi-squared value for no predicted signal (mu=0)
     74     1                      130308232   # Analysis ID
     74     2     ||arXiv:1303.0823||        # Reference to publication
     74     3     ||(ppbar)->h->WW||      # Description (Search channel)
     74     4                           1.96   # Center-of-mass energy
     74     5                           9.70   # Luminosity
     74     6                           6.10   # Luminosity uncertainty (in %)
     74     7                          25.00   # Mass resolution (GeV)
     74     8                         125.00   # Mass value at peak position (in GeV)
     74     9                         1.9000   # Observed signal strength modifier (mu)
     74    10                         1.5200   # Lower 68%C.L. uncertainty on observed mu
     74    11                         1.6300   # Upper 68%C.L. uncertainty on observed mu
     74    12                            001   # Assigned Higgs combination
     74    13                              1   # Index of dominant Higgs boson
     74    14                             25   # pdg number of dominant Higgs boson
     74    15                       122.6512   # Mass of dominant Higgs boson
     74    16                         0.7351   # Signal strength modifier of dominant Higgs boson
     74    17                         0.7351   # Total predicted signal strength modifier mu
     74    18                         0.5558   # Chi-squared value (mu-part)
     74    19                         0.0000   # Chi-squared value (mh-part)
     74    20                         0.5558   # Chi-squared value (total)
     74    21                         1.5777   # Chi-squared value for no predicted signal (mu=0)
     75     1                      130308234   # Analysis ID
     75     2     ||arXiv:1303.0823||        # Reference to publication
     75     3     ||(ppbar)->h->bb||      # Description (Search channel)
     75     4                           1.96   # Center-of-mass energy
     75     5                           9.70   # Luminosity
     75     6                           6.10   # Luminosity uncertainty (in %)
     75     7                          25.00   # Mass resolution (GeV)
     75     8                         125.00   # Mass value at peak position (in GeV)
     75     9                         1.2300   # Observed signal strength modifier (mu)
     75    10                         1.1700   # Lower 68%C.L. uncertainty on observed mu
     75    11                         1.2400   # Upper 68%C.L. uncertainty on observed mu
     75    12                            001   # Assigned Higgs combination
     75    13                              1   # Index of dominant Higgs boson
     75    14                             25   # pdg number of dominant Higgs boson
     75    15                       122.6512   # Mass of dominant Higgs boson
     75    16                         1.1325   # Signal strength modifier of dominant Higgs boson
     75    17                         1.1325   # Total predicted signal strength modifier mu
     75    18                         0.0072   # Chi-squared value (mu-part)
     75    19                         0.0000   # Chi-squared value (mh-part)
     75    20                         0.0072   # Chi-squared value (total)
     75    21                         1.1049   # Chi-squared value for no predicted signal (mu=0)
     76     1                      130308231   # Analysis ID
     76     2     ||arXiv:1303.0823||        # Reference to publication
     76     3     ||(ppbar)->h->gammagamma||      # Description (Search channel)
     76     4                           1.96   # Center-of-mass energy
     76     5                           9.70   # Luminosity
     76     6                           6.10   # Luminosity uncertainty (in %)
     76     7                           5.00   # Mass resolution (GeV)
     76     8                         125.00   # Mass value at peak position (in GeV)
     76     9                         4.2000   # Observed signal strength modifier (mu)
     76    10                         4.2000   # Lower 68%C.L. uncertainty on observed mu
     76    11                         4.6000   # Upper 68%C.L. uncertainty on observed mu
     76    12                            001   # Assigned Higgs combination
     76    13                              1   # Index of dominant Higgs boson
     76    14                             25   # pdg number of dominant Higgs boson
     76    15                       122.6512   # Mass of dominant Higgs boson
     76    16                         0.6591   # Signal strength modifier of dominant Higgs boson
     76    17                         0.6591   # Total predicted signal strength modifier mu
     76    18                         0.6985   # Chi-squared value (mu-part)
     76    19                         0.0000   # Chi-squared value (mh-part)
     76    20                         0.6985   # Chi-squared value (total)
     76    21                         1.0071   # Chi-squared value for no predicted signal (mu=0)
     77     1                      130308233   # Analysis ID
     77     2     ||arXiv:1303.0823||        # Reference to publication
     77     3     ||(ppbar)->h->tautau||      # Description (Search channel)
     77     4                           1.96   # Center-of-mass energy
     77     5                           9.70   # Luminosity
     77     6                           6.10   # Luminosity uncertainty (in %)
     77     7                          25.00   # Mass resolution (GeV)
     77     8                         125.00   # Mass value at peak position (in GeV)
     77     9                         3.9600   # Observed signal strength modifier (mu)
     77    10                         3.3800   # Lower 68%C.L. uncertainty on observed mu
     77    11                         4.1100   # Upper 68%C.L. uncertainty on observed mu
     77    12                            001   # Assigned Higgs combination
     77    13                              1   # Index of dominant Higgs boson
     77    14                             25   # pdg number of dominant Higgs boson
     77    15                       122.6512   # Mass of dominant Higgs boson
     77    16                         1.0080   # Signal strength modifier of dominant Higgs boson
     77    17                         1.0080   # Total predicted signal strength modifier mu
     77    18                         0.7419   # Chi-squared value (mu-part)
     77    19                         0.0000   # Chi-squared value (mh-part)
     77    20                         0.7419   # Chi-squared value (total)
     77    21                         1.3860   # Chi-squared value for no predicted signal (mu=0)
Index: trunk/HiggsSignals/pc_chisq.f90
===================================================================
--- trunk/HiggsSignals/pc_chisq.f90	(revision 505)
+++ trunk/HiggsSignals/pc_chisq.f90	(revision 506)
@@ -1,2494 +1,2475 @@
 !--------------------------------------------------------------------
 ! This file is part of HiggsSignals (TS 03/03/2013)
 !--------------------------------------------------------------------
 module pc_chisq
 
  use numerics
  use combinatorics
  use usefulbits_hs
  implicit none
 
  integer :: i,j,k
  double precision,parameter :: pi=3.14159265358979323846264338328D0
  integer, allocatable :: peakindices_best(:,:)
 
 contains
 
 !------------------------------------------------------------------------------------    
 subroutine set_toyvalues(ii, peaks)
 ! This subroutine sets the mass and mu measurements of the peak observable(s) of analyses ii
 ! to those values which are given by the user using assign_toyvalues_to_observables.
 !------------------------------------------------------------------------------------   
  use usefulbits_hs, only: obs, mupeak
  
  integer, intent(in) :: ii
  type(mupeak),dimension(:), intent(inout) :: peaks
  integer :: i
  
  if(obs(ii)%table%npeaks.ne.size(peaks)) then
   stop 'Error in subroutine set_toyvalues: Number of peaks does not match!'
  endif
  
  do i=lbound(peaks,dim=1),ubound(peaks,dim=1)
   peaks(i)%mpeak = obs(ii)%table%Toys_mhobs(i)
   peaks(i)%mu = obs(ii)%table%Toys_muobs(i)
  enddo
 
 end subroutine set_toyvalues
 !------------------------------------------------------------------------------------   
 !subroutine scale_uncertainties(ii, peaks)
 !! Scales the uncertainty of the signal strength and mass measurement of the peak
 !! observables of analysis ii by the scalefactors which have been set via the subroutine
 !! assign_uncertainty_scalefactors_to_observables.
 !!------------------------------------------------------------------------------------   
 ! use usefulbits_hs, only : obs, mupeak
 !
 ! integer, intent(in) :: ii
 ! type(mupeak),dimension(:), intent(inout) :: peaks
 ! integer :: i
 !
 ! if(obs(ii)%table%npeaks.ne.size(peaks)) then
 !  stop 'Error in subroutine scale_uncertainties: Number of peaks does not match!'
 ! endif
 ! 
 ! do i=lbound(peaks,dim=1),ubound(peaks,dim=1)
 !  peaks(i)%dmuup = obs(ii)%table%scale_mu(i)*peaks(i)%dmuup
 !  peaks(i)%dmulow = obs(ii)%table%scale_mu(i)*peaks(i)%dmulow
 !  peaks(i)%dm = obs(ii)%table%scale_mh(i)*peaks(i)%dm
 ! enddo
 ! 
 !end subroutine scale_uncertainties 
 !------------------------------------------------------------------------------------   
 !subroutine restore_uncertainties(ii, peaks)
 !! Restores the uncertainty of the signal strength and mass measurement of the peak
 !! observables of analysis ii after scaling.
 !!------------------------------------------------------------------------------------   
 ! use usefulbits, only : vsmall
 ! use usefulbits_hs, only : obs, mupeak
 !
 ! integer, intent(in) :: ii
 ! type(mupeak),dimension(:), intent(inout) :: peaks
 ! integer :: i
 !
 ! if(obs(ii)%table%npeaks.ne.size(peaks)) then
 !  stop 'Error in subroutine restore_uncertainties: Number of peaks does not match!'
 ! endif
 ! 
 ! do i=lbound(peaks,dim=1),ubound(peaks,dim=1)
 !  if(obs(ii)%table%scale_mu(i).ge.vsmall) then
 !   peaks(i)%dmuup = peaks(i)%dmuup/obs(ii)%table%scale_mu(i)
 !   peaks(i)%dmulow = peaks(i)%dmulow/obs(ii)%table%scale_mu(i)
 !  else
 !   write(*,*) 'WARNING: scale_mu is (too close to) zero!'
 !  endif
 !  if(obs(ii)%table%scale_mh(i).ge.vsmall) then
 !   peaks(i)%dm = peaks(i)%dm/obs(ii)%table%scale_mh(i)
 !  else
 !   write(*,*) 'WARNING: scale_mh is (too close to) zero!'
 !  endif   
 ! enddo
 ! 
 !end subroutine restore_uncertainties 
 !!------------------------------------------------------------------------------------   
 subroutine assign_Higgs_to_peaks_with_correlations(iter)
 ! Do this only for pdf = 2
 !
 ! NOTE: This is possibly still buggy. Only use it with iter=0.
 ! TODO: Have to extend this here for assignment-groups.
 !------------------------------------------------------------------------------------   
  use usefulbits_HS, only : neutHiggses, nanalys
  use usefulbits, only : np, Hneut
  implicit none
  
  integer, intent(in) :: iter
  integer :: i, ii, iii, n, jjj
  character(LEN=100), allocatable :: assignmentgroups(:)
  integer, allocatable :: assignmentgroups_Higgs_comb(:,:)
 
 !! allocate(assignmentgroups(nanalys))
 !! allocate(assignmentgroups_Higgs_comb(nanalys,np(Hneut))) 
 
 !! write(*,*) "Running assign_Higgs_to_peaks_with_correlations."
 
  if(iter.gt.0) write(*,*) "WARNING: Iterations in the Higgs-to-peaks assignment are ",&
 &                         "still under development."
 
  jjj = 1
  do n=1, iter
   call create_covariance_matrices()
   iii=0
   do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1
     analyses(i)%peaks(ii)%internalnumber = iii
    enddo 
    call assign_Higgs_to_peaks(analyses(i)%table, analyses(i)%peaks, n)
   enddo  
  enddo
 
 
 end subroutine assign_Higgs_to_peaks_with_correlations
 !------------------------------------------------------------------------------------    
 subroutine assign_Higgs_to_peaks(table, peaks, iterstep)
 ! This subroutine assigns the best combination of Higgs bosons to each peak observable
 ! found in ONE mutable/analysis.
 ! It calculates for every possible assignment of the Higgs bosons to the peaks a
 ! chi-squared value. It takes care that each Higgs boson is used for at most one peak.
 ! The combination with the minimal chi-squared value is selected. The relevant information
 ! about the assigned Higgs bosons is then saved in each peak object.
 !------------------------------------------------------------------------------------    
  use usefulbits, only : div, np, Hneut
  implicit none
  
  type(mutable), intent(in) :: table
  type(mupeak), dimension(:), intent(inout) :: peaks(:)
  integer, intent(in) :: iterstep
 
  integer, allocatable :: peakindices_best(:,:), domH(:), domH_tmp(:)
  integer, allocatable :: Higgs_to_be_assigned(:),Higgs_fulfills_req_assignment(:)
  integer :: Npeaks, nH, a, i, j, ii,jj, Hindex, NHiggs
  integer :: Higgs_assignment_forced,Higgs_assignment_forced_tmp
  double precision :: pccsq, pccsq_tmp, chisq_fp
 !! integer, allocatable :: indices_best(:)
  double precision :: force_in_range
 
  chisq_fp = 10000000.0D0
  nH=np(Hneut)
  Npeaks=size(peaks)
 
 ! write(*,*) 'DEBUG: Calling assign_Higgs_to_peaks for'
 ! write(*,*) 'table ID = ',table%id
 ! write(*,*) 'table expt, desc = ',table%expt, table%desc
  
  if(Npeaks.le.0) then 
   if(iterstep.eq.0) then
    write(*,'(A,1X,A,1X,A,1X,A,F4.2,A,I12,A)') ' No peaks defined for ', &
 &   trim(adjustl(table%collaboration)),trim(adjustl(table%desc)),'(',table%energy, &
 &   " TeV) search (analysis ID = ",table%id,")."
   endif 
  else
   !-Create indices matrix from combinatorics module containing all possible 
   !-peak-Higgs combinations:
   call create_peakindices(Npeaks,nH)
   allocate(peakindices_best(Npeaks,nH))
   allocate(domH(Npeaks),domH_tmp(Npeaks))
   allocate(Higgs_to_be_assigned(nH),Higgs_fulfills_req_assignment(nH))
 
 
 ! (TS 11/01/2013: Give some default values)
   Higgs_assignment_forced = 1
   call copy_matrices(peakindices(1,:,:),peakindices_best(:,:))
   do k=lbound(domH_tmp,dim=1),ubound(domH_tmp,dim=1)
    domH_tmp(k) = 0
   enddo  
 
 ! write(*,*) 'DEBUG: print peakindices before start...'
 !  do a=lbound(peakindices,dim=1),ubound(peakindices,dim=1)
 !   write(*,*) ' a = ',a
 !   write(*,*) peakindices(a,:,:)
 !  enddo
   
  if(table%mhchisq.eq.1) then
   force_in_range = assignmentrange_massobs
  else 
   force_in_range = assignmentrange
  endif 
  if(pdf.eq.1) force_in_range = 1.0D0
   
 
 ! (TS 09/09/2012: Add the criterium that if the Higgs bosons masses are close enough to 
 !  the peaks they have to be assigned. )
 !-First, find out which Higgs bosons have to be assigned. For this, we loop over all peaks
 !-and check which Higgses lie close enough (i.e. the mass difference is less than the
 !-total (gaussian) mass uncertainty). In that case, we tag this Higgs to be assigned.
   do i=lbound(Higgs_to_be_assigned,dim=1), ubound(Higgs_to_be_assigned,dim=1)
    Higgs_to_be_assigned(i)=0
   enddo
   do i=lbound(peaks,dim=1),ubound(peaks,dim=1)
    do j=lbound(Higgs_to_be_assigned,dim=1), ubound(Higgs_to_be_assigned,dim=1)  
     if(abs(peaks(i)%Higgses(j)%m-peaks(i)%mpeak).le.									&
 &	   force_in_range*sqrt(peaks(i)%Higgses(j)%dm**2 + table%deltam**2)) then
     if(useaveragemass.and.peaks(i)%Higgses(j)%mu.le.1.0D-03) then
 !    if(useaveragemass) then    
      Higgs_to_be_assigned(j)=0
     else 
      Higgs_to_be_assigned(j)=1
     endif 
     else
      !-If the chisq contribution from the Higgs masses is not used, we do NOT want
      ! to assign Higgs bosons which are far away from peak.
      if(table%mhchisq.ne.1) Higgs_to_be_assigned(j)=-1       
 !     if(table%mhchisq.ne.1.or.useaveragemass) Higgs_to_be_assigned(j)=-1     
     endif 
    enddo
   enddo	
 
 ! write(*,*) 'Higgs_to_be_assigned = ',Higgs_to_be_assigned
 
 !-Loop over all possible combinations, calculate the chisq and find the best combination.
   do a=lbound(peakindices,dim=1),ubound(peakindices,dim=1)
    pccsq_tmp = 0
 !--Loop over all peaks, i.e. rows of the combination matrices:
    do i=lbound(peakindices,dim=2),ubound(peakindices,dim=2)
 !---Calculate the chi squared value for this combination assigned to peak i:
     call calc_pc_chisq(pccsq, peaks(i), table%mhchisq, peaks(i)%Higgses, domH(i),		&
 &					   peakindices(a,i,:),iterstep)
     pccsq = pccsq + csq_mass_separation_weighted(peakindices(a,i,:), peaks(i))
 !---Add the calculated value to the total chi-squared value for all peaks:	
     pccsq_tmp = pccsq_tmp + pccsq
    enddo
    
 !   write(*,*) 'a = ',a,' temporary chisq contribution = ', pccsq_tmp
 
 !--Determine the best Higgs-to-peaks assignment:	
    if(pccsq_tmp.lt.chisq_fp) then
 !    write(*,*) 'pccsq_tmp is below chisq_fp = ', chisq_fp
      do i=lbound(Higgs_fulfills_req_assignment,dim=1), 									&
 & 	      ubound(Higgs_fulfills_req_assignment,dim=1)
       Higgs_fulfills_req_assignment(i)=0
      enddo
      Higgs_assignment_forced_tmp = 0
      do j=lbound(Higgs_to_be_assigned,dim=1),ubound(Higgs_to_be_assigned,dim=1)
       if(Higgs_to_be_assigned(j).eq.1) then
        do ii=lbound(peakindices,dim=2),ubound(peakindices,dim=2)
         do jj=lbound(peakindices,dim=3),ubound(peakindices,dim=3)
          if(peakindices(a,ii,jj).eq.j) then
          Higgs_fulfills_req_assignment(j)=1
          Higgs_assignment_forced_tmp = 1
          endif
         enddo
        enddo
       else if(Higgs_to_be_assigned(j).eq.-1) then
        Higgs_fulfills_req_assignment(j)=1
        do ii=lbound(peakindices,dim=2),ubound(peakindices,dim=2)
         do jj=lbound(peakindices,dim=3),ubound(peakindices,dim=3)
          if(peakindices(a,ii,jj).eq.j) then
          Higgs_fulfills_req_assignment(j)=0
          endif
         enddo
        enddo
       else
        Higgs_fulfills_req_assignment(j)=1
       endif 
      enddo
 !     write(*,*) 'Higgs_fulfills_req_assignment = ', Higgs_fulfills_req_assignment 
    	 if(sum(Higgs_fulfills_req_assignment).eq.nH) then
       chisq_fp = pccsq_tmp
       Higgs_assignment_forced = Higgs_assignment_forced_tmp
       call copy_matrices(peakindices(a,:,:),peakindices_best(:,:))
 	  if(a.eq.1) then
 	   do k=lbound(domH_tmp,dim=1),ubound(domH_tmp,dim=1)
         domH_tmp(k) = 0
 	   enddo
 	  else 
         domH_tmp(:) = domH(:)   
       endif
 !      write(*,*) 'Assignment taken over: ', peakindices_best  
      endif
    endif
   enddo
 !--Save information in peak object
   do i=lbound(peakindices_best,dim=1),ubound(peakindices_best,dim=1)
 !--Best Higgs Combination:
    peaks(i)%Higgs_comb(:) = peakindices_best(i,:)
 !   write(*,*) "hello: Higgs assignment of ID = ",peaks(i)%id, ": ", peaks(i)%Higgs_comb,&
 !   & "Higgs_assignment_forced: ",Higgs_assignment_forced
    peaks(i)%domH = domH_tmp(i)
    peaks(i)%Higgs_assignment_forced = Higgs_assignment_forced
    call evaluate_peak(peaks(i),table)
   enddo
   deallocate(peakindices, peakindices_best, domH, domH_tmp)
   deallocate(Higgs_to_be_assigned,Higgs_fulfills_req_assignment)  
   endif
 
 end subroutine assign_Higgs_to_peaks
 !------------------------------------------------------------------------------------    
 subroutine evaluate_peak(peak, table)
 ! Evaluates the peak information for a given Higgs boson combination and dominant Higgs
 ! (both have to be assigned to the peak before calling this subroutine!)
 !------------------------------------------------------------------------------------    
  use usefulbits, only : div, np, Hneut, small, vsmall
  implicit none
  type(mupeak) :: peak
  type(mutable) :: table
  integer :: j,k
  integer :: NHiggs,Hindex
  double precision :: normalization
 
  NHiggs=0
  do j=lbound(peak%Higgs_comb,dim=1),ubound(peak%Higgs_comb,dim=1)
   if(peak%Higgs_comb(j).ne.0) NHiggs=NHiggs+1
  enddo 
  peak%NHiggs_comb = NHiggs
 !--Chose dominant Higgs in the best Higgs combination for weights and systematics 
 !--------------
 !  In rare cases there appears a segmentation fault, 
 !  because peak%domH seems not to be initialized.
 !  HERE: Check that it is in a reasonable range.
  if(peak%domH.ne.0.and.peak%domH.le.np(Hneut)) then
   peak%channel_w(:) = peak%channel_w_allH(:,peak%domH)
   peak%channel_w_corrected_eff(:) = peak%channel_w_corrected_eff_allH(:,peak%domH)  
   peak%channel_syst(:) = peak%channel_syst_allH(:,peak%domH)
   peak%channel_systSM(:) = peak%channel_systSM_allH(:,peak%domH)
  else
 !-Part of fix: 
   peak%domH=0
 !--------------  
   call get_weights_at_peak(peak, table)
 !! If no Higgs is assigned we don't correct the efficiencies...  
   peak%channel_w_corrected_eff(:) = peak%channel_w(:)
 !!  peak%channel_w(:) = peak%channel_w_allH(:,1)        
   peak%channel_syst(:) = peak%channel_syst_allH(:,1)     
   peak%channel_systSM(:) = peak%channel_systSM_allH(:,1)     													   
  endif
 !--Subtract the correlated uncertainties from mu uncertainty:   
  call correct_mu_uncertainty_of_peak(peak, table)
 !--Add the channel contributions of the Higgses and adjust them to the "averaged weights":
  peak%total_mu=0
 !--n.b.: Have to set channel_mu to zero in case this subroutine is called several times.
  do k=lbound(peak%channel_mu,dim=1),ubound(peak%channel_mu,dim=1)
   peak%channel_mu(k)=0.0D0
   peak%channel_w_model(k)=0.0D0    
  enddo
 !--Loop over Higgses in best combination
  do j=lbound(peak%Higgs_comb,dim=1),ubound(peak%Higgs_comb,dim=1)
   if(peak%Higgs_comb(j).ne.0) then
    Hindex=peak%Higgs_comb(j)
 !----Loop over the channels and add rates
    do k=lbound(peak%channel_mu,dim=1),ubound(peak%channel_mu,dim=1)
     peak%channel_mu(k)=peak%channel_mu(k)+									&
 &   peak%channel_mu_allH(k,Hindex)*peak%channel_w_corrected_eff_allH(k,Hindex)
     peak%total_mu = peak%total_mu + 											&
 &	 peak%channel_mu_allH(k,Hindex)*peak%channel_w_corrected_eff_allH(k,Hindex)
    enddo     
   endif 
  enddo
    do k=lbound(peak%channel_mu,dim=1),ubound(peak%channel_mu,dim=1)
 !---Calculate channel weights of the model, using the possibly combined rates.
 !   (TS 20/04/2013)
     peak%channel_w_model(k)=div(peak%channel_mu(k),peak%total_mu,0.0D0,1.0D9)
 !--Reweight the rates to obtain the channel_mu 
     peak%channel_mu(k)=div(peak%channel_mu(k),peak%channel_w_corrected_eff(k),0.0D0,1.0D9)
    enddo
 !--If no Higgs boson has been assigned, use the SM weight at the peak position for
 !  the channel weight of the model (TS26/04/2013):
    if(peak%domH.eq.0) then
     peak%channel_w_model = peak%channel_w
    endif
 !--In the (unphysical) case of negative channel rates, we have to take care that the
 !  model channel weights are still positive and between 0 and 1:
    normalization = 0.0D0
    do k=lbound(peak%channel_w_model,dim=1),ubound(peak%channel_w_model,dim=1)
     normalization = normalization + abs(peak%channel_w_model(k))
    enddo
    if(abs(normalization).gt.small) then
     do k=lbound(peak%channel_w_model,dim=1),ubound(peak%channel_w_model,dim=1)
      peak%channel_w_model(k) = div(abs(peak%channel_w_model(k)),&
 &                                  normalization,1.0D0/peak%Nc,1.0D0)
     enddo
    else
 !--If the predicted signal strength is zero, use SM weights   
     peak%channel_w_model = peak%channel_w 
    endif 
    if(abs(sum(peak%channel_w_model)-1.0D0).gt.small) then
     write(*,*) "WARNING: Channel weights of the model are not correctly normalized:"
     write(*,*) peak%channel_w_model
    endif 
 end subroutine evaluate_peak
 !------------------------------------------------------------------------------------    
 subroutine calculate_total_pc_chisq(csq_tot, csq_mu, csq_mh, N, Nmu, Nmh)
 ! Calculates the total chi^2 value with the peak-centered chi^2 method. This 
 ! subroutine is called from evaluate_model in the HiggsSignals run.
 !------------------------------------------------------------------------------------    
  implicit none
  double precision, allocatable :: csq_mu_in(:), csq_mh_in(:,:), csq0(:), csq0_nocorr(:)
  double precision, intent(out) :: csq_tot, csq_mu, csq_mh
  integer, intent(out) :: N, Nmu, Nmh
  integer :: i, ii, iii, j,jj, iter, Niterations
  logical :: iterate
 
 ! Need to do iterations of the following procedure. Due to modifications in the
 ! Higgs-to-peak assignments necessary for so-called assignment groups (i.e. a set of
 ! observables which should take over the assignment our their leading observable,
 ! which should be the one with a mass measurement), the covariance matrices of the Higgs
 ! mass part change, and therefore also the chi^2 contribution from the Higgs mass.
 ! Since a cutoff chi^2(tot) < chi^2(max) applies in specific cases, this cutoff has to be
 ! re-evaluated a few times to converge to the correct total chi^2 evaluation.
 
  iterate=.True.
  Niterations=0
  do while(iterate)
 
   call calculate_mu_chisq(csq0, Nmu, 2)
 
 !--Debugging
 !  call calculate_mu_chisq(csq0_nocorr, Nmu, 2)      ! csq0 without correlations  
 !--
 
   call calculate_mu_chisq(csq_mu_in, Nmu, 0)	
   call calculate_mh_chisq(csq_mh_in, Nmh)
 
 !--Debugging  
 !  write(*,*) "chi2 values (i, max with corr, max without corr, csq_mu, csq_mh)"
 !  do i=1,size(csq0)
 !!  write(*,*) i, csq0(i),  csq0_nocorr(i), csq_mu_in(i), csq_mh_in(1,i)
 !  write(*,*) i, csq0(i), csq_mu_in(i), csq_mh_in(1,i)  
 !  enddo
 
   
   
   iii=0 
   do i=1, size(analyses)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1  
 !    write(*,*) "analyses(",i,")%peaks(",ii,")%Higgs_assignment_forced = ",analyses(i)%peaks(ii)%Higgs_assignment_forced
     if(analyses(i)%peaks(ii)%Higgs_assignment_forced.eq.0.and.(.not.maximalchisq).or.&
 &      analyses(i)%peaks(ii)%Higgs_assignment_forced.eq.1.and.(.not.maximalchisq).and.pdf.eq.1) then
      if((csq_mu_in(iii)+sum(csq_mh_in(:,iii))).gt.csq0(iii).and.&
 &         analyses(i)%peaks(ii)%NHiggs_comb.gt.0.and.analyses(i)%table%mhchisq.eq.1) then
        analyses(i)%peaks(ii)%undo_assignment=1
 !---Now, undo Higgs-to-peak-assignment for the whole group (if existent)	 
  	  if(len(trim(analyses(i)%peaks(ii)%assignmentgroup)).ne.0) then
  	   do j=1, size(analyses)
         do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
          if(analyses(i)%peaks(ii)%assignmentgroup.eq.&
 &           analyses(j)%peaks(jj)%assignmentgroup) then
           analyses(j)%peaks(jj)%undo_assignment=1
          endif
         enddo
        enddo
       endif 
 	 endif 
     endif
    enddo   
   enddo 
 
   call correcting_Higgs_to_peak_assignment(iterate)
   if(iterate) Niterations = Niterations + 1
   deallocate(csq_mu_in, csq_mh_in) 
  enddo
  
 !! if(Niterations.gt.0) write(*,*) "Ran ",Niterations," iterations to determine Higgs to peak assignment."
 
  ! After these iterations, the code should know the correct assignments.
  call calculate_mh_chisq(csq_mh_in, Nmh)	! This will undo the assignments, if necessary
 ! call calculate_mu_chisq(csq0, Nmu, 1)
 ! call calculate_mu_chisq(csq0_nocorr, Nmu, 2)      ! csq0 without correlations
 
  call calculate_mu_chisq(csq_mu_in, Nmu, 0)	! Need to evaluate this again with new assignments
  
  !Calculate total ndf:
  N = Nmu + Nmh
  
  csq_mu = 0.0D0 
  csq_mh = 0.0D0  
  csq_tot = 0.0D0
  
  iii=0 
  do i=1, size(analyses)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1  
 !--Only allow positive chisq contributions if wanted   
    if(minimalchisq) then
     if(csq_mu_in(iii).lt.0.0D0) csq_mu_in(iii) = 0.0D0 
     do j=lbound(csq_mh_in, dim=1), ubound(csq_mh_in, dim=1)
      if(csq_mh_in(j,iii).lt.0.0D0) csq_mh_in(j,iii) = 0.0D0 
     enddo 
    endif 
 !--Assign chisq_mu and chisq_mh such that the total chisq does not exceed the maximum
 !--chisq csq0
    if(maximalchisq) then	
     analyses(i)%peaks(ii)%chisq_mu = min(csq_mu_in(iii),csq0(iii))
     analyses(i)%peaks(ii)%chisq_mh = min(csq0(iii)-analyses(i)%peaks(ii)%chisq_mu,		&
 &									    sum(csq_mh_in(:,iii)))
 !TESTING: comment out this -->
 !   elseif(analyses(i)%peaks(ii)%Higgs_assignment_forced.eq.0) then
 !    analyses(i)%peaks(ii)%chisq_mu = min(csq_mu_in(iii),csq0(iii))
 !    analyses(i)%peaks(ii)%chisq_mh = min(csq0(iii)-analyses(i)%peaks(ii)%chisq_mu,		&
 !&									    sum(csq_mh_in(:,iii)))
 !!	write(*,*) csq0(iii),csq_mu_in(iii),sum(csq_mh_in(:,iii))
 ! NEW FOR CORRECTED ASSIGNMENTS:
 !   elseif(analyses(i)%peaks(ii)%Higgs_assignment_forced.eq.1.and.&
 !&         analyses(i)%peaks(ii)%domH.eq.0) then
     elseif(analyses(i)%peaks(ii)%domH.eq.0) then
     analyses(i)%peaks(ii)%chisq_mu = csq0(iii)
     analyses(i)%peaks(ii)%chisq_mh = 0.0D0
    else
 !!    write(*,*) "HtP assignment is forced for analysis: ",iii   
     analyses(i)%peaks(ii)%chisq_mu = csq_mu_in(iii)
     analyses(i)%peaks(ii)%chisq_mh = sum(csq_mh_in(:,iii))
 !!	write(*,*) csq0(iii),csq_mu_in(iii),sum(csq_mh_in(:,iii))    
    endif
    analyses(i)%peaks(ii)%chisq_tot = analyses(i)%peaks(ii)%chisq_mu + 					&
 &									 analyses(i)%peaks(ii)%chisq_mh
    analyses(i)%peaks(ii)%chisq_max = csq0(iii)
    csq_mu = csq_mu + analyses(i)%peaks(ii)%chisq_mu
    csq_mh = csq_mh + analyses(i)%peaks(ii)%chisq_mh
    csq_tot = csq_tot + analyses(i)%peaks(ii)%chisq_tot
    
   enddo 
  enddo 
 
  deallocate(csq_mu_in, csq_mh_in)
 
 ! write(*,*) "End of subroutine calculate_total_pc_chisq."
 
 end subroutine calculate_total_pc_chisq
 !-----------------------------------------------------------------------------------
 subroutine correcting_Higgs_to_peak_assignment(iterate)
 !-----------------------------------------------------------------------------------
  use usefulbits, only : np, Hneut
  implicit none
  integer :: i, ii, k
  logical, intent(inout) :: iterate
  
  iterate=.False.
   do i=1, size(analyses)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     if(analyses(i)%peaks(ii)%undo_assignment.eq.1.and.analyses(i)%peaks(ii)%domH.ne.0)then
 !!     write(*,*) "Correcting HtP."
      iterate=.True.
      do k=1,np(Hneut)
       analyses(i)%peaks(ii)%Higgs_comb(k)=0
      enddo
      analyses(i)%peaks(ii)%domH=0
      call evaluate_peak(analyses(i)%peaks(ii),analyses(i)%table)
 !!     analyses(i)%peaks(ii)%undo_assignment=0
     endif
    enddo
   enddo 
 
 end subroutine correcting_Higgs_to_peak_assignment
 !------------------------------------------------------------------------------------
 subroutine create_covariance_matrices()
 !------------------------------------------------------------------------------------
  if(.not.allocated(analyses)) then
   stop 'Error in subroutine create_covariance_matrices: analyses is not allocated.'
  endif
  
  write(*,*) "hello: Called subroutine create_covariance_matrices..."
  
  if(allocated(cov)) deallocate(cov)
  call create_covariance_matrix_mu(0)  
  if(pdf.eq.2) then
 !  if(useaveragemass) then
    if(allocated(cov_mh_av)) deallocate(cov_mh_av)
    call create_covariance_matrix_mh_av(0)
    if(allocated(cov_mh_av_max)) deallocate(cov_mh_av_max)
    call create_covariance_matrix_mh_av(1)
 !  else
    if(allocated(cov_mhneut)) deallocate(cov_mhneut)
     call create_covariance_matrix_mhneut(0)
    if(allocated(cov_mhneut_max)) deallocate(cov_mhneut_max)
     call create_covariance_matrix_mhneut(1)
 !   endif 
  endif
 
 end subroutine create_covariance_matrices
 !------------------------------------------------------------------------------------    
 subroutine calculate_mu_chisq(csq_mu, N, domax)
 !------------------------------------------------------------------------------------    
 ! use usefulbits_hs, only : peaklist, cov
  use numerics, only : invmatrix, matmult
 
  integer :: i, ii, iii
  double precision, allocatable :: v(:), vmat(:,:), invcov(:,:), v2(:)
  double precision, allocatable, intent(out) :: csq_mu(:)
  character(LEN=50) :: title = "covariance matrix for signal strength mu"
  integer, intent(out) :: N
  integer, intent(in) :: domax   ! if 1, then calculate maximal chisq
   
  if(allocated(cov)) deallocate(cov)
  call create_covariance_matrix_mu(domax) 
  
  if(allocated(mu_vector)) deallocate(mu_vector)
 
  N = size(cov,dim=1)
  allocate(v(N), vmat(N,1),invcov(N,N), v2(N), csq_mu(N))
  allocate(mu_vector(N))
  
 !! write(*,*) ' domax = ',domax
  
  !-First construct the vector (mupred - muobs)_iii
  iii=0
  do i=1, size(analyses, dim=1)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    if(domax.ge.1) then
     v(iii) = analyses(i)%peaks(ii)%mu
    else	
     v(iii) = analyses(i)%peaks(ii)%mu - analyses(i)%peaks(ii)%total_mu
    endif
    vmat(iii,1) = v(iii)
    
 !!   write(*,*) 'v(',iii,') = ',v(iii)
   enddo
  enddo
 
 
 ! Copy vector into global module vector (for later access)
  mu_vector = v
     
  call invmatrix(cov,invcov)   
  call matmult(invcov,vmat,v2,N,1)
  
 !! write(*,*) "Calculating mu chi^2. domax = ", domax
  
  do i=1, N
   csq_mu(i) = v(i)*v2(i)
 !!  write(*,*) i, analyses(i)%peaks(1)%total_mu,csq_mu(i)
  enddo
 !! write(*,*) "sum = ", sum(csq_mu(:))
 
  deallocate(v,vmat,invcov,v2)
 
 end subroutine calculate_mu_chisq
 !------------------------------------------------------------------------------------    
 subroutine calculate_mh_chisq(csq_mh_out, ndf)
 !------------------------------------------------------------------------------------    
 ! use usefulbits_hs, only : peaklist
  use usefulbits, only : np, Hneut
  use numerics, only : invmatrix, matmult
 
  integer, intent(out) :: ndf
  integer :: i, ii, iii, k, nH, N, Hindex
  double precision, allocatable :: v(:,:), invcov(:,:), v2(:), vmat(:,:)
  double precision, allocatable, intent(out) :: csq_mh_out(:,:)
  double precision :: m_av_iii, dm_av_iii
 
  if((pdf.eq.1).or.(pdf.eq.3)) then
 !-First, determine number of peaks: 
   N = 0
   do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
    do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     N = N + 1
    enddo 
   enddo  
   nH = np(Hneut)
   if(useaveragemass) then
    allocate(csq_mh_out(1,N))
   else 
    allocate(csq_mh_out(nH,N))  
   endif
    
 !-First, fill the chisq vector with zeros:
   csq_mh_out(:,:) = 0.0D0
   
   iii=0
   do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1
     if(useaveragemass) then
      call get_average_mass_for_peak(analyses(i)%peaks(ii)%Higgs_comb, &
 &                                   analyses(i)%peaks(ii), m_av_iii, dm_av_iii)
-     csq_mh_out(1,iii) = csq_mh(m_av_iii, analyses(i)%peaks(ii)%mpeak, dm_av_iii, &
+	 if(m_av_iii.gt.0.0D0) then
+      csq_mh_out(1,iii) = csq_mh(m_av_iii, analyses(i)%peaks(ii)%mpeak, dm_av_iii, &
 &                               analyses(i)%peaks(ii)%dm) 
+     endif
     else
      do k=1,nH
       Hindex = analyses(i)%peaks(ii)%Higgs_comb(k)
       if(Hindex.ne.0.and.analyses(i)%table%mhchisq.eq.1) then 
        csq_mh_out(Hindex,iii) = csq_mh(analyses(i)%peaks(ii)%Higgses(Hindex)%m, 			&
 &         analyses(i)%peaks(ii)%mpeak,analyses(i)%peaks(ii)%Higgses(Hindex)%dm,			&
 &		  analyses(i)%peaks(ii)%dm)
 	  endif
      enddo
     endif
    enddo 
   enddo 
   
   
  else if(pdf.eq.2) then
   if(useaveragemass) then
    if(allocated(cov_mh_av)) deallocate(cov_mh_av)
 
    call create_covariance_matrix_mh_av(0)
    N = size(cov_mh_av,dim=1)
 
    allocate(v(1,N), v2(N), csq_mh_out(1,N), vmat(N,1))
 
    do i=1,N
     v(1,i) = 0.0D0
    enddo
 
    iii=0
    do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
      iii=iii+1
      call get_average_mass_for_peak(analyses(i)%peaks(ii)%Higgs_comb, &
 &                                   analyses(i)%peaks(ii), m_av_iii, dm_av_iii)         
      if(m_av_iii.gt.0) then     
       v(1,iii) = m_av_iii - analyses(i)%peaks(ii)%mpeak
      endif  
     enddo
    enddo
    
    call invmatrix(cov_mh_av(:,:),invcov) 
 
    vmat(:,1)=v(1,:)
    call matmult(invcov,vmat,v2,N,1)   
    do i=1, N
     csq_mh_out(1,i) = v(1,i)*v2(i)
    enddo   
 
   else
    if(allocated(cov_mhneut)) deallocate(cov_mhneut)
    call create_covariance_matrix_mhneut(0)
 
    nH = size(cov_mhneut,dim=1)
    N = size(cov_mhneut,dim=2)
    allocate(v(nH,N), v2(N), csq_mh_out(nH,N), vmat(N,1))
  
 !-Construct the vector (mhpred - mhobs)_iii. Do this for every Higgs boson
 !-of the model. If the Higgs boson (Hindex) is not assigned to the peak, we set
 !-the entry of the vector to zero.
 !-First, fill the vectors with zeros:
    do k=1,nH
     do i=1,N
      v(k,i) = 0.0D0
     enddo
    enddo  
 
    do k=1,nH
     iii=0
     do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
      do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
       iii=iii+1
       Hindex = analyses(i)%peaks(ii)%Higgs_comb(k)
       if(Hindex.ne.0) then     
        v(Hindex,iii) = analyses(i)%peaks(ii)%Higgses(Hindex)%m - &
 &  	                   analyses(i)%peaks(ii)%mpeak
       endif  
      enddo
     enddo
    enddo 
 
    do k=1,nH 		!-n.b.: this loops now over Hindex
     call invmatrix(cov_mhneut(k,:,:),invcov) 
     vmat(:,1)=v(k,:)
 !   call matmult(invcov,v(k,:),v2,N,1)
     call matmult(invcov,vmat,v2,N,1)   
     do i=1, N
      csq_mh_out(k,i) = v(k,i)*v2(i)
      if(csq_mh_out(k,i).ge.0.00001D0) then
 !!     write(*,*) "hello: ",k,i,v(k,i),sign(1.0D0,v(k,i)), csq_mh_out(k,i)
      endif
     enddo   
    enddo
    
   endif   
   deallocate(v,v2,vmat,invcov)  
 
  endif
  
  if(useaveragemass) then
 !--Calculate additional chi^2 contribution from the mass separation
    iii=0
    do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
      iii=iii+1
      if(analyses(i)%table%mhchisq.eq.1) then
       csq_mh_out(1,iii) = csq_mh_out(1,iii) + csq_mass_separation_weighted( &
 &      analyses(i)%peaks(ii)%Higgs_comb, analyses(i)%peaks(ii))
      endif
     enddo
    enddo 
  endif  
    
  
 
 ! write(*,*) "before deallocate csq_mh_out"
 ! deallocate(csq_mh_out)
 ! write(*,*) "after deallocate csq_mh_out"
 
 !--Determine number of observables ndf. This checks for each peak whether the mass
 !--resolution is less than a huge number and thus the chisq evaluation from the mass
 !--measurement is enabled.
   ndf=0
   if(pdf.eq.2.or.pdf.eq.3) then
    do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
  	if(analyses(i)%table%mhchisq.eq.1) ndf=ndf+1
     enddo
    enddo 	
   endif
 
 ! write(*,*) "End of subroutine calculate_mh_chisq."
 end subroutine calculate_mh_chisq
 !------------------------------------------------------------------------------------    
 subroutine create_covariance_matrix_mhneut(domax)
 !------------------------------------------------------------------------------------    
  use usefulbits, only : np, Hneut
  implicit none
 
  double precision :: dratesq, dmu0sq, dmtemp
  character(LEN=50) :: title 	
  integer, intent(in) ::  domax   ! = 0 or 1. If set to 1, then fill all off-diagonal elements
  							! with squared theoretical mass uncertainty, corresponding to
  							! a complete Higgs-to-peaks assignment
  integer :: Npeaks,i,ii,iii,j,jj,jjj,k,Hindex_i, Hindex_j
   
 !! write(*,*) "Create Higgs mass covariance matrix" 
   
  Npeaks = 0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    Npeaks = Npeaks + 1
   enddo 
  enddo
  
  if(domax.eq.0) then
   allocate(cov_mhneut(np(Hneut),Npeaks,Npeaks))
  elseif(domax.eq.1) then
   allocate(cov_mhneut_max(np(Hneut),Npeaks,Npeaks))
  else
   stop'ERROR in subroutine create_covariance_matrix_mhneut. Specify domax correctly!'
  endif
   
 !-First, fill all elements of the covariance matrices with zero except the diagonal
 !-elements which contain the experimental mass resolution squared
  do k=1,np(Hneut)
   iii=0
   do i=1, size(analyses)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1
     jjj=0
     do j=1, size(analyses)
      do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
  	  jjj=jjj+1 	  
 	  if(domax.eq.0) cov_mhneut(k,iii,jjj) = 0.0D0
 	  if(domax.eq.1) cov_mhneut_max(k,iii,jjj) = 0.0D0
 	  if(iii.eq.jjj) then
  !-----Deactivate mh chisq contributions for those analysis which are tagged mhchisq==0
  !-----by setting the uncertainty to a very large value. 
 	   if(analyses(i)%table%mhchisq.eq.1) then
 	    if(domax.eq.0) cov_mhneut(k,iii,jjj) = analyses(i)%peaks(ii)%dm**2
 	    if(domax.eq.1) cov_mhneut_max(k,iii,jjj) = analyses(i)%peaks(ii)%dm**2
 	   else
 	    if(domax.eq.0) cov_mhneut(k,iii,jjj) = vlarge**2
 	    if(domax.eq.1) cov_mhneut_max(k,iii,jjj) = vlarge**2	    
 	   endif 	  
 	  endif
      enddo
     enddo
    enddo 
   enddo
  enddo 
 	     
 
 !-Now, look for Higgs bosons shared by 2 peaks and fill the corresponding cov. matrix
 !-element with the theoretical uncertainty squared of this Higgs boson.
  do k=1,np(Hneut)
   iii=0
   do i=1, size(analyses)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1
     jjj=0
     do j=1, size(analyses)
      do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
  	  jjj=jjj+1 	  
 !      Hindex_i = analyses(i)%peaks(ii)%Higgs_comb(k)
 !      Hindex_j = analyses(j)%peaks(jj)%Higgs_comb(k)      
 !	  if((Hindex_i.eq.Hindex_j).and.(Hindex_i.ne.0).and.domax.eq.0) then
       if(int_in_array(k,analyses(i)%peaks(ii)%Higgs_comb).and.int_in_array(k, &
 &        analyses(j)%peaks(jj)%Higgs_comb).and.domax.eq.0) then
 !      write(*,*) 'debug: k = ',k,', jjj = ',jjj,' comb1 =, ', &
 !      & analyses(i)%peaks(ii)%Higgs_comb,' comb2 = ',analyses(j)%peaks(jj)%Higgs_comb 
 	   if(correlations_mh.or.(.not.correlations_mh.and.iii.eq.jjj)) then
-        if(anticorrmh) then
-         cov_mhneut(k,iii,jjj)=cov_mhneut(k,iii,jjj) + 					&
-& sign(1.0D0,(analyses(i)%peaks(ii)%Higgses(k)%m-analyses(i)%peaks(ii)%mpeak))*  &
-& sign(1.0D0,(analyses(j)%peaks(jj)%Higgses(k)%m-analyses(j)%peaks(jj)%mpeak))*  &
-& analyses(i)%peaks(ii)%Higgses(k)%dm**2
-         else
+!        if(anticorrmh) then
+!         cov_mhneut(k,iii,jjj)=cov_mhneut(k,iii,jjj) + 					&
+!& sign(1.0D0,(analyses(i)%peaks(ii)%Higgses(k)%m-analyses(i)%peaks(ii)%mpeak))*  &
+!& sign(1.0D0,(analyses(j)%peaks(jj)%Higgses(k)%m-analyses(j)%peaks(jj)%mpeak))*  &
+!& analyses(i)%peaks(ii)%Higgses(k)%dm**2
+!         else
           cov_mhneut(k,iii,jjj)=cov_mhneut(k,iii,jjj) + 					&
 & analyses(i)%peaks(ii)%Higgses(k)%dm**2 
-         endif
+!         endif
    	   endif
 	  elseif(domax.eq.1) then
 	   if(correlations_mh.or.(.not.correlations_mh.and.iii.eq.jjj)) then
 !	    
 !NEW TEST (sign dependence):
-        if(anticorrmh) then
-         cov_mhneut_max(k,iii,jjj)= cov_mhneut_max(k,iii,jjj) + 							&
-& sign(1.0D0,(analyses(i)%peaks(ii)%Higgses(k)%m-analyses(i)%peaks(ii)%mpeak))*  &
-& sign(1.0D0,(analyses(j)%peaks(jj)%Higgses(k)%m-analyses(j)%peaks(jj)%mpeak))*  &
-& analyses(i)%peaks(ii)%Higgses(k)%dm**2
-        else
+!        if(anticorrmh) then
+!         cov_mhneut_max(k,iii,jjj)= cov_mhneut_max(k,iii,jjj) + 							&
+!& sign(1.0D0,(analyses(i)%peaks(ii)%Higgses(k)%m-analyses(i)%peaks(ii)%mpeak))*  &
+!& sign(1.0D0,(analyses(j)%peaks(jj)%Higgses(k)%m-analyses(j)%peaks(jj)%mpeak))*  &
+!& analyses(i)%peaks(ii)%Higgses(k)%dm**2
+!        else
         cov_mhneut_max(k,iii,jjj)= cov_mhneut_max(k,iii,jjj) + 							&
 & analyses(i)%peaks(ii)%Higgses(k)%dm**2
-        endif
+!        endif
 	   endif
   	  endif  	  
      enddo
     enddo 
    enddo 	 
   enddo 
  enddo
 !! title = "mass covariance matrix for maximal assignment, first Higgs boson"
 !! if(domax.eq.1) call print_dble_matrix(cov_mhneut_max(1,:,:), title)
 ! title = "covariance matrix for mh1"
 ! call print_dble_matrix(cov_mhneut(1,:,:), title)
 ! title = "covariance matrix for mh2"
 ! call print_dble_matrix(cov_mhneut(2,:,:), title)
 
 !! title = "covariance matrix for signal strength mh3" 
 !! call print_dble_matrix(cov_mhneut(3,:,:), title) 
 end subroutine create_covariance_matrix_mhneut
 !------------------------------------------------------------------------------------    
 subroutine create_covariance_matrix_mh_av(domax)
 !------------------------------------------------------------------------------------    
  use usefulbits, only : np, Hneut
  implicit none
 
  double precision :: dratesq, dmu0sq, dmtemp
  character(LEN=50) :: title 	
  integer, intent(in) ::  domax   ! = 0 or 1. If set to 1, then fill all off-diagonal elements
  							! with squared theoretical mass uncertainty, corresponding to
  							! a complete Higgs-to-peaks assignment
  integer :: Npeaks,i,ii,iii,j,jj,jjj,k,Hindex_i, Hindex_j
  integer, dimension(np(Hneut)) :: ones
  double precision :: m_av_iii, m_av_jjj
  double precision :: dm_av_iii, dm_av_jjj  
 ! write(*,*) "Create Higgs mass covariance matrix" 
  ones = 1 
   
  Npeaks = 0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    Npeaks = Npeaks + 1
   enddo 
  enddo
  
  if(domax.eq.0) then
   allocate(cov_mh_av(Npeaks,Npeaks))
  elseif(domax.eq.1) then
   allocate(cov_mh_av_max(Npeaks,Npeaks))
  else
   stop'ERROR in subroutine create_covariance_matrix_mh_av. Specify domax correctly!'
  endif
   
 !-First, fill all elements of the covariance matrices with zero except the diagonal
 !-elements which contain the experimental mass resolution squared
 ! do k=1,np(Hneut)
  iii=0
  do i=1, size(analyses)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    jjj=0
    do j=1, size(analyses)
     do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
      jjj=jjj+1 	  
 	 if(domax.eq.0) cov_mh_av(iii,jjj) = 0.0D0
 	 if(domax.eq.1) cov_mh_av_max(iii,jjj) = 0.0D0
      if(iii.eq.jjj) then
       if(analyses(i)%table%mhchisq.eq.1) then
 	   if(domax.eq.0) cov_mh_av(iii,jjj) = analyses(i)%peaks(ii)%dm**2
 	   if(domax.eq.1) cov_mh_av_max(iii,jjj) = analyses(i)%peaks(ii)%dm**2
       else
        if(domax.eq.0) cov_mh_av(iii,jjj) = vlarge**2
 	   if(domax.eq.1) cov_mh_av_max(iii,jjj) = vlarge**2	    
 	  endif 	  
 	 endif
     enddo
    enddo
   enddo 
  enddo
 !enddo 
 	     
 !-Now, look for Higgs bosons shared by 2 peaks and fill the corresponding cov. matrix
 !-element with the theoretical uncertainty squared of this Higgs boson.
  do k=1,np(Hneut)
   iii=0
   do i=1, size(analyses)
    do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
     iii=iii+1
     call get_average_mass_for_peak(analyses(i)%peaks(ii)%Higgs_comb, &
 &                                  analyses(i)%peaks(ii), m_av_iii, dm_av_iii)
 !    write(*,*) "Higgs comb = ",analyses(i)%peaks(ii)%Higgs_comb," average mass = ",m_av_iii, dm_av_iii    
     jjj=0    
     do j=1, size(analyses)
      do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
  	  jjj=jjj+1
       call get_average_mass_for_peak(analyses(j)%peaks(jj)%Higgs_comb, &
 &                                    analyses(j)%peaks(jj), m_av_jjj, dm_av_jjj) 	  
       if(int_in_array(k,analyses(i)%peaks(ii)%Higgs_comb).and.int_in_array(k, &
 &        analyses(j)%peaks(jj)%Higgs_comb).and.domax.eq.0) then              
 	   if(correlations_mh.or.(.not.correlations_mh.and.iii.eq.jjj)) then
-        if(anticorrmh) then
-         cov_mh_av(iii,jjj)=cov_mh_av(iii,jjj) + 					           &
-&         sign(1.0D0,(m_av_iii-analyses(i)%peaks(ii)%mpeak)) *                 &
-&         sign(1.0D0,(m_av_jjj-analyses(j)%peaks(jj)%mpeak)) *                 &
-&         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
-&         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
-&         dm_av_iii * dm_av_jjj
-         else
+!        if(anticorrmh) then
+!         cov_mh_av(iii,jjj)=cov_mh_av(iii,jjj) + 					           &
+!&         sign(1.0D0,(m_av_iii-analyses(i)%peaks(ii)%mpeak)) *                 &
+!&         sign(1.0D0,(m_av_jjj-analyses(j)%peaks(jj)%mpeak)) *                 &
+!&         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
+!&         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
+!&         dm_av_iii * dm_av_jjj
+!         else
           cov_mh_av(iii,jjj)=cov_mh_av(iii,jjj) + 	                           &
 &         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
 &         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
 &         dm_av_iii * dm_av_jjj
-         endif
+!         endif
    	    endif
 	  elseif (domax.eq.1) then
 	   if(correlations_mh.or.(.not.correlations_mh.and.iii.eq.jjj)) then
         call get_average_mass_for_peak(ones, analyses(i)%peaks(ii), m_av_iii, dm_av_iii)    
         call get_average_mass_for_peak(ones, analyses(j)%peaks(jj), m_av_jjj, dm_av_jjj)
-        if(anticorrmh) then
-         cov_mh_av_max(iii,jjj)=cov_mh_av_max(iii,jjj) + 					           &
-&         sign(1.0D0,(m_av_iii-analyses(i)%peaks(ii)%mpeak)) *                 &
-&         sign(1.0D0,(m_av_jjj-analyses(j)%peaks(jj)%mpeak)) *                 &
-&         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
-&         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
-&         dm_av_iii * dm_av_jjj
-         else
+!        if(anticorrmh) then
+!         cov_mh_av_max(iii,jjj)=cov_mh_av_max(iii,jjj) + 					           &
+!&         sign(1.0D0,(m_av_iii-analyses(i)%peaks(ii)%mpeak)) *                 &
+!&         sign(1.0D0,(m_av_jjj-analyses(j)%peaks(jj)%mpeak)) *                 &
+!&         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
+!&         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
+!&         dm_av_iii * dm_av_jjj
+!         else
           cov_mh_av_max(iii,jjj)=cov_mh_av_max(iii,jjj) + 	                           &
 &         analyses(i)%peaks(ii)%Higgses(k)%mu/analyses(i)%peaks(ii)%total_mu * &
 &         analyses(j)%peaks(jj)%Higgses(k)%mu/analyses(j)%peaks(jj)%total_mu * &
 &         dm_av_iii * dm_av_jjj
-         endif
+!         endif
 	   endif
   	  endif 
   	   	  
      enddo
     enddo 
    enddo 	 
   enddo 
  enddo
 ! title = "mass averaged covariance matrix"
 !! if(domax.eq.1) call print_dble_matrix(cov_mh_av_max(1,:,:), title)
 !! title = "covariance matrix for signal strength mh2"
 ! call print_dble_matrix(cov_mh_av(:,:), title)
 !! title = "covariance matrix for signal strength mh3" 
 !! call print_dble_matrix(cov_mh_av(3,:,:), title) 
 end subroutine create_covariance_matrix_mh_av
 
 !------------------------------------------------------------------------------------ 
 subroutine correct_mu_uncertainty_of_peak(peak, table)
 ! The mu uncertainty as given in the mutable contains also systematic uncertainties for
 ! the luminosity and signal rate. These uncertainties are highly correlated to other
 ! analyses. Therefore, we subtract them here to obtain the intrinsic mu uncertainty of
 ! this peak. The correlated uncertainties enter later via the covariance matrix.
 !------------------------------------------------------------------------------------    
  use usefulbits_hs, only : usescalefactor, output_level,symmetricerrors,&
 & absolute_errors, THU_included!, withcorrexpsyst
  implicit none
 
  type(mupeak), intent(inout) :: peak
  type(mutable), intent(in) :: table
 ! double precision, intent(in) :: dlumi  	! Uncertainty of Luminosity (relative)
  integer :: j
  double precision :: dcsq, dmulow0sq, dmuup0sq, allsystsq, dmuaverage, dmuaverage0sq, mu
 
  dcsq = 0
  do j=1, peak%Nc
   dcsq = dcsq + peak%channel_systSM(j)**2
  enddo
 
  if(absolute_errors) then
   mu=peak%mu_original
  else
   mu=peak%mu
  endif
 
 ! if(.not.symmetricerrors) then
  if(THU_included) then
 !  if(withcorrexpsyst) then
 !   allsystsq = 0.0D0
 !   do j=lbound(table%correxpsyst,dim=1),ubound(table%correxpsyst,dim=1)
 !    allsystsq = allsystsq + table%correxpsyst(j)**2
 !   enddo 
 !   dmulow0sq = (peak%dmulow)**2-(allsystsq + dcsq)*mu**2
 !   dmuup0sq = (peak%dmuup)**2-(allsystsq + dcsq)*mu**2
 !  else 
    dmulow0sq = (peak%dmulow)**2-(table%dlumi*mu)**2-dcsq*mu**2
    dmuup0sq = (peak%dmuup)**2-(table%dlumi*mu)**2-dcsq*mu**2
 !  endif
  else
 !- In the case of future projections we usually use measurements
 !- without theoretical uncertainty included:
   dmulow0sq = (peak%dmulow)**2
   dmuup0sq = (peak%dmuup)**2
  endif
   
   if(usescalefactor) then
    dmulow0sq = peak%scale_mu**2*dmulow0sq
    dmuup0sq =  peak%scale_mu**2*dmuup0sq
   endif
   if(.not.symmetricerrors) then
   peak%dmulow0sq = dmulow0sq
   peak%dmuup0sq = dmuup0sq
   else
    if(peak%dmulow0sq.lt.0.0d0.or.peak%dmuup0sq.lt.0.0d0) then
     write(*,*) "WARNING: squared intrinsic mu uncertainty is negative!"
    endif 
    peak%dmulow0sq = (sqrt(abs(dmulow0sq))+sqrt(abs(dmuup0sq)))**2/4.0d0
    peak%dmuup0sq = (sqrt(abs(dmulow0sq))+sqrt(abs(dmuup0sq)))**2/4.0d0
   endif 
 ! else
 !  dmuaverage = (peak%dmulow+peak%dmuup)/2.
 !  if(withcorrexpsyst) then
 !  allsystsq = 0.0D0
 !   do j=lbound(table%correxpsyst,dim=1),ubound(table%correxpsyst,dim=1)
 !    allsystsq = allsystsq + table%correxpsyst(j)**2
 !   enddo 
 !   dmuaverage0sq = (dmuaverage)**2-(allsystsq + dcsq)*peak%mu**2
 !  else 
 !   dmuaverage0sq = (dmuaverage)**2-(table%dlumi*peak%mu)**2-dcsq*peak%mu**2
 !  endif
 !  if(usescalefactor) then
 !   dmuaverage0sq = peak%scale_mu**2*dmuaverage0sq
 !  endif
 !  peak%dmulow0sq = dmuaverage0sq
 !  peak%dmuup0sq = dmuaverage0sq
 ! endif
      
 
 
 ! if(output_level.ne.0) then
   if(peak%dmulow0sq.lt.0.0D0) then
    write(*,*) "WARNING: Negative intrinsic (lower) error squared for observable ID = ",&
    			 peak%ID,", with value ",peak%dmulow0sq
   endif 
   if(peak%dmuup0sq.lt.0.0D0) then
    write(*,*) "WARNING: Negative intrinsic (upper) error squared for observable ID = ",&
    			 peak%ID,", with value ",peak%dmuup0sq
   endif 
 ! endif 
 
  
 !! write(*,*) "Original / Corrected uncertainties (low): ",peak%dmulow, sqrt(dmulow0sq)
 !! write(*,*) "Original / Corrected uncertainties (up): ",peak%dmuup, sqrt(dmuup0sq)
  
  
 end subroutine correct_mu_uncertainty_of_peak
 !------------------------------------------------------------------------------------    
 subroutine create_covariance_matrix_mu(domax)
 !------------------------------------------------------------------------------------    
  use usefulbits_hs, only : withcorrexpsyst, absolute_errors
  use expt_syst, only : get_expt_syst_corr_for_peaks
  implicit none
 
  integer, intent(in) :: domax   ! if 1, then use predicted mu == 0
  double precision :: dratesq, dmu0sq, s1, s2, mu_iii, mu_jjj, corrsyst, corrsystSM
  integer :: Npeaks
  integer :: i,ii,iii,j,jj,jjj
  character(LEN=50) :: title
  logical :: corr
  integer csqmax
 
 !---TRY TO EVALUATE THE MAX CHISQ WITHOUT CORRELATIONS---!
  if(domax.eq.1) then
   csqmax = 1
   corr=correlations_mu
  elseif(domax.eq.2) then
   csqmax = 1
   corr=.False.
  else
   csqmax = 0
   corr=correlations_mu
  endif
 !--------------------------------------------------------!  
   
  Npeaks = 0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
    Npeaks = Npeaks + analyses(i)%Npeaks
  enddo
    
  allocate(cov(Npeaks,Npeaks))
  
  iii=0
  !--Loop twice over all peaks to construct matrix
  do i=1, size(analyses)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    if(absolute_errors) then
     mu_iii=analyses(i)%peaks(ii)%mu_original
    else
     mu_iii=analyses(i)%peaks(ii)%mu
    endif   
    jjj=0
    do j=1, size(analyses)
     do jj=lbound(analyses(j)%peaks,dim=1),ubound(analyses(j)%peaks,dim=1)
  	 jjj=jjj+1
      if(absolute_errors) then
       mu_jjj=analyses(j)%peaks(jj)%mu_original
      else
       mu_jjj=analyses(j)%peaks(jj)%mu
      endif
 
  	 if(usescalefactor) then
  	  s1 = analyses(i)%peaks(ii)%scale_mu
    	  s2 = analyses(j)%peaks(jj)%scale_mu
    	 else
    	  s1 = 1.0D0
    	  s2 = 1.0D0
    	 endif  
 	 cov(iii,jjj)=0.0D0
  	 if(corr.or.(.not.corr.and.iii.eq.jjj)) then
       call get_rate_uncertainties_sq_peaks(dratesq,analyses(i)%peaks(ii),&
       &    analyses(j)%peaks(jj),analyses(i)%table%collider, analyses(j)%table%collider)
+
       if(anticorrmu) then
+
 !-----Treat luminosity uncertainty as correlated systematic error if same collaboration:
  	   if(analyses(i)%table%collaboration.eq.analyses(j)%table%collaboration) then
-!!        if(withcorrexpsyst) then !!THIS IS IN TESTING PHASE!!
-!!         do k=lbound(analyses(i)%table%correxpsyst,dim=1),&
-!!&            ubound(analyses(i)%table%correxpsyst,dim=1)
-!!         cov(iii,jjj)=cov(iii,jjj) + ( s1*analyses(i)%table%correxpsyst(k)  &
-!!&                                    *s2*analyses(j)%table%correxpsyst(k) ) &
-!!& 		 	  					  * (mu_iii*mu_jjj)
-!!         enddo
-!!        else
   	     cov(iii,jjj)=cov(iii,jjj)+(s1*analyses(i)%table%dlumi*s2*analyses(j)%table%dlumi)&
 & 		 	  					*(mu_iii*mu_jjj)
-!!        endif
 	   endif
 	   corrsyst=0.0D0
-
 !------Include correlated experimental systematic uncertainties (TS 2013-11-21)
        if(withcorrexpsyst) then       
         if(iii.eq.jjj) then
          call get_expt_syst_corr_for_peaks(corrsystSM, analyses(i)%peaks(ii),&
 &             mu_iii, analyses(j)%peaks(jj),mu_jjj, 0) 
          cov(iii,jjj)=cov(iii,jjj) - corrsystSM
         endif
-!! TESTING: 21/01/2014
         call get_expt_syst_corr_for_peaks(corrsyst, analyses(i)%peaks(ii),&
 &            mu_iii, analyses(j)%peaks(jj),mu_jjj, 1) 
-!!
-!!        call get_expt_syst_corr_for_peaks(corrsyst, analyses(i)%peaks(ii),&
-!!&            analyses(i)%peaks(ii)%total_mu, analyses(j)%peaks(jj),analyses(j)%peaks(jj)%total_mu, 1) 
         cov(iii,jjj)=cov(iii,jjj) + corrsyst
        endif 
 !------
        if(useSMweights) then
         cov(iii,jjj)=cov(iii,jjj)+ &
 &       (dratesq)*(analyses(i)%peaks(ii)%mu*analyses(j)%peaks(jj)%mu)
        else 
    	    cov(iii,jjj)=cov(iii,jjj)+ &
 &       (dratesq)*(analyses(i)%peaks(ii)%total_mu*analyses(j)%peaks(jj)%total_mu)
        endif
       else
 !-----Treat luminosity uncertainty as correlated systematic error if same collaboration:
  	   if(analyses(i)%table%collaboration.eq.analyses(j)%table%collaboration) then
-!!        if(withcorrexpsyst) then !!THIS IS IN TESTING PHASE!!
-!!         do k=lbound(analyses(i)%table%correxpsyst,dim=1),&
-!!&            ubound(analyses(i)%table%correxpsyst,dim=1)
-!!         cov(iii,jjj)=cov(iii,jjj) + ( s1*analyses(i)%table%correxpsyst(k)  &
-!!&                                    *s2*analyses(j)%table%correxpsyst(k) )&
-!!& 		 	  					  * abs(mu_iii*mu_jjj)
-!!         enddo
-!!        else
   	     cov(iii,jjj)=cov(iii,jjj)+(s1*analyses(i)%table%dlumi*s2*analyses(j)%table%dlumi)&
 & 		 	  					  *abs(mu_iii*mu_jjj)
-!!        endif
 	   endif
        if(useSMweights) then
         cov(iii,jjj)=cov(iii,jjj)+ &
 &       (dratesq)*(analyses(i)%peaks(ii)%mu*analyses(j)%peaks(jj)%mu)
        else 
    	    cov(iii,jjj)=cov(iii,jjj)+ &
 &       (dratesq)*(analyses(i)%peaks(ii)%total_mu*analyses(j)%peaks(jj)%total_mu)
        endif
       endif        
  	 endif 
 !----Add the intrinsic (uncorrelated) uncertainty of this peak to the diagonal elements:	 
 	 if(iii.eq.jjj) then
   	  call get_dmu0sq_peak(dmu0sq,analyses(i)%peaks(ii),csqmax)
 	  cov(iii,jjj) = cov(iii,jjj) + dmu0sq
 	 endif
   	enddo  	
    enddo 
   enddo 	 
  enddo 
  
 !! write(*,*) "signal strength covariance matrix:"
 !! do iii=lbound(cov,dim=1),ubound(cov,dim=1)
 !!  write(*,*) "(",iii,",",iii,") = ",cov(iii,iii)
 !! enddo
 end subroutine create_covariance_matrix_mu
 !------------------------------------------------------------------------------------    
 subroutine get_rate_uncertainties_sq_peaks_old(dratesq, peak1, peak2)
 ! Returns the sum of the squared theoretical uncertainties of the common 
 ! production and decay rates of the two peak observables.
 !------------------------------------------------------------------------------------    
  use usefulbits_HS, only : mupeak, delta_rate, useSMweights
  
  type(mupeak), intent(in) :: peak1, peak2
  double precision, intent(out) :: dratesq
  integer :: i,j,id1,p1,d1,id2,p2,d2
  double precision :: res
  res=0.0D0
  do i=1,peak1%Nc
   do j=1,peak2%Nc
    id1 = peak1%channel_id(i)
    p1 = int((id1-modulo(id1,10))/dble(10))
    d1 = modulo(id1,10)
    id2 = peak2%channel_id(j)
    p2 = int((id2-modulo(id2,10))/dble(10))
    d2 = modulo(id2,10)
 !   if(p1.eq.p2) res=res+delta_rate%dCS(p1)**2*peak1%channel_w(i)*peak2%channel_w(j)
 !   if(d1.eq.d2) res=res+delta_rate%dBR(d1)**2*peak1%channel_w(i)*peak2%channel_w(j)
    if(p1.eq.p2) then
     if(useSMweights) then
      res=res+delta_rate%dCS(p1)**2*peak1%channel_w(i)*peak2%channel_w(j)
     else
      res=res+delta_rate%dCS(p1)**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
     endif 
    endif 
    if(d1.eq.d2) then
     if(useSMweights) then
      res=res+delta_rate%dBR(d1)**2*peak1%channel_w(i)*peak2%channel_w(j)
     else 
      res=res+delta_rate%dBR(d1)**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
     endif 
    endif   
   enddo
  enddo
   
  dratesq=res
 end subroutine get_rate_uncertainties_sq_peaks_old
 !------------------------------------------------------------------------------------    
 subroutine get_rate_uncertainties_sq_peaks(dratesq, peak1, peak2, collider1, collider2)
 ! Returns the sum of the squared theoretical uncertainties of the common 
 ! production and decay rates of the two peak observables.
 !------------------------------------------------------------------------------------    
  use usefulbits_HS, only : mupeak, delta_rate, useSMweights
  
  type(mupeak), intent(in) :: peak1, peak2
  character(LEN=*), intent(in) :: collider1, collider2
  double precision, intent(out) :: dratesq
  integer :: i,j,id1,p1,d1,id2,p2,d2
  double precision :: res !, delta
  res=0.0D0
 ! delta=0.0D0
  do i=1,peak1%Nc
   do j=1,peak2%Nc
    id1 = peak1%channel_id(i)
    p1 = int((id1-modulo(id1,10))/dble(10))
    d1 = modulo(id1,10)
    id2 = peak2%channel_id(j)
    p2 = int((id2-modulo(id2,10))/dble(10))
    d2 = modulo(id2,10)
 !   if(p1.eq.p2) res=res+delta_rate%dCS(p1)**2*peak1%channel_w(i)*peak2%channel_w(j)
 !   if(d1.eq.d2) res=res+delta_rate%dBR(d1)**2*peak1%channel_w(i)*peak2%channel_w(j)
    if((p1.gt.0).and.(p2.gt.0)) then
     if(collider1.ne.'ILC'.and.collider2.ne.'ILC') then
      if(delta_rate%CScov_ok.and.delta_rate%usecov) then
       if(useSMweights) then
         res=res+delta_rate%CScov(p1,p2)*peak1%channel_w(i)*peak2%channel_w(j)
        else 
         res=res+delta_rate%CScov(p1,p2)*peak1%channel_w_model(i)*peak2%channel_w_model(j)
       endif 
      else
       if(p1.eq.p2) then
        if(useSMweights) then
         res=res+delta_rate%dCS(p1)**2*peak1%channel_w(i)*peak2%channel_w(j)
        else
         res=res+delta_rate%dCS(p1)**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
        endif
       endif 
      endif
     else if(collider1.eq.'ILC'.and.collider2.eq.'ILC') then
      if(p1.eq.p2) then
       if(useSMweights) then
        res=res+delta_rate%dCS_ILC(p1)**2*peak1%channel_w(i)*peak2%channel_w(j)
       else
        res=res+delta_rate%dCS_ILC(p1)**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
       endif
      endif     
     endif 
    endif
 !    if(collider1.ne.'ILC'.and.collider2.ne.'ILC') then
 !     delta=delta_rate%dCS(p1)
 !    else
 !---Set the theoretical uncertainty of production mode to zero if collider==ILC     
 !     delta=0.0D0
 !    endif 
 !    if(useSMweights) then
 !     res=res+delta**2*peak1%channel_w(i)*peak2%channel_w(j)
 !    else
 !     res=res+delta**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
 !    endif 
 !   endif 
    if((d1.gt.0).and.(d2.gt.0)) then
     if(delta_rate%BRcov_ok.and.delta_rate%usecov) then
      if(useSMweights) then
        res=res+delta_rate%BRcov(d1,d2)*peak1%channel_w(i)*peak2%channel_w(j)
       else 
        res=res+delta_rate%BRcov(d1,d2)*peak1%channel_w_model(i)*peak2%channel_w_model(j)
      endif 
     else
      if(d1.eq.d2) then
       if(useSMweights) then
        res=res+delta_rate%dBR(d1)**2*peak1%channel_w(i)*peak2%channel_w(j)
       else 
        res=res+delta_rate%dBR(d1)**2*peak1%channel_w_model(i)*peak2%channel_w_model(j)
       endif 
      endif
     endif     
    endif   
   enddo
  enddo
   
  dratesq=res
 end subroutine get_rate_uncertainties_sq_peaks
 
 
 !------------------------------------------------------------------------------------       
 subroutine get_cov_mu(matrix)
 !------------------------------------------------------------------------------------       
  implicit none
  double precision, dimension(:,:), intent(out) :: matrix
  if(allocated(cov)) then
   if(size(cov,dim=1).eq.size(matrix,dim=1).and.size(cov,dim=2).eq.size(matrix,dim=2)) then
 !  allocate(matrix(size(cov,dim=1),size(cov,dim=2)))
    matrix = cov
  else
   write(*,*) "WARNING in subroutine get_cov_mu: different dimensions."
   endif  
  else
   write(*,*) "WARNING in subroutine get_cov_mu: cov not allocated."
  endif
 end subroutine get_cov_mu
 !------------------------------------------------------------------------------------    
 subroutine get_cov_mh(Hindex,matrix)
 !------------------------------------------------------------------------------------       
  implicit none
  double precision, dimension(:,:), intent(out) :: matrix
  integer, intent(in) :: Hindex
 
  if(allocated(cov_mhneut)) then
   if(size(cov_mhneut,dim=2).eq.size(matrix,dim=1)&
 &    .and.size(cov_mhneut,dim=3).eq.size(matrix,dim=2)) then
    if(Hindex.ge.lbound(cov_mhneut,dim=1).and.Hindex.le.ubound(cov_mhneut,dim=1)) then
     matrix = cov_mhneut(Hindex,:,:)
    else
     write(*,*) "WARNING in subroutine get_cov_mh: Hindex not in range."
    endif  
   else
    write(*,*) "WARNING in subroutine get_cov_mh: different dimensions."
   endif
  else
   write(*,*) "WARNING in subroutine get_cov_mh: cov not allocated."
  endif
  
 end subroutine get_cov_mh
 !------------------------------------------------------------------------------------       
 subroutine print_cov_mu_to_file
  use usefulbits, only : file_id_common3
  implicit none
  character(LEN=20):: formatstring
 
  open(file_id_common3, file='cov_mu.txt', form='formatted')
  write(formatstring,'(A1,I2,A7)') '(',size(cov,dim=2),'F20.10)'
   do i=lbound(cov,dim=1),ubound(cov,dim=1)
    write(file_id_common3, formatstring) cov(i,:)
   enddo	
  close(file_id_common3)
 end subroutine print_cov_mu_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_corr_mu_to_file
  use usefulbits, only : file_id_common3
  implicit none
  character(LEN=20):: formatstring
 
  open(file_id_common3, file='corr_mu.txt', form='formatted')
  write(formatstring,'(A1,I2,A7)') '(',size(cov,dim=2),'F20.10)'
   do i=lbound(cov,dim=1),ubound(cov,dim=1)
 ! TS fix 14/08/2013: Took square root of this!  
    write(file_id_common3, formatstring) (cov(i,j)/sqrt(cov(i,i)*cov(j,j)), &
 &   j=lbound(cov,dim=2),ubound(cov,dim=2))   
   enddo	
  close(file_id_common3)
  
 end subroutine print_corr_mu_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_inverse_cov_mu_to_file
  use usefulbits, only : file_id_common3
  implicit none
  character(LEN=20):: formatstring
 
  double precision, allocatable :: invcov(:,:)
  
  allocate(invcov(size(cov,dim=1),size(cov,dim=2)))
  call invmatrix(cov,invcov)  
 
  open(file_id_common3, file='inverse_cov_mu.txt', form='formatted')
  write(formatstring,'(A1,I2,A7)') '(',size(invcov,dim=2),'F20.10)'
   do i=lbound(invcov,dim=1),ubound(invcov,dim=1)
    write(file_id_common3, formatstring) invcov(i,:)
   enddo	
  close(file_id_common3)
 
  open(file_id_common3, file='mu_vector.txt', form='formatted')
  
   do i=lbound(mu_vector,dim=1),ubound(mu_vector,dim=1)
    write(file_id_common3, '(1F20.10)') mu_vector(i)
   enddo	
  close(file_id_common3)
 
  
 end subroutine print_inverse_cov_mu_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_inverse_cov_mh_to_file(Hindex)
  use usefulbits, only : file_id_common3
  implicit none
  character(LEN=20):: formatstring, filename
  integer, intent(in) :: Hindex
 
  double precision, allocatable :: invcov(:,:)
  
  allocate(invcov(size(cov_mhneut,dim=2),size(cov_mhneut,dim=3)))
 
  if(useaveragemass) then
   call invmatrix(cov_mh_av(:,:),invcov)  
 
   open(file_id_common3, file='inverse_cov_mh_average.txt', form='formatted')
   write(formatstring,'(A1,I2,A7)') '(',size(invcov,dim=2),'F20.10)'
    do i=lbound(invcov,dim=1),ubound(invcov,dim=1)
     write(file_id_common3, formatstring) invcov(i,:)
    enddo	
   close(file_id_common3)
  else
   call invmatrix(cov_mhneut(Hindex,:,:),invcov)  
   write(filename,'(A14,I1,A4)') 'inverse_cov_mh',Hindex,'.txt'
   open(file_id_common3, file=trim(adjustl(filename)), form='formatted')
   write(formatstring,'(A1,I2,A7)') '(',size(invcov,dim=2),'F20.10)'
    do i=lbound(invcov,dim=1),ubound(invcov,dim=1)
     write(file_id_common3, formatstring) invcov(i,:)
    enddo	
   close(file_id_common3)
  endif
  
 end subroutine print_inverse_cov_mh_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_cov_mh_to_file(Hindex)
  use usefulbits, only : file_id_common3
  implicit none
  character(LEN=20):: formatstring, filename
  integer, intent(in) :: Hindex
 
  write(filename,'(A6,I1,A4)') 'cov_mh',Hindex,'.txt'
  open(file_id_common3, file=trim(adjustl(filename)), form='formatted')
  write(formatstring,'(A1,I2,A7)') '(',size(cov_mhneut,dim=3),'F20.10)'
   do i=lbound(cov_mhneut,dim=2),ubound(cov_mhneut,dim=2)
    write(file_id_common3, formatstring) cov_mhneut(Hindex,i,:)
   enddo	
  close(file_id_common3)
  
 end subroutine print_cov_mh_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_peakinformation
 !------------------------------------------------------------------------------------    
 ! use usefulbits_HS, only : peaklist
  implicit none
  
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    write(*,*)
    write(*,*)'#*************************************************************************#'   
    write(*,'(A,I3,A,I3,A)') ' #                        Analysis ',i,					&
 &							'   Peak ',j,'                          #'
    write(*,*)'#*************************************************************************#'      
    write(*,'(A25,1I10)') 'ID =', analyses(i)%id
    write(*,'(A25,4X,A3)') 'Collaboration =', analyses(i)%table%collaboration
    write(*,'(A25,1F10.2)') 'Energy =', analyses(i)%table%energy   
    write(*,'(A25,4X,A45)') 'Reference =', analyses(i)%table%label
    write(*,'(A25,4X,A100)') 'Description =', analyses(i)%table%desc      
    write(*,'(A25,1F10.3)') 'mass resolution =',analyses(i)%table%deltam   
    write(*,'(A25,1F10.3)') 'peak mass =',analyses(i)%peaks(j)%mpeak
    write(*,'(A25,1F10.4)') 'peak mu =',analyses(i)%peaks(j)%mu
    write(*,'(A25,2F10.4)') 'cyan band(low,high) =',analyses(i)%peaks(j)%dmulow, 		&
 &						   analyses(i)%peaks(j)%dmuup
 !   write(*,'(A25,2F10.4)') 'dmu0 (low,high) =',analyses(i)%peaks(j)%dmulow0,			&
 !&						   analyses(i)%peaks(j)%dmuup0
    write(*,'(A25,4X,$)')   'Higgs combination ='
    do k=lbound(analyses(i)%peaks(j)%Higgs_comb,dim=1),									&
 &		ubound(analyses(i)%peaks(j)%Higgs_comb,dim=1)
     write(*,'(1I3,$)')		analyses(i)%peaks(j)%Higgs_comb(k)
    enddo
    write(*,*) 
    write(*,'(A25,7X,1I3)') 'Dominant Higgs =',analyses(i)%peaks(j)%domH
    write(*,'(A25,1F10.4)'), 'Total pred. mu =',analyses(i)%peaks(j)%total_mu
    write(*,'(A25,1F15.9)'), 'Chisq for mu =',analyses(i)%peaks(j)%chisq_mu
    write(*,'(A25,1F15.9)'), 'Chisq for mh =',analyses(i)%peaks(j)%chisq_mh
    write(*,'(A25,1F15.9)'), 'Chisq (total) =',analyses(i)%peaks(j)%chisq_tot
    write(*,'(A25,1F15.9)'), 'Chisq (max) =',analyses(i)%peaks(j)%chisq_max
    write(*,*)'#------------------------ Channel information ----------------------------#'
    write(*,*) '  ID       prod.	decay 	       mu  	     weight  	 syst.err. '
    write(*,*)'#-------------------------------------------------------------------------#'   
    do k=1, analyses(i)%peaks(j)%Nc
     write(*,'(1I5,5X,2A,3F15.6)') analyses(i)%peaks(j)%channel_id(k),&
     &	analyses(i)%table%channel_description(k,:),&
     &	analyses(i)%peaks(j)%channel_mu(k),analyses(i)%peaks(j)%channel_w_model(k),&
     &	analyses(i)%peaks(j)%channel_syst(k)
    enddo 
    write(*,*)'#-------------------------------------------------------------------------#'   
   enddo
  enddo 
 end subroutine print_peakinformation  
 !------------------------------------------------------------------------------------    
 subroutine print_peakinformation_essentials
 !------------------------------------------------------------------------------------    
 !x use usefulbits_HS, only : peaklist
  implicit none
  
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    write(*,*)
    write(*,*)'#*************************************************************************#'   
    write(*,'(A,I3,A,I3,A)') ' #                        Analysis ',i,					&
    &	 					'   Peak ',j,'                          #'
    write(*,*)'#*************************************************************************#'      
    write(*,'(A25,1I10)') 'ID =', analyses(i)%id
    write(*,'(A25,7X,A3)') 'Collaboration =', analyses(i)%table%collaboration   
    write(*,'(A25,4X,F6.2)') 'cms energy =', analyses(i)%table%energy   
    write(*,'(A25,4X,A45)') 'Reference =', analyses(i)%table%label
    write(*,'(A25,4X,A100)') 'Description =', analyses(i)%table%desc
    write(*,'(A25,1F10.2)') 'mass resolution =',analyses(i)%table%deltam         
    write(*,'(A25,1F10.2)') 'peak mass =',analyses(i)%peaks(j)%mpeak
    write(*,'(A25,1F10.4)') 'peak mu =',analyses(i)%peaks(j)%mu
    write(*,'(A25,2F10.4)') 'cyan band(low,high) =',analyses(i)%peaks(j)%dmulow, 		&
 &							analyses(i)%peaks(j)%dmuup
    write(*,*)'#------------------------ Channel information ----------------------------#'
    write(*,*)'  ID       prod.	decay 	    efficiency'
    write(*,*)'#-------------------------------------------------------------------------#'   
    do k=1, analyses(i)%peaks(j)%Nc
     write(*,'(1I5,5X,2A,1F15.6)') analyses(i)%peaks(j)%channel_id(k),					&
 &		analyses(i)%table%channel_description(k,:),analyses(i)%table%channel_eff(k)
    enddo 
    write(*,*)'#-------------------------------------------------------------------------#'   
   enddo
  enddo 
 end subroutine print_peakinformation_essentials
 !------------------------------------------------------------------------------------    
 subroutine print_peaks_to_file
 !------------------------------------------------------------------------------------    
  use usefulbits, only : file_id_common3
  use usefulbits_hs, only : StrCompress
  implicit none
  character(LEN=100) :: formatspec
  integer :: kk
  kk=0
  formatspec='(I3,7X,I10,1X,F6.2,1X,4F8.4,1X,A3,1X,F6.2,1X,F6.2,1X,I3,1X,A,5X,A)'
  open(file_id_common3,file="peak_information.txt")
  write(file_id_common3,*) "#HiggsSignals-"//trim(adjustl(HSvers))//						&
 &						  " with experimental dataset '"//trim(adjustl(Exptdir))//"'" 
  write(file_id_common3,*) "#Number Analysis-ID mh_obs   mu_obs dmu_low dmu_high ",		&
  &				"dmh_exp  collaboration   energy	luminosity   description   reference"
  write(file_id_common3,*) "#"
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
   kk=kk+1
   write(file_id_common3,formatspec)kk,analyses(i)%id,analyses(i)%peaks(j)%mpeak,		&
   & analyses(i)%peaks(j)%mu, analyses(i)%peaks(j)%dmulow,analyses(i)%peaks(j)%dmuup,	&
   & analyses(i)%table%deltam,analyses(i)%table%collaboration, analyses(i)%table%energy,	&
   & analyses(i)%table%lumi, analyses(i)%table%mhchisq, 									&
   & trim(strcompress(analyses(i)%table%desc)), analyses(i)%table%label
   enddo
  enddo 
  close(file_id_common3)
 end subroutine print_peaks_to_file
 !------------------------------------------------------------------------------------    
 subroutine print_peaks_to_LaTeX
 !------------------------------------------------------------------------------------    
  use usefulbits, only : file_id_common3
  use usefulbits_hs, only : StrCompress
  implicit none
  character(LEN=100) :: formatspec
  integer :: kk, N, ii, id, p
  double precision :: weights(5) = (/ 0.0D0, 0.0D0,0.0D0,0.0D0,0.0D0 /)
  kk=0
  open(file_id_common3,file="peak_information.tex")
  write(file_id_common3,*) "\begin{tabular}{lcrrrrr}"
  write(file_id_common3,*) "\hline"
  write(file_id_common3,*) "Analysis & Signal strength & \multicolumn{5}{c}{Signal contamination [in \%]} \\"
  write(file_id_common3,*) "& & ggH & VBF & WH &  ZH & $t\bar{t}H$ \\"
  write(file_id_common3,*) "\hline"
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
   kk=kk+1
   N = analyses(i)%peaks(j)%Nc
   weights = (/ 0.0D0, 0.0D0,0.0D0,0.0D0,0.0D0 /)
   do ii=1,N
    id = analyses(i)%peaks(j)%channel_id(ii)
    p = int((id-modulo(id,10))/dble(10))
    weights(p) = analyses(i)%peaks(j)%channel_w_model(ii)
   enddo
   write(formatspec,"(A,I1,A,I1,A)") '(A3,1X,A,A,A,A,A,F6.2,A,F6.2,A,F6.2,A,F6.1,A,F6.1,A,F6.1,A,F6.1,A,F6.1,A,',N,'I3)'
   write(file_id_common3,formatspec) analyses(i)%table%collaboration, &
   & "$",trim(strcompress(analyses(i)%table%desc)), "$~\cite{", &
   & trim(strcompress(analyses(i)%table%label)),"} & $", &
   & analyses(i)%peaks(j)%mu, "\substack{+",analyses(i)%peaks(j)%dmuup,"\\ -",&
   & abs(analyses(i)%peaks(j)%dmulow),"}$ & $",100*weights(1),"$ & $",100*weights(2),&
   & "$ & $",100*weights(3),"$ & $",100*weights(4),"$ & $",100*weights(5),"$\\ %", &
   & analyses(i)%peaks(j)%channel_id
   enddo
  enddo 
  write(file_id_common3,*) "\hline"
  write(file_id_common3,*) "\end{tabular}"
 
 end subroutine print_peaks_to_LaTeX
 !------------------------------------------------------------------------------------    
 subroutine print_peaks_signal_rates_to_file
 !------------------------------------------------------------------------------------    
  use usefulbits, only : file_id_common3 
  use usefulbits_hs, only : HSres
  implicit none
  character(LEN=100) :: formatspec,formatspec2
  integer :: kk
  double precision :: mh_pull, mu_pull, dmu
  kk=0
  formatspec='(I3,7X,I10,1X,4F8.2,1X,6F10.4)'
  formatspec2='(I3,7X,I10,1X,2F8.2,1X,A7,1X,A7,1X,A7,1X,5F10.4)'
 
  open(file_id_common3,file="peak_massesandrates.txt")
  write(file_id_common3,*) "#HiggsSignals-"//trim(adjustl(HSvers))//						&
 &						  " with experimental dataset '"//trim(adjustl(Exptdir))//"'" 
  write(file_id_common3,*) "#pull = (predicted - observed)/(gaussian uncertainty)"
  write(file_id_common3,*) "#Number Analysis-ID mh_obs dmh_exp mh_pred dmh_theo mh_pull",&
 &						  " mu_obs dmu_low dmu_high mu_pred mu_pull"
  write(file_id_common3,*) "#"
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
   kk=kk+1
   if(analyses(i)%peaks(j)%domH.ne.0) then
    mh_pull = (analyses(i)%peaks(j)%Higgses(analyses(i)%peaks(j)%domH)%m - 				&
 &			 analyses(i)%peaks(j)%mpeak)/												&
 &			 sqrt(analyses(i)%table%deltam**2+											&
 &			 analyses(i)%peaks(j)%Higgses(analyses(i)%peaks(j)%domH)%dm**2)
   endif
   call get_dmu_peak(dmu,analyses(i)%peaks(j))
   mu_pull = (analyses(i)%peaks(j)%total_mu - analyses(i)%peaks(j)%mu)/dmu
   
   if(analyses(i)%peaks(j)%domH.ne.0) then
   write(file_id_common3,formatspec)kk,analyses(i)%id,analyses(i)%peaks(j)%mpeak,		&
 &  analyses(i)%table%deltam, analyses(i)%peaks(j)%Higgses(analyses(i)%peaks(j)%domH)%m,	&
 &  analyses(i)%peaks(j)%Higgses(analyses(i)%peaks(j)%domH)%dm, mh_pull,					&
 &  analyses(i)%peaks(j)%mu, analyses(i)%peaks(j)%dmulow,analyses(i)%peaks(j)%dmuup,		&
 &  analyses(i)%peaks(j)%total_mu, mu_pull
   else	
     write(file_id_common3,formatspec2)kk,analyses(i)%id,analyses(i)%peaks(j)%mpeak,		&
 &  analyses(i)%table%deltam, 'NAN','NAN','NAN',											&
 &  analyses(i)%peaks(j)%mu, analyses(i)%peaks(j)%dmulow,analyses(i)%peaks(j)%dmuup,		&
 &  analyses(i)%peaks(j)%total_mu, mu_pull
   endif	
   enddo
  enddo 
  close(file_id_common3)
 end subroutine print_peaks_signal_rates_to_file
 !--------------------------------------------------------------------
 subroutine get_peakchi2(obsID, csqmu, csqmh, csqmax, csqtot)
 !--------------------------------------------------------------------
  implicit none
  integer, intent(in) :: obsID
  double precision, intent(out) :: csqmu, csqmh, csqmax, csqtot
  integer :: i, j
  
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    if(obsID.eq.analyses(i)%peaks(j)%id) then
     csqmu = analyses(i)%peaks(j)%chisq_mu
     csqmh = analyses(i)%peaks(j)%chisq_mh
     csqmax = analyses(i)%peaks(j)%chisq_max
     csqtot = analyses(i)%peaks(j)%chisq_tot
    endif
   enddo
  enddo
 
 end subroutine get_peakchi2
 !------------------------------------------------------------------------------------     
 subroutine get_masschi2_from_separation(csq)
 !------------------------------------------------------------------------------------     
  implicit none
  double precision, intent(out) :: csq
  integer :: i, ii, iii
  
 ! write(*,*) "Calling get_masschi2_from_separation."
  
  csq =0.0D0
 
  iii=0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    if(analyses(i)%table%mhchisq.eq.1) then
     csq = csq + csq_mass_separation_weighted( &
 &    analyses(i)%peaks(ii)%Higgs_comb, analyses(i)%peaks(ii))
 !    write(*,*) 'analyses(',i,')%peaks(',ii,')%Higgs_comb = ',analyses(i)%peaks(ii)%Higgs_comb
    endif
   enddo
  enddo 
 
 ! write(*,*) 'csq_sep =', csq
 
 end subroutine get_masschi2_from_separation
 !------------------------------------------------------------------------------------     
 subroutine add_peaks_to_HSresults(r)
 !------------------------------------------------------------------------------------    
 ! use usefulbits_hs, only : HSresults, peaklist
  implicit none
  
  type(HSresults), intent(out) :: r
  
  integer :: i,j, iii
  if(allocated(r%obsID)) deallocate(r%obsID)
  if(allocated(r%mupred)) deallocate(r%mupred)
  if(allocated(r%domH)) deallocate(r%domH)
  if(allocated(r%nH)) deallocate(r%nH)
 
 !-The number of peaks should maybe be saved in a global usefulbits_HS variable in order
 ! to avoid multiple loops over the peaklist.
  iii=0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
   enddo
  enddo
  
  allocate(r%mupred(iii), r%domH(iii), r%nH(iii), r%obsID(iii)) 
   
  iii=0
  do i=lbound(analyses,dim=1),ubound(analyses,dim=1)
   do j=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    r%mupred(iii)=analyses(i)%peaks(j)%total_mu
    r%domH(iii)=analyses(i)%peaks(j)%domH
    r%nH(iii)=analyses(i)%peaks(j)%NHiggs_comb
    r%obsID(iii)=analyses(i)%peaks(j)%id
   enddo
  enddo
  
 ! write(*,*) "End of subroutine add_peaks_to_HSresults."
 end subroutine add_peaks_to_HSresults
 !------------------------------------------------------------------------------------    
 subroutine get_dmu0sq_peak(dmu0sq,peak,domax)
 !------------------------------------------------------------------------------------    
  use usefulbits_HS, only : mupeak, symmetricerrors, absolute_errors
  implicit none
  
  integer, intent(in) :: domax   ! if 1, then use predicted mu == 0 
  double precision, intent(out) :: dmu0sq
  double precision :: pred_mu, mu
  
  type(mupeak), intent(in) :: peak
 
 ! TESTING:
 ! if(absolute_errors) then
 !  mu=peak%mu_original
 ! else
  mu=peak%mu
 ! endif
 
  if(domax.eq.1) then
   pred_mu = 0.0D0
  else
   pred_mu = peak%total_mu 
  endif
  
  if(.not.symmetricerrors) then
   if(pred_mu.le.mu) then
    dmu0sq = peak%dmulow0sq
   else if(pred_mu.gt.mu) then
    dmu0sq = peak%dmuup0sq
   endif 
  else
   if(peak%dmulow0sq.lt.0.0d0.or.peak%dmuup0sq.lt.0.0d0) then
    write(*,*) "WARNING: squared intrinsic mu uncertainty is negative!"
    dmu0sq= (sqrt(abs(peak%dmulow0sq))+sqrt(abs(peak%dmuup0sq)))**2/4.
   else 
   dmu0sq = (sqrt(peak%dmulow0sq)+sqrt(peak%dmuup0sq))**2/4.
   endif
  endif
  
 !! write(*,*) 'DEBUG: ',peak%dmulow0sq, peak%dmuup0sq, (sqrt(peak%dmulow0sq)+sqrt(peak%dmuup0sq))**2/4.
  
 end subroutine get_dmu0sq_peak
 !------------------------------------------------------------------------------------    
 subroutine get_dmu_peak(dmu,peak)
 !------------------------------------------------------------------------------------    
  use usefulbits_HS, only : mupeak
  implicit none
  
  double precision, intent(out) :: dmu
  double precision :: pred_mu
  
  type(mupeak), intent(in) :: peak
  
  pred_mu = peak%total_mu 
  
  if(pred_mu.le.peak%mu) then
   dmu = peak%dmulow
  else if(pred_mu.gt.peak%mu) then
   dmu = peak%dmuup
  endif 
 
 end subroutine get_dmu_peak
 !------------------------------------------------------------------------------------    
 subroutine calc_pc_chisq(pc_chisq,peak,mhchisqflag,Higgses,Higgs_dom,indices_in,iterstep)
 ! This subroutine calculates the chisq value for a given Higgs combination assigned
 ! to one peak.
 ! Parameters:
 !
 !  pc_chisq:       Return value (double precision)
 !  peak:           Peak observable the Higgs bosons are assigned to (type mupeak)
 !  Higgses:		   neutral Higgs bosons considered for the assignment (type neutHiggs(:))
 !  Hdom:		   dominantly contribution Higgs boson (int)	
 !  indices_in:     Higgs boson combination the chi squared value is evaluated for (int(:))
 !  iterstep:	   Iteration-step of Higgs-to-peak assignment
 !------------------------------------------------------------------------------------    
  implicit none
  type(mupeak), intent(in) :: peak
  type(neutHiggs), dimension(:), intent(in) :: Higgses(:)
 ! integer, allocatable, intent(out) :: indices_best(:)
 ! integer, intent(in), optional :: Nindices_in
  integer, dimension(:), intent(in) :: indices_in(:)
  integer, intent(in) :: mhchisqflag, iterstep
  integer, intent(out) :: Higgs_dom
  double precision, intent(out) :: pc_chisq
  
 !--Internal parameters:
  double precision :: mutot,dmu,csq0,csq_mh_tot,csq_tot,csq_tot_tmp,csq_mh_tmp,mumax
  double precision :: deltam
  integer :: nH
  double precision :: m, dm
  
  call check_pdf(pdf)
  
  nH=size(Higgses)
 !--Calculate the maximal chisq value for this peak
  csq0 = csq_mu(0.0D0,peak%mu,peak%dmuup,peak%dmulow)
 
  mumax = -1.0D6
  mutot = 0.0D0
  csq_mh_tot=0.0D0
  Higgs_dom=0
 
 ! Calculate mutot and find dominant Higgs
 
  do i=lbound(indices_in,dim=1),ubound(indices_in,dim=1)
   if(indices_in(i).ne.0) then  
    mutot = mutot + Higgses(indices_in(i))%mu
    if(Higgses(indices_in(i))%mu.gt.mumax) then
     mumax = Higgses(indices_in(i))%mu
     Higgs_dom = indices_in(i)
    endif
   endif
  enddo 
 
 
  if(allocated(cov_mhneut_max).and.iterstep.eq.1) then
  !-In the first iterated step, use a Higgs mass covariance matrix, where all Higgs bosons
  !-are assumed to be assigned.
 !  write(*,*) "Warning!! called csq_mh_with_max_corr!"
   csq_mh_tot = csq_mh_with_max_corr(indices_in, peak%internalnumber)
  elseif(allocated(cov_mhneut).and.iterstep.gt.1) then
 !-In the second (and succeeding) iterated steps, use a the Higgs mass covariance matrix
 !-based on the the previous Higgs-to-peaks assignment.
 !  write(*,*) "Warning!! called csq_mh_with_corr!"
   csq_mh_tot = csq_mh_with_corr(indices_in, peak%internalnumber)  
  else
   if(useaveragemass) then
    call get_average_mass_for_peak(indices_in, peak, m, dm)
    if(mhchisqflag.eq.1) then
     deltam = peak%dm
     csq_mh_tot = csq_mh(m, peak%mpeak, dm, peak%dm)
    else
     csq_mh_tot = 0.0D0
    endif  
   else 
    do i=lbound(indices_in,dim=1),ubound(indices_in,dim=1)
     if(indices_in(i).ne.0) then
      if(mhchisqflag.eq.1) then
       deltam = peak%dm
       csq_mh_tmp = csq_mh(Higgses(indices_in(i))%m, peak%mpeak,							&
 & 	                      Higgses(indices_in(i))%dm,deltam)
      else
       csq_mh_tmp = 0.0D0
      endif   
      csq_mh_tot = csq_mh_tot + csq_mh_tmp
     endif	
    enddo
   endif
  endif 
 
  if(allocated(cov)) then
   csq_tot = csq_mh_tot + csq_mu_with_corr(mutot, peak%internalnumber)
  else
   csq_tot = csq_mh_tot + csq_mu(mutot, peak%mu, peak%dmuup, peak%dmulow) 
  endif
 
  pc_chisq = csq_tot  
   
 end subroutine calc_pc_chisq
 !---------------------------------------------------------------------------
 function csq_mh_with_max_corr(indices_in, peaknumber)
 !---------------------------------------------------------------------------
  integer, dimension(:), intent(in) :: indices_in(:)
  integer, intent(in) :: peaknumber
  double precision :: csq_mh_with_max_corr 
  double precision, allocatable :: csq_mh_per_Higgs(:)
  integer :: i, ii, iii, k, nH, N, Hindex
  double precision, allocatable :: v(:,:), invcov(:,:), v2(:)
 
   nH = size(cov_mhneut,dim=1)
   N = size(cov_mhneut,dim=2)
   allocate(v(nH,N), v2(N), csq_mh_per_Higgs(nH))
   
   do k=1,nH
    iii=0
    do i=1, size(analyses)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
      iii=iii+1
       v(k,iii) = analyses(i)%peaks(ii)%Higgses(k)%m - analyses(i)%peaks(ii)%mpeak
       if(iii.eq.peaknumber) v(k,iii) = 0.0D0 ! Will be filled later...
     enddo
    enddo
   enddo 
 
   do k=1,nH
    iii=0
    do i=1, size(analyses)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
      iii=iii+1
      if(iii.eq.peaknumber) then
       Hindex=indices_in(k)
       if(Hindex.ne.0) then     
        v(Hindex,iii) = analyses(i)%peaks(ii)%Higgses(k)%m - analyses(i)%peaks(ii)%mpeak
       endif  
      endif 
     enddo
    enddo
   enddo
 
    do k=1,nH 		!-n.b.: this loops now over Hindex
    call invmatrix(cov_mhneut_max(k,:,:),invcov) 
    call matmult(invcov,v(k,:),v2,N,1)
    csq_mh_per_Higgs(k) = v(k,peaknumber)*v2(peaknumber)
   enddo  
   
 csq_mh_with_max_corr = sum(csq_mh_per_Higgs)
 
 deallocate(v,v2,csq_mh_per_Higgs)
 
 end function csq_mh_with_max_corr
 !---------------------------------------------------------------------------
 function csq_mh_with_corr(indices_in, peaknumber)
 !---------------------------------------------------------------------------
  integer, dimension(:), intent(in) :: indices_in(:)
  integer, intent(in) :: peaknumber
  double precision :: csq_mh_with_corr 
  double precision, allocatable :: csq_mh_per_Higgs(:)
  integer :: i, ii, iii, k, nH, N, Hindex
  double precision, allocatable :: v(:,:), invcov(:,:), v2(:)
 
  nH = size(cov_mhneut,dim=1)
  N = size(cov_mhneut,dim=2)
  allocate(v(nH,N), v2(N), csq_mh_per_Higgs(nH))
     
 !-First, fill the vectors with zeros:
  do k=1,nH
   do i=1,N
    v(k,i) = 0.0D0
   enddo
  enddo  
 
   do k=1,nH
    iii=0
    do i=1, size(analyses)
     do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
      iii=iii+1
      Hindex = analyses(i)%peaks(ii)%Higgs_comb(k)
      if(iii.eq.peaknumber) Hindex=indices_in(k)     
      if(Hindex.ne.0) then     
       v(Hindex,iii) = analyses(i)%peaks(ii)%Higgses(Hindex)%m -							&
 &					  analyses(i)%peaks(ii)%mpeak
      endif  
     enddo
    enddo
   enddo 
 
   do k=1,nH 		!-n.b.: this loops now over Hindex
    call invmatrix(cov_mhneut(k,:,:),invcov) 
    call matmult(invcov,v(k,:),v2,N,1)
    csq_mh_per_Higgs(k) = v(k,peaknumber)*v2(peaknumber)
   enddo  
   
   csq_mh_with_corr = sum(csq_mh_per_Higgs)
 
   deallocate(v,v2,csq_mh_per_Higgs)
 
  end function csq_mh_with_corr
 !------------------------------------------------------------------------------------    
 function csq_mu_with_corr(mu, peaknumber)
 !------------------------------------------------------------------------------------    
 ! use usefulbits_hs, only : peaklist, cov
  use numerics, only : invmatrix, matmult
 
  integer, intent(in) :: peaknumber
  double precision, intent(in) :: mu
  integer :: i, ii, iii, N
  double precision, allocatable :: v(:), vmat(:,:), invcov(:,:), v2(:)
  double precision :: csq_mu_with_corr
  
  if(allocated(cov)) deallocate(cov)
  call create_covariance_matrix_mu(0) 
  
  N = size(cov,dim=1)
  allocate(v(N), vmat(N,1),invcov(N,N), v2(N))
  
  !-First construct the vector (mupred - muobs)_iii
  iii=0
  do i=1, size(analyses)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    v(iii) = analyses(i)%peaks(ii)%total_mu - analyses(i)%peaks(ii)%mu
    if(iii.eq.peaknumber) v(iii) = mu - analyses(i)%peaks(ii)%mu
    vmat(iii,1) = v(iii)
   enddo
  enddo
     
  call invmatrix(cov,invcov)   
  call matmult(invcov,vmat,v2,N,1)
  
  csq_mu_with_corr = v(peaknumber)*v2(peaknumber)
 
  deallocate(v,vmat,invcov,v2)
 
 end function csq_mu_with_corr
 !------------------------------------------------------------------------------------  
 subroutine check_pdf(pdf)
 !------------------------------------------------------------------------------------  
  implicit none
  integer, intent(inout) :: pdf
  
  if(.not.((pdf.eq.1).or.(pdf.eq.2).or.(pdf.eq.3))) then
   write(*,*) 'WARNING: pdf not properly specified. Will be set to pdf=2 (gaussian-shape)'
   pdf=2
  endif
   
 end subroutine check_pdf
 !------------------------------------------------------------------------------------    
 function csq_mu(x, x0, dx_up, dx_low)
 !- x: model predicted value
 !- x0: observed value
 !- dx_up: difference between observed and upper 1sigma band (always positive)
 !- dx_low: difference between observed and lower 1sigma band (always positive)
 !------------------------------------------------------------------------------------    
  use usefulbits_hs, only : symmetricerrors
  implicit none
 
  double precision, intent(in) :: x, x0, dx_up, dx_low
  double precision :: csq_mu, dx
  
  if(.not.symmetricerrors) then
   if(x.ge.x0) then
    dx = dx_up
   else
    dx = dx_low
   endif
  else
   dx = (abs(dx_up)+abs(dx_low))/2.
  endif
   
  csq_mu=chisq(x, x0, dx)
  
 end function csq_mu 
 !------------------------------------------------------------------------------------      
 function csq_mh(x,x0,dx1,dx2)
 !------------------------------------------------------------------------------------    
  implicit none
  double precision, intent(in) :: x, x0, dx1, dx2
  double precision :: csq_mh, dx
  
  if(pdf.eq.1) then			! box pdf
   dx = dx1 + dx2			! Add exp. and th. uncertainties linearly
   if(x.ge.(x0-dx).and.x.le.(x0+dx)) then
    csq_mh = 0.0D0
   else
    csq_mh = 100000.0D0	!Large number
   endif
  else if(pdf.eq.2) then		! gaussian pdf
   dx = sqrt(dx1**2+dx2**2)	! Add uncertainties in quadrature
   csq_mh = chisq(x,x0,dx)
 !---------------------------- Have to verify boxgaussian...
  else if(pdf.eq.3) then		! box+gaussian pdf
   if(x.ge.(x0-dx1).and.x.le.(x0+dx1)) then
    csq_mh = 0.0D0
   else if(x.ge.(x0+dx1)) then
    csq_mh = chisq(x,x0+dx1,dx2)
   else if(x.le.(x0-dx1)) then
    csq_mh = chisq(x,x0-dx1,dx2)
   endif
  endif 
 end function csq_mh
 !------------------------------------------------------------------------------------      
 function csq_mass_separation_weighted(indices_in, peak)
 !---------------------------------------------------------------------------
  use usefulbits, only : vsmall
  implicit none
  integer, dimension(:), intent(in) :: indices_in(:)
  type(mupeak), intent(in) :: peak
  double precision :: csq_mass_separation_weighted
  double precision :: mutotal,csq,csq_mh_tmp, m, dm
  integer :: i,k
 !------------------------------------------------------------------------------------    
 
 mutotal = 0.0D0
 do k=lbound(indices_in,dim=1),ubound(indices_in,dim=1)
  i = indices_in(k)
  if(i.ne.0) mutotal = mutotal + peak%Higgses(i)%mu
 enddo 
 
 call get_average_mass_for_peak(indices_in, peak, m, dm)
 
 csq = 0.0D0
 if(abs(mutotal).gt.vsmall) then
  do k=lbound(indices_in,dim=1),ubound(indices_in,dim=1)
   i = indices_in(k)
   csq_mh_tmp = 0.0D0  
   if(i.ne.0) then
    if(pdf.eq.1) then			! box pdf
-    if(peak%Higgses(i)%m.ge.(m-peak%Higgses(i)%dm).and. &
-&      peak%Higgses(i)%m.le.(m+peak%Higgses(i)%dm)) then
+    if(peak%Higgses(i)%m.ge.(m-peak%Higgses(i)%dm-peak%dm).and. &
+&      peak%Higgses(i)%m.le.(m+peak%Higgses(i)%dm+peak%dm)) then
      csq_mh_tmp = 0.0D0
     else
      csq_mh_tmp = 100000.0D0	!Large number
     endif   
    else if(pdf.eq.2) then
     csq_mh_tmp = chisq(peak%Higgses(i)%m,m,sqrt(peak%dm**2+peak%Higgses(i)%dm**2))
 !    write(*,*) "m, m_av, dm = ",peak%Higgses(i)%m,m,sqrt(peak%dm**2+peak%Higgses(i)%dm**2)
 !    write(*,*) "i, csq_mh_tmp = ", i , csq_mh_tmp
    else if(pdf.eq.3) then
     if(peak%Higgses(i)%m.ge.(m-peak%Higgses(i)%dm).and. &
 &      peak%Higgses(i)%m.le.(m+peak%Higgses(i)%dm)) then
      csq_mh_tmp = 0.0D0  
     else if(peak%Higgses(i)%m.gt.m+peak%Higgses(i)%dm) then
      csq_mh_tmp = chisq(peak%Higgses(i)%m,m+peak%Higgses(i)%dm,peak%dm)
     else if(peak%Higgses(i)%m.lt.m-peak%Higgses(i)%dm) then
      csq_mh_tmp = chisq(peak%Higgses(i)%m,m-peak%Higgses(i)%dm,peak%dm)
     endif
    else
     stop "Error: Unknown pdf!"
    endif  
 
    csq = csq + abs(peak%Higgses(i)%mu/mutotal)*csq_mh_tmp    
   endif 
  enddo
 endif
 
 csq_mass_separation_weighted = csq 
 
 end function csq_mass_separation_weighted
 !------------------------------------------------------------------------------------    
 function chisq(x,x0,dx)
 !------------------------------------------------------------------------------------    
  implicit none 
  double precision, intent(in) :: x,x0,dx
  double precision :: chisq
  
  if(dx.ne.0) then 
   chisq=(x-x0)**2/dx**2
  else
   write(*,*) 'WARNING, dx = 0'
   chisq=100000. 
  endif
  
 end function chisq
 !------------------------------------------------------------------------------------      
 subroutine get_ncomb(ncomb, indices_truncated, indices_best)
 !------------------------------------------------------------------------------------     
  implicit none
  
  integer, dimension(:), intent(in) :: indices_best(:)
  integer, allocatable, intent(out) :: indices_truncated(:)
  integer, intent(out) :: ncomb
  integer :: i,j
 
  ncomb=0
 
  do i=lbound(indices_best,dim=1),ubound(indices_best,dim=1)
   if(indices_best(i).ne.0) ncomb=ncomb+1
  enddo
  
  allocate(indices_truncated(ncomb))
  j=1
  do i=lbound(indices_best,dim=1),ubound(indices_best,dim=1)
   if(indices_best(i).ne.0) then
    indices_truncated(j)=indices_best(i)
    j=j+1
   endif 
  enddo 
 end subroutine get_ncomb 
 !------------------------------------------------------------------------------------  
 subroutine get_weights_at_peak( peak, mutab )
 ! This subroutines fills the channels weights array of the peak object with the
 ! Standard Model weights obtained at the peaks position.
 !------------------------------------------------------------------------------------  
  use usefulbits, only : div, small
 ! use theory_XS_SM_functions
  use usefulbits_HS, only : mutable
 
  type(mupeak), intent(inout) :: peak
  type(mutable), intent(in) :: mutab
 
  integer :: i, id, p, d
  double precision :: SMrate, mass
  double precision :: SMCS_lhc7_gg_H,SMCS_lhc7_bb_H,SMCS_lhc7_vbf_H,SMCS_lhc7_HW,	&
  &	SMCS_lhc7_HZ, SMCS_lhc7_ttH, SMCS_lhc8_gg_H,SMCS_lhc8_bb_H,SMCS_lhc8_vbf_H,		&
  &	SMCS_lhc8_HW, SMCS_lhc8_HZ, SMCS_lhc8_ttH, SMCS_tev_gg_H,SMCS_tev_bb_H,			&
  &  SMCS_tev_vbf_H, SMCS_tev_HW, SMCS_tev_HZ, SMCS_tev_ttH,SMBR_Hgamgam,SMBR_HWW,	&
  &  SMBR_HZZ, SMBR_Htautau, SMBR_Hbb,SMBR_HZgam,SMBR_Hcc, SMBR_Hmumu,SMBR_Hgg
  ! Check experiment and energy flag to choose the relevant dataset
 
  mass = peak%mpeak
 
  do i=1,mutab%Nc
   id = mutab%channel_id(i)
   p = int((id-modulo(id,10))/dble(10))
   d = modulo(id,10)
   
 !--Do the production rate for the relevant experiment and cms-energy 
   if(mutab%collider.eq.'LHC') then
    if(abs(mutab%energy-7.0D0).le.small) then
     if(p.eq.1) then 
      SMrate=SMCS_lhc7_gg_H(mass)+SMCS_lhc7_bb_H(mass)
     else if(p.eq.2) then
      SMrate=SMCS_lhc7_vbf_H(mass)
     else if(p.eq.3) then
      SMrate=SMCS_lhc7_HW(mass)
     else if(p.eq.4) then
      SMrate=SMCS_lhc7_HZ(mass)
     else if(p.eq.5) then
      SMrate=SMCS_lhc7_ttH(mass)
     endif 
    else if(abs(mutab%energy-8.0D0).le.small) then
     if(p.eq.1) then 
      SMrate=SMCS_lhc8_gg_H(mass)+SMCS_lhc8_bb_H(mass)
     else if(p.eq.2) then
      SMrate=SMCS_lhc8_vbf_H(mass)
     else if(p.eq.3) then
      SMrate=SMCS_lhc8_HW(mass)
     else if(p.eq.4) then
      SMrate=SMCS_lhc8_HZ(mass)
     else if(p.eq.5) then
      SMrate=SMCS_lhc8_ttH(mass)
     endif 
    endif
   else if(mutab%collider.eq.'TEV') then
     if(p.eq.1) then 
      SMrate=SMCS_tev_gg_H(mass)+SMCS_tev_bb_H(mass)
     else if(p.eq.2) then
      SMrate=SMCS_tev_vbf_H(mass)
     else if(p.eq.3) then
      SMrate=SMCS_tev_HW(mass)
     else if(p.eq.4) then
      SMrate=SMCS_tev_HZ(mass)
     else if(p.eq.5) then
      SMrate=SMCS_tev_ttH(mass)
     endif 
   endif
 !--Multiply now by the decay rate
   if(d.eq.1) then
    SMrate=SMrate*SMBR_Hgamgam(mass)
   else if(d.eq.2) then
    SMrate=SMrate*SMBR_HWW(mass)
   else if(d.eq.3) then
    SMrate=SMrate*SMBR_HZZ(mass)
   else if(d.eq.4) then
    SMrate=SMrate*SMBR_Htautau(mass)
   else if(d.eq.5) then
    SMrate=SMrate*SMBR_Hbb(mass)
   else if(d.eq.6) then
    SMrate=SMrate*SMBR_HZgam(mass)
   else if(d.eq.7) then
    SMrate=SMrate*SMBR_Hcc(mass)
   else if(d.eq.8) then
    SMrate=SMrate*SMBR_Hmumu(mass)
   else if(d.eq.9) then
    SMrate=SMrate*SMBR_Hgg(mass)   
   endif
   
   peak%channel_w(i)=peak%channel_eff(i)*SMrate
  enddo
  
  SMrate=sum(peak%channel_w(:))
  do i=1,mutab%Nc
   peak%channel_w(i)=div(peak%channel_w(i),SMrate,0.0D0,1.0D9)
  enddo
  
 end subroutine get_weights_at_peak
 !---------------------------------------------------------------------------
 subroutine get_average_mass(indices_in, peaknumber, m, dm)
 !---------------------------------------------------------------------------
  integer, dimension(:), intent(in) :: indices_in(:)
  integer, intent(in) :: peaknumber
  double precision, intent(out) :: m, dm
 
  integer :: i, ii, iii, k, nH, N, Hindex
  double precision :: num1, num2, denom
 
  nH = size(indices_in,dim=1)
  
  num1 = 0.0D0
  num2 = 0.0D0 
  denom = 0.0D0
  
  iii=0
  do i=1, size(analyses)
   do ii=lbound(analyses(i)%peaks,dim=1),ubound(analyses(i)%peaks,dim=1)
    iii=iii+1
    if(iii.eq.peaknumber) then
     call get_average_mass_for_peak(indices_in, analyses(i)%peaks(ii), m, dm)
    endif  
   enddo
  enddo 
  
  if(denom.ne.0.0D0) then
   m  = num1 / denom
   dm = num2 / denom
  else
   m  = 0.0D0
   dm = 0.0D0   
  endif 
 
 end subroutine get_average_mass 
 !---------------------------------------------------------------------------
 subroutine get_average_mass_for_peak(indices_in, peak, m, dm)
 !---------------------------------------------------------------------------
  integer, dimension(:), intent(in) :: indices_in(:)
  type(mupeak), intent(in) :: peak
  double precision, intent(out) :: m, dm
 
  integer :: i, ii, iii, k, nH, N, Hindex
  double precision :: num1, num2, denom
 
  nH = size(indices_in,dim=1)
  
  num1 = 0.0D0
  num2 = 0.0D0 
  denom = 0.0D0
  
  do k=1,nH
   Hindex=indices_in(k) 
   if(Hindex.ne.0) then
    num1 = num1 + peak%Higgses(Hindex)%mu * &
 &                peak%Higgses(Hindex)%m
    num2 = num2 + peak%Higgses(Hindex)%mu * &
 &                peak%Higgses(Hindex)%dm
    denom = denom + peak%Higgses(Hindex)%mu
   endif
  enddo 
  
  if(denom.ne.0.0D0) then
   m  = num1 / denom
   dm = num2 / denom
  else
   m  = 0.0D0
   dm = 0.0D0   
  endif 
 
 end subroutine get_average_mass_for_peak
 !------------------------------------------------------------------------------------   
 
 end module pc_chisq
 !------------------------------------------------------------------------------------  
\ No newline at end of file
Index: trunk/HiggsSignals/run_tests.bat
===================================================================
--- trunk/HiggsSignals/run_tests.bat	(revision 505)
+++ trunk/HiggsSignals/run_tests.bat	(revision 506)
@@ -1,199 +1,199 @@
 #!/bin/bash
 
 startdir="$PWD"
 
 # Checking for a eps viewer
 if hash gv 2>/dev/null; then
 	openeps=gv
 elif hash open 2>/dev/null; then
 	openeps=open
 elif hash ggv 2>/dev/null; then
 	openeps=ggv
 elif hash eog 2>/dev/null; then
 	openeps=eog
 else
 	echo 'Note: No eps viewer found. The .eps files will not be displayed.'
 	openeps='#'
 fi	
 
 # Checking for a gnuplot
 if hash gnuplot 2>/dev/null; then
 	gnplt=gnuplot
 else
 	echo 'Note: Gnuplot not found. Will not run plotting scripts.'
 	gnplt='#'
 fi	
 
 
 
 echo '*********************************************************************'
 echo '*                   Running HiggsSignals test script                *'
 echo '*                                                                   *'
 echo '* This may take a while so better go and get a cup of coffee/tea... *'
 echo '*********************************************************************'
 echo 'cleaning HiggsSignals distribution...'
 rm temp_error*.txt temp_output*.txt > /dev/null
 make hyperclean 2>> temp_error.txt 1>> temp_output.txt
 echo 'running configure script...'
 ./configure 2>> temp_error.txt 1>> temp_output.txt
 echo 'make HiggsSignals...'
 make HiggsSignals 2>> temp_error.txt 1>> temp_output.txt
 if [ $(grep -c 'Error' temp_error.txt) == 0 ]; then
    echo 'Compilation successfully.'
 else
    echo 'Compilation failed with'
    grep 'Error' temp_error.txt
    echo '---------------------------------------------------------------------'
    echo 'Here are some things you might want to check:'
    echo ' - Have you set the HiggsBounds path correctly in the configure script?'
    echo ' - Does the HiggsBounds library exist?'
    echo ' - Is it compiled with the same Fortran compiler?'   
    echo '---------------------------------------------------------------------'
    exit 0
 fi   
 echo '---------------------------------------------------------------------'
 echo ' TEST 1: Run HiggsSignals command-line version on random test points:'
 echo '---------------------------------------------------------------------'
 echo './HiggsSignals latestresults peak 2 effC 3 1 example_data/random/HB_randomtest50points_'
 ./HiggsSignals latestresults peak 2 effC 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults peak 2 part 3 1 example_data/random/HB_randomtest50points_'
 # ./HiggsSignals latestresults peak 2 part 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults peak 2 hadr 3 1 example_data/random/HB_randomtest50points_'
 # ./HiggsSignals latestresults peak 2 hadr 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults mass 2 effC 3 1 example_data/random/HB_randomtest50points_'
 # ./HiggsSignals latestresults mass 2 effC 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 echo './HiggsSignals latestresults mass 2 part 3 1 example_data/random/HB_randomtest50points_'
 ./HiggsSignals latestresults mass 2 part 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults mass 2 hadr 3 1 example_data/random/HB_randomtest50points_'
 # ./HiggsSignals latestresults mass 2 hadr 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults both 2 effC 3 1 example_data/random/HB_randomtest50points_'
 # ./HiggsSignals latestresults both 2 effC 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 # echo './HiggsSignals latestresults both 2 part 3 1 example_data/random/HB_randomtest50points_'
 /./HiggsSignals latestresults both 2 part 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
-echo './HiggsSignals latestresults both 2 hadr 3 1 example_data/random/HB_randomtest50points_'
+# echo './HiggsSignals latestresults both 2 hadr 3 1 example_data/random/HB_randomtest50points_'
 ./HiggsSignals latestresults both 2 hadr 3 1 example_data/random/HB_randomtest50points_ 2>> temp_error1.txt 1>> temp_output1.txt
 
 echo '---------------------------------------------------------------------'
-echo 'There were' $(grep -c 'WARNING' temp_output.txt) 'warnings.'
-echo 'There were' $(grep -c 'Interrupt' temp_error.txt) 'interrupts.'
-echo 'There were' $(grep -c 'Error' temp_error.txt) 'errors.'
-echo 'There were' $(grep -c 'stop' temp_error.txt) 'stops.'
+echo 'There were' $(grep -c 'WARNING' temp_output1.txt) 'warnings.'
+echo 'There were' $(grep -c 'Interrupt' temp_error1.txt) 'interrupts.'
+echo 'There were' $(grep -c 'Error' temp_error1.txt) 'errors.'
+echo 'There were' $(grep -c 'stop' temp_error1.txt) 'stops.'
 echo '---------------------------------------------------------------------'
 echo 'make HiggsSignals example programs...'
 make HSexamples 2> temp_error.txt 1> temp_output.txt
 if [ $(grep -c 'Error' temp_error.txt) == 0 ]; then
    echo 'Compilation successfully.'
 else
    echo 'Compilation failed with'
    grep 'Error' temp_error.txt
 fi
 echo '---------------------------------------------------------------------'
 echo ' TEST 2: Run HiggsSignals example programs:'
 echo '---------------------------------------------------------------------'
 # echo -n '1) Running HSscaleUncertainties...'
 # cd example_programs
 # ./HSscaleUncertainties 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 # if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
 #    echo ' done.'
 #    echo -n '   Running gnuplot script...'
 #    cd results
 #    $gnplt plot_scaleUncertainties.gnu > /dev/null
 #    echo 'done (created example_programs/results/scaling_mu.eps).'
 #    $openeps scaling_dmu.eps 2>/dev/null &
 #    cd ..
 # else
 #    echo '   an error occured. Going to next example...'
 # fi
 echo -n '2) Running HS_2Higgses...'
 cd example_programs
 ./HS_2Higgses 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
    echo -n '   Running gnuplot script...'
    cd results
    $gnplt plot_2Higgses.gnu > /dev/null
    echo 'done (created example_programs/results/2Higgses.eps).'
    $openeps 2Higgses.eps 2>/dev/null &
    cd ..
 else
    echo '   an error occured. Going to next example...'
 fi
 
-echo -n '2) Running HShadr...'
-./HShadr 2 > ../temp_error2.txt 1 > ../temp_output2.txt
-if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
-   echo ' done.'
-   echo -n '   Running gnuplot script...'
-   cd results
-   $gnplt plot_CSscaling.gnu > /dev/null
-   echo 'done (created example_programs/results/CSscaling.eps).'
-   $openeps CSscaling.eps 2>/dev/null &
-   cd ..
-else
-   echo '   an error occured. Going to next example...'
-fi
+# echo -n '2) Running HShadr...'
+# ./HShadr 2 > ../temp_error2.txt 1 > ../temp_output2.txt
+# if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
+#    echo ' done.'
+#    echo -n '   Running gnuplot script...'
+#    cd results
+#    $gnplt plot_CSscaling.gnu > /dev/null
+#    echo 'done (created example_programs/results/CSscaling.eps).'
+#    $openeps CSscaling.eps 2>/dev/null &
+#    cd ..
+# else
+#    echo '   an error occured. Going to next example...'
+# fi
 echo -n '3) Running HSeffC...'
 ./HSeffC 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
    echo -n '   Running gnuplot script...'
    cd results
    $gnplt plot_HSeffC.gnu > /dev/null
    echo 'done (created example_programs/results/Hgg_Hbb.eps).'
    $openeps Hgg_Hbb.eps 2>/dev/null &
    cd ..
 else
    echo '   an error occured. Going to next example...'
 fi
 echo -n '4) Running HSwithSLHA on provided example SLHA file...'
 ./HSwithSLHA 1 ../example_data/SLHA/SLHA_FHexample.fh 2> ../temp_error2.txt 1> ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
 else
    echo '   an error occured. Going to next example...'
 fi
 echo -n '5) Running HBandHSwithSLHA on provided example SLHA file...'
 ./HBandHSwithSLHA 1 ../example_data/SLHA/SLHA_FHexample.fh 2> ../temp_error2.txt 1> ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
 else
    echo '   an error occured. Going to next example...'
 fi
 echo -n '6) Running HSwithToys...'
 ./HSwithToys 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
 else
    echo '   an error occured. Going to next example...'
 fi
 echo -n '7) Running HS_mass...'
 ./HS_mass 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
    echo -n '   Running gnuplot script...'
    cd results
    $gnplt plot_mh.gnu > /dev/null
    echo 'done (created example_programs/results/HS_mass.eps).'
    $openeps HS_mass.eps 2>/dev/null &
    cd ..
 else
    echo '   an error occured. Going to next example...'
 fi
 echo -n '8) Running HS_efficiencies...'
 ./HS_efficiencies 2 > ../temp_error2.txt 1 > ../temp_output2.txt
 if [ $(grep -c 'Error' ../temp_error2.txt) == 0 ] || [ $(grep -c 'stop' ../temp_error2.txt) == 0 ]; then
    echo ' done.'
    echo -n '   Running gnuplot script...'
    cd results
    $gnplt plot_efficiencies.gnu > /dev/null
    echo 'done (created example_programs/results/HS_efficiencies.eps).'
    $openeps HS_efficiencies.eps 2>/dev/null &
    cd ..
 else
    echo '   an error occured.'
 fi
 
 echo '---------------------------------------------------------------------'
 echo ' FINISHED WITH ALL TESTS. ENJOY!'
 echo '---------------------------------------------------------------------'
 rm -f results/tmp/*
\ No newline at end of file
Index: trunk/webversion/minipaper.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/webversion/GetinputfromFH.pm
===================================================================
--- trunk/webversion/GetinputfromFH.pm	(revision 505)
+++ trunk/webversion/GetinputfromFH.pm	(revision 506)
@@ -1,490 +1,490 @@
 
 #=================================================================================================================
 package     GetinputfromFH;
 #=================================================================================================================
 
 require     Exporter;
 
 use Gettestdata qw(%newhash);
 use CGI;
 use strict;
 #use warnings; To see warnings while debugging, uncomment next line:
 use CGI::Carp qw(warningsToBrowser fatalsToBrowser); 
 
 our @ISA       = qw(Exporter);
 our @EXPORT    = qw(parseFHinput);
 #our @EXPORT_OK = qw(%newhash @effChi @partR @tevhadXS @Brhi @whichinputlist);
 our $VERSION   = 1.00;
 
 
 
 sub parseFHinput{
 
 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 #
 # This is the main subroutine which extracts the numbers from the FeynHiggs User Control Center (FHUCC) results page 
 # (see www.feynhiggs.de) which was copied-and-pasted onto the HiggsBounds homepage.
 #
 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 # argument
  my $inputtype = $_[0]; 
 # should be either "fromuser" or a filename
 #------------------------------------------------------------------------------------------------------------------
 
  #declaring/initialising variables
 
  my $FHquery= "";
  my $testvar2= "";
  my $A= "";
  my $i= "";
  my $j= "";
  my $k= "";
  my $ii= "";
  my $nHiggsneut=3;
  my $nHiggsplus=1;
  my $t = "";
  my $testvarFH = "";
  my %FHvar = ();
  my $SMcoup = "";
  my $textfromFH = "";
 
  if($inputtype eq "fromuser"){ 
    $FHquery = new CGI;
 
    #------------------------------------------------------------------------------------------------------------
    #fill $textfromFH with the text which was given in the box on the homepage. Should have been copied-and-pasted from
    #the FHUCC page 
    #------------------------------------------------------------------------------------------------------------
 
    $textfromFH = $FHquery->param('textfromFH');
  }
  else{
   my $fullfilename="/hepforge/home/higgsbounds/public_html/extra/".$inputtype;
 
   open FILE1,"<", $fullfilename or die $!;      #all the fortran names for variables should be in here
 
   $textfromFH = "";
   while (my $line = <FILE1>) { #goes through each line in the file, stores it in $textfromFH
      $textfromFH = $textfromFH."\n".$line;
   }
 
  }
 
  #------------------------------------------------------------------------------------------------------------
  #first, need the value of the flag 'higgsmix', to know whether the neutral Higgs are labeled 
  #h0,HH,A0 or h1,h2,h3 
  #------------------------------------------------------------------------------------------------------------
 
  my @Higgs= ("h0","HH","A0");
  if ($textfromFH =~ m/higgsmix = 3/) {
    @Higgs= ("h1","h2","h3");
  }
 
  #------------------------------------------------------------------------------------------------------------
  # set up some lists of the strings used as keys in $FHvar. 
  #------------------------------------------------------------------------------------------------------------
 
  my @listFHBROP = ("Brhiss","Brhicc","Brhibb","Brhimumu","Brhitautau","BrhiWW","BrhiZZ","BrhiZga","Brhigaga","Brhigg");
  my @listFHBR = (@listFHBROP,"Brhjhihi","Brhiinvisible");
  my @listFHg = ("ghibb","ghitoptop","ghitautau","ghiVV");
  my @listFHRecoup = ("Recouphibb","Recouphitoptop","Recouphitautau");
  my @listFHImcoup = ("Imcouphibb","Imcouphitoptop","Imcouphitautau");
  my @listFHBRextra = ("BrtWpb","BrtHpb","BrHpjcs","BrHpjcb","BrHpjtaunu");
  my @listSMBr  = ("SMBrhigg" ,"SMBrhibb" ,"SMBrhitoptop" ,"SMBrhitautau" );
  my @listGamma = ("Gammahigg","Gammahibb","Gammahitoptop","Gammahitautau");
  my @listprodMSSM = ("prodMSSMgghi","prodMSSMtthi","prodMSSMbbhi");
  my @listprodSM   = ("prodSMgghi",  "prodSMtthi"  ,"prodSMbbhi");
  # This one should contain all of keys used:
  my @listFHvar= ("Mhi", "Mhplusi", "GF", "MZ", "couphjhiZ", "prodSqrts","Gammahi","SMGammahi", 
                  @listFHRecoup,@listFHImcoup,@listFHBR, @listFHg,
                  @listprodMSSM,@listprodSM,@listFHBRextra,@listGamma,@listSMBr);
 
  #------------------------------------------------------------------------------------------------------------
  # This section sets "string" in %FHvar, which is the string that needs to be found in $textfromFH, 
  # to locate the numers we want to extract 
  #------------------------------------------------------------------------------------------------------------
 
  $FHvar{GF}{string}[0]="GF            =";
  $FHvar{MZ}{string}[0]="MZ            =";
  $FHvar{prodSqrts}{string}[0]="prodSqrts";
 
  for ($i = 1; $i <= $nHiggsneut; ++$i){
 
   $FHvar{Mhi}{string}[$i-1]="M".$Higgs[$i-1]."           =";
 
   $FHvar{Brhiss}{string}[$i-1]    =" ".$Higgs[$i-1]."-s-s              ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhicc}{string}[$i-1]    =" ".$Higgs[$i-1]."-c-c              ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhibb}{string}[$i-1]    =" ".$Higgs[$i-1]."-b-b              ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhimumu}{string}[$i-1]  =" ".$Higgs[$i-1]."-mu-mu            ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhitautau}{string}[$i-1]=" ".$Higgs[$i-1]."-tau-tau          ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{BrhiWW}{string}[$i-1]    =" ".$Higgs[$i-1]."-W-W              ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{BrhiZZ}{string}[$i-1]    =" ".$Higgs[$i-1]."-Z-Z              ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{BrhiZga}{string}[$i-1]   =" ".$Higgs[$i-1]."-gamma-Z          ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhigaga}{string}[$i-1]  =" ".$Higgs[$i-1]."-gamma-gamma      ="; # note the space at the front is important, otherwise might get coupling
   $FHvar{Brhigg}{string}[$i-1]    =" ".$Higgs[$i-1]."-g-g              ="; # note the space at the front is important, otherwise might get coupling
                                      
   $FHvar{Brhiinvisible}{string}[$i-1]=" ".$Higgs[$i-1]."-Neu1-Neu1        ="; # note the space at the front is important, otherwise might get coupling
 
   $FHvar{Brhitoptop}{string}[$i-1]    =" ".$Higgs[$i-1]."-t-t              ="; # note the space at the front is important, otherwise might get coupling
 
   $FHvar{Gammahigg}{string}[$i-1]    =$FHvar{Brhigg}{string}[$i-1]; 
   $FHvar{SMBrhigg}{string}[$i-1]     =$FHvar{Brhigg}{string}[$i-1];
 
   $FHvar{Gammahibb}{string}[$i-1]    =$FHvar{Brhibb}{string}[$i-1]; 
   $FHvar{SMBrhibb}{string}[$i-1]     =$FHvar{Brhibb}{string}[$i-1];
 
   $FHvar{Gammahitoptop}{string}[$i-1]    =$FHvar{Brhitoptop}{string}[$i-1]; 
   $FHvar{SMBrhitoptop}{string}[$i-1]     =$FHvar{Brhitoptop}{string}[$i-1];
 
   $FHvar{Gammahitautau}{string}[$i-1]    =$FHvar{Brhitautau}{string}[$i-1]; 
   $FHvar{SMBrhitautau}{string}[$i-1]     =$FHvar{Brhitautau}{string}[$i-1];
 
-  $FHvar{Gammahi}{string}[$i-1]        =" GammaTot-".$Higgs[$i-1]."           ="; 
-  $FHvar{SMGammahi}{string}[$i-1]      =" GammaTot-SM".$Higgs[$i-1]."         ="; 
+  $FHvar{Gammahi}{string}[$i-1]        =" GammaTot-".$Higgs[$i-1]."          ="; 
+  $FHvar{SMGammahi}{string}[$i-1]      =" GammaTot-SM".$Higgs[$i-1]."        ="; 
 
   $FHvar{ghibb}{string}[$i-1]     ="CL:".$Higgs[$i-1]."-b-b           =";
   $FHvar{ghitoptop}{string}[$i-1] ="CL:".$Higgs[$i-1]."-t-t           =";
   $FHvar{ghitautau}{string}[$i-1] ="CL:".$Higgs[$i-1]."-tau-tau       =";
   $FHvar{ghiVV}{string}[$i-1] ="C:".$Higgs[$i-1]."-Z-Z            =";
 
   $FHvar{Recouphibb}{string}[$i-1]    =$FHvar{ghibb}{string}[$i-1]; 
   $FHvar{Recouphitoptop}{string}[$i-1]=$FHvar{ghitoptop}{string}[$i-1];
   $FHvar{Recouphitautau}{string}[$i-1]=$FHvar{ghitautau}{string}[$i-1];
 
   $FHvar{Imcouphibb}{string}[$i-1]    =$FHvar{ghibb}{string}[$i-1]; 
   $FHvar{Imcouphitoptop}{string}[$i-1]=$FHvar{ghitoptop}{string}[$i-1];
   $FHvar{Imcouphitautau}{string}[$i-1]=$FHvar{ghitautau}{string}[$i-1];
 
   $FHvar{prodMSSMgghi}{string}[$i-1]="prod:g-g-".$Higgs[$i-1]."          =";
   $FHvar{prodSMgghi}{string}[$i-1]=$FHvar{prodMSSMgghi}{string}[$i-1];
 
   $FHvar{prodMSSMtthi}{string}[$i-1]="prod:t-t-".$Higgs[$i-1]."          =";
   $FHvar{prodSMtthi}{string}[$i-1]=$FHvar{prodMSSMtthi}{string}[$i-1];
 
   $FHvar{prodMSSMbbhi}{string}[$i-1]="prod:b-b-".$Higgs[$i-1]."          =";
   $FHvar{prodSMbbhi}{string}[$i-1]=$FHvar{prodMSSMbbhi}{string}[$i-1];
  }
 
  $k=0;
  for ($j = 1; $j <= $nHiggsneut; ++$j){
    for ($i = 1; $i <= $nHiggsneut; ++$i){
     if($i != $j){
      $k=$k+1;
      $FHvar{Brhjhihi}{string}[$k-1]  =" ".$Higgs[$j-1]."-".$Higgs[$i-1]."-".$Higgs[$i-1]."            ="; # note the space at the front is important, otherwise might get coupling
     }
    }
  }
  $k=0;
  for ($j = 1; $j <= $nHiggsneut; ++$j){
    for ($i = 1; $i <= $j; ++$i){
      $k=$k+1;
      $FHvar{couphjhiZ}{string}[$k-1]     ="C:".$Higgs[$j-1]."-".$Higgs[$i-1]."-Z           =";
    }
  }
 
 #---------------------------------------------------------
  
  $FHvar{Mhplusi}{string}[0]="MHp           =";
 
  $FHvar{BrtWpb}{string}[0]    =" t-W-b               =";
  $FHvar{BrtHpb}{string}[0]    =" t-Hp-b              =";
  $FHvar{BrHpjcs}{string}[0]   =" Hp-c-s              =";
  $FHvar{BrHpjcb}{string}[0]   =" Hp-c-b              ="; 
  $FHvar{BrHpjtaunu}{string}[0]=" Hp-nu_tau-tau       =";
 
  #------------------------------------------------------------------------------------------------------------
  # This section sets "column" in %FHvar, which indicates the column number which we want to read the number in from
  #------------------------------------------------------------------------------------------------------------
 
  foreach $j ("Mhi","Mhplusi","couphjhiZ",@listFHRecoup,"GF","MZ",@listprodMSSM,"prodSqrts", 
              "Gammahi","SMGammahi",@listGamma){
    $FHvar{$j}{column}=1;
  }
  
  foreach $j (@listFHBR,@listFHBRextra,@listprodSM ,@listFHImcoup){
    $FHvar{$j}{column}=2;
  }
  foreach $j ( @listFHg, @listSMBr){
    $FHvar{$j}{column}=3;
  }
  $FHvar{Mhplusi}{column}= -1;#special case
 
  #------------------------------------------------------------------------------------------------------------
  # This section sets "necessary" in %FHvar, which indicates whether we should be concerned if we can't read in the 
  # number
  #------------------------------------------------------------------------------------------------------------
 
  foreach $j (@listFHvar){
   for ($i = 1; $i <= @{$FHvar{$j}{string}}; ++$i){
    $FHvar{$j}{necessary}[$i-1]="yes";
   }
  }
 
  foreach $j ("Brhiinvisible", "Brhjhihi", "BrHpjcb", "BrhiZga", "BrhiZZ", "BrhiWW", "ghiVV","couphjhiZ",
              @listSMBr,@listGamma,@listprodMSSM,@listprodSM){
   for ($i = 1; $i <= @{$FHvar{$j}{string}}; ++$i){
    $FHvar{$j}{necessary}[$i-1]="no";
   }
  }
 
  #------------------------------------------------------------------------------------------------------------
  # Now to read in the numbers we want from $textfromFH into "val" in %FHvar
  #------------------------------------------------------------------------------------------------------------
 
  foreach $A ($textfromFH){
     if ( (length($A) == 0) ) {
         print "Missing input data ";  
         die;
     }
     if (length($A) > 50000) {
         print "Input data too long";
         print "size = ".length($A);
         die;
     }
 
     foreach $j (@listFHvar){
 
      for ($i = 1; $i <= @{$FHvar{$j}{string}}; ++$i){
 
       if ($textfromFH =~ m/$FHvar{$j}{string}[$i-1]/) {
 
        $_ = $textfromFH;
 
        if ($FHvar{$j}{column}==1){
          /$FHvar{$j}{string}[$i-1]\s+([0-9\.E\-\+]+)\s+/;
          $FHvar{$j}{val}[$i-1] = $1;
        }
        elsif ($FHvar{$j}{column}==2){
          /$FHvar{$j}{string}[$i-1]\s+[0-9\.E\-\+]+\s+([0-9\.E\-\+]+)\s+/;
          $FHvar{$j}{val}[$i-1] = $1;
        }       
        elsif ($FHvar{$j}{column}==3){
          /$FHvar{$j}{string}[$i-1]\s+[0-9\.E\-\+]+\s+[0-9\.E\-\+]+\s+([0-9\.E\-\+]+)\s+/;
          $FHvar{$j}{val}[$i-1] = $1;
        }       
        elsif ($FHvar{$j}{column}==-1){ #special case
          if($j eq "Mhplusi"){ # don't want MHp=-1 (i.e. says that MA0 was input para), want next occurence
           /$FHvar{$j}{string}[$i-1]\s+([0-9][0-9\.E\-\+]+)\s+/; #as for option column==1, except specifies that 
                                                                 #first character must be a number i.e. *not* a minus sign
           $FHvar{$j}{val}[$i-1] = $1;
          }
          else{
           print "not done yet 2";
           die;
          }
        }
        else{
          print "not done yet";
          die;
        }
 
       } 
      
       elsif ($FHvar{$j}{necessary}[$i-1] eq "no"){
         $FHvar{$j}{val}[$i-1] = 0; # if we don't find this number, and it's not necessary, we can just set it to zero
       }
       else {
          print "Bad input data: ".$j.'<br>'; 
          die;
       }
 
       $testvar2 = $FHvar{$j}{val}[$i-1];
       $testvar2 =~ s/[0-9E\-\+]//g;
       if  (length($testvar2) > 1) {
         print "Too many decimal points";
         die;
       }
  
       $testvar2 = $FHvar{$j}{val}[$i-1];
       $testvar2 =~ s/[0-9\.]//g;
       if  (($testvar2 != "-" )|| ($testvar2 != "" )||($testvar2 != "E-" )||($testvar2 != "E+")||($testvar2 != "-E-" )||($testvar2 != "-E+")) {
           print "Wrong input";
           die;
       }
 
      }
 
     }
 
  }
 	    
  #------------------------------------------------------------------------------------------------------------
  # Now, use %FHvar to fill %newhash
  #------------------------------------------------------------------------------------------------------------
 
  # get the normalisation factor for the Higgs pair production cross section:
 
  my $norm = $FHvar{GF}{val}[0]*sqrt(2)*$FHvar{MZ}{val}[0]**2;
 
  # start filling "array" in %newhash:
 
  for ($i = 1; $i <= $nHiggsneut; ++$i){
   $newhash{Mhi}{array}[$i-1]        = $FHvar{Mhi}{val}[$i-1];
 
   foreach my $t ("partRudhjWp", "partRcshjWp", "partRudhjWm", "partRcshjWm",
-                  "tevXSvbfratio","lhc7XSvbfratio","lepXShjZratio",
+                  "tevXSvbfratio","lhc7XSvbfratio","lhc8XSvbfratio","lepXShjZratio",
                   "partRddhjZ","partRuuhjZ","partRsshjZ","partRcchjZ","partRbbhjZ"){
     $newhash{$t}{array}[$i-1]       =$FHvar{ghiVV}{val}[$i-1]**2; 
   }
 
   $newhash{partRgghjZ}{array}[$i-1]  =  0; # this contribution is not included in FH 2.8.0, so just set to zero. It's small anyway.
 
   foreach my $t ("partRgghj"){
     my $prodMSSMgghi=$FHvar{prodMSSMgghi}{val}[$i-1];
     if( $prodMSSMgghi >= 0 ){
       $newhash{$t}{array}[$i-1]       = $prodMSSMgghi / $FHvar{prodSMgghi}{val}[$i-1];
     }
     else{
       $newhash{$t}{array} [$i-1]      = $FHvar{Gammahigg}{val}[$i-1]/($FHvar{SMGammahi}{val}[$i-1]*$FHvar{SMBrhigg}{val}[$i-1]);
     } 
   }  
 
   foreach my $t (@listFHBROP,"Brhiinvisible"){
     $newhash{$t}{array}[$i-1]       =$FHvar{$t}{val}[$i-1];
   }
   
  }
 
  # these couplings are a bit more complicated, so they are dealt with in a separate subroutine at the end of this file
  adjustcoupling("Recouphibb",    "Imcouphibb",    "ghibb"    ,"Gammahibb"    ,"SMBrhibb",   , "prodMSSMbbhi", "prodSMbbhi");
  adjustcoupling("Recouphitoptop","Imcouphitoptop","ghitoptop","Gammahitoptop","SMBrhitoptop", "prodMSSMtthi", "prodSMtthi");
  adjustcoupling("Recouphitautau","Imcouphitautau","ghitautau","Gammahitautau","SMBrhitautau",-1,-1 );
  
 
  for ($i = 1; $i <= $nHiggsneut; ++$i){
    foreach my $t ("partRbbhj", "partRbghjb", "lepXSbbhjratio"){
      $newhash{$t}{array}[$i-1]      =$FHvar{ghibb}{val}[$i-1]**2;
    }
 
-   foreach my $t ("tevXStthjratio","lhc7XStthjratio"){
+   foreach my $t ("tevXStthjratio","lhc7XStthjratio","lhc8XStthjratio"){
      $newhash{$t}{array}[$i-1]      =$FHvar{ghitoptop}{val}[$i-1]**2;
    }
 
    foreach my $t ("lepXStautauhjratio"){
      $newhash{$t}{array}[$i-1]      =$FHvar{ghitautau}{val}[$i-1]**2;
    }
  }
 
  # determine whether the Higgs is CP even, odd or mixed, using the coupling to b-quarks, since this coupling should always exist
  for ($i = 1; $i <= $nHiggsneut; ++$i){
    if(     abs($FHvar{Imcouphibb}{val}[$i-1]) < 10**(-10) ){
      $newhash{CPvalue}{array}[$i-1] = '-1';
    }
    elsif(  abs($FHvar{Recouphibb}{val}[$i-1]) < 10**(-10) ){
      $newhash{CPvalue}{array}[$i-1] = '1';
    }
    else{
      $newhash{CPvalue}{array}[$i-1] = '0';
    }
  }
 
  $newhash{Brhjhihi}{array}     = $FHvar{Brhjhihi}{val};
 
  $k=0;
  for ($j = 1; $j <= $nHiggsneut; ++$j){
    for ($i = 1; $i <= $nHiggsneut; ++$i){
      $k=$k+1;
      $newhash{lepXShjhiratio}{array}[$k-1]   =  $FHvar{couphjhiZ}{val}[$k-1]**2/$norm; 
    }
  } 
 
  $newhash{Mhplusi}{array}[0]        = $FHvar{Mhplusi}{val}[0];
  $newhash{lepXSHpjHmjratio}{array}[0]        = 1; # this is always 1 in 2HDM at tree level
 
  foreach my $t (@listFHBRextra){ 
   $newhash{$t}{array}        = $FHvar{$t}{val};
  }
 
  if($inputtype eq "fromuser"){ 
    # printing this warning message saves us having to check all the susy particle masses! A bit lazy though. 
    print '<p><b>Warning</b>: if the lightest neutralino is not the LSP, edit Br(higgs->invisible) by hand.</p>';
  }
 
  # this is commented out because now we have both tevatron and lhc cross sections, there is not a strong preference
  # for using one type of hadronic cross section over the other to get the partonic cross sections.
  
  #if ( abs($FHvar{prodSqrts}{val}[0]-2) > 0.1 ) {
  # print '<p><b>Warning</b>: it is better to take Higgs production cross sections from FeynHiggs which are calculated at a centre-of-mass energy of 2 GeV rather than '
  #   .$FHvar{prodSqrts}{val}[0].' GeV, since we will be using limits from the Tevatron.</p>';
  #}
 
 
  sub adjustcoupling{
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #
  # This subroutine manipulates the normalised effective coupling (where needed).
  #
  # $ratcoup in %FHvar starts off by containing the number from the third column in the lines for the couplings 
  # (labeled 'SMratio' on the FHUCC results page), where it exists and is zero where not. 
  #
  # 'SMratio' is calculated from im(mssm coupling)/im(sm coupling)
  # 
  # If im(mssm)=0 (e.g. for A0-b-b, because A0 is CP odd) or there is CP violation,
  # $ratcoup needs to be edited. 
  #
  # So, by the end of the subroutine, $FHvar{$ratcoup}{val} should store the square root of what we need as input to HB.
  # 
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  # arguments: these are all strings
     my $recoup    = $_[0]; # real part of MSSM coupling
     my $imcoup    = $_[1]; # imaginary part of MSSM coupling
     my $ratcoup   = $_[2]; # the normalised coupling (i.e. the square root of what we need as input to HiggsBounds)
     my $partgamma = $_[3]; # the MSSM partial decay width
     my $SMBr      = $_[4]; # the SM branching ratio
     my $MSSMprod  = $_[5]; # the MSSM production cross section
     my $SMprod    = $_[6]; # the SM production cross section
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
     my $small = 10**(-10);
 
     my $sumimcoup = 0;
     for ($i = 1; $i <= $nHiggsneut; ++$i){
        $sumimcoup = $sumimcoup + abs($FHvar{$imcoup}{val}[$i-1]);
     }
 
     for ($i = 1; $i <= $nHiggsneut; ++$i){
 
       if(  abs($FHvar{$ratcoup}{val}[$i-1]) > $small){#can use SMratio column
         if(abs($FHvar{$recoup}{val}[$i-1]) > $small){
            #CP mixed case: first get normalisation from imcoup and ratcoup:
            $SMcoup = $FHvar{$imcoup}{val}[$i-1]/$FHvar{$ratcoup}{val}[$i-1];
            $FHvar{$ratcoup}{val}[$i-1]          =  sqrt($FHvar{$recoup}{val}[$i-1]**2+$FHvar{$imcoup}{val}[$i-1]**2)/$SMcoup;
         }
         else{
            # CP even case: $FHvar{$ratcoup}{val} does not need to be changed
         }
       }
       else{# the SMratio column can not be used
 
         # try getting $FHvar{$ratcoup}{val} from the decay widths
         if(abs($FHvar{SMGammahi}{val}[$i-1]*$FHvar{$SMBr}{val}[$i-1]) > 0){
           $FHvar{$ratcoup}{val}[$i-1]      = sqrt($FHvar{$partgamma}{val}[$i-1]/($FHvar{SMGammahi}{val}[$i-1]*$FHvar{$SMBr}{val}[$i-1]));
         }
         # if that doesn't work, try getting it from the production cross sections
         elsif($FHvar{$SMprod}{val}[$i-1] > $small ){
           $FHvar{$ratcoup}{val}[$i-1]      = sqrt($FHvar{$MSSMprod}{val}[$i-1]/$FHvar{$SMprod}{val}[$i-1]);;
         }
         # and if that doesn't work, can get it from a real coupling, using normalisation from a different imaginary coupling.
         # this is a last resort because the SM couplings are not independent of Higgs mass
         # e.g. the h0-b-b SM coupling will involve mb(Mh0) but the HH-b-b SM coupling will involve mb(MHH),
         # yet this method will neglect the difference between mb(Mh0) and mb(MHH) 
         elsif(  $sumimcoup > $small ){
          for ($j = 1; $j <= $nHiggsneut; ++$j){
            if(abs($FHvar{$imcoup}{val}[$j-1]) > 10**(-10) ){
              $SMcoup = $FHvar{$imcoup}{val}[$j-1]/$FHvar{$ratcoup}{val}[$j-1];
              $FHvar{$ratcoup}{val}[$i-1]          =  ($FHvar{$recoup}{val}[$i-1]/$SMcoup);
            }     
          } 
         }
         else{
           print "Warning: Can not calculate ".$ratcoup."[".$i."]...setting to zero.<br>";
           $FHvar{$ratcoup}{val}[$i-1]      =0; 
         }
       }
     }
  }
 
 
 }
 
Index: trunk/webversion/downloads.html
===================================================================
--- trunk/webversion/downloads.html	(revision 505)
+++ trunk/webversion/downloads.html	(revision 506)
@@ -1,372 +1,379 @@
 <HTML>
 <HEAD>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" >
 <link rel="stylesheet" type="text/css" href="http://higgsbounds.hepforge.org/HBstyle.css">
 <TITLE>HiggsBounds and HiggsSignals</TITLE>
 </HEAD>
 <BODY>
 
 
 <!--<p><h1>Program HiggsBounds</h1></p>-->
 <p><h1>HiggsBounds</h1></p>
 <p><h2>Downloads</h2></p>
 
 <p>
 You can download the current version of HiggsBounds here: <a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.2.0.tar.gz">  HiggsBounds-4.2.0.tar.gz  </a>. This package is using Fortran 90/2003 (note to gfortran users: you will need version 4.2 or higher). As always, please contact us if you have any problems with the installation. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <a href="downloads_detailed.html">show history</a> )
 </p>
 
 <!--<p> In the future HiggsBounds will only contain the Fortran 90/2003 version.</p>-->
 <!--<p>Version 3.x.xbeta includes an <a href="http://home.fnal.gov/~skands/slha/">SLHA</a> interface. For HiggsBounds 2.x.x, a beta version of an SLHA interface can be downloaded here:  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HB2.x.x-beta-SLHA-extension.tar.gz">  HB2.x.x-beta-SLHA-extension.tar.gz</a>. (This requires a Fortran 90/2003 compiler.) -->
 
 <!-- BEGIN DETAILED BIT
 <p>
 <table border="0">
  <tr>
   <td width=100><b>Date</b></td><td width=250><b>File</b></td><td><b>Comments</b></td>
  </tr>
 
  <tr>
   <td valign="top">  12.12.14 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.2.0.tar.gz">  HiggsBounds-4.2.0.tar.gz  </a></td>
   <td valign="top">  Includes many results from Summer 2014. The CMS MSSM h/H/A->tau tau search results are implemented via a likelihood, that is reconstructed from the single resonance model provided by CMS, see the new example program 'HBwithLHCchisq.f90' for details. Careful: This is still in testing phase!
   </td>
  </tr>
 
  <tr>
   <td valign="top">  02.09.14 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.1.3.tar.gz">  HiggsBounds-4.1.3.tar.gz  </a></td>
   <td valign="top">  Bug fix: corrected problem in implementation of ATL-CONF-2013-013 (high mass H->4l, ggF/VBF), which led to weaker limits.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  03.07.14 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.1.2.tar.gz">  HiggsBounds-4.1.2.tar.gz  </a></td>
   <td valign="top">  Update of HiggsBounds-4.1.1, where one analysis (CMS MSSM H->tau tau) had been accidentally removed. This affected only HiggsBounds-4.1.1.
   </td>
  </tr>
 
 
  <tr>
   <td valign="top">  26.05.14 </td><td valign="top">  HiggsBounds-4.1.1.tar.gz </td>
   <td valign="top">  Bug fix: Problem in theory input of the neutral Higgs mass value(s) in parameter scans, which appeared when HiggsBounds and HiggsSignals were used simultaneously. Thanks go to Matthias Hamer for pointing it out!
   </td>
  </tr>
 
  <tr>
   <td valign="top">  03.11.13 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.1.0.tar.gz">  HiggsBounds-4.1.0.tar.gz  </a></td>
   <td valign="top">  Higgs exclusion limits from Summer 2013 conferences added.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  09.05.13 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-4.0.0.tar.gz">  HiggsBounds-4.0.0.tar.gz  </a></td>
   <td valign="top">  <b>Major changes:</b> Includes extended input framework and the latest results for the LHC at 8TeV. Modified statistical combination ("full method": testing each Higgs boson individually) necessary due to Higgs discovery. Treatment of theoretical mass uncertainties by multiple evaluations at varied mass positions. Chi-squared values for the LEP exclusion limits are now officially included via an addon (separate download, see below).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  18.05.12 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.8.0.tar.gz">  HiggsBounds-3.8.0.tar.gz  </a></td>
   <td valign="top">  Includes the Higgs search results from the Moriond 2012 conference. Another major improvement is a revamped model likeness test, which weights the allowed deviation of the individual Higgs channels by their expected contribution to the total signal rate in the Standard Model. This in particular enhances the applicability of combined SM Higgs searches.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  20.03.12 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.7.0.tar.gz">  HiggsBounds-3.7.0.tar.gz  </a></td>
   <td valign="top">  Official release of HiggsBounds Version 3.x.x including both versions of the code. Minor changes in the Fortran 90/2003 version. The package contains the most recent analyses before Moriond 2012.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  19.01.12 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.6.1beta.tar.gz">  HiggsBounds-3.6.1beta.tar.gz  </a></td>
   <td valign="top">  Bug fix in CMS analysis HIG-PAS-11-029. The observed and expected limits were in the wrong order. Thanks go to Oscar Stal for spotting this.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  18.01.12 </td><td valign="top"> HiggsBounds-3.6.0beta.tar.gz  </td>
   <td valign="top">Contains 8 new ATLAS and 11 new CMS searches, including the results from the joint ATLAS and CMS seminar at CERN on 13th December 2011.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  19.10.11 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.5.0beta.tar.gz">  HiggsBounds-3.5.0beta.tar.gz  </a></td>
   <td valign="top">EPS 2011 results part III: 3 new tables of experimental results from EPS 2011. LeptonPhoton 2011 results: 8 new ATLAS analyses and 7 new CMS analyses. SUSY 2011: 1 new CMS analysis.
   </td>
  </tr>
  
  <tr>
   <td valign="top">  29.07.11 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.4.0beta.tar.gz">  HiggsBounds-3.4.0beta.tar.gz  </a></td>
   <td valign="top">EPS 2011 results part II: 14 new tables of experimental results from EPS 2011.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  26.07.11 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.3.0beta.tar.gz">  HiggsBounds-3.3.0beta.tar.gz  </a></td>
   <td valign="top">EPS 2011 results part I: 15 new tables of experimental results, mostly from EPS 2011 (part II to follow shortly).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  13.07.11 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-3.2.0beta.tar.gz">  HiggsBounds-3.2.0beta.tar.gz  </a></td>
   <td valign="top">Includes new searches. Fixed bug in S95tables.f90 which could cause the code to stop when it was compiled with intel fortran (thanks go to Lisa Zeune).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  07.07.11 </td><td valign="top"> HiggsBounds-3.1.4beta.tar.gz </td>
   <td valign="top">Fixed bug in S95tables.f90 in the SM-likeness test of the search ATLAS-CONF-2011-025. Due to this bug the analysis was applied also in inappropriate cases such as fermiophobic Higgs models. Many thanks to Aleksandr Azatov for pointing this out.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  19.06.11 (slight change 21.06.11) </td><td valign="top"> HiggsBounds-3.1.3beta.tar.gz  </td>
   <td valign="top">Fixed bug in input.F90, which affected the command line version of HiggsBounds only. Bug caused the program to stop with the error message 'error in input file format' if the option whichinput='part' was selected.<br>
   21.06.11: Version number corrected. Default delta_Mh_TEV and delta_Mh_LHC changed from 10GeV to 0GeV (these variables are set at the top of S95tables.f90 and can be changed by the user - see manual for a description).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  06.06.11 </td><td valign="top">HiggsBounds-3.1.2beta.tar.gz</td>
   <td valign="top"> Bug Fix in example program HBwithFH.F: BR(Higgs->invisible) was always set to zero by mistake. Thanks go to Nazila Mahmoudi for pointing this out!
   </td>
  </tr>
 
  <tr>
   <td valign="top">  01.06.11 (slight change 03.06.11) </td><td valign="top"> HiggsBounds-3.1.1beta.tar.gz</td>
   <td valign="top"> Bug Fix in normalisation factor in the Tevatron gluon fusion cross section. (Bug was present in HB-3.0.0beta and HB-3.1.0beta.)<br>
   03.06.11: Now allows the user to change delta_Mh_TEV and delta_Mh_LHC (this was not implemented in HB-3.0.0beta and HB-3.1.0beta).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  20.05.11 (slight change 23.05.11, 24.05.11, 26.05.11)  </td><td valign="top"> HiggsBounds-3.1.0beta.tar.gz </td>
   <td valign="top"> Improved SLHA interface: subroutine version and HBwithSLHA run 6 times faster, commandline version runs 12 times faster. We provide a new program (HBSLHAinputblocksfromFH) that uses FeynHiggs 2.8.0 subroutines to create a SLHA file suitable for input to HiggsBounds. See notes in the beginning of HBSLHAinputblocksfromFH.f90 for further instructions. We have also updated the example program HBwithFH (which demonstrates how HiggsBounds subroutines and FeynHiggs subroutines can be used together) to use FeynHiggs 2.8.0. We have also added one more CDF analysis.<br>
 23.05.11: Couple of lines added to make sure the code compiles with Portland Fortran compiler. If you are not using the Portland compiler there is no need to change your copy of HiggsBounds-3.1.0beta.<br>
 24.05.11: Renamed HBSLHAinputblocksfromFH.f90 to HBSLHAinputblocksfromFH.F90 and fixed a typo in this file, which was added yesterday. <br>
 26.05.11: Changed the FeynHiggs flags used by default in HBSLHAinputblocksfromFH_extras.F90. Note that, if using either HBSLHAinputblocksfromFH or HBwithFH, the user should check that these flags are given their preferred values (e.g. these could differ in the real and complex MSSM).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  10.05.11  </td><td valign="top"> HiggsBounds-3.0.0beta.tar.gz </td>
   <td valign="top"><b>Major changes:</b> Includes LHC Higgs searches. Sinces this requires a lot of extra theoretical information, this required substantial changes in the user interface: see the <a href="manual3.0.0beta.pdf">updated manual</a> for more information.<br> 
   </td>
  </tr>
 
  <tr>
   <td valign="top">  08.04.11  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-2.1.1.tar.gz">  HiggsBounds-2.1.1.tar.gz  </a></td>
   <td valign="top">Bug in HB 2.0.0 and HB2.1.0 corrected: In the f77 version, the array
 BRhjZgam was not properly initialised for large Higgs masses. Thanks go
 to Oscar Stål.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  02.02.11  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-2.1.0.tar.gz">  HiggsBounds-2.1.0.tar.gz  </a></td>
   <td valign="top">New tables of experimental results added (see the output of the webversion for full list).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  05.08.10 (slight change 16.03.11) </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-2.0.0.tar.gz">  HiggsBounds-2.0.0.tar.gz  </a></td>
   <td valign="top"><b>Major changes:</b> Includes charged Higgs searches and a wider range of neutral Higgs searches. Sinces this requires a lot of extra theoretical information, this required substantial changes in the user interface: see the <a href="http://arxiv.org/abs/1102.1898">updated manual</a> for more information.<br> 16.03.11: replaced the -for-comparison files in the HiggsBounds-f77 folder (they had not been generated with the most up-to-date copy of HB 2.0.0). No changes made to the code itself. </td>
  </tr>
 
  <tr>
   <td valign="top">  12.09.09 (slight change 24.02.10)  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.2.0.tar.gz">  HiggsBounds-1.2.0.tar.gz  </a></td>
   <td valign="top">More tables of Tevatron results added, where they require no new input to HiggsBounds. New versions of the files HBwithCPsuperH.f and HBwithCPsuperH.input, which can be used in conjunction with the version of CPsuperH2.0 from 10 June 2009. (Old versions are also still included). Bug fixed in the sample program HBwithFHdemo (calculation of g2hjgg).<br> 24.02.2010: some line breaks added to files HiggsBounds-f77/TEV-bound.F and HiggsBounds-f77/analyses-descriptions.h, so that code now compiles with the Intel Fortran compiler. (Thanks go to Shehu AbdusSalam)
   </td>
  </tr>
 
  <tr>
   <td valign="top">  29.06.09  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.1.0.tar.gz">  HiggsBounds-1.1.0.tar.gz  </a></td>
   <td valign="top">Many new tables of experimental results added (see the output of the webversion for full list). Note that this release only includes experimental results which require no new input from the HiggsBounds user - we will shortly release another version which will deal with these extra results. Slight change to Standard Model results such that they agree more precisely with those used by the Tevatron experiments (see the file br.input for the input given to HDecay to get these branching ratios). The variable 'whichexpt' has been renamed 'whichanalyses', since future verions will have the option of including results from published experimental analyses only. The file HBwithFH.F is designed to be used in conjunction with FeynHiggs version 2.6.5. The package also includes the file HBwithFH2.6.4.F, which is suitable for FeynHiggs version 2.6.4. Note that these are not interchangeable.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  09.03.09  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.0.3.tar.gz">  HiggsBounds-1.0.3.tar.gz  </a></td>
   <td valign="top">F90 version: now uses the Bayesian results from
 arXiv:0808.0534, rather than those obtained with the CLs calculation
 (and is therefore now consistent with F77 version). F77 version: bug in
 user interface to SM Br(H->ZZ) fixed. (n.b. this does not affect the
 branching ratios used internally by <code>HiggsBounds</code> or any of the example
 programs)
   </td>
  </tr>
 
  <tr>
   <td valign="top">  04.03.09  </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.0.2.tar.gz">  HiggsBounds-1.0.2.tar.gz  </a></td>
   <td valign="top">F90 version: changes made to ensure it compiles with g95 (Some changes also made to aid compilation with the NAG compiler. However, note that <code>HiggsBounds</code> has not been properly tested with this compiler).
 Edited <code>HiggsBounds-f90/create_store_pathname.bat</code> to cope with arbitrarily long paths.
 Named some sample output files more concisely.
 Commentaries in <code>HiggsBounds-f77/makefile.in</code> improved.</td>
  </tr>
 
  <tr>
   <td>  10.02.09  </td><td><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.0.1.tar.gz">  HiggsBounds-1.0.1.tar.gz  </a></td>
   <td>minor cosmetic change to file <code>HiggsBounds-f77/makefile.in</code></td>
  </tr>
  <tr>
   <td>  06.02.09  </td><td><a href="http://www.hepforge.org/archive/higgsbounds/HiggsBounds-1.0.0.tar.gz">  HiggsBounds-1.0.0.tar.gz  </a></td>
   <td>Version Submitted to CPC</td>
  </tr>
 </table>
 </p>
 END DETAILED BIT -->
 
 <!--<p>Further information can be found in <a href="http://arxiv.org/abs/0811.4169" target="_blank">arXiv:0811.4169</a> (Comput.Phys.Commun.181:138-167,2010), <a href="http://arxiv.org/abs/1102.1898">arXiv:1102.1898</a> and the <a href="manual3.0.0beta.pdf">HiggsBounds 3.x.xbeta manual</a>.</p>-->
 
 <p>
 Further information can be found in the following references:
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/0811.4169"">arXiv:0811.4169</a> (Comput.Phys.Commun.181:138-167,2010)</li>
 <li><a href="http://arxiv.org/abs/1102.1898">arXiv:1102.1898</a> (Comput.Phys.Commun.182:2605-2631,2011)</li>
 <li><a href="http://arxiv.org/abs/1301.2345">arXiv:1301.2345</a> (PoS CHARGED2012 (2012) 024)</li>
 <li><a href="http://arxiv.org/abs/1311.0055">arXiv:1311.0055</a> (Eur.Phys.J. C74 (2014) 2693)</li>
 </ul>
 <p>In particular, consult the latest version of the <a href="HiggsBounds-4-manual.pdf">HiggsBounds 4.x.x manual</a>.</p>
 <p>If you download the code, we recommend that you sign up to the <a href="http://www.hepforge.org/lists/listinfo/higgsbounds-announce">HiggsBounds-announce mailing list</a>, in order to be informed when new releases are available. </p>
 <p>If you have any questions, comments, bug reports or feature requests please let us know. Contact <a href="mailto:tim ( at ) th.physik.uni-bonn.de">Tim</a> or <a href="mailto:oscar.stal ( at ) fysik.su.se">Oscar</a>.</p>
 
 <h2>Referencing HiggsBounds</h2>
 
 <!--<p>If you use HiggsBounds, please cite <a href="http://arxiv.org/abs/0811.4169" target="_blank">arXiv:0811.4169</a> (Comput.Phys.Commun.181:138-167,2010) and <a href="http://arxiv.org/abs/1102.1898" target="_blank">arXiv:1102.1898</a>.</p>-->
 <p>If you use HiggsBounds, please cite the references listed above.</p>
 
 <p>HiggsBounds incorporates many results from experimental searches and SM calculations. To make it quicker for users to access these references, we provide a list as a <a href="extra/minipaper.bib" target="_blank">.bib file</a> and a <a href="extra/minipaper.bbl" target="_blank">.bbl file</a>. (This example <a href="extra/minipaper.tex" target="_blank">.tex file</a> cites each of these sources once, creating this <a href="extra/minipaper.pdf" target="_blank">.pdf file</a>).
 </p>
 
 <p>
 <h2>Quick start guide</h2>
 <ol>
  <li>unpack the <code>.tar.gz</code> file </li>
  <li><code>cd</code> to the HiggsBounds directory</li>
  <li><code>./configure</code></li>
  <li><code>make</code></li>
  <li>run the program <code>HiggsBounds</code> using the command-line options 
   <pre> 
 ./HiggsBounds <i>whichanalyses whichinput nHzero nHplus prefix </i>
   </pre>
   For example,  
   <pre>
 ./HiggsBounds LandH effC 3 1 'example_data/HB_randomtest50points_'
   </pre>
   will run <code>HiggsBounds</code>
  <ul>
   <li> using LEP, Tevatron and LHC data (<code><i>whichanalyses</i>=LandH</code>)</li>
   <li> with input in the 'effective coupling' format (<code><i>whichinput</i>=effC</code>) </li>
   <li> for a model containing three neutral Higgs (<code><i>nHzero</i>=3</code>) </li>
   <li>   and one singly, positively charged Higgs (<code><i>nHplus</i>=1</code>) </li>
   <li> using the example input files (supplied in the HiggsBounds package): <pre> 
   example_data/HB_randomtest50points_MH_GammaTot.dat
   example_data/HB_randomtest50points_MHplus_GammaTot.dat
   example_data/HB_randomtest50points_effC.dat
   example_data/HB_randomtest50points_BR_H_NP.dat
   example_data/HB_randomtest50points_BR_t.dat
   example_data/HB_randomtest50points_BR_Hplus.dat
   example_data/HB_randomtest50points_LEP_HpHm_CS_ratios.dat
   example_data/HB_randomtest50points_additional.dat </pre>
   </li>
  </ul>
  The results are stored in
  <pre> 
       example_data/HB_randomtest50points_HiggsBounds_results.dat
  </pre>
 
  <li>
  The HiggsBounds package also contains simple example programs showing the use of the HiggsBounds subroutines, including programs demonstrating the use of HiggsBounds in conjunction with <a href="http://www.feynhiggs.de" target="_blank">FeynHiggs</a> or <a href="http://www.hep.man.ac.uk/u/jslee/CPsuperH.html" target="_blank">CPsuperH</a>.  
  </li> 
 </ol>
 
 </p>
 
 <h2>The LEP exclusion chi-squared extension</h2>
 
 <p>For the model-independent LEP Higgs searches the full information on CLs and CLsb have been made available to the HiggsBounds team, such that we can derive a chi-squared measure (assuming the Gaussian limit) for the LEP exclusion. For more information, see the <a href="HiggsBounds-4-manual.pdf">HiggsBounds 4.x.x manual</a>.</p>
 <p>In order to enable the LEP chi-squared extension, please download <a href="http://www.hepforge.org/archive/higgsbounds/csboutput_trans_binary.tar.gz">csboutput_trans_binary.tar.gz</a>, which contains the necessary experimental tables, and follow the descriptions in the HiggsBounds manual.</p>
 <p>Note that the LEP chi-squared extension is only supported for the usage of HiggsBounds via the Fortran subroutines/library.
 
 <br>
 
 <p><h1>HiggsSignals</h1></p>
 <p><h2>Downloads</h2></p>
 
 <p>
-You can download the current version of HiggsSignals here: <a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.3.0.tar.gz">  HiggsSignals-1.3.0.tar.gz  </a>. This package is using Fortran 90/2003 (note to gfortran users: you will need version 4.2 or higher). HiggsSignals needs to be linked to the HiggsBounds version 4.1 (or higher) library. As always, please contact us if you have any problems with the installation. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <a href="downloads_detailed.html">show history</a> )
+You can download the current version of HiggsSignals here: <a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.3.1.tar.gz">  HiggsSignals-1.3.1.tar.gz  </a>. This package is using Fortran 90/2003 (note to gfortran users: you will need version 4.2 or higher). HiggsSignals needs to be linked to the HiggsBounds version 4.1 (or higher) library. As always, please contact us if you have any problems with the installation. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( <a href="downloads_detailed.html">show history</a> )
 </p>
 
 <!-- BEGIN DETAILED BIT
 <p>
 <table border="0">
  <tr>
   <td width=100><b>Date</b></td><td width=250><b>File</b></td><td><b>Comments</b></td>
  </tr>
 
+
+ <tr>
+  <td valign="top">  28.01.15 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.3.1.tar.gz">  HiggsSignals-1.3.1.tar.gz  </a></td>
+  <td valign="top">  Bug fix in the Higgs mass chi-squared contribution in the peak-centered chi-squared method: Removed artificial minus signs in the off-diagonal entries of the covariance matrix. (Thanks go to Bjoern Sarrazin for helpful comments!) The simultaneous use of peak- and mass-centered chi-squared methods is currently deactivated due to current developments. We strongly recommend to use the peak-centered chi-squared method.
+  </td>
+ </tr>
+
  <tr>
   <td valign="top">  12.12.14 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.3.0.tar.gz">  HiggsSignals-1.3.0.tar.gz  </a></td>
   <td valign="top">  Includes: updated observables (status December 2014). Revamped the Higgs mass chi^2 contribution in the peak-centered chi^2 method and included a new example program 'HS_2Higgses.f90'. Changes are documented in the <a href="HS-1.3_releasenote.pdf" target="_blank">HiggsSignals-1.3 release note</a>.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  10.03.14 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.2.0.tar.gz">  HiggsSignals-1.2.0.tar.gz  </a></td>
   <td valign="top">  Includes: updated observables (status March 2014).
   </td>
  </tr>
 
  <tr>
   <td valign="top">  13.11.13 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.1.0.tar.gz">  HiggsSignals-1.1.0.tar.gz  </a></td>
   <td valign="top">  Includes: updated default observables (status November 2013); some corrections in the HS-1.0.0 observable set (status April 2013); refined implementation of theoretical rate uncertainties; interface to insert different signal efficiencies for the model vs. SM. A bug was fixed, affecting the Higgs boson to signal assignment in case of more than 3 neutral Higgs bosons (Thanks go to Florian Domingo for reporting this bug!). New features and observables are documented in the <a href="HS-1.1_releasenote.pdf" target="_blank">HiggsSignals-1.1 release note</a>.
   </td>
  </tr>
 
  <tr>
   <td valign="top">  09.05.13 </td><td valign="top"><a href="http://www.hepforge.org/archive/higgsbounds/HiggsSignals-1.0.0.tar.gz">  HiggsSignals-1.0.0.tar.gz  </a></td>
   <td valign="top">  First release.
   </td>
  </tr>
 
 </table>
 </p>
 END DETAILED BIT -->
 
 <p>
 The program is documented in:
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/1305.1933" target="_blank">arXiv:1305.1933</a></li>
 </ul>
 <p>
 Please consult the latest version of the <a href="HiggsSignals-1-manual.pdf">HiggsSignals 1.x.x manual</a>. Further information on the program and related issues can be found in
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/1310.4039" target="_blank">arXiv:1310.4039</a> (Short introduction to the program with examples)</li>
 <li><a href="http://arxiv.org/abs/1403.1582" target="_blank">arXiv:1403.1582</a> (Detailed Higgs coupling study; validation of implementation of experimental data, details on statistical HiggsSignals output, including Toy studies.)</li>
 <li><a href="HS-1.1_releasenote.pdf" target="_blank">HiggsSignals-1.1 release note</a></li>
 <li><a href="HS-1.3_releasenote.pdf" target="_blank">HiggsSignals-1.3 release note</a></li>
 <li><a href="CorrSystErr.pdf" target="_blank">Notes on the presentation of correlated systematic uncertainties in Higgs boson rate measurements</a></li>
 </ul>
 <p>
 
 <p>Announcements about HiggsSignals will also be given to the <a href="http://www.hepforge.org/lists/listinfo/higgsbounds-announce">HiggsBounds-announce mailing list</a>. </p>
 <p>If you have any questions, comments, bug reports or feature requests please let us know. Contact <a href="mailto:tim ( at ) th.physik.uni-bonn.de">Tim</a> or <a href="mailto:oscar.stal ( at ) fysik.su.se">Oscar</a>.</p>
 
 <p><h2>Referencing HiggsSignals</h2>
 <p>If you use HiggsSignals, please cite the HiggsSignals as well as HiggsBounds references listed above. Furthermore, please do not forget to include citations to the experimental measurements, which are used as observables in your project.</p>
 </p>
 
 <p>
 <h2>Quick start guide</h2>
 <ol>
  <li>unpack the <code>.tar.gz</code> file </li>
  <li><code>cd</code> to the HiggsSignals directory</li>
  <li>please check/edit <code>configure</code> for the correct link to the HiggsBounds library and compiler settings.</li>
  <li>you can now directly run the bash script <code>./run_tests.bat</code>. (Note: The script uses gnuplot to create results from test runs.) </li>
  <li>We provide various example programs, where many features are demonstrated. Also, they show how to use HiggsSignals together with <a href="http://www.feynhiggs.de" target="_blank">FeynHiggs</a> and HiggsBounds.</li>
 </ol>
 <br>
 
 <a href="http://higgsbounds.hepforge.org/index.html">back to HiggsBounds/HiggsSignals homepage</a>
 
 </BODY>
 </HTML>
Index: trunk/webversion/index.html
===================================================================
--- trunk/webversion/index.html	(revision 505)
+++ trunk/webversion/index.html	(revision 506)
@@ -1,286 +1,287 @@
 <HTML>
 <HEAD>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" >
 <link rel="stylesheet" type="text/css" href="http://higgsbounds.hepforge.org/HBstyle.css">
 <TITLE>HiggsBounds and HiggsSignals</TITLE>
 </HEAD>
 <!--<BODY background="http://higgsbounds.hepforge.org//HiggsBounds/HiggsBounds-logo-watermark.jpg">--> 
 <BODY>
 <table border="0">
 <tr>
 <td>
 <!--<p><H1>Program HiggsBounds</H1></p>-->
 <p><H1>HiggsBounds and HiggsSignals</H1></p>
 <!--<p><H2><FONT color=#ff0000>Warning - Site under construction!</FONT></H2></p>
 --> 
  
 <!-- BEGIN DEBUGGING BIT
 <p><H2>ADMINISTRATORS' PAGE</H2></p>
 
 <p><FONT color=#ff0000>Note</FONT> - if you want the public version of HiggsBounds, see our <a href="http://higgsbounds.hepforge.org/">public webpage</a></p>
 
 END DEBUGGING BIT -->
 <!--<FONT COLOR="7CE800">    (NEW VERSION!)</FONT>--><!-- insert this for new version behind HiggsBounds (below)-->
-<p><h2>HiggsBounds<FONT COLOR="7CE800">    (12-12-2014 NEW VERSION!)</FONT></h2> (<em>P. Bechtle, O. Brein, S. Heinemeyer, O. Stål, T. Stefaniak, G. Weiglein and K. Williams</em>)</p> 
+<!-- <p><h2>HiggsBounds<FONT COLOR="7CE800">    (12-12-2014 NEW VERSION!)</FONT></h2> (<em>P. Bechtle, O. Brein, S. Heinemeyer, O. Stål, T. Stefaniak, G. Weiglein and K. Williams</em>)</p>  -->
+<p><h2>HiggsBounds</h2> (<em>P. Bechtle, O. Brein, S. Heinemeyer, O. Stål, T. Stefaniak, G. Weiglein and K. Williams</em>)</p> 
 <p>
 HiggsBounds takes a selection of Higgs sector predictions for any particular model as input and then uses the experimental topological cross section limits from Higgs searches at LEP, the Tevatron and the LHC to determine if this parameter point has been excluded at 95&#37 C.L..
 </p>
 <p>
 Further information can be found in the following references:
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/0811.4169" target="_blank">arXiv:0811.4169</a> (Comput.Phys.Commun.181:138-167,2010)</li>
 <li><a href="http://arxiv.org/abs/1102.1898">arXiv:1102.1898</a> (Comput.Phys.Commun.182:2605-2631,2011)</li>
 <li><a href="http://arxiv.org/abs/1301.2345">arXiv:1301.2345</a> (PoS CHARGED2012 (2012) 024)</li>
 <li><a href="http://arxiv.org/abs/1311.0055">arXiv:1311.0055</a> (Eur.Phys.J C74 (2014) 2693)</li>
 </ul>
 <p>
 In particular, consult the latest version of the <a href="HiggsBounds-4-manual.pdf">HiggsBounds 4.x.x manual</a>.
 </p>
 <td>
 <img src="http://higgsbounds.hepforge.org/include/HiggsBounds-logo-small.jpg" alt="HiggsBounds logo" align="right" border="0">
 </td>
 </td>
 </tr>
 </table>
 <p>
 The HiggsBounds source files can be obtained from our <a href="downloads.html" target="_blank">download page</a>.
 </p>
 <p>
 You can also quickly run HiggsBounds via our online version (see below).
 </p>
 <p>
 If you have any questions or comments, contact <a href="mailto:tim ( at ) th.physik.uni-bonn.de">Tim</a> or <a href="mailto:oscar.stal ( at ) fysik.su.se">Oscar</a>.
 </p>
 <br>
-<p><h2>HiggsSignals<FONT COLOR="7CE800">    (12-12-2014 NEW VERSION!)</FONT></h2> (<em>P. Bechtle, S. Heinemeyer, O. Stål, T. Stefaniak and G. Weiglein</em>)</p>
+<p><h2>HiggsSignals<FONT COLOR="7CE800">    (28-01-2015 NEW VERSION!)</FONT></h2> (<em>P. Bechtle, S. Heinemeyer, O. Stål, T. Stefaniak and G. Weiglein</em>)</p>
 <p>HiggsSignals performs a statistical test of the Higgs sector predictions of arbitrary models (using the HiggsBounds input routines) with the measurements of Higgs boson signal rates and masses from the Tevatron and the LHC.</p>
 <p>
 The program is documented in:
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/1305.1933" target="_blank">arXiv:1305.1933</a> (Eur.Phys.J C74 (2014) 2711)</li>
 </ul>
 <p>
 The latest version of the user manual can be found here: <a href="HiggsSignals-1-manual.pdf">HiggsSignals 1.x.x manual</a>. Further information on the program and related issues can be found in
 </p>
 <ul>
 <li><a href="http://arxiv.org/abs/1310.4039" target="_blank">arXiv:1310.4039</a> (Short introduction to the program with examples)</li>
 <li><a href="http://arxiv.org/abs/1403.1582" target="_blank">arXiv:1403.1582</a> (Detailed Higgs coupling study; validation of implementation of experimental data, details on statistical HiggsSignals output, including Toy studies.)</li>
 <li><a href="HS-1.1_releasenote.pdf" target="_blank">HiggsSignals-1.1 release note</a></li>
 <li><a href="HS-1.3_releasenote.pdf" target="_blank">HiggsSignals-1.3 release note</a></li>
 <li><a href="CorrSystErr.pdf" target="_blank">Notes on the presentation of correlated systematic uncertainties in Higgs boson rate measurements</a></li>
 </ul>
 <p>
 The HiggsSignals source files can be obtained from our <a href="downloads.html" target="_blank">download page</a>.
 </p>
 <p>
 If you have any questions or comments, contact <a href="mailto:tim ( at ) th.physik.uni-bonn.de">Tim</a> or <a href="mailto:oscar.stal ( at ) fysik.su.se">Oscar</a>.
 </p>
 <br>
 <p>To recieve emails announcing new releases of HiggsBounds and HiggsSignals, we recommend to subscribe to the <a href="http://www.hepforge.org/lists/listinfo/higgsbounds-announce">HiggsBounds-announce mailing list</a>.</p>
 <br><br>
 <p><h2>HiggsBounds Online</h2></p>
 <p>Start with Step 1 if you'd like to test a general model or skip most of the steps by using one of the examples below.</p>
 
 <table  CELLPADDING=20 COLS=2 BORDER=1>
 <tr>
 <td>
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank">
 <b>Step 1 of 4</b>: Give some information about the particle content of your model.<br>
 
 <p>How many neutral Higgs bosons?</p>
 
 <select name="nHneut">
   <option value=0>0</option>
   <option value=1>1</option>
   <option value=2>2</option>
   <option value=3 selected >3</option>
   <option value=4>4</option>
   <option value=5>5</option>
   <option value=6>6</option>
   <option value=7>7</option>  
   <option value=8>8</option>
   <option value=9>9</option>   
 </select>
 
 
 <p>How many singly, positively charged Higgs bosons?</p>
 
 <select name="nHplus">
   <option value=0>0</option>
   <option value=1 selected >1</option>
   <option value=2>2</option>
   <option value=3>3</option>
   <option value=4>4</option>
   <option value=5>5</option>
   <option value=6>6</option>
   <option value=7>7</option>  
   <option value=8>8</option>
   <option value=9>9</option>   
 </select>
 
 
 <!-- BEGIN DEBUGGING BIT
 <p>How many neutralinos?</p>
 
 <select name="nChineut">
   <option value=0>0</option>
   <option value=1>1</option>
   <option value=2>2</option>
   <option value=3 >3</option>
   <option value=4 selected>4</option>
   <option value=5>5</option>
   <option value=6>6</option>
   <option value=7>7</option>  
   <option value=8>8</option>
   <option value=9>9</option>   
 </select>
 
 <p>How many charginos?</p>
 
 <select name="nChiplus">
   <option value=0>0</option>
   <option value=1>1</option>
   <option value=2 selected>2</option>
   <option value=3>3</option>
   <option value=4>4</option>
   <option value=5>5</option>
   <option value=6>6</option>
   <option value=7>7</option>
   <option value=8>8</option>
   <option value=9>9</option>
 </select>
 
 
 END DEBUGGING BIT -->
 
 <INPUT TYPE=hidden NAME="testdata" VALUE="Clear Form"/>
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH"/>
 <INPUT TYPE=hidden NAME="whichinput" VALUE="part"/>
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F"/>
 
 <!-- BEGIN COMMENT OUT IN DEBUGGING BIT -->
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0"/>
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0"/>
 <!-- END COMMENT OUT IN DEBUGGING BIT -->
 
 
 <br>
 
 <br>
 
 
 <center><INPUT TYPE=SUBMIT NAME="action" VALUE="Go"/></center>
 
 </p> 
 
 </td>
 </tr>
 </table>
 
 </FORM>
 
 <p><b>Examples</h4></b>
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank"><p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="1">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="0">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=SUBMIT NAME="testdata" VALUE="SM">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="effC">
 <INPUT TYPE=hidden NAME="action" VALUE="Go">Standard Model Higgs with mass <INPUT NAME="MHiggsSM" value="80" size=5> GeV. 
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 </p></FORM> 
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank"><p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="1">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="0">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=SUBMIT NAME="testdata" VALUE="4thGen">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="effC">
 <INPUT TYPE=hidden NAME="action" VALUE="Go">Simple approximation to 4th Generation Model with Higgs mass <INPUT NAME="MHiggsSM" value="80" size=5> GeV. (effective gluon-gluon-Higgs coupling is multiplied by 3 (good for MH much less than 2MT), photon-photon-Higgs coupling is not relevent).
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 </p></FORM> 
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank"><p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="1">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="0">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=SUBMIT NAME="testdata" VALUE="fermiophobic">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="effC">
 <INPUT TYPE=hidden NAME="action" VALUE="Go"> Fermiophobic Higgs with mass 80 GeV. (effective Z-photon-Higgs coupling is not relevent).
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 </p></FORM>
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank"><p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="3">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="1">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=SUBMIT NAME="testdata" VALUE="CPX">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="part">
 <INPUT TYPE=hidden NAME="action" VALUE="Go"> CP violating MSSM example (CPX-like) at relatively small <i>M<sub>h<sub>1</sub></sub></i>(TB=8, charged Higgs mass 125 GeV, other parameters as <a href='http://arxiv.org/abs/1103.1335'>arXiv:1103.1335</a> p.5)
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 </p></FORM>
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank"><p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="3">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="1">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=SUBMIT NAME="testdata" VALUE="Mhmax plus">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="part">
 <INPUT TYPE=hidden NAME="action" VALUE="Go"> Mhmax values with MUE= 200 GeV, MA0= 200 GeV, TB= 20, MT= 173.1 GeV 
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 </p></FORM>
 </p>
 <br>
 
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HiggsBounds_input.cgi" target="_blank">
 <p>
 Alternatively, enter all text from FeynHiggs Results webpage, generated using the <a href="http://www.feynhiggs.de" target="_blank">FeynHiggs User Control Center</a> (<a href="http://higgsbounds.hepforge.org/extra/sample_fhucc_mhmax.txt" target="_blank"><!--real MSSM -->example</a><!--, <a href="http://higgsbounds.hepforge.org/extra/sample_fhucc_cpx.txt" target="_blank">complex MSSM example</a>-->). Assumes that any Higgs coupling or Higgs branching ratio which is not given explicitly is zero (you can edit this on the next page if you wish). (DOES NOT WORK AT THE MOMENT!)
 </p>
 <INPUT TYPE=hidden NAME="nHneut" VALUE="3">
 <INPUT TYPE=hidden NAME="nHplus" VALUE="1">
 <INPUT TYPE=hidden NAME="nChineut" VALUE="0">
 <INPUT TYPE=hidden NAME="nChiplus" VALUE="0">
 <INPUT TYPE=hidden NAME="whichanalyses" VALUE="LandH">
 <INPUT TYPE=hidden NAME="whichinput" VALUE="part">
 <INPUT TYPE=hidden NAME="action" VALUE="Go">
 <INPUT TYPE=hidden NAME="debugmode" VALUE="F">
 <textarea name="textfromFH" rows="10" cols="110"
 
 ></textarea>
 <br>
 <INPUT TYPE=submit NAME="testdata" VALUE="Convert to HB input">
 </FORM>
 <br>
 <p>
 You can also access HiggsBounds results for mSUGRA and MSSM-7+ scenarios (and many supersymmetric dark matter calculations) via <A HREF="http://www.physto.se/~edsjo/darksusy/" target="_blank">DarkSUSY</a> online.<!-- <A HREF="http://www.physto.se/~edsjo/darksusy/" target="_blank">
 <IMG SRC="http://www.physto.se/~edsjo/darksusy/logos/DarkSUSY2-100.jpg">
 </A>-->
 </p>
 <br>
 <!--<hr>-->
 <p>
 <FORM METHOD=POST ACTION="http://higgsbounds.hepforge.org/cgi-bin/HB_BRSM.cgi" target="_blank">
 Internally, HiggsBounds uses some SM results (see <a href="http://arxiv.org/abs/0811.4169" target="_blank">table 12</a> for references). <br>
 To access some of these quantities directly, enter a Higgs mass:
 <INPUT NAME="MHiggsSM" >
 <INPUT TYPE=SUBMIT NAME="action" VALUE="Get SM quantities">
 </FORM>
 </p>
 
 
 </BODY>
 </HTML>
Index: trunk/HiggsBounds_KW/minipaper.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/HiggsBounds_KW/HiggsBounds_subroutines.F90
===================================================================
--- trunk/HiggsBounds_KW/HiggsBounds_subroutines.F90	(revision 505)
+++ trunk/HiggsBounds_KW/HiggsBounds_subroutines.F90	(revision 506)
@@ -1,1785 +1,1785 @@
 ! This file is part of HiggsBounds
 !  -KW
 !************************************************************      
 subroutine initialize_HiggsBounds(nHiggsneut,nHiggsplus,whichanalyses_in)
 ! This the first Higgsbounds subroutine that should be called
 ! by the user.
 ! It calls subroutines to read in the tables of Standard Model data,
 ! read in the tables of LEP, Tevatron and LHC data,
 ! set up lists of processes which should be checked against 
 ! the experimental results, allocate arrays etc
 ! Arguments (input):
 !   * nHiggs= number of neutral Higgs in the model 
 !     (see subroutine check_nH_nHplus in input.f90 for more details)
 !   * nHiggsplus= number of singly,positively charged Higgs in the model 
 !     (see subroutine check_nH_nHplus in input.f90 for more details)
 !   * whichanalyses_in= which combination of experimental results to use
 !     (see subroutine check_whichanalyses in input.f90 for more details)
 !************************************************************
  use usefulbits, only : np,Hneut,Hplus,Chineut,Chiplus,debug,inputmethod,  &
   &   inputsub,theo,whichanalyses,HiggsBounds_info,just_after_run,&
   &   file_id_debug1,file_id_debug2,allocate_if_stats_required,run_HB_classic
  use input, only : setup_input,check_number_of_particles,check_whichanalyses
  use S95tables, only : setup_S95tables,S95_t2
  use likelihoods, only : setup_likelihoods
  use theory_BRfunctions, only : setup_BRSM
  use channels, only : setup_channels
  use output, only : setup_output
 #ifdef enableCHISQ
  use S95tables_type3, only : clsb_t3,fillt3needs_M2_gt_2M1
 #endif
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
 !#define FORFITTINO
 
  implicit none
  !--------------------------------------input
  integer,intent(in) :: nHiggsneut
 ! integer,intent(in),optional :: nHiggsplus
 ! character(LEN=5),intent(in),optional :: whichanalyses_in
  integer,intent(in) :: nHiggsplus
  character(LEN=5),intent(in) :: whichanalyses_in
  !-----------------------------------internal
  integer :: i
  logical :: messages 
  !-------------------------------------------
 
 ! if((.not.present(nHiggsplus)).or.(.not.present(whichanalyses_in)))then 
    !Actually, this doesn't work as I wanted it to
    !because if initialize_HiggsBounds is called in the old way, the program
    !usually just crashes..... but leaving it in for now, in case
    !some compilers accept it
 !   call attempting_to_use_an_old_HB_version('init')
 ! endif
 
 #ifdef FORFITTINO
  write(*,*)'The arguments passed to initialize_HiggsBounds are:'
  write(*,*)'nHiggsneut=',nHiggsneut
  write(*,*)'nHiggsplus=',nHiggsplus
  write(*,*)'whichanalyses_in=','~'//trim(adjustl(whichanalyses_in))//'~'
 #endif
 
 #ifdef DEBUGGING
   debug=.True.
 #else
   debug=.False.
 #endif
 
  messages=debug.or.(inputmethod=='datfile')
 
 ! inputmethod='subrout' !('datfile' or 'website' are also possible, but not here)
 
  np(Hneut)=nHiggsneut
  np(Hplus)=nHiggsplus
  
  np(Chineut)=0! do not change this without contacting us first!
  np(Chiplus)=0! do not change this without contacting us first!
 
  whichanalyses=whichanalyses_in
  
  if(inputmethod=='subrout') then
   if(allocated(theo))then
    stop 'subroutine HiggsBounds_initialize has already been called once'
   endif
 
   if(messages)write(*,*)'doing other preliminary tasks...'      ; call flush(6)
   call setup_input
 
   allocate(inputsub( 4 )) !(1)np(Hneut)>0 (2)np(Hplus)>0 (3)np(Chineut)>0 (4)np(Chineut)>0 and np(Chiplus)>0
    !                                                                           |        np
    !                                                                           |Hneu Hcha Chineut Chiplus
    !                                                                           | ==0  ==0  ==0     ==0 
   inputsub(1)%desc='HiggsBounds_neutral_input_*'
   inputsub(1)%req=req(   0,   1,   1,   1)
   inputsub(2)%desc='HiggsBounds_charged_input'
   inputsub(2)%req=req(   1,   0,   1,   1)
   inputsub(3)%desc='SUSYBounds_neutralinoonly_input'
   inputsub(3)%req=req(   1,   1,   0,   1)
   inputsub(4)%desc='SUSYBounds_neutralinochargino_input'
   inputsub(4)%req=req(   1,   1,   0,   0)
   do i=1,ubound(inputsub,dim=1)
    inputsub(i)%stat=0
   enddo
  endif 
 
 #ifndef WEBVERSION
  if(inputmethod.ne.'datfile') call HiggsBounds_info
  if (run_HB_classic.EQV..True.) then
   PRINT *, "run_HB_classic=True - HiggsBounds is running in classic mode"
  endif
   
 #endif
 
  if(messages)write(*,*)'reading in Standard Model tables...'   ; call flush(6) 
  call setup_BRSM 
              
  if(messages)write(*,*)'reading in S95tables...'               ; call flush(6)
  call setup_S95tables                                    
 
  if(messages)write(*,*)'reading in likelihoods...'   ; call flush(6)
  call setup_likelihoods
 !if(debug)write(*,*)'doing other preliminary tasks...'      ; call flush(6)
 !call setup_input
 
  if(messages)then
   open(file_id_debug2,file='debug_predratio.txt')
   open(file_id_debug1,file='debug_channels.txt')
  endif
 
  if(messages)write(*,*)'sorting out processes to be checked...'; call flush(6)
  call setup_channels      
       
  if(messages)write(*,*)'preparing output arrays...'            ; call flush(6)
  call setup_output
 
 #ifdef enableCHISQ
  if(allocated(allocate_if_stats_required))then
    call fillt3needs_M2_gt_2M1(clsb_t3,S95_t2)
  endif 
 #endif
 
  just_after_run=.False.
   
  contains 
    !         |        np
    !         |Hneu Hcha Chineut Chiplus
    !         | ==0  ==0  ==0     ==0 
  function req(Hneu,Hcha, Chneu,  Chcha)
   integer, intent(in) ::Hneu,Hcha, Chneu,  Chcha
   integer :: req
   
   req=1
   if(np(Hneut)==0)  req= Hneu  * req
   if(np(Hplus)==0)  req= Hcha  * req
   if(np(Chineut)==0)req= Chneu * req
   if(np(Chiplus)==0)req= Chcha * req
 
  end function req 
 end subroutine initialize_HiggsBounds
 !************************************************************      
 
 
 !************************************************************      
 ! Version of initialize_HiggsBounds which takes an integer as
 ! the third argument. More useful for library linking to 
 ! non-Fortran codes.
 subroutine initialize_HiggsBounds_int(nHn,nHp,flag)
  
        implicit none
 
        integer nHn,nHp,flag
 
     interface
         subroutine initialize_HiggsBounds(nHiggsneut, nHiggsplus, whichanalyses_in)
      integer,intent(in) :: nHiggsneut
      integer,intent(in),optional :: nHiggsplus
      character(LEN=5),intent(in),optional :: whichanalyses_in
         end subroutine initialize_HiggsBounds
     end interface 
 
       IF (flag.EQ.1) then
         call initialize_HiggsBounds(nHn,nHp, "onlyL")
       elseif (flag.EQ.2) then
         call initialize_HiggsBounds(nHn,nHp, "onlyH")
       elseif (flag.EQ.3) then
         call initialize_HiggsBounds(nHn,nHp, "LandH")
       elseif (flag.EQ.4) then
         call initialize_HiggsBounds(nHn,nHp, "onlyP")
       else
         stop "Illegal value for flag in call to initialize_HB"
       endif
       
 
 end subroutine
 !************************************************************      
 
 
 
 !************************************************************      
 subroutine attempting_to_use_an_old_HB_version(subroutineid)
  use usefulbits, only : vers
  character(len=4),intent(in) :: subroutineid
 
  select case(subroutineid)
  case('init')
   write(*,*)'The subroutine initialize_HiggsBounds has been called with the'
   write(*,*)'wrong number of arguments. It should be called as:'
   write(*,*)'initialize_HiggsBounds(nHiggsneut,nHiggsplus,whichanalyses)'
   write(*,*)
   write(*,*)'Note that in early versions of HiggsBounds (HB 1.*.*)'
   write(*,*)'this subroutine was called as:'
   write(*,*)'initialize_HiggsBounds(nHiggsneut,whichanalyses)'
   write(*,*)
  case('effC','part','hadr')
   write(*,*)'The subroutine run_HiggsBounds_'//subroutineid//' has been discontinued in this'
   write(*,*)'version of HiggsBounds.'
  case default
   stop'wrong input to subroutine attempting_to_use_an_old_HB_version'
  end select
 
  write(*,*)'If you have code written for use with HB 1.*.*, you have two choices:'
  write(*,*)
  write(*,*)' (1) You can edit your code, such that it works with this' 
  write(*,*)'     version of HiggsBounds (HB'//trim(adjustl(vers))//').'
  write(*,*)'     This has the advantage that you can test your model against many, many'
  write(*,*)'     more Higgs search limits , including charged Higgs search limits.'
  write(*,*)'     See the updated manual for more information.'
  write(*,*)
  write(*,*)' (2) You can download the most recent HB 1.*.* from the HiggsBounds'
  write(*,*)'     website. This contains the LEP Higgs search limits which are'
  write(*,*)'     generally the most useful when constraining new physics models.'
  write(*,*)'     We will continue to support this code.'
 
  stop'Incorrect call to a HiggsBounds subroutine.'
 
 end subroutine attempting_to_use_an_old_HB_version
 !************************************************************      
 subroutine HiggsBounds_input_SLHA(infile)
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! Arguments (input): SLHA filename
 !************************************************************
  use usefulbits, only : whichinput,inputsub,infile1,theo,g2,just_after_run, &
    & np,Hneut,Hplus     
  use extra_bits_for_SLHA
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
 
  !----------------------------------------input
  character(len=100),intent(in) :: infile
  !--------------------------------------internal
  integer :: n
  !----------------------------------------------
  
  whichinput='SLHA'
 
  if(np(Hneut).gt.0)inputsub(Hneut)%stat=inputsub(Hneut)%stat+1
  if(np(Hplus).gt.0)inputsub(Hplus)%stat=inputsub(Hplus)%stat+1
  ! note: can't be used for charginos or neutralinos yet 
 
  n=1  
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
  
  infile1=infile   
 
  call getSLHAdata(theo(n),g2(n),infile1)    
 
  just_after_run=.False.
 
 end subroutine HiggsBounds_input_SLHA
 !************************************************************     
 subroutine HiggsBounds_neutral_input_effC(Mh,GammaTotal_hj,        &  
      &          g2hjss_s,g2hjss_p,g2hjcc_s,g2hjcc_p,               &
      &          g2hjbb_s,g2hjbb_p,g2hjtoptop_s,g2hjtoptop_p,       &
      &          g2hjmumu_s,g2hjmumu_p,                             &
      &          g2hjtautau_s,g2hjtautau_p,                         &
      &          g2hjWW,g2hjZZ,g2hjZga,                             &
      &          g2hjgaga,g2hjgg,g2hjggZ,g2hjhiZ_nHbynH,            &
      &          BR_hjinvisible,BR_hjhihi_nHbynH                    )
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! Arguments (input): theoretical predictions (see manual for definitions)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,g2,whichinput,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
 
  !----------------------------------------input
  double precision,intent(in) :: Mh( np(Hneut) ),GammaTotal_hj( np(Hneut) ),                                 &  
      &          g2hjss_s( np(Hneut) ),g2hjss_p( np(Hneut) ),g2hjcc_s( np(Hneut) ),g2hjcc_p( np(Hneut) ),        &
      &          g2hjbb_s( np(Hneut) ),g2hjbb_p( np(Hneut) ),g2hjtoptop_s( np(Hneut) ),g2hjtoptop_p( np(Hneut) ),&
      &          g2hjmumu_s( np(Hneut) ),g2hjmumu_p( np(Hneut) ),                                        &
      &          g2hjtautau_s( np(Hneut) ),g2hjtautau_p( np(Hneut) ),                                        &
      &          g2hjWW( np(Hneut) ),g2hjZZ( np(Hneut) ),g2hjZga( np(Hneut) ),                                 &
      &          g2hjgaga( np(Hneut) ),g2hjgg( np(Hneut) ),g2hjggZ( np(Hneut) ),g2hjhiZ_nHbynH(np(Hneut),np(Hneut)),&
      &          BR_hjinvisible( np(Hneut) ),BR_hjhihi_nHbynH(np(Hneut),np(Hneut)) 
  !--------------------------------------internal
  integer :: n
  integer :: subtype
  !----------------------------------------------
  
  whichinput='effC'
  subtype=1
  n=1  
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if(np(Hneut).eq.0)then
   write(*,*)'subroutine HiggsBounds_neutral_input_effC should'
   write(*,*)'only be called if np(Hneut)>0'
   stop 'error in subroutine HiggsBounds_neutral_input_effC'
  endif
 
  theo(n)%particle(Hneut)%M       = Mh
  theo(n)%particle(Hneut)%Mc      = Mh    
  theo(n)%particle(Hneut)%GammaTot= GammaTotal_hj
 
  g2(n)%hjss_s              = g2hjss_s
  g2(n)%hjss_p              = g2hjss_p
  g2(n)%hjcc_s              = g2hjcc_s
  g2(n)%hjcc_p              = g2hjcc_p
  g2(n)%hjbb_s              = g2hjbb_s
  g2(n)%hjbb_p              = g2hjbb_p
  g2(n)%hjtoptop_s              = g2hjtoptop_s
  g2(n)%hjtoptop_p              = g2hjtoptop_p
  g2(n)%hjmumu_s                = g2hjmumu_s
  g2(n)%hjmumu_p                = g2hjmumu_p
  g2(n)%hjtautau_s              = g2hjtautau_s
  g2(n)%hjtautau_p              = g2hjtautau_p
         
  g2(n)%hjWW              = g2hjWW
  g2(n)%hjZZ              = g2hjZZ  
  g2(n)%hjZga             = g2hjZga      
  g2(n)%hjgaga            = g2hjgaga
  g2(n)%hjgg              = g2hjgg
  g2(n)%hjggZ             = g2hjggZ
 
  g2(n)%hjhiZ = g2hjhiZ_nHbynH
 
  theo(n)%BR_hjinvisible  = BR_hjinvisible 
  theo(n)%BR_hjhihi       = BR_hjhihi_nHbynH  
 
  just_after_run=.False. 
 
 end subroutine HiggsBounds_neutral_input_effC
 !************************************************************      
 subroutine HiggsBounds_neutral_input_part(Mh,GammaTotal_hj,CP_value,       &
      &          CS_lep_hjZ_ratio,                            &
      &          CS_lep_bbhj_ratio,CS_lep_tautauhj_ratio,     &
      &          CS_lep_hjhi_ratio_nHbynH,                    &
      &          CS_gg_hj_ratio,CS_bb_hj_ratio,       &
      &          CS_bg_hjb_ratio,                         &
      &          CS_ud_hjWp_ratio,CS_cs_hjWp_ratio,   & 
      &          CS_ud_hjWm_ratio,CS_cs_hjWm_ratio,   & 
      &          CS_gg_hjZ_ratio,     &
      &          CS_dd_hjZ_ratio,CS_uu_hjZ_ratio,     &
      &          CS_ss_hjZ_ratio,CS_cc_hjZ_ratio,     &
      &          CS_bb_hjZ_ratio,                         &
      &          CS_tev_vbf_ratio,CS_tev_tthj_ratio,    &
      &          CS_lhc7_vbf_ratio,CS_lhc7_tthj_ratio,    &
      &          CS_lhc8_vbf_ratio,CS_lhc8_tthj_ratio,    &
      &          BR_hjss,BR_hjcc,                             &
      &          BR_hjbb,BR_hjmumu,BR_hjtautau,               &
      &          BR_hjWW,BR_hjZZ,BR_hjZga, BR_hjgaga,BR_hjgg, & 
      &          BR_hjinvisible,BR_hjhihi_nHbynH              )
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! (see manual for full description)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,partR,whichinput,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
  !----------------------------------------input
  double precision,intent(in) :: Mh( np(Hneut) ),GammaTotal_hj( np(Hneut) )
  integer,intent(in) ::CP_value( np(Hneut) )
  double precision,intent(in) :: CS_lep_hjZ_ratio( np(Hneut) ),                         &
      &          CS_lep_bbhj_ratio( np(Hneut) ),CS_lep_tautauhj_ratio( np(Hneut) ),     &
      &          CS_lep_hjhi_ratio_nHbynH(np(Hneut),np(Hneut)),                         &
      &          CS_gg_hj_ratio( np(Hneut) ),CS_bb_hj_ratio( np(Hneut) ),       &
      &          CS_bg_hjb_ratio( np(Hneut) ),                                      &
      &          CS_ud_hjWp_ratio( np(Hneut) ),CS_cs_hjWp_ratio( np(Hneut) ),   & 
      &          CS_ud_hjWm_ratio( np(Hneut) ),CS_cs_hjWm_ratio( np(Hneut) ),   & 
      &          CS_gg_hjZ_ratio( np(Hneut) ),    &
      &          CS_dd_hjZ_ratio( np(Hneut) ),CS_uu_hjZ_ratio( np(Hneut) ),     &
      &          CS_ss_hjZ_ratio( np(Hneut) ),CS_cc_hjZ_ratio( np(Hneut) ),     &
      &          CS_bb_hjZ_ratio( np(Hneut) ),                                      &
      &          CS_tev_vbf_ratio( np(Hneut) ),CS_tev_tthj_ratio( np(Hneut) ),    &
      &          CS_lhc7_vbf_ratio( np(Hneut) ),CS_lhc7_tthj_ratio( np(Hneut) ),    &
      &          CS_lhc8_vbf_ratio( np(Hneut) ),CS_lhc8_tthj_ratio( np(Hneut) ),    &
      &          BR_hjss( np(Hneut) ),BR_hjcc( np(Hneut) ),                             &
      &          BR_hjbb( np(Hneut) ),BR_hjmumu( np(Hneut) ),BR_hjtautau( np(Hneut) ),  &
      &          BR_hjWW( np(Hneut) ),BR_hjZZ( np(Hneut) ),BR_hjZga( np(Hneut) ),       &
      &          BR_hjgaga( np(Hneut) ),BR_hjgg( np(Hneut) ),                           & 
      &          BR_hjinvisible( np(Hneut) ),BR_hjhihi_nHbynH(np(Hneut),np(Hneut)) 
  !---------------------------------------internal
  integer :: n
  integer :: subtype
  !-----------------------------------------------
 
  whichinput='part'
  subtype=1
  n=1 
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
       
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if(np(Hneut).eq.0)then
   write(*,*)'subroutine HiggsBounds_neutral_input_part should'
   write(*,*)'only be called if np(Hneut)>0'
   stop 'error in subroutine HiggsBounds_neutral_input_part'
  endif
 
  theo(n)%particle(Hneut)%M = Mh 
  theo(n)%particle(Hneut)%Mc      = Mh        
  theo(n)%particle(Hneut)%GammaTot= GammaTotal_hj
  theo(n)%CP_value          = CP_value  
  theo(n)%lep%XS_hjZ_ratio       = CS_lep_hjZ_ratio
  theo(n)%lep%XS_bbhj_ratio      = CS_lep_bbhj_ratio
  theo(n)%lep%XS_tautauhj_ratio  = CS_lep_tautauhj_ratio
  theo(n)%lep%XS_hjhi_ratio      = CS_lep_hjhi_ratio_nHbynH 
  partR(n)%gg_hj             = CS_gg_hj_ratio 
  partR(n)%qq_hj(5,:)        = CS_bb_hj_ratio
  partR(n)%bg_hjb            = CS_bg_hjb_ratio                    
  partR(n)%qq_hjWp(1,:)      = CS_ud_hjWp_ratio
  partR(n)%qq_hjWp(2,:)      = CS_cs_hjWp_ratio         
  partR(n)%qq_hjWm(1,:)      = CS_ud_hjWm_ratio
  partR(n)%qq_hjWm(2,:)      = CS_cs_hjWm_ratio  
  partR(n)%gg_hjZ(:)         = CS_gg_hjZ_ratio      
  partR(n)%qq_hjZ(1,:)       = CS_dd_hjZ_ratio
  partR(n)%qq_hjZ(2,:)       = CS_uu_hjZ_ratio           
  partR(n)%qq_hjZ(3,:)       = CS_ss_hjZ_ratio
  partR(n)%qq_hjZ(4,:)       = CS_cc_hjZ_ratio             
  partR(n)%qq_hjZ(5,:)       = CS_bb_hjZ_ratio                         
  theo(n)%tev%XS_vbf_ratio  = CS_tev_vbf_ratio   
  theo(n)%tev%XS_tthj_ratio = CS_tev_tthj_ratio  
  theo(n)%lhc7%XS_vbf_ratio = CS_lhc7_vbf_ratio   
  theo(n)%lhc7%XS_tthj_ratio= CS_lhc7_tthj_ratio
  theo(n)%lhc8%XS_vbf_ratio = CS_lhc8_vbf_ratio   
  theo(n)%lhc8%XS_tthj_ratio= CS_lhc8_tthj_ratio
  theo(n)%BR_hjss           = BR_hjss  
  theo(n)%BR_hjcc           = BR_hjcc                
  theo(n)%BR_hjbb           = BR_hjbb
  theo(n)%BR_hjmumu         = BR_hjmumu
  theo(n)%BR_hjtautau       = BR_hjtautau              
  theo(n)%BR_hjWW           = BR_hjWW
  theo(n)%BR_hjZZ           = BR_hjZZ
  theo(n)%BR_hjZga          = BR_hjZga  
  theo(n)%BR_hjgaga         = BR_hjgaga
  theo(n)%BR_hjgg           = BR_hjgg  
  theo(n)%BR_hjinvisible    = BR_hjinvisible             
  theo(n)%BR_hjhihi         = BR_hjhihi_nHbynH  
 
  just_after_run=.False. 
 
 end subroutine HiggsBounds_neutral_input_part
 !************************************************************      
 subroutine HiggsBounds_neutral_input_hadr(Mh,GammaTotal_hj,CP_value,      &
      &          CS_lep_hjZ_ratio,                           &
      &          CS_lep_bbhj_ratio,CS_lep_tautauhj_ratio,    &   
      &          CS_lep_hjhi_ratio_nHbynH,                   &
      &          CS_tev_hj_ratio ,CS_tev_hjb_ratio,    &
      &          CS_tev_hjW_ratio,CS_tev_hjZ_ratio,    &
      &          CS_tev_vbf_ratio,CS_tev_tthj_ratio,   &
      &          CS_lhc7_hj_ratio ,CS_lhc7_hjb_ratio,    &
      &          CS_lhc7_hjW_ratio,CS_lhc7_hjZ_ratio,    &
      &          CS_lhc7_vbf_ratio,CS_lhc7_tthj_ratio,   &
      &          CS_lhc8_hj_ratio ,CS_lhc8_hjb_ratio,    &
      &          CS_lhc8_hjW_ratio,CS_lhc8_hjZ_ratio,    &
      &          CS_lhc8_vbf_ratio,CS_lhc8_tthj_ratio,   &
      &          BR_hjss,BR_hjcc,                            &
      &          BR_hjbb,                                    &
      &          BR_hjmumu,                                  &
      &          BR_hjtautau,                                &
      &          BR_hjWW,BR_hjZZ,BR_hjZga,BR_hjgaga,         &
      &          BR_hjgg, BR_hjinvisible,                    &
      &          BR_hjhihi_nHbynH                            )
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! (see manual for full description)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,whichinput,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
  !----------------------------------------input
  double precision,intent(in) :: Mh( np(Hneut) ),GammaTotal_hj( np(Hneut) )
  integer,intent(in) :: CP_value( np(Hneut) )
  double precision,intent(in) :: CS_lep_hjZ_ratio( np(Hneut) ),                        &
      &          CS_lep_bbhj_ratio( np(Hneut) ),CS_lep_tautauhj_ratio( np(Hneut) ),    &   
      &          CS_lep_hjhi_ratio_nHbynH(np(Hneut),np(Hneut)),                        &
      &          CS_tev_hj_ratio( np(Hneut)  ) ,CS_tev_hjb_ratio( np(Hneut) ),    &
      &          CS_tev_hjW_ratio( np(Hneut) ) ,CS_tev_hjZ_ratio( np(Hneut) ),    &
      &          CS_tev_vbf_ratio( np(Hneut) ) ,CS_tev_tthj_ratio( np(Hneut)),    &
      &          CS_lhc7_hj_ratio( np(Hneut)  ),CS_lhc7_hjb_ratio( np(Hneut) ),    &
      &          CS_lhc7_hjW_ratio( np(Hneut) ),CS_lhc7_hjZ_ratio( np(Hneut) ),    &
      &          CS_lhc7_vbf_ratio( np(Hneut) ),CS_lhc7_tthj_ratio( np(Hneut)),    &
      &          CS_lhc8_hj_ratio( np(Hneut)  ),CS_lhc8_hjb_ratio( np(Hneut) ),    &
      &          CS_lhc8_hjW_ratio( np(Hneut) ),CS_lhc8_hjZ_ratio( np(Hneut) ),    &
      &          CS_lhc8_vbf_ratio( np(Hneut) ),CS_lhc8_tthj_ratio( np(Hneut)),    &
      &          BR_hjss( np(Hneut) ),BR_hjcc( np(Hneut) ),                            &
      &          BR_hjbb( np(Hneut) ),                                                 &
      &          BR_hjmumu( np(Hneut) ),BR_hjtautau( np(Hneut) ),                      &
      &          BR_hjWW( np(Hneut) ),BR_hjZZ( np(Hneut) ),                            &
      &          BR_hjZga( np(Hneut) ),BR_hjgaga( np(Hneut) ),                         &
      &          BR_hjgg( np(Hneut) ), BR_hjinvisible( np(Hneut) ),                    &
      &          BR_hjhihi_nHbynH(np(Hneut),np(Hneut))
  !-------------------------------------internal
  integer :: n
  integer :: subtype
  !---------------------------------------------
    
  whichinput='hadr'
  subtype=1
  n=1 
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if(np(Hneut).eq.0)then
   write(*,*)'subroutine HiggsBounds_neutral_input_hadr should'
   write(*,*)'only be called if np(Hneut)>0'
   stop 'error in subroutine HiggsBounds_neutral_input_hadr'
  endif
 
 ! write(*,*) "DEBUG HB: before hadronic input. Mass is ",theo(n)%particle(Hneut)%M 
 
 
  theo(n)%particle(Hneut)%M       = Mh
  theo(n)%particle(Hneut)%Mc      = Mh  
  theo(n)%particle(Hneut)%GammaTot= GammaTotal_hj
  theo(n)%CP_value                = CP_value             
  theo(n)%lep%XS_hjZ_ratio        = CS_lep_hjZ_ratio
  theo(n)%lep%XS_bbhj_ratio       = CS_lep_bbhj_ratio
  theo(n)%lep%XS_tautauhj_ratio   = CS_lep_tautauhj_ratio
  theo(n)%lep%XS_hjhi_ratio       = CS_lep_hjhi_ratio_nHbynH 
  theo(n)%tev%XS_hj_ratio         = CS_tev_hj_ratio
  theo(n)%tev%XS_hjb_ratio        = CS_tev_hjb_ratio   
  theo(n)%tev%XS_hjW_ratio        = CS_tev_hjW_ratio
  theo(n)%tev%XS_hjZ_ratio        = CS_tev_hjZ_ratio    
  theo(n)%tev%XS_vbf_ratio        = CS_tev_vbf_ratio      
  theo(n)%tev%XS_tthj_ratio       = CS_tev_tthj_ratio
  theo(n)%lhc7%XS_hj_ratio        = CS_lhc7_hj_ratio
  theo(n)%lhc7%XS_hjb_ratio       = CS_lhc7_hjb_ratio   
  theo(n)%lhc7%XS_hjW_ratio       = CS_lhc7_hjW_ratio
  theo(n)%lhc7%XS_hjZ_ratio       = CS_lhc7_hjZ_ratio    
  theo(n)%lhc7%XS_vbf_ratio       = CS_lhc7_vbf_ratio      
  theo(n)%lhc7%XS_tthj_ratio      = CS_lhc7_tthj_ratio
  theo(n)%lhc8%XS_hj_ratio        = CS_lhc8_hj_ratio
  theo(n)%lhc8%XS_hjb_ratio       = CS_lhc8_hjb_ratio   
  theo(n)%lhc8%XS_hjW_ratio       = CS_lhc8_hjW_ratio
  theo(n)%lhc8%XS_hjZ_ratio       = CS_lhc8_hjZ_ratio    
  theo(n)%lhc8%XS_vbf_ratio       = CS_lhc8_vbf_ratio      
  theo(n)%lhc8%XS_tthj_ratio      = CS_lhc8_tthj_ratio
  theo(n)%BR_hjss           = BR_hjss
  theo(n)%BR_hjcc           = BR_hjcc 
  theo(n)%BR_hjbb           = BR_hjbb
  theo(n)%BR_hjmumu         = BR_hjmumu
  theo(n)%BR_hjtautau       = BR_hjtautau                 
  theo(n)%BR_hjWW           = BR_hjWW
  theo(n)%BR_hjZZ           = BR_hjZZ
  theo(n)%BR_hjZga          = BR_hjZga 
  theo(n)%BR_hjgaga         = BR_hjgaga
  theo(n)%BR_hjgg           = BR_hjgg
  theo(n)%BR_hjinvisible    = BR_hjinvisible                  
  theo(n)%BR_hjhihi         = BR_hjhihi_nHbynH  
 
  just_after_run=.False. 
   
 ! write(*,*) "DEBUG HB: filled hadronic input. Mass is ",theo(n)%particle(Hneut)%M 
     
 end subroutine HiggsBounds_neutral_input_hadr
 !************************************************************      
 subroutine HiggsBounds_charged_input(Mhplus,GammaTotal_Hpj, &
      &          CS_lep_HpjHmj_ratio,                        &
      &          BR_tWpb,BR_tHpjb,                           &
      &          BR_Hpjcs,BR_Hpjcb,BR_Hpjtaunu)
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! Arguments (input): theoretical predictions (see manual for definitions)
 !************************************************************
  use usefulbits, only : theo,np,Hplus,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
 
  !----------------------------------------input
  double precision,intent(in) :: Mhplus( np(Hplus) ),GammaTotal_Hpj( np(Hplus) ), &
      &          CS_lep_HpjHmj_ratio( np(Hplus) ),                              &
      &          BR_tWpb,BR_tHpjb( np(Hplus) ),                                 &
      &          BR_Hpjcs( np(Hplus) ),BR_Hpjcb( np(Hplus) ),BR_Hpjtaunu( np(Hplus) ) 
  !--------------------------------------internal
  integer :: n
  integer :: subtype
  !----------------------------------------------
  
  n=1  
  subtype=2
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if(np(Hplus).eq.0)then
   write(*,*)'subroutine HiggsBounds_charged_input should'
   write(*,*)'only be called if np(Hplus)>0'
   stop 'error in subroutine HiggsBounds_charged_input'
  endif
 
  theo(n)%particle(Hplus)%M       = Mhplus 
  theo(n)%particle(Hplus)%Mc      = Mhplus 
  theo(n)%particle(Hplus)%GammaTot= GammaTotal_Hpj
 
  theo(n)%lep%XS_HpjHmj_ratio = CS_lep_HpjHmj_ratio
 
  theo(n)%BR_tWpb  = BR_tWpb
  theo(n)%BR_tHpjb = BR_tHpjb 
 
  theo(n)%BR_Hpjcs     = BR_Hpjcs
  theo(n)%BR_Hpjcb     = BR_Hpjcb
  theo(n)%BR_Hpjtaunu  = BR_Hpjtaunu
   
 
  just_after_run=.False. 
 
 end subroutine HiggsBounds_charged_input
 !************************************************************      
 subroutine HiggsBounds_set_mass_uncertainties(dMhneut, dMhch)
 ! Assigns the mass uncertainties in the subroutine version.
 !
    use usefulbits, only : theo,np,Hneut,Hplus
    
   implicit none
   
   double precision, intent(in) :: dMhneut(np(Hneut))
   double precision, intent(in) :: dMhch(np(Hplus))
     
   theo(1)%particle(Hneut)%dMh = dMhneut
   theo(1)%particle(Hplus)%dMh = dMhch 
   
 end subroutine HiggsBounds_set_mass_uncertainties
 !************************************************************      
 subroutine get_mass_variation_param(n)
 
   use usefulbits, only : theo,np,Hneut,Hplus,diffMhneut,diffMhch,ndmh,dmhsteps,small_mh
   implicit none
 
   integer, intent(in) :: n
 
   double precision :: dMhneut(np(Hneut))
   double precision :: dMhch(np(Hplus))      
   integer :: km(np(Hneut)+np(Hplus))
   integer :: dm(dmhsteps**(np(Hneut)+np(Hplus)),np(Hneut)+np(Hplus))
 
   integer i,j,k,kp
 
   if(np(Hneut).gt.0) dMhneut = theo(n)%particle(Hneut)%dMh
   if(np(Hplus).gt.0) dMhch = theo(n)%particle(Hplus)%dMh
 
   if (modulo(dmhsteps,2).NE.1) then
      stop 'Wrong number of steps in set_mass_uncertainty: must be odd (>=3)'
   endif  
 
   ndmh = 0
   do i=1,np(Hneut)
    
    IF (dMhneut(i).GT.small_mh) THEN
     ndmh = ndmh + 1
    ENDIF
    km(i)=-(dmhsteps-1)/2
   enddo
    
   do i=1,np(Hplus)
    IF (dMhch(i).GT.small_mh) ndmh = ndmh + 1
     km(i+np(Hneut))=-(dmhsteps-1)/2
   enddo
   
   IF (ndmh.EQ.0) THEN
     RETURN
   ENDIF
     
 !  print *, "Number of mass uncertainties: ", ndmh
 
   if(allocated(diffMhneut)) deallocate(diffMhneut)
   if(allocated(diffMhch)) deallocate(diffMhch)
     
   allocate(diffMhneut(dmhsteps**(np(Hneut)+np(Hplus)),np(Hneut)))
   allocate(diffMhch(dmhsteps**(np(Hneut)+np(Hplus)),np(Hplus)))
 
   k = 1
   do i=1,dmhsteps**ndmh
 
     do j=1,ndmh
      dm(i,j) = km(j)
     enddo
 
     km(k) = km(k)+1
 
     do j=2,ndmh
      IF (modulo(i,dmhsteps**(j-1)).EQ.0) THEN
       km(j) = km(j)+1
       km(j-1) = -1
      ENDIF
     ENDDO
 
   enddo    
   
   
   do i=1,dmhsteps**ndmh
    k=1
  
     do j=1,np(Hneut)
      IF (dMhneut(j).GT.small_mh) THEN
       diffMhneut(i,j)=theo(n)%particle(Hneut)%M(j)+dm(i,k)*dMhneut(k)/((dmhsteps-1)/2)
       k = k +1
      ELSE
       diffMhneut(i,j)=theo(n)%particle(Hneut)%M(j)
      ENDIF
     enddo
     
     kp = k
     do j=1,np(Hplus)
      IF (dMhch(j).GT.small_mh) THEN
       diffMhch(i,j)=theo(n)%particle(Hplus)%M(j)+dm(i,k)*dMhch(k-(kp-1))/((dmhsteps-1)/2)
       k = k +1
      ELSE
       diffMhch(i,j)=theo(n)%particle(Hplus)%M(j)
      ENDIF
     enddo
     
   
 !    print *, i, (diffMhneut(i,j),j=1,np(Hneut)),(diffMhch(i,j),j=1,np(Hplus))
   
   enddo
   
 end subroutine get_mass_variation_param
 
 
 subroutine SUSYBounds_neutralinoonly_input(MN,GammaTotal_N, &
      &          CS_NjNi,                        &
      &          BR_NjqqNi,BR_NjZNi                           &
      &          )
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! Arguments (input): theoretical predictions (see manual for definitions)
 !************************************************************
  use usefulbits, only : theo,np,Chineut,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
 
  !----------------------------------------input
  double precision,intent(in) :: MN( np(Chineut) ),GammaTotal_N( np(Chineut) ) , &
      &          CS_NjNi( np(Chineut),np(Chineut) ),                        &
      &          BR_NjqqNi( np(Chineut),np(Chineut) ),BR_NjZNi( np(Chineut),np(Chineut) )                        
  !--------------------------------------internal
  integer :: n
  integer :: subtype
  !----------------------------------------------
  
  n=1  
  subtype=3
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if(np(Chineut).eq.0)then
    write(*,*)'subroutine SUSYBounds_neutralinoonly_input should'
    write(*,*)'only be called if np(Chineut)>0'
    stop'error in SUSYBounds_neutralinoonly_input'
  endif
 
  theo(n)%particle(Chineut)%M       = MN
  theo(n)%particle(Chineut)%GammaTot= GammaTotal_N
 
  theo(n)%lep%XS_NjNi = CS_NjNi
 
  theo(n)%BR_NjqqNi  = BR_NjqqNi
  theo(n)%BR_NjZNi   = BR_NjZNi  
 
  just_after_run=.False. 
 
 end subroutine SUSYBounds_neutralinoonly_input
 !************************************************************      
 subroutine SUSYBounds_neutralinochargino_input(MC,GammaTotal_C, &
      &          CS_CpjCmj,                                      &
      &          BR_CjqqNi,                                      &
      &          BR_CjlnuNi,                                     &
      &          BR_CjWNi                                        &
      &          )
 ! This subroutine can be called by the user after subroutine initialize_HiggsBounds
 ! has been called.
 ! Arguments (input): theoretical predictions (see manual for definitions)
 !************************************************************
  use usefulbits, only : theo,np,Chineut,Chiplus,inputsub,just_after_run
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none
 
  !----------------------------------------input
  double precision,intent(in) :: MC( np(Chiplus) ),GammaTotal_C( np(Chiplus) ),  &
      &          CS_CpjCmj(  np(Chiplus) ),                                     &
      &          BR_CjqqNi(  np(Chiplus),np(Chineut) ),                         &
      &          BR_CjlnuNi( np(Chiplus),np(Chineut) ),                         &
      &          BR_CjWNi(   np(Chiplus),np(Chineut) )                                        
  !--------------------------------------internal
  integer :: n
  integer :: subtype
  !----------------------------------------------
  
  n=1  
  subtype=4
  inputsub(subtype)%stat=inputsub(subtype)%stat+1
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  if((np(Chineut).eq.0).or.(np(Chiplus).eq.0))then
    write(*,*)'subroutine SUSYBounds_neutralinochargino_input should'
    write(*,*)'only be called if np(Chineut)>0 and np(Chiplus)>0'
    stop 'error in subroutine SUSYBounds_neutralinochargino_input'
  endif
 
  theo(n)%particle(Chineut)%M       = MC
  theo(n)%particle(Chineut)%GammaTot= GammaTotal_C
 
  theo(n)%lep%XS_CpjCmj = CS_CpjCmj
 
  theo(n)%BR_CjqqNi  = BR_CjqqNi
  theo(n)%BR_CjlnuNi = BR_CjlnuNi
  theo(n)%BR_CjWNi   = BR_CjWNi  
 
  just_after_run=.False. 
 
 end subroutine SUSYBounds_neutralinochargino_input
 !************************************************************
 
 
 subroutine run_HiggsBounds(HBresult, chan, obsratio, ncombined)
 ! This subroutine can be called by the user after HiggsBounds_initialize has been called.
 ! The input routines, where required, should be called before calling run_HiggsBounds.
 ! It takes theoretical predictions for a particular parameter point 
 ! in the model and calls subroutines which compare these predictions 
 ! to the experimental limits
 ! Arguments (output): 
 !   * HBresult = 1 if point is unexcluded, 0 if excluded, -1 if parameter point is invalid
 !   * chan = number of channel predicted to have the highest statistical sensitivity, as defined in Key.dat
 !   * obsratio = ratio of the theoretical rate to the observed limit for this channel
 !   * ncombined = number of Higgs combined in order to calculate this obsratio
 !    (see manual for more precise definitions))
 ! (TS 30/01/2012): Note, that if many data points are tested at the same time (as for
 !                  inputmethod==datfiles), this subroutine only returns the results of
 !                  the last datapoint. The full results are saved in fullHBres.
  use usefulbits, only : np, Hneut, Hplus, run_HB_classic
 
  implicit none
  integer HBresult, chan, ncombined
  double precision obsratio
  
  integer hbres(0:np(Hneut)+np(Hplus)), hbchan(0:np(Hneut)+np(Hplus)), hbcomb(0:np(Hneut)+np(Hplus))
  double precision hbobs(0:np(Hneut)+np(Hplus))
 
 ! Check if we are using the old 'classic' method
  if (run_HB_classic.EQV..True.) then
    call run_HiggsBounds_classic(HBresult,chan,obsratio,ncombined)
    return
  endif
  
 ! Call the new ('full') method
  call run_HiggsBounds_full(hbres, hbchan, hbobs, hbcomb)
  
 ! Combined results are contained in the zero elements of result arrays
  HBresult = hbres(0)
  chan = hbchan(0)
  obsratio = hbobs(0)
  ncombined = hbcomb(0)
     
 end subroutine run_HiggsBounds
 !************************************************************
 
 
 
 subroutine run_HiggsBounds_single(h, HBresult, chan, obsratio, ncombined)
 ! This subroutine can be used to get the exclusion results
 ! for a single Higgs boson (specified by the index h).
 !
 ! To obtain individual results from more than one Higgs boson, it
 ! is more efficient to use run_HiggsBounds_full rather than this method.
  use usefulbits, only : np, Hneut, Hplus
 
  implicit none
  integer, intent(in) :: h
  integer, intent(out) :: HBresult, chan, ncombined
  double precision, intent(out) :: obsratio
  
  integer hbres(0:np(Hneut)+np(Hplus)), hbchan(0:np(Hneut)+np(Hplus)), hbcomb(0:np(Hneut)+np(Hplus))
  double precision hbobs(0:np(Hneut)+np(Hplus))
  
  IF (h.LT.0) stop "Illegal number of Higgs boson: h < 0"
  if (h.GT.np(Hneut)+np(Hplus)) stop "Illegal number of Higgs boson"
  
  call run_HiggsBounds_full(hbres, hbchan, hbobs, hbcomb)
 
  HBresult = hbres(h)
  chan = hbchan(h)
  obsratio = hbobs(h)
  ncombined = hbcomb(h)
 end subroutine run_HiggsBounds_single
 !************************************************************
 
 
 subroutine run_HiggsBounds_full( HBresult,chan,                      &
      &                      obsratio, ncombined                 )
 ! This subroutine can be called by the user after HiggsBounds_initialize has been called.
 ! The input routines, where required, should be called before calling run_HiggsBounds.
 ! It takes theoretical predictions for a particular parameter point 
 ! in the model and calls subroutines which compare these predictions 
 ! to the experimental limits.
 ! 
 ! The results are given as (n+1)-component arrays (starting from 0), 
 ! where n is the total number of Higgs bosons in the model (neutral+charged).
 ! The zeroth component gives the combined results (equivalent to run_HiggsBounds).
 !
 ! Arguments (output): 
 !   * HBresult = 1 if point is unexcluded, 0 if excluded, -1 if parameter point is invalid
 !   * chan = number of channel predicted to have the highest statistical sensitivity, as defined in Key.dat
 !   * obsratio = ratio of the theoretical rate to the observed limit for this channel
 !   * ncombined = number of Higgs combined in order to calculate this obsratio
 !    (see manual for more precise definitions))
  use usefulbits, only : theo,res,inputsub,just_after_run,ndmh,debug, &
 &                       np,Hneut,Hplus,dmhsteps,ndat,fullHBres,small_mh
  use channels, only : check_channels
  !use input, only : test_input
  use theo_manip, only : complete_theo, recalculate_theo_for_datapoint
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none                      
  !----------------------------------------output
  integer,intent(out)::  HBresult(0:np(Hneut)+np(Hplus))
  integer,intent(out)::  chan(0:np(Hneut)+np(Hplus))
  integer,intent(out)::  ncombined(0:np(Hneut)+np(Hplus))
 
  double precision,intent(out) :: obsratio(0:np(Hneut)+np(Hplus))
  
  double precision :: Mhneut(np(Hneut))
  double precision :: Mhch(np(Hplus))
  !-------------------------------------internal
  integer :: n,i,j,ind,part
  !---------------------------------------------
 
 ! print *, "Running HiggsBounds in Normal Mode (most sensitive limit considered for each Higgs boson)"
  
  if (lbound(HBresult,dim=1).NE.0) stop "run_HiggsBounds_full: Array HBresult must begin with element 0"
  if (ubound(HBresult,dim=1).NE.(np(Hneut)+np(Hplus))) then
   stop "run_HiggsBounds_full: Upper limit of array HBresult must be equal to number of Higgses"
  endif 
  if (lbound(chan,dim=1).NE.0) stop "run_HiggsBounds_full: Array chan must begin with element 0"
  if (ubound(chan,dim=1).NE.(np(Hneut)+np(Hplus))) then
   stop "run_HiggsBounds_full: Upper limit of array chan must be equal to number of Higgses"
  endif 
  if (lbound(obsratio,dim=1).NE.0) stop "run_HiggsBounds_full: Array obsratio must begin with element 0"
  if (ubound(obsratio,dim=1).NE.(np(Hneut)+np(Hplus))) then
   stop "run_HiggsBounds_full: Upper limit of array obsratio must be equal to number of Higgses"
  endif 
  if (lbound(ncombined,dim=1).NE.0) stop "run_HiggsBounds_full: Array ncombined must begin with element 0"
  if (ubound(ncombined,dim=1).NE.(np(Hneut)+np(Hplus))) then
   stop "run_HiggsBounds_full: Upper limit of array ncombined must be equal to number of Higgses"
  endif 
 
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  do i=1,ubound(inputsub,dim=1)
    if(  inputsub(i)%req .ne. inputsub(i)%stat  )then
        write(*,*)'subroutine '//trim(adjustl(inputsub(i)%desc))
        write(*,*)'should be called once and only once before each call to'
        write(*,*)'subroutine run_HiggsBounds.'
        stop'error in subroutine run_HiggsBounds'
    endif
    inputsub(i)%stat=0!now we have used this input, set back to zero
  enddo
 
  call complete_theo    
  
   do n=1,ndat
 
 !   if(debug) then
 !    write(*,*) "DEBUG BRs: ", theo(n)%BR_hjWW, theo(n)%BR_hjZZ, theo(n)%BR_hjgaga
    
 !   endif
 
         
    theo(n)%particle(Hneut)%Mc = theo(n)%particle(Hneut)%M
    theo(n)%particle(Hplus)%Mc = theo(n)%particle(Hplus)%M
 
    call get_mass_variation_param(n)
 
     do i=0,ubound(Hbresult,dim=1)
      obsratio(i) = -999d0
      HBresult(i) = 1
      chan(i) = -999
      ncombined(i) = -999
     enddo
 
 !  Do we have mass uncertainties to take care off
     IF (ndmh.GT.0) THEN
    
 !    print *, "Running HiggsBounds with Higgs mass uncertainties"
 !    write(*,*) theo(n)%particle(Hplus)%dM
       
      if(np(Hneut).ne.0) Mhneut =  theo(n)%particle(Hneut)%M 
      if(np(Hplus).ne.0) Mhch = theo(n)%particle(Hplus)%M
 
 !   Loop over all Higgses
      do i=1,np(Hneut)+np(Hplus)
       obsratio(i) = 1.D23
 
       IF (i.LE.np(Hneut)) THEN
        ind = i
        part = Hneut
       ELSE
        ind = i-np(Hneut)
        part = Hplus
       ENDIF
           
 !     Check for mass steps for this particular Higgs boson
       IF(theo(n)%particle(part)%dMh(ind).GT.small_mh) THEN
 
 !       theo(n)%particle(part)%M(ind)=theo(n)%particle(part)%M(ind)  &
 !       &                             -(dmhsteps-1)/2*theo(n)%particle(part)%dMh(ind)
 
        theo(n)%particle(part)%M(ind)=theo(n)%particle(part)%M(ind)  &
        &                             -theo(n)%particle(part)%dMh(ind)
 
        do j=1,dmhsteps 
         
 !        print *, theo(n)%particle(Hneut)%M, theo(n)%particle(Hplus)%M
 
         call recalculate_theo_for_datapoint(n)       
 
         call check_channels(theo(n),res(n),i)
      	
         IF (res(n)%obsratio(1).LT.obsratio(i)) THEN
          HBresult(i)    = res(n)%allowed95(1)       
          chan(i)        = res(n)%chan(1)       
          obsratio(i)    = res(n)%obsratio(1)
          ncombined(i)   = res(n)%ncombined(1)        
         ENDIF
         
 !        print *, i,theo(n)%particle(part)%M(ind),HBresult(i),chan(i),obsratio(i),ncombined(i)
         
         theo(n)%particle(part)%M(ind)= theo(n)%particle(part)%M(ind)  &
         &                             +theo(n)%particle(part)%dMh(ind)/(dmhsteps-1)*2
         
       enddo
      else
       call recalculate_theo_for_datapoint(n)
       call check_channels(theo(n),res(n),i)
 
       HBresult(i)    = res(n)%allowed95(1)       
       chan(i)        = res(n)%chan(1)       
       obsratio(i)    = res(n)%obsratio(1)
       ncombined(i)   = res(n)%ncombined(1)            
      endif 
      
 !	 Logical OR between exclusions (one Higgs excluded = combined exclusion)
      HBresult(0) = HBresult(0) * HBresult(i)
     
 !    Save the data for the Higgs that has the highest ratio of theory/obs 
      IF (obsratio(i).GT.obsratio(0)) THEN
       chan(0)        = chan(i)       
       obsratio(0)    = obsratio(i)
       ncombined(0)   = ncombined(i)        
      ENDIF
      
      theo(n)%particle(Hneut)%M = Mhneut
      theo(n)%particle(Hplus)%M = Mhch
       
     enddo
  !    return 
      
    ELSE
  
  
 !    print *, "Running HiggsBounds without Higgs mass uncertainties"
 
     call recalculate_theo_for_datapoint(n)       
 !    write(*,*) "Higgses = " , np(Hneut)+np(Hplus)
 
    do i=1,np(Hneut)+np(Hplus)
     call check_channels(theo(n),res(n),i)
     HBresult(i)    = res(n)%allowed95(1)       
     chan(i)        = res(n)%chan(1)       
     obsratio(i)    = res(n)%obsratio(1)
     ncombined(i)   = res(n)%ncombined(1)        
     
     HBresult(0) = HBresult(0) * res(n)%allowed95(1)
     
     IF (obsratio(i).GT.obsratio(0)) THEN
 !     write(*,*) "hello: ", n, i
      chan(0)        = res(n)%chan(1)       
      obsratio(0)    = res(n)%obsratio(1)
      ncombined(0)   = res(n)%ncombined(1)        
     ENDIF
        
 !    IF (i.LE.np(Hneut)) THEN
 !     print *, i,theo(n)%particle(Hneut)%M(i),HBresult(i),chan(i),obsratio(i),ncombined(i),HBresult(0), obsratio(0)   
 !    ELSE
 !     print *, i,theo(n)%particle(Hplus)%M(i-np(Hneut)),HBresult(i),chan(i),obsratio(i),ncombined(i),HBresult(0), obsratio(0)   
 !    endif
    enddo
   ENDIF
 
   fullHBres(n)%allowed95=HBresult(0)
   fullHBres(n)%chan=chan(0)
   fullHBres(n)%obsratio=obsratio(0)
   fullHBres(n)%ncombined=ncombined(0)
  
  enddo
 
 
  just_after_run=.True.   
  
- print *, "HB: run done"
+! print *, "HB: run done"
 
 end subroutine run_HiggsBounds_full
 !************************************************************
 
 
 
 subroutine run_HiggsBounds_classic( HBresult,chan,obsratio,ncombined)
 ! This subroutine can be called by the user after HiggsBounds_initialize has been called.
 ! The input routines, where required, should be called before calling run_HiggsBounds.
 ! It takes theoretical predictions for a particular parameter point 
 ! in the model and calls subroutines which compare these predictions 
 ! to the experimental limits
 ! Arguments (output): 
 !   * HBresult = 1 if point is unexcluded, 0 if excluded, -1 if parameter point is invalid
 !   * chan = number of channel predicted to have the highest statistical sensitivity, as defined in Key.dat
 !   * obsratio = ratio of the theoretical rate to the observed limit for this channel
 !   * ncombined = number of Higgs combined in order to calculate this obsratio
 !    (see manual for more precise definitions))
  use usefulbits, only : theo,res,debug,inputsub,just_after_run,ndmh,diffmhneut,diffmhch, &
  np,Hneut,Hplus,full_dmth_variation,dmhsteps, ndat,fullHBres
  use channels, only : check_channels
  !use input, only : test_input
  use theo_manip, only : complete_theo, recalculate_theo_for_datapoint
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
 
  implicit none                      
  !----------------------------------------output
  integer,intent(out)::     HBresult,chan,ncombined
  double precision,intent(out) :: obsratio
  
  double precision :: Mhneut(np(Hneut))
  double precision :: Mhch(np(Hplus))
  !-------------------------------------internal
  integer :: n,i
  integer :: HBresult_tmp,chan_tmp,ncombined_tmp
  double precision :: obsratio_tmp
  !---------------------------------------------
 ! n=1
  
 !  print *, "Running HiggsBounds in Classic Mode (globally most sensitive limit only)"
     
   
  if(.not.allocated(theo))then
   stop 'subroutine HiggsBounds_initialize must be called first'
  endif
 
  do i=1,ubound(inputsub,dim=1)
    if(  inputsub(i)%req .ne. inputsub(i)%stat  )then
        write(*,*)'subroutine '//trim(adjustl(inputsub(i)%desc))
        write(*,*)'should be called once and only once before each call to'
        write(*,*)'subroutine run_HiggsBounds.'
        stop'error in subroutine run_HiggsBounds'
    endif
    inputsub(i)%stat=0!now we have used this input, set back to zero
  enddo
 
  call complete_theo    
 
  do n=1,ndat
         
   theo(n)%particle(Hneut)%Mc = theo(n)%particle(Hneut)%M
 
   call get_mass_variation_param(n)
 
   IF (ndmh.GT.0) THEN
    
     if(np(Hneut).ne.0) Mhneut =  theo(n)%particle(Hneut)%M     
     if(np(Hplus).ne.0) Mhch = theo(n)%particle(Hplus)%M
   
     obsratio_tmp = 10.0E6 ! Set to very large initial value
     do i=1,dmhsteps**ndmh 
      theo(n)%particle(Hneut)%M = diffMhneut(i,:)
      theo(n)%particle(Hplus)%M = diffMhch(i,:)
 		 
      if(debug)write(*,*)'manipulating input...'                 ; call flush(6)
      call recalculate_theo_for_datapoint(n)
 	
      if(debug)write(*,*)'compare each data point to the experimental bounds...' ; call flush(6)                  
      call check_channels(theo(n),res(n),0)
 		
      HBresult    = res(n)%allowed95(1)
      chan        = res(n)%chan(1)       
      obsratio    = res(n)%obsratio(1)
      ncombined   = res(n)%ncombined(1)        
 !     print *, HBresult, chan, obsratio, ncombined
 		
      IF (.NOT.full_dmth_variation) THEN
       IF (HBresult.EQ.1) THEN
 !		 	 theo(n)%particle(Hneut)%M = Mhneut
 ! 			 theo(n)%particle(Hplus)%M = Mhch
        just_after_run=.True.   
        exit
       ENDIF
      ELSE
       IF (obsratio.lt.obsratio_tmp) THEN
        HBresult_tmp  = HBresult
        chan_tmp      = chan
        obsratio_tmp  = obsratio
        ncombined_tmp = ncombined
       ENDIF
      ENDIF  
    enddo
    
    IF (full_dmth_variation) THEN
     HBresult  = HBresult_tmp
     chan      = chan_tmp
     obsratio  = obsratio_tmp
     ncombined = ncombined
 !    theo(n)%particle(Hneut)%M = Mhneut
 !    theo(n)%particle(Hplus)%M = Mhch
     just_after_run=.True.    
 !	return
    ENDIF
    
    theo(n)%particle(Hneut)%M = Mhneut
    theo(n)%particle(Hplus)%M = Mhch
    call recalculate_theo_for_datapoint(n)
    call check_channels(theo(n),res(n),0)
 
  ELSE
  
    if(debug)write(*,*)'manipulating input...'                 ; call flush(6)
    call recalculate_theo_for_datapoint(n)
 
    if(debug)write(*,*)'compare each data point to the experimental bounds...' ; call flush(6)                  
    
    call check_channels(theo(n),res(n),0)
    
    HBresult    = res(n)%allowed95(1)
    chan        = res(n)%chan(1)       
    obsratio    = res(n)%obsratio(1)
    ncombined   = res(n)%ncombined(1)        
 
    just_after_run=.True.   
  ENDIF
 
  fullHBres(n)%allowed95=HBresult
  fullHBres(n)%chan=chan
  fullHBres(n)%obsratio=obsratio
  fullHBres(n)%ncombined=ncombined
 
  enddo 
 
  just_after_run=.True.    
 
 
 end subroutine run_HiggsBounds_classic
 !************************************************************
 subroutine HiggsBounds_get_chisq(analysisID, Hindex, M_av, nc, cbin, llh, obspred)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,Hplus
  use theo_manip, only : complete_theo
  use likelihoods, only : get_likelihood, calcpredratio_llh
  implicit none
  
  integer, intent(in) :: analysisID
  integer, intent(out) :: Hindex, nc, cbin
  double precision, intent(out) :: llh, M_av
  character(LEN=*), intent(in) :: obspred  
 
  integer :: c,i
  double precision, allocatable :: expllh(:) 
 
 ! double precision :: fact
  double precision, allocatable :: mass(:) ! predratio(:)
  integer, allocatable :: nclist(:) 
 ! call complete_theo
 ! allocate(predratio(np(Hneut)))
 ! predratio = 0.0D0
 
 ! write(*,*) "Calling HiggsBounds_get_chisq..." 
 
  allocate(expllh(np(Hneut)),mass(np(Hneut)),nclist(np(Hneut)))
  expllh = 0.0D0
  
  select case(analysisID)
   case(3316)
    c=1
   case default
    stop 'Unknown analysisID in subroutine HiggsBounds_get_chisq!' 
  end select  
   
 ! Determine most sensitive combination
  do i=1,np(Hneut)
   call get_likelihood(analysisID, i, theo(1), expllh(i), mass(i), nclist(i), cbin, 'pred')
  enddo
 
  Hindex = maxloc(expllh,dim=1)
  
  call get_likelihood(analysisID, Hindex, theo(1), llh, M_av, nc, cbin, obspred)
  
  deallocate(mass,nclist,expllh) !predratio
 
 end subroutine HiggsBounds_get_chisq
 !************************************************************
 subroutine HiggsBounds_get_combined_chisq(analysisID, llh, obspred)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,Hplus, vsmall
 
  integer, intent(in) :: analysisID
  character(LEN=*), intent(in), optional :: obspred  
  double precision, intent(out) :: llh
 
  double precision :: M_av, llh_tmp
  integer :: i, j, nc, cbin, Hindex, cbin_end, cbin_in
  
  cbin_end = 0
  do i= 1,np(Hneut)
   cbin_end = cbin_end + 2**(i-1)
  enddo 
  
  llh = -1.0D0
  cbin_in = 0
  llh_tmp = 0.0D0
  
  do while(cbin_in.lt.cbin_end)
   if(present(obspred)) then
    call HiggsBounds_get_maximal_chisq_for_comb(analysisID, obspred, cbin_in, Hindex, cbin, nc, M_av, llh)
   else
    call HiggsBounds_get_maximal_chisq_for_comb(analysisID, 'obs', cbin_in, Hindex, cbin, nc, M_av, llh)
   endif 
   if(llh.ge.0.0D0) then
    llh_tmp = llh_tmp + llh
   else
    exit
   endif  
   cbin_in = cbin_in + cbin
  enddo  
 
  if(llh_tmp.gt.0.0D0) then 
   llh = llh_tmp
  endif 
 
  
 end subroutine HiggsBounds_get_combined_chisq
 !************************************************************
 subroutine HiggsBounds_get_chisq_for_Higgs(analysisID, cbin_in, Hindex, nc, cbin, M_av, llh)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,Hplus
  use theo_manip, only : complete_theo
  use likelihoods, only : get_likelihood, calcpredratio_llh
  implicit none
  
  integer, intent(in) :: analysisID,Hindex
  integer, intent(out) ::  nc, cbin
  double precision, intent(out) :: llh, M_av
  integer, intent(in) :: cbin_in 
  integer :: c,i
  
 ! write(*,*) "Calling HiggsBounds_get_chisq_for_Higgs..."
  select case(analysisID)
   case(3316)
    c=1
   case default
    stop 'Unknown analysisID in subroutine HiggsBounds_get_chisq!' 
  end select
  
  call get_likelihood(analysisID, Hindex, theo(1), llh, M_av, nc, cbin,'obs',cbin_in)
    
 ! write(*,*) "h(",Hindex,") llh: ", llh, M_av, nc, cbin
  
 end subroutine HiggsBounds_get_chisq_for_Higgs
 !************************************************************
 subroutine HiggsBounds_get_maximal_chisq(analysisID, Hindex, nc, M_av, llh)
 ! Wrapper subroutine for HiggsBounds_get_maximal_chisq_for_comb considering
 ! all neutral Higgs bosons
 !************************************************************
 
  use usefulbits, only : theo,np,Hneut,Hplus
   
  integer, intent(in) :: analysisID
  integer, intent(out) :: Hindex, nc
  double precision, intent(out) :: llh, M_av
  
  integer :: cbin
  
  call HiggsBounds_get_maximal_chisq_for_comb(analysisID, 'obs', 0, Hindex, cbin, nc, M_av, llh)
  
 end subroutine HiggsBounds_get_maximal_chisq
 !************************************************************
 subroutine HiggsBounds_get_maximal_chisq_for_comb(analysisID, obspred, cbin_in, Hindex, cbin, nc, M_av, llh)
 !************************************************************
  use usefulbits, only : theo,np,Hneut,Hplus
  use theo_manip, only : complete_theo
  use likelihoods, only : get_likelihood, calcpredratio_llh
  implicit none
  
  integer, intent(in) :: analysisID, cbin_in
  integer, intent(out) :: Hindex, nc, cbin
  double precision, intent(out) :: llh, M_av
  character(LEN=*), intent(in) :: obspred  
 
  integer :: c,i
  double precision, allocatable :: obsllh(:) 
 
 ! double precision :: fact
  double precision, allocatable :: mass(:) ! predratio(:)
  integer, allocatable :: nclist(:), cbinlist(:)
 ! call complete_theo
 ! allocate(predratio(np(Hneut)))
 ! predratio = 0.0D0
 
 ! write(*,*) "Calling HiggsBounds_get_maximal_chisq_for_comb with dataset: ", obspred 
 
  allocate(obsllh(np(Hneut)),mass(np(Hneut)),nclist(np(Hneut)),cbinlist(np(Hneut)))
  obsllh = 0.0D0
  
  select case(analysisID)
   case(3316)
    c=1
   case default
    stop 'Unknown analysisID in subroutine HiggsBounds_get_maximal_chisq!' 
  end select
   
 ! Determine most sensitive combination
  do i=1,np(Hneut)
   call get_likelihood(analysisID, i, theo(1), obsllh(i), mass(i), nclist(i),cbinlist(i),obspred, cbin_in)
  enddo
 
  Hindex = maxloc(obsllh,dim=1) 
  llh = obsllh(Hindex)
  M_av = mass(Hindex)
  nc = nclist(Hindex)
  cbin = cbinlist(Hindex)
  
  deallocate(mass,nclist,obsllh,cbinlist) !predratio
 
 end subroutine HiggsBounds_get_maximal_chisq_for_comb
 !************************************************************ 
 subroutine HiggsBounds_SLHA_output
 !**** ******************************************************** 
 use usefulbits, only : whichinput,just_after_run
 use output, only : do_output
 
   if(.not.just_after_run)then
    stop'subroutine run_HiggsBounds should be called before subroutine HiggsBounds_SLHA_output' 
   endif  
 
   select case(whichinput)
   case('SLHA') 
     call do_output
   case default
     stop'The subroutine HiggsBounds_SLHA_output should only be used when whichinput=SLHA'
   end select
 
 end subroutine HiggsBounds_SLHA_output
 
 #ifdef enableCHISQ
 !************************************************************      
 subroutine initialize_HiggsBounds_chisqtables
 ! use S95tables, only : S95_t2
  use S95tables_type3
  use usefulbits, only : allocate_if_stats_required,theo
  implicit none            
  
  if(allocated(theo))then
   stop 'subroutine initialize_HiggsBounds_chisqtables should be called before subroutine HiggsBounds_initialize'
  elseif(allocated(clsb_t3))then
   stop 'subroutine initialize_HiggsBounds_chisqtables has already been called once'
  endif 
 
  allocate(clsb_t3(ntable3))
 
  call initializetables_type3_blank(clsb_t3)
  call initializetables3(clsb_t3)
 
  call readclsbfiles_binary
 
  if(allocated(allocate_if_stats_required))then
    stop'error in subroutine initialize_HiggsBounds_chisqtables'
  else
    allocate(allocate_if_stats_required(1))
  endif
 
 
 end subroutine initialize_HiggsBounds_chisqtables
 
 !************************************************************
 subroutine finish_HiggsBounds_chisqtables
 !************************************************************
  use S95tables_type3
  use usefulbits, only : allocate_if_stats_required
  implicit none      
  integer :: x      
 
  if(.not.allocated(clsb_t3))then
   stop 'initialize_HiggsBounds_chisqtables should be called first'
  endif
 
  do x=lbound(clsb_t3,dim=1),ubound(clsb_t3,dim=1)
   deallocate(clsb_t3(x)%dat)
  enddo
  deallocate(filename)
  deallocate(clsb_t3)
  deallocate(allocate_if_stats_required)
 
 end subroutine finish_HiggsBounds_chisqtables
 
 !************************************************************
 subroutine HB_calc_stats(theory_uncertainty_1s,chisq_withouttheory,chisq_withtheory,chan2)
 !************************************************************
 ! this is in the middle of development! DO NOT USE!
  use usefulbits, only : res,theo,pr,just_after_run,vsmall
  use interpolate
  use S95tables_type1
  use S95tables_type3
  use S95tables
  use extra_bits_for_chisquared
  implicit none      
 
   integer,intent(out)::chan2
   integer :: x,c,z,y
   integer :: id
   double precision, intent(in) :: theory_uncertainty_1s
   double precision :: chisq_withouttheory,chisq_withtheory
   double precision :: low_chisq,sigma
 
   x=1
   low_chisq=1.0D-2
 
   if(.not.allocated(theo))then
    stop 'subroutine HiggsBounds_initialize must be called first'
   elseif(.not.allocated(clsb_t3))then
    stop 'subroutine initialize_HiggsBounds_chisqtables must be called first'
   elseif(.not.just_after_run)then
    stop 'subroutine run_HiggsBounds must be called first'
   endif
 
   sigma=theory_uncertainty_1s
   if(sigma.lt.vsmall)then 
    write(*,*)'Warning: will not calculate chi^2 with theory uncertainty'
   endif
 
   chisq_withtheory              = -2.0D0
   chisq_withouttheory           = -2.0D0
 
   z=2;
   c= res(x)%chan(z)
   chan2=c
 
   if(res(x)%allowed95(z).eq.-1)then! labels an unphysical parameter point
    chisq_withtheory             =-1.0D0
    chisq_withouttheory          =-1.0D0
   elseif( c.gt.0 )then ! labels a physical parameter point and a real channel                      
   
    id=S95_t1_or_S95_t2_idfromelementnumber(pr(c)%ttype,pr(c)%tlist)
    y=clsb_t3elementnumber_from_S95table(pr(c)%ttype,id)
 
    if(y.gt.0)then
 
     !------------------------------
 
     call get_chisq(sigma,res(x)%axis_i(z),res(x)%axis_j(z),res(x)%sfactor(z), &
       &  y,chisq_withouttheory,chisq_withtheory)
 
     !-------------------------------
 
    else
      write(*,*)'hello y=',y
      stop'problem here with y'
    endif
 
   else
    chisq_withtheory             =0.0D0
    chisq_withouttheory          =0.0D0
   endif  
 
 end subroutine HB_calc_stats
 #endif
 !************************************************************
 subroutine finish_HiggsBounds
 ! This subroutine needs to be called right at the end, to close files
 ! and deallocate arrays
 !************************************************************
  use usefulbits, only : deallocate_usefulbits,debug,theo,debug,inputsub, &
    & file_id_debug1,file_id_debug2
  use S95tables, only : deallocate_S95tables
  use theory_BRfunctions, only : deallocate_BRSM
 
 #if defined(NAGf90Fortran)
  use F90_UNIX_IO, only : flush
 #endif
       
  if(debug)then
   close(file_id_debug2)
   close(file_id_debug1)
  endif
 
  if(.not.allocated(theo))then
   stop 'HiggsBounds_initialize  should be called first'
  endif
 
  if(debug)write(*,*)'finishing off...'                      ; call flush(6)
  call deallocate_BRSM
  call deallocate_S95tables
  call deallocate_usefulbits
 
  if(debug)write(*,*)'finished'                              ; call flush(6)
  
  if(allocated(inputsub)) deallocate(inputsub)
 end subroutine finish_HiggsBounds
 !
 !!************************************************************
 !	
 !subroutine run_HiggsBounds_effC(nHdummy,Mh,GammaTotal,             &   
 !     &          g2hjbb,g2hjtautau,g2hjWW,g2hjZZ,                   &
 !     &          g2hjgaga,g2hjgg,g2hjhiZ_nHbynH,                    &
 !     &          BR_hjhihi_nHbynH,                                  &
 !     &          HBresult,chan,                                     &
 !     &          obsratio, ncombined                                )
 !! Obsolete subroutine
 !!************************************************************
 !
 ! implicit none
 !
 ! !----------------------------------------input
 ! integer,intent(in) :: nHdummy
 ! double precision,intent(in) :: Mh(nHdummy),GammaTotal(nHdummy),&   
 !     &          g2hjbb(nHdummy),g2hjtautau(nHdummy),            &
 !     &          g2hjWW(nHdummy),g2hjZZ(nHdummy),                &
 !     &          g2hjgaga(nHdummy),g2hjgg(nHdummy),              &
 !     &          g2hjhiZ_nHbynH(nHdummy,nHdummy),                &
 !     &          BR_hjhihi_nHbynH(nHdummy,nHdummy) 
 ! !----------------------------------------output
 ! integer ::     HBresult,chan,ncombined
 ! double precision :: obsratio
 ! !----------------------------------------------
 !	  
 ! call attempting_to_use_an_old_HB_version('effC')
 !
 !end subroutine run_HiggsBounds_effC
 !!************************************************************	
 !subroutine run_HiggsBounds_part(nHdummy,Mh,                  &
 !     &          CS_lep_hjZ_ratio,                            &
 !     &          CS_lep_hjhi_ratio_nHbynH,                    &
 !     &          CS_tev_gg_hj_ratio,CS_tev_bb_hj_ratio,       &
 !     &          CS_tev_bg_hjb_ratio,                         &
 !     &          CS_tev_ud_hjWp_ratio,CS_tev_cs_hjWp_ratio,   & 
 !     &          CS_tev_ud_hjWm_ratio,CS_tev_cs_hjWm_ratio,   & 
 !     &          CS_tev_dd_hjZ_ratio,CS_tev_uu_hjZ_ratio,     &
 !     &          CS_tev_ss_hjZ_ratio,CS_tev_cc_hjZ_ratio,     &
 !     &          CS_tev_bb_hjZ_ratio,                         &
 !     &          CS_tev_pp_vbf_ratio,                         &
 !     &          BR_hjbb,BR_hjtautau,                         &
 !     &          BR_hjWW,BR_hjgaga,                           & 
 !     &          BR_hjhihi_nHbynH,                            &
 !     &          HBresult,chan,                               &
 !     &          obsratio, ncombined                          )
 !! Obsolete subroutine
 !!************************************************************
 !
 ! implicit none
 !
 ! !----------------------------------------input
 ! integer , intent(in) :: nHdummy
 ! double precision,intent(in) ::Mh(nHdummy),                                 &
 !     &          CS_lep_hjZ_ratio(nHdummy),                                  &
 !     &          CS_lep_hjhi_ratio_nHbynH(nHdummy,nHdummy),                  &
 !     &          CS_tev_gg_hj_ratio(nHdummy),CS_tev_bb_hj_ratio(nHdummy),    &
 !     &          CS_tev_bg_hjb_ratio(nHdummy),                               &
 !     &          CS_tev_ud_hjWp_ratio(nHdummy),CS_tev_cs_hjWp_ratio(nHdummy),& 
 !     &          CS_tev_ud_hjWm_ratio(nHdummy),CS_tev_cs_hjWm_ratio(nHdummy),& 
 !     &          CS_tev_dd_hjZ_ratio(nHdummy),CS_tev_uu_hjZ_ratio(nHdummy),  &
 !     &          CS_tev_ss_hjZ_ratio(nHdummy),CS_tev_cc_hjZ_ratio(nHdummy),  &
 !     &          CS_tev_bb_hjZ_ratio(nHdummy),                               &
 !     &          CS_tev_pp_vbf_ratio(nHdummy),                               &
 !     &          BR_hjbb(nHdummy),BR_hjtautau(nHdummy),                      &
 !     &          BR_hjWW(nHdummy),BR_hjgaga(nHdummy),                        &
 !     &          BR_hjhihi_nHbynH(nHdummy,nHdummy)
 ! !---------------------------------------output
 ! integer ::     HBresult,chan,ncombined
 ! double precision :: obsratio
 ! !-----------------------------------------------
 !	  
 ! call attempting_to_use_an_old_HB_version('part')
 !
 !end subroutine run_HiggsBounds_part
 !!************************************************************	
 !subroutine run_HiggsBounds_hadr(nHdummy,Mh,                  &
 !     &          CS_lep_hjZ_ratio,CS_lep_hjhi_ratio_nHbynH,   &
 !     &          CS_tev_pp_hj_ratio, CS_tev_pp_hjb_ratio,     &
 !     &          CS_tev_pp_hjW_ratio,CS_tev_pp_hjZ_ratio,     &
 !     &          CS_tev_pp_vbf_ratio,                         &
 !     &          BR_hjbb,BR_hjtautau,                         &
 !     &          BR_hjWW,BR_hjgaga,                           &
 !     &          BR_hjhihi_nHbynH,                            &
 !     &          HBresult,chan,                               &
 !     &          obsratio, ncombined                          )
 !! Obsolete subroutine
 !!************************************************************
 !
 ! implicit none
 ! !----------------------------------------input
 ! integer,intent(in) :: nHdummy
 ! double precision,intent(in) :: Mh(nHdummy),              &
 !     &          CS_lep_hjZ_ratio(nHdummy),                &
 !     &          CS_lep_hjhi_ratio_nHbynH(nHdummy,nHdummy),&
 !     &          CS_tev_pp_hj_ratio(nHdummy),              &
 !     &          CS_tev_pp_hjb_ratio(nHdummy),             &
 !     &          CS_tev_pp_hjW_ratio(nHdummy),             &
 !     &          CS_tev_pp_hjZ_ratio(nHdummy),             &
 !     &          CS_tev_pp_vbf_ratio(nHdummy),             &
 !     &          BR_hjbb(nHdummy),BR_hjtautau(nHdummy),    &
 !     &          BR_hjWW(nHdummy),BR_hjgaga(nHdummy),      &
 !     &          BR_hjhihi_nHbynH(nHdummy,nHdummy)
 ! !---------------------------------------output
 ! integer ::     HBresult,chan,ncombined
 ! double precision :: obsratio
 ! !---------------------------------------------
 !
 ! call attempting_to_use_an_old_HB_version('hadr')
 !
 !
 !end subroutine run_HiggsBounds_hadr
 !!************************************************************	
Index: trunk/HiggsBounds_KW/example_data/HB_randomtest50points_HiggsBounds_results.dat-for-comparison
===================================================================
--- trunk/HiggsBounds_KW/example_data/HB_randomtest50points_HiggsBounds_results.dat-for-comparison	(revision 505)
+++ trunk/HiggsBounds_KW/example_data/HB_randomtest50points_HiggsBounds_results.dat-for-comparison	(revision 506)
@@ -1,90 +1,90 @@
- # generated with HiggsBounds version 4.2.0 on 12.12.2014 at 16:29
+ # generated with HiggsBounds version 4.2.0 on 12.12.2014 at 17:27
  # settings: LandH, part
  #
  # column abbreviations
  #   n          : line id of input
  #   Mh(i)      : Neutral Higgs boson masses in GeV
  #   Mhplus(i)  : Charged Higgs boson masses in GeV
  #   HBresult   : scenario allowed flag (1: allowed, 0: excluded, -1: unphysical)
  #   chan       : most sensitive channel (see below). chan=0 if no channel applies
  #   obsratio   : ratio [sig x BR]_model/[sig x BR]_limit (<1: allowed, >1: excluded)
  #   ncomb      : number of Higgs bosons combined in most sensitive channel
  #   additional : optional additional data stored in <prefix>additional.dat (e.g. tan beta)
  #
  # channel numbers used in this file
  #           4 : (e e)->(h1)Z->(tau tau)Z   (hep-ex/0602042, table 14c (LEP))
  #           7 : (e e)->(h1)Z->(...)Z   (hep-ex/0206022 (OPAL))
  #           8 : (e e)->(h2)Z->(...)Z   (hep-ex/0206022 (OPAL))
  #           9 : (e e)->(h3)Z->(...)Z   (hep-ex/0206022 (OPAL))
  #          15 : (e e)->(h3)Z->(gamma gamma)Z   (LHWG Note 2002-02)
  #          18 : (e e)->(h3)Z->(2 jets)Z   (LHWG (unpublished))
  #          21 : (e e)->(h3)Z->(2 jets)Z   (hep-ex/0107034 (LHWG))
  #          85 : (ee)->(h1 h1)->(tau tau tau tau)   (hep-ex/0602042, table 19 (LEP))
  #          89 : (ee)->(h2 h2)->(tau tau tau tau)   (hep-ex/0602042, table 19 (LEP))
  #          93 : (ee)->(h3 h3)->(tau tau tau tau)   (hep-ex/0602042, table 19 (LEP))
  #         131 : (p p-bar)->Z(h2)->l l (b b-bar)   (CDF Note 10799)
  #         172 : (p p)->h1(VBF)->V (invisible)   ([hep-ex] arXiv:1404.1344 (CMS))
  #         192 : (p p-bar)->h3->W W   (CDF Note 10599)
  #         228 : (p p)->h3(VBF)->WW   (CMS-PAS-HIG-13-022)
  #         268 : (p p)->h1/ggF h->Z Z-> l l l l (ATLAS-CONF-2013-013)
  #         270 : (p p)->h3/ggF h->Z Z-> l l l l (ATLAS-CONF-2013-013)
  #         271 : (p p)->h1/VBF/V h->Z Z-> l l l l (ATLAS-CONF-2013-013)
  #         273 : (p p)->h3/VBF/V h->Z Z-> l l l l (ATLAS-CONF-2013-013)
  #         412 : (p p)->h1/VBF/Wh1/Zh1/tth1->gamma gamma  ([hep-ex] arXiv:1407.6583)
  #         413 : (p p)->h2/VBF/Wh2/Zh2/tth2->gamma gamma  ([hep-ex] arXiv:1407.6583)
  #         414 : (p p)->h3/VBF/Wh3/Zh3/tth3->gamma gamma  ([hep-ex] arXiv:1407.6583)
  #         508 :(pp)->h2->tautau, using -2ln(L) reconstruction  ([hep-ex] arXiv:1408.3316 (CMS))
  # (for full list of processes, see Key.dat)
  #
  #cols:  n           Mh(1)           Mh(2)           Mh(3)       Mhplus(1)  HBresult  chan    obsratio     ncomb   additional(1)   additional(2)
  #
              1     359.121         159.618         337.305         71.6423         0   413     514689.         1     0.00000        0.592460    
              2     83.8032         49.2839         220.782         357.500         0   414    0.165707E+07     1     0.00000         0.00000    
              3     85.8826         249.094         179.329         238.330         0   508     29127.1         1     0.00000         0.00000    
              4     127.520         164.372         55.4257         322.887         0    15     15141.7         1     0.00000        0.294416E-01
              5     70.6587         359.723         130.202         6.50796         0     7     154123.         1     0.00000         0.00000    
              6     169.400         70.6569         323.343         41.3798         0   413     17154.1         1    0.333513        0.802317    
              7     38.1288         47.7534         112.361         273.425         0    18     29.4229         1     0.00000        0.670977    
              8     137.482         89.2260         191.735         26.2198         0   414     39689.7         1    0.678461E-01     0.00000    
              9     57.2973         277.236         120.915         345.145         0    85     349.785         1    0.419713         0.00000    
             10     269.812         185.721         161.594         234.695         0   271     148.547         1    0.258086        0.322748    
             11     29.5216         264.171         200.460         337.761         0   414     350544.         1     0.00000        0.528913    
             12     282.543         48.0135         273.487         137.955         0   172     884.031         1     0.00000         0.00000    
             13     321.618         57.8368         108.141         58.0303         0   414    0.495151E+07     1    0.579861        0.210765    
             14     25.3174         86.0196         215.979         50.9341         0   414     23428.0         1    0.490045        0.671123    
             15     182.003         168.197         239.773         353.488         0   414     1664.70         1    0.257430        0.241756    
             16     172.629         170.290         331.271         213.331         0   412     13344.0         1    0.256373        0.134367    
             17     43.1592         7.10876         334.029         136.449         0   414     21791.8         1    0.412981         0.00000    
             18     260.351         241.117         52.8639         236.306         0   412     42705.3         1    0.981251         0.00000    
             19     184.389         201.275         93.1450         17.1938         0   413     248082.         1    0.339361         0.00000    
             20     318.588         182.282         96.7497         163.509         0   412     18750.2         1     0.00000         0.00000    
             21     116.354         76.5644         220.670         2.32286         0   270     18581.5         1    0.996861        0.345883    
             22     42.4572         17.0286         95.6197         93.7070         0     7     81126.2         1     0.00000        0.508411    
             23     267.868         323.640         297.323         33.2555         0   273     1652.60         1    0.942210         0.00000    
             24     195.062         277.485         286.385         173.057         0   270     5887.95         1    0.495710        0.293892    
             25     63.7171         236.923         179.568         247.528         0   228     677.382         1    0.570381E-02     0.00000    
             26     201.333         154.946         40.1986         78.0106         0     9     33794.8         1     0.00000        0.183563    
             27     316.921         99.1857         134.244         90.8209         0   412     163.540         1     0.00000         0.00000    
             28     43.1417         109.812         49.9498         358.450         0   131     124.850         1     0.00000        0.389621    
             29     32.9300         2.50641         307.458         29.2709         0     7     194769.         1     0.00000         0.00000    
             30     179.403         186.978         174.798         89.4833         0   414     3751.19         1    0.326535         0.00000    
             31     129.581         28.5000         253.953         353.162         0   414     288685.         1    0.665685        0.198533    
             32     209.172         99.8650         35.5228         337.892         0   268     251.501         1    0.443801         0.00000    
             33     28.7356         264.683         166.743         258.544         0   414     6287.95         1     0.00000        0.785404E-01
             34     173.633         330.726         107.045         225.501         0    21     1473.65         1    0.324846         0.00000    
             35     54.6512         32.6453         283.236         294.189         0   414     813097.         1     0.00000        0.938392    
             36     146.064         285.733         149.044         71.6345         0   412     44036.5         1    0.897355         0.00000    
             37     24.7264         115.334         203.394         204.786         0   270     2744.03         1    0.528866E-02    0.356043    
             38     85.8442         307.707         52.0641         243.525         0     4     91729.3         1     0.00000        0.188661    
             39     259.486         349.551         16.4252         206.723         0   412     129721.         1    0.111999        0.374511    
             40     66.0497         66.4642         133.639         295.482         0    89     6279.38         1     0.00000         0.00000    
             41     207.530         321.571         285.256         100.629         0   413     1669.88         1     0.00000         0.00000    
             42     2.33050         206.329         261.763         340.230         0   414     3984.89         1     0.00000         0.00000    
             43     259.148         77.5749         352.402         203.247         0     8     7689.18         1     0.00000        0.162866    
             44    0.530648E-01     11.4247         52.8747         166.918        -1    93    0.127099E-08     1     0.00000        0.128263    
             45     187.493         107.107         173.738         247.540         0   192     379.124         1     0.00000        0.444294    
             46     199.313         231.562         168.755         84.5395         0   413     6860.53         1     0.00000        0.815096    
             47     7.13980         179.589         354.651         182.860         0   414     2518.16         1     0.00000         0.00000    
             48     147.464         316.808         236.643         232.922         0   412    0.121490E+07     1     0.00000        0.145378    
             49     241.435         179.680         156.465         256.995         0   412     62640.9         1     0.00000        0.183243    
             50     280.002         215.162         175.263         178.551         0   413     60262.5         1    0.673905         0.00000    
Index: trunk/HiggsBounds_KW/likelihoods.F90
===================================================================
--- trunk/HiggsBounds_KW/likelihoods.F90	(revision 505)
+++ trunk/HiggsBounds_KW/likelihoods.F90	(revision 506)
@@ -1,1088 +1,1088 @@
 ! This file is part of HiggsBounds
 !  -TS (23/09/2014)
 !******************************************************************
 module likelihoods
 !******************************************************************
 ! Some options:
  logical :: rescale = .False.
 
 !--
  type likelihood2D
   integer :: analysisID
   integer :: particle_x 
   character(LEN=45) :: label
   character(LEN=3) :: expt 
   double precision :: lumi, energy
   character(LEN=100) :: description
   double precision :: mass_sep
   double precision :: mass_range_tolerance
   double precision :: mass
   double precision :: xstep
   double precision :: ystep
   double precision :: xmin
   double precision :: xmax
   double precision :: ymin
   double precision :: ymax
   integer :: size
   integer :: xsize
   integer :: ysize  
   double precision, dimension(200,200) :: llhgrid_pred, llhgrid_obs
   double precision, dimension(1:3) :: bestfit_pred, bestfit_obs
  end type
  
  type threetuple
   double precision, dimension(1:3) :: val
  end type 
 
  integer, parameter :: nllhs = 1
 
 ! If more likelihoods become available (nllhs > 1), have to generalize this
 ! to a list of likelihoods
 
 ! CMS-3316 related stuff 
  integer, parameter :: n2Dslices = 38
  type(likelihood2D), dimension(1:n2Dslices) :: CMS_3316_data ! should be renamed to something more general at some point!
  
  contains
 !--------------------------------------------------------------
  subroutine setup_likelihoods
 !--------------------------------------------------------------
   use usefulbits, only : file_id_common4, Hneut
   use store_pathname, only : pathname  
 !  implicit none
   
   integer :: ios,i,j,status
   character(LEN=4) :: charstatus
   
 ! for CMS-3316 likelihoods
   integer :: analysisID = 3316   
   character(LEN=100) :: label = '[hep-ex] arXiv:1408.3316 (CMS)'
   character(LEN=100) :: description = '(pp) -> h -> tautau, using -2ln(L) reconstruction'
   character(LEN=100) :: stem = 'Expt_tables/CMStables/CMS_tautau_llh_1408.3316/'
 !  character(LEN=100) :: stem = 'Expt_tables/CMStables/CMS_tautau_llh_1408.3316_withSMHinBG/'
   character(LEN=3) :: expt = 'CMS'
   integer :: particle_type = Hneut
   double precision :: lumi = 19.7D0
   double precision :: energy = 8.0D0
   double precision :: mass_sep = 0.20D0  ! in percentage
   double precision :: mass_range_tolerance = 10.0D0 ! If the predicted mass lies outside the mass range within the tolerance,
                                                     ! the mass will be rounded to the closest value within the grid.
   double precision, dimension(1:n2Dslices) :: masses, xmin, xmax, ymin, ymax, xstep, ystep
   integer, dimension(1:n2Dslices) :: xsize, ysize
   
 
   masses = (/ 90.0D0, 100.0D0, 110.0D0, 120.0D0, 125.0D0, 130.0D0, 140.0D0, &
 &            150.0D0, 160.0D0, 170.0D0, 180.0D0, 190.0D0, 200.0D0, 210.0D0,&
 &            220.0D0, 230.0D0, 240.0D0, 250.0D0, 275.0D0, 300.0D0, 325.0D0,&
 &            350.0D0, 375.0D0, 400.0D0, 425.0D0, 450.0D0, 475.0D0, 500.0D0,&
 &            550.0D0, 600.0D0, 650.0D0, 700.0D0, 750.0D0, 800.0D0, 850.0D0,&
 &            900.0D0, 950.0D0, 1000.0D0 /)
   xmin = (/ 0.1750000, 0.1000000, 0.0300000, 0.0250000, 0.0250000, 0.0150000, 0.0075000,&
 &         0.0050000, 0.0037500, 0.0025000, 0.0025000, 0.0025000, 0.0020000, 0.0020000,&
 &         0.0020000, 0.0020000, 0.0015000, 0.0012500, 0.0010000, 0.0005000, 0.0004500,&
 &         0.0003750, 0.0003750, 0.0003750, 0.0003250, 0.0002500, 0.0002000, 0.0001250,&
 &         0.0001000, 0.0000750, 0.0000700, 0.0000625, 0.0000575, 0.0000500, 0.0000500,&
 &         0.0000375, 0.0000375, 0.0000375/)
   xmax = (/69.8250000,39.9000000,11.9700000, 9.9750000, 9.9750000, 5.9850000, 2.9925000,&
 &         1.9950000, 1.4962500, 0.9975000, 0.9975000, 0.9975000, 0.7980000, 0.7980000,&
 &         0.7980000, 0.7980000, 0.5985000, 0.4987500, 0.3990000, 0.1995000, 0.1795500,&
 &         0.1496250, 0.1496250, 0.1496250, 0.1296750, 0.0997500, 0.0798000, 0.0498750,&
 &         0.0399000, 0.0299250, 0.0279300, 0.0249375, 0.0229425, 0.0199500, 0.0199500,&
 &         0.0149625, 0.0149625, 0.0149625/)
   ymin = (/ 0.0325000, 0.0200000, 0.0175000, 0.0087500, 0.0087500, 0.0062500, 0.0062500,&
 &         0.0050000, 0.0037500, 0.0030000, 0.0025000, 0.0025000, 0.0022500, 0.0020000,&
 &         0.0017500, 0.0015000, 0.0015000, 0.0010000, 0.0008750, 0.0005000, 0.0004500,&
 &         0.0003000, 0.0003000, 0.0003000, 0.0002500, 0.0002000, 0.0001750, 0.0001500,&
 &         0.0001250, 0.0000750, 0.0000700, 0.0000625, 0.0000625, 0.0000625, 0.0000625,&
 &         0.0000625, 0.0000625, 0.0000625/)
   ymax = (/12.9675000, 7.9800000, 6.9825000, 3.4912500, 3.4912500, 2.4937500, 2.4937500,&
 &         1.9950000, 1.4962500, 1.1970000, 0.9975000, 0.9975000, 0.8977500, 0.7980000,&
 &         0.6982500, 0.5985000, 0.5985000, 0.3990000, 0.3491250, 0.1995000, 0.1795500,&
 &         0.1197000, 0.1197000, 0.1197000, 0.0997500, 0.0798000, 0.0698250, 0.0598500,&
 &         0.0498750, 0.0299250, 0.0279300, 0.0249375, 0.0249375, 0.0249375, 0.0249375,&
 &         0.0249375, 0.0249375, 0.0249375/)
   xstep = (/0.350, 0.200, 0.060, 0.050, 0.050, 0.030, 0.015,&
 &         0.010, 0.0075, 0.0050, 0.0050, 0.0050, 0.0040, 0.0040,&
 &         0.0040, 0.0040, 0.0030, 0.0025, 0.0020, 0.0010, 0.00090,&
 &         0.00075, 0.00075, 0.00075, 0.00065, 0.00050, 0.00040, 0.00025,&
 &         0.00020, 0.00015, 0.00014, 0.000125, 0.000115, 0.00010, 0.00010,&
 &         0.000075, 0.000075, 0.000075/)
   ystep = (/0.065, 0.040, 0.035, 0.0175, 0.0175, 0.0125, 0.0125,&
 &         0.010, 0.0075, 0.0060, 0.0050, 0.0050, 0.0045, 0.0040,&
 &         0.0035, 0.0030, 0.0030, 0.0020, 0.00175, 0.00100, 0.00090,&
 &         0.00060, 0.00060, 0.00060, 0.00050, 0.00040, 0.00035, 0.00030,&
 &         0.00025, 0.00015, 0.00014, 0.000125, 0.000125, 0.000125, 0.000125,&
 &         0.000125, 0.000125, 0.000125/)
   xsize = (/ 200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200/)
   ysize = (/ 200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200,  200,  200,  200,  200,&
 &          200,  200,  200/)
   
  open(file_id_common4,file = trim(adjustl(pathname))// &
  &    '/Expt_tables/CMS_tautau_llh_1408.3316.binary',form='unformatted')
  read(file_id_common4,iostat=ios) CMS_3316_data
 
  if(ios.ne.0)then
   do j=1,n2Dslices
    call write_metadata(analysisID,label,description,expt,lumi,energy,particle_type,&
 & mass_sep,mass_range_tolerance,masses(j),xmin(j),xmax(j),xstep(j),xsize(j),ymin(j),&
 & ymax(j),ystep(j),ysize(j),CMS_3316_data(j))
    call read2Ddata(masses(j),CMS_3316_data(j),stem,'obs',status)
    if(status.ne.0) stop 'Error in setup_likelihoods: Data files not found!'
    call read2Ddata(masses(j),CMS_3316_data(j),stem,'pred',status)
    if(status.ne.0) stop 'Error in setup_likelihoods: Data files not found!'
   enddo
 !  write(*,*) 'Creating binaries...'
 #ifndef WEBVERSION
   rewind(file_id_common4)
   write(file_id_common4) CMS_3316_data
 #endif  
  endif
 
  close(file_id_common4)
 !--------------------------------------------------------------
   end subroutine setup_likelihoods
 !--------------------------------------------------------------
  subroutine write_metadata(analysisID,label,description,expt,lumi,energy,particle_type,&
  &                         mass_sep,mass_range_tolerance,mass,xmin,xmax,xstep,xsize,ymin,&
  &                         ymax,ystep,ysize,llh2D)
 !--------------------------------------------------------------  
   use usefulbits, only : small
   implicit none
   
   integer, intent(in) :: analysisID,particle_type
   character(LEN=*),intent(in) :: label, description,expt  
   double precision, intent(in) :: mass_sep,mass,xmin,xmax,ymin,ymax,xstep,ystep,lumi,&
  &                                energy,mass_range_tolerance
   integer, intent(in) :: xsize, ysize
   type(likelihood2D), intent(inout) :: llh2D
 
 
   llh2D%analysisID = analysisID
   llh2D%label = trim(adjustl(label))
   llh2D%description = trim(adjustl(description))
   llh2D%expt = expt
   llh2D%energy = energy
   llh2D%lumi = lumi
   llh2D%particle_x = particle_type
   llh2D%mass_sep = mass_sep
   llh2D%mass_range_tolerance = mass_range_tolerance
   llh2D%mass = mass
   llh2D%xmin = xmin
   llh2D%xmax = xmax
   llh2D%xstep = xstep
   llh2D%xsize = xsize  
   llh2D%ymin = ymin
   llh2D%ymax = ymax
   llh2D%ystep = ystep
   llh2D%ysize = ysize  
 
 !  if(abs((xmax-xmin)/xstep+1.-xsize).gt.small) then
 !   write(*,*) 'Warning: xsize does not match: ',(xmax-xmin)/xstep+1,' vs. ', xsize
 !  endif
 !  if(abs((ymax-ymin)/ystep+1.-ysize).gt.small) then
 !   write(*,*) 'Warning: ysize does not match: ',(ymax-ymin)/ystep+1,' vs. ', ysize
 !  endif
 !-------------------------------------------------------------- 
  end subroutine write_metadata 
 !-------------------------------------------------------------- 
  subroutine read2Ddata(mass,llh2D,stem,obspred,status)
 !--------------------------------------------------------------
   use usefulbits, only : small,file_id_common2
   use store_pathname, only : pathname
   implicit none
   
   double precision, intent(in) :: mass
   type(likelihood2D), intent(inout) :: llh2D
   character(LEN=*), intent(in) :: stem,obspred
   integer, intent(out) :: status
   
   integer :: size,i,j,k,remove,posx,posy
   double precision, dimension(1:3) :: values
   type(threetuple), allocatable :: dummylikelihood(:), likelihood(:)
   double precision, dimension(200,200) :: llhgrid  
   double precision, dimension(1:3) :: bestfit
   character(LEN=4) :: intstring
   character(LEN=100) ::  filename
   double precision :: modx, mody  
 
   write(intstring,"(I4)") int(mass)  
   if(trim(adjustl(obspred)).eq.'obs') then
 !   filename = 'L_data_SMHb_'//trim(adjustl(intstring))//'.out'
    filename = 'L_data_b_'//trim(adjustl(intstring))//'.out'   
   else if(trim(adjustl(obspred)).eq.'pred') then
 !   filename = 'L_asimovSMH_SMHb_'//trim(adjustl(intstring))//'.out'
    filename = 'L_asimov_b_'//trim(adjustl(intstring))//'.out'   
   else
    stop 'Error in read2Ddata: obspred unknown.'   
   endif 
 
   llh2D%mass = mass
 
   call get_length_of_file(trim(adjustl(pathname))//trim(adjustl(stem))// &
   &                       trim(adjustl(filename)),size,status)
   if(status.ne.0) return
   
   open(file_id_common2,file=trim(adjustl(pathname))//trim(adjustl(stem))// &
   &                         trim(adjustl(filename)))
      
   allocate(dummylikelihood(size))  
   
   k=0
   remove=0
   do i=1, size
    read(file_id_common2,*) values
    if(values(3).eq.0.0D0) then
     bestfit = values
     remove = remove + 1
    else 
     k=k+1
     dummylikelihood(k)%val = values
    endif 
   enddo
 
   close(file_id_common2)
 
   llh2D%size = k
     
   allocate(likelihood(k))
   
   do i=1,k
    likelihood(i)%val = dummylikelihood(i)%val
   enddo 
   
   deallocate(dummylikelihood)
 !  write(*,*) 'size = ',llh2D%size
 
   
   llhgrid = 0.0D0
   
   do i=lbound(likelihood,dim=1),ubound(likelihood,dim=1)
 
    posx = nint((likelihood(i)%val(1)-llh2D%xmin)/llh2D%xstep)+1
    posy = nint((likelihood(i)%val(2)-llh2D%ymin)/llh2D%ystep)+1
    llhgrid(posx,posy) = likelihood(i)%val(3)     
   enddo
  
 !  k=0
 !  do i=1,llh2D%xsize
 !   do j=1, llh2D%ysize
 !    if(llhgrid(i,j).lt.small) then
 !     k=k+1
 !!     write(*,*) i,j,llh2D%llhgrid(i,j)
 !    endif
 !   enddo
 !  enddo   
 !  write(*,*) k, 'grid points are unfilled!'    
  
   if(trim(adjustl(obspred)).eq.'obs') then
    llh2D%llhgrid_obs = llhgrid
    llh2D%bestfit_obs = bestfit
   else if(trim(adjustl(obspred)).eq.'pred') then
    llh2D%llhgrid_pred = llhgrid
    llh2D%bestfit_pred = bestfit
   endif 
  
   deallocate(likelihood)
 !--------------------------------------------------------------     
  end subroutine read2Ddata
  !--------------------------------------------------------------
  subroutine get_likelihood(analysisID, jj, t, llh, M_av, nc, cbin, obspred, cbin_in)
  !--------------------------------------------------------------
   use usefulbits, only : dataset
   implicit none
  
   type(dataset), intent(in) :: t
   integer, intent(in) :: analysisID, jj
   character(LEN=*), intent(in) :: obspred  
   double precision, intent(out) :: llh,M_av    
   integer, intent(out) :: nc, cbin
   integer, optional, intent(in) :: cbin_in   
   double precision :: cfact1,cfact2
   
-  llh = -1.0D0
+  llh = 0.0D0
     
    select case(analysisID)
     case(3316)
      if(present(cbin_in)) then
 !      write(*,*) "Calling get_likelihood with cbin_in = ", cbin_in, ", obspred = ", obspred
       call calcfact_llh(1,jj,t,cfact1,cfact2,M_av,nc,cbin,cbin_in)
      else
       call calcfact_llh(1,jj,t,cfact1,cfact2,M_av,nc,cbin)     
      endif
      if(cbin.ne.0) then
       llh = get_llh_CMS_tautau_3316(M_av, cfact1, cfact2, obspred)
      endif 
 !     write(*,*) jj, cfact1, cfact2, M_av, nc, cbin, "llh = ", llh
 !     if(nc.eq.3) then
 !      write(*,*) "nc=3: ", jj, cfact1, cfact2, M_av, llh
 !     endif      
     case default
      stop 'Error: Unknown analysis ID to retrieve chi^2 value.'
    end select   
    
  end subroutine get_likelihood
   
   !--------------------------------------------------------------
  subroutine calcpredratio_llh(c,jj,t,M_av,fact,nc,predratio)
  !--------------------------------------------------------------
   use usefulbits, only : dataset,small,vsmall
   implicit none
     
  !prsep(h,n)%tlist,prsep(h,n)%findj,t,axis_i(n),ncomb(n),predratio(n)
   type(dataset), intent(in) :: t
   integer, intent(in) :: c,jj 
   double precision, intent(out) :: M_av, predratio, fact
   integer, intent(out) ::  nc
  
   double precision :: cfact1,cfact2
   double precision :: sf, expllh, interval,expllh0
   double precision :: diff(2)
   integer :: kk, cbin
 
   double precision sf_low,sf_high,llh_low,llh_high, sf_max
 
 
   call calcfact_llh(c,jj,t,cfact1,cfact2,M_av,nc,cbin)
   fact = cfact1 + cfact2
  
   expllh = get_llh_CMS_tautau_3316(M_av, cfact1, cfact2, 'pred')
   expllh0 = expllh
 !  write(*,*) 'c = ',c,' jj = ',jj,'nc = ',nc,' M_av = ', M_av, 'ggH = ',cfact1, 'bbH = ',cfact2
   
   
   if(cfact1.lt.small.and.cfact2.lt.small) then
 !   write(*,*) 'Very small cross sections. CMS tautau is not competitive, expected llh =',expllh
    predratio = -1.0D0   
    return
   endif
      
 !  write(*,*) "Find predicted ratio..."
   if(expllh.lt.0.0D0) then
    predratio = -1.0D0
    return
 ! NEW
   endif
  
 !  sf = 1.0D0
 !  kk = 0
 !  interval = 0.0005D0  
 !  interval = 0.50D0  
 !  diff = 0.0D0  
   
 ! TS implementation  
 !  do while(abs(expllh-5.99D0).gt.0.01D0)
 !   kk = kk + 1
 !   if(abs(diff(2)-diff(1)).le.vsmall) then
 !    interval = 0.5D0*sf
 !   else    
 !    interval = min(abs(rand(0)*interval/(diff(2)-diff(1))),0.5D0*sf)
 !   endif 
 !   
 !   sf = sf + sign(1.0D0,5.99D0-expllh)*interval
 !   if (sf.le.0.0D0) exit    
 !   
 !   diff(2)=abs(expllh-5.99D0)
 !   
 !   expllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'pred')
 !   
 !   diff(1)=abs(expllh-5.99D0)
 !   
 !!   write(*,*) kk, sf, interval, diff(1), diff(2), expllh
 !  enddo
   
 
 ! OS implementation of bisection
 ! Maximum scale factor corresponds to min_predratio=1/sf_max
   sf_max = 1.d0
   llh_high = get_llh_CMS_tautau_3316(M_av, sf_max*cfact1, sf_max*cfact2, 'pred')
   kk=0
   do while(llh_high-5.99d0.lt.0d0.and.kk.lt.100)
    sf_max = sf_max*10.d0
    llh_high = get_llh_CMS_tautau_3316(M_av, sf_max*cfact1, sf_max*cfact2, 'pred')
    kk=kk+1
   enddo
 
 
   sf_low = 0.d0
   sf_high = sf_max
   kk=0  
 
   sf = (sf_high+sf_low)/2.
 
   llh_low = get_llh_CMS_tautau_3316(M_av, sf_low*cfact1, sf_low*cfact2, 'pred')
   llh_high = get_llh_CMS_tautau_3316(M_av, sf_high*cfact1, sf_high*cfact2, 'pred')
 
   ! Check that root exists in starting interval
   if ((llh_low-5.99)*(llh_high-5.99).ge.0) then
     sf = sf_max
   else
    expllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'pred')
    
 !   write(*,*) kk, sf_low, sf_high, sf, expllh  
    do while(abs(expllh-5.99D0).gt.0.01D0.and.kk.lt.100)
    
     ! Five digit precision on scale factor in case of oscillating solutions
     if ((sf_high-sf_low).LT.1D-5) exit     
    
     kk = kk + 1
     if((expllh-5.99d0).lt.0) sf_low = sf
     if((expllh-5.99d0).gt.0) sf_high= sf
     sf = (sf_high+sf_low)/2.
    
     expllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'pred')
       
 !    write(*,*) kk, sf_low, sf_high, sf, expllh
    enddo
   endif
   
   if( kk.ge.100) write(*,*) 'Warning: Maximum number of iterations reached with no convergence: predratio might be unreliable.'
 !      write(*,*) kk, sf_low, sf_high, sf, expllh
 
     
 !  write(*,*) "Ended predratio finder for h",jj," (",nc," combined, average mass = "&
 !  &   ,M_av,") with ",kk,"steps: scalefactor = ", sf,", original -2ln(L) = ",expllh0    
 ! --
 
 !  elseif(expllh.gt.5.99D0) then
 !   do while(expllh.gt.5.99D0)
 !
 !! Adjust scanning intervals to distance
 !    kk = kk + 1 
 !    if(abs(expllh-5.99D0) > 2.5D0) then
 !     interval = 0.05D0
 !    elseif(abs(expllh-5.99D0) > 0.5D0) then
 !     interval = 0.01D0
 !    elseif(abs(expllh-5.99D0) > 0.25D0) then
 !     interval = 0.001D0 
 !    elseif(abs(expllh-5.99D0) > 0.05D0) then
 !     interval = 0.0005D0 
 !    endif
 !     
 !    sf = sf - interval
 !    if (sf.le.0.0D0) exit
 !    
 !    expllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'pred')
 !    
 !    write(*,*) kk, sf, interval, expllh
 !   enddo
 !  elseif(expllh.lt.5.99D0) then
 !   do while(expllh.lt.5.99D0)
 !
 !! Adjust scanning intervals to distance
 !    kk = kk + 1 
 !    if(abs(expllh-5.99D0) > 2.5D0) then
 !     interval = 0.05D0
 !    elseif(abs(expllh-5.99D0) > 0.5D0) then
 !     interval = 0.01D0
 !    elseif(abs(expllh-5.99D0) > 0.25D0) then
 !     interval = 0.001D0 
 !    elseif(abs(expllh-5.99D0) > 0.05D0) then
 !     interval = 0.0005D0 
 !    endif
 !     
 !    sf = sf + interval
 !    expllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'pred')
 !    
 !    write(*,*) kk, sf, interval, expllh
 !   enddo    
 !  endif
   
   if(sf.le.0.0D0) sf = 1.0D-10
 
   predratio = 1./sf 
  
  end subroutine calcpredratio_llh 
  !--------------------------------------------------------------
  subroutine check_against_bound_llh(c,jj,t,M_av,nc,obsratio) 
  !-------------------------------------------------------------- 
   use usefulbits, only : dataset,vsmall
   implicit none
   
   type(dataset), intent(in) :: t
   integer, intent(in) :: c,jj , nc
   double precision, intent(in) :: M_av
   double precision, intent(out) :: obsratio
  
   double precision :: cfact1,cfact2
   double precision :: sf, obsllh,M_av2, interval,obsllh0
   double precision :: diff(2)  
   integer :: kk,nc2,cbin
   
   double precision sf_low,sf_high,llh_low,llh_high,sf_max
 
   call calcfact_llh(c,jj,t,cfact1,cfact2,M_av2,nc2,cbin)
  
   if(abs(M_av2-M_av).gt.vsmall.or.nc.ne.nc2) then
    write(*,*) M_av2, M_av, nc, nc2
    stop 'Error in subroutine check_against_bound_llh !'
    
   endif 
  
   obsllh = get_llh_CMS_tautau_3316(M_av, cfact1, cfact2, 'obs')
   obsllh0 = obsllh
   
 !  write(*,*) "Find observed ratio..."
   if(obsllh.lt.0.0D0) then
    obsratio = -1.0D0
    return
   endif 
    
   sf = 1.0D0
   kk = 0
   interval = 0.50D0  
   diff = 0.0D0  
 
 !! TS implementation  
 !  do while(abs(obsllh-5.99D0).gt.0.05D0)
 !   kk = kk + 1
 !   if(abs(diff(2)-diff(1)).le.vsmall) then
 !    interval = 0.5D0*sf
 !   else    
 !    interval = min(abs(rand(0)*interval/(diff(2)-diff(1))),0.5D0*sf)
 !   endif 
 !   
 !   sf = sf + sign(1.0D0,5.99D0-obsllh)*interval
 !   if (sf.le.0.0D0) exit    
 !   
 !   diff(2)=abs(obsllh-5.99D0)
 !   
 !   obsllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'obs')
 !   
 !   diff(1)=abs(obsllh-5.99D0)
 !
 !   write(*,*) kk, sf, interval, diff(1), diff(2), obsllh
 !   
 !  enddo
 
 
 !! OS implementation of bisection
   sf_max = 1.d0
   llh_high = get_llh_CMS_tautau_3316(M_av, sf_max*cfact1, sf_max*cfact2, 'obs')
   kk=0
   do while(llh_high-5.99d0.lt.0d0.and.kk.lt.100)
    sf_max = sf_max*10.d0
    llh_high = get_llh_CMS_tautau_3316(M_av, sf_max*cfact1, sf_max*cfact2, 'obs')
    kk=kk+1
   enddo
 
   sf_low = 0.d0
   sf_high = sf_max
   kk=0
 
   sf = (sf_high+sf_low)/2.
 
   llh_low = get_llh_CMS_tautau_3316(M_av, sf_low*cfact1, sf_low*cfact2, 'obs')
   llh_high = get_llh_CMS_tautau_3316(M_av, sf_high*cfact1, sf_high*cfact2, 'obs')
 
   ! Check that root exists in starting interval
   if ((llh_low-5.99d0)*(llh_high-5.99d0).ge.0) then
     sf = sf_max
   else
    obsllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'obs')
 !   write(*,*) kk, sf_low, sf_high, sf, obsllh
      
    do while(abs(obsllh-5.99D0).gt.0.01D0.and.kk.lt.100)
    
     ! Five digit precision on scale factor in case of oscillating solutions
     if ((sf_high-sf_low).LT.1D-5) exit     
    
     kk = kk + 1
     if((obsllh-5.99d0).lt.0) sf_low = sf
     if((obsllh-5.99d0).gt.0) sf_high= sf
     sf = (sf_high+sf_low)/2.
    
     obsllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'obs')
       
 !    write(*,*) kk, sf_low, sf_high, sf, obsllh
    enddo
   endif
 
   if( kk.ge.100) write(*,*) 'Warning: Maximum number of iterations reached with no convergence: obsratio might be unreliable.'
   
 !  write(*,*) "Ended obsratio finder with ",kk,"steps: ", sf,obsllh, ", original -2ln(L) = ",obsllh0   
   
      
 !  elseif(obsllh.gt.5.99D0) then
 !   do while(obsllh.gt.5.99D0)
 !
 !! Adjust scanning intervals to distance
 !    kk = kk + 1 
 !    if(abs(obsllh-5.99D0) > 3.0D0) then
 !     interval = 0.05D0
 !    elseif(abs(obsllh-5.99D0) > 0.5D0) then
 !     interval = 0.01D0
 !    elseif(abs(obsllh-5.99D0) > 0.25D0) then
 !     interval = 0.001D0 
 !    elseif(abs(obsllh-5.99D0) > 0.05D0) then
 !     interval = 0.0005D0 
 !    endif
 !     
 !    sf = sf - interval
 !    if(sf.le.0.0D0) exit
 !    obsllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'obs')
 !    
 !    write(*,*) kk, sf, interval, obsllh
 !   enddo
 !  elseif(obsllh.lt.5.99D0) then
 !   do while(obsllh.lt.5.99D0)
 !
 !! Adjust scanning intervals to distance
 !    kk = kk + 1 
 !    if(abs(obsllh-5.99D0) > 3.0D0) then
 !     interval = 0.05D0
 !    elseif(abs(obsllh-5.99D0) > 0.5D0) then
 !     interval = 0.01D0
 !    elseif(abs(obsllh-5.99D0) > 0.25D0) then
 !     interval = 0.001D0 
 !    elseif(abs(obsllh-5.99D0) > 0.05D0) then
 !     interval = 0.0005D0 
 !    endif
 !     
 !    sf = sf + interval
 !    obsllh = get_llh_CMS_tautau_3316(M_av, sf*cfact1, sf*cfact2, 'obs')
 !    
 !    write(*,*) kk, sf, interval, obsllh
 !   enddo    
 !  endif
   
   if(sf.le.0.0D0) sf = 1.0D-10  
   obsratio = 1./sf 
    
  end subroutine check_against_bound_llh
 !-------------------------------------------------------------- 
  subroutine calcfact_llh(c,jj,t,cfact1,cfact2,M_av,nc,cbin,cbin_in)
  !-------------------------------------------------------------- 
  ! This routine calculates the predicted rates for each process
  ! Need to generalize this if more likelihoods become available.
   use usefulbits, only : dataset, np, div, vvsmall
   use theory_BRfunctions
   use theory_XS_SM_functions 
     
   implicit none      
   !--------------------------------------input
   type(dataset), intent(in) :: t
   integer, intent(in) :: c,jj
   integer, optional, intent(in) :: cbin_in
   !-----------------------------------output
   double precision, intent(out) :: cfact1, cfact2 ,M_av
   integer, intent(out) :: nc,cbin
   !-----------------------------------internal
   double precision,allocatable :: mass(:),fact1(:),fact2(:)
   integer :: npart,f,j !number of particles  
   double precision :: numerator, denominator
   logical, allocatable :: Havail(:)
   
   cfact1=0.0D0    
   cfact2=0.0D0    
   
   if(c.eq.1) then ! this is the CMS tautau likelihood
    npart=np( CMS_3316_data(1)%particle_x )
    allocate(mass(npart),fact1(npart),fact2(npart))
 
    mass(:)=t%particle( CMS_3316_data(1)%particle_x )%M(:) 
    fact1= 0.0D0
    fact2= 0.0D0      
 
   allocate(Havail(npart))
   
   if(present(cbin_in)) then
    call available_Higgses(Havail,npart,cbin_in)
   else
    Havail = .True.
   endif 
 
    
 !   write(*,*) 'calcfact_llh: mass = ', mass
    cbin = 0
    
    !write(*,*) "Calling calcfact_llh..."
    
    do j=1,npart
     if(Havail(j)) then    
 !   if(abs(mass(jj)-mass(j)).le.CMS_3316_data(1)%mass_sep*mass(jj))then
 !   if((abs(mass(jj)-mass(j)).le.CMS_3316_data(1)%mass_sep*100.0D0)) then 
    if(abs(mass(jj)-mass(j)).le.CMS_3316_data(1)%mass_sep*max(mass(jj),mass(j)))then     
       if((t%gg_hj_ratio(j).ge.0.0D0).and.(t%bb_hj_ratio(j).ge.0.0D0)) then
 !      write(*,*) "Using partonic input for CMS tautau analysis..."
        fact1(j)=t%gg_hj_ratio(j)*XS_lhc8_gg_H_SM(mass(j))*t%BR_hjtautau(j)
        fact2(j)=t%bb_hj_ratio(j)*XS_lhc8_bb_H_SM(mass(j))*t%BR_hjtautau(j)  
       else
 !      write(*,*) "Using hadronic input for CMS tautau analysis..."
        fact1(j)=t%lhc8%XS_hj_ratio(j)*XS_lhc8_gg_H_SM(mass(j))*t%BR_hjtautau(j)
        fact2(j)=t%lhc8%XS_hjb_ratio(j)*XS_lhc8_bb_H_SM(mass(j))*t%BR_hjtautau(j)  
       endif
       cbin = cbin + 2**(j-1)
 !     write(*,*) cbin
      endif
     endif 
    enddo
    
 !   write(*,*) 'calcfact_llh: fact1 = ', fact1
 !   write(*,*) 'calcfact_llh: fact2 = ', fact2
    
   if(fact1(jj).le.vvsmall.and.fact2(jj).le.vvsmall)then
 !Higgs jj doesn't contribute - wait until another call of this subroutine before
 !looking at nearby masses
    M_av = mass(jj)
    nc=0
    cfact1=0.0D0   
    cfact2=0.0D0      
   else
 !find M_av weighted by the rates (only using higgs which have non-zero fact): 
    f=0  
    numerator=0.0D0
    denominator=0.0D0
    do j=1,npart    
     if(   fact1(j).gt.vvsmall.or.fact2(j).gt.vvsmall  )then       
      f=f+1
      numerator=numerator+mass(j)*(fact1(j)+fact2(j))
      denominator=denominator+(fact1(j)+fact2(j))     
     endif
    enddo 
 
   if(denominator.ne.0.0D0) then
    M_av = numerator/denominator
   else
    M_av = 0.0D0
    write(*,*) 'Warning: could not find average mass for CMS tautau analysis!'
   endif  
 
   nc=f !f will always be > 0 because we've already made sure that fact(jj)>0.0D0
   cfact1=sum(fact1)
   cfact2=sum(fact2)
   endif
 
   deallocate(mass,fact1,fact2)
   deallocate(Havail)
      
   endif 
  end subroutine calcfact_llh 
 !--------------------------------------------------------------
  function get_llh_from_interpolation(llh2D, xval0, yval0,obspred)
  ! This routine returns the - 2 Delta ln(llh) from grid interpolation
 !-------------------------------------------------------------- 
  use usefulbits, only : small
   type(likelihood2D), intent(in) :: llh2D  
   double precision, intent(in) :: xval0, yval0
   character(LEN=*), intent(in) :: obspred  
   double precision :: get_llh_from_interpolation
   integer :: posx1, posx2, posy1, posy2, posxlow, posxup
   double precision :: xval, yval, xval1, xval2, yval1, yval2, fvaly1, fvaly2, fval
   integer :: i, max_expansion
   logical :: lowerxfound, upperxfound
   double precision, dimension(200,200) :: llhgrid
 
   if(trim(adjustl(obspred)).eq.'obs') then
    llhgrid = llh2D%llhgrid_obs
   else if(trim(adjustl(obspred)).eq.'pred') then
    llhgrid = llh2D%llhgrid_pred
   else
    stop 'Error in get_llh_from_interpolation: obspred unknown.'   
   endif 
 
 
   ! This number is the maximal number of tries, that the algorithm steps further up or
   ! downwards the grid in case of non-existent grid points.
   max_expansion = 3
 
   if(isnan(xval0)) then
    xval = 0.0D0
   else 
    xval = xval0
   endif
    
   if(isnan(yval0)) then
    yval = 0.0D0
   else 
    yval = yval0
   endif
 
 ! write(*,*) 'input x,y vals = ', xval0, xval, yval0,  yval
 
  if(xval.lt.llh2D%xmin) then
 !  write(*,*) 'Warning: ggH rate outside grid -- value too small.'
   xval = llh2D%xmin
  else if (xval.gt.llh2D%xmax) then
 !  write(*,*) 'Warning: ggH rate outside grid -- value too large.'
   xval = llh2D%xmax-small 
  endif 
  if(yval.lt.llh2D%ymin) then
 !  write(*,*) 'Warning: bbH rate outside grid -- value too small.'
   yval = llh2D%ymin
  else if (yval.gt.llh2D%ymax) then
 !  write(*,*) 'Warning: ggH rate outside grid -- value too large.'
   yval = llh2D%ymax -small
  endif 
 
 ! Get coordinates of neighboring points
  posx1 = (xval-llh2D%xmin) / llh2D%xstep + 1
  if(posx1.lt.llh2D%xsize) then
   posx2 = (xval-llh2D%xmin) / llh2D%xstep + 2
  else
   write(*,*) "Warning: on the edge of the grid in x-position!"
   posx1 = (xval-llh2D%xmin) / llh2D%xstep
   posx2 = (xval-llh2D%xmin) / llh2D%xstep + 1  
  endif
 
  posy1 = (yval-llh2D%ymin) / llh2D%ystep + 1 
  if(posy1.lt.llh2D%ysize) then 
   posy2 = (yval-llh2D%ymin) / llh2D%ystep + 2
  else
   write(*,*) "Warning: on the edge of the grid in y-position!" 
   posy1 = (yval-llh2D%ymin) / llh2D%ystep
   posy2 = (yval-llh2D%ymin) / llh2D%ystep + 1
  endif
   
  ! Get x,y values at these points
  xval1 = (posx1 - 1)*llh2D%xstep + llh2D%xmin
  xval2 = (posx2 - 1)*llh2D%xstep + llh2D%xmin
  yval1 = (posy1 - 1)*llh2D%ystep + llh2D%ymin
  yval2 = (posy2 - 1)*llh2D%ystep + llh2D%ymin
  
  ! Do bilinear interpolation and retrieve likelihood value
  if(llhgrid(posx1,posy1).ne.0.0D0.and.llhgrid(posx2,posy1).ne.0.0D0) then
   fvaly1 = (xval2 - xval) / (xval2 - xval1) * llhgrid(posx1,posy1) + &
   &        (xval - xval1) / (xval2 - xval1) * llhgrid(posx2,posy1)
  else if (llhgrid(posx1,posy1).ne.0.0D0) then
   fvaly1 = llhgrid(posx1,posy1)
  else if (llhgrid(posx2,posy1).ne.0.0D0) then
   fvaly1 = llhgrid(posx2,posy1)
  else
 !  write(*,*) 'Warning in interpolating grid: Both gridpoints in x-direction missing!'
 !  write(*,*) '(', xval1, yval1, '), (', xval2, yval1,')'
   lowerxfound = .False.
   upperxfound = .False.  
   do i=1,max_expansion
    if(posx1-i.gt.0) then
     if (llhgrid(posx1-i,posy1).ne.0.0D0) then
       xval1 = (posx1 - i - 1)*llh2D%xstep + llh2D%xmin
       lowerxfound = .True.
       posxlow = posx1-i
      endif 
     endif
    if(posx2+i.le.ubound(llhgrid,dim=1)) then 
     if (llhgrid(posx2+i,posy1).ne.0.0D0) then
       xval2 = (posx2 + i - 1)*llh2D%xstep + llh2D%xmin
       upperxfound = .True.
       posxup = posx2+i
      endif 
     endif
     if(lowerxfound.or.upperxfound) exit
    enddo 
    if(lowerxfound.and.upperxfound) then
     fvaly1 = (xval2 - xval) / (xval2 - xval1) * llhgrid(posxlow,posy1) + &
     &        (xval - xval1) / (xval2 - xval1) * llhgrid(posxup,posy1)
    else if(lowerxfound) then
     fvaly1 = llhgrid(posxlow,posy1)     
    else if(upperxfound) then
     fvaly1 = llhgrid(posxup,posy1)     
    else
     write(*,*) 'Found no surrounding points!'
     fvaly1 = 99999.0D0
    endif   
  endif  
    
  if(llhgrid(posx1,posy2).ne.0.0D0.and.llhgrid(posx2,posy2).ne.0.0D0) then 
   fvaly2 = (xval2 - xval) / (xval2 - xval1) * llhgrid(posx1,posy2) + &
   &        (xval - xval1) / (xval2 - xval1) * llhgrid(posx2,posy2)
  else if (llhgrid(posx1,posy2).ne.0.0D0) then
   fvaly2 = llhgrid(posx1,posy2)
  else if (llhgrid(posx2,posy2).ne.0.0D0) then
   fvaly2 = llhgrid(posx2,posy2)
  else
 !  write(*,*) 'Warning in interpolating grid: Both gridpoints in x-direction missing!'
 !  write(*,*) '(', xval1, yval2, '), (', xval2, yval2,')' 
   lowerxfound = .False.
   upperxfound = .False.  
   do i=1,max_expansion
    if(posx1-i.gt.0) then
     if (llhgrid(posx1-i,posy2).ne.0.0D0) then
       xval1 = (posx1 - i - 1)*llh2D%xstep + llh2D%xmin
       lowerxfound = .True.
       posxlow = posx1-i
      endif 
     endif
    if(posx2+i.le.ubound(llhgrid,dim=1)) then 
     if (llhgrid(posx2+i,posy2).ne.0.0D0) then
       xval2 = (posx2 + i - 1)*llh2D%xstep + llh2D%xmin
       upperxfound = .True.
       posxup = posx2+i
      endif 
     endif
 !    write(*,*) i, lowerxfound, upperxfound
     if(lowerxfound.or.upperxfound) exit
    enddo 
    if(lowerxfound.and.upperxfound) then
     fvaly2 = (xval2 - xval) / (xval2 - xval1) * llhgrid(posxlow,posy2) + &
     &        (xval - xval1) / (xval2 - xval1) * llhgrid(posxup,posy2)
    else if(lowerxfound) then
     fvaly2 = llhgrid(posxlow,posy2)     
    else if(upperxfound) then
     fvaly2 = llhgrid(posxup,posy2)     
    else
 !    write(*,*) 'Found no surrounding points!'
     fvaly2 = 99999.0D0
    endif   
  endif  
  
  fval =  (yval2 - yval) / (yval2 - yval1) * fvaly1 + &
  &       (yval - yval1) / (yval2 - yval1) * fvaly2
   
  ! we want to obtain - 2 * Delta log(likelihood) \simeq chi^2
  get_llh_from_interpolation = 2*fval
  return
  
  end function get_llh_from_interpolation
 !--------------------------------------------------------------  
  function get_llh_CMS_tautau_3316(mpred, rate1, rate2, obspred)
 !-------------------------------------------------------------- 
   use theory_XS_SM_functions, only : XS_lhc8_gg_H_SM, XS_lhc8_bb_H_SM
   use theory_BRfunctions, only : BRSM_Htautau
   
   implicit none
  
   double precision, intent(in) :: mpred, rate1, rate2
   character(LEN=*), intent(in) :: obspred
 
   double precision :: get_llh_CMS_tautau_3316
   double precision :: ggH1, bbH1, llh1, ggH2, bbH2, llh2, mpred_tmp
   integer :: i,j
 
   mpred_tmp = mpred
 
   if (mpred_tmp.lt.(CMS_3316_data(1)%mass-CMS_3316_data(1)%mass_range_tolerance)) then
 !   write(*,*) 'Warning: predicted mass below lowest mass value of CMS analysis.'
    get_llh_CMS_tautau_3316 = 0.0D0
   else if (mpred_tmp.gt.(CMS_3316_data(n2Dslices)%mass+CMS_3316_data(1)%mass_range_tolerance)) then
 !   write(*,*) 'Warning: predicted mass above highest mass value of CMS analysis.'
    get_llh_CMS_tautau_3316 = 0.0D0
   else 
    do i=lbound(CMS_3316_data,dim=1),ubound(CMS_3316_data,dim=1)-1
     if(mpred_tmp.lt.CMS_3316_data(1)%mass) then
      mpred_tmp = CMS_3316_data(1)%mass
     else if(mpred_tmp.gt.CMS_3316_data(n2Dslices)%mass) then
      mpred_tmp = CMS_3316_data(n2Dslices)%mass
     endif      
     if(((mpred_tmp - CMS_3316_data(i)%mass).ge.0.0D0).and.(mpred_tmp-CMS_3316_data(i+1)%mass.lt.0.0D0)) then
      ! Rescale to grid mass values by SM rate ratios
      if(rescale) then
       ggH1 = rate1 * XS_lhc8_gg_H_SM(CMS_3316_data(i)%mass) * BRSM_Htautau(CMS_3316_data(i)%mass) / &
 &                  ( XS_lhc8_gg_H_SM(mpred_tmp)           * BRSM_Htautau(mpred_tmp) )
       bbH1 = rate2 * XS_lhc8_bb_H_SM(CMS_3316_data(i)%mass) * BRSM_Htautau(CMS_3316_data(i)%mass) / &
 &                  ( XS_lhc8_bb_H_SM(mpred_tmp)           * BRSM_Htautau(mpred_tmp) )     
      else
 	  ggH1 = rate1      
       bbH1 = rate2
      endif 
      llh1 = get_llh_from_interpolation(CMS_3316_data(i),ggH1,bbH1,obspred)
 
 	 if(rescale) then     
       ggH2 = rate1*XS_lhc8_gg_H_SM(CMS_3316_data(i+1)%mass)*BRSM_Htautau(CMS_3316_data(i+1)%mass) / &
 &                ( XS_lhc8_gg_H_SM(mpred_tmp)           * BRSM_Htautau(mpred_tmp) )
       bbH2 = rate2*XS_lhc8_bb_H_SM(CMS_3316_data(i+1)%mass)*BRSM_Htautau(CMS_3316_data(i+1)%mass) / &
 &                ( XS_lhc8_bb_H_SM(mpred_tmp)           * BRSM_Htautau(mpred_tmp) )     
      else
       ggH2 = rate1
       bbH2 = rate2
      endif
       
      llh2 = get_llh_from_interpolation(CMS_3316_data(i+1),ggH2,bbH2,obspred)
 
       get_llh_CMS_tautau_3316 = llh1 + (mpred_tmp - CMS_3316_data(i)%mass)/(CMS_3316_data(i+1)%mass-CMS_3316_data(i)%mass) * &
 &                      (llh2 - llh1)
      exit
      else if(mpred_tmp-CMS_3316_data(i+1)%mass.eq.0.0D0) then
       get_llh_CMS_tautau_3316 = get_llh_from_interpolation(CMS_3316_data(i+1),rate1,rate2,obspred)
      endif 
    enddo
   endif
   return
 !-------------------------------------------------------------- 
  end function get_llh_CMS_tautau_3316 
 !-------------------------------------------------------------- 
  subroutine outputproc_llh(proc,file_id_common,descrip) 
 !--------------------------------------------------------------  
  use usefulbits, only : listprocesses
  
  type(listprocesses),intent(in) :: proc
  integer, intent(in) :: file_id_common
  character(LEN=200), intent(out) :: descrip
 
  character(LEN=45) :: label
  integer :: i,j
  character(LEN=1) :: jj
 
  i=proc%findi
  j=proc%findj
 
  write(jj,'(I1)')j
  
  label='('//trim(CMS_3316_data(1)%label)//')'
 
  descrip = '(pp)->h'//jj//'->tautau, using -2ln(L) reconstruction  '//label
  
  end subroutine outputproc_llh 
 !--------------------------------------------------------------
  subroutine get_length_of_file(filename, n, status)
 !-------------------------------------------------------------- 
   use usefulbits, only : file_id_common3
   implicit none
 
   character(LEN=*),intent(in) :: filename
   integer, intent(out) :: n, status
   integer :: error
  
   open(file_id_common3,file=trim(adjustl(filename)),action='read',status='old',iostat=status)
   if(status.ne.0) then
    write(*,*) 'Bad status', status, 'with the following file:'
    write(*,*) trim(adjustl(filename))
   endif 
   n = 0
    do
     read(file_id_common3,*, iostat = error)
     if (error == -1) exit
     n = n + 1
    enddo
   close(file_id_common3)
  end subroutine get_length_of_file
 !-------------------------------------------------------------- 
  subroutine available_Higgses(Havail,nH,cbin_in)
   implicit none
   
   integer, intent(in) :: nH, cbin_in
   logical, intent(inout) :: Havail(:)
   
   integer :: c,i,r
   
   if(size(Havail,dim=1).ne.nH) then
    write(*,*) "Warning in subroutine available_Higgses: sizes do not match!"
    Havail = .True.
   else
    c = cbin_in
    do i=1,nH
     r = c / (2**(nH-i))
     if(r.eq.1) then
      Havail(nH-i+1) = .False.
     elseif (r.eq.0) then
      Havail(nH-i+1) = .True.
     else
      stop "Error in subroutine available_Higgses: not valid binary!"      
     endif 
     c = mod(c,2**(nH-i))
    enddo
 !  write(*,*) "cbin = ",cbin_in, " Havail = ",Havail
   endif 
  
  end subroutine available_Higgses
 !******************************************************************
 end module likelihoods
 !******************************************************************
\ No newline at end of file