Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:50

0001 #include <iostream>
0002 #include <fstream>
0003 #include <iomanip>
0004 #include <vector>
0005 #include "TFile.h"
0006 #include "TTree.h"
0007 #include "TChain.h"
0008 #include "TString.h"
0009 #include "TStyle.h"
0010 #include "TEventList.h"
0011 #include "TH1F.h"
0012 #include "THStack.h"
0013 #include "TCanvas.h"
0014 #include "TArrow.h"
0015 #include "TTreeFormula.h"
0016 
0017 struct filter {
0018   TString name;
0019   TString cut;
0020   Int_t pathNum;
0021   Int_t direction; // -1: <, 0: bool, 1: >
0022   Double_t hltBarrelCut;
0023   Double_t hltEndcapCut;
0024   Double_t maxCut;
0025 };
0026 
0027 struct path {
0028   TString name;
0029   Int_t nCandsCut;
0030   std::vector<filter> filters;
0031 };
0032 
0033 struct sample {
0034   TString name;
0035   TChain *chain;
0036   Double_t nEvents;
0037   Double_t xSection;
0038 };
0039 
0040 void PlotVars() {
0041   /* Set desired luminosity.  Conversion gives rate in Hz */
0042   Double_t luminosity = 1.0E32;
0043   Double_t conversion  = 1.0E-27;
0044 
0045   /* Set name to prefix image filenames with */
0046   TString name = "WenuOpt";
0047 
0048   /* Set the running mode: 0 - basic variable plot, 1 - electrons with optimal value of variable in given event, 2 - N-1 plots */
0049   Int_t mode = 1;
0050 
0051   /* Variable declarations */
0052   struct path thisPath;
0053   TString pathName;
0054   struct filter thisFilter;
0055   std::vector<filter> filters;
0056 
0057   std::vector<sample> samples;
0058   sample thisSample;
0059   TChain *thisChain;
0060 
0061   Int_t cutNum = 0;
0062 
0063   TTree *tempTree;
0064   TTreeFormula *thisFormula;
0065   Double_t best;
0066   Long64_t entry = 0, part = 0;
0067 
0068   /* Set the values of the cuts */
0069   Double_t cutEt = 17.;
0070   Double_t cutHoE = 0.07;
0071   Double_t cutEpMatch = 0.9;
0072   Double_t cutItrack = 0.15;
0073 
0074   /* Choose samples */
0075   thisChain = new TChain("Events");
0076 
0077   /*
0078 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-0.root");
0079 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-1.root");
0080 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-2.root");
0081 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-3.root");
0082 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-4.root");
0083 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-5.root");
0084 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-6.root");
0085 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-7.root");
0086 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-8.root");
0087 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-9.root");
0088 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-10.root");
0089 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-11.root");
0090 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-12.root");
0091 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-13.root");
0092 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-14.root");
0093 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-15.root");
0094 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-16.root");
0095 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-17.root");
0096 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-18.root");
0097 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-19.root");
0098 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-20.root");
0099 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-21.root");
0100 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-22.root");
0101 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-23.root");
0102 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-24.root");
0103 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-25.root");
0104 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-26.root");
0105 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-27.root");
0106 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-28.root");
0107 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-29.root");
0108 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-30.root");
0109 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-31.root");
0110 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-32.root");
0111 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-33.root");
0112 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-34.root");
0113 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-35.root");
0114 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-36.root");
0115 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-37.root");
0116 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-38.root");
0117 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-39.root");
0118 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-40.root");
0119 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-41.root");
0120 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-42.root");
0121 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-43.root");
0122 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-44.root");
0123 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-45.root");
0124 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-46.root");
0125 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-47.root");
0126 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-48.root");
0127 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-49.root");
0128 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-50.root");
0129 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-51.root");
0130 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-52.root");
0131 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-53.root");
0132 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-54.root");
0133 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-55.root");
0134 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-56.root");
0135 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-57.root");
0136 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-58.root");
0137 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-59.root");
0138 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-60.root");
0139 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-61.root");
0140 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-62.root");
0141 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-63.root");
0142 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-64.root");
0143 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-65.root");
0144 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-66.root");
0145 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-67.root");
0146 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-68.root");
0147 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-69.root");
0148 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-70.root");
0149 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-71.root");
0150 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-72.root");
0151 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-73.root");
0152 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-74.root");
0153 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-75.root");
0154 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-76.root");
0155 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-77.root");
0156 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-78.root");
0157 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-79.root");
0158 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-80.root");
0159 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-81.root");
0160 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-82.root");
0161 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-83.root");
0162 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-84.root");
0163 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-85.root");
0164 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-86.root");
0165 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-87.root");
0166 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-88.root");
0167 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-89.root");
0168 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-90.root");
0169 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-91.root");
0170 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-92.root");
0171 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-93.root");
0172 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-94.root");
0173 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-95.root");
0174 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-96.root");
0175 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-97.root");
0176 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-98.root");
0177 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-99.root");
0178 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-100.root");
0179 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-101.root");
0180 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-102.root");
0181 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-103.root");
0182 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-104.root");
0183 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-105.root");
0184 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-106.root");
0185 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-107.root");
0186 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-108.root");
0187 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-109.root");
0188 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-110.root");
0189 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-111.root");
0190 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-112.root");
0191 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-113.root");
0192 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-114.root");
0193 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-115.root");
0194 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-116.root");
0195 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-117.root");
0196 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-118.root");
0197 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-119.root");
0198 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-120.root");
0199 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-121.root");
0200 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-122.root");
0201 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-123.root");
0202 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-124.root");
0203 thisChain->Add("../test/HLTStudyData/QCD-15-20/QCD-15-20-HLTVars-125.root");
0204   thisSample.name = "QCD 15-20";
0205   thisSample.chain = thisChain;
0206   thisSample.nEvents = 1260000;
0207   thisSample.xSection = 1.46;
0208   samples.push_back(thisSample);
0209 
0210   thisChain = new TChain("Events");
0211   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-20-30-HLTVars.root");
0212   thisSample.name = "QCD 20-30";
0213   thisSample.chain = thisChain;
0214   thisSample.nEvents = 100000;
0215   thisSample.xSection = 6.32E-1;
0216   samples.push_back(thisSample);
0217 
0218   thisChain = new TChain("Events");
0219   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-30-50-HLTVars.root");
0220   thisSample.name = "QCD 30-50";
0221   thisSample.chain = thisChain;
0222   thisSample.nEvents = 100000;
0223   thisSample.xSection = 1.63E-1;
0224   samples.push_back(thisSample);
0225 
0226   thisChain = new TChain("Events");
0227   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-1.root");
0228   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-2.root");
0229   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-3.root");
0230   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-4.root");
0231   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-5.root");
0232   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-6.root");
0233   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-7.root");
0234   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-8.root");
0235   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-9.root");
0236   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-HLTVars-10.root");
0237   thisSample.name = "QCD 50-80";
0238   thisSample.chain = thisChain;
0239   thisSample.nEvents = 100000;
0240   thisSample.xSection = 2.16E-2;
0241   samples.push_back(thisSample);
0242 
0243   thisChain = new TChain("Events");;
0244   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-0.root");
0245   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-1.root");
0246   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-2.root");
0247   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-3.root");
0248   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-4.root");
0249   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-5.root");
0250   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-6.root");
0251   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-7.root");
0252   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-8.root");
0253   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/QCD-cfgs/QCD-HLTVars80120-9.root");
0254   thisSample.name = "QCD 80-120";
0255   thisSample.chain = thisChain;
0256   thisSample.nEvents = 239993;
0257   thisSample.xSection = 3.08E-3;
0258   samples.push_back(thisSample);
0259 
0260   thisChain = new TChain("Events");;
0261   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-120-170-HLTVars-2.root");
0262   thisSample.name = "QCD 120-170";
0263   thisSample.chain = thisChain;
0264   thisSample.nEvents = 11092;
0265   thisSample.xSection = 4.94E-4;
0266   samples.push_back(thisSample);
0267 
0268   thisChain = new TChain("Events");
0269   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-170-230-HLTVars-0.root");
0270   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-170-230-HLTVars-1.root");
0271   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-170-230-HLTVars-2.root");
0272   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-170-230-HLTVars-3.root");
0273   thisSample.name = "QCD 170-230";
0274   thisSample.chain = thisChain;
0275   thisSample.nEvents = 400000;
0276   thisSample.xSection = 1.01E-4;
0277   samples.push_back(thisSample);
0278 
0279   thisChain = new TChain("Events");
0280   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-230-300-HLTVars-0.root");
0281   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-230-300-HLTVars-1.root");
0282   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-230-300-HLTVars-2.root");
0283   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/QCD-230-300-HLTVars-3.root");
0284   thisSample.name = "QCD 230-300";
0285   thisSample.chain = thisChain;
0286   thisSample.nEvents = 400000;
0287   thisSample.xSection = 2.45E-5;
0288   samples.push_back(thisSample);
0289   */
0290 
0291   /*
0292   thisChain = new TChain("Events");
0293   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/ZEE-HLTVars.root");
0294   thisSample.name = "Z->ee";
0295   thisSample.chain = thisChain;
0296   thisSample.nEvents = 3800;
0297   thisSample.xSection = 1.62E-6;
0298   samples.push_back(thisSample);
0299   */
0300 
0301   thisChain = new TChain("Events");
0302   thisChain->Add("../test/HLTStudyData/WENU-HLTVars-NoPresel.root");
0303   thisSample.name = "W->ev";
0304   thisSample.chain = thisChain;
0305   thisSample.nEvents = 2000;
0306   thisSample.xSection = 1.72E-5;
0307   samples.push_back(thisSample);
0308 
0309   /*
0310   thisChain = new TChain("Events");
0311   thisChain->Add("../../../../../CMSSW_1_6_0/src/HLTriggerOffline/Egamma/test/HLTStudyData/TTbar-HLTVars-1e.root");
0312   thisSample.name = "TTBar";
0313   thisSample.chain = thisChain;
0314   thisSample.nEvents = 100000;
0315   thisSample.xSection = 8.33E-7;
0316   samples.push_back(thisSample);
0317   */
0318 
0319   /* Selec path: (Relaxed)SingleElecs, (Relaxed)DoubleElecs */
0320   pathName = "SingleElecs.";
0321   thisPath.name = pathName;
0322   thisPath.nCandsCut = 1;
0323   /* Define the filters that go into the HLT.  hltBarrelCut, hltEndcapCut now redundant but still necessary */
0324   thisFilter.name = "Et";
0325   thisFilter.cut = thisPath.name; // this sets the text to go with the cut for each filter
0326   thisFilter.cut += "Et > ";
0327   thisFilter.cut += cutEt;
0328   thisFilter.pathNum = 0;
0329   thisFilter.direction = 1;
0330   thisFilter.hltBarrelCut = 17.; // Still being used to position arrows; should be removed (or cut* variables should be removed)
0331   thisFilter.hltEndcapCut = 17.;
0332   thisFilter.maxCut = 60.;
0333   filters.push_back(thisFilter);
0334   thisFilter.name = "HOE";
0335   thisFilter.cut = thisPath.name;
0336   thisFilter.cut += "IHcal / ";
0337   thisFilter.cut += thisPath.name;
0338   thisFilter.cut += "Et < ";
0339   thisFilter.cut += cutHoE;
0340   thisFilter.pathNum = 0;
0341   thisFilter.direction = -1;
0342   thisFilter.hltBarrelCut = 0.07;
0343   thisFilter.hltEndcapCut = 0.07;
0344   thisFilter.maxCut = 0.15;
0345   filters.push_back(thisFilter);
0346   thisFilter.name = "EpMatch";
0347   thisFilter.cut = "fabs((1. - ";
0348   thisFilter.cut += thisPath.name;
0349   thisFilter.cut += "Eoverp) * sin(2.*atan(exp(-";
0350   thisFilter.cut += thisPath.name;
0351   thisFilter.cut += "eta))) / ";
0352   thisFilter.cut += thisPath.name;
0353   thisFilter.cut += "Et) < ";
0354   thisFilter.cut += cutEpMatch;
0355   thisFilter.pathNum = 1;
0356   thisFilter.direction = -1;
0357   thisFilter.hltBarrelCut = 0.9;
0358   thisFilter.hltEndcapCut = 0.9;
0359   thisFilter.maxCut = 2.;
0360   filters.push_back(thisFilter);
0361   thisFilter.name = "Itrack";
0362   thisFilter.cut = thisPath.name;
0363   thisFilter.cut += "Itrack < ";
0364   thisFilter.cut += cutItrack;
0365   cout<<thisFilter.cut<<endl;
0366   thisFilter.pathNum = 1;
0367   thisFilter.direction = -1;
0368   thisFilter.hltBarrelCut = 0.15;
0369   thisFilter.hltEndcapCut = 0.15;
0370   thisFilter.maxCut = 0.5;
0371   filters.push_back(thisFilter);
0372   thisPath.filters = filters;
0373   filters.clear();
0374 
0375   TString cutText;
0376 
0377   TString plotText = "", plotFileName = "", plotTitle, thisHName = "";
0378   Double_t thisBCut = 0., thisECut = 0.;
0379   TString filterName;
0380   Long64_t sampleNum = 0, filterNum = 0;
0381   Double_t nPass = 0, oldNPass = 0, errNPass = 0, eff = 0, errEff = 0;
0382   vector<TH1F*> hists;
0383   TCanvas *myCanvas = new TCanvas("myCanvas", "Cut Variable", 700, 300);
0384   TArrow *barrelCutArr;
0385   TArrow *endcapCutArr;
0386   gStyle->SetOptStat(0);
0387   for (filterNum = 0; filterNum < (thisPath.filters).size(); filterNum++) {
0388     filterName = (thisPath.filters)[filterNum].name;
0389     //    thisHist = new TH1F("thisHist", filterName, 50, 0, (thisPath.filters)[filterNum].maxCut);
0390     THStack thisHist("thisHist", filterName);
0391     cutText = "";
0392     /* First set any cuts we would like on the plots */
0393     if (mode < 2) {
0394       cutText = pathName;
0395       cutText += "mcEt > 0."; // Check if MC elec matches reco Elec... optional I suppose
0396     }
0397     else if (mode == 2) {
0398       cutText = pathName;
0399       cutText += "l1Match && ";
0400       cutText += pathName;
0401       cutText += "pixMatch > 0";
0402       for (cutNum = 0; cutNum < (thisPath.filters).size(); cutNum++) {
0403     if (cutNum != filterNum) {
0404       cutText += " && ";
0405       cutText += filters[cutNum].cut;
0406     }
0407       }
0408     }
0409     
0410     hists.resize(samples.size());
0411     /* Now add each sample to the stack */
0412     for (sampleNum = 0; sampleNum < samples.size(); sampleNum++) {
0413       thisHName = "thisH";
0414       thisHName += sampleNum;
0415       if (filterName == "HOE") {
0416     plotText = pathName;
0417     plotText += "IHcal / ";
0418     plotText += pathName;
0419     plotText += "Et";
0420       }
0421       else if (filterName == "EpMatch") {
0422     plotText ="fabs(1. / ";
0423     plotText += pathName;
0424     plotText += "Et - ";
0425     plotText += pathName;
0426     plotText += "Eoverp / ";
0427     plotText += pathName;
0428     plotText += "Et) * sin(2*atan(exp(-";
0429     plotText += pathName;
0430     plotText += "eta)))";
0431       }
0432       else {
0433     plotText = pathName;
0434     plotText += filterName;
0435       }
0436       hists[sampleNum] = new TH1F(thisHName, filterName, 50, 0, (thisPath.filters)[filterNum].maxCut);
0437       if (mode == 2) {
0438     plotText += ">>";
0439     plotText += thisHName;
0440     samples[sampleNum].chain->Draw(plotText, cutText);
0441       }
0442       else if (mode == 1) {
0443     tempTree = samples[sampleNum].chain; // Must work with tree (as opposed to chain for this method... ROOT quirk
0444     thisFormula = new TTreeFormula("thisFormula", plotText, tempTree);
0445     for (entry = 0; entry < tempTree->GetEntries(); entry++) {
0446       tempTree->LoadTree(entry);
0447       if (thisFormula->GetNdata() == 0) {
0448         thisFormula->EvalInstance(0); // Do eval instance even if nothing is there... another ROOT quirk
0449       }
0450       if (filters[filterNum].direction == 1) {
0451         best = 0.;
0452       }
0453       else {
0454         best = 100000.;
0455       }
0456       for (part = 0; part < thisFormula->GetNdata(); part++) {
0457         if (filters[filterNum].direction == 1) {
0458           if (thisFormula->EvalInstance(part) > best) {
0459         best = thisFormula->EvalInstance(part);                                                                                      
0460           }                                                                                                                                                          
0461         }                                                  
0462         else if (filters[filterNum].direction == -1) {
0463           if (thisFormula->EvalInstance(part) < best) {
0464         best = thisFormula->EvalInstance(part);
0465           }
0466         }
0467       }
0468       hists[sampleNum]->Fill(best);
0469     }
0470       delete thisFormula;
0471       }
0472       hists[sampleNum]->Scale(samples[sampleNum].xSection * luminosity * conversion / samples[sampleNum].nEvents);
0473       hists[sampleNum]->SetFillColor(sampleNum+1);
0474       plotTitle = filterName;
0475       plotTitle += ";";
0476       plotTitle += filterName;
0477       plotTitle += ";";
0478       plotTitle += "Rate (Hz)";
0479       hists[sampleNum]->SetTitle(plotTitle);
0480       thisHist.Add(hists[sampleNum]);
0481     }
0482     thisHist.Draw();
0483     
0484     /* Now just add the arrows and we're done */
0485     barrelCutArr = new TArrow((thisPath.filters)[filterNum].hltBarrelCut, -0.1, (thisPath.filters)[filterNum].hltBarrelCut, 0.);
0486     barrelCutArr->SetLineColor(2);
0487     barrelCutArr->Draw();
0488     if ( (thisPath.filters)[filterNum].hltBarrelCut !=  (thisPath.filters)[filterNum].hltEndcapCut) {
0489       endcapCutArr = new  TArrow((thisPath.filters)[filterNum].hltEndcapCut, -0.1, (thisPath.filters)[filterNum].hltEndcapCut, 0.);
0490       endcapCutArr->SetLineColor(4);
0491       endcapCutArr->Draw();
0492     }
0493     plotFileName = "images/";
0494     plotFileName += name;
0495     plotFileName += filterName;
0496     plotFileName += pathName;
0497     plotFileName += "gif";
0498     myCanvas->Print(plotFileName);
0499     /* Clean-up a little */ 
0500     delete barrelCutArr;
0501     for (sampleNum = 0; sampleNum < samples.size(); sampleNum++) {
0502       delete hists[sampleNum];
0503     }
0504     hists.clear();
0505   }
0506 }