Photon energy scale and Resolution (2011 and 2012) with Z→μμγ events

Step 1 : Framework installation

Set correct environment

      source ${VO_CMS_SW_DIR}/cmsset_default.sh
      source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh
      source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh
      export SCRAM_ARCH="slc5_amd64_gcc462" 

      cd /.../CMSSW_5_3_X/src 
      cmsenv

To install a CMSSW version use :

 
      scram project -n CMSSW_nameYouWant CMSSW CMSSW_X_X_X 

If you are not on lxplus, use these lines to download on cvs :

      export CVSROOT=:gserver:cmscvs.cern.ch:/local/reps/CMSSW
      kinit -5 login@CERN.CH

or (password: 98passwd) :

      CVSROOT=:pserver:anonymous@cmssw.cvs.cern.ch:/local/reps/CMSSW
      cvs login

Step 2 : IpnTreeProducer and Regression (V3 to V5) installation

      cd /.../CMSSW_5_3_X/src
      git clone https://github.com/IPNL-CMS/IpnTreeProducer.git Toto/IpnTreeProducer
      cvs co -r regressionMay18b RecoEgamma/EgammaTools
      cvs co -r V05-08-20 RecoEcal/EgammaCoreTools
      checkdeps -a
      git clone -b hggpaperV5 https://github.com/bendavid/GBRLikelihood.git HiggsAnalysis/GBRLikelihood
      git clone -b hggpaperV5 https://github.com/bendavid/GBRLikelihoodEGTools.git HiggsAnalysis/GBRLikelihoodEGTools
      scram build
      cd /.../CMSSW_5_3_X/src/HiggsAnalysis/GBRLikelihoodEGTools/data/
      rm *.root
      cd /.../CMSSW_5_3_X/src/IpnTreeProducer/src/
      make 

Step 3: Creation of toto-uples :

Preliminary steps

      cd /.../CMSSW_X_X_X/src/IpnTreeProducer/test/
      git clone git@github.com:lsgandurra/IpnTreeProducer_scripts.git
      cd IpnTreeProducer_scripts

Modify the default code

You have to modify the different macros in IpnTreeProducer_scripts :

  • crab_*201*_*.cfg
    • lumi_mask, lumi_mask, pset, user_remote_dir, ui_working_dir
    • Also replace "scheduler = glite" by "scheduler = remoteGlidein"
  • the corresponding toto_*.py file
    • Put the good Global Tag :
      • process.GlobalTag.globaltag = cms.string('HERE')
    • If you don't want to use the Zmmg_skim, comment this line +process.ZmmgSkimSeq

To find the good Global Tag, you can go here Global Tag twiki

Running and monitoring of grid jobs

      crab -cfg crab_X_.cfg -create 
      crab "your directory" -submit
      crab "your directory" -get
      crab "your directory" -report

Check if everything is ok and create listFiles

      source listGoodFiles.sh "your directory"

Numbers after each cut

      source getPathNumbers_2012.sh

Step 4: Creation of miniTrees :

Download the code

      cd /.../CMSSW_5_3_X/src/

      git clone  git@github.com:lsgandurra/ZmmgStudies.git

Compilation

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/Selection
      ln /.../CMSSW_5_3_X/src/IpnTreeProducer/interface/
      ln /.../CMSSW_5_3_X/src/IpnTreeProducer/src/libToto.so
      make clean && make

What you MUST check before running the code

You must verify :

  • in Selection_miniTree.h that the pileup weights are ok (between lines 65 and 566 ).
    • To generate the pileup weights, you have to know both the original pileup distributions in data and MC. For data, everithing is explained here : data pileup. For MC, you have to go on this page : MC pileup and find the good distribution. Then, to obtain the pileup weighs you have to use this macro : pileup weights.
  • that you chose the good set of SC corrections.
    • 1.0 (default corrections), MITregression2, MITregression3 or MITregression5
  • that the rochester muon corrections are up to date (see Rochester muon momentum corrections).
    • To use the last corrections arg[12] (applyMuonScaleCorrection) in Selection_miniTree.C have to be equal to 3.
  • the lumi numbers in Selection_miniTree.C (search integratedLuminosity).
    • To obtain the good luminosity, use the documentation here : lumi calc. The command you should use is this one : lumiCalc2.py overview -i lumi_summary.json (this file is generated when you do a crab -report).
  • the cross sections for the different processes in Selection_miniTree.C (search XSection*).
  • the initial numbers of MC events in Selection_miniTree.C (search InitialNumber*) (they correspond to the number of events before running the totouples).
    • The good numbers correpond to the first line of the output of getPathNumbers_2012.sh. These numbers must be identicals to the ones given by DAS.
  • the scale factors for the HLT and the tight muID in Selection_miniTree.h (search weight_hlt_scaleFactors and weight_tightMuId_scaleFactors).
  • the rescaling of r9 in Selection_miniTree.h (search doR9Rescaling).
    • You can find them in the Hgg analysis note.

