Exemplo n.º 1
0
void mlayer(void)
{
   static char command[COMMANDLEN+2];
   static double undoFit[NA], undoFitUnc[NA];

   /* Process command */
      while (queryString("mlayer% ", command, COMMANDLEN + 2) == NULL);
      caps(command);

      /* Spawn a command */
      if (strcmp(command, "!") == 0 || strcmp(command, "!!") == 0) {
         bang(command);

      /* Print current directory */
      } else if (strcmp(command, "PWD") == 0) {
         puts(currentDir);

      /* Change current directory */
      } else if (strcmp(command, "CD") == 0) {
         cd(command);

      /* Help */
      } else if (strcmp(command, "?") == 0
		 || strcmp(command, "HE") == 0
		 || strcmp(command, "HELP") == 0) {
         help(command + (*command == '?' ? 1 : 2));

      /* Value of vacuum QCSQ */
      } else if (strcmp(command, "QCV") == 0 || strcmp(command, "VQC") == 0) {
         setVQCSQ(tqcsq);

      /* Value of vacuum linear absorption coefficient */
      } else if (strcmp(command, "MUV") == 0 || strcmp(command, "VMU") == 0) {
         setVMU(tmu);

      /* Wavelength */
      } else if (strcmp(command, "WL") == 0) {
	 double v = lambda;
         if (setWavelength(&lambda)==0 && lambda != v) {
	   /* May need to recalculate Q for the new wavelength */
	   if (theta_offset != 0. && loaded) loadData(infile); 
	 }

      /* Theta offset */
      } else if (strcmp(command, "TO") == 0) {
	 double v = theta_offset;
	 if (setThetaoffset(&theta_offset)==0 && theta_offset != v) {
	   /* May need to recalculate Q for the new theta offset */
	   if (loaded) loadData(infile); 
	 }

      /* Number of layers */
      } else if (
         strcmp(command, "NTL") == 0 ||
         strcmp(command, "NML") == 0 ||
         strcmp(command, "NBL") == 0
      ) switch (command[1]) {
         case 'T':
            setNLayer(&ntlayer);
            break;
         case 'M':
            setNLayer(&nmlayer);
            break;
         case 'B':
            setNLayer(&nblayer);
            break;

      /* Add or remove layers */
      } else if (
         strcmp(command, "ATL") == 0 ||
         strcmp(command, "AML") == 0 ||
         strcmp(command, "ABL") == 0 ||
         strcmp(command, "RTL") == 0 ||
         strcmp(command, "RML") == 0 ||
         strcmp(command, "RBL") == 0
      ) {
         modifyLayers(command);

      /* Copy layer */
      } else if (strcmp(command, "CL") == 0) {
         copyLayer(command);

      /* Maximum number of layers used to simulate rough interface */
      } else if (
         strcmp(command, "NR") == 0 &&
         !setNRough(&nrough)
      ) {
         /* Generate interface profile */
         if (nrough < 3) nrough = 11;
         if (*proftyp == 'H')
            gentanh(nrough, zint, rufint);
         else
            generf(nrough, zint, rufint);

      /* Specify error function or hyperbolic tangent profile */
      } else if (strcmp(command, "PR") == 0) {
         setProfile(proftyp, PROFTYPLEN + 2);

      /* Number of layers in multilayer */
      } else if (strcmp(command, "NMR") == 0) {
         setNrepeat(&nrepeat);

      /* Range of Q to be scanned */
      } else if (strcmp(command, "QL") == 0) {
         setQrange(&qmin, &qmax);

      /* Number of points scanned */
      } else if (strcmp(command, "NP") == 0) {
         setNpnts();

      /* File for input data */
      } else if (strcmp(command, "IF") == 0) {
         setFilename(infile, INFILELEN + 2);

      /* File for output data */
      } else if (strcmp(command, "OF") == 0) {
         setFilename(outfile, OUTFILELEN + 2);

      /* File for parameters */
      } else if (strcmp(command, "PF") == 0) {
         setFilename(parfile, PARFILELEN + 2);

      /* Delta lambda */
      } else if (strcmp(command, "DL") == 0) {
         setLamdel(&lamdel);

      /* Delta theta */
      } else if (strcmp(command, "DT") == 0) {
         setThedel(&thedel);

      /* Beam intensity */
      } else if (strcmp(command, "BI") == 0) {
         setBeamIntens(&bmintns, &Dbmintns);

      /* Background intensity */
      } else if (strcmp(command, "BK") == 0) {
         setBackground(&bki, &Dbki);

      /* Verify parameters by printing out */
      } else if (
         strncmp(command, "TVE", 3) == 0 ||
         strncmp(command, "MVE", 3) == 0 ||
         strncmp(command, "BVE", 3) == 0 ||
         strncmp(command, "VE", 2) == 0
      ) {
         printLayers(command);

      /* Get data from file */
      } else if (strcmp(command, "GD") == 0) {
         loadData(infile);

      /* Edit constraints */
      } else if (strcmp(command, "EC") == 0) {
         constrainFunc newmodule;

         newmodule = newConstraints(constrainScript, constrainModule);
         if (newmodule != NULL) Constrain = newmodule;

      /* Reload constrain module */
      } else if (strcmp(command, "LC") == 0) {
         Constrain = loadConstrain(constrainModule);

      /* Unload constrain module */
      } else if (strcmp(command, "ULC") == 0) {
         Constrain = loadConstrain(NULL);

      /* Load parameters from parameter file */
      } else if (strncmp(command, "LP", 2) == 0) {
         loadParms(command, &npnts, parfile, constrainScript, constrainModule);

      /* Save parameters to parameter file */
      } else if (strcmp(command, "SP") == 0) {
         parms(tqcsq, mqcsq, bqcsq, tqcmsq, mqcmsq, bqcmsq, td, md, bd,
               trough, mrough, brough, tmu, mmu, bmu,
               MAXLAY, &lambda, &lamdel, &thedel, &theta_offset,
               &ntlayer, &nmlayer, &nblayer, &nrepeat, &qmin, &qmax, &npnts,
               infile, outfile,
               &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp,
               DA, constrainScript, parfile, TRUE);

      /* List data and fit */
      } else if (strcmp(command, "LID") == 0) {
         listData();

      /* Generate logarithm of bare (unconvoluted) reflectivity */
      } else if (strcmp(command, "GR") == 0 || strcmp(command, "SA") == 0) {
         genReflect(command);

      /* Generate and display layer profile used for roughness */
      } else if (strcmp(command, "GLP") == 0) {
         genProfile();

      /* Save layer profile to OUTFILE */
      } else if (
         strcmp(command, "SLP") == 0 ||
         strcmp(command, "SSP") == 0
      ) {
         saveProfile(command);

      /* Save values in XTEMP and YTEMP to OUTFILE */
      } else if (strcmp(command, "SV") == 0) {
         saveTemps(outfile);

      /* Calculate derivative of reflectivity or spin asymmetry with respect
         to a fit parameter or save a fit to disk file */
      } else if (
         strcmp(command, "RD") == 0 ||
         strcmp(command, "RSD") == 0 ||
         strcmp(command, "SRF") == 0 ||
         strcmp(command, "SRSF") == 0
      ) {
         printDerivs(command);

      /* Turn off all varied parameters */
      } else if (strcmp(command, "VANONE") == 0) {
         clearLista(listA);

      /* Specify which parameters are to be varied in the reflectivity fit */
      } else if (strncmp(command, "VA", 2) == 0) {
         varyParm(command);

      /* Calculate chi-squared */
      } else if (strcmp(command, "CSR") == 0 || strcmp(command, "CSRS") == 0) {
         printChiSq(command);

      /* Fit five-layer reflectivity */
      } else if (strncmp(command, "FR", 2) == 0) {
         register int n;

         for (n = 0; n < NA; n++) {
            undoFit[n] = A[n];
            undoFitUnc[n] = DA[n];
         }
         fitReflec(command);

      /* Undo last fit */
      } else if (strcmp(command, "UF") == 0) {
         register int n;

         for (n = 0; n < NA; n++) {
            A[n] = undoFit[n];
            DA[n] = undoFitUnc[n];
         }

      /* Exit */
      } else if (strcmp(command, "EX") == 0) {
         parms(tqcsq, mqcsq, bqcsq, tqcmsq, mqcmsq, bqcmsq, td, md, bd,
               trough, mrough, brough, tmu, mmu, bmu,
               MAXLAY, &lambda, &lamdel, &thedel, &theta_offset,
               &ntlayer, &nmlayer, &nblayer, &nrepeat, &qmin, &qmax, &npnts,
               infile, outfile,
               &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp,
               DA, constrainScript, parfile, TRUE);
         exit(0);

      /* Exit without saving changes */
      } else if (strcmp(command, "QU") == 0 || strcmp(command, "QUIT") == 0) {
         exit(0);

      /***** Start new ************** */

      /* Plot reflectivity on screen */
      } else if (strncmp(command, "PRF", 3) == 0) {
         plotfit(command);

      /* Plot profile on screen */
      } else if (strcmp(command, "PLP") == 0) {
      /* Generate profile */
         plotprofile(command);

      /* Send data to other processes. */
      } else if (strcmp(command, "SEND") == 0) {
	ipc_send(command);

      /* Receive data to other processes. */
      } else if (strcmp(command, "RECV") == 0) {
	ipc_recv(command);

      /* Plot movie of reflectivity change from fit */
      } else if (strncmp(command, "MVF", 3) == 0) {
         fitMovie(command, undoFit);

      /* Plot general movie from data file on screen */
      } else if (strncmp(command, "MVX", 3) == 0) {
         arbitraryMovie(command);

      /* Plot movie of parameter on screen */
      } else if (strncmp(command, "MV", 2) == 0) {
         oneParmMovie(command);

      /* Update constraints */
      } else if (strcmp(command, "UC") == 0) {
         genshift(a, TRUE);
         /* constrain(a); */
         (*Constrain)(FALSE, a, ntlayer, nmlayer, nrepeat, nblayer);
         genshift(a, FALSE);

      /* Enter critical Q squared */
      /* or */
      /* Top length absorption coefficient */
      /* or */
      /* Thicknesses of top layers */
      /* or */
      /* Roughnesses of top layers */

      } else {
         static char *paramcom[] = {"QC", "MU", "D", "RO"};
         static double  *top[] = { tqcsq,  tmu,  td,  trough};
         static double  *mid[] = { mqcsq,  mmu,  md,  mrough};
         static double  *bot[] = { bqcsq,  bmu,  bd,  brough};
         static double *Dtop[] = {Dtqcsq, Dtmu, Dtd, Dtrough};
         static double *Dmid[] = {Dmqcsq, Dmmu, Dmd, Dmrough};
         static double *Dbot[] = {Dbqcsq, Dbmu, Dbd, Dbrough};
         static int (*store[])(int, double *, double *) = {
            setQCSQ, setMU, setD, setRO
         };
         int param, code = -1;

         for (param = 0; param < sizeof(paramcom) / sizeof(paramcom[0]); param++) {
            code = fetchLayParam(command, paramcom[param], top[param],
               mid[param], bot[param], Dtop[param], Dmid[param], Dbot[param],
               store[param]);
            if (code > -1) break;
         }
         if (code == -1)
            ERROR("/** Unrecognized command: %s **/\n", command);
      }
}
Exemplo n.º 2
0
void magblocks4(void)
{
   static char command[COMMANDLEN + 2];
   static double undoFit[NA], undoFitUnc[NA];
   int npnts, j;
   double qmax, qmin;

   /* Process command */
      while (queryString("magblocks4% ", command, COMMANDLEN + 2) == NULL);
      caps(command);

      /* Spawn a command */
      if (strcmp(command, "!") == 0 || strcmp(command, "!!") == 0) {
        bang(command);

      /* Print current directory */
      } else if (strcmp(command, "PWD") == 0) {
         puts(currentDir);

      /* Change current directory */
      } else if (strcmp(command, "CD") == 0) {
         cd(command);
         
      /* Help */
      } else if (
         strcmp(command, "?") == 0 ||
         strcmp(command, "HE") == 0
      ) {
         help(command + (*command == '?' ? 1 : 2));

      /* Value of vacuum QCSQ */
      } else if (
         strcmp(command, "QCV") == 0 ||
         strcmp(command, "VQC") == 0
      ) {
         setVQCSQ(qcsq);

      /* Vacuum QCMSQ */
      } else if (
         strcmp(command, "QMV") == 0 ||
         strcmp(command, "VQM") == 0
      ) {
         setVMQCSQ(qcmsq);

      /* Value of vacuum linear absorption coefficient */
      } else if (
         strcmp(command, "MUV") == 0 ||
         strcmp(command, "VMU") == 0
      ) {
         setVMU(mu);

      /* Enter critical Q squared */
      } else if (strncmp(command, "QC", 2) == 0) {
         setQCSQ(command + 2, qcsq, Dqcsq);

      /* Top magnetic critical Q squared */
      } else if (strncmp(command, "QM", 2) == 0) {
         setMQCSQ(command + 2, qcmsq, Dqcmsq);

      /* Top length absorption coefficient */
      } else if (strncmp(command, "MU", 2) == 0) {
         setMU(command + 2, mu, Dmu);

      /* Thicknesses of magnetic layers */
      } else if (strncmp(command, "DM", 2) == 0) {
         setDM(command + 2, dm, Ddm);

      /* Delta lambda */
      } else if (strcmp(command, "DL") == 0) {
         setLamdel(&lamdel);

      /* Delta theta */
      } else if (strcmp(command, "DT") == 0) {
         setThedel(&thedel);

      /* Enter chemical thickness */
      } else if (command[0] == 'D') {
         setD(command + 1, d, Dd);

      /* Chemical roughnesses */
      } else if (strncmp(command, "RO", 2) == 0) {
         setRO(command + 2, rough, Drough);

      /* Magnetic roughnesses of layers */
      } else if (strncmp(command, "RM", 2) == 0) {
         setMRO(command + 2, mrough, Dmrough);

      /* Theta angle of average moment in layer */
      } else if (strncmp(command, "TH", 2) == 0) {
         setTHE(command + 2, the, Dthe);

      /* Wavelength */
      } else if (strcmp(command, "WL") == 0) {
         setWavelength(&lambda);

      /* Guide angle */
      } else if (strcmp(command, "EPS") == 0) {
         setGuideangle(&aguide);

      /* Number of layers */
      } else if (strcmp(command, "NL") == 0) {
         if (!setNlayer(&nlayer))
         /* Bug found Wed Jun  7 10:38:45 EDT 2000 by KOD */
         /* since it starts at 0, correction for vacuum forces zero */
         for (j = 1; j <= nlayer; j++)
            /* Set all absorptions to non-zero values */
            if (mu[j] < *mu) mu[j] = *mu + 1.e-20;

      /* Add or remove layers */
      } else if (strcmp(command, "AL") == 0 || strcmp(command, "RL") == 0) {
         modifyLayers(command);

      /* Copy layer */
      } else if (strcmp(command, "CL") == 0) {
         copyLayer(command);

      /* Make superlattice */
      } else if (strcmp(command, "SL") == 0) {
         superLayer(command);

      /* Maximum number of layers used to simulate rough interface */
      } else if (strcmp(command, "NR") == 0) {
         if (!setNrough(&nrough)) {
            /* Generate interface profile */
            if (nrough < 3) nrough = 11;
            if (proftyp[0] == 'H')
               gentanh(nrough, zint, rufint);
            else
               generf(nrough, zint, rufint);
         }

      /* Specify error function or hyperbolic tangent profile */
      } else if (strcmp(command, "PR") == 0) {
         setProfile(proftyp, PROFTYPLEN + 2);

      /* Range of Q to be scanned */
      } else if (strcmp(command, "QL") == 0) {
         if (!setQrange(&qmin, &qmax)) {
            qmina = qmin;
            qmaxa = qmax;
            qminb = qmin;
            qmaxb = qmax;
            qminc = qmin;
            qmaxc = qmax;
            qmind = qmin;
            qmaxd = qmax;
         }

      /* Number of points scanned */
      } else if (strcmp(command, "NP") == 0) {
         if (!setNpnts(&npnts)) {
            npntsa = npnts;
            npntsb = npnts;
            npntsc = npnts;
            npntsd = npnts;
         }

      /* File for input data */
      } else if (strcmp(command, "IF") == 0) {
         setFilename(infile, INFILELEN + 2);

      /* File for output data */
      } else if (strcmp(command, "OF") == 0) {
         setFilename(outfile, OUTFILELEN + 2);

      /* File for parameters */
      } else if (strcmp(command, "PF") == 0) {
         setFilename(parfile, PARFILELEN + 2);

      /* Polarization state */
      } else if (strcmp(command, "PS") == 0) {
         setPolstat(polstat, POLSTATLEN + 2);

      /* Beam intensity */
      } else if (strcmp(command, "BI") == 0) {
         setBeamIntens(&bmintns, &Dbmintns);

      /* Background intensity */
      } else if (strcmp(command, "BK") == 0) {
         setBackground(&bki, &Dbki);

      /* Verify parameters by printing out */
      } else if (strncmp(command, "VE", 2) == 0) {
         printLayers(command);

      /* Get data from file */
      } else if (strcmp(command, "GD") == 0) {
         loadData(infile, xspin);

      /* Edit constraints */
      } else if (strcmp(command, "EC") == 0) {
         constrainFunc newmodule;

         newmodule = newConstraints(constrainScript, constrainModule);
         if (newmodule != NULL) Constrain = newmodule;

      /* Reload constrain module */
      } else if (strcmp(command, "LC") == 0) {
         Constrain = loadConstrain(constrainModule);

      /* Unload constrain module */
      } else if (strcmp(command, "ULC") == 0) {
         Constrain = loadConstrain(NULL);

      /* Load parameters from parameter file */
      } else if (strncmp(command, "LP", 2) == 0) {
         loadParms(command, parfile, constrainScript, constrainModule);

      /* Save parameters to parameter file */
      } else if (strcmp(command, "SP") == 0) {
         parms(qcsq, qcmsq, d, dm, rough, mrough, mu, the,
               MAXLAY, &lambda, &lamdel, &thedel, &aguide,
              &nlayer, &qmina, &qmaxa, &npntsa,
              &qminb, &qmaxb, &npntsb, &qminc, &qmaxc, &npntsc,
              &qmind, &qmaxd, &npntsd,
               infile, outfile,
              &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp,
               polstat, DA, constrainScript, parfile, TRUE);

      /* List data and fit */
      } else if (strcmp(command, "LID") == 0) {
         listData();

      /* Generate logarithm of bare (unconvoluted) reflectivity */
      /* or generate reflected amplitude */
      } else if (strcmp(command,"GR") == 0 || strcmp(command, "GA") == 0) {
         genReflect(command);

      /* Generate and display layer profile */
      } else if (
         strcmp(command, "GLP") == 0 ||
         strncmp(command, "SLP", 3) == 0
      ) {
         genProfile(command);

      /* Save values in Q4X and YFIT to OUTFILE */
      } else if (strcmp(command, "SV") == 0) {
         saveTemps(outfile, xspin, y4x, n4x, FALSE);

      /* Save values in Q4X and YFITA to OUTFILE */
      } else if (strcmp(command, "SVA") == 0) {
         saveTemps(outfile, xspin, yfita, n4x, TRUE);

      /* Calculate derivative of reflectivity or spin asymmetry with respect */
      /* to a fit parameter or save a fit to disk file */
      } else if (
         strcmp(command, "RD") == 0 ||
         strcmp(command, "SRF") == 0
      ) {
         printDerivs(command, npnts);

      /* Turn off all varied parameters */
      } else if (strcmp(command, "VANONE") == 0) {
         clearLista(listA);

      /* Specify which parameters are to be varied in the reflectivity fit */
      } else if (strncmp(command, "VA", 2) == 0) {
         varyParm(command);

      /* Calculate chi-squared */
      } else if (
         strcmp(command, "CSR") == 0 ||
         strcmp(command, "CS") == 0
      ) {
         calcChiSq(command);

      /* Fit reflectivity */
      } else if (strncmp(command, "FR", 2) == 0) {
         for (j = 0; j < NA; j++) {
            undoFit[j] = A[j];
            undoFitUnc[j] = DA[j];
         }
         fitReflec(command);

      /* Undo last fit */
      } else if (strcmp(command, "UF") == 0) {
         for (j = 0; j < NA; j++) {
            A[j] = undoFit[j];
            DA[j] = undoFitUnc[j];
         }

      /* Exit */
      } else if (
         strcmp(command, "EX") == 0 ||
         strcmp(command, "EXS") == 0
      ) {
         parms(qcsq, qcmsq, d, dm, rough, mrough, mu, the,
               MAXLAY, &lambda, &lamdel, &thedel, &aguide,
              &nlayer, &qmina, &qmaxa, &npntsa,
              &qminb, &qmaxb, &npntsb, &qminc, &qmaxc, &npntsc,
              &qmind, &qmaxd, &npntsd,
               infile, outfile,
              &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp,
               polstat, DA, constrainScript, parfile, TRUE);
         /* Print elapsed CPU time */
         if (strcmp(command, "EXS") == 0) system("ps");
         exit(0);

      /* Exit without saving changes */
      } else if (strcmp(command, "QU") == 0 || strcmp(command, "QUIT") == 0) {
         exit(0);

      /* Plot reflectivity on screen */
      } else if (strncmp(command, "PRF", 3) == 0) {
         plotfit(command, xspin);

      /* Plot profile on screen */
      } else if (strncmp(command, "PLP", 3) == 0) {
         plotprofile(command, xspin);

      /* Plot movie of reflectivity change from fit */
      } else if (strncmp(command, "MVF", 3) == 0) {
         fitMovie(command, xspin, undoFit);

      /* Plot general movie from data file on screen */
      } else if (strncmp(command, "MVX", 3) == 0) {
         arbitraryMovie(command, xspin);

      /* Plot movie of parameter on screen */
      } else if (strncmp(command, "MV", 2) == 0) {
         oneParmMovie(command, xspin);

      /* Update constraints */
      } else if (strcmp(command, "UC") == 0) {
         genshift(a, TRUE);
         /* constrain(a); */
         (*Constrain)(FALSE, a, nlayer);
         genshift(a, FALSE);

      /* Determine number of points required for resolution extension */
      } else if (strcmp(command, "RE") == 0) {
         calcExtend(xspin);

#if 0 /* Dead code --- shadowed by "CD" command earlier */
      /* Convolute input raw data set with instrumental resolution */
      } else if (strcmp(command, "CD") == 0) {
         calcConvolve(polstat);
#endif

      /* Send data to other processes. */
      } else if (strcmp(command, "SEND") == 0) {
	ipc_send(command);

      /* Receive data to other processes. */
      } else if (strcmp(command, "RECV") == 0) {
	ipc_recv(command);

      /* Faulty input */
      } else
         ERROR("/** Unrecognized command **/");
}
Exemplo n.º 3
0
void plotJER_afterCorr()
{
	TFile *f_read = new TFile("CORR_JER.root","READ");
	cout<<"plot the fittting result in file : "<<"CORR_JER.root"<<endl;

/*	
	TStyle *MyStyle = new TStyle("MyStyle","My Root Styles");
	MyStyle->SetMarkerStyle(
  MyStyle->SetTitleOffset(1.5, "y");
	MyStyle->SetOptFit(1112);
	MyStyle->SetOptStat(0);
  gROOT->SetStyle("MyStyle");
*/
	gStyle->SetMarkerStyle(24);
	gStyle->SetOptFit(1112);
	gStyle->SetOptStat(0);



	plotfit("JERCorr", f_read, "Inclusice");
	cout<<"check1"<<endl;
  plotfit("BJERCorr", f_read,"b-jet");
	cout<<"check2"<<endl;
  plotfit("csvBJERCorr", f_read,"csv B-jet");
  cout<<"check3"<<endl;
  plotfit("FCRBJERCorr", f_read,"FCR B-jet");
  cout<<"check4"<<endl;


//  plotfit("FCRcsvBJERCorr", f_read,"FCR csv B-jet");


/*
	TCanvas *C_plot = new TCanvas("C_plot","C_plot");
	C_plot->Divide(2,2);
	TH1F* h_reCorr[nCentBins];
	TLegend* le[nCentBins];
	for(int iCentBins=0; iCentBins < nCentBins; iCentBins++)
	{
		h_reCorr[iCentBins] = (TH1F*)f_read->Get(Form("resCorr_cent%dto%d_h", centBins[iCentBins], centBins[iCentBins+1]));
		C_plot->cd(iCentBins+1);
		le[iCentBins] = new TLegend(0.2,0.75,0.45,0.88);
		le[iCentBins]->SetBorderSize(0);
		le[iCentBins]->AddEntry((TObject*)0,Form("Cent %d-%d %%", centBins[iCentBins], centBins[iCentBins+1]),"");
		h_reCorr[iCentBins]->GetXaxis()->SetTitle("refpt [GeV]");
		double ymax = h_reCorr[iCentBins]->GetMaximum();
		double ymin = h_reCorr[iCentBins]->GetMinimum();
		h_reCorr[iCentBins]->SetMaximum( ymax + 0.45*(ymax-ymin) );
		h_reCorr[iCentBins]->SetMinimum( ymin - 0.1*(ymax-ymin) );
		h_reCorr[iCentBins]->Draw();	
		le[iCentBins]->Draw();
	}
*/
	// plotting difference

/*	
	TF1 * residualJetCorrFuncs_p[nCentBins];
	double ptBinCenter[nPtBins];
	double ptBinErr[nPtBins];
	double corrFactor[nCentBins][nPtBins];
	double hist_Value[nCentBins][nPtBins];
	double closure[nCentBins][nPtBins];	
	TGraph *gr_closure[nCentBins];
	TCanvas *c_closure = new TCanvas("c_closure","c_closure");
	c_closure->Divide(2,2);
	TLegend* le1[nCentBins];

	
	for(int iCentBins=0; iCentBins < nCentBins; iCentBins++)
	{
		c_closure->cd(iCentBins+1);
//	  h_reCorr[iCentBins] = (TH1F*)f_read->Get(Form("resCorr_cent%dto%d_h", centBins[iCentBins], centBins[iCentBins+1]));
		residualJetCorrFuncs_p[iCentBins] = (TF1*)h_reCorr[iCentBins]->GetFunction("f1_p");
		for(int iPtBins =0; iPtBins<nPtBins ; iPtBins++)
		{
			ptBinCenter[iPtBins] = (ptBin[iPtBins]+ptBin[iPtBins+1])/2;
			ptBinErr[iPtBins] = (ptBin[iPtBins+1]-ptBin[iPtBins])/2;
			corrFactor[iCentBins][iPtBins] = residualJetCorrFuncs_p[iCentBins]->Eval(ptBinCenter[iPtBins]);
			hist_Value[iCentBins][iPtBins] = h_reCorr[iCentBins]->GetBinContent(iPtBins+1);
			closure[iCentBins][iPtBins] = corrFactor[iCentBins][iPtBins] -hist_Value[iCentBins][iPtBins];	
			cout<<"corrFactor ["<<iCentBins<<"]"<<"["<<iPtBins<<"] = "<< corrFactor[iCentBins][iPtBins]<<endl;
		}
		cout<<endl;
		gr_closure[iCentBins] = new TGraph(nPtBins, ptBinCenter, closure[iCentBins]);
		gr_closure[iCentBins]->SetTitle("JEC closre"); 
		gr_closure[iCentBins]->GetXaxis()->SetTitle("refpt");
		gr_closure[iCentBins]->Draw("AP*l");
    le1[iCentBins] = new TLegend(0.6,0.75,0.88,0.88);
    le1[iCentBins]->SetBorderSize(0);
    le1[iCentBins]->AddEntry((TObject*)0,Form("Cent %d-%d %%", centBins[iCentBins], centBins[iCentBins+1]),"");
	  le1[iCentBins]->Draw();

	
	}
*/

}