Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /Validation/RecoEgamma/test/validationMiniAOD.csh is written in an unsupported language. File is not indexed.

0001 ##!/bin/csh -x
0002 #!/bin/csh 
0003 
0004 #This script can be used to generate a web page to compare histograms from 
0005 #two input root files produced using the EDAnalyzers in RecoEgamma/Examples,
0006 #by running one of:
0007 #
0008 #  
0009 #  #  "Validation/RecoEgamma/test/PhotonValidator_cfg.py
0010 #
0011 # The default list of histograms (configurable) is based on version VXX-XX-XX
0012 # of Validation/RecoEgamma
0013 #
0014 #Two files are created by this script: validation.C and validation.html.
0015 #validation.C should be run inside root to greate a set of gif images
0016 #which can then be viewed in a web browser using validation.html.
0017 
0018 #=============BEGIN CONFIGURATION=================
0019 
0020 setenv RUNTYPE Central
0021 #setenv RUNTYPE Local
0022 setenv STARTUP True
0023 setenv FASTSIM False
0024 setenv UPGRADE True
0025 ## TYPE options: Photons, GEDPhotons
0026 ## ANALYZERNAME options: PhotonValidator, oldpfPhotonValidator, pfPhotonValidator
0027 #setenv TYPE Photons
0028 #setenv ANALYZERNAME PhotonValidator
0029 setenv TYPE GEDPhotons
0030 setenv ANALYZERNAME1 PhotonValidatorMiniAOD
0031 setenv ANALYZERNAME2 pfPhotonValidator
0032 
0033 
0034 setenv CMSSWver1 7_6_0
0035 setenv CMSSWver2 7_6_0
0036 setenv OLDRELEASE 7_6_0
0037 setenv NEWRELEASE 7_6_0
0038 setenv OLDPRERELEASE pre5
0039 setenv NEWPRERELEASE pre5
0040 setenv UPGRADEVER  UPG2017
0041 setenv LHCENERGY   13
0042 setenv PU False
0043 setenv PUlevel 25ns
0044 
0045 if ( $STARTUP == True &&  $FASTSIM == False && $PU == False && $UPGRADE == True ) then
0046 setenv OLDGLOBALTAG MCRUN2_74_V7-v1
0047 setenv NEWGLOBALTAG MCRUN2_74_V7-v2
0048 else if ( $UPGRADE == True && $PU == True &&  $FASTSIM == False ) then
0049 setenv OLDGLOBALTAG PU${PUlevel}_76X_mcRun2_asymptotic_v1-v1
0050 setenv NEWGLOBALTAG PUpmx${PUlevel}_76X_mcRun2_asymptotic_v1-v1
0051 else if (  $STARTUP == True  && $FASTSIM == True) then
0052 setenv OLDGLOBALTAG MCRUN2_73_V7_FastSim-v1
0053 setenv NEWGLOBALTAG MCRUN2_74_V1_FastSim-v1
0054  endif
0055 
0056 
0057 
0058 
0059 setenv OLDRELEASE ${OLDRELEASE}_${OLDPRERELEASE}
0060 #setenv OLDRELEASE ${OLDRELEASE}
0061 setenv NEWRELEASE ${NEWRELEASE}_${NEWPRERELEASE}
0062 #setenv NEWRELEASE ${NEWRELEASE}
0063 
0064 setenv WorkDir1    /afs/cern.ch/user/n/nancy/scratch0/CMSSW/workForMINIAOD/CMSSW_7_6_0_pre5/src/Validation/RecoEgamma/myTest3
0065 
0066 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}/src/Validation/RecoEgamma/test
0067 #setenv WorkDir2   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver2}_${NEWPRERELEASE}/src/Validation/RecoEgamma/test
0068 
0069 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}_${OLDPRERELEASE}/src/Validation/RecoEgamma/test
0070 #setenv WorkDir2   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver2}_${NEWPRERELEASE}/src/Validation/RecoEgamma/test
0071 
0072 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}_${OLDPRERELEASE}/src/Validation/RecoEgamma/test
0073 #setenv WorkDir2   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver2}/src/Validation/RecoEgamma/test
0074 
0075 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}/src/Validation/RecoEgamma/test
0076 #setenv WorkDir2   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver2}/src/Validation/RecoEgamma/test
0077 
0078 #Name of sample (affects output directory name and htmldescription only) 
0079 
0080 
0081 #setenv SAMPLE SingleGammaPt10
0082 #setenv SAMPLE SingleGammaPt35
0083 ##setenv SAMPLE SingleGammaFlatPt10_100
0084 setenv SAMPLE H130GGgluonfusion
0085 #setenv SAMPLE PhotonJets_Pt_10
0086 #setenv SAMPLE GammaJets_Pt_80_120
0087 #setenv SAMPLE QCD_Pt_80_120
0088 
0089 
0090 if ( $RUNTYPE == Central ) then
0091 setenv HISTOPATHNAME_Photons_miniAOD DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME1}/Photons
0092 setenv HISTOPATHNAME_Photons DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME2}/Photons
0093 endif
0094 
0095 #==============END BASIC CONFIGURATION==================
0096 
0097 
0098 #Input root trees for the two cases to be compared 
0099 
0100 if ($SAMPLE == SingleGammaPt10) then
0101 
0102 if ( $RUNTYPE == Local ) then
0103 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_SingleGammaPt10.root
0104 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_SingleGammaPt10.root
0105 else if ( $RUNTYPE == Central &&  $UPGRADE == False ) then
0106 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt10_UP15__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0107 else if ( $RUNTYPE == Central && $UPGRADE == True ) then
0108 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt10_UP15__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0109 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt10_UP15__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0110 #setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt10_${UPGRADEVER}__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0111 else 
0112 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt10_UP15__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0113 endif
0114 
0115 
0116 
0117 else if ($SAMPLE == SingleGammaPt35) then 
0118 
0119 if ( $RUNTYPE == Local ) then
0120 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_SingleGammaPt35.root
0121 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_SingleGammaPt35.root
0122 else if ( $RUNTYPE == Central &&  $UPGRADE == False ) then
0123 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt35_UP15__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0124 else if ( $RUNTYPE == Central && $UPGRADE == True ) then
0125 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt35_UP15__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0126 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt35_UP15__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0127 #setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt35_${UPGRADEVER}__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0128 else 
0129 #setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValSingleGammaPt35_UP15__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0130 endif
0131 
0132 
0133 
0134 
0135 else if ($SAMPLE == SingleGammaFlatPt10_100) then 
0136 
0137 
0138 if ( $RUNTYPE == Local ) then
0139 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_SingleGammaFlatPt10To100.root
0140 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_SingleGammaFlatPt10To100.root
0141 endif 
0142 
0143 
0144 else if ($SAMPLE == H130GGgluonfusion) then 
0145 
0146 
0147 if ( $RUNTYPE == Local ) then
0148 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_H130GGgluonfusion.root
0149 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_H130GGgluonfusion.root
0150 else if ( $RUNTYPE == Central &&  $UPGRADE == False ) then
0151 
0152 
0153 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValH130GGgluonfusion_${UPGRADEVER}_${LHCENERGY}__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0154 
0155 else if ( $RUNTYPE == Central && $UPGRADE == True ) then
0156 
0157 #setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValH130GGgluonfusion_${LHCENERGY}__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQMIO.root
0158 #setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValH130GGgluonfusion_${LHCENERGY}__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQMIO.root
0159 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root
0160 setenv NEWFILE ${WorkDir1}/DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root
0161 else
0162 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValH130GGgluonfusion__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQMIO.root
0163 endif
0164 
0165 
0166 else if ($SAMPLE == PhotonJets_Pt_10) then
0167 
0168 if ( $RUNTYPE == Local ) then
0169 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_PhotonJets_Pt_10.root
0170 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_PhotonJets_Pt_10.root
0171 else if ( $RUNTYPE == Central ) then
0172 
0173 setenv OLDFILE ${WorkDir1}/DQM_V0001_R000000001__RelValPhotonJets_Pt_10__CMSSW_${OLDRELEASE}-${OLDGLOBALTAG}__DQM.root
0174 if ( $UPGRADE == True ) then
0175 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValPhotonJets_Pt_10_${UPGRADEVER}_${LHCENERGY}__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0176 else
0177 setenv NEWFILE ${WorkDir2}/DQM_V0001_R000000001__RelValPhotonJets_Pt_10__CMSSW_${NEWRELEASE}-${NEWGLOBALTAG}__DQM.root
0178 endif 
0179 endif
0180 
0181 else if ($SAMPLE ==  GammaJets_Pt_80_120) then 
0182 
0183 if ( $RUNTYPE == Local ) then
0184 setenv OLDFILE ${WorkDir1}/PhotonValidationRelVal${OLDRELEASE}_GammaJets_Pt_80_120.root
0185 setenv NEWFILE ${WorkDir2}/PhotonValidationRelVal${NEWRELEASE}_DQM.root
0186 endif
0187 
0188 else if ($SAMPLE == QCD_Pt_80_120) then 
0189 
0190 
0191 endif
0192 
0193 
0194 
0195 #Location of output.  The default will put your output in:
0196 #http://cmsdoc.cern.ch/Physics/egamma/www/validation/
0197 
0198 setenv CURRENTDIR $PWD
0199 setenv OUTPATH /afs/cern.ch/cms/Physics/egamma/www/validation/Photons
0200 cd $OUTPATH
0201 setenv NEWRELEASE {$NEWRELEASE}_MiniAOD
0202 #setenv NEWRELEASE {$NEWRELEASE}
0203 setenv OLDRELEASE {$OLDRELEASE}
0204 
0205 if (! -d $NEWRELEASE) then
0206   mkdir $NEWRELEASE
0207 endif
0208 setenv OUTPATH $OUTPATH/$NEWRELEASE
0209 cd $OUTPATH
0210 
0211 if (! -d ${TYPE}) then
0212   mkdir ${TYPE}
0213 endif
0214 setenv OUTPATH $OUTPATH/${TYPE}
0215 cd  $OUTPATH
0216 
0217 if (! -d vs${OLDRELEASE}) then
0218   mkdir vs${OLDRELEASE}
0219 endif
0220 setenv OUTPATH $OUTPATH/vs${OLDRELEASE}
0221 
0222 
0223 if ( $FASTSIM == True) then 
0224 setenv OUTDIR $OUTPATH/${SAMPLE}FastSim
0225 else if ( $FASTSIM == False && $UPGRADE == False && $PU == True ) then 
0226 setenv OUTDIR $OUTPATH/${SAMPLE}PU
0227 else if ( $FASTSIM == False && $PU == False && $UPGRADE == False ) then 
0228 setenv OUTDIR $OUTPATH/${SAMPLE}
0229 else if ( $SAMPLE == H130GGgluonfusion  && $UPGRADE == True && $PU == True && $FASTSIM == False) then
0230 setenv OUTDIR $OUTPATH/${SAMPLE}_${LHCENERGY}TeV_PU${PUlevel}
0231 else if ( $SAMPLE == H130GGgluonfusion  && $UPGRADE == True ) then
0232 setenv OUTDIR $OUTPATH/${SAMPLE}_${LHCENERGY}TeV
0233 else if ( $SAMPLE ==  PhotonJets_Pt_10  && $UPGRADE == True ) then
0234 setenv OUTDIR $OUTPATH/${SAMPLE}_${LHCENERGY}TeV
0235 else if ( $SAMPLE ==  SingleGammaPt10  && $UPGRADE == True ) then
0236 setenv OUTDIR $OUTPATH/${SAMPLE}
0237 else if ( $SAMPLE ==  SingleGammaPt35  && $UPGRADE == True ) then
0238 setenv OUTDIR $OUTPATH/${SAMPLE}
0239 endif
0240 
0241 
0242 #else if ( $SAMPLE == H130GGgluonfusion ||  PhotonJets_Pt_10  && $UPGRADE == True ) then
0243 #if ( $PU == True) then
0244 #setenv OUTDIR $OUTPATH/${SAMPLE}PU
0245 #else if ( $PU == False) then
0246 #setenv OUTDIR $OUTPATH/${SAMPLE}
0247 #endif
0248 
0249 
0250 
0251 if (! -d $OUTDIR) then
0252   cd $OUTPATH
0253   mkdir $OUTDIR
0254   cd $OUTDIR
0255   mkdir gifs
0256 endif
0257 cd $OUTDIR
0258 
0259 
0260 #The list of histograms to be compared for each TYPE can be configured below:
0261 
0262 
0263 if ( $TYPE == Photons ||  $TYPE == GEDPhotons ) then
0264 
0265 
0266 cat > efficiencyForPhotons <<EOF
0267 
0268 EOF
0269 #  recoEffVsEta
0270 #  recoEffVsPhi
0271 #  recoEffVsEt
0272 #  deadChVsEta
0273 #  deadChVsPhi
0274 #  deadChVsEt
0275 
0276 
0277 
0278 cat > scaledhistosForPhotons <<EOF
0279   scEta_miniAOD
0280   scPhi_miniAOD
0281   phoEAll_miniAOD
0282   phoEtAll_miniAOD
0283   eResAll_miniAOD
0284   eResBarrel_miniAOD
0285   eResEndcap_miniAOD
0286   sigmaEoEBarrel_miniAOD
0287   sigmaEoEEndcap_miniAOD
0288   isoTrkSolidConeDR04All_miniAOD
0289   isoTrkSolidConeDR04Barrel_miniAOD
0290   isoTrkSolidConeDR04Endcap_miniAOD
0291   nTrkSolidConeDR04All_miniAOD
0292   nTrkSolidConeDR04Barrel_miniAOD
0293   nTrkSolidConeDR04Endcap_miniAOD
0294   r9Barrel_miniAOD
0295   r9Endcap_miniAOD
0296   full5x5_r9Barrel_miniAOD
0297   full5x5_r9Endcap_miniAOD
0298   r1Barrel_miniAOD
0299   r1Endcap_miniAOD
0300   r2Barrel_miniAOD
0301   r2Endcap_miniAOD
0302   sigmaIetaIetaBarrel_miniAOD
0303   sigmaIetaIetaEndcap_miniAOD
0304   full5x5_sigmaIetaIetaBarrel_miniAOD
0305   full5x5_sigmaIetaIetaEndcap_miniAOD
0306   hOverEAll_miniAOD
0307   hOverEBarrel_miniAOD
0308   hOverEEndcap_miniAOD
0309   newhOverEAll_miniAOD
0310   newhOverEBarrel_miniAOD
0311   newhOverEEndcap_miniAOD
0312   hcalTowerSumEtConeDR04Barrel_miniAOD
0313   hcalTowerSumEtConeDR04Endcap_miniAOD
0314   hcalTowerBcSumEtConeDR04Barrel_miniAOD
0315   hcalTowerBcSumEtConeDR04Endcap_miniAOD
0316   ecalRecHitSumEtConeDR04Barrel_miniAOD
0317   ecalRecHitSumEtConeDR04Endcap_miniAOD
0318 
0319 
0320 EOF
0321 
0322 cat > scaledhistosForPhotonsLogScale <<EOF
0323   hOverEAll_miniAOD
0324   hOverEBarrel_miniAOD
0325   hOverEEndcap_miniAOD
0326   newhOverEAll_miniAOD
0327   newhOverEBarrel_miniAOD
0328   newhOverEEndcap_miniAOD
0329   hcalTowerSumEtConeDR04Barrel_miniAOD
0330   hcalTowerSumEtConeDR04Endcap_miniAOD
0331   hcalTowerBcSumEtConeDR04Barrel_miniAOD
0332   hcalTowerBcSumEtConeDR04Endcap_miniAOD
0333   ecalRecHitSumEtConeDR04Barrel_miniAOD
0334   ecalRecHitSumEtConeDR04Endcap_miniAOD
0335   r9Barrel_miniAOD
0336   r9Endcap_miniAOD
0337   full5x5_r9Barrel_miniAOD
0338   full5x5_r9Endcap_miniAOD
0339   r1Barrel_miniAOD
0340   r1Endcap_miniAOD
0341   r2Barrel_miniAOD
0342   r2Endcap_miniAOD
0343   sigmaIetaIetaBarrel_miniAOD
0344   sigmaIetaIetaEndcap_miniAOD
0345 
0346 
0347 
0348 EOF
0349 
0350 
0351 
0352 
0353 cat > scaledhistosGEDspecific <<EOF
0354   chargedHadIsoBarrel_miniAOD
0355   chargedHadIsoEndcap_miniAOD
0356   neutralHadIsoBarrel_miniAOD
0357   neutralHadIsoEndcap_miniAOD
0358   photonIsoBarrel_miniAOD
0359   photonIsoEndcap_miniAOD
0360 
0361 EOF
0362 
0363 
0364 cat > scaledhistosGEDspecificLogScale <<EOF
0365   photonIsoBarrel_miniAOD
0366   photonIsoEndcap_miniAOD
0367   chargedHadIsoBarrel_miniAOD
0368   chargedHadIsoEndcap_miniAOD
0369   neutralHadIsoBarrel_miniAOD
0370   neutralHadIsoEndcap_miniAOD
0371 
0372 
0373 EOF
0374 
0375 
0376 
0377 
0378 endif
0379 
0380 #=================END CONFIGURATION=====================
0381 
0382 if (-e validation.C) rm validation.C
0383 touch validation.C
0384 cat > begin.C <<EOF
0385 {
0386 TFile *file_old = TFile::Open("$OLDFILE");
0387 TFile *file_new = TFile::Open("$NEWFILE");
0388 
0389 int nBins = 0;
0390 float xMin= 0;
0391 float xMax= 0;
0392 TH1F* hold;
0393 TH1F* hnew;
0394 TH1F* hratio;
0395 TLine *l;
0396 Double_t nnew;
0397 Double_t mnew;
0398 Double_t mold;
0399 Double_t nold;
0400 int scolor=kBlack;
0401 int rcolor=kPink+8;
0402 Double_t value;
0403 
0404 EOF
0405 cat begin.C >>& validation.C
0406 rm begin.C
0407 
0408 setenv N 1
0409 
0410 
0411 
0412 foreach i (`cat scaledhistosForPhotons`)
0413   cat > temp$N.C <<EOF
0414 TCanvas *c$i = new TCanvas("c$i");
0415 c$i->SetFillColor(10);
0416 c$i->Divide(1,2);
0417 c$i->cd(1);
0418 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0419 nBins = $i->GetNbinsX();
0420 xMin=$i->GetBinLowEdge(1);
0421 xMax=$i->GetBinLowEdge(nBins)+$i->GetBinWidth(nBins);
0422 mnew=$i->GetMaximum();
0423 nnew=$i->GetEntries();
0424 file_old->cd("$HISTOPATHNAME_Photons");
0425 hold=new  TH1F("hold"," ",nBins,xMin,xMax);
0426 hold=$i;
0427 mold=$i->GetMaximum();
0428 nold=$i->GetEntries();
0429 if ( $i==phoEAll_miniAOD ) {  
0430 $i->GetYaxis()->SetRangeUser(0.,2000.);
0431 } else if ( $i==r9Barrel_miniAOD ) {
0432 $i->GetXaxis()->SetRangeUser(0.8,1.);
0433 $i->GetYaxis()->SetRangeUser(0.,3500);
0434 } else if ( $i==r9Endcap_miniAOD ) {
0435 $i->GetXaxis()->SetRangeUser(0.8,1.);
0436 $i->GetYaxis()->SetRangeUser(0.,1000);
0437 } else if ( $i==sigmaIetaIetaBarrel_miniAOD ) {
0438 $i->GetXaxis()->SetRangeUser(0.,0.02);
0439 }  else if ( $i==sigmaIetaIetaEndcap_miniAOD ) {
0440 $i->GetXaxis()->SetRangeUser(0.,0.06);
0441 }  else if ( $i==r2Barrel_miniAOD || $i==r2Endcap_miniAOD) {
0442 $i->GetXaxis()->SetRangeUser(0.7,1.02);
0443 } 
0444 $i->SetStats(1111);
0445 $i->SetMinimum(0.);
0446 $i->Draw();
0447 gPad->Update();
0448 TPaveStats *os$i = (TPaveStats*)$i->FindObject("stats");
0449 os$i->SetX1NDC(0.82);
0450 os$i->SetX2NDC(0.92);
0451 os$i->SetY1NDC(0.8);
0452 os$i->SetY2NDC(0.97);
0453 os$i->SetTextColor(rcolor);
0454 os$i->SetLineColor(rcolor);
0455 if ( mnew > mold+sqrt(mold) )  { 
0456 value=mnew+2*sqrt(mnew);
0457 $i->SetMaximum(value); 
0458 }  else { 
0459 value=mold+2*sqrt(mold);
0460 $i->SetMaximum(value); 
0461 }
0462 $i->SetLineColor(rcolor);
0463 $i->SetFillColor(rcolor);
0464 //$i->SetLineWidth(3);
0465 $i->Draw();
0466 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0467 nnew=$i->GetEntries();
0468 $i->SetStats(1111);
0469 $i->SetLineColor(scolor);
0470 $i->SetMarkerColor(scolor);
0471 $i->SetMarkerStyle(20);
0472 $i->SetMarkerSize(0.8);
0473 hnew=new  TH1F("hnew"," ",nBins,xMin,xMax);
0474 hnew=$i;
0475 $i->Draw("e1sames");
0476 gPad->Update();
0477 TPaveStats *s$i = (TPaveStats*)$i->FindObject("stats");
0478 s$i->SetX1NDC(0.82);
0479 s$i->SetX2NDC(0.92);
0480 s$i->SetY1NDC(0.55);
0481 s$i->SetY2NDC(0.72);
0482 c$i->cd(2);
0483 hratio=new  TH1F("hratio"," ",nBins,xMin,xMax);
0484 hratio->Divide(hnew,hold);
0485 for ( int i=1; i<=hratio->GetNbinsX(); i++ ) {
0486 float num=hnew->GetBinContent(i);
0487 float den=hold->GetBinContent(i);
0488 float dNum=hnew->GetBinError(i);
0489 float dDen=hold->GetBinError(i);
0490 float erro=0;
0491 if ( num!=0 && den!=0) {
0492 erro= ((1./den)*(1./den)*dNum*dNum) + ((num*num)/(den*den*den*den) * (dDen*dDen));
0493 erro=sqrt(erro);
0494 }
0495 hratio->SetBinError(i, erro);
0496 }
0497 hratio->SetStats(0);
0498 hratio->SetLineColor(1);
0499 hratio->SetLineWidth(2);
0500 if ( $i==r9Barrel_miniAOD || $i==r9Endcap_miniAOD ) {
0501 hratio->GetXaxis()->SetRangeUser(0.8,1.);
0502 hratio->GetYaxis()->SetRangeUser(0.,2.);
0503 } else if ( $i==eResAll_miniAOD || $i==eResBarrel_miniAOD || $i==eResEndcap_miniAOD ) {
0504 hratio->GetYaxis()->SetRangeUser(0.,2.); 
0505 } else if ( $i==sigmaIetaIetaBarrel_miniAOD ) {
0506 hratio->GetXaxis()->SetRangeUser(0.,0.02);
0507 }  else if ( $i==sigmaIetaIetaEndcap_miniAOD ) {
0508 hratio->GetXaxis()->SetRangeUser(0.,0.06);
0509 }  else if ( $i==r2Barrel_miniAOD || $i==r2Endcap_miniAOD) {
0510 hratio->GetXaxis()->SetRangeUser(0.7,1.02);
0511 hratio->GetYaxis()->SetRangeUser(0.,5.);
0512 } else {
0513 hratio->GetYaxis()->SetRangeUser(0.,2.);
0514 }
0515 hratio->Draw("e");
0516 l = new TLine(xMin,1.,xMax,1.);
0517 l->Draw(); 
0518 c$i->SaveAs("gifs/$i.gif");
0519 EOF
0520   setenv N `expr $N + 1`
0521 end
0522 
0523 
0524 foreach i (`cat scaledhistosGEDspecific`)
0525   cat > temp$N.C <<EOF
0526 TCanvas *c$i = new TCanvas("c$i");
0527 c$i->SetFillColor(10);
0528 c$i->Divide(1,2);
0529 c$i->cd(1);
0530 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0531 nBins =$i->GetNbinsX();
0532 xMin=$i->GetBinLowEdge(1);
0533 xMax=$i->GetBinLowEdge(nBins)+$i->GetBinWidth(nBins);
0534 mnew=$i->GetMaximum();
0535 nnew=$i->GetEntries();
0536 file_old->cd("$HISTOPATHNAME_Photons");
0537 hold=new  TH1F("hold"," ",nBins,xMin,xMax);
0538 hold=$i;
0539 mold=$i->GetMaximum();
0540 nold=$i->GetEntries();
0541 if ( $i==phoEAll_miniAOD ) {  
0542 $i->GetYaxis()->SetRangeUser(0.,2000.);
0543 }
0544 if ($i==chargedHadIsoBarrel_miniAOD || $i==chargedHadIsoBarrel_miniAOD ) {
0545 $i->GetXaxis()->SetRangeUser(0.,12.);
0546 }
0547 $i->SetStats(11111);
0548 $i->SetMinimum(0.);
0549 $i->Draw();
0550 gPad->Update();
0551 TPaveStats *os2$i = (TPaveStats*)$i->FindObject("stats");
0552 os2$i->SetTextColor(rcolor);
0553 os2$i->SetLineColor(rcolor);
0554 
0555 if ( mnew > mold+sqrt(mold) )  {
0556 value=mnew+2*sqrt(mnew); 
0557 $i->SetMaximum(value); 
0558 }  else { 
0559 value=mold+2*sqrt(mold);
0560 $i->SetMaximum(value); 
0561 }
0562 $i->SetLineColor(rcolor);
0563 $i->SetFillColor(rcolor);
0564 $i->Draw();
0565 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0566 nnew=$i->GetEntries();
0567 $i->SetStats(111111);
0568 $i->SetLineColor(scolor);
0569 $i->SetMarkerColor(scolor);
0570 $i->SetMarkerStyle(20);
0571 $i->SetMarkerSize(0.8);
0572 hnew=new  TH1F("hnew"," ",nBins,xMin,xMax);
0573 hnew=$i;
0574 $i->Draw("e1sames");
0575 gPad->Update();
0576 TPaveStats *s2$i = (TPaveStats*)$i->FindObject("stats");
0577 s2$i->SetY1NDC(.5);
0578 s2$i->SetY2NDC(.67);
0579 c$i->cd(2);
0580 hratio=new  TH1F("hratio"," ",nBins,xMin,xMax);
0581 hratio->Divide(hnew,hold);
0582 for ( int i=1; i<=hratio->GetNbinsX(); i++ ) {
0583 float num=hnew->GetBinContent(i);
0584 float den=hold->GetBinContent(i);
0585 float dNum=hnew->GetBinError(i);
0586 float dDen=hold->GetBinError(i);
0587 float erro=0;
0588 if ( num!=0 && den!=0) {
0589 erro= ((1./den)*(1./den)*dNum*dNum) + ((num*num)/(den*den*den*den) * (dDen*dDen));
0590 erro=sqrt(erro);
0591 }
0592 hratio->SetBinError(i, erro);
0593 }
0594 hratio->SetStats(0);
0595 hratio->SetLineColor(1);
0596 hratio->SetLineWidth(2);
0597 hratio->SetMinimum(0.);
0598 hratio->SetMaximum(4.);
0599 hratio->Draw("e");
0600 l = new TLine(xMin,1.,xMax,1.);
0601 l->Draw(); 
0602 c$i->SaveAs("gifs/$i.gif");
0603 EOF
0604   setenv N `expr $N + 1`
0605 end
0606 
0607 
0608 
0609 foreach i (`cat scaledhistosGEDspecificLogScale`)
0610   cat > temp$N.C <<EOF
0611 TCanvas *cc$i = new TCanvas("cc$i");
0612 cc$i->cd();
0613 cc$i->SetFillColor(10);
0614 cc$i->SetLogy();
0615 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0616 nnew=$i->GetEntries();
0617 file_old->cd("$HISTOPATHNAME_Photons");
0618 if ( $i==hcalTowerSumEtConeDR04Barrel_miniAOD ||  $i==hcalTowerSumEtConeDR04Endcap_miniAOD  ) {  
0619 $i->GetXaxis()->SetRangeUser(0.,10.);
0620 }
0621 nold=$i->GetEntries();
0622 $i->SetStats(1111);
0623 $i->SetMinimum(1);
0624 $i->SetLineColor(rcolor);
0625 $i->SetFillColor(rcolor);
0626 $i->Draw();
0627 gPad->Update();
0628 TPaveStats *os3$i = (TPaveStats*)$i->FindObject("stats");
0629 os3$i->SetTextColor(rcolor);
0630 os3$i->SetLineColor(rcolor);
0631 
0632 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0633 nnew=$i->GetEntries();
0634 $i->SetStats(11111);
0635 $i->SetLineColor(scolor);
0636 $i->SetMarkerColor(scolor);
0637 $i->SetMarkerStyle(20);
0638 $i->SetMarkerSize(1);
0639 $i->Draw("e1sames");
0640 gPad->Update();
0641 TPaveStats *s3$i = (TPaveStats*)$i->FindObject("stats");
0642 s3$i->SetY1NDC(.5);
0643 s3$i->SetY2NDC(.67);
0644 cc$i->SaveAs("gifs/log$i.gif");
0645 EOF
0646   setenv N `expr $N + 1`
0647 end
0648 
0649 
0650 
0651 
0652 
0653 foreach i (`cat scaledhistosForPhotonsLogScale`)
0654   cat > temp$N.C <<EOF
0655 TCanvas *cc$i = new TCanvas("cc$i");
0656 cc$i->cd();
0657 cc$i->SetFillColor(10);
0658 cc$i->SetLogy();
0659 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0660 nnew=$i->GetEntries();
0661 file_old->cd("$HISTOPATHNAME_Photons");
0662 if ( $i==hcalTowerSumEtConeDR04Barrel_miniAOD ||  $i==hcalTowerSumEtConeDR04Endcap_miniAOD  ) {  
0663 $i->GetXaxis()->SetRangeUser(0.,10.);
0664 }
0665 nold=$i->GetEntries();
0666 $i->SetStats(1111);
0667 $i->SetMinimum(1);
0668 $i->SetLineColor(rcolor);
0669 $i->SetFillColor(rcolor);
0670 $i->Draw();
0671 gPad->Update();
0672 TPaveStats *os4$i = (TPaveStats*)$i->FindObject("stats");
0673 os4$i->SetTextColor(rcolor);
0674 os4$i->SetLineColor(rcolor);
0675 file_new->cd("$HISTOPATHNAME_Photons_miniAOD");
0676 nnew=$i->GetEntries();
0677 $i->SetStats(11111);
0678 $i->SetLineColor(scolor);
0679 $i->SetMarkerColor(scolor);
0680 $i->SetMarkerStyle(20);
0681 $i->SetMarkerSize(1);
0682 $i->Draw("e1sames");
0683 gPad->Update();
0684 TPaveStats *s4$i = (TPaveStats*)$i->FindObject("stats");
0685 s4$i->SetY1NDC(.5);
0686 s4$i->SetY2NDC(.67);
0687 cc$i->SaveAs("gifs/log$i.gif");
0688 EOF
0689   setenv N `expr $N + 1`
0690 end
0691 
0692 
0693 
0694 setenv NTOT `expr $N - 1`
0695 setenv N 1
0696 while ( $N <= $NTOT )
0697   cat temp$N.C >>& validation.C
0698   rm temp$N.C
0699   setenv N `expr $N + 1`
0700 end
0701 
0702 cat > end.C <<EOF
0703 }
0704 EOF
0705 cat end.C >>& validation.C
0706 rm end.C
0707 
0708 
0709 if  ( $PU == True &&  $FASTSIM == False && $SAMPLE !=  H130GGgluonfusion  && $UPGRADE == True ) then
0710 #setenv SAMPLE ${SAMPLE}PU
0711 else if ( $PU == False && $FASTSIM == True) then
0712 setenv SAMPLE ${SAMPLE}FastSim
0713 else if ( $SAMPLE == H130GGgluonfusion && $UPGRADE == True && $PU == False  &&  $FASTSIM == False) then
0714 setenv SAMPLE ${SAMPLE}_${LHCENERGY}TeV
0715 else if ( $SAMPLE == H130GGgluonfusion && $UPGRADE == True &&  $PU == True  &&  $FASTSIM == False ) then
0716 setenv SAMPLE ${SAMPLE}_${LHCENERGY}TeV_PU${PUlevel}
0717 endif
0718 
0719 echo $SAMPLE
0720 
0721 if (-e validation.html) rm validation.html
0722 if (-e validationPlotsTemplateForMiniAOD.html) rm validationPlotsTemplateForMiniAOD.html
0723 cp ${CURRENTDIR}/validationPlotsTemplateForMiniAOD.html validationPlotsTemplateForMiniAOD.html
0724 touch validation.html
0725 cat > begin.html <<EOF
0726 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0727 <html>
0728 <head>
0729 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
0730 <title>$NEWRELEASE vs $OLDRELEASE $TYPE validation</title>
0731 </head>
0732 
0733 <h1>$NEWRELEASE vs $OLDRELEASE $TYPE validation
0734 <br>
0735  $SAMPLE 
0736 </h1>
0737 
0738 <br>
0739 In all plots below, $OLDRELEASE is in purple , $NEWRELEASE in black. 
0740 <br>
0741 Click on the plots to see them enlarged.
0742 <br>
0743 Responsible: N. Marinelli
0744 <br>
0745 <br>
0746 
0747 
0748 
0749 EOF
0750 cat begin.html >>& validation.html
0751 rm begin.html
0752 cat  validationPlotsTemplateForMiniAOD.html >>& validation.html
0753 rm   validationPlotsTemplateForMiniAOD.html
0754 
0755 rm efficiencyForPhotons
0756 rm scaledhistosForPhotons
0757 rm scaledhistosForPhotonsLogScale
0758 rm scaledhistosGEDspecific
0759 rm scaledhistosGEDspecificLogScale
0760 
0761 
0762 #echo "Now paste the following into your terminal window:"
0763 #echo ""
0764 echo "cd $OUTDIR"
0765 #echo " root -b"
0766 #echo ".x validation.C"
0767 #echo ".q"
0768 #echo "cd $CURRENTDIR"
0769 #echo ""
0770 
0771 
0772 root -b -l -q validation.C
0773 cd $CURRENTDIR
0774 echo "Then you can view your validation plots here:"
0775 echo "http://cmsdoc.cern.ch/Physics/egamma/www/$OUTPATH/validation.html"