Running the code

First, you need to copy the listFiles* you created with listGoodFiles.sh in /.../CMSSW_5_3_X/src/ZmmgStudies/Selection. Then, you have to modify lanceurJobs_mumugamma_v2.sh :

  • Put the samples corresponding to your listFiles*.
  • Choose the good pileup_set, lumi_set, isZgamma (0 = data, 1 = MC FSR, 2 = MC nonFSR, 3 = WJets and TTJets) and scCorrection (default = 0, regression SC corrections = MITregression).
  • For 2012, put lowMuMuCut=35 and highMuMuCut=9999. For 2011, put lowMuMuCut=40 and highMuMuCut=80.
  • If you don't want to run systematics, let itoy=0 and inj_resolution=0.
  • You can modify the name of the output.

Finally, to run the code :

      source lanceurJobs_mumugamma_v2.sh

Check and merge outputs

When all the jobs are done and if you have no failed jobs (ls *.fail), you can merge the miniTrees :

  • in lanceurJobs_mumugamma_v2.sh :
    • Comment qsub batchJob.sh ....
    • Uncomment hadd miniTree_...

Then, do :

      source lanceurJobs_mumugamma_v2.sh

Finally :

  • in lanceurJobs_mumugamma_v2.sh :
    • Comment hadd miniTree_...
    • Uncomment the 3 lines beginning by mv ...

And then, do :

      source lanceurJobs_mumugamma_v2.sh

Generation of the events list (optionnal) :

You can modify the cuts in EventsList.C. Then, run this code :

      source EventsList.sh miniTree_name

Creation of RECO samples of our selection (optionnal) (cvs version):

In CMSSW_5_3_X/src/ do :

      cvs co -r CMSSW_5_3_X PhysicsTools/Utilities
      scram build
Copy the outputs (= .txt files) of EventsList.sh in PhysicsTools/Utilities/scripts. Then run edmPickEvents.py as follows (before creating crab jobs, you can modify pickevents_crab.config) :
      edmPickEvents.py "Dataset_name" events.txt --crab 
      crab -create -cfg pickevents_crab.config
      crab -submit
      crab -getoutput

A complete description of pick events can be found here: How to Pick Events

Data/MC comparisons :

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/EnergyScaleAndResolution/

  • Edit Data_MC_Var_Comparison.cpp. Modify the cuts if you want and put your miniTrees (just the names, not the complete pathes).
  • Then open launcherData_MC_Comparison_thesis_v1.sh and choose the directoryName

      source launcherData_MC_Comparison_thesis_v1.sh

  • When all the jobs will be over, you will have a new directory called directoryName with all the plots inside.

Energy Scale extraction :

Check if everything is ok :

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/EnergyScaleAndResolution/

  • You have first to edit SFits.cpp and put the miniTree*.root you want instead of the default ones.
  • SFits.cpp is the main macro. It loads functions.h (general functions + χ2 + ... ) and fitFunctions.h.
  • Compilation :

      source /afs/cern.ch/sw/lcg/external/gcc/4.3.2/x86_64-slc5/setup.sh
      source /afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.04/x86_64-slc5-gcc43-opt/root/bin/thisroot.sh
      make clean && make

  • Edit launcherAllBatch_thesis_v1.sh and choose what you want to run :
    • dataType : MC, data.
    • fitVariable : mmg_s, mmg_s_true, Mmumugamma, mmg_s_surface ...
    • fitPercentage (-> differents fit ranges) : default 60 to 100.
    • injectedResolution : should correspond to the one you applied in the miniTrees (default is 0).
    • You should change the name of the output directory (Results_v6_RecoEnergy for now).
    • Choose the cut variable : default is Photon_Et.
    • Choose the number of bins (in cut variable) : LimitesAllPtOneBin.txt, LimitesAllPtFiveBin.txt, LimitesAllPt7Bin.txt

  • Edit batchJob.sh :
    • Change the HOMEDIR directory and the set-up environment file (default 5311p3_RECO_5_3_11_v1.sh).
    • Under the line COPY EXECUTABLE TO WORKER, copy what you need (.exe, *.txt, *.sh, miniTree.root).
    • You can remove or add fit functions (default : voigtian, cruijff) .
    • Change the different pathes under the line GET BACK OUTPUT FILES TO SPS AND REMOVE THEM FROM DISTANT DIR.

  • Then you can launch jobs on batch :

      source launcherAllBatch_thesis_v1.sh

