Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:05

0001 #!/bin/csh
0002 
0003 #This script can be used to generate a web page to compare histograms from 
0004 #two input root files produced using the EDAnalyzers in RecoEgamma/Examples,
0005 #by running one of:
0006 #
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 ANALYZERNAME1 PhotonValidator
0021 setenv ANALYZERNAME2 pfPhotonValidator
0022 #setenv TYPE GEDPhotons
0023 setenv TYPE GEDPhotons
0024 setenv COMPAREWITH Photons
0025 setenv CMSSWver1 7_0_0
0026 setenv RELEASE   7_0_0
0027 setenv PRERELEASE pre11
0028 setenv LHCENERGY   13
0029 setenv UPGRADE True
0030 setenv PU True
0031 setenv PUlevel 25ns
0032 
0033 #setenv FULLGLOBALTAG POSTLS162_V4_OldEG-v1
0034 setenv FULLGLOBALTAG PU${PUlevel}_POSTLS162_V4-v1
0035 
0036 setenv RELEASE ${RELEASE}_${PRERELEASE}
0037 #setenv RELEASE ${RELEASE}
0038 
0039 
0040 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}/src/Validation/RecoEgamma/test
0041 setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}_${PRERELEASE}/src/Validation/RecoEgamma/test
0042 #setenv WorkDir1   /afs/cern.ch/user/n/nancy/scratch0/CMSSW/test/CMSSW_${CMSSWver1}/src/Validation/RecoEgamma/test
0043 
0044 
0045 #Name of sample (affects output directory name and htmldescription only) 
0046 
0047 
0048 
0049 setenv HISTOPATHNAME1_Efficiencies DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME1}/Efficiencies
0050 setenv HISTOPATHNAME1_Photons      DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME1}/Photons
0051 setenv HISTOPATHNAME1_Conversions  DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME1}/ConversionInfo
0052 setenv HISTOPATHNAME2_Efficiencies DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME2}/Efficiencies
0053 setenv HISTOPATHNAME2_Photons      DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME2}/Photons
0054 setenv HISTOPATHNAME2_Conversions  DQMData/Run\ 1/EgammaV/Run\ summary/${ANALYZERNAME2}/ConversionInfo
0055 
0056 
0057 
0058 #setenv SAMPLE SingleGammaPt10
0059 #setenv SAMPLE SingleGammaPt35
0060 setenv SAMPLE H130GGgluonfusion
0061 #setenv SAMPLE PhotonJets_Pt_10
0062 #setenv SAMPLE QCD_Pt_80_120
0063 
0064 
0065 
0066 #==============END BASIC CONFIGURATION==================
0067 
0068 
0069 #Input root trees for the two cases to be compared 
0070 
0071 
0072 if ($SAMPLE == SingleGammaPt10) then
0073 
0074 setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt10_UP15__CMSSW_${RELEASE}-${FULLGLOBALTAG}__DQM.root
0075 
0076 
0077 else if ($SAMPLE == SingleGammaPt35) then 
0078 
0079 setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__RelValSingleGammaPt35__CMSSW_${RELEASE}-${FULLGLOBALTAG}__DQM.root
0080 
0081 
0082 else if ($SAMPLE == H130GGgluonfusion) then 
0083 
0084 setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__RelValH130GGgluonfusion_${LHCENERGY}__CMSSW_${RELEASE}-${FULLGLOBALTAG}__DQM.root
0085 #setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__RelValH130GGgluonfusion__CMSSW_${RELEASE}-${FULLGLOBALTAG}__DQM.root
0086 #setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO_2K.root
0087 
0088 
0089 
0090 else if ($SAMPLE == PhotonJets_Pt_10) then
0091 
0092 setenv ROOTFILE ${WorkDir1}/DQM_V0001_R000000001__PhotonJets_Pt_10__CMSSW_${RELEASE}-${FULLGLOBALTAG}__DQM.root
0093 
0094 else if ($SAMPLE == QCD_Pt_80_120) then 
0095 
0096 
0097 
0098 endif
0099 
0100 
0101 
0102 #Location of output.  The default will put your output in:
0103 #http://cmsdoc.cern.ch/Physics/egamma/www/validation/
0104 
0105 setenv CURRENTDIR $PWD
0106 setenv OUTPATH /afs/cern.ch/cms/Physics/egamma/www/validation
0107 cd $OUTPATH
0108 
0109 #setenv RELEASE {$RELEASE}_OldEG
0110 #setenv RELEASE {$RELEASE}_OldTrk
0111 
0112 if (! -d $RELEASE) then
0113   mkdir $RELEASE
0114 endif
0115 setenv OUTPATH $OUTPATH/$RELEASE
0116 cd $OUTPATH
0117 
0118 if (! -d ${TYPE}) then
0119   mkdir ${TYPE}
0120 endif
0121 setenv OUTPATH $OUTPATH/${TYPE}
0122 cd  $OUTPATH
0123 
0124 if (! -d vs${COMPAREWITH} ) then
0125   mkdir vs${COMPAREWITH}
0126 endif
0127 setenv OUTPATH $OUTPATH/vs${COMPAREWITH}
0128 
0129 
0130 if ( $UPGRADE == True && $PU == False ) then
0131 setenv OUTDIR $OUTPATH/${SAMPLE}_${LHCENERGY}TeV
0132 else if ( $UPGRADE == True && $PU == True ) then
0133 setenv OUTDIR $OUTPATH/${SAMPLE}_${LHCENERGY}TeV_PU${PUlevel}
0134 else 
0135 setenv OUTDIR $OUTPATH/${SAMPLE}
0136 endif
0137 
0138 if (! -d $OUTDIR) then
0139   cd $OUTPATH
0140   mkdir $OUTDIR
0141   cd $OUTDIR
0142   mkdir gifs
0143 endif
0144 cd $OUTDIR
0145 
0146 
0147 #The list of histograms to be compared for each TYPE can be configured below:
0148 
0149 
0150 if ( $TYPE == oldpfPhotons || $TYPE == GEDPhotons  || $TYPE == fullGEDPhotons  ) then
0151 
0152 
0153 cat > efficiencyForPhotons <<EOF
0154   recoEffVsEta
0155   recoEffVsPhi
0156   recoEffVsEt
0157   deadChVsEta
0158   deadChVsPhi
0159   deadChVsEt
0160 EOF
0161 
0162 
0163 #  gamgamMassAll
0164 #  gamgamMassBarrel
0165 #  gamgamMassEndcap
0166 #  gamgamMassNoConvAll
0167 #  gamgamMassNoConvBarrel
0168 #  gamgamMassNoConvEndcap
0169 #  gamgamMassConvAll
0170 #  gamgamMassConvBarrel
0171 #  gamgamMassConvEndcap
0172 
0173 
0174 cat > scaledhistosForPhotons <<EOF
0175   nOfflineVtx
0176   scEta
0177   scPhi
0178   scEAll
0179   scEtAll
0180   phoEta
0181   phoPhi
0182   phoDEta
0183   phoDPhi
0184   phoEAll
0185   phoEtAll
0186   eResAll
0187   eResBarrel
0188   eResEndcap
0189   eResunconvAll
0190   eResunconvBarrel
0191   eResunconvEndcap
0192   eResconvAll
0193   eResconvBarrel
0194   eResconvEndcap
0195   isoTrkSolidConeDR04All
0196   isoTrkSolidConeDR04Barrel
0197   isoTrkSolidConeDR04Endcap
0198   nTrkSolidConeDR04All
0199   nTrkSolidConeDR04Barrel
0200   nTrkSolidConeDR04Endcap
0201   r9Barrel
0202   r9Endcap
0203   r1Barrel
0204   r1Endcap
0205   r2Barrel
0206   r2Endcap
0207   sigmaIetaIetaBarrel
0208   sigmaIetaIetaEndcap
0209   hOverEAll
0210   hOverEBarrel
0211   hOverEEndcap
0212   newhOverEAll
0213   newhOverEBarrel
0214   newhOverEEndcap
0215   hcalTowerSumEtConeDR04Barrel
0216   hcalTowerSumEtConeDR04Endcap
0217   hcalTowerBcSumEtConeDR04Barrel
0218   hcalTowerBcSumEtConeDR04Endcap
0219   ecalRecHitSumEtConeDR04Barrel
0220   ecalRecHitSumEtConeDR04Endcap
0221 
0222 EOF
0223 
0224 cat > scaledhistosForPhotonsLogScale <<EOF
0225   hOverEAll
0226   hOverEBarrel
0227   hOverEEndcap
0228   newhOverEAll
0229   newhOverEBarrel
0230   newhOverEEndcap
0231   hcalTowerSumEtConeDR04Barrel
0232   hcalTowerSumEtConeDR04Endcap
0233   hcalTowerBcSumEtConeDR04Barrel
0234   hcalTowerBcSumEtConeDR04Endcap
0235   ecalRecHitSumEtConeDR04Barrel
0236   ecalRecHitSumEtConeDR04Endcap
0237   r9Barrel
0238   r9Endcap
0239   r1Barrel
0240   r1Endcap
0241   r2Barrel
0242   r2Endcap
0243   sigmaIetaIetaAll
0244   sigmaIetaIetaBarrel
0245   sigmaIetaIetaEndcap
0246 
0247 
0248 EOF
0249 
0250 
0251 cat > unscaledhistosForPhotons <<EOF
0252 pEResVsR9Barrel
0253 pEResVsR9Endcap
0254 scpEResVsR9Barrel
0255 scpEResVsR9Endcap
0256 pEResVsEtAll
0257 pEResVsEtBarrel
0258 pEResVsEtEndcap
0259 pEResVsEtaAll
0260 pEResVsEtaUnconv
0261 pEResVsEtaConv
0262 pEcalRecHitSumEtConeDR04VsEtaAll
0263 pEcalRecHitSumEtConeDR04VsEtBarrel
0264 pEcalRecHitSumEtConeDR04VsEtEndcap
0265 pHcalTowerSumEtConeDR04VsEtaAll
0266 pHcalTowerSumEtConeDR04VsEtBarrel
0267 pHcalTowerSumEtConeDR04VsEtEndcap
0268 pHcalTowerBcSumEtConeDR04VsEtaAll
0269 pHcalTowerBcSumEtConeDR04VsEtBarrel
0270 pHcalTowerBcSumEtConeDR04VsEtEndcap
0271 pHoverEVsEtaAll
0272 pHoverEVsEtAll
0273 pnewHoverEVsEtaAll
0274 pnewHoverEVsEtAll
0275 
0276 
0277 EOF
0278 
0279 
0280 
0281 
0282 
0283 
0284 cat > efficiencyForConvertedPhotons <<EOF
0285 
0286   convEffVsEtaTwoTracks
0287   convEffVsPhiTwoTracks
0288   convEffVsRTwoTracks
0289   convEffVsZTwoTracks
0290   convEffVsEtTwoTracks
0291   convEffVsEtaTwoTracksAndVtxProbGT0
0292   convEffVsRTwoTracksAndVtxProbGT0
0293 
0294 EOF
0295 
0296 
0297 
0298 cat > scaledhistosForConvertedPhotons <<EOF
0299 
0300   convEta2
0301   convPhi
0302   convEResAll
0303   convEResBarrel
0304   convEResEndcap
0305   PoverEtracksAll
0306   PoverEtracksBarrel 
0307   PoverEtracksEndcap
0308   convPtResAll
0309   convPtResBarrel
0310   convPtResEndcap
0311   convVtxdR
0312   convVtxdR_barrel
0313   convVtxdR_endcap
0314   convVtxdZ
0315   convVtxdZ_barrel
0316   convVtxdZ_endcap
0317   convVtxdX
0318   convVtxdX_barrel
0319   convVtxdX_endcap
0320   convVtxdY
0321   convVtxdY_barrel
0322   convVtxdY_endcap
0323   mvaOutAll
0324   mvaOutBarrel
0325   mvaOutEndcap
0326 
0327 EOF
0328 
0329 
0330 cat > scaledhistosForConvertedPhotonsLogScale <<EOF
0331   EoverPtracksAll
0332   EoverPtracksBarrel 
0333   EoverPtracksEndcap
0334   vtxChi2ProbAll
0335   vtxChi2ProbBarrel
0336   vtxChi2ProbEndcap
0337 
0338 
0339 EOF
0340 
0341 
0342 
0343 cat > unscaledhistosForConvertedPhotons <<EOF
0344 pEoverEtrueVsEtaAll
0345 pEoverPVsEtaAll
0346 pEoverPVsRAll
0347 pConvVtxdRVsR
0348 pConvVtxdRVsEta
0349 pConvVtxdXVsX
0350 pConvVtxdYVsY
0351 pConvVtxdZVsZ
0352 EOF
0353 
0354 
0355 cat > 2dhistosForConvertedPhotons <<EOF
0356   convVtxRvsZAll
0357 EOF
0358 
0359 cat > projectionsForConvertedPhotons <<EOF
0360    convVtxRvsZBarrel
0361    convVtxRvsZEndcap
0362 EOF
0363 
0364 
0365 
0366 cat > fakeRateForConvertedPhotons <<EOF
0367 
0368   convFakeRateVsEtaTwoTracks
0369   convFakeRateVsPhiTwoTracks
0370   convFakeRateVsRTwoTracks
0371   convFakeRateVsZTwoTracks
0372   convFakeRateVsEtTwoTracks
0373 
0374 EOF
0375 
0376 
0377 
0378 cat > scaledhistosForTracks <<EOF
0379 
0380 tkChi2AllTracks
0381 hTkPtPullAll
0382 hTkPtPullBarrel
0383 hTkPtPullEndcap
0384 hDPhiTracksAtVtxAll
0385 hDCotTracksAll
0386 zPVFromTracksAll
0387 zPVFromTracksBarrel
0388 zPVFromTracksEndcap
0389 dzPVFromTracksAll
0390 dzPVFromTracksBarrel
0391 dzPVFromTracksEndcap
0392 
0393 EOF
0394 
0395 cat > unscaledhistosForTracks <<EOF
0396 h_nHitsVsEtaAllTracks
0397 h_nHitsVsRAllTracks
0398 pChi2VsEtaAll
0399 pChi2VsRAll
0400 pDCotTracksVsEtaAll
0401 pDCotTracksVsRAll
0402 pdzPVVsR
0403 
0404 
0405 EOF
0406 
0407 
0408 
0409 
0410 
0411 endif
0412 
0413 
0414 
0415 
0416 
0417 
0418 #=================END CONFIGURATION=====================
0419 
0420 if (-e validation.C) rm validation.C
0421 touch validation.C
0422 cat > begin.C <<EOF
0423 {
0424 TFile *file = TFile::Open("$ROOTFILE");
0425 
0426 EOF
0427 cat begin.C >>& validation.C
0428 rm begin.C
0429 
0430 setenv N 1
0431 
0432 
0433 
0434 
0435 
0436 foreach i (`cat efficiencyForPhotons`)
0437   cat > temp$N.C <<EOF
0438 
0439 TCanvas *c$i = new TCanvas("c$i");
0440 c$i->SetFillColor(10);
0441 c$i->Divide(1,2);
0442 c$i->cd(1);
0443 file->cd("$HISTOPATHNAME1_Efficiencies");
0444 $i->SetStats(0);
0445 int nBins = $i->GetNbinsX();
0446 float xMin=$i->GetBinLowEdge(1);
0447 float xMax=$i->GetBinLowEdge(nBins)+$i->GetBinWidth(nBins);
0448 TH1F* hold=new  TH1F("hold"," ",nBins,xMin,xMax);
0449 hold=$i;
0450 if ( $i==deadChVsEta ||  $i==deadChVsPhi ||  $i==deadChVsEt ) {
0451 $i->SetMinimum(0.);
0452 $i->SetMaximum(0.2);
0453 } else if (  $i==recoEffVsEt ) {
0454 $i->GetXaxis()->SetRangeUser(0.,200.);
0455 } else {
0456 $i->SetMinimum(0.);
0457 $i->SetMaximum(1.1);
0458 }
0459 $i->SetLineColor(kPink+8);
0460 $i->SetMarkerColor(kPink+8);
0461 $i->SetMarkerStyle(20);
0462 $i->SetMarkerSize(1);
0463 $i->SetLineWidth(1);
0464 $i->Draw();
0465 file->cd("$HISTOPATHNAME2_Efficiencies");
0466 $i->SetStats(0);
0467 $i->SetMinimum(0.);
0468 $i->SetMaximum(1.1);
0469 TH1F* hnew=new  TH1F("hnew"," ",nBins,xMin,xMax);
0470 hnew=$i;
0471 $i->SetLineColor(kBlack);
0472 $i->SetMarkerColor(kBlack);
0473 $i->SetMarkerStyle(20);
0474 $i->SetMarkerSize(1);
0475 $i->SetLineWidth(1);
0476 $i->Draw("same");
0477 c$i->cd(2);
0478 TH1F* ratio=new  TH1F("ratio"," ",nBins,xMin,xMax);
0479 ratio->Divide(hnew,hold);
0480 ratio->SetStats(0);
0481 for ( int i=1; i<=ratio->GetNbinsX(); i++ ) {
0482 float num=hnew->GetBinContent(i);
0483 float den=hold->GetBinContent(i);
0484 float dNum=hnew->GetBinError(i);
0485 float dDen=hold->GetBinError(i);
0486 float erro=0;
0487 if ( num!=0 && den!=0) {
0488 erro= ((1./den)*(1./den)*dNum*dNum) + ((num*num)/(den*den*den*den) * (dDen*dDen));
0489 erro=sqrt(erro);
0490 }
0491 ratio->SetBinError(i, erro);
0492 }
0493 ratio->SetLineColor(1);
0494 ratio->SetLineWidth(2);
0495 ratio->SetMinimum(0.);
0496 ratio->SetMaximum(2.);
0497 ratio->Draw("e");
0498 TLine *l = new TLine(xMin,1.,xMax,1.);
0499 l->Draw(); 
0500 c$i->SaveAs("gifs/$i.gif");
0501 
0502 
0503 EOF
0504   setenv N `expr $N + 1`
0505 end
0506 
0507 
0508 foreach i (`cat scaledhistosForPhotons`)
0509   cat > temp$N.C <<EOF
0510 
0511 TCanvas *c$i = new TCanvas("c$i");
0512 c$i->SetFillColor(10);
0513 c$i->Divide(1,2);
0514 c$i->cd(1);
0515 file->cd("$HISTOPATHNAME2_Photons");
0516 int nBins = $i->GetNbinsX();
0517 float xMin=$i->GetBinLowEdge(1);
0518 float xMax=$i->GetBinLowEdge(nBins)+$i->GetBinWidth(nBins);
0519 Double_t mnew=$i->GetMaximum();
0520 Double_t nnew=$i->GetEntries();
0521 file->cd("$HISTOPATHNAME1_Photons");
0522 
0523 TH1F* hold=new  TH1F("hold"," ",nBins,xMin,xMax);
0524 hold=$i;
0525 Double_t mold=$i->GetMaximum();
0526 Double_t nold=$i->GetEntries();
0527 if ( $i==scEAll || $i==phoEAll ) {  
0528 $i->GetYaxis()->SetRangeUser(0.,2000.);
0529 }
0530 $i->SetStats(0);
0531 $i->SetMinimum(0.);
0532 if ( mnew > mold+sqrt(mold) )  { 
0533 $i->SetMaximum(mnew+2*sqrt(mnew)); 
0534 }  else { 
0535 $i->SetMaximum(mold+2*sqrt(mold)); 
0536 }
0537 $i->SetLineColor(kPink+8);
0538 $i->SetFillColor(kPink+8);
0539 //$i->SetLineWidth(3);
0540 $i->Draw();
0541 file->cd("$HISTOPATHNAME2_Photons");
0542 Double_t nnew=$i->GetEntries();
0543 $i->SetStats(0);
0544 $i->SetLineColor(kBlack);
0545 $i->SetMarkerColor(kBlack);
0546 $i->SetMarkerStyle(20);
0547 $i->SetMarkerSize(0.8);
0548 //$i->SetLineWidth(1);
0549 $i->Scale(nold/nnew);
0550 TH1F* hnew=new  TH1F("hnew"," ",nBins,xMin,xMax);
0551 hnew=$i;
0552 $i->Draw("e1same");
0553 c$i->cd(2);
0554 TH1F* ratio=new  TH1F("ratio"," ",nBins,xMin,xMax);
0555 ratio->Divide(hnew,hold);
0556 for ( int i=1; i<=ratio->GetNbinsX(); i++ ) {
0557 float num=hnew->GetBinContent(i);
0558 float den=hold->GetBinContent(i);
0559 float dNum=hnew->GetBinError(i);
0560 float dDen=hold->GetBinError(i);
0561 float erro=0;
0562 if ( num!=0 && den!=0) {
0563 erro= ((1./den)*(1./den)*dNum*dNum) + ((num*num)/(den*den*den*den) * (dDen*dDen));
0564 erro=sqrt(erro);
0565 }
0566 ratio->SetBinError(i, erro);
0567 }
0568 ratio->SetStats(0);
0569 ratio->SetLineColor(1);
0570 ratio->SetLineWidth(2);
0571 ratio->SetMinimum(0.);
0572 ratio->SetMaximum(4.);
0573 ratio->Draw("e");
0574 TLine *l = new TLine(xMin,1.,xMax,1.);
0575 l->Draw(); 
0576 c$i->SaveAs("gifs/$i.gif");
0577 
0578 
0579 
0580 EOF
0581   setenv N `expr $N + 1`
0582 end
0583 
0584 
0585 foreach i (`cat scaledhistosForPhotonsLogScale`)
0586   cat > temp$N.C <<EOF
0587 
0588 TCanvas *cc$i = new TCanvas("cc$i");
0589 cc$i->cd();
0590 cc$i->SetFillColor(10);
0591 cc$i->SetLogy();
0592 file->cd("$HISTOPATHNAME2_Photons");
0593 Double_t nnew=$i->GetEntries();
0594 file->cd("$HISTOPATHNAME1_Photons");
0595 if ( $i==hcalTowerSumEtConeDR04Barrel ||  $i==hcalTowerSumEtConeDR04Endcap  ) {  
0596 $i->GetXaxis()->SetRangeUser(0.,10.);
0597 }
0598 Double_t nold=$i->GetEntries();
0599 $i->SetStats(0);
0600 $i->SetMinimum(1);
0601 $i->SetLineColor(kPink+8);
0602 $i->SetFillColor(kPink+8);
0603 $i->Draw();
0604 file->cd("$HISTOPATHNAME2_Photons");
0605 Double_t nnew=$i->GetEntries();
0606 $i->SetStats(0);
0607 $i->SetLineColor(kBlack);
0608 $i->SetMarkerColor(kBlack);
0609 $i->SetMarkerStyle(20);
0610 $i->SetMarkerSize(1);
0611 $i->Draw("e1same");
0612 cc$i->SaveAs("gifs/log$i.gif");
0613 
0614 
0615 EOF
0616   setenv N `expr $N + 1`
0617 end
0618 
0619 
0620 
0621 
0622 
0623 foreach i (`cat unscaledhistosForPhotons`)
0624   cat > temp$N.C <<EOF
0625 
0626 
0627 TCanvas *c$i = new TCanvas("c$i");
0628 c$i->SetFillColor(10);
0629 file->cd("$HISTOPATHNAME1_Photons");
0630 $i->SetStats(0);
0631 if ( $i==pEcalRecHitSumEtConeDR04VsEtaAll   ) {  
0632 $i->GetYaxis()->SetRangeUser(0.,5.);
0633 } else if ( $i==pEcalRecHitSumEtConeDR04VsEtBarrel ) 
0634 { $i->GetYaxis()->SetRangeUser(0.,20.); 
0635 } else if ( $i==pEcalRecHitSumEtConeDR04VsEtEndcap ) 
0636 { $i->GetYaxis()->SetRangeUser(0.,20.);
0637 } else if ( $i==pHcalTowerSumEtConeDR04VsEtaAll) 
0638 { $i->GetYaxis()->SetRangeUser(0.,0.5);
0639 } else if ( $i==pHcalTowerBcSumEtConeDR04VsEtaAll   ) 
0640 { $i->GetYaxis()->SetRangeUser(0.,1.);
0641 } else if ( $i==pHcalTowerSumEtConeDR04VsEtBarrel ||  $i==pHcalTowerBcSumEtConeDR04VsEtBarrel) 
0642 { $i->GetYaxis()->SetRangeUser(0.,5.);
0643 } else if ( $i==pHcalTowerSumEtConeDR04VsEtEndcap  || $i==pHcalTowerBcSumEtConeDR04VsEtEndcap ) 
0644 { $i->GetYaxis()->SetRangeUser(0.,5.);
0645 } else if ( $i==pHoverEVsEtaAll || $i==pnewHoverEVsEtaAll  ) 
0646 { $i->GetYaxis()->SetRangeUser(-0.05,0.05);
0647 } else if ( $i==pHoverEVsEtAll ||  $i==pnewHoverEVsEtAll ) 
0648 { $i->GetYaxis()->SetRangeUser(-0.05,0.05);
0649 } else  {
0650 $i->SetMinimum(0.8);
0651 $i->SetMaximum(1.1);
0652 }
0653 $i->SetLineColor(kPink+8);
0654 $i->SetMarkerColor(kPink+8);
0655 $i->SetMarkerStyle(20);
0656 $i->SetMarkerSize(1);
0657 $i->SetLineWidth(1);
0658 $i->Draw();
0659 file->cd("$HISTOPATHNAME2_Photons");
0660 $i->SetStats(0);
0661 $i->SetLineColor(kBlack);
0662 $i->SetMarkerColor(kBlack);
0663 $i->SetMarkerStyle(20);
0664 $i->SetMarkerSize(1);
0665 $i->SetLineWidth(1);
0666 $i->Draw("e1same");
0667 c$i->SaveAs("gifs/$i.gif");
0668 
0669 
0670 EOF
0671   setenv N `expr $N + 1`
0672 end
0673 
0674 
0675 
0676 
0677 foreach i (`cat efficiencyForConvertedPhotons`)
0678   cat > temp$N.C <<EOF
0679 TCanvas *c$i = new TCanvas("c$i");
0680 c$i->SetFillColor(10);
0681 c$i->Divide(1,2);
0682 c$i->cd(1);
0683 file->cd("$HISTOPATHNAME1_Efficiencies");
0684 $i->SetStats(0);
0685 int nBins = $i->GetNbinsX();
0686 float xMin=$i->GetBinLowEdge(1);
0687 float xMax=$i->GetBinLowEdge(nBins)+$i->GetBinWidth(nBins);
0688 TH1F* hold=new  TH1F("hold"," ",nBins,xMin,xMax);
0689 hold=$i;
0690 $i->SetMinimum(0.);
0691 $i->SetMaximum(1.);
0692 $i->SetLineColor(kPink+8);
0693 $i->SetMarkerColor(kPink+8);
0694 $i->SetMarkerStyle(20);
0695 $i->SetMarkerSize(1);
0696 $i->SetLineWidth(1);
0697 $i->Draw();
0698 file->cd("$HISTOPATHNAME2_Efficiencies");
0699 TH1F* hnew=new  TH1F("hnew"," ",nBins,xMin,xMax);
0700 hnew=$i;
0701 $i->SetStats(0);
0702 $i->SetMinimum(0.);
0703 $i->SetMaximum(1.);
0704 $i->SetLineColor(kBlack);
0705 $i->SetMarkerColor(kBlack);
0706 $i->SetMarkerStyle(20);
0707 $i->SetMarkerSize(1);
0708 $i->SetLineWidth(1);
0709 $i->Draw("same");
0710 TH1F* ratio=new  TH1F("ratio"," ",nBins,xMin,xMax);
0711 ratio->Divide(hnew,hold);
0712 for ( int i=1; i<=ratio->GetNbinsX(); i++ ) {
0713 float num=hnew->GetBinContent(i);
0714 float den=hold->GetBinContent(i);
0715 float dNum=hnew->GetBinError(i);
0716 float dDen=hold->GetBinError(i);
0717 float erro=0;
0718 if ( num!=0 && den!=0) {
0719 erro= ((1./den)*(1./den)*dNum*dNum) + ((num*num)/(den*den*den*den) * (dDen*dDen));
0720 erro=sqrt(erro);
0721 }
0722 ratio->SetBinError(i, erro);
0723 }
0724 ratio->SetStats(0);
0725 ratio->SetLineColor(1);
0726 ratio->SetLineWidth(2);
0727 ratio->SetMinimum(0.);
0728 ratio->SetMaximum(2.);
0729 c$i->cd(2);
0730 ratio->Draw("e");
0731 TLine *l = new TLine(xMin,1.,xMax,1.);
0732 l->Draw();
0733 c$i->SaveAs("gifs/$i.gif");
0734 
0735 EOF
0736   setenv N `expr $N + 1`
0737 end
0738 
0739 
0740 
0741 foreach i (`cat scaledhistosForConvertedPhotons`)
0742   cat > temp$N.C <<EOF
0743 TCanvas *c$i = new TCanvas("c$i");
0744 c$i->SetFillColor(10);
0745 file->cd("$HISTOPATHNAME2_Conversions");
0746 Double_t mnew=$i->GetMaximum();
0747 file->cd("$HISTOPATHNAME1_Conversions");
0748 Double_t mold=$i->GetMaximum();
0749 $i->SetStats(0);
0750 $i->SetMinimum(0.);
0751 if ( mnew > mold) 
0752 $i->SetMaximum(mnew+mnew*0.1);
0753 else 
0754 $i->SetMaximum(mold+mold*0.1);
0755 $i->SetLineColor(kPink+8);
0756 $i->SetFillColor(kPink+8);
0757 $i->SetLineWidth(3);
0758 $i->Draw();
0759 Double_t nold=$i->GetEntries();
0760 file->cd("$HISTOPATHNAME2_Conversions");
0761 Double_t nnew=$i->GetEntries();
0762 $i->SetStats(0);
0763 $i->SetLineColor(kBlack);
0764 $i->SetMarkerColor(kBlack);
0765 $i->SetMarkerStyle(20);
0766 $i->SetMarkerSize(1);
0767 $i->SetLineWidth(1);
0768 $i->Scale(nold/nnew);
0769 $i->Draw("e1same");
0770 c$i->SaveAs("gifs/$i.gif");
0771 
0772 EOF
0773   setenv N `expr $N + 1`
0774 end
0775 
0776 
0777 foreach i (`cat scaledhistosForConvertedPhotonsLogScale`)
0778   cat > temp$N.C <<EOF
0779 TCanvas *c$i = new TCanvas("c$i");
0780 c$i->SetFillColor(10);
0781 c$i->SetLogy(1);
0782 file->cd("$HISTOPATHNAME2_Conversions");
0783 Double_t mnew=$i->GetMaximum();
0784 file->cd("$HISTOPATHNAME1_Conversions");
0785 Double_t mold=$i->GetMaximum();
0786 $i->SetStats(0);
0787 $i->SetLineColor(kPink+8);
0788 $i->SetFillColor(kPink+8);
0789 $i->SetLineWidth(3);
0790 $i->Draw();
0791 Double_t nold=$i->GetEntries();
0792 file->cd("$HISTOPATHNAME2_Conversions");
0793 Double_t nnew=$i->GetEntries();
0794 $i->SetStats(0);
0795 $i->SetLineColor(kBlack);
0796 $i->SetMarkerColor(kBlack);
0797 $i->SetMarkerStyle(20);
0798 $i->SetMarkerSize(1);
0799 $i->SetLineWidth(1);
0800 $i->Scale(nold/nnew);
0801 $i->Draw("e1same");
0802 c$i->SaveAs("gifs/$i.gif");
0803 
0804 EOF
0805   setenv N `expr $N + 1`
0806 end
0807 
0808 
0809 
0810 
0811 
0812 foreach i (`cat unscaledhistosForConvertedPhotons`)
0813   cat > temp$N.C <<EOF
0814 TCanvas *c$i = new TCanvas("c$i");
0815 c$i->SetFillColor(10);
0816 file->cd("$HISTOPATHNAME1_Conversions");
0817 $i->SetStats(0);
0818 $i->GetYaxis()->SetRangeUser(0.6.,2);
0819 if (  $i == pConvVtxdRVsR || $i == pConvVtxdRVsEta || $i == pConvVtxdXVsX ||  $i ==  pConvVtxdYVsY ) {
0820 $i->GetYaxis()->SetRangeUser(-10.,10);
0821 } else if ( $i == pConvVtxdZVsZ ) {
0822 $i->GetYaxis()->SetRangeUser(-10.,10);
0823 }
0824 $i->SetLineColor(kPink+8);
0825 $i->SetMarkerColor(kPink+8);
0826 $i->SetMarkerStyle(20);
0827 $i->SetMarkerSize(1);
0828 $i->SetLineWidth(1);
0829 $i->Draw();
0830 file->cd("$HISTOPATHNAME2_Conversions");
0831 $i->SetStats(0);
0832 $i->SetLineColor(kBlack);
0833 $i->SetMarkerColor(kBlack);
0834 $i->SetMarkerStyle(20);
0835 $i->SetMarkerSize(1);
0836 $i->SetLineWidth(1);
0837 $i->Draw("e1same");
0838 c$i->SaveAs("gifs/$i.gif");
0839 
0840 EOF
0841   setenv N `expr $N + 1`
0842 end
0843 
0844 
0845 
0846 foreach i (`cat fakeRateForConvertedPhotons`)
0847   cat > temp$N.C <<EOF
0848 TCanvas *c$i = new TCanvas("c$i");
0849 c$i->SetFillColor(10);
0850 file->cd("$HISTOPATHNAME1_Efficiencies");
0851 $i->SetStats(0);
0852 $i->SetMinimum(0.);
0853 $i->SetMaximum(1.);
0854 $i->SetLineColor(kPink+8);
0855 $i->SetMarkerColor(kPink+8);
0856 $i->SetMarkerStyle(20);
0857 $i->SetMarkerSize(1);
0858 $i->SetLineWidth(1);
0859 $i->Draw();
0860 file->cd("$HISTOPATHNAME2_Efficiencies");
0861 $i->SetStats(0);
0862 $i->SetMinimum(0.);
0863 $i->SetLineColor(kBlack);
0864 $i->SetMarkerColor(kBlack);
0865 $i->SetMarkerStyle(20);
0866 $i->SetMarkerSize(1);
0867 $i->SetLineWidth(1);
0868 $i->Draw("same");
0869 c$i->SaveAs("gifs/$i.gif");
0870 
0871 EOF
0872   setenv N `expr $N + 1`
0873 end
0874 
0875 
0876 foreach i (`cat 2dhistosForConvertedPhotons`)
0877   cat > temp$N.C <<EOF
0878 TCanvas *c$i = new TCanvas("c$i");
0879 c$i->SetFillColor(10);
0880 file->cd("$HISTOPATHNAME1_Conversions");
0881 $i->SetStats(0);
0882 $i->SetMinimum(0.);
0883 $i->SetMarkerColor(kPink+8);
0884 $i->Draw();
0885 file->cd("$HISTOPATHNAME2_Conversions");
0886 $i->SetStats(0);
0887 $i->SetMarkerColor(kBlack);
0888 $i->Draw("same");
0889 c$i->SaveAs("gifs/$i.gif");
0890 
0891 EOF
0892   setenv N `expr $N + 1`
0893 end
0894 
0895 foreach i (`cat projectionsForConvertedPhotons`)
0896   cat > temp$N.C <<EOF
0897 TCanvas *c$i = new TCanvas("c$i");
0898 c$i->SetFillColor(10);
0899 file->cd("$HISTOPATHNAME1_Conversions");
0900 if ($i==convVtxRvsZBarrel)
0901 TH1D *tmp1$i= $i->ProjectionY();
0902 else if ($i==convVtxRvsZEndcap)
0903 TH1D *tmp1$i= $i->ProjectionX();
0904 Double_t nold=tmp1$i->GetEntries();
0905 Double_t mold=tmp1$i->GetMaximum();
0906 file->cd("$HISTOPATHNAME2_Conversions");
0907 //TH1D *tmp2$i= $i->ProjectionY();
0908 if ($i==convVtxRvsZBarrel)
0909 TH1D *tmp2$i= $i->ProjectionY();
0910 else if ($i==convVtxRvsZEndcap)
0911 TH1D *tmp2$i= $i->ProjectionX();
0912 Double_t nnew=tmp2$i->GetEntries();
0913 Double_t mnew=tmp2$i->GetMaximum();
0914 tmp1$i->SetStats(0);
0915 tmp1$i->SetMinimum(0.);
0916 if ( mnew > mold) 
0917 tmp1$i->SetMaximum(mnew+mnew*0.2);
0918 else 
0919 tmp1$i->SetMaximum(mold+mold*0.2);
0920 tmp1$i->SetLineColor(kPink+8);
0921 tmp1$i->SetFillColor(kPink+8);
0922 tmp1$i->SetLineWidth(3);
0923 tmp1$i->Draw();
0924 tmp2$i->SetStats(0);
0925 tmp2$i->SetLineColor(kBlack);
0926 tmp2$i->SetLineWidth(3);
0927 tmp2$i->Scale(nold/nnew);
0928 tmp2$i->Draw("same");
0929 c$i->SaveAs("gifs/$i.gif");
0930 
0931 EOF
0932   setenv N `expr $N + 1`
0933 end
0934 
0935 
0936 
0937 
0938 foreach i (`cat scaledhistosForTracks`)
0939   cat > temp$N.C <<EOF
0940 TCanvas *c$i = new TCanvas("c$i");
0941 c$i->SetFillColor(10);
0942 file->cd("$HISTOPATHNAME2_Conversions");
0943 Double_t mnew=$i->GetMaximum();
0944 file->cd("$HISTOPATHNAME1_Conversions");
0945 Double_t mold=$i->GetMaximum();
0946 $i->SetStats(0);
0947 $i->SetMinimum(0.);
0948 if ( mnew > mold) 
0949 $i->SetMaximum(mnew+mnew*0.1);
0950 else 
0951 $i->SetMaximum(mold+mold*0.1);
0952 $i->SetLineColor(kPink+8);
0953 $i->SetFillColor(kPink+8);
0954 $i->SetLineWidth(3);
0955 $i->Draw();
0956 Double_t nold=$i->GetEntries();
0957 file->cd("$HISTOPATHNAME2_Conversions");
0958 Double_t nnew=$i->GetEntries();
0959 $i->SetStats(0);
0960 $i->SetLineColor(kBlack);
0961 $i->SetMarkerColor(kBlack);
0962 $i->SetMarkerStyle(20);
0963 $i->SetMarkerSize(1);
0964 $i->SetLineWidth(1);
0965 $i->Scale(nold/nnew);
0966 $i->Draw("e1same");
0967 c$i->SaveAs("gifs/$i.gif");
0968 
0969 EOF
0970   setenv N `expr $N + 1`
0971 end
0972 
0973 foreach i (`cat unscaledhistosForTracks`)
0974   cat > temp$N.C <<EOF
0975 TCanvas *c$i = new TCanvas("c$i");
0976 c$i->SetFillColor(10);
0977 file->cd("$HISTOPATHNAME2_Conversions");
0978 Double_t mnew=$i->GetMaximum();
0979 file->cd("$HISTOPATHNAME1_Conversions");
0980 Double_t mold=$i->GetMaximum();
0981 $i->SetStats(0);
0982 if ($i==pDCotTracksVsEtaAll ||  $i==pDCotTracksVsRAll ) {
0983 $i->SetMinimum(-0.05);
0984 $i->SetMaximum(0.05);
0985 } else if ( $i==pdzPVVsR ) { 
0986 $i->GetYaxis()->SetRangeUser(-3.,3.);
0987 } else {
0988 $i->SetMinimum(0.);
0989     if ( mnew > mold) 
0990     $i->SetMaximum(mnew+mnew*0.4);
0991     else 
0992     $i->SetMaximum(mold+mold*0.4);
0993 }
0994 
0995 $i->SetLineColor(kPink+8);
0996 $i->SetMarkerColor(kPink+8);
0997 $i->SetMarkerStyle(20);
0998 $i->SetMarkerSize(1);
0999 $i->SetLineWidth(1);
1000 $i->Draw();
1001 Double_t nold=$i->GetEntries();
1002 file->cd("$HISTOPATHNAME2_Conversions");
1003 Double_t nnew=$i->GetEntries();
1004 $i->SetStats(0);
1005 $i->SetLineColor(kBlack);
1006 $i->SetMarkerColor(kBlack);
1007 $i->SetMarkerStyle(20);
1008 $i->SetMarkerSize(1);
1009 $i->SetLineWidth(1);
1010 //$i->Scale(nold/nnew);
1011 $i->Draw("e1same");
1012 c$i->SaveAs("gifs/$i.gif");
1013 
1014 EOF
1015   setenv N `expr $N + 1`
1016 end
1017 
1018 
1019 
1020 
1021 
1022 
1023 setenv NTOT `expr $N - 1`
1024 setenv N 1
1025 while ( $N <= $NTOT )
1026   cat temp$N.C >>& validation.C
1027   rm temp$N.C
1028   setenv N `expr $N + 1`
1029 end
1030 
1031 cat > end.C <<EOF
1032 }
1033 EOF
1034 cat end.C >>& validation.C
1035 rm end.C
1036 
1037 
1038 #if ( $TYPE == PixelMatchGsfElectron ) then
1039 #  setenv ANALYZER PixelMatchGsfElectronAnalyzer
1040 #  setenv CFG read_gsfElectrons
1041 #else if ( $TYPE == oldpfPhotons ||  $TYPE == pfPhotons ) then
1042 #  setenv ANALYZER PhotonValidator
1043 #  setenv CFG PhotonValidator_cfg
1044 #endif
1045 
1046 if (-e validation.html) rm validation.html
1047 if (-e validationPlotsTemplate.html) rm validationPlotsTemplate.html
1048 cp ${CURRENTDIR}/validationPlotsTemplate.html validationPlotsTemplate.html
1049 touch validation.html
1050 
1051 
1052 cat > begin.html <<EOF
1053 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1054 <html>
1055 <head>
1056 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
1057 <title>$RELEASE : $TYPE vs ${COMPAREWITH} validation</title>
1058 </head>
1059 
1060 <h1>$RELEASE :  $TYPE vs ${COMPAREWITH} validation
1061 <br>
1062  $SAMPLE 
1063 </h1>
1064 In all plots below, ${COMPAREWITH}  is in purple, ${TYPE} in black.<br>
1065 <br>
1066 Click on the plots to see them enlarged.
1067 <br>
1068 Responsible: N. Marinelli
1069 <br>
1070 <br>
1071 
1072 EOF
1073 
1074 
1075 cat begin.html >>& validation.html
1076 rm begin.html
1077 cat  validationPlotsTemplate.html >>& validation.html
1078 rm  validationPlotsTemplate.html 
1079 
1080 
1081 rm scaledhistosForPhotons
1082 rm unscaledhistosForPhotons
1083 rm efficiencyForPhotons
1084 rm scaledhistosForPhotonsLogScale
1085 rm efficiencyForConvertedPhotons
1086 rm fakeRateForConvertedPhotons
1087 rm 2dhistosForConvertedPhotons
1088 rm projectionsForConvertedPhotons
1089 rm scaledhistosForTracks
1090 rm unscaledhistosForTracks
1091 rm scaledhistosForPhotonsLogScale
1092 rm scaledhistosForConvertedPhotons
1093 rm scaledhistosForConvertedPhotonsLogScale
1094 rm unscaledhistosForConvertedPhotons
1095 
1096 
1097 #echo "Now paste the following into your terminal window:"
1098 #echo ""
1099 echo "cd $OUTDIR"
1100 #echo " root -b"
1101 #echo ".x validation.C"
1102 #echo ".q"
1103 #echo "cd $CURRENTDIR"
1104 #echo ""
1105 
1106 
1107 root -b -l -q validation.C
1108 cd $CURRENTDIR
1109 echo "Then you can view your valdation plots here:"
1110 echo "http://cmsdoc.cern.ch/Physics/egamma/www/$OUTPATH/validation.html"