Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:16

0001 #include "TreeAnalysisHcalNZS.h"
0002 #include <TStyle.h>
0003 #include <TCanvas.h>
0004 
0005 Bool_t FillChain(TChain *chain, const TString &inputFileList);
0006 
0007 int main(Int_t argc, Char_t *argv[]) {
0008 
0009   if ( argc<12 ) {
0010     std::cerr << "Please give 10 arguments "
0011               << "runList \n"
0012               << "outputFileName \n"
0013               << "dataType \n"
0014               << "ecalCharIso \n"
0015               << "hcalCharIso \n"
0016               << "ebNeutIso \n"
0017               << "eeNeutIso \n"
0018               << "hhNeutIso \n"
0019           << "L1Seed \n"
0020               << "dRL1Jet \n"
0021           << "ZS/NZS Flag \n"
0022           << "nGoodPV \n"
0023           << std::endl;
0024     return -1;
0025   }
0026 
0027   const char *inputFileList = argv[1];
0028   const char *outFileName   = argv[2];
0029   const char *dataType      = argv[3];
0030   const char *ecalCharIso   = argv[4];
0031   const char *hcalCharIso   = argv[5];
0032   const char *ebNeutIso     = argv[6];
0033   const char *eeNeutIso     = argv[7];
0034   const char *hhNeutIso     = argv[8];
0035   const char *L1Seed        = argv[9];
0036   const char *dRL1Jet       = argv[10];
0037   const char *ZSNZSFlag     = argv[11];
0038   const char *nGoodPV       = argv[12];
0039 
0040   int cut = 0;
0041   int flag = atoi(ZSNZSFlag);
0042 
0043   std::cout << "Command line arguments"          << std::endl;
0044   std::cout << "inputFileList " << inputFileList << std::endl;
0045   std::cout << "outFileName   " << outFileName   << std::endl;
0046   std::cout << "dataType      " << dataType      << std::endl;
0047   std::cout << "ecalCharIso   " << ecalCharIso   << std::endl;
0048   std::cout << "hcalCharIso   " << hcalCharIso   << std::endl;
0049   std::cout << "ebNeutIso     " << ebNeutIso     << std::endl;
0050   std::cout << "eeNeutIso     " << eeNeutIso     << std::endl;
0051   std::cout << "hhNeutIso     " << hhNeutIso     << std::endl;
0052   std::cout << "dRL1Jet       " << dRL1Jet       << std::endl;
0053   std::cout << "L1Seed        " << L1Seed        << std::endl;
0054   std::cout << "ZS/NZS Flag   " << flag          << "(1 for ZS, 0 for NZS)" << std::endl;
0055   std::cout << "nGoodPV       " << nGoodPV       << "(0: nGoodPV=1, -1: firstGoodPV, -2: anyGoodPV)" << std::endl;
0056 
0057   // Reading Tree 
0058   std::cout << "---------------------" << std::endl;
0059   std::cout << "Reading List of input trees from " << inputFileList << std::endl;
0060   
0061   TChain *chain;
0062   if (flag) chain = new TChain("/isolatedTracksNxN/tree");
0063   else  chain = new TChain("/isolatedTracksNxN_NZS/tree");
0064   if( ! FillChain(chain, inputFileList) ) {
0065     std::cerr << "Cannot get the tree " << std::endl;
0066     return(0);
0067   }
0068 
0069   TreeAnalysisHcalNZS tree(chain, outFileName);
0070   
0071   tree.ecalCharIso = ecalCharIso;
0072   tree.hcalCharIso = hcalCharIso;
0073   tree.dataType    = dataType;
0074   tree.ebNeutIso   = atof(ebNeutIso);
0075   tree.eeNeutIso   = atof(eeNeutIso);
0076   tree.hhNeutIso   = atof(hhNeutIso);
0077   tree.dRL1Jet     = atof(dRL1Jet);
0078   tree.L1Seed      = L1Seed;
0079   tree.GoodPVCut   = atoi(nGoodPV);
0080 
0081   tree.Loop(cut);
0082 
0083   return 0;
0084 }
0085 
0086 Bool_t FillChain(TChain *chain, const TString &inputFileList) {
0087 
0088   ifstream infile(inputFileList);
0089   std::string buffer;
0090 
0091   if(!infile.is_open()) {
0092     std::cerr << "** ERROR: Can't open '" << inputFileList << "' for input" << std::endl;
0093     return kFALSE;
0094   }
0095   
0096   std::cout << "TreeUtilities : FillChain " << std::endl;
0097   while(1) {
0098     infile >> buffer;
0099     if(!infile.good()) break;
0100     //std::cout << "Adding tree from " << buffer.c_str() << std::endl;
0101     chain->Add(buffer.c_str());
0102   }
0103   std::cout << "No. of Entries in this tree : " << chain->GetEntries() << std::endl;
0104   return kTRUE;
0105 }
0106 
0107 TreeAnalysisHcalNZS::TreeAnalysisHcalNZS(TChain *tree, const char *outFileName) {
0108 
0109   double tempgen_TH[NPBins+1] = { 0.0,  1.0,  2.0,  3.0,  4.0,  
0110                   5.0,  6.0,  7.0,  9.0,  11.0, 
0111                   15.0, 20.0, 30.0, 50.0, 75.0, 100.0};
0112 
0113   for(int i=0; i<NPBins+1; i++)  genPartPBins[i]  = tempgen_TH[i];
0114 
0115   double tempgen_Eta[NEtaBins+1] = {0.0, 0.2, 0.4, 0.6, 0.8, 
0116                                     1.0, 1.2, 1.4, 1.6, 1.8, 
0117                                     2.0, 2.2, 2.4};
0118   
0119   for(int i=0; i<NEtaBins+1; i++) genPartEtaBins[i] = tempgen_Eta[i];
0120 
0121   Init(tree);
0122    
0123   BookHistograms(outFileName);
0124 }
0125 
0126 TreeAnalysisHcalNZS::~TreeAnalysisHcalNZS(){
0127    if (!fChain) return;
0128    delete fChain->GetCurrentFile();
0129    fout->cd();
0130    fout->Write();
0131    fout->Close();   
0132 }
0133 
0134 Int_t TreeAnalysisHcalNZS::Cut(Long64_t entry) {
0135   // This function may be called from Loop.
0136   // returns  1 if entry is accepted.
0137   // returns -1 otherwise.
0138   return 1;
0139 }
0140 
0141 Int_t TreeAnalysisHcalNZS::GetEntry(Long64_t entry) {
0142   // Read contents of entry.
0143   if (!fChain) return 0;
0144   return fChain->GetEntry(entry);
0145 }
0146 
0147 Long64_t TreeAnalysisHcalNZS::LoadTree(Long64_t entry)
0148 {
0149 // Set the environment to read one entry
0150    if (!fChain) return -5;
0151    Long64_t centry = fChain->LoadTree(entry);
0152    if (centry < 0) return centry;
0153    if (!fChain->InheritsFrom(TChain::Class()))  return centry;
0154    TChain *chain = (TChain*)fChain;
0155    if (chain->GetTreeNumber() != fCurrent) {
0156       fCurrent = chain->GetTreeNumber();
0157       Notify();
0158    }
0159    return centry;
0160 }
0161 
0162 void TreeAnalysisHcalNZS::Init(TChain *tree)
0163 {
0164    // The Init() function is called when the selector needs to initialize
0165    // a new tree or chain. Typically here the branch addresses and branch
0166    // pointers of the tree will be set.
0167    // It is normally not necessary to make changes to the generated
0168    // code, but the routine can be extended by the user if needed.
0169    // Init() will be called many times when running on PROOF
0170    // (once per file to be processed).
0171 
0172    // Set object pointer
0173    PVx = 0;
0174    PVy = 0;
0175    PVz = 0;
0176    PVisValid = 0;
0177    PVndof = 0;
0178    PVNTracks = 0;
0179    PVNTracksWt = 0;
0180    t_PVTracksSumPt = 0;
0181    t_PVTracksSumPtWt = 0;
0182    PVNTracksHP = 0;
0183    PVNTracksHPWt = 0;
0184    t_PVTracksSumPtHP = 0;
0185    t_PVTracksSumPtHPWt = 0;
0186 
0187    t_L1AlgoNames = 0;
0188    t_L1PreScale = 0;
0189    t_L1CenJetPt = 0;
0190    t_L1CenJetEta = 0;
0191    t_L1CenJetPhi = 0;
0192    t_L1FwdJetPt = 0;
0193    t_L1FwdJetEta = 0;
0194    t_L1FwdJetPhi = 0;
0195    t_L1TauJetPt = 0;
0196    t_L1TauJetEta = 0;
0197    t_L1TauJetPhi = 0;
0198    t_L1MuonPt = 0;
0199    t_L1MuonEta = 0;
0200    t_L1MuonPhi = 0;
0201    t_L1IsoEMPt = 0;
0202    t_L1IsoEMEta = 0;
0203    t_L1IsoEMPhi = 0;
0204    t_L1NonIsoEMPt = 0;
0205    t_L1NonIsoEMEta = 0;
0206    t_L1NonIsoEMPhi = 0;
0207    t_L1METPt = 0;
0208    t_L1METEta = 0;
0209    t_L1METPhi = 0;
0210 
0211    t_jetPt = 0;
0212    t_jetEta = 0;
0213    t_jetPhi = 0;
0214    t_nTrksJetCalo = 0;
0215    t_nTrksJetVtx = 0;
0216 
0217    t_trackPAll = 0;
0218    t_trackEtaAll = 0;
0219    t_trackPhiAll = 0;
0220    t_trackPtAll = 0;
0221    t_trackDxyAll = 0;
0222    t_trackDzAll = 0;
0223    t_trackDxyPVAll = 0;
0224    t_trackDzPVAll = 0;
0225    t_trackChiSqAll = 0;
0226 
0227    t_trackP = 0;
0228    t_trackPt = 0;
0229    t_trackEta = 0;
0230    t_trackPhi = 0;
0231    t_trackEcalEta = 0;
0232    t_trackEcalPhi = 0;
0233    t_trackHcalEta = 0;
0234    t_trackHcalPhi = 0;
0235    t_trackNOuterHits = 0;
0236    t_NLayersCrossed = 0;
0237    t_trackHitsTOB = 0;
0238    t_trackHitsTEC = 0;
0239    t_trackHitInMissTOB = 0;
0240    t_trackHitInMissTEC = 0;
0241    t_trackHitInMissTIB = 0;
0242    t_trackHitInMissTID = 0;
0243    t_trackHitInMissTIBTID = 0;
0244    t_trackHitOutMissTOB = 0;
0245    t_trackHitOutMissTEC = 0;
0246    t_trackHitOutMissTIB = 0;
0247    t_trackHitOutMissTID = 0;
0248    t_trackHitOutMissTOBTEC = 0;
0249    t_trackHitInMeasTOB = 0;
0250    t_trackHitInMeasTEC = 0;
0251    t_trackHitInMeasTIB = 0;
0252    t_trackHitInMeasTID = 0;
0253    t_trackHitOutMeasTOB = 0;
0254    t_trackHitOutMeasTEC = 0;
0255    t_trackHitOutMeasTIB = 0;
0256    t_trackHitOutMeasTID = 0;
0257    t_trackOutPosOutHitDr = 0;
0258    t_trackL = 0;
0259    t_trackDxy = 0;
0260    t_trackDxyBS = 0;
0261    t_trackDz = 0;
0262    t_trackDzBS = 0;
0263    t_trackDxyPV = 0;
0264    t_trackDzPV = 0;
0265    t_trackChiSq = 0;
0266    t_trackPVIdx = 0;
0267 
0268    t_maxNearP31x31 = 0;
0269    t_maxNearP21x21 = 0;
0270    t_ecalSpike11x11 = 0;
0271    t_e7x7 = 0;
0272    t_e9x9 = 0;
0273    t_e11x11 = 0;
0274    t_e15x15 = 0;
0275    t_e7x7_10Sig = 0;
0276    t_e9x9_10Sig = 0;
0277    t_e11x11_10Sig = 0;
0278    t_e15x15_10Sig = 0;
0279    t_e7x7_15Sig = 0;
0280    t_e9x9_15Sig = 0;
0281    t_e11x11_15Sig = 0;
0282    t_e15x15_15Sig = 0;
0283    t_e7x7_20Sig = 0;
0284    t_e9x9_20Sig = 0;
0285    t_e11x11_20Sig = 0;
0286    t_e15x15_20Sig = 0;
0287    t_e7x7_25Sig = 0;
0288    t_e9x9_25Sig = 0;
0289    t_e11x11_25Sig = 0;
0290    t_e15x15_25Sig = 0;
0291    t_e7x7_30Sig = 0;
0292    t_e9x9_30Sig = 0;
0293    t_e11x11_30Sig = 0;
0294    t_e15x15_30Sig = 0;
0295 
0296    t_maxNearHcalP3x3 = 0;
0297    t_maxNearHcalP5x5 = 0;
0298    t_maxNearHcalP7x7 = 0;
0299    t_h3x3 = 0;
0300    t_h5x5 = 0;
0301    t_h7x7 = 0;
0302    t_h3x3Sig = 0;
0303    t_h5x5Sig = 0;
0304    t_h7x7Sig = 0;
0305    t_infoHcal = 0;
0306 
0307    // Set branch addresses and branch pointers
0308    if (!tree) return;
0309    fChain = tree;
0310    fCurrent = -1;
0311    fChain->SetMakeClass(1);
0312 
0313    fChain->SetBranchAddress("t_EvtNo", &t_EvtNo, &b_t_EvtNo);
0314    fChain->SetBranchAddress("t_RunNo", &t_RunNo, &b_t_RunNo);
0315    fChain->SetBranchAddress("t_Lumi", &t_Lumi, &b_t_Lumi);
0316    fChain->SetBranchAddress("t_Bunch", &t_Bunch, &b_t_Bunch);
0317    fChain->SetBranchAddress("PVx", &PVx, &b_PVx);
0318    fChain->SetBranchAddress("PVy", &PVy, &b_PVy);
0319    fChain->SetBranchAddress("PVz", &PVz, &b_PVz);
0320    fChain->SetBranchAddress("PVisValid", &PVisValid, &b_PVisValid);
0321    fChain->SetBranchAddress("PVndof", &PVndof, &b_PVndof);
0322    fChain->SetBranchAddress("PVNTracks", &PVNTracks, &b_PVNTracks);
0323    fChain->SetBranchAddress("PVNTracksWt", &PVNTracksWt, &b_PVNTracksWt);
0324    fChain->SetBranchAddress("t_PVTracksSumPt", &t_PVTracksSumPt, &b_t_PVTracksSumPt);
0325    fChain->SetBranchAddress("t_PVTracksSumPtWt", &t_PVTracksSumPtWt, &b_t_PVTracksSumPtWt);
0326    fChain->SetBranchAddress("PVNTracksHP", &PVNTracksHP, &b_PVNTracksHP);
0327    fChain->SetBranchAddress("PVNTracksHPWt", &PVNTracksHPWt, &b_PVNTracksHPWt);
0328    fChain->SetBranchAddress("t_PVTracksSumPtHP", &t_PVTracksSumPtHP, &b_t_PVTracksSumPtHP);
0329    fChain->SetBranchAddress("t_PVTracksSumPtHPWt", &t_PVTracksSumPtHPWt, &b_t_PVTracksSumPtHPWt);
0330 
0331    fChain->SetBranchAddress("t_L1Decision",  t_L1Decision,   &b_t_L1Decision);
0332    fChain->SetBranchAddress("t_L1AlgoNames", &t_L1AlgoNames, &b_t_L1AlgoNames);
0333    fChain->SetBranchAddress("t_L1PreScale",  &t_L1PreScale,  &b_t_L1PreScale);
0334    fChain->SetBranchAddress("t_L1CenJetPt",  &t_L1CenJetPt,  &b_t_L1CenJetPt);
0335    fChain->SetBranchAddress("t_L1CenJetEta", &t_L1CenJetEta, &b_t_L1CenJetEta);
0336    fChain->SetBranchAddress("t_L1CenJetPhi", &t_L1CenJetPhi, &b_t_L1CenJetPhi);
0337    fChain->SetBranchAddress("t_L1FwdJetPt",  &t_L1FwdJetPt,  &b_t_L1FwdJetPt);
0338    fChain->SetBranchAddress("t_L1FwdJetEta", &t_L1FwdJetEta, &b_t_L1FwdJetEta);
0339    fChain->SetBranchAddress("t_L1FwdJetPhi", &t_L1FwdJetPhi, &b_t_L1FwdJetPhi);
0340    fChain->SetBranchAddress("t_L1TauJetPt",  &t_L1TauJetPt,  &b_t_L1TauJetPt);
0341    fChain->SetBranchAddress("t_L1TauJetEta", &t_L1TauJetEta, &b_t_L1TauJetEta);
0342    fChain->SetBranchAddress("t_L1TauJetPhi", &t_L1TauJetPhi, &b_t_L1TauJetPhi);
0343    fChain->SetBranchAddress("t_L1MuonPt",    &t_L1MuonPt,    &b_t_L1MuonPt);
0344    fChain->SetBranchAddress("t_L1MuonEta",   &t_L1MuonEta,   &b_t_L1MuonEta);
0345    fChain->SetBranchAddress("t_L1MuonPhi",   &t_L1MuonPhi,   &b_t_L1MuonPhi);
0346    fChain->SetBranchAddress("t_L1IsoEMPt",   &t_L1IsoEMPt,   &b_t_L1IsoEMPt);
0347    fChain->SetBranchAddress("t_L1IsoEMEta",  &t_L1IsoEMEta,  &b_t_L1IsoEMEta);
0348    fChain->SetBranchAddress("t_L1IsoEMPhi",  &t_L1IsoEMPhi,  &b_t_L1IsoEMPhi);
0349    fChain->SetBranchAddress("t_L1NonIsoEMPt",&t_L1NonIsoEMPt,&b_t_L1NonIsoEMPt);
0350    fChain->SetBranchAddress("t_L1NonIsoEMEta", &t_L1NonIsoEMEta, &b_t_L1NonIsoEMEta);
0351    fChain->SetBranchAddress("t_L1NonIsoEMPhi", &t_L1NonIsoEMPhi, &b_t_L1NonIsoEMPhi);
0352    fChain->SetBranchAddress("t_L1METPt",     &t_L1METPt,     &b_t_L1METPt);
0353    fChain->SetBranchAddress("t_L1METEta",    &t_L1METEta,    &b_t_L1METEta);
0354    fChain->SetBranchAddress("t_L1METPhi",    &t_L1METPhi,    &b_t_L1METPhi);
0355 
0356    fChain->SetBranchAddress("t_jetPt", &t_jetPt, &b_t_jetPt);
0357    fChain->SetBranchAddress("t_jetEta", &t_jetEta, &b_t_jetEta);
0358    fChain->SetBranchAddress("t_jetPhi", &t_jetPhi, &b_t_jetPhi);
0359    fChain->SetBranchAddress("t_nTrksJetCalo", &t_nTrksJetCalo, &b_t_nTrksJetCalo);
0360    fChain->SetBranchAddress("t_nTrksJetVtx", &t_nTrksJetVtx, &b_t_nTrksJetVtx);
0361 
0362    fChain->SetBranchAddress("t_trackPAll",   &t_trackPAll,   &b_t_trackPAll);
0363    fChain->SetBranchAddress("t_trackEtaAll", &t_trackEtaAll, &b_t_trackEtaAll);
0364    fChain->SetBranchAddress("t_trackPhiAll", &t_trackPhiAll, &b_t_trackPhiAll);
0365    fChain->SetBranchAddress("t_trackPtAll",  &t_trackPtAll,  &b_t_trackPtAll);
0366    fChain->SetBranchAddress("t_trackDxyAll", &t_trackDxyAll, &b_t_trackDxyAll);
0367    fChain->SetBranchAddress("t_trackDzAll",  &t_trackDzAll,  &b_t_trackDzAll);
0368    fChain->SetBranchAddress("t_trackDxyPVAll", &t_trackDxyPVAll, &b_t_trackDxyPVAll);
0369    fChain->SetBranchAddress("t_trackDzPVAll", &t_trackDzPVAll, &b_t_trackDzPVAll);
0370    fChain->SetBranchAddress("t_trackChiSqAll", &t_trackChiSqAll, &b_t_trackChiSqAll);
0371    fChain->SetBranchAddress("t_trackP", &t_trackP, &b_t_trackP);
0372    fChain->SetBranchAddress("t_trackPt", &t_trackPt, &b_t_trackPt);
0373    fChain->SetBranchAddress("t_trackEta", &t_trackEta, &b_t_trackEta);
0374    fChain->SetBranchAddress("t_trackPhi", &t_trackPhi, &b_t_trackPhi);
0375    fChain->SetBranchAddress("t_trackEcalEta", &t_trackEcalEta, &b_t_trackEcalEta);
0376    fChain->SetBranchAddress("t_trackEcalPhi", &t_trackEcalPhi, &b_t_trackEcalPhi);
0377    fChain->SetBranchAddress("t_trackHcalEta", &t_trackHcalEta, &b_t_trackHcalEta);
0378    fChain->SetBranchAddress("t_trackHcalPhi", &t_trackHcalPhi, &b_t_trackHcalPhi);
0379    fChain->SetBranchAddress("t_trackNOuterHits", &t_trackNOuterHits, &b_t_trackNOuterHits);
0380    fChain->SetBranchAddress("t_NLayersCrossed", &t_NLayersCrossed, &b_t_NLayersCrossed);
0381    fChain->SetBranchAddress("t_trackHitsTOB", &t_trackHitsTOB, &b_t_trackHitsTOB);
0382    fChain->SetBranchAddress("t_trackHitsTEC", &t_trackHitsTEC, &b_t_trackHitsTEC);
0383    fChain->SetBranchAddress("t_trackHitInMissTOB", &t_trackHitInMissTOB, &b_t_trackHitInMissTOB);
0384    fChain->SetBranchAddress("t_trackHitInMissTEC", &t_trackHitInMissTEC, &b_t_trackHitInMissTEC);
0385    fChain->SetBranchAddress("t_trackHitInMissTIB", &t_trackHitInMissTIB, &b_t_trackHitInMissTIB);
0386    fChain->SetBranchAddress("t_trackHitInMissTID", &t_trackHitInMissTID, &b_t_trackHitInMissTID);
0387    fChain->SetBranchAddress("t_trackHitInMissTIBTID", &t_trackHitInMissTIBTID, &b_t_trackHitInMissTIBTID);
0388    fChain->SetBranchAddress("t_trackHitOutMissTOB", &t_trackHitOutMissTOB, &b_t_trackHitOutMissTOB);
0389    fChain->SetBranchAddress("t_trackHitOutMissTEC", &t_trackHitOutMissTEC, &b_t_trackHitOutMissTEC);
0390    fChain->SetBranchAddress("t_trackHitOutMissTIB", &t_trackHitOutMissTIB, &b_t_trackHitOutMissTIB);
0391    fChain->SetBranchAddress("t_trackHitOutMissTID", &t_trackHitOutMissTID, &b_t_trackHitOutMissTID);
0392    fChain->SetBranchAddress("t_trackHitOutMissTOBTEC", &t_trackHitOutMissTOBTEC, &b_t_trackHitOutMissTOBTEC);
0393    fChain->SetBranchAddress("t_trackHitInMeasTOB", &t_trackHitInMeasTOB, &b_t_trackHitInMeasTOB);
0394    fChain->SetBranchAddress("t_trackHitInMeasTEC", &t_trackHitInMeasTEC, &b_t_trackHitInMeasTEC);
0395    fChain->SetBranchAddress("t_trackHitInMeasTIB", &t_trackHitInMeasTIB, &b_t_trackHitInMeasTIB);
0396    fChain->SetBranchAddress("t_trackHitInMeasTID", &t_trackHitInMeasTID, &b_t_trackHitInMeasTID);
0397    fChain->SetBranchAddress("t_trackHitOutMeasTOB", &t_trackHitOutMeasTOB, &b_t_trackHitOutMeasTOB);
0398    fChain->SetBranchAddress("t_trackHitOutMeasTEC", &t_trackHitOutMeasTEC, &b_t_trackHitOutMeasTEC);
0399    fChain->SetBranchAddress("t_trackHitOutMeasTIB", &t_trackHitOutMeasTIB, &b_t_trackHitOutMeasTIB);
0400    fChain->SetBranchAddress("t_trackHitOutMeasTID", &t_trackHitOutMeasTID, &b_t_trackHitOutMeasTID);
0401    fChain->SetBranchAddress("t_trackDxy", &t_trackDxy, &b_t_trackDxy);
0402    fChain->SetBranchAddress("t_trackDxyBS", &t_trackDxyBS, &b_t_trackDxyBS);
0403    fChain->SetBranchAddress("t_trackDz", &t_trackDz, &b_t_trackDz);
0404    fChain->SetBranchAddress("t_trackDzBS", &t_trackDzBS, &b_t_trackDzBS);
0405    fChain->SetBranchAddress("t_trackDxyPV", &t_trackDxyPV, &b_t_trackDxyPV);
0406    fChain->SetBranchAddress("t_trackDzPV", &t_trackDzPV, &b_t_trackDzPV);
0407    fChain->SetBranchAddress("t_trackChiSq", &t_trackChiSq, &b_t_trackChiSq);
0408    fChain->SetBranchAddress("t_trackPVIdx", &t_trackPVIdx, &b_t_trackPVIdx);
0409 
0410    fChain->SetBranchAddress("t_maxNearP31x31", &t_maxNearP31x31, &b_t_maxNearP31x31);
0411    fChain->SetBranchAddress("t_maxNearP21x21", &t_maxNearP21x21, &b_t_maxNearP21x21);
0412    fChain->SetBranchAddress("t_ecalSpike11x11", &t_ecalSpike11x11, &b_t_ecalSpike11x11);
0413    fChain->SetBranchAddress("t_e7x7", &t_e7x7, &b_t_e7x7);
0414    fChain->SetBranchAddress("t_e9x9", &t_e9x9, &b_t_e9x9);
0415    fChain->SetBranchAddress("t_e11x11", &t_e11x11, &b_t_e11x11);
0416    fChain->SetBranchAddress("t_e15x15", &t_e15x15, &b_t_e15x15);
0417    fChain->SetBranchAddress("t_e7x7_10Sig", &t_e7x7_10Sig, &b_t_e7x7_10Sig);
0418    fChain->SetBranchAddress("t_e9x9_10Sig", &t_e9x9_10Sig, &b_t_e9x9_10Sig);
0419    fChain->SetBranchAddress("t_e11x11_10Sig", &t_e11x11_10Sig, &b_t_e11x11_10Sig);
0420    fChain->SetBranchAddress("t_e15x15_10Sig", &t_e15x15_10Sig, &b_t_e15x15_10Sig);
0421    fChain->SetBranchAddress("t_e7x7_15Sig", &t_e7x7_15Sig, &b_t_e7x7_15Sig);
0422    fChain->SetBranchAddress("t_e9x9_15Sig", &t_e9x9_15Sig, &b_t_e9x9_15Sig);
0423    fChain->SetBranchAddress("t_e11x11_15Sig", &t_e11x11_15Sig, &b_t_e11x11_15Sig);
0424    fChain->SetBranchAddress("t_e15x15_15Sig", &t_e15x15_15Sig, &b_t_e15x15_15Sig);
0425    fChain->SetBranchAddress("t_e7x7_20Sig", &t_e7x7_20Sig, &b_t_e7x7_20Sig);
0426    fChain->SetBranchAddress("t_e9x9_20Sig", &t_e9x9_20Sig, &b_t_e9x9_20Sig);
0427    fChain->SetBranchAddress("t_e11x11_20Sig", &t_e11x11_20Sig, &b_t_e11x11_20Sig);
0428    fChain->SetBranchAddress("t_e15x15_20Sig", &t_e15x15_20Sig, &b_t_e15x15_20Sig);
0429    fChain->SetBranchAddress("t_e7x7_25Sig", &t_e7x7_25Sig, &b_t_e7x7_25Sig);
0430    fChain->SetBranchAddress("t_e9x9_25Sig", &t_e9x9_25Sig, &b_t_e9x9_25Sig);
0431    fChain->SetBranchAddress("t_e11x11_25Sig", &t_e11x11_25Sig, &b_t_e11x11_25Sig);
0432    fChain->SetBranchAddress("t_e15x15_25Sig", &t_e15x15_25Sig, &b_t_e15x15_25Sig);
0433    fChain->SetBranchAddress("t_e7x7_30Sig", &t_e7x7_30Sig, &b_t_e7x7_30Sig);
0434    fChain->SetBranchAddress("t_e9x9_30Sig", &t_e9x9_30Sig, &b_t_e9x9_30Sig);
0435    fChain->SetBranchAddress("t_e11x11_30Sig", &t_e11x11_30Sig, &b_t_e11x11_30Sig);
0436    fChain->SetBranchAddress("t_e15x15_30Sig", &t_e15x15_30Sig, &b_t_e15x15_30Sig);
0437 
0438    fChain->SetBranchAddress("t_maxNearHcalP3x3", &t_maxNearHcalP3x3, &b_t_maxNearHcalP3x3);
0439    fChain->SetBranchAddress("t_maxNearHcalP5x5", &t_maxNearHcalP5x5, &b_t_maxNearHcalP5x5);
0440    fChain->SetBranchAddress("t_maxNearHcalP7x7", &t_maxNearHcalP7x7, &b_t_maxNearHcalP7x7);
0441    fChain->SetBranchAddress("t_h3x3", &t_h3x3, &b_t_h3x3);
0442    fChain->SetBranchAddress("t_h5x5", &t_h5x5, &b_t_h5x5);
0443    fChain->SetBranchAddress("t_h7x7", &t_h7x7, &b_t_h7x7);
0444    fChain->SetBranchAddress("t_h3x3Sig", &t_h3x3Sig, &b_t_h3x3Sig);
0445    fChain->SetBranchAddress("t_h5x5Sig", &t_h5x5Sig, &b_t_h5x5Sig);
0446    fChain->SetBranchAddress("t_h7x7Sig", &t_h7x7Sig, &b_t_h7x7Sig);
0447    fChain->SetBranchAddress("t_infoHcal", &t_infoHcal, &b_t_infoHcal);
0448    fChain->SetBranchAddress("t_nTracks", &t_nTracks, &b_t_nTracks);
0449    Notify();
0450 }
0451 
0452 void TreeAnalysisHcalNZS::Loop(int cut) {
0453 
0454   std::cout << "Track isolation thresholds "          <<std::endl;
0455   std::cout << "dataType      " << dataType      << std::endl;
0456   std::cout << "ecalCharIso   " << ecalCharIso   << std::endl;
0457   std::cout <<" hcalCharIso   " << hcalCharIso   << std::endl;
0458   std::cout << "ebNeutIso     " << ebNeutIso     << std::endl;
0459   std::cout << "eeNeutIso     " << eeNeutIso     << std::endl;
0460   std::cout << "hhNeutIso     " << hhNeutIso     << std::endl;
0461   std::cout << "L1Seed        " << L1Seed        << std::endl;
0462   if (fChain == 0) {
0463     std::cout << "\n Tree does not exist "<<std::endl;
0464     return;
0465   }
0466 
0467   bool debug = false;
0468   Long64_t nentries = fChain->GetEntriesFast();
0469   std::cout << "No. of Entries in tree " << nentries << std::endl;
0470 
0471   Long64_t nEventsGoodRuns=0, nEventsValidPV=0, nEventsPVTracks=0;
0472 
0473   Long64_t nbytes = 0, nb = 0;
0474   std::map<unsigned int, unsigned int> runEvtList;
0475   std::map<unsigned int, unsigned int> runNTrkList;
0476   std::map<unsigned int, unsigned int> runNIsoTrkList;
0477 
0478   for (Long64_t jentry=0; jentry<nentries;jentry++) {
0479 
0480     // load tree and get current entry
0481     Long64_t ientry = LoadTree(jentry);
0482     if (ientry < 0) break;
0483     nb = fChain->GetEntry(jentry);   nbytes += nb;
0484 
0485     if( !(jentry%100000) ) {
0486       std::cout << "processing event " << jentry+1 << std::endl;
0487     }
0488 
0489     bool goodRun= false;
0490     goodRun     = true;
0491     
0492     bool evtSel = true;
0493     if(dataType=="Data" && !goodRun ) {
0494       evtSel = false;
0495     }
0496     if( !evtSel ) continue;  //<=================    
0497 
0498     if( runEvtList.find(t_RunNo) != runEvtList.end() ) {
0499       runEvtList[t_RunNo] += 1; 
0500    } else {
0501       runEvtList.insert( std::pair<unsigned int, unsigned int>(t_RunNo,1) );
0502       if (debug) std::cout << "runNo " << t_RunNo <<" "<<runEvtList[t_RunNo]<<std::endl;
0503     }
0504     
0505     nEventsGoodRuns++;
0506   
0507     // I guess the vertex filter works on any PV of the collection
0508     // All PVs in the event
0509 
0510     std::vector<int> isGoodPV(PVz->size(), -1);
0511     int  nGoodPV=0;
0512     bool anyGoodPV  =false;
0513     bool firstPVGood=false;
0514 
0515     for(int ipv=0; ipv<PVz->size(); ipv++) {
0516       double rho = sqrt((*PVx)[ipv]*(*PVx)[ipv] + (*PVy)[ipv]*(*PVy)[ipv]);      
0517       h_PVx[0]            ->Fill( (*PVx)[ipv]             );
0518       h_PVy[0]            ->Fill( (*PVy)[ipv]             );
0519       h_PVr[0]            ->Fill( rho                   );
0520       h_PVz[0]            ->Fill( (*PVz)[ipv]             );
0521       h_PVNDOF[0]         ->Fill( (*PVndof)[ipv]          );
0522       h_PVNTracks[0]      ->Fill( (*PVNTracks)[ipv]       );
0523       h_PVTracksSumPt[0]  ->Fill( (*t_PVTracksSumPt)[ipv] ); 
0524       h_PVNTracksWt[0]    ->Fill( (*PVNTracksWt)[ipv]       );
0525       h_PVTracksSumPtWt[0]->Fill( (*t_PVTracksSumPtWt)[ipv] ); 
0526       h_PVNTracksSumPt[0] ->Fill( (*PVNTracks)[ipv], (*t_PVTracksSumPt)[ipv]);
0527       
0528       if( std::abs((*PVz)[ipv])<=15.0 && rho<=2.0 && (*PVndof)[ipv]>4 ) 
0529     isGoodPV[ipv] = 1;
0530       else 
0531     isGoodPV[ipv] = 0;
0532       
0533       if (debug) std::cout << "PV : " << ipv << " rho " << rho << " z " << (*PVz)[ipv] << " ndf " << (*PVndof)[ipv] << " Good " << isGoodPV[ipv] << std::endl;
0534       if( isGoodPV[ipv]>0 ) {
0535     nGoodPV++;
0536     anyGoodPV = true;
0537     if(ipv==0)              firstPVGood = true;
0538     h_PVx[1]            ->Fill( (*PVx)[ipv]             );
0539     h_PVy[1]            ->Fill( (*PVy)[ipv]             );
0540     h_PVr[1]            ->Fill( rho                   );
0541     h_PVz[1]            ->Fill( (*PVz)[ipv]             );
0542     h_PVNDOF[1]         ->Fill( (*PVndof)[ipv]          );
0543     h_PVNTracks[1]      ->Fill( (*PVNTracks)[ipv]       );
0544     h_PVTracksSumPt[1]  ->Fill( (*t_PVTracksSumPt)[ipv] ); 
0545     h_PVNTracksWt[1]    ->Fill( (*PVNTracksWt)[ipv]       );
0546     h_PVTracksSumPtWt[1]->Fill( (*t_PVTracksSumPtWt)[ipv] ); 
0547     h_PVNTracksSumPt[1] ->Fill( (*PVNTracks)[ipv], (*t_PVTracksSumPt)[ipv]);
0548       }     
0549     }
0550     h_NPV[0] ->Fill(PVz->size());
0551     h_NPV[1] ->Fill(nGoodPV);
0552     
0553     if( firstPVGood ) { 
0554       nEventsValidPV++;
0555       nEventsPVTracks++;
0556     }
0557 
0558     bool pvSel = true;
0559     //if( !firstPVGood )     pvSel = false;
0560     if (debug) std::cout << "GoodPVCut " << GoodPVCut << " anyGoodPV " << anyGoodPV << " firstPVGood " << firstPVGood << " nGoodPV " << nGoodPV << std::endl;
0561     if (GoodPVCut == -2 && !anyGoodPV           ) pvSel = false;
0562     else if (GoodPVCut == -1 && !firstPVGood    ) pvSel = false;
0563     else if (GoodPVCut==0 && nGoodPV != 1        ) pvSel = false; 
0564     else if (GoodPVCut>0 && (nGoodPV > GoodPVCut || nGoodPV < 1)) pvSel = false;
0565 
0566     if(dataType=="DiPion") pvSel = true;  // no PV selection for DiPion sample
0567     if (debug) std::cout << "NGoodPV " << nGoodPV << " First " << firstPVGood << " pvSel " << pvSel << std::endl;
0568     if( !pvSel ) continue;
0569 
0570     //================= avoid trigger bias ===================
0571     double maxL1Pt=-1.0, maxL1Eta=999.0, maxL1Phi=999.0;
0572     bool checkL1=false;
0573 
0574     if( L1Seed=="L1Jet" || L1Seed=="L1JetL1Tau" || L1Seed=="L1JetL1TauL1EM" || L1Seed=="L1JetL1EM") {
0575       if( t_L1Decision[15]>0 || t_L1Decision[16]>0 ||  t_L1Decision[17]>0   ||
0576       t_L1Decision[18]>0 || t_L1Decision[19]>0 ||  t_L1Decision[20]>0   ||
0577       t_L1Decision[21]>0 ){ 
0578     if( t_L1CenJetPt->size()>0 && (*t_L1CenJetPt)[0]>maxL1Pt )
0579       {maxL1Pt=(*t_L1CenJetPt)[0]; maxL1Eta=(*t_L1CenJetEta)[0]; maxL1Phi=(*t_L1CenJetPhi)[0];}
0580     if( t_L1FwdJetPt->size()>0 && (*t_L1FwdJetPt)[0]>maxL1Pt )
0581       {maxL1Pt=(*t_L1FwdJetPt)[0]; maxL1Eta=(*t_L1FwdJetEta)[0]; maxL1Phi=(*t_L1FwdJetPhi)[0];}
0582     checkL1=true;
0583       } 
0584     }
0585     if( L1Seed=="L1Tau" || L1Seed=="L1JetL1Tau" || L1Seed=="L1JetL1TauL1EM") {
0586       if( t_L1Decision[30]>0 ||  t_L1Decision[31]>0 || t_L1Decision[32]>0 ||
0587       t_L1Decision[33]>0 ) {
0588     if( t_L1TauJetPt->size()>0 && (*t_L1TauJetPt)[0]>maxL1Pt )
0589       {maxL1Pt=(*t_L1TauJetPt)[0]; maxL1Eta=(*t_L1TauJetEta)[0]; maxL1Phi=(*t_L1TauJetPhi)[0];}
0590     checkL1=true;
0591       } 
0592     }
0593     if( L1Seed=="L1EM" || L1Seed=="L1JetL1TauL1EM" || L1Seed=="L1JetL1EM") {      
0594       if( t_L1Decision[46]>0 || t_L1Decision[47]>0 || t_L1Decision[48]>0 ||  
0595       t_L1Decision[49]>0 || t_L1Decision[50]>0 || t_L1Decision[51]>0 ||  
0596       t_L1Decision[52]>0    ) {
0597     if( t_L1IsoEMPt->size()>0 && (*t_L1IsoEMPt)[0]>maxL1Pt )
0598       {maxL1Pt=(*t_L1IsoEMPt)[0]; maxL1Eta=(*t_L1IsoEMEta)[0]; maxL1Phi=(*t_L1IsoEMPhi)[0];}
0599     checkL1=true;
0600       } 
0601     }
0602     if( maxL1Pt<0 ) checkL1=false;
0603     if (debug) {
0604       std::cout << "L1Seed " << L1Seed << " pt/eta/phi " << maxL1Pt << "|" << maxL1Eta << "|" << maxL1Phi << " checkL1 " << checkL1 << " L1Decision " << std::endl;
0605       for (int i=-14; i<53; ++i) std::cout << " i " << i << ":" << t_L1Decision[i];
0606       std::cout << std::endl;
0607     }
0608 
0609     // good events satisfying good first PV selection
0610     for(int itrk=0; itrk<t_trackPAll->size(); itrk++ ){
0611       h_trackP[0]    ->Fill((*t_trackPAll)[itrk]    );  
0612       h_trackPt[0]   ->Fill((*t_trackPtAll)[itrk]    );  
0613       h_trackEta[0]  ->Fill((*t_trackEtaAll)[itrk]  );  
0614       h_trackPhi[0]  ->Fill((*t_trackPhiAll)[itrk]  );  
0615       h_trackDxy[0]  ->Fill((*t_trackDxyPVAll)[itrk]  );  
0616       h_trackDz[0]   ->Fill((*t_trackDzPVAll)[itrk]  );  
0617       h_trackChiSq[0]->Fill((*t_trackChiSqAll)[itrk]  );  
0618     }
0619     
0620     // if charged isolated in ecal 31x31
0621     for(int itrk=0; itrk<t_trackP->size(); itrk++ ){
0622       h_trackP[1]    ->Fill((*t_trackP)[itrk]    );  
0623       h_trackPt[1]   ->Fill((*t_trackPt)[itrk]   );  
0624       h_trackEta[1]  ->Fill((*t_trackEta)[itrk]  );  
0625       h_trackPhi[1]  ->Fill((*t_trackPhi)[itrk]  );  
0626       h_trackDxy[1]  ->Fill((*t_trackDxyPV)[itrk]);  
0627       h_trackDz[1]   ->Fill((*t_trackDzPV )[itrk]);  
0628       h_trackChiSq[1]->Fill((*t_trackChiSq)[itrk]  );  
0629     }
0630     
0631     if( runNTrkList.find(t_RunNo) != runNTrkList.end() ) {
0632       runNTrkList[t_RunNo] += t_trackP->size(); 
0633     } else {
0634       runNTrkList.insert( std::pair<unsigned int, unsigned int>(t_RunNo,t_trackP->size()) );
0635       if (debug) std::cout << "runNo " << t_RunNo <<" "<<runNTrkList[t_RunNo]<<std::endl;
0636     }
0637     
0638     unsigned int NIsoTrk=0;
0639     for(int itrk=0; itrk<t_trackP->size(); itrk++ ){
0640       
0641       // reject soft tracks
0642       if (debug) std::cout << "Track " << itrk << " pt " << (*t_trackPt)[itrk] << std::endl;
0643       if( (*t_trackPt)[itrk] < 1.0 ) continue;
0644 
0645       double p1              = (*t_trackP)[itrk];
0646       double pt1             = (*t_trackPt)[itrk];
0647       double eta1            = (*t_trackEta)[itrk];
0648       double phi1            = (*t_trackPhi)[itrk];
0649       double etaEcal1        = (*t_trackEcalEta)[itrk];
0650       double phiEcal1        = (*t_trackEcalPhi)[itrk];
0651       double etaHcal1        = (*t_trackHcalEta)[itrk];
0652       double phiHcal1        = (*t_trackHcalPhi)[itrk];
0653       int    trackNOuterHits = (*t_trackNOuterHits)[itrk];
0654       int    NLayersCrossed  = (*t_NLayersCrossed)[itrk];
0655       int    ecalSpike11x11  = (*t_ecalSpike11x11)[itrk];
0656 
0657       double maxNearP31x31   = (*t_maxNearP31x31)[itrk];
0658       
0659       double e7x7            = (*t_e7x7)[itrk]; 
0660       double e9x9            = (*t_e9x9)[itrk]; 
0661       double e11x11          = (*t_e11x11)[itrk]; 
0662       double e15x15          = (*t_e15x15)[itrk];
0663       
0664       double maxNearHcalP3x3 = (*t_maxNearHcalP3x3)[itrk];
0665       double maxNearHcalP5x5 = (*t_maxNearHcalP5x5)[itrk];
0666       double maxNearHcalP7x7 = (*t_maxNearHcalP7x7)[itrk];
0667       
0668       double h3x3            = (*t_h3x3)[itrk];
0669       double h5x5            = (*t_h5x5)[itrk];
0670       double h7x7            = (*t_h7x7)[itrk];
0671       
0672       if( (*t_infoHcal)[itrk] < 1 ) {
0673     h3x3            = 0.0;
0674     h5x5            = 0.0;
0675     h7x7            = 0.0;
0676       }
0677 
0678       h_trackP[2]    ->Fill((*t_trackP)[itrk]    );
0679       h_trackPt[2]   ->Fill((*t_trackPt)[itrk]   );  
0680       h_trackEta[2]  ->Fill((*t_trackEta)[itrk]  );  
0681       h_trackPhi[2]  ->Fill((*t_trackPhi)[itrk]  );  
0682       h_trackDxy[2]  ->Fill((*t_trackDxyPV)[itrk]);  
0683       h_trackDz[2]   ->Fill((*t_trackDzPV )[itrk]);  
0684       h_trackChiSq[2]->Fill((*t_trackChiSq)[itrk]  );  
0685       
0686       int iTrkEtaBin=-1, iTrkMomBin=-1;
0687       for(int ieta=0; ieta<NEtaBins; ieta++)   {
0688     if(std::abs(etaEcal1)>genPartEtaBins[ieta] && std::abs(etaEcal1)<genPartEtaBins[ieta+1] ) iTrkEtaBin = ieta;
0689       }
0690       for(int ipt=0;  ipt<NPBins;   ipt++)  {
0691     if( p1>genPartPBins[ipt] &&  p1<genPartPBins[ipt+1] )  iTrkMomBin = ipt;
0692       }
0693       if (debug) std::cout << "p " << p1 << " " << iTrkMomBin << " eta " << eta1 << " " << iTrkEtaBin << std::endl;       
0694       
0695       bool trackChargeIso = true;
0696       if(ecalCharIso=="MaxNearP31x31"     && maxNearP31x31>0)     trackChargeIso=false;
0697       
0698       if(hcalCharIso=="MaxNearHcalP7x7"   && maxNearHcalP7x7>0)   trackChargeIso=false;
0699       if(hcalCharIso=="MaxNearHcalP5x5"   && maxNearHcalP5x5>0)   trackChargeIso=false;
0700       if(hcalCharIso=="MaxNearHcalP3x3"   && maxNearHcalP3x3>0)   trackChargeIso=false;
0701       if (debug) std::cout << "Isolation " << ecalCharIso << ":" << hcalCharIso << " ==> " << trackChargeIso << std::endl;
0702       
0703       bool hcalNeutIso = true;
0704       if( h7x7-h5x5   > hhNeutIso )                             hcalNeutIso=false;
0705       
0706       if( iTrkMomBin>=0 && iTrkEtaBin>=0) {  
0707     h_trackPhi_2_2[iTrkEtaBin] ->Fill((*t_trackPhi)[itrk]);
0708       }
0709 
0710       bool trackSel = true;
0711       // reject interactions in tracker
0712       if( (*t_trackHitInMissTOB )[itrk]>0 || (*t_trackHitInMissTEC )[itrk]>0 || 
0713       (*t_trackHitInMissTIB )[itrk]>0 || (*t_trackHitInMissTID )[itrk]>0 || 
0714       (*t_trackHitOutMissTOB)[itrk]>0 || (*t_trackHitOutMissTEC)[itrk]>0 ) 
0715     trackSel = false;
0716       if( ecalSpike11x11==0 ) trackSel=false ;
0717       if( trackSel ) {
0718     h_trackP[3]    ->Fill((*t_trackP)[itrk]    );  
0719     h_trackPt[3]   ->Fill((*t_trackPt)[itrk]   );  
0720     h_trackEta[3]  ->Fill((*t_trackEta)[itrk]  );  
0721     h_trackPhi[3]  ->Fill((*t_trackPhi)[itrk]  );  
0722     h_trackDxy[3]  ->Fill((*t_trackDxyPV)[itrk]);  
0723     h_trackDz[3]   ->Fill((*t_trackDzPV )[itrk]);  
0724     h_trackChiSq[3]->Fill((*t_trackChiSq)[itrk]  );  
0725     if( iTrkMomBin>=0 && iTrkEtaBin>=0) {    
0726       h_trackPhi_3_3[iTrkEtaBin] ->Fill((*t_trackPhi)[itrk]);
0727     }
0728       }
0729 
0730       if( iTrkMomBin>=0 && iTrkEtaBin>=0) {  
0731     if((*t_trackHitInMissTIB )[itrk]<1 && (*t_trackHitInMissTID )[itrk]<1 )
0732       h_trackPhi_3_Inner[iTrkEtaBin] ->Fill((*t_trackPhi)[itrk]);
0733     if((*t_trackHitOutMissTOB)[itrk]<1 && (*t_trackHitOutMissTEC)[itrk]<1 )
0734       h_trackPhi_3_Outer[iTrkEtaBin] ->Fill((*t_trackPhi)[itrk]);
0735       }
0736       if( NLayersCrossed<7 ) trackSel=false ;
0737 
0738       if(dataType=="Data" && (std::abs((*t_trackDxyPV)[itrk])>0.2 || std::abs((*t_trackDzPV)[itrk])>0.2 || (*t_trackChiSq)[itrk]>5.0 || (*t_trackPVIdx)[itrk]>0 ) ) 
0739     trackSel = false;
0740       if(dataType=="MC"   && (std::abs((*t_trackDxyPV)[itrk])>0.2 || std::abs((*t_trackDzPV)[itrk])>0.2 || (*t_trackChiSq)[itrk]>5.0 ) ) 
0741     trackSel = false;
0742       if(dataType=="DiPion" && (*t_trackChiSq)[itrk]>5.0 ) trackSel = false;
0743 
0744       double drTrackL1=0.0;
0745       if( (dataType=="Data" || dataType=="MC") ) {
0746     if( checkL1 ){
0747       drTrackL1 = DeltaR(eta1, phi1, maxL1Eta, maxL1Phi);     
0748 
0749       bool tempIso=true;
0750       if( std::abs(eta1)<1.47 ) if( e15x15-e11x11 > ebNeutIso ) tempIso=false;
0751       if( std::abs(eta1)>1.47 ) if( e15x15-e11x11 > eeNeutIso ) tempIso=false;
0752       if (debug) std::cout << "Track Selection " << trackSel << " Isolation " << tempIso << ":" << hcalNeutIso << " dr " << drTrackL1 << ":" << dRL1Jet << std::endl;
0753       if( drTrackL1<dRL1Jet) trackSel=false;
0754       if( trackChargeIso &&  hcalNeutIso && tempIso) {
0755         if( drTrackL1>100.0) {
0756           std::cout<<"trackP,eta,phi "<<std::setw(10)<<(*t_trackP)[itrk]<<std::setw(10)<<(*t_trackEta)[itrk]
0757                <<std::setw(10)<<(*t_trackPhi)[itrk]
0758                <<" L1eta,phi "<<std::setw(10)<<maxL1Eta<<std::setw(10)<<maxL1Phi
0759                <<" dEta,dPhi "<<std::setw(10)<<eta1-maxL1Eta<<std::setw(10)<<DeltaPhi(phi1,maxL1Phi)
0760                <<" dR "<<std::setw(10)<<drTrackL1<<" maxL1Pt "<<std::setw(5)<<maxL1Pt<<" "<<checkL1
0761                <<std::endl;
0762         }
0763         h_drTrackL1[iTrkMomBin][iTrkEtaBin]->Fill(drTrackL1);
0764       }
0765     } else {
0766       trackSel = false; // use only the events triigered by some L1
0767     }
0768       }
0769 
0770       if( trackSel ) {
0771     h_trackP[4]    ->Fill((*t_trackP)[itrk]    );  
0772     h_trackPt[4]   ->Fill((*t_trackPt)[itrk]   );  
0773     h_trackEta[4]  ->Fill((*t_trackEta)[itrk]  );  
0774     h_trackPhi[4]  ->Fill((*t_trackPhi)[itrk]  );  
0775     h_trackDxy[4]  ->Fill((*t_trackDxyPV)[itrk]);  
0776     h_trackDz[4]   ->Fill((*t_trackDzPV )[itrk]);  
0777     h_trackChiSq[4]->Fill((*t_trackChiSq)[itrk]  );  
0778       }
0779       
0780       //if( iTrkMomBin>=0 && iTrkEtaBin>=0 && trackNOuterHits>=4 && NLayersCrossed>=8 && trackSel) {     
0781       bool ecalNeutIso = true;
0782       if( std::abs(eta1)<1.47 ) if( e15x15-e11x11 > ebNeutIso ) ecalNeutIso=false;
0783       if( std::abs(eta1)>1.47 ) if( e15x15-e11x11 > eeNeutIso ) ecalNeutIso=false;
0784       if (debug) std::cout << "All selection " << iTrkMomBin << ":" << iTrkEtaBin << ":" << trackSel << ":" << trackChargeIso << ":" << hcalNeutIso << ":" << ecalNeutIso << std::endl;
0785 
0786       if( iTrkMomBin>=0 && iTrkEtaBin>=0 && trackSel) {  
0787      
0788     h_maxNearP31x31[iTrkMomBin][iTrkEtaBin]->Fill( maxNearP31x31 );
0789 
0790     if( trackChargeIso ) {
0791       h_diff_e15x15e11x11      [iTrkMomBin][iTrkEtaBin]->Fill(e15x15-e11x11);
0792       h_diff_e15x15e11x11_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((*t_e15x15_20Sig)[itrk]-(*t_e11x11_20Sig)[itrk]);
0793       h_diff_h7x7h5x5          [iTrkMomBin][iTrkEtaBin]->Fill( h7x7-h5x5 ) ;
0794     }
0795 
0796     if( trackChargeIso &&  hcalNeutIso) { 
0797 
0798       if(ecalNeutIso ) {
0799 
0800         h_trackP[5]    ->Fill((*t_trackP)[itrk]    );  
0801         h_trackPt[5]   ->Fill((*t_trackPt)[itrk]   );  
0802         h_trackEta[5]  ->Fill((*t_trackEta)[itrk]  );  
0803         h_trackPhi[5]  ->Fill((*t_trackPhi)[itrk]  );  
0804         h_trackDxy[5]  ->Fill((*t_trackDxyPV)[itrk]);  
0805         h_trackDz[5]   ->Fill((*t_trackDzPV )[itrk]);  
0806         h_trackChiSq[5]->Fill((*t_trackChiSq)[itrk]  );  
0807         
0808         NIsoTrk++;
0809 
0810         if( pt1>1.0 && std::abs(eta1)<2.3 ) {
0811           double etot11x11=0, etot9x9=0, etot7x7=0;
0812           if( std::abs(eta1)<1.7 ){
0813         etot11x11=e11x11+h3x3;
0814         etot9x9  =e9x9+h3x3;
0815         etot7x7  =e7x7+h3x3;
0816           } else {
0817         etot11x11=(*t_e11x11_20Sig)[itrk]+h3x3;
0818         etot9x9  =(*t_e9x9_20Sig)[itrk]+h3x3;
0819         etot7x7  =(*t_e7x7_20Sig)[itrk]+h3x3;
0820           }       
0821           h_trackPCaloE11x11H3x3[NEtaBins]->Fill( p1, etot11x11);
0822           h_trackPCaloE9x9H3x3[NEtaBins]  ->Fill( p1, etot9x9);
0823           h_trackPCaloE7x7H3x3[NEtaBins]  ->Fill( p1, etot7x7);
0824           
0825           h_trackPCaloE11x11H3x3[iTrkEtaBin]->Fill( p1, etot11x11);
0826           h_trackPCaloE9x9H3x3[iTrkEtaBin]  ->Fill( p1, etot9x9);
0827           h_trackPCaloE7x7H3x3[iTrkEtaBin]  ->Fill( p1, etot7x7);          
0828         }
0829 
0830         if( p1>3.0 &&  p1<4.0)  h_eECAL11x11VsHCAL3x3[iTrkEtaBin]->Fill(e11x11, h3x3);
0831         
0832         // Ecal tranverse profile
0833         h_eECAL7x7_Frac  [iTrkMomBin][iTrkEtaBin]->Fill(e7x7/p1);
0834         h_eECAL9x9_Frac  [iTrkMomBin][iTrkEtaBin]->Fill(e9x9/p1);
0835         h_eECAL11x11_Frac[iTrkMomBin][iTrkEtaBin]->Fill(e11x11/p1);
0836         h_eECAL15x15_Frac[iTrkMomBin][iTrkEtaBin]->Fill(e15x15/p1);
0837         
0838         hh_eECAL7x7_Frac  [iTrkEtaBin]->Fill(e7x7/p1);
0839         hh_eECAL9x9_Frac  [iTrkEtaBin]->Fill(e9x9/p1);
0840         hh_eECAL11x11_Frac[iTrkEtaBin]->Fill(e11x11/p1);
0841         hh_eECAL15x15_Frac[iTrkEtaBin]->Fill(e15x15/p1);
0842         
0843         // Hcal transverse profile
0844         h_eHCAL3x3_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h3x3/p1);
0845         h_eHCAL5x5_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h5x5/p1);
0846         h_eHCAL7x7_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h7x7/p1);
0847         if( e7x7<0.7) {
0848           h_eHCAL3x3MIP_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h3x3/p1);
0849           h_eHCAL5x5MIP_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h5x5/p1);
0850           h_eHCAL7x7MIP_Frac[iTrkMomBin][iTrkEtaBin]->Fill(h7x7/p1);
0851         }
0852         hh_eHCAL3x3_Frac[iTrkEtaBin]->Fill(h3x3/p1);
0853         hh_eHCAL5x5_Frac[iTrkEtaBin]->Fill(h5x5/p1);
0854         hh_eHCAL7x7_Frac[iTrkEtaBin]->Fill(h7x7/p1);
0855         
0856         // Response : Ecal+Hcal
0857         h_eHCAL3x3_eECAL11x11_response[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e11x11)/p1);
0858         h_eHCAL5x5_eECAL11x11_response[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e11x11)/p1);
0859         h_eHCAL7x7_eECAL11x11_response[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e11x11)/p1);
0860         if( e7x7<0.7) {
0861           h_eHCAL3x3_eECAL11x11_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e11x11)/p1);
0862           h_eHCAL5x5_eECAL11x11_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e11x11)/p1);
0863           h_eHCAL7x7_eECAL11x11_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e11x11)/p1);
0864         } else {
0865           h_eHCAL3x3_eECAL11x11_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e11x11)/p1);
0866           h_eHCAL5x5_eECAL11x11_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e11x11)/p1);
0867           h_eHCAL7x7_eECAL11x11_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e11x11)/p1);
0868         }
0869         
0870         h_eHCAL3x3_eECAL9x9_response[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e9x9)/p1);
0871         h_eHCAL5x5_eECAL9x9_response[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e9x9)/p1);
0872         h_eHCAL7x7_eECAL9x9_response[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e9x9)/p1);
0873         if( e7x7<0.700) {
0874           h_eHCAL3x3_eECAL9x9_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e9x9)/p1);
0875           h_eHCAL5x5_eECAL9x9_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e9x9)/p1);
0876           h_eHCAL7x7_eECAL9x9_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e9x9)/p1);
0877         } else {
0878           h_eHCAL3x3_eECAL9x9_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e9x9)/p1);
0879           h_eHCAL5x5_eECAL9x9_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e9x9)/p1);
0880           h_eHCAL7x7_eECAL9x9_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e9x9)/p1);
0881         }
0882         
0883         h_eHCAL3x3_eECAL7x7_response[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e7x7)/p1);
0884         h_eHCAL5x5_eECAL7x7_response[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e7x7)/p1);
0885         h_eHCAL7x7_eECAL7x7_response[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e7x7)/p1);
0886         if( e7x7<0.700) {
0887           h_eHCAL3x3_eECAL7x7_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e7x7)/p1);
0888           h_eHCAL5x5_eECAL7x7_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e7x7)/p1);
0889           h_eHCAL7x7_eECAL7x7_responseMIP[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e7x7)/p1);
0890         } else {
0891           h_eHCAL3x3_eECAL7x7_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+e7x7)/p1);
0892           h_eHCAL5x5_eECAL7x7_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+e7x7)/p1);
0893           h_eHCAL7x7_eECAL7x7_responseInteract[iTrkMomBin][iTrkEtaBin]->Fill((h7x7+e7x7)/p1);
0894         }       
0895       } // ecal neutral isolation
0896 
0897 
0898       // cut on xtal noise
0899 
0900 
0901       bool ecalNeutIso20Sig = true;
0902       if( std::abs(eta1)<1.47 ) if( (*t_e15x15_20Sig)[itrk]-(*t_e11x11_20Sig)[itrk] > ebNeutIso ) ecalNeutIso20Sig=false;
0903       if( std::abs(eta1)>1.47 ) if( (*t_e15x15_20Sig)[itrk]-(*t_e11x11_20Sig)[itrk] > eeNeutIso ) ecalNeutIso20Sig=false;     
0904       if(ecalNeutIso20Sig) {
0905 
0906         h_meanTrackP[iTrkMomBin][iTrkEtaBin]->Fill(p1);
0907         h_eECAL11x11_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((*t_e11x11_20Sig)[itrk]/p1);
0908         h_eECAL9x9_Frac_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((*t_e9x9_20Sig)[itrk]/p1);
0909         h_eECAL7x7_Frac_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((*t_e7x7_20Sig)[itrk]/p1);
0910 
0911         hh_eECAL11x11_Frac_20Sig[iTrkEtaBin]->Fill((*t_e11x11_20Sig)[itrk]/p1);
0912         hh_eECAL9x9_Frac_20Sig  [iTrkEtaBin]->Fill((*t_e9x9_20Sig)[itrk]/p1);
0913         hh_eECAL7x7_Frac_20Sig  [iTrkEtaBin]->Fill((*t_e7x7_20Sig)[itrk]/p1);
0914 
0915         h_eHCAL3x3_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h3x3/p1);
0916         h_eHCAL5x5_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h5x5/p1);
0917         h_eHCAL7x7_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h7x7/p1);
0918         if((*t_e7x7_20Sig)[itrk]<0.7 ) {
0919           h_eHCAL3x3MIP_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h3x3/p1);
0920           h_eHCAL5x5MIP_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h5x5/p1);
0921           h_eHCAL7x7MIP_Frac_20Sig[iTrkMomBin][iTrkEtaBin]->Fill(h7x7/p1);
0922         }
0923         hh_eHCAL3x3_Frac_20Sig[iTrkEtaBin]->Fill(h3x3/p1);
0924         hh_eHCAL5x5_Frac_20Sig[iTrkEtaBin]->Fill(h5x5/p1);
0925         hh_eHCAL7x7_Frac_20Sig[iTrkEtaBin]->Fill(h7x7/p1);
0926 
0927         h_eHCAL3x3_eECAL11x11_response_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e11x11_20Sig)[itrk])/p1);
0928         if((*t_e7x7_20Sig)[itrk]<0.7 ) {
0929           h_eHCAL3x3_eECAL11x11_responseMIP_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e11x11_20Sig)[itrk])/p1);
0930         } else {
0931           h_eHCAL3x3_eECAL11x11_responseInteract_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e11x11_20Sig)[itrk])/p1);
0932         }
0933         h_eHCAL3x3_eECAL9x9_response_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e9x9_20Sig)[itrk])/p1);
0934         if((*t_e7x7_20Sig)[itrk]<0.7 ) {
0935           h_eHCAL3x3_eECAL9x9_responseMIP_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e9x9_20Sig)[itrk])/p1);
0936         } else {
0937           h_eHCAL3x3_eECAL9x9_responseInteract_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e9x9_20Sig)[itrk])/p1);
0938         }
0939         h_eHCAL3x3_eECAL7x7_response_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e7x7_20Sig)[itrk])/p1);
0940         if((*t_e7x7_20Sig)[itrk]<0.7 ) {
0941           h_eHCAL3x3_eECAL7x7_responseMIP_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e7x7_20Sig)[itrk])/p1);
0942         } else {
0943           h_eHCAL3x3_eECAL7x7_responseInteract_20Sig  [iTrkMomBin][iTrkEtaBin]->Fill((h3x3+(*t_e7x7_20Sig)[itrk])/p1);
0944         }
0945         h_eHCAL5x5_eECAL11x11_response_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+(*t_e11x11_20Sig)[itrk])/p1);
0946         if((*t_e7x7_20Sig)[itrk]<0.7 ) {
0947           h_eHCAL5x5_eECAL11x11_responseMIP_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+(*t_e11x11_20Sig)[itrk])/p1);
0948         } else {
0949           h_eHCAL5x5_eECAL11x11_responseInteract_20Sig[iTrkMomBin][iTrkEtaBin]->Fill((h5x5+(*t_e11x11_20Sig)[itrk])/p1);
0950         }
0951 
0952       }
0953 
0954     }    // if charged & hcal iso
0955     
0956       } // momentum and eta bins 
0957       
0958     } // loop over tracks in the event 
0959 
0960     if( runNIsoTrkList.find(t_RunNo) != runNIsoTrkList.end() ) {
0961       runNIsoTrkList[t_RunNo] += NIsoTrk;
0962     } else {
0963       runNIsoTrkList.insert( std::pair<unsigned int, unsigned int>(t_RunNo,NIsoTrk) );
0964       if (debug) std::cout << "runNo " << t_RunNo <<" "<<runNIsoTrkList[t_RunNo]<<std::endl;
0965     }
0966   
0967   } //loop over tree entries
0968 
0969   std::cout<<"Number of entries in tree "<<nentries                                                         << "\n"
0970        <<"nEventsGoodRuns           "<<nEventsGoodRuns                                                  << "\n"
0971        <<"nEventsValidPV            "<<nEventsValidPV  << " " <<(double)nEventsValidPV/nEventsGoodRuns  << "\n"
0972        <<"nEventsPVTracks           "<<nEventsPVTracks << " " <<(double)nEventsPVTracks/nEventsGoodRuns << "\n"
0973        << std::endl;
0974 
0975   std::cout << "saved runEvtList " << std::endl;
0976   std::map<unsigned int, unsigned int>::iterator runEvtListItr = runEvtList.begin();
0977   long total=0;
0978   for(runEvtListItr=runEvtList.begin(); runEvtListItr != runEvtList.end(); runEvtListItr++) {
0979     std::cout<<runEvtListItr->first << " "<< runEvtListItr->second << std::endl;
0980     total += runEvtListItr->second;
0981   }
0982   std::cout<<"Total   " << total << std::endl << std::endl;
0983 
0984   total = 0;
0985   std::cout << "Number of tracks in runs " << std::endl;
0986   std::map<unsigned int, unsigned int>::iterator runNTrkListItr = runNTrkList.begin();
0987   for(runNTrkListItr=runNTrkList.begin(); runNTrkListItr != runNTrkList.end(); runNTrkListItr++) {
0988     std::cout<<runNTrkListItr->first << " "<< runNTrkListItr->second << std::endl;
0989     total += runNTrkListItr->second;
0990   }
0991   std::cout<<"Total   " << total << std::endl << std::endl;
0992 
0993   total = 0;
0994   std::cout << "Number of isolated tracks in runs " << std::endl;
0995   std::map<unsigned int, unsigned int>::iterator runNIsoTrkListItr = runNIsoTrkList.begin();
0996   for(runNIsoTrkListItr=runNIsoTrkList.begin(); runNIsoTrkListItr != runNIsoTrkList.end(); runNIsoTrkListItr++) {
0997     std::cout<<runNIsoTrkListItr->first << " "<< runNIsoTrkListItr->second << std::endl;
0998     total += runNIsoTrkListItr->second;
0999   }
1000   std::cout<<"Total   " << total << std::endl << std::endl;  
1001 }
1002 
1003 Bool_t TreeAnalysisHcalNZS::Notify() {
1004   // The Notify() function is called when a new file is opened. This
1005   // can be either for a new TTree in a TChain or when when a new TTree
1006   // is started when using PROOF. It is normally not necessary to make changes
1007   // to the generated code, but the routine can be extended by the
1008   // user if needed. The return value is currently not used.
1009 
1010   return kTRUE;
1011 }
1012 
1013 void TreeAnalysisHcalNZS::Show(Long64_t entry) {
1014   // Print contents of entry.
1015   // If entry is not specified, print current entry
1016   if (!fChain) return;
1017   fChain->Show(entry);
1018 }
1019 
1020 double TreeAnalysisHcalNZS::DeltaPhi(double v1, double v2) {
1021   // Computes the correctly normalized phi difference 
1022   // v1, v2 = phi of object 1 and 2 
1023 
1024   double pi    = 3.141592654;
1025   double twopi = 6.283185307;
1026 
1027   double diff = std::abs(v2 - v1);
1028   double corr = twopi - diff;
1029   if (diff < pi){ return diff;} else { return corr;}
1030 }
1031 
1032 double TreeAnalysisHcalNZS::DeltaR(double eta1, double phi1, double eta2, double phi2) {
1033   double deta = eta1 - eta2;
1034   double dphi = DeltaPhi(phi1, phi2);
1035   return std::sqrt(deta*deta + dphi*dphi);
1036 }
1037 
1038 void TreeAnalysisHcalNZS::BookHistograms(const char *outFileName) {
1039 
1040   fout = new TFile(outFileName, "RECREATE");
1041 
1042   fout->cd();
1043 
1044   char hname[1000], htit[1000];
1045 
1046   TDirectory *d_caloTrkPProfile = fout->mkdir( "ProfileTrackPcaloEne" );
1047   d_caloTrkPProfile->cd();
1048   for (int ibin=0; ibin<=NEtaBins; ibin++) {
1049     if (ibin == NEtaBins) sprintf (htit, "CaloEne(E11x11+H3x3) as trackP:|#eta|<%f", genPartEtaBins[NEtaBins]);
1050     else sprintf (htit, "CaloEne(E11x11+H3x3) as trackP:%f<|#eta|<%f", genPartEtaBins[ibin],genPartEtaBins[ibin+1]);
1051     sprintf (hname, "h_trackPCaloE11x11H3x3_%d", ibin);
1052     h_trackPCaloE11x11H3x3[ibin] = new TProfile(hname, htit,   15, genPartPBins);
1053     if (ibin == NEtaBins) sprintf (htit, "CaloEne(E9x9+H3x3) as trackP:|#eta|<%f", genPartEtaBins[NEtaBins]);
1054     else sprintf (htit, "CaloEne(E9x9+H3x3) as trackP:%f<|#eta|<%f", genPartEtaBins[ibin],genPartEtaBins[ibin+1]);
1055     sprintf (hname, "h_trackPCaloE9x9H3x3_%d", ibin);
1056     h_trackPCaloE9x9H3x3[ibin] = new TProfile(hname, htit,   15, genPartPBins);
1057     if (ibin == NEtaBins) sprintf (htit, "CaloEne(E7x7+H3x3) as trackP:|#eta|<%f", genPartEtaBins[NEtaBins]);
1058     else sprintf (htit, "CaloEne(E7x7+H3x3) as trackP:%f<|#eta|<%f", genPartEtaBins[ibin],genPartEtaBins[ibin+1]);
1059     sprintf (hname, "h_trackPCaloE7x7H3x3_%d", ibin);
1060     h_trackPCaloE7x7H3x3[ibin] = new TProfile(hname, htit,   15, genPartPBins);
1061   }
1062 
1063   fout->cd();
1064   for (int i=0; i<2; ++i) {
1065     sprintf (hname, "h_NPV_%d", i);
1066     h_NPV[i]              = new TH1F(hname, hname,    10, -0.5,   9.5); 
1067     h_NPV[i]              ->Sumw2(); 
1068     sprintf (hname, "h_PVx_%d", i);
1069     h_PVx[i]              = new TH1F(hname, hname,    40, -2.0,   2.0); 
1070     h_PVx[i]              ->Sumw2(); 
1071     sprintf (hname, "h_PVy_%d", i);
1072     h_PVy[i]              = new TH1F(hname, hname,    40, -2.0,   2.0); 
1073     h_PVy[i]              ->Sumw2(); 
1074     sprintf (hname, "h_PVr_%d", i);
1075     h_PVr[i]              = new TH1F(hname, hname,   100,  0.0,   3.0); 
1076     h_PVr[i]              ->Sumw2(); 
1077     sprintf (hname, "h_PVz_%d", i);
1078     h_PVz[i]              = new TH1F(hname, hname,   100,-20.0,  20.0); 
1079     h_PVz[i]              ->Sumw2(); 
1080     sprintf (hname, "h_PVNDOF_%d", i);
1081     h_PVNDOF[i]           = new TH1F(hname, hname,   300, -0.5, 299.5); 
1082     h_PVNDOF[i]           ->Sumw2();
1083     sprintf (hname, "h_PVNTracks_%d", i);
1084     h_PVNTracks[i]        = new TH1F(hname, hname,   300,  0.0, 300.0); 
1085     h_PVNTracks[i]        ->Sumw2(); 
1086     sprintf (hname, "h_PVTracksSumPt_%d", i);
1087     h_PVTracksSumPt[i]    = new TH1F(hname, hname,   300,  0.0, 300.0);
1088     h_PVTracksSumPt[i]    ->Sumw2();
1089     sprintf (hname, "h_PVNTracksWt_%d", i);
1090     h_PVNTracksWt[i]      = new TH1F(hname, hname,   300,  0.0, 300.0); 
1091     h_PVNTracksWt[i]      ->Sumw2(); 
1092     sprintf (hname, "h_PVTracksSumPtWt_%d", i);
1093     h_PVTracksSumPtWt[i]  = new TH1F(hname, hname,   300,  0.0, 300.0);
1094     h_PVTracksSumPtWt[i]  ->Sumw2();
1095     sprintf (hname, "h_PVNTracksSumPt_%d", i);
1096     h_PVNTracksSumPt[i] = new TH2F(hname, hname, 100,0.0,100.0, 100,0.0,100.0);
1097   }
1098 
1099   std::string subtitle[6] = {"All HighPirity Tracks",
1100                  "good first PV & Iso in Ecal31x31",
1101                  "good first PV & Iso in Ecal31x31 & Pt>1.0",
1102                  "good first PV & Iso in Ecal31x31 & Pt>1.0 & NoIntInTracker",
1103                  "good first PV & Iso in Ecal31x31 & Pt>1.0 & NoIntInTracker & |dxy|<0.2,|dz|<0.2,chisq<5.0",
1104                  "Fully Isolated"};
1105   for (int i=0; i<6; ++i) {
1106     sprintf (hname, "h_trackP_%d", i);
1107     sprintf (htit,  "P:    %s", subtitle[i].c_str());
1108     h_trackP[i]     = new TH1F(hname, htit,   15, genPartPBins);
1109     h_trackP[i]     ->Sumw2();
1110     sprintf (hname, "h_trackPt_%d", i);
1111     sprintf (htit,  "Pt:   %s", subtitle[i].c_str());
1112     h_trackPt[i]    = new TH1F(hname, htit,   15, genPartPBins);
1113     h_trackPt[i]    ->Sumw2();
1114     sprintf (hname, "h_trackEta_%d", i);
1115     sprintf (htit,  "Eta:  %s", subtitle[i].c_str());
1116     h_trackEta[i]  = new TH1F(hname, htit,   100, -3.0, 3.0);
1117     h_trackEta[i]  ->Sumw2();
1118     sprintf (hname, "h_trackPhi_%d", i);
1119     sprintf (htit,  "Phi:  %s", subtitle[i].c_str());
1120     h_trackPhi[i]   = new TH1F(hname, htit,  100, -3.14159, 3.14159);
1121     h_trackPhi[i]  ->Sumw2();
1122     sprintf (hname, "h_trackChiSq_%d", i);
1123     sprintf (htit,  "ChiSq:%s", subtitle[i].c_str());
1124     h_trackChiSq[i] = new TH1F(hname, htit,  200,  0.0,20.0);
1125     h_trackChiSq[i]->Sumw2();  
1126     sprintf (hname, "h_trackDxyPV_%d", i);
1127     sprintf (htit,  "DxyPV:%s", subtitle[i].c_str());
1128     h_trackDxy[i]   = new TH1F(hname, htit,  200, -1.0, 1.0);
1129     h_trackDxy[i]  ->Sumw2();  
1130     sprintf (hname, "h_trackDzPV_%d", i);
1131     sprintf (htit,  "DzPV:%s", subtitle[i].c_str());
1132     h_trackDz[i]    = new TH1F(hname, htit,  200, -1.0, 1.0);
1133     h_trackDz[i]   ->Sumw2();  
1134   }
1135 
1136   for(int ieta=0; ieta<NEtaBins; ieta++) {
1137     double lowEta=-5.0, highEta= 5.0;
1138     lowEta  = genPartEtaBins[ieta];
1139     highEta = genPartEtaBins[ieta+1];
1140     
1141      sprintf(hname, "h_trackPhi_2_2_etaBin%i",ieta);
1142      sprintf(htit,  "h_trackPhi(pt>1.0, iso in 31x31) : %3.2f<|#eta|<%3.2f)", lowEta, highEta);
1143     h_trackPhi_2_2[ieta]= new TH1F(hname, htit,  100, -3.14159, 3.14159);
1144      sprintf(hname, "h_trackPhi_3_3_etaBin%i",ieta);
1145      sprintf(htit,  "h_trackPhi(pt>1.0, iso in 31x31,no missing hit) : %3.2f<|#eta|<%3.2f)", lowEta, highEta);
1146     h_trackPhi_3_3[ieta]= new TH1F(hname, htit,  100, -3.14159, 3.14159);
1147 
1148      sprintf(hname, "h_trackPhi_3_Inner_etaBin%i",ieta);
1149      sprintf(htit,  "h_trackPhi(pt>1.0, iso in 31x31,no missing Inner hit) : %3.2f<|#eta|<%3.2f)", lowEta, highEta);
1150     h_trackPhi_3_Inner[ieta]= new TH1F(hname, htit,  100, -3.14159, 3.14159);
1151 
1152      sprintf(hname, "h_trackPhi_3_Outer_etaBin%i",ieta);
1153      sprintf(htit,  "h_trackPhi(pt>1.0, iso in 31x31,no missing Outer hit) : %3.2f<|#eta|<%3.2f)", lowEta, highEta);
1154     h_trackPhi_3_Outer[ieta]= new TH1F(hname, htit,  100, -3.14159, 3.14159);
1155 
1156   }
1157 
1158   TDirectory *d_meanTrackP   = fout->mkdir( "MeanTrackP" );
1159   TDirectory *d_maxNearP     = fout->mkdir( "MaxNearP" );
1160   TDirectory *d_neutralIso   = fout->mkdir( "NeutralIsolation" );
1161   TDirectory* d_trProf1      = fout->mkdir( "EcalTranverseProfile" );
1162   TDirectory* d_trProf2      = fout->mkdir( "HcalTranverseProfile" );
1163   TDirectory* d_response     = fout->mkdir( "Response" );
1164   TDirectory* d_response10Sig= fout->mkdir( "Response10Sig" );
1165   TDirectory* d_response15Sig= fout->mkdir( "Response15Sig" ); 
1166   TDirectory* d_response20Sig= fout->mkdir( "Response20Sig" );
1167   TDirectory* d_response25Sig= fout->mkdir( "Response25Sig" );
1168   TDirectory* d_response30Sig= fout->mkdir( "Response30Sig" );
1169   TDirectory *d_drTrackL1    = fout->mkdir( "DrTrackL1" );
1170 
1171   for (int ieta=0; ieta<NEtaBins; ieta++) {
1172     double lowEta=-5.0, highEta= 5.0;
1173     lowEta  = genPartEtaBins[ieta];
1174     highEta = genPartEtaBins[ieta+1];
1175 
1176     sprintf(hname, "h_eECAL11x11VsHCAL3x3_etaBin%i",ieta);
1177     sprintf(htit,  "eEvseH : %3.2f<|#eta|<%3.2f)", lowEta, highEta);
1178     h_eECAL11x11VsHCAL3x3[ieta] = new TH2F(hname, hname, 220, -1.0, 10.0, 220, -1.0, 10.0);
1179 
1180     d_trProf1->cd();
1181     sprintf(hname, "hh_eECAL7x7Frac_etaBin%i", ieta);
1182     sprintf(htit,  "eECAL7x7/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1183     hh_eECAL7x7_Frac[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1184     hh_eECAL7x7_Frac[ieta] ->Sumw2();
1185     sprintf(hname, "hh_eECAL9x9Frac_etaBin%i", ieta);
1186     sprintf(htit,  "eECAL9x9/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1187     hh_eECAL9x9_Frac[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1188     hh_eECAL9x9_Frac[ieta] ->Sumw2();
1189     sprintf(hname, "hh_eECAL11x11Frac_etaBin%i", ieta);
1190     sprintf(htit,  "eECAL11x11/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1191     hh_eECAL11x11_Frac[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1192     hh_eECAL11x11_Frac[ieta] ->Sumw2();
1193     sprintf(hname, "hh_eECAL15x15Frac_etaBin%i", ieta);
1194     sprintf(htit,  "eECAL15x15/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1195     hh_eECAL15x15_Frac[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1196     hh_eECAL15x15_Frac[ieta] ->Sumw2();
1197 
1198     sprintf(hname, "hh_eECAL7x7Frac20Sig_etaBin%i", ieta);
1199     sprintf(htit,  "eECAL7x7/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1200     hh_eECAL7x7_Frac_20Sig[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1201     hh_eECAL7x7_Frac_20Sig[ieta] ->Sumw2();
1202     sprintf(hname, "hh_eECAL9x9Frac20Sig_etaBin%i", ieta);
1203     sprintf(htit,  "eECAL9x9/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1204     hh_eECAL9x9_Frac_20Sig[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1205     hh_eECAL9x9_Frac_20Sig[ieta] ->Sumw2();
1206     sprintf(hname, "hh_eECAL11x11Frac20Sig_etaBin%i", ieta);
1207     sprintf(htit,  "eECAL11x11/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1208     hh_eECAL11x11_Frac_20Sig[ieta] =  new TH1F(hname, htit, 500, -1.0, 4.0);
1209     hh_eECAL11x11_Frac_20Sig[ieta] ->Sumw2();
1210     
1211     d_trProf2->cd();
1212     sprintf(hname, "hh_eHCAL3x3Frac_etaBin%i", ieta);
1213     sprintf(htit,  "eHCAL3x3/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1214     hh_eHCAL3x3_Frac[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1215     hh_eHCAL3x3_Frac[ieta] ->Sumw2();
1216     sprintf(hname, "hh_eHCAL5x5Frac_etaBin%i", ieta);
1217     sprintf(htit,  "eHCAL5x5/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1218     hh_eHCAL5x5_Frac[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1219     hh_eHCAL5x5_Frac[ieta] ->Sumw2();
1220     sprintf(hname, "hh_eHCAL7x7Frac_etaBin%i", ieta);
1221     sprintf(htit,  "eHCAL7x7/trkP (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1222     hh_eHCAL7x7_Frac[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1223     hh_eHCAL7x7_Frac[ieta] ->Sumw2();
1224 
1225     sprintf(hname, "hh_eHCAL3x3Frac20Sig_etaBin%i", ieta);
1226     sprintf(htit,  "eHCAL3x3/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1227     hh_eHCAL3x3_Frac_20Sig[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1228     hh_eHCAL3x3_Frac_20Sig[ieta] ->Sumw2();
1229     sprintf(hname, "hh_eHCAL5x5Frac20Sig_etaBin%i", ieta);
1230     sprintf(htit,  "eHCAL5x5/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1231     hh_eHCAL5x5_Frac_20Sig[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1232     hh_eHCAL5x5_Frac_20Sig[ieta] ->Sumw2();
1233     sprintf(hname, "hh_eHCAL7x7Frac20Sig_etaBin%i", ieta);
1234     sprintf(htit,  "eHCAL7x7/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f)", lowEta, highEta );
1235     hh_eHCAL7x7_Frac_20Sig[ieta] = new TH1F(hname, htit, 500, -2.0, 4.0);
1236     hh_eHCAL7x7_Frac_20Sig[ieta] ->Sumw2();
1237 
1238     for(int ipt=0; ipt<NPBins; ipt++) {
1239       double lowP=0.0, highP=300.0;
1240       lowP    = genPartPBins[ipt];
1241       highP   = genPartPBins[ipt+1];
1242 
1243       d_neutralIso->cd();
1244       sprintf(hname, "h_diff_e15x15e11x11_ptBin%i_etaBin%i", ipt, ieta);
1245       sprintf(htit,  "h_diff_e15x15e11x11: (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1246       h_diff_e15x15e11x11      [ipt][ieta] = new TH1F(hname, htit, 600, -10.0, 50.0);
1247       sprintf(hname, "h_diff20Sig_e15x15e11x11_ptBin%i_etaBin%i", ipt, ieta);
1248       sprintf(htit,  "h_diff20Sig_e15x15e11x11: (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1249       h_diff_e15x15e11x11_20Sig[ipt][ieta] = new TH1F(hname, htit, 600, -10.0, 50.0);
1250       sprintf(hname, "h_diff_h7x7h5x5_ptBin%i_etaBin%i", ipt, ieta);
1251       sprintf(htit,  "h_diff_h7x7h5x5: (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1252       h_diff_h7x7h5x5[ipt][ieta] = new TH1F(hname, htit, 600, -10.0, 50.0);
1253 
1254       d_maxNearP->cd();
1255       sprintf(hname, "h_maxNearP31x31_ptBin%i_etaBin%i",ipt, ieta);
1256       sprintf(htit,  "maxNearP in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1257       h_maxNearP31x31[ipt][ieta] = new TH1F(hname, htit, 220, -2.0, 20.0);
1258       h_maxNearP31x31[ipt][ieta] ->Sumw2();
1259     
1260       //==============================
1261       // Ecal plots
1262       //==============================
1263       d_trProf1->cd();
1264       sprintf(hname, "h_eECAL7x7Frac_ptBin%i_etaBin%i", ipt, ieta);
1265       sprintf(htit,  "eECAL7x7/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1266       h_eECAL7x7_Frac[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1267       h_eECAL7x7_Frac[ipt][ieta] ->Sumw2();
1268       sprintf(hname, "h_eECAL9x9Frac_ptBin%i_etaBin%i", ipt, ieta);
1269       sprintf(htit,  "eECAL9x9/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1270       h_eECAL9x9_Frac[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1271       h_eECAL9x9_Frac[ipt][ieta] ->Sumw2();
1272       sprintf(hname, "h_eECAL11x11Frac_ptBin%i_etaBin%i", ipt, ieta);
1273       sprintf(htit,  "eECAL11x11/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1274       h_eECAL11x11_Frac[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1275       h_eECAL11x11_Frac[ipt][ieta] ->Sumw2();
1276       sprintf(hname, "h_eECAL15x15Frac_ptBin%i_etaBin%i", ipt, ieta);
1277       sprintf(htit,  "eECAL15x15/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1278       h_eECAL15x15_Frac[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1279       h_eECAL15x15_Frac[ipt][ieta] ->Sumw2();
1280     
1281       //==== additional plots with Sigma cut
1282       sprintf(hname, "h_eECAL7x7Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1283       sprintf(htit,  "eECAL7x7/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1284       h_eECAL7x7_Frac_20Sig[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1285       h_eECAL7x7_Frac_20Sig[ipt][ieta] ->Sumw2();
1286       sprintf(hname, "h_eECAL9x9Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1287       sprintf(htit,  "eECAL9x9/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1288       h_eECAL9x9_Frac_20Sig[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1289       h_eECAL9x9_Frac_20Sig[ipt][ieta] ->Sumw2();
1290       sprintf(hname, "h_eECAL11x11Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1291       sprintf(htit,  "eECAL11x11/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1292       h_eECAL11x11_Frac_20Sig[ipt][ieta] =  new TH1F(hname, htit, 1500, -1.0, 4.0);
1293       h_eECAL11x11_Frac_20Sig[ipt][ieta] ->Sumw2();
1294       //==============================
1295       // Hcal plots
1296       //==============================
1297       d_trProf2->cd();
1298       sprintf(hname, "h_eHCAL3x3Frac_ptBin%i_etaBin%i", ipt, ieta);
1299       sprintf(htit,  "eHCAL3x3/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1300       h_eHCAL3x3_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1301       h_eHCAL3x3_Frac[ipt][ieta] ->Sumw2();
1302       sprintf(hname, "h_eHCAL5x5Frac_ptBin%i_etaBin%i", ipt, ieta);
1303       sprintf(htit,  "eHCAL5x5/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1304       h_eHCAL5x5_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1305       h_eHCAL5x5_Frac[ipt][ieta] ->Sumw2();
1306       sprintf(hname, "h_eHCAL7x7Frac_ptBin%i_etaBin%i", ipt, ieta);
1307       sprintf(htit,  "eHCAL7x7/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1308       h_eHCAL7x7_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1309       h_eHCAL7x7_Frac[ipt][ieta] ->Sumw2();
1310       
1311       sprintf(hname, "h_eHCAL3x3Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1312       sprintf(htit,  "eHCAL3x3/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1313       h_eHCAL3x3_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1314       h_eHCAL3x3_Frac_20Sig[ipt][ieta] ->Sumw2();
1315       sprintf(hname, "h_eHCAL5x5Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1316       sprintf(htit,  "eHCAL5x5/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1317       h_eHCAL5x5_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1318       h_eHCAL5x5_Frac_20Sig[ipt][ieta] ->Sumw2();
1319       sprintf(hname, "h_eHCAL7x7Frac20Sig_ptBin%i_etaBin%i", ipt, ieta);
1320       sprintf(htit,  "eHCAL7x7/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1321       h_eHCAL7x7_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1322       h_eHCAL7x7_Frac_20Sig[ipt][ieta] ->Sumw2();
1323       
1324       sprintf(hname, "h_eHCAL3x3FracMIP_ptBin%i_etaBin%i", ipt, ieta);
1325       sprintf(htit,  "eHCAL3x3MIP/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1326       h_eHCAL3x3MIP_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1327       h_eHCAL3x3MIP_Frac[ipt][ieta] ->Sumw2();
1328       sprintf(hname, "h_eHCAL5x5FracMIP_ptBin%i_etaBin%i", ipt, ieta);
1329       sprintf(htit,  "eHCAL5x5MIP/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1330       h_eHCAL5x5MIP_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1331       h_eHCAL5x5MIP_Frac[ipt][ieta] ->Sumw2();
1332       sprintf(hname, "h_eHCAL7x7FracMIP_ptBin%i_etaBin%i", ipt, ieta);
1333       sprintf(htit,  "eHCAL7x7MIP/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1334       h_eHCAL7x7MIP_Frac[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1335       h_eHCAL7x7MIP_Frac[ipt][ieta] ->Sumw2();
1336       
1337       sprintf(hname, "h_eHCAL3x3FracMIP20Sig_ptBin%i_etaBin%i", ipt, ieta);
1338       sprintf(htit,  "eHCAL3x3MIP/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1339       h_eHCAL3x3MIP_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1340       h_eHCAL3x3MIP_Frac_20Sig[ipt][ieta] ->Sumw2();
1341       sprintf(hname, "h_eHCAL5x5FracMIP20Sig_ptBin%i_etaBin%i", ipt, ieta);
1342       sprintf(htit,  "eHCAL5x5MIP/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1343       h_eHCAL5x5MIP_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1344       h_eHCAL5x5MIP_Frac_20Sig[ipt][ieta] ->Sumw2();
1345       sprintf(hname, "h_eHCAL7x7FracMIP20Sig_ptBin%i_etaBin%i", ipt, ieta);
1346       sprintf(htit,  "eHCAL7x7MIP/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1347       h_eHCAL7x7MIP_Frac_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1348       h_eHCAL7x7MIP_Frac_20Sig[ipt][ieta] ->Sumw2();
1349 
1350       //=================== Ecal+Hcal Response ====================
1351       d_response->cd();
1352       sprintf(hname, "h_Response_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1353       sprintf(htit,  "(eHCAL3x3+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1354       h_eHCAL3x3_eECAL11x11_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1355       h_eHCAL3x3_eECAL11x11_response[ipt][ieta] ->Sumw2();
1356       sprintf(hname, "h_Response_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1357       sprintf(htit,  "(eHCAL5x5+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1358       h_eHCAL5x5_eECAL11x11_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1359       h_eHCAL5x5_eECAL11x11_response[ipt][ieta] ->Sumw2();
1360       sprintf(hname, "h_Response_eHCAL7x7_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1361       sprintf(htit,  "(eHCAL7x7+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1362       h_eHCAL7x7_eECAL11x11_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1363       h_eHCAL7x7_eECAL11x11_response[ipt][ieta] ->Sumw2();
1364       
1365       sprintf(hname, "h_ResponseMIP_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1366       sprintf(htit,  "(eHCAL3x3MIP+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1367       h_eHCAL3x3_eECAL11x11_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1368       h_eHCAL3x3_eECAL11x11_responseMIP[ipt][ieta] ->Sumw2();
1369       sprintf(hname, "h_ResponseMIP_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1370       sprintf(htit,  "(eHCAL5x5MIP+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1371       h_eHCAL5x5_eECAL11x11_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1372       h_eHCAL5x5_eECAL11x11_responseMIP[ipt][ieta] ->Sumw2();
1373       sprintf(hname, "h_ResponseMIP_eHCAL7x7_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1374       sprintf(htit,  "(eHCAL7x7MIP+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1375       h_eHCAL7x7_eECAL11x11_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1376       h_eHCAL7x7_eECAL11x11_responseMIP[ipt][ieta] ->Sumw2();
1377       
1378       sprintf(hname, "h_ResponseInteract_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1379       sprintf(htit,  "(eHCAL3x3Interact+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1380       h_eHCAL3x3_eECAL11x11_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1381       h_eHCAL3x3_eECAL11x11_responseInteract[ipt][ieta] ->Sumw2();
1382       sprintf(hname, "h_ResponseInteract_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1383       sprintf(htit,  "(eHCAL5x5Interact+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1384       h_eHCAL5x5_eECAL11x11_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1385       h_eHCAL5x5_eECAL11x11_responseInteract[ipt][ieta] ->Sumw2();
1386       sprintf(hname, "h_ResponseInteract_eHCAL7x7_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1387       sprintf(htit,  "(eHCAL7x7Interact+eECAL11x11)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1388       h_eHCAL7x7_eECAL11x11_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1389       h_eHCAL7x7_eECAL11x11_responseInteract[ipt][ieta] ->Sumw2();
1390       
1391       sprintf(hname, "h_Response_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1392       sprintf(htit,  "(eHCAL3x3+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1393       h_eHCAL3x3_eECAL9x9_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1394       h_eHCAL3x3_eECAL9x9_response[ipt][ieta] ->Sumw2();
1395       sprintf(hname, "h_Response_eHCAL5x5_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1396       sprintf(htit,  "(eHCAL5x5+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1397       h_eHCAL5x5_eECAL9x9_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1398       h_eHCAL5x5_eECAL9x9_response[ipt][ieta] ->Sumw2();
1399       sprintf(hname, "h_Response_eHCAL7x7_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1400       sprintf(htit,  "(eHCAL7x7+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1401       h_eHCAL7x7_eECAL9x9_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1402       h_eHCAL7x7_eECAL9x9_response[ipt][ieta] ->Sumw2();
1403       
1404       sprintf(hname, "h_ResponseMIP_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1405       sprintf(htit,  "(eHCAL3x3MIP+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1406       h_eHCAL3x3_eECAL9x9_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1407       h_eHCAL3x3_eECAL9x9_responseMIP[ipt][ieta] ->Sumw2();
1408       sprintf(hname, "h_ResponseMIP_eHCAL5x5_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1409       sprintf(htit,  "(eHCAL5x5MIP+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1410       h_eHCAL5x5_eECAL9x9_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1411       h_eHCAL5x5_eECAL9x9_responseMIP[ipt][ieta] ->Sumw2();
1412       sprintf(hname, "h_ResponseMIP_eHCAL7x7_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1413       sprintf(htit,  "(eHCAL7x7MIP+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1414       h_eHCAL7x7_eECAL9x9_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1415       h_eHCAL7x7_eECAL9x9_responseMIP[ipt][ieta] ->Sumw2();
1416       
1417       sprintf(hname, "h_ResponseInteract_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1418       sprintf(htit,  "(eHCAL3x3Interact+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1419       h_eHCAL3x3_eECAL9x9_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1420       h_eHCAL3x3_eECAL9x9_responseInteract[ipt][ieta] ->Sumw2();
1421       sprintf(hname, "h_ResponseInteract_eHCAL5x5_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1422       sprintf(htit,  "(eHCAL5x5Interact+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1423       h_eHCAL5x5_eECAL9x9_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1424       h_eHCAL5x5_eECAL9x9_responseInteract[ipt][ieta] ->Sumw2();
1425       sprintf(hname, "h_ResponseInteract_eHCAL7x7_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1426       sprintf(htit,  "(eHCAL7x7Interact+eECAL9x9)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1427       h_eHCAL7x7_eECAL9x9_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1428       h_eHCAL7x7_eECAL9x9_responseInteract[ipt][ieta] ->Sumw2();
1429 
1430 
1431       sprintf(hname, "h_Response_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1432       sprintf(htit,  "(eHCAL3x3+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1433       h_eHCAL3x3_eECAL7x7_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1434       h_eHCAL3x3_eECAL7x7_response[ipt][ieta] ->Sumw2();
1435       sprintf(hname, "h_Response_eHCAL5x5_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1436       sprintf(htit,  "(eHCAL5x5+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1437       h_eHCAL5x5_eECAL7x7_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1438       h_eHCAL5x5_eECAL7x7_response[ipt][ieta] ->Sumw2();
1439       sprintf(hname, "h_Response_eHCAL7x7_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1440       sprintf(htit,  "(eHCAL7x7+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1441       h_eHCAL7x7_eECAL7x7_response[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1442       h_eHCAL7x7_eECAL7x7_response[ipt][ieta] ->Sumw2();
1443 
1444       sprintf(hname, "h_ResponseMIP_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1445       sprintf(htit,  "(eHCAL3x3MIP+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1446       h_eHCAL3x3_eECAL7x7_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1447       h_eHCAL3x3_eECAL7x7_responseMIP[ipt][ieta] ->Sumw2();
1448       sprintf(hname, "h_ResponseMIP_eHCAL5x5_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1449       sprintf(htit,  "(eHCAL5x5MIP+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1450       h_eHCAL5x5_eECAL7x7_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1451       h_eHCAL5x5_eECAL7x7_responseMIP[ipt][ieta] ->Sumw2();
1452       sprintf(hname, "h_ResponseMIP_eHCAL7x7_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1453       sprintf(htit,  "(eHCAL7x7MIP+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1454       h_eHCAL7x7_eECAL7x7_responseMIP[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1455       h_eHCAL7x7_eECAL7x7_responseMIP[ipt][ieta] ->Sumw2();
1456       
1457       sprintf(hname, "h_ResponseInteract_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1458       sprintf(htit,  "(eHCAL3x3Interact+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1459       h_eHCAL3x3_eECAL7x7_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1460       h_eHCAL3x3_eECAL7x7_responseInteract[ipt][ieta] ->Sumw2();
1461       sprintf(hname, "h_ResponseInteract_eHCAL5x5_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1462       sprintf(htit,  "(eHCAL5x5Interact+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1463       h_eHCAL5x5_eECAL7x7_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1464       h_eHCAL5x5_eECAL7x7_responseInteract[ipt][ieta] ->Sumw2();
1465       sprintf(hname, "h_ResponseInteract_eHCAL7x7_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1466       sprintf(htit,  "(eHCAL7x7Interact+eECAL7x7)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1467       h_eHCAL7x7_eECAL7x7_responseInteract[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1468       h_eHCAL7x7_eECAL7x7_responseInteract[ipt][ieta] ->Sumw2();
1469       
1470       d_response20Sig->cd();
1471       sprintf(hname, "h_Response20Sig_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1472       sprintf(htit,  "(eHCAL3x3+eECAL11x11)(Xtal>2.0#sigma)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1473       h_eHCAL3x3_eECAL11x11_response_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1474       h_eHCAL3x3_eECAL11x11_response_20Sig[ipt][ieta] ->Sumw2();
1475       sprintf(hname, "h_ResponseMIP20Sig_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1476       sprintf(htit,  "(eHCAL3x3MIP+eECAL11x11)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1477       h_eHCAL3x3_eECAL11x11_responseMIP_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1478       h_eHCAL3x3_eECAL11x11_responseMIP_20Sig[ipt][ieta] ->Sumw2();
1479       sprintf(hname, "h_ResponseInteract20Sig_eHCAL3x3_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1480       sprintf(htit,  "(eHCAL3x3Interact+eECAL11x11)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1481       h_eHCAL3x3_eECAL11x11_responseInteract_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1482       h_eHCAL3x3_eECAL11x11_responseInteract_20Sig[ipt][ieta] ->Sumw2();
1483       sprintf(hname, "h_Response20Sig_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1484       sprintf(htit,  "(eHCAL5x5+eECAL11x11)(Xtal>2.0#sigma)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1485       h_eHCAL5x5_eECAL11x11_response_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1486       h_eHCAL5x5_eECAL11x11_response_20Sig[ipt][ieta] ->Sumw2();
1487       sprintf(hname, "h_ResponseMIP20Sig_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1488       sprintf(htit,  "(eHCAL5x5MIP+eECAL11x11)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1489       h_eHCAL5x5_eECAL11x11_responseMIP_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1490       h_eHCAL5x5_eECAL11x11_responseMIP_20Sig[ipt][ieta] ->Sumw2();
1491       sprintf(hname, "h_ResponseInteract20Sig_eHCAL5x5_eECAL11x11_ptBin%i_etaBin%i", ipt, ieta);
1492       sprintf(htit,  "(eHCAL5x5Interact+eECAL11x11)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1493       h_eHCAL5x5_eECAL11x11_responseInteract_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1494       h_eHCAL5x5_eECAL11x11_responseInteract_20Sig[ipt][ieta] ->Sumw2();
1495       
1496       sprintf(hname, "h_Response20Sig_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1497       sprintf(htit,  "(eHCAL3x3+eECAL9x9)(Xtal>2.0#sigma)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1498       h_eHCAL3x3_eECAL9x9_response_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1499       h_eHCAL3x3_eECAL9x9_response_20Sig[ipt][ieta] ->Sumw2();
1500       sprintf(hname, "h_ResponseMIP20Sig_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1501       sprintf(htit,  "(eHCAL3x3MIP+eECAL9x9)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1502       h_eHCAL3x3_eECAL9x9_responseMIP_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1503       h_eHCAL3x3_eECAL9x9_responseMIP_20Sig[ipt][ieta] ->Sumw2();
1504       sprintf(hname, "h_ResponseInteract20Sig_eHCAL3x3_eECAL9x9_ptBin%i_etaBin%i", ipt, ieta);
1505       sprintf(htit,  "(eHCAL3x3Interact+eECAL9x9)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1506       h_eHCAL3x3_eECAL9x9_responseInteract_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1507       h_eHCAL3x3_eECAL9x9_responseInteract_20Sig[ipt][ieta] ->Sumw2();
1508 
1509       sprintf(hname, "h_Response20Sig_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1510       sprintf(htit,  "(eHCAL3x3+eECAL7x7)(Xtal>2.0#sigma)/trkP (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1511       h_eHCAL3x3_eECAL7x7_response_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1512       h_eHCAL3x3_eECAL7x7_response_20Sig[ipt][ieta] ->Sumw2();
1513       sprintf(hname, "h_ResponseMIP20Sig_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1514       sprintf(htit,  "(eHCAL3x3MIP+eECAL7x7)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1515       h_eHCAL3x3_eECAL7x7_responseMIP_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1516       h_eHCAL3x3_eECAL7x7_responseMIP_20Sig[ipt][ieta] ->Sumw2();
1517       sprintf(hname, "h_ResponseInteract20Sig_eHCAL3x3_eECAL7x7_ptBin%i_etaBin%i", ipt, ieta);
1518       sprintf(htit,  "(eHCAL3x3Interact+eECAL7x7)/trkP(Xtal>2.0#sigma) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
1519       h_eHCAL3x3_eECAL7x7_responseInteract_20Sig[ipt][ieta] = new TH1F(hname, htit, 1500, -1.0, 4.0);
1520       h_eHCAL3x3_eECAL7x7_responseInteract_20Sig[ipt][ieta] ->Sumw2();
1521       
1522       d_maxNearP->cd();
1523       sprintf(hname, "h_meanTrackP_ptBin%i_etaBin%i", ipt, ieta);
1524       sprintf(htit,  "Track Momentum (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );             
1525       h_meanTrackP[ipt][ieta] = new TH1F(hname, htit, 100, lowP*0.9, highP*1.1);
1526       h_meanTrackP[ipt][ieta] ->Sumw2();
1527       
1528       d_drTrackL1->cd();
1529       sprintf(hname, "h_drTrackL1_ptBin%i_etaBin%i", ipt, ieta);
1530       sprintf(htit,  "dr(Track,L1) (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );             
1531       h_drTrackL1[ipt][ieta] = new TH1F(hname, htit, 100, -0.01, 10.0);
1532       h_drTrackL1[ipt][ieta] ->Sumw2();
1533 
1534     }
1535   }
1536 
1537   
1538   fout->cd();
1539   double hcalEtaBins[55] = {-2.650,-2.500,-2.322,-2.172,-2.043,-1.930,
1540                 -1.830,-1.740,-1.653,-1.566,-1.479,-1.392,-1.305,
1541                 -1.218,-1.131,-1.044,-0.957,-0.879,-0.783,-0.696,
1542                 -0.609,-0.522,-0.435,-0.348,-0.261,-0.174,-0.087,
1543                 0.000,
1544                 0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609,
1545                 0.696, 0.783, 0.879, 0.957, 1.044, 1.131, 1.218,
1546                 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830,
1547                 1.930, 2.043, 2.172, 2.322, 2.500, 2.650};
1548   h_HcalMeanEneVsEta = new TProfile("h_HcalMeanEneVsEta", "h_HcalMeanEneVsEta", 54, hcalEtaBins);
1549   h_HcalMeanEneVsEta->Sumw2();
1550 
1551 }