Verify if all the jobs are done and do the plots :

  • Check if all the jobs ran correctly, you can use :

      ./CheckAllFits.exe directory_name dataType fitVariable cutVariable binFileName lowFitRange highFitRange injectedResolution

    • If you have some failed jobs, this macro will generate a file : jobsToResubmit*.sh. You must then do :

      source jobsToResubmit*.sh

  • Do the plots and select the best fit ranges (+ do the fit ranges systematics) :
    • Edit launcherCombinedPlotter_thesis_v1.sh and choose the good directory, dataType, fitVariable and fitFunction.
    • Uncomment lines to do additionnal plots
    • Then do :

      source launcherCombinedPlotter_thesis_v1.sh

    • You will then have in your_directory/InjectedResolution_*Percent/dataType 2 new directories :
      • Selected_Fits, where you have a Summary*.txt file with all the usefull informations and the choosen fits for all the categories and all the Pt bins (+ the fitRange systematics for each chosen fit).
      • CombinedGraphs, containing some plots of p-values, fit-ranges...

Energy Scale Muon and fit function systematics :

Muon systematics

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/Selection

  • Edit lanceurJobs_mumugamma_MuSys_v2.sh : put the good samples and change the different options if you like (the option should be similar to the ones you have in lanceurJobs_mumugamma_v2.sh). Then uncomment the line qsub... and comment the rest. You can change the miniTree name if you like.

  • Then launch the jobs on batch :

      source lanceurJobs_mumugamma_MuSys_v2.sh

  • If all the jobs are ok (no *.fail files in your directory), you can merge the miniTrees (comment the line with qsub... and uncomment the line with hadd..., then source lanceurJobs_muSys.sh).

  • You have now 100 new miniTrees per datasets. In each one, muon momentum is smeared by a random number given by a gaussian of width DeltaK.

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/EnergyScaleAndResolution/

  • Open launcherAllBatch_muSys_thesis_v1.sh and change the directory name and other oprion if you like.
  • Edit batchJob_muSys.sh and put the good pathes, HOMEDIR and environment file. Then under COPY EXECUTABLE TO WORKER, copy the files you need (.exe, .txt, .sh and miniTrees*.root)
  • Edit SFits.cpp and put the good miniTrees after if(muSys > 0 && extraScale = "0")=. Don't forget to do a make !
  • Modify SelectedFits_MC.txt and SelectedFits_data.txt with the good numbers stored in your_directory/InjectedResolution_*Percent/dataType/Selected_Fits/
  • Then you can launch the jobs on batch :

      source launcherAllBatch_muSys_thesis_v1.sh

  • Ones all the jobs are ok, open and modify launcherMuonsSystematics_thesis_v1.sh and finaly do :

      source launcherMuonsSystematics_thesis_v1.sh

  • The results are stored in directory_MuSys/dataType/MuonSystematics/.

Systematics coming from the choice of the fit function (works with Voigtian as truth and Cruijff as test model for now) :

      cd /.../CMSSW_5_3_X/src/ZmmgStudies/EnergyScaleAndResolution/

  • Edit batchJob_fitFunctionSystematics.sh and change the different pathes, the HOMEDIR and 5311p3_RECO_5_3_11_v1.sh.
  • Then open launcherFitFunctionSystematics.sh and put the good directory name and variables you want to use.

      source launcherFitFunctionSystematics.sh

  • If everything went well, you should now have a new directory : your_directory/InjectedResolution_*Percent/dataType/Selected_Fits/FitFunctionSystematics/. Inside, you will find some plots and a file called Summary_fitFunctionSystematics.txt with all the systematics for the different categories.

Energy Scale extraction with surface :

Generation of Dimuon miniTrees

First of all, you have to use Toto-uples without the Zmmg_skim !!

      cd ZmmgStudies/Selection

  • Open Muons_miniTree_test.C and Muons_miniTree_test.h and do the same checks that you did here : What you MUST do

  • Open and modify lanceurJobs_muons_v2.sh and batchJob_muons.sh

  • Then launch the jobs :

      source lanceurJobs_muons_v2.sh

*Don't forget to check if all the jobs are ok and to merge the output !

Surface creation

     cd ZmmgStudies/EnergyScaleAndResolution

  • Open SurfaceGenerator.cpp and put the correct Dimuons and mumugamma miniTrees.
  • Do the same things with this file : Surface_fit.cpp but don't put the complete path (just the miniTree names).

  • Then compile and do :

     ./SurfaceGenerator.exe directoryName dataType surfaceBinning nbJobs option fitFunction MmumuOption
    • dataType : "MC" or "data"
    • surfaceBinning : "5" GeV by default
    • nbJobs : Try "200"
    • option : "plot2D_pro" "plot3D_pro" "plot2D_fit" "plot3D_fit" "MmumuPro" "MmumuFit"
    • fitFunction : "voigtian" by default
    • MmumuOption : "MmumuRECO" "MmumuGEN" "MmumugammaRECO" "MmumugammaGEN"
  • To generate the Mmumu surface, choose "data" "5" "200" "MmumuFit" and "MmumuRECO"
  • To generate the Mmumugamma Gen surface choose "MC" "5" "200" "MmumuFit" and "MmumugammaGEN"
  • You can try different options to see the differences between the surfaces

  • After this command you should have a file called fileTosubmit_*_*_*.sh
  • To launch the jobs that will fit the Mmumu mass in each 5 GeV bins of the surface, just do :

     source fileTosubmit_*_*_*.sh

* Make sure that no jobs crashed and then do :

     ./SurfaceGenerator.exe directoryName data 5 200 plot2D_fit voigtian MmumuRECO
  • Then you should have the surface in 2 dimensions and the corresponding values of MmumuRECO in Mmumu.txt.

  • You have to redo the same procedure with the MC.

MuMuGamma minitree with the good surface

  • You should have now 2 Mmumu.txt : one for data and the other for MC.
  • If yes, copy both files in ZmmgStudies/Selection and rename them in Mmumu_data.txt and Mmumu_MC.txt.
  • Finally, to generate MuMugamma minitrees with the good surface follow the same procedure as the one described here Minitree creation.

Energy scale extraction

     cd ZmmgStudies/EnergyScaleAndResolution

  • Put the correct miniTrees in SFits.cpp and re-compile.
  • Then open launcherAllBatch_thesis_v1_surface.sh, put the directory you want and launch the jobs :

     source launcherAllBatch_thesis_v1_surface.sh

  • Check if all the fits are ok with CheckAllFits.cpp.

  • Modify launcherCombinedPlotter_thesis_v1.sh to put mmg_s_MZ_Surface instead of mmg_s and launch this macros to select the good fits and generate some plots :

     source launcherCombinedPlotter_thesis_v1.sh

Comparison plots with Strue and Sreco

     cd ZmmgStudies/EnergyScaleAndResolution

  • Open SFitvsVar.cpp and put the correct directories after line 133 (don't forget to re-compile !).

  • Then launch the macro :

     ./SFitvsVar.exe directoryName bothPlusTrue mmg_s_MZ_Surface Photon_Et LimitesAllPtFiveBin.txt voigtian 0 2012

Resolution extraction :

  • To do this you must have both Dimuons minitrees and MuMugamma minitrees. To know how to do them, follow the description given in this page.
  • To obtain sigmaE, you have to extract 5 quantities : sigmaMu, sigmaMuMu2, sigmaMuMuGamma2 + 2 additionnal terms.
  • The main macro is this one : ResolutionExtractor.cpp.

  • First put the correct miniTrees in ResolutionExtractor.cpp and re-compile.

sigmaMu extraction :

     ./ResolutionExtractor.exe directoryName all all dataType Mmumu sigmaMu
    • Instead of dataType, select data or MC.

  • In the new directory you have just created, you should have plots with a second order polynomial function to describe the evolution of sigmaMu with Pmu.

sigmaMuMu2 extraction :

     ./ResolutionExtractor.exe directoryName all all dataType Mmumu sigmaMuMu2

sigmaMuMuGamma2 extraction :

     ./ResolutionExtractor.exe directoryName all all dataType Mmumugamma sigmaMuMuGamma2

Additionnal terms :

  • To extract these terms, you will have to redo MuMuGamma miniTrees.
  • So first go in ZmmgStudies/Selection.
  • Open Selection_miniTree.h and put the correct polynomial form for sigmaMu (lines 2232 to 2241).
  • Then follow the classical procedure of miniTree generation.

  • By default the following command give you the values for the additionnal terms (in addition of sigmaMuMuGamma2) :

     ./ResolutionExtractor.exe directoryName all all dataType Mmumugamma sigmaMuMuGamma2

Comments :

  • To obtain sigmaE, you just have to combine all the terms together as described in my thesis.
  • Note that someone has to recompute the formula because it could be wrong (see Fabrice Couderc version here : Fabrice formula)
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2014-07-16 - LouisSgandurra
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback