Exemplo n.º 1
0
void HHToBBGGSelection_BBHGG(const string inputfile,          // input file
                             const string outputfile,         // output directory
                             Int_t SampleType = 4,
                             Bool_t applyExtrapWeightTo140PU = kFALSE                             
  ) {
  
  //--------------------------------------------------------------------------------------------------------------
  // Settings 
  //============================================================================================================== 
  bool printdebug = false;


  //*****************************************************************************************
  //Setup
  //*****************************************************************************************
  TFile *photonEffFile = new TFile("/afs/cern.ch/work/s/sixie/public/releases/analysis/CMSSW_5_3_9_patch3/src/CMSAna/HHToBBGG/data/PhotonEfficiency_PromptPhoton.root","READ"); 
  TH2F* photonEffHist = (TH2F*)photonEffFile->Get("Efficiency_PtEta");
  photonEffHist->SetDirectory(0);
  photonEffFile->Close(); delete photonEffFile;

  TFile *btagEffFile = new TFile("/afs/cern.ch/work/s/sixie/public/releases/analysis/CMSSW_5_3_9_patch3/src/CMSAna/HHToBBGG/data/BTaggingEfficiency_BJetEfficiency.root","READ"); 
  TH2F* btagEffHist = (TH2F*)btagEffFile->Get("Efficiency_PtEta");
  btagEffHist->SetDirectory(0);
  btagEffFile->Close(); delete btagEffFile;

  //load photon response functions
  TFile *photonResponseFunctionFile = new TFile("/afs/cern.ch/work/s/sixie/public/releases/analysis/CMSSW_5_3_9_patch3/src/CMSAna/HHToBBGG/data/PhotonResolution.root","READ"); 
  vector<vector<TH1F* > > photonResponseFunctions;
  vector<double> PtBins;
  PtBins.push_back(25);
  PtBins.push_back(35);
  PtBins.push_back(45);
  PtBins.push_back(55);
  PtBins.push_back(65);
  PtBins.push_back(75);
  vector<double> EtaBins;
  EtaBins.push_back(0.0);
  EtaBins.push_back(0.25);
  EtaBins.push_back(0.50);
  EtaBins.push_back(0.75);
  EtaBins.push_back(1.00);
  EtaBins.push_back(1.25);
  EtaBins.push_back(1.50);
  EtaBins.push_back(1.75);
  EtaBins.push_back(2.00);
  EtaBins.push_back(2.25);
  for (int ipt = 0; ipt < PtBins.size(); ++ipt) {
    vector<TH1F*> tmpPhotonResponseFunctions;
    for (int ieta = 0; ieta < EtaBins.size(); ++ieta) {      
      tmpPhotonResponseFunctions.push_back( (TH1F*)photonResponseFunctionFile->Get( Form("PhotonResponseFunction_PtBin%d_EtaBin%d",ipt,ieta)));
    }
    photonResponseFunctions.push_back(tmpPhotonResponseFunctions);
  }
  //check histogram loading
  for (int ipt = 0; ipt < PtBins.size(); ++ipt) {
    for (int ieta = 0; ieta < EtaBins.size(); ++ieta) {   
      assert( photonResponseFunctions[ipt][ieta] );
    }
  }
  
  TRandom3 *MyRandom = new TRandom3( time(NULL) );


  //--------------------------------------------------------------------------------------------------------------
  // Main analysis code 
  //==============================================================================================================  
  Double_t nEvents = 0;

  
  //*****************************************************************************************
  // Set up output ntuple
  //*****************************************************************************************
  TFile *outFile = new TFile(outputfile.c_str(),"RECREATE"); 
  TH1F *NEvents =  new TH1F("NEvents",";;",1,-0.5,0.5);
  TH1F *NPUMean = new TH1F("NPUMean",";NPUMean;Number of Events", 100, -0.5, 99.5);
  cmsana::HHToBBGGEventTree *outputEventTree = new cmsana::HHToBBGGEventTree;
  outputEventTree->CreateTree();


  //*****************************************************************************************
  // Set up input
  //*****************************************************************************************
  TFile *infile=0;
  TTree *eventTree=0;
  
  // Data structures to store info from TTrees
  cmsana::TEventInfo *info  = new cmsana::TEventInfo();
  TClonesArray *genparticleArr = new TClonesArray("cmsana::TGenParticle");
  TClonesArray *genjetArr = new TClonesArray("cmsana::TGenJet");

  // Read input file and get the TTrees
  cout << "Processing " << inputfile << "..." << endl;
  infile = TFile::Open(inputfile.c_str(),"read");
  assert(infile);

    
  eventTree = (TTree*)infile->Get("Events"); assert(eventTree);  
  eventTree->SetBranchAddress("Info",     &info);        TBranch *infoBr     = eventTree->GetBranch("Info");
  eventTree->SetBranchAddress("GenParticle", &genparticleArr); TBranch *genparticleBr = eventTree->GetBranch("GenParticle");
  eventTree->SetBranchAddress("GenJet", &genjetArr); TBranch *genjetBr = eventTree->GetBranch("GenJet");
  cout << "NEvents = " << eventTree->GetEntries() << endl;

  
  //Double_t weight = 1;

  // null vector for default four vectors
  cmsana::FourVector null(0.0,0.0,0.0,0.0);

  // loop over events
  for(UInt_t ientry=0; ientry<eventTree->GetEntries(); ientry++) {
    printdebug = false;
    if (ientry % 1000 == 0) cout << "Processed Event " << ientry << endl;
    infoBr->GetEntry(ientry);

    NEvents->Fill(0);
    NPUMean->Fill(info->nPUMean);

    //***********************************************************
    // Definition of Pileup Energy density
    //***********************************************************
    Double_t rho = info->RhoKt6PFJets;

    genparticleArr->Clear(); 
    genjetArr->Clear(); 
    genparticleBr->GetEntry(ientry);
    genjetBr->GetEntry(ientry);

    //***********************************************************
    // Find Gen-Level particles
    //***********************************************************
    const cmsana::TGenParticle *genPhoton1 = 0;
    const cmsana::TGenParticle *genPhoton2 = 0;
    const cmsana::TGenParticle *genB1 = 0;
    const cmsana::TGenParticle *genB2 = 0;
    const cmsana::TGenJet *genBJet1 = 0;
    const cmsana::TGenJet *genBJet2 = 0;
    int NBGenJets = 0;
    int NNonBGenJets = 0;
    int NBJets = 0;

    
    //***********************************************************
    // Find B Partons
    //***********************************************************    
    for(Int_t i=0; i<genparticleArr->GetEntriesFast(); i++) {
      const cmsana::TGenParticle *p = (cmsana::TGenParticle*)((*genparticleArr)[i]);

      if (abs(p->pdgid) == 5 && p->status == 3 && ( ( abs(p->motherPdgID) >= 1 && abs(p->motherPdgID) <= 5 ) || abs(p->motherPdgID) == 21) ) {
        if (!genB1) {
          genB1 = p;
        } else {
          if (!genB2 && ( p->pdgid != genB1->pdgid || cmsana::deltaR(genB1->eta,genB1->phi,p->eta,p->phi) > 0.5) ) genB2 = p;
        }
      }
    }
    

    //***********************************************************
    // Find B Gen-Jets
    //***********************************************************    
    for(Int_t i=0; i<genjetArr->GetEntriesFast(); i++) {
      const cmsana::TGenJet *genjet = (cmsana::TGenJet*)((*genjetArr)[i]);  
      if (!(genjet->pt > 30)) continue;

      if (abs(genjet->matchedPdgId) == 5) {
        NBGenJets++;
        if (abs(genjet->eta) < 2.4) {
          if(!genBJet1) genBJet1 = genjet;
          else if (!genBJet2) genBJet2 = genjet;
        }
      } else {
        NNonBGenJets++;
      }
    }

    //***********************************************************
    //Filter for events with 2 b genjets
    //***********************************************************
    if ( NBGenJets < 2 ) {
      continue;
    }



    //***********************************************************
    // Find Gen Photons
    //***********************************************************    
    for(Int_t i=0; i<genparticleArr->GetEntriesFast(); i++) {
      const cmsana::TGenParticle *p = (cmsana::TGenParticle*)((*genparticleArr)[i]);
      if ( SampleType == cmsana::HHToBBGGEventTree::bbHgg) {
        if (p->pdgid == 22 && ( p->motherPdgID == 25 ) && p->status == 3 ) {
          if (!genPhoton1) {
            genPhoton1 = p;
          } else if (!genPhoton2) {
            genPhoton2 = p;
          }
        }
      }
    }
    
    //***********************************************************
    // Count Jets
    //***********************************************************    
    int NJets = 0;
    int NCentralJets = 0;
    double jetSumPt = 0;
    for(Int_t i=0; i<genjetArr->GetEntriesFast(); i++) {
      const cmsana::TGenJet *genjet = (cmsana::TGenJet*)((*genjetArr)[i]);  
      if (!(genjet->pt > 30)) continue;

      //Si Note: need to implement jet efficiency too
      if (abs(genjet->eta) < 5.0) {
        jetSumPt += genjet->pt;
        NJets++;
        if (abs(genjet->eta) < 2.5) {
          NCentralJets++;
        }
      }

    }



    //sampleType
    cmsana::HHToBBGGEventTree::SampleType stype = cmsana::HHToBBGGEventTree::none;
    if (SampleType == 4) stype = cmsana::HHToBBGGEventTree::bbHgg;
    else {
      cout << "Warning: sample type not diphoton jets. Unintended use of this macro. \n";
    }

    outputEventTree->sampletype = stype;
    outputEventTree->run = info->runNum;
    outputEventTree->lumi = info->lumiSec;
    outputEventTree->event = info->evtNum;
    outputEventTree->npu = info->nPU;
    outputEventTree->rho = info->RhoKt6PFJets;
    outputEventTree->nvtx = info->nGoodPV;
    
    cmsana::FourVectorM genpho1v;
    cmsana::FourVectorM genpho2v;
    outputEventTree->genpho1 = null;
    outputEventTree->genpho2 = null;
    if (genPhoton1) {
      genpho1v.SetPt(genPhoton1->pt);
      genpho1v.SetEta(genPhoton1->eta);
      genpho1v.SetPhi(genPhoton1->phi);
      genpho1v.SetM(0);
      outputEventTree->genpho1 = genpho1v;
    }
    if (genPhoton2) {
      genpho2v.SetPt(genPhoton2->pt);
      genpho2v.SetEta(genPhoton2->eta);
      genpho2v.SetPhi(genPhoton2->phi);
      genpho2v.SetM(0);   
      outputEventTree->genpho2 = genpho2v;    
    }
    
    cmsana::FourVectorM genb1v;
    cmsana::FourVectorM genb2v;
    outputEventTree->genb1 = null;
    outputEventTree->genb2 = null;
    if (genB1) {
      genb1v.SetPt(genB1->pt);
      genb1v.SetEta(genB1->eta);
      genb1v.SetPhi(genB1->phi);
      genb1v.SetM(0);
      outputEventTree->genb1 = genb1v;
    }
    if (genB2) {
      genb2v.SetPt(genB2->pt);
      genb2v.SetEta(genB2->eta);
      genb2v.SetPhi(genB2->phi);
      genb2v.SetM(0);   
      outputEventTree->genb2 = genb2v;
    }

    cmsana::FourVectorM genbjet1v;
    cmsana::FourVectorM genbjet2v;
    outputEventTree->genbjet1 = null;    
    outputEventTree->genbjet2 = null;    
    if (genBJet1) {
      genbjet1v.SetPt(genBJet1->pt);
      genbjet1v.SetEta(genBJet1->eta);
      genbjet1v.SetPhi(genBJet1->phi);
      genbjet1v.SetM(genBJet1->mass);
      outputEventTree->genbjet1 = genbjet1v;
    }
    if (genBJet2) {
      genbjet2v.SetPt(genBJet2->pt);
      genbjet2v.SetEta(genBJet2->eta);
      genbjet2v.SetPhi(genBJet2->phi);
      genbjet2v.SetM(genBJet2->mass);   
      outputEventTree->genbjet2 = genbjet2v;    
    }


    //********************************************************
    //Select photons
    //********************************************************
    cmsana::FourVectorM photon1v;
    cmsana::FourVectorM photon2v;
    cmsana::FourVectorM diphotonv;
    double pho1eff = 0;
    double pho2eff = 0;
    outputEventTree->pho1 = null;      //default 4-vector
    outputEventTree->pho2 = null;
    outputEventTree->diphoton = null;    

    if (genPhoton1) {      
      photon1v.SetPt(GetSmearedPhotonPt( genPhoton1->pt, genPhoton1->eta, PtBins, EtaBins, photonResponseFunctions ) );
      photon1v.SetEta(genPhoton1->eta);
      photon1v.SetPhi(genPhoton1->phi);
      photon1v.SetM(0);
      outputEventTree->pho1 = photon1v;
      pho1eff = photonEffHist->GetBinContent( 
        photonEffHist->GetXaxis()->FindFixBin( fmax( fmin( genPhoton1->pt, 99.9), 0.01) ),
        photonEffHist->GetYaxis()->FindFixBin( fmax( fmin (genPhoton1->eta, 2.99), -2.99))
        );
      
      if (pho1eff > 1) {
        cout << "ERROR: " << genPhoton1->pt << " " << genPhoton1->eta << " | " << photonEffHist->GetXaxis()->FindFixBin( genPhoton1->pt) << " " << photonEffHist->GetYaxis()->FindFixBin( genPhoton1->eta) << " | " << pho1eff << "\n";
      }

    } 

    if (genPhoton2) {
      photon2v.SetPt(GetSmearedPhotonPt( genPhoton2->pt, genPhoton2->eta, PtBins, EtaBins, photonResponseFunctions ));
      photon2v.SetEta(genPhoton2->eta);
      photon2v.SetPhi(genPhoton2->phi);
      photon2v.SetM(0);
      outputEventTree->pho2 = photon2v;
      pho2eff = photonEffHist->GetBinContent( 
        photonEffHist->GetXaxis()->FindFixBin( fmax( fmin( genPhoton2->pt, 99.9), 0.01) ),
        photonEffHist->GetYaxis()->FindFixBin( fmax( fmin (genPhoton2->eta, 2.99), -2.99))
        );
    }
    
    if (genPhoton1 && genPhoton2) {
      diphotonv = photon1v + photon2v;
      outputEventTree->diphoton = diphotonv;
    }
   

    //********************************************************
    //Select b-jets
    //********************************************************
    cmsana::FourVectorM bjet1v;
    cmsana::FourVectorM bjet2v;
    cmsana::FourVectorM dibjetv;
    double bjet1eff = 0;
    double bjet2eff = 0;
    outputEventTree->bjet1 = null;      //default 4-vector
    outputEventTree->bjet2 = null;
    outputEventTree->dibjet = null;    

    if (genBJet1) {
      bjet1v.SetPt(genBJet1->pt);
      bjet1v.SetEta(genBJet1->eta);
      bjet1v.SetPhi(genBJet1->phi);
      bjet1v.SetM(genBJet1->mass);
      bjet1eff = btagEffHist->GetBinContent( 
        btagEffHist->GetXaxis()->FindFixBin( fmax( fmin( genBJet1->pt, 199.9), 0.01) ),
        btagEffHist->GetYaxis()->FindFixBin( fmax( fmin (genBJet1->eta, 2.49), -2.49))
        );
      outputEventTree->bjet1 = bjet1v;
    } else {

    }

    if (genBJet2) {
      bjet2v.SetPt(genBJet2->pt);
      bjet2v.SetEta(genBJet2->eta);
      bjet2v.SetPhi(genBJet2->phi);
      bjet2v.SetM(genBJet2->mass);
      bjet2eff = btagEffHist->GetBinContent( 
        btagEffHist->GetXaxis()->FindFixBin( fmax( fmin( genBJet2->pt, 199.9), 0.01) ),
        btagEffHist->GetYaxis()->FindFixBin( fmax( fmin (genBJet2->eta, 2.49), -2.49))
        );
      outputEventTree->bjet2 = bjet2v;
    }

    if (genBJet1 && genBJet2) {
      dibjetv = bjet1v + bjet2v;
      outputEventTree->dibjet = dibjetv;
    }


    //********************************************************
    //implement efficiency weights
    //********************************************************    
    outputEventTree->weight = pho1eff*pho2eff*bjet1eff*bjet2eff;

    //********************************************************
    //bbgg system
    //********************************************************    
    cmsana::FourVectorM bbggSystemv;
    outputEventTree->bbgg = null;
    if (genBJet1 && genBJet2 && genPhoton1 && genPhoton2) {
      bbggSystemv = (photon1v + photon2v + bjet1v + bjet2v);
      outputEventTree->bbgg = bbggSystemv;
    }



    //********************************************************
    //NJets
    //********************************************************    
    outputEventTree->njets = NJets;
    outputEventTree->ncentraljets = NCentralJets;

    outputEventTree->nlep = 0;

    //********************************************************
    //Some kinematic variables
    //********************************************************
    outputEventTree->DRgg = -1;
    outputEventTree->DRbb = -1;
    outputEventTree->minDRgb = -1;
    if (genBJet1 && genBJet2 && genPhoton1 && genPhoton2) {
      outputEventTree->DRgg = cmsana::deltaR(genPhoton1->eta, genPhoton1->phi, genPhoton2->eta, genPhoton2->phi);
      outputEventTree->DRbb = cmsana::deltaR(genBJet1->eta, genBJet1->phi, genBJet2->eta, genBJet2->phi);
      outputEventTree->minDRgb = fmin(fmin(fmin( cmsana::deltaR(genPhoton1->eta, genPhoton1->phi, genBJet1->eta, genBJet1->phi), 
                                                 cmsana::deltaR(genPhoton1->eta, genPhoton1->phi, genBJet2->eta, genBJet2->phi)),
                                           cmsana::deltaR(genPhoton2->eta, genPhoton2->phi, genBJet1->eta, genBJet1->phi)),
                                      cmsana::deltaR(genPhoton2->eta, genPhoton2->phi, genBJet2->eta, genBJet2->phi));      
    }

    outputEventTree->pfmet = sqrt( info->pfMEx*info->pfMEx + info->pfMEy*info->pfMEy);
    outputEventTree->pfTrackMET = sqrt( info->pfTrackMEx*info->pfTrackMEx + info->pfTrackMEy*info->pfTrackMEy);
    
    outputEventTree->HT = jetSumPt;
    if (genPhoton1) outputEventTree->HT += genPhoton1->pt;
    if (genPhoton2) outputEventTree->HT += genPhoton2->pt;
    

    //************************************
    //Extrapolation to 140 Pileup
    //************************************
    double pho1EffScalingForPU140 = 1.0;
    double pho2EffScalingForPU140 = 1.0;
    double bjet1EffScalingForPU140 = 1.0;
    double bjet2EffScalingForPU140 = 1.0;
    pho1EffScalingForPU140 = (0.85/0.95)*(0.85/0.95);
    pho2EffScalingForPU140 = (0.85/0.95)*(0.85/0.95);
    bjet1EffScalingForPU140 = (0.55/0.65);
    bjet2EffScalingForPU140 = (0.55/0.65);
    if (applyExtrapWeightTo140PU) {
      outputEventTree->weight = outputEventTree->weight * pho1EffScalingForPU140*pho2EffScalingForPU140*bjet1EffScalingForPU140*bjet2EffScalingForPU140;
    }




    //********************************************************
    //Fill Output Tree
    //********************************************************
    outputEventTree->tree_->Fill();
    nEvents++;


    //********************************************************
    //Debug
    //********************************************************    
    if (printdebug) {
      cout << "\n\nDebug Event: " << info->runNum << " " << info->lumiSec << " " << info->evtNum << "\n";
      if (genB1) cout << "GenB1: " << genB1->pt << " " << genB1->eta << " " << genB1->phi << "\n";
      if (genB2) cout << "GenB2: " << genB2->pt << " " << genB2->eta << " " << genB2->phi << "\n";
      if (genPhoton1) cout << "GenPho1: " << genPhoton1->pt << " " << genPhoton1->eta << " " << genPhoton1->phi << "\n";
      if (genPhoton2) cout << "GenPho2: " << genPhoton2->pt << " " << genPhoton2->eta << " " << genPhoton2->phi << "\n";
      cout << "NBGenJets = " << NBGenJets << "\n";

      for(Int_t i=0; i<genparticleArr->GetEntriesFast(); i++) {
        const cmsana::TGenParticle *p = (cmsana::TGenParticle*)((*genparticleArr)[i]);
        if ( (abs(p->pdgid) == 5 && p->pt > 0)
            || 
            ( p->pdgid == 22 && p->status==3 && ( p->motherPdgID == 21 || (abs(p->motherPdgID) >= 1 && abs(p->motherPdgID) <= 6) ) )
          ) {
          cout << p->pdgid << " " << p->status << " " << p->pt << " " << p->eta << " " << p->phi 
               << " | " << p->motherPdgID << "\n";
        }
      }

      for(Int_t i=0; i<genjetArr->GetEntriesFast(); i++) {
        const cmsana::TGenJet *genjet = (cmsana::TGenJet*)((*genjetArr)[i]);
        
        bool isStablePhoton = false;
        bool isTruthB = false;
        for(Int_t j=0; j<genparticleArr->GetEntriesFast(); j++) {
          const cmsana::TGenParticle *p = (cmsana::TGenParticle*)((*genparticleArr)[j]);

          if (p->pdgid == 22 && ( p->motherPdgID == 21 || (abs(p->motherPdgID) >= 1 && abs(p->motherPdgID) <= 6) ) 
              && cmsana::deltaR(p->eta,p->phi,genjet->eta,genjet->phi) < 0.5
            ) {
            //genjet matches to a stable photon. don't consider these
            isStablePhoton = true;
            break;
          }
        }

        if (abs(genjet->matchedPdgId) == 5) isTruthB = true;

        cout << "genjet " << i << " : " << genjet->pt << " " << genjet->eta << " " << genjet->phi << " " << genjet->mass << " | ";
        if (isStablePhoton) cout << " matched photon";
        if (isTruthB) cout << " matched b";
        cout << "\n";

      }
      
 
      cout << "All Gen Particles\n";
      for(Int_t i=0; i<genparticleArr->GetEntriesFast(); i++) {
        const cmsana::TGenParticle *p = (cmsana::TGenParticle*)((*genparticleArr)[i]);
        cout << p->pdgid << " " << p->status << " " << p->pt << " " << p->eta << " " << p->phi 
             << " | " << p->motherPdgID << "\n";
      }
      cout << "\n\n";

    }
    //********************************************************
    //End Debug
    //********************************************************



    //********************************************************
    //Clean up Memory
    //********************************************************

  }

  delete infile;
  infile=0, eventTree=0;      
  delete info;
  delete genparticleArr;
  delete genjetArr;
  
     
  //--------------------------------------------------------------------------------------------------------------
  // Output
  //==============================================================================================================
   
  
  outFile->Write();
  outFile->Close();
  delete outFile;
  
  cout << " Number of events selected: " << nEvents << endl;
  cout << endl;
  cout << "  <> Output saved in " << outputfile << endl;    
  cout << endl;  
      

}
int main (int argc, char **argv)
{
  /// Mc Ntuplas
  TString input = Form("/data1/rgerosa/NTUPLES_FINAL_CALIB/MC/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_All.root"); 
  /// MC Calibration result E/p
  TString input2 = Form("/data1/rgerosa/L3_Weight/MC_WJets/EB_Z_recoFlag/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_Z_noEP.root"); 

  TApplication* theApp = new TApplication("Application",&argc, argv);

  TFile *f = new TFile(input,"");
  TTree *inputTree = (TTree*)f->Get("ntu");

  TFile *f2 = new TFile(input2,"");
  TH2F *h_scale_EB = (TH2F*)f2->Get("h_scale_EB");
  TH2F *hcmap = (TH2F*) h_scale_EB->Clone("hcmap");
  
  hcmap -> Reset("ICEMS");
  hcmap -> ResetStats();
  
  /// Taking infos

  std::vector<float>* ele1_recHit_E=0;
  std::vector<float>* ele2_recHit_E=0;
  std::vector<int>* ele1_recHit_hashedIndex=0;
  std::vector<int>* ele2_recHit_hashedIndex=0;
  std::vector<int>* ele1_recHit_flag=0;
  std::vector<int>* ele2_recHit_flag=0;
  float ele1_E_true,ele2_E_true;
  float ele1_tkP,ele2_tkP;
  int ele1_isEB, ele2_isEB;
  float   ele1_fbrem,ele2_fbrem;
  int isW, isZ;
  
  inputTree->SetBranchAddress("ele1_recHit_E", &ele1_recHit_E);
  inputTree->SetBranchAddress("ele2_recHit_E", &ele2_recHit_E);
  inputTree->SetBranchAddress("ele1_recHit_hashedIndex", &ele1_recHit_hashedIndex);
  inputTree->SetBranchAddress("ele2_recHit_hashedIndex", &ele2_recHit_hashedIndex);
  inputTree->SetBranchAddress("ele1_recHit_flag", &ele1_recHit_flag);
  inputTree->SetBranchAddress("ele2_recHit_flag", &ele2_recHit_flag);
  inputTree->SetBranchAddress("ele1_E_true", &ele1_E_true);
  inputTree->SetBranchAddress("ele2_E_true", &ele2_E_true);
  inputTree->SetBranchAddress("ele1_tkP", &ele1_tkP);
  inputTree->SetBranchAddress("ele2_tkP", &ele2_tkP);
  inputTree->SetBranchAddress("ele1_isEB", &ele1_isEB);
  inputTree->SetBranchAddress("ele2_isEB", &ele2_isEB);
  inputTree->SetBranchAddress("ele1_fbrem", &ele1_fbrem);
  inputTree->SetBranchAddress("ele2_fbrem", &ele2_fbrem);
  inputTree->SetBranchAddress("isW", &isW);
  inputTree->SetBranchAddress("isZ", &isZ);
 
  TProfile2D* mapMomentum = new TProfile2D("mapMomentum","mapMomentum",360,0,360,170,-85,85);
  TProfile2D* mapfbrem = new TProfile2D("mapfbrem","mapfbrem",360,0,360,170,-85,85);

  /// Make fbrem and p/ptrue map cycling on MC --> all the events 

  for(Long64_t i=0; i< inputTree->GetEntries(); i++)
  {
   inputTree->GetEntry(i);
   if (!(i%100000))std::cerr<<i;
   if (!(i%10000)) std::cerr<<".";
       
   if (ele1_isEB == 1 && (isW==1 || isZ==1)) {
  
      double E_seed=0;
      int seed_hashedIndex, iseed;

      for (unsigned int iRecHit = 0; iRecHit < ele1_recHit_E->size(); iRecHit++ ) {
            
            if(ele1_recHit_E -> at(iRecHit) > E_seed &&  ele1_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good
            {
              seed_hashedIndex=ele1_recHit_hashedIndex -> at(iRecHit);
              iseed=iRecHit;
              E_seed=ele1_recHit_E -> at(iRecHit);  ///! Seed search

            }
      }
    
   int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex);
   int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex);
   if(ele1_tkP>0 && ele1_E_true>0 && abs(ele1_tkP/ele1_E_true)<2. && abs(ele1_tkP/ele1_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele1_tkP/ele1_E_true));
   mapfbrem->Fill(phi_seed,eta_seed,abs(ele1_fbrem)); 
   }
   
   if (ele2_isEB == 1 && isZ==1) {

      double E_seed=0;
      int seed_hashedIndex, iseed;

      for (unsigned int iRecHit = 0; iRecHit < ele2_recHit_E->size(); iRecHit++ ) {
            
            if(ele2_recHit_E -> at(iRecHit) > E_seed &&  ele2_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good
            {
              seed_hashedIndex=ele2_recHit_hashedIndex -> at(iRecHit);
              iseed=iRecHit;
              E_seed=ele2_recHit_E -> at(iRecHit);  ///! Seed search

            }
      }
    
   int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex);
   int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex);
   if(ele2_tkP>0 && ele2_E_true>0 && abs(ele2_tkP/ele2_E_true)<2. && abs(ele2_tkP/ele2_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele2_tkP/ele2_E_true));
   mapfbrem->Fill(phi_seed,eta_seed,abs(ele2_fbrem));

   }
 }

 /// Map of IC normalized in eta rings

 std::vector< std::pair<int,int> > TT_centre ;
 
 TT_centre.push_back(std::pair<int,int> (58,49));
 TT_centre.push_back(std::pair<int,int> (53,109));
 TT_centre.push_back(std::pair<int,int> (8,114));
 TT_centre.push_back(std::pair<int,int> (83,169));
 TT_centre.push_back(std::pair<int,int> (53,174));
 TT_centre.push_back(std::pair<int,int> (63,194));
 TT_centre.push_back(std::pair<int,int> (83,224));
 TT_centre.push_back(std::pair<int,int> (73,344));
 TT_centre.push_back(std::pair<int,int> (83,358));
 TT_centre.push_back(std::pair<int,int> (-13,18));
 TT_centre.push_back(std::pair<int,int> (-18,23));
 TT_centre.push_back(std::pair<int,int> (-8,53));
 TT_centre.push_back(std::pair<int,int> (-3,63));
 TT_centre.push_back(std::pair<int,int> (-53,128));
 TT_centre.push_back(std::pair<int,int> (-53,183));
 TT_centre.push_back(std::pair<int,int> (-83,193));
 TT_centre.push_back(std::pair<int,int> (-74,218));
 TT_centre.push_back(std::pair<int,int> (-8,223));
 TT_centre.push_back(std::pair<int,int> (-68,303));
 TT_centre.push_back(std::pair<int,int> (-43,328));
 
 /// Mean over phi corrected skipping dead channel 

 for (int iEta = 1 ; iEta < h_scale_EB->GetNbinsY()+1; iEta ++)
 {
   float SumIC = 0;
   int numIC = 0;
   
   for(int iPhi = 1 ; iPhi < h_scale_EB->GetNbinsX()+1 ; iPhi++)
   {
    bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta);
    bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre);
 
     if(isGood && isGoodTT)
     {
      SumIC = SumIC + h_scale_EB->GetBinContent(iPhi,iEta);
      numIC ++ ;
     }
    }
   //fede: skip bad channels and bad TTs
   for (int iPhi = 1; iPhi< h_scale_EB->GetNbinsX()+1  ; iPhi++)
   { 
     if(numIC==0 || SumIC==0) continue;

     bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta);
     bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre);
     if (!isGood || !isGoodTT) continue;

     hcmap->SetBinContent(iPhi,iEta,h_scale_EB->GetBinContent(iPhi,iEta)/(SumIC/numIC));
   }
  }

 /// ratio map

 TH2F* ratioMap = (TH2F*) hcmap -> Clone("ratioMap");
 ratioMap->Reset();

 for( int i =0 ; i<hcmap->GetNbinsX() ; i++){
  for( int j=0; j<hcmap->GetNbinsY() ; j++){
   if(hcmap->GetBinContent(i,j)!=0 && mapMomentum->GetBinContent(i,j)!=0)
    ratioMap->SetBinContent(i+1,j+1,mapMomentum->GetBinContent(i,j)/hcmap->GetBinContent(i,j));
  }
 }

 /// Profile along phi taking into account dead channels
 TGraphErrors *coeffEBp = new TGraphErrors();
 TGraphErrors *coeffEBm = new TGraphErrors();

 for (int iPhi =1; iPhi< hcmap->GetNbinsX()+1 ; iPhi++){
  double SumEBp =0, SumEBm=0;
  double iEBp=0, iEBm=0;
  for(int iEta = 1; iEta<hcmap->GetNbinsY()+1 ; iEta++){
     if(hcmap->GetBinContent(iPhi,iEta)==0)continue;
     if(iEta>85) {SumEBp=SumEBp+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta);
                  iEBp++;}
     else{ SumEBm=SumEBm+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta);
           iEBm++;}
     }
  coeffEBp->SetPoint(iPhi-1,iPhi-1,SumEBp/iEBp);
  coeffEBm->SetPoint(iPhi-1,iPhi-1,SumEBm/iEBm);

  }
     
 TFile* outputGraph = new TFile("output/GraphFor_P_Correction.root","RECREATE");
 outputGraph->cd();

 coeffEBp->Write("coeffEBp");
 coeffEBm->Write("coeffEBm");
 outputGraph->Close();
     
 gROOT->Reset();
 gROOT->SetStyle("Plain");

 gStyle->SetPadTickX(1);
 gStyle->SetPadTickY(1);
 gStyle->SetOptTitle(1); 
 gStyle->SetOptStat(0); 
 gStyle->SetOptFit(0); 
 gStyle->SetFitFormat("6.3g"); 
 gStyle->SetPalette(1); 
  
 gStyle->SetTextFont(42);
 gStyle->SetTextSize(0.05);
 gStyle->SetTitleFont(42,"xyz");
 gStyle->SetTitleSize(0.05);
 gStyle->SetLabelFont(42,"xyz");
 gStyle->SetLabelSize(0.05);
 gStyle->SetTitleXOffset(0.8);
 gStyle->SetTitleYOffset(1.1);
 gROOT->ForceStyle();
 
 TCanvas* c1 = new TCanvas("mapMomentum","mapMomentum",1);
 c1->cd();
 mapMomentum->GetXaxis()->SetTitle("#phi");
 mapMomentum->GetXaxis()->SetNdivisions(20);
 c1->SetGridx(); 
 mapMomentum->GetYaxis()->SetTitle("#eta");
 mapMomentum->GetZaxis()->SetRangeUser(0.7,1.3);
 mapMomentum->Draw("colz");

 TCanvas* c2 = new TCanvas("mapfbrem","mapfbrem",1);
 c2->cd();
 mapfbrem->GetXaxis()->SetTitle("#phi");
 mapfbrem->GetYaxis()->SetTitle("#eta");
 mapfbrem->GetXaxis()->SetNdivisions(20);
 c2->SetGridx(); 
 mapfbrem->GetZaxis()->SetRangeUser(0.,0.7);
 mapfbrem->Draw("colz");

 TCanvas* c3 = new TCanvas("ratioMap","ratioMap",1);
 c3->cd();
 ratioMap->GetXaxis()->SetTitle("#phi");
 ratioMap->GetYaxis()->SetTitle("#eta");
 ratioMap->GetXaxis()->SetNdivisions(20);
 c3->SetGridx(); 
 ratioMap->GetZaxis()->SetRangeUser(0.7,1.3);
 ratioMap->Draw("colz");

 TCanvas* c4 = new TCanvas("coeffEB","coeffEB",1);
 c4->cd();
 coeffEBp->GetXaxis()->SetTitle("#phi");
 coeffEBp->GetYaxis()->SetTitle("p/p_{true}");
 coeffEBp -> SetMarkerStyle(20);
 coeffEBp -> SetMarkerSize(1);
 coeffEBp -> SetMarkerColor(kRed+1); 
 coeffEBp -> SetLineColor(kRed+1); 
 c4->SetGridx(); 
 c4->SetGridy(); 
 ratioMap->Draw("ap");

 coeffEBm->GetXaxis()->SetTitle("#phi");
 coeffEBm->GetYaxis()->SetTitle("p/p_{true}");
 coeffEBm -> SetMarkerStyle(20);
 coeffEBm -> SetMarkerSize(1);
 coeffEBm -> SetMarkerColor(kBlue+1); 
 coeffEBm -> SetLineColor(kBlue+1); 
 coeffEBm->Draw("ap same");


 theApp->Run();
 return 0;
}
Exemplo n.º 3
0
Arquivo: getResV.C Projeto: XuQiao/HI
void getResv(int ispt){

	double theta[ntheta];
	TFile *f[nFileAll];
		
	for(int itheta=0;itheta<ntheta;itheta++)
        	theta[itheta]=itheta*TMath::Pi()/ntheta/nn;
        
        int nvv;
        const double *binv;
        if(ispt){             nvv = nptv;       binv = ptbinv;}
            else{             nvv = netav;          binv = etabinv;}

	string SumorProd = getenv("SUMORPROD");
	ofstream fstrv;
        if(ispt){
	if(SumorProd=="Sum")fstrv.open("v.txt");
	else fstrv.open("v_2.txt");
        }
        else{
	if(SumorProd=="Sum")fstrv.open("v_finer_eta.txt");
	else fstrv.open("v_2_finer_eta.txt");
        }
	TVectorD totmult[nbin],totpt[nbin], toteta[nbin];    
        TVectorD Nevent, totmultall, tottrkall,totmultall_, totmultallcorr;
	TVectorD V_int, V_interr;
	TVectorD* V_mean;
	TVectorD* deltaV_mean;
	TVectorD* V[nbin]; TVectorD* chi;
	TVectorD V_intcorr, V_intcorrerr;
	TVectorD totmulthisto_f[nbin][netav];
	TVectorD totmulthisto[nbin], totmulthistocorr[nbin];
	TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin];
	TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta];
	TComplex dD[nbin][ntheta], dN[nbin][ntheta][nvv];
	TVectorD avgmult[nbin];	TVectorD avgmultall;
	TVectorD avgtrk[nbin];	TVectorD avgtrkall;
	TVectorD avgpt[nbin], avgeta[nbin];
	TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin];
	if(SumorProd=="Sum")	TFile *infile = TFile::Open("mergedV_Sum.root");
	else	TFile *infile = TFile::Open("mergedV_Prod.root");
	Nevent.ResizeTo(nbin);	Nevent.Zero();
	totmultall.ResizeTo(nbin);	totmultall.Zero();
	tottrkall.ResizeTo(nbin);	tottrkall.Zero();
	totmultall_.ResizeTo(nbin);	totmultall_.Zero();
	totmultallcorr.ResizeTo(nbin);	totmultallcorr.Zero();
	avgmultall.ResizeTo(nbin);
	avgtrkall.ResizeTo(nbin);
	V_int.ResizeTo(nbin);	V_int.Zero();
	V_interr.ResizeTo(nbin);	V_interr.Zero();
        if(ispt){
	V_intcorr.ResizeTo(nbin);	V_intcorr.Zero();
	V_intcorrerr.ResizeTo(nbin);	V_intcorrerr.Zero();
        }
	for(int ibin=0;ibin<nbin;ibin++){
		totmult[ibin].ResizeTo(nvv);	totmult[ibin].Zero();
                if(ispt){
                    for(int ietabin=0;ietabin<netav;ietabin++){
		totmulthisto_f[ibin][ietabin].ResizeTo(nvv);	
		totmulthisto_f[ibin][ietabin].Zero();
                    }
		totmulthisto[ibin].ResizeTo(nvv);
		totmulthisto[ibin].Zero();
		totmulthistocorr[ibin].ResizeTo(nvv);
		totmulthistocorr[ibin].Zero();
                }
		avgmult[ibin].ResizeTo(nvv);	avgpt[ibin].ResizeTo(nvv);  avgeta[ibin].ResizeTo(nvv);
		totpt[ibin].ResizeTo(nvv);	totpt[ibin].Zero(); 
                toteta[ibin].ResizeTo(nvv);     toteta[ibin].Zero();
		vmean[ibin].ResizeTo(nvv);	deltavmean[ibin].ResizeTo(nvv);
		V[ibin] = (TVectorD*) infile->Get(Form("D_%d/V",ibin));
		chi = (TVectorD*) infile->Get(Form("chi"));
		V_mean = (TVectorD*) infile->Get(Form("Vmean"));
		deltaV_mean = (TVectorD*) infile->Get(Form("deltaVmean"));
		for(int itheta=0;itheta<ntheta;itheta++){
			v[ibin][itheta].ResizeTo(nvv);	deltav[ibin][itheta].ResizeTo(nvv);
			dD[ibin][itheta]=0;
			for(int ivbin=0;ivbin<nvv;ivbin++){
				dN[ibin][itheta][ivbin]=0;
			}
		}
	}
        
        for(int ifile=0; ifile<nFileAll; ifile++){
            if(ispt){
	        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/Anav_Prod_%d.root",ifile));
	        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/Anav_Prod2_%d.root",ifile));
            }
            else{
	        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/finereta/Anaveta_Prod_%d.root",ifile));
	        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/PbPb2011MB/finereta/Anaveta_Prod2_%d.root",ifile));
            }
		TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent");	
		TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall");
		TVectorD* tottrkall_t = (TVectorD*)f[ifile]->Get("tottrk");
		for(int ibin=0;ibin<nbin;ibin++){
			TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin));
			TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin));
			TVectorD* toteta_t = (TVectorD*)f[ifile]->Get(Form("toteta_%d",ibin));
			dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin));
			dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin));
			Nevent[ibin]+=(*Nevent_t)[ibin];
			totmultall[ibin]+=(*totmultall_t)[ibin];
			tottrkall[ibin]+=(*tottrkall_t)[ibin];
			for(int ivbin=0;ivbin<nvv;ivbin++){
				totmult[ibin][ivbin]+=(*totmult_t)[ivbin];
				totpt[ibin][ivbin]+=(*totpt_t)[ivbin];
				toteta[ibin][ivbin]+=(*toteta_t)[ivbin];
			}
			for(int itheta=0;itheta<ntheta;itheta++){
				dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta));
				dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta));
				dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]);
				for(int ivbin=0;ivbin<nvv;ivbin++)
					dN[ibin][itheta][ivbin]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]);
			}
		}
	f[ifile]->Close();
	}
	
        double eff[netav];
        if(ispt){
	TH2F* hetapt[nbin];
	TH1D* hpt[nbin];
	TH2F* hetapteffcorr[nbin];
	TFile *fhisto = TFile::Open("histomerged.root");
	//TFile *feff = TFile::Open("/home/xuq7/HI/dNchdeta/Correction/trkEff_pp_all_42X_origin.root");
	TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HYDJET_442_OFFICIAL_Mar25.root");
	TH2F* heff = (TH2F*)feff->Get("rTotalEff3D");
      	//TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o");
      	//TGraphError* hpteff = (TGraphErrors*)feff->Get("gEffPt");
	TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins();
	double *ptbinhisto = ptarr->GetArray();
	int NbinX = heff->GetXaxis()->GetNbins();
	int NbinY = heff->GetYaxis()->GetNbins();
	//hpteff->Scale(1.0/NbinX);
                }
        for(int ibin=0;ibin<nbin;ibin++)
		for(int itheta=0;itheta<ntheta;itheta++)
			dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin];
	
        for(int ibin=0;ibin<nbin;ibin++){
		avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin];
		avgtrkall[ibin]=1.0*tottrkall[ibin]/Nevent[ibin];
                if(ispt){
                hetapt[ibin] = (TH2F*)fhisto->Get(Form("D_%d/hetapt",ibin));
                hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin));
                //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,Form("hptre_%d",ibin),ptbinhisto);
                //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,Form("hptre_%d",ibin),ptbinhisto);
                hetapteffcorr[ibin] = (TH2F*)hetapt[ibin]->Clone(Form("hetapteffcorr_%d",ibin));
                //hpteffcorr[ibin]->Divide(hpteff);
                }
	        for(int ivbin=0;ivbin<nvv; ivbin++){
			vmean[ibin][ivbin]=0;
			deltavmean[ibin][ivbin]=0;
			avgmult[ibin][ivbin]=1.0*totmult[ibin][ivbin]/Nevent[ibin];
			avgpt[ibin][ivbin]=1.0*totpt[ibin][ivbin]/totmult[ibin][ivbin];
			avgeta[ibin][ivbin]=1.0*toteta[ibin][ivbin]/totmult[ibin][ivbin];
			for(int itheta=0;itheta<ntheta;itheta++){
				dN[ibin][itheta][ivbin]/=totmult[ibin][ivbin];
				TComplex Res=dN[ibin][itheta][ivbin]/dD[ibin][itheta];
				v[ibin][itheta][ivbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re();
				vmean[ibin][ivbin]+=v[ibin][itheta][ivbin];
				deltav[ibin][itheta][ivbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][ivbin]*(TMath::Exp(j01*j01/2./(*chi)[ibin]/(*chi)[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi)[ibin]/(*chi)[ibin]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)));
				deltavmean[ibin][ivbin]+=deltav[ibin][itheta][ivbin];
			//	fstrv<<itheta<<"\t"<<v[ibin][itheta][ivbin]<<"\t"<<deltav[ibin][itheta][ivbin]<<endl;
			}
		deltavmean[ibin][ivbin]=TMath::Sqrt(deltavmean[ibin][ivbin])/2./Besselj01(mm);
		//fstrv<<endl;
		vmean[ibin][ivbin]/=ntheta;
		deltavmean[ibin][ivbin]/=TMath::Sqrt(ntheta);
		fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t"<<vmean[ibin][ivbin]<<"\t"<<deltavmean[ibin][ivbin]<<endl;
                if(ispt){
                    for(int ietabin=0;ietabin<netav;ietabin++){
                eff[ietabin] = heff->GetBinContent(heff->FindBin((etabinv[ietabin]+etabinv[ietabin+1])/2,(binv[ivbin]+binv[ivbin+1])/2));
                totmulthisto_f[ibin][ietabin][ivbin]=hetapt[ibin]->Integral(hetapt[ibin]->GetXaxis()->FindBin(etabinv[ietabin]+1e-4),hetapt[ibin]->GetXaxis()->FindBin(etabinv[ietabin+1]-1e-4),hetapt[ibin]->GetYaxis()->FindBin(binv[ivbin]+1e-4),hetapt[ibin]->GetYaxis()->FindBin(binv[ivbin+1]+1e-4));
                totmulthisto[ibin][ivbin]+=totmulthisto_f[ibin][ietabin][ivbin];
                }
                }
                
		V_int[ibin]+=vmean[ibin][ivbin]*totmult[ibin][ivbin];
		V_interr[ibin]+=deltavmean[ibin][ivbin]*totmult[ibin][ivbin];
		totmultall_[ibin]+=totmult[ibin][ivbin];
                if(ispt){
		if(binv[ivbin+1]>3.0) continue;
                    for(int ietabin=0;ietabin<netav;ietabin++)
                totmulthistocorr[ibin][ivbin]+=totmulthisto_f[ibin][ietabin][ivbin]/eff[ietabin];
		V_intcorr[ibin]+=vmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
		V_intcorrerr[ibin]+=deltavmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
                totmultallcorr[ibin]+=totmulthistocorr[ibin][ivbin];
		}
                }
		V_int[ibin]/=totmultall_[ibin];
		V_interr[ibin]/=totmultall_[ibin];
                if(ispt){
		V_intcorr[ibin]/=totmultallcorr[ibin];
		V_intcorrerr[ibin]/=totmultallcorr[ibin];
                }
	}
                if(ispt){
                fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl;
	        for(int ibin=0;ibin<nbin;ibin++){
		for(int ivbin=0;ivbin<nvv; ivbin++){
                fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<"\t"<<totmulthisto[ibin][ivbin]<<"\t"<<totmulthistocorr[ibin][ivbin]<<endl;
		}
		fstrv<<"Integral\t\t"<<totmultall_[ibin]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<totmultallcorr[ibin]<<endl;
		fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<"\t"<<"V int corr="<<V_intcorr[ibin]<<endl;
	        fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin]<<endl;
	    }
                }
            else 
            for(int ibin=0;ibin<nbin;ibin++){
                for(int ivbin=0;ivbin<nvv; ivbin++){
                    fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<endl;
                }
		fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<endl;
		fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<endl;
            }
        if(ispt){
	if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2.root","Recreate");
        }
        else{
	if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_finer_eta.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2_finer_eta.root","Recreate");
        }
	for(ibin=0;ibin<nbin;ibin++){
	Nevent.Write("Nevent");
	avgtrkall.Write("avgtrk");
	V_int.Write("V_int");
	V_interr.Write("V_interr");
        if(ispt){
	V_intcorr.Write("V_intcorr");
	V_intcorrerr.Write("V_intcorrerr");
        }
	TDirectory *dir0 = fout->mkdir(Form("D_%d",ibin));
	dir0->cd();
	avgpt[ibin].Write("avgpt");
	avgeta[ibin].Write("avgeta");
	totmult[ibin].Write("totmult");
	vmean[ibin].Write("vmean");
	deltavmean[ibin].Write("deltavmean");
         for(int itheta=0;itheta<ntheta;itheta++){
            TDirectory *dir1 = dir0->mkdir(Form("D_%d",itheta));dir1->cd();
            v[ibin][itheta].Write("v");
            deltav[ibin][itheta].Write("deltav");
        }
	}
	
	infile->Close();
	fout->Close();
}
void display(){
  
  gROOT->ProcessLine(".x lhcbStyle.C");
  gStyle->SetPalette(1);
	
  string filename = "../analysed/SET9THL914.root";
	TFile* file = new TFile(filename.c_str(),"OPEN");

	int nBinsX=32; int nBinsY=32;
	int nPixelsX=64; int nPixelsY=64;
	
  std::cout<<"Making global intercept tot map"<<std::endl;
  // Global intercept map (not per pixel)
	TH2F* hToTMap = new TH2F("hToTMap","hToTMap",nBinsX,0,nPixelsX,nBinsY,0,nPixelsY);
	for(int x=0;x<nBinsX;x++){
		for(int y=0;y<nBinsY;y++){
			int id = x + y*nBinsX;
			// Get the ToT distribution for this location
			string histoname = "/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixMap"+makestring(id);
			TH1F* totMapHisto = 0;
			totMapHisto = (TH1F*)gDirectory->Get(histoname.c_str());
			if(totMapHisto == 0) continue;
			if(totMapHisto->GetEntries() < 20) continue;
	
			// Fit the tot distribution and enter the value in the ToT map
			totMapHisto->Fit("gaus","0q");
			TF1* fit = totMapHisto->GetFunction("gaus");
			hToTMap->Fill(x*floor(nPixelsX/nBinsX),y*floor(nPixelsY/nBinsY),fit->GetParameter(1));
			
			delete fit; delete totMapHisto;
		}
	}
	// Plot the map of ToT
	TCanvas* canv = new TCanvas();
	hToTMap->GetXaxis()->SetTitle("Column");
	hToTMap->GetYaxis()->SetTitle("Row");
  hToTMap->GetZaxis()->SetTitle("Mean charge (ToT)");
	hToTMap->SetMaximum(9);
	hToTMap->SetMinimum(5);
	hToTMap->DrawCopy("colz");

  
  std::cout<<"Making per pixel tot map"<<std::endl;
  // Per pixel map
  TH2F* hToTMapPerPixel = new TH2F("hToTMapPerPixel","hToTMapPerPixel",nPixelsX,0,nPixelsX,nPixelsY,0,nPixelsY);
  for(int x=0;x<nPixelsX;x++){
    for(int y=0;y<nPixelsY;y++){
      int id = x + y*nPixelsX;
      // Get the ToT distribution for this location
      string histoname = "/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixPixel"+makestring(id);
      TH1F* totMapHisto = 0;
      totMapHisto = (TH1F*)gDirectory->Get(histoname.c_str());
      if(totMapHisto == 0) continue;
      if(totMapHisto->GetEntries() < 10) continue;
      
      // Fit the tot distribution and enter the value in the ToT map
      totMapHisto->Fit("gaus","0q");
      TF1* fit = totMapHisto->GetFunction("gaus");
      hToTMapPerPixel->Fill(x,y,fit->GetParameter(1));
      
      delete fit; delete totMapHisto;
    }
  }
  // Plot the map of ToT
  TCanvas* canv2 = new TCanvas();
  hToTMapPerPixel->GetXaxis()->SetTitle("Column");
  hToTMapPerPixel->GetYaxis()->SetTitle("Row");
  hToTMapPerPixel->GetZaxis()->SetTitle("Mean charge (ToT)");
  hToTMapPerPixel->SetMaximum(10);
  hToTMapPerPixel->SetMinimum(0);
  hToTMapPerPixel->DrawCopy("colz");

  std::cout<<"Making pixel response tot maps"<<std::endl;
  // Pixel response maps
  int responseBins=100;
  double responseWidth=0.05;
  TH2F* hToTMapPixelResponseX = new TH2F("hToTMapPixelResponseX","hToTMapPixelResponseX",responseBins+1,-responseWidth,responseWidth,15,0,15);
  for(double rID=0;rID<responseBins;rID++){
    // Get the ToT distribution for this location
    string histoname = "/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixResponseX"+makestringD(rID);
    TH1F* totMapHisto = 0;
    totMapHisto = (TH1F*)gDirectory->Get(histoname.c_str());
    if(totMapHisto == 0) continue;
    if(totMapHisto->GetEntries() < 1) continue;
 		// loop over all tot bins
    for(int i=0;i<45;i++){
      hToTMapPixelResponseX->Fill(2.*responseWidth*(rID/100.)-responseWidth,i,totMapHisto->GetBinContent(totMapHisto->FindBin(i)));
    }
    delete totMapHisto;
  }
  // Plot the map of ToT
  TCanvas* canv3 = new TCanvas();
  hToTMapPixelResponseX->GetXaxis()->SetTitle("Track distance x (mm)");
  hToTMapPixelResponseX->GetYaxis()->SetTitle("ToT");
  hToTMapPixelResponseX->DrawCopy("colz");

  TH1F* hToTProfilePixelResponseY = new TH1F("hToTProfilePixelResponseY","hToTProfilePixelResponseY",responseBins+1,-responseWidth,responseWidth);
  TH2F* hToTMapPixelResponseY = new TH2F("hToTMapPixelResponseY","hToTMapPixelResponseY",responseBins+1,-responseWidth,responseWidth,16,0,16);
  for(double rID=0;rID<responseBins;rID++){
    // Get the ToT distribution for this location
    string histoname = "/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixResponseY"+makestringD(rID);
    TH1F* totMapHisto = 0;
    totMapHisto = (TH1F*)gDirectory->Get(histoname.c_str());
    if(totMapHisto == 0) continue;
    if(totMapHisto->GetEntries() < 1) continue;
    // loop over all tot bins
    for(int i=0;i<45;i++){
      hToTMapPixelResponseY->Fill(2.*responseWidth*(rID/100.)-responseWidth,i,totMapHisto->GetBinContent(totMapHisto->FindBin(i)));
    }
    hToTProfilePixelResponseY->Fill(2.*responseWidth*(rID/100.)-responseWidth+0.001,totMapHisto->GetXaxis()->GetBinCenter(totMapHisto->GetMaximumBin()));
    delete totMapHisto;
  }
  // Plot the map of ToT
  TCanvas* canv4 = new TCanvas();
  hToTMapPixelResponseY->GetXaxis()->SetTitle("Track distance y (mm)");
  hToTMapPixelResponseY->GetYaxis()->SetTitle("ToT");
  hToTMapPixelResponseY->GetZaxis()->SetTitle("Number of events");
  hToTMapPixelResponseY->DrawCopy("colz");
//  drawline(-0.03,1,7);
//  drawline(0.03,1,7);
	
  TCanvas* canv6 = new TCanvas();
  hToTProfilePixelResponseY->GetXaxis()->SetTitle("Track distance y (mm)");
  hToTProfilePixelResponseY->GetYaxis()->SetTitle("Most probable ToT");
  hToTProfilePixelResponseY->DrawCopy("");



  
  TCanvas* canv5 = new TCanvas();
  TH1F* sidebandLow = (TH1F*)gDirectory->Get("/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixResponseY20");
  TH1F* sidebandHigh = (TH1F*)gDirectory->Get("/tpanal/ClicpixAnalysis/hClusterTOTAssociated1pixResponseY80");
  sidebandHigh->GetXaxis()->SetTitle("ToT (single pixel)");
  sidebandHigh->GetXaxis()->SetRangeUser(0,20);
  sidebandHigh->DrawCopy("");
  sidebandLow->SetLineColor(2);
  sidebandLow->DrawCopy("same");

}
Exemplo n.º 5
0
//================================================
void embed(int save = 0)
{
  char *run_config = "Embed.fix.";
  
  TString fileName;
  if(year==2013) fileName = Form("Run13.pp500.jpsi.%sroot",run_config);

  f = TFile::Open(Form("./output/%s",fileName.Data()),"read");
  THnSparseF *hnDtof = (THnSparseF*)f->Get("mhMcTofQA_di_mu");

  // dtof vs pt
  TH2F *hTofVsPt = (TH2F*)hnDtof->Projection(0,3);
  hTofVsPt->SetName("Embed_dTof_vs_pt");
  hTofVsPt->SetTitle("Embedding: tof_{mc} - tof_{exp} vs p_{T}");
  hTofVsPt->GetXaxis()->SetRangeUser(0,12);
  hTofVsPt->GetYaxis()->SetRangeUser(-1,1);
  c = draw2D(hTofVsPt);
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_pt.png",run_type,run_config));
    }

  // dtof vs mctof
  TH2F *hTofVsMcTof = (TH2F*)hnDtof->Projection(0,1);
  hTofVsMcTof->SetName("Embed_dTof_vs_mc_tof");
  hTofVsMcTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{mc}");
  hTofVsMcTof->GetXaxis()->SetRangeUser(13,17);
  hTofVsMcTof->GetYaxis()->SetRangeUser(-1,1);
  c = draw2D(hTofVsMcTof);
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_mctof.png",run_type,run_config));
    }

  // dtof vs exptof
  TH2F *hTofVsExpTof = (TH2F*)hnDtof->Projection(0,2);
  hTofVsExpTof->SetName("Embed_dTof_vs_exp_tof");
  hTofVsExpTof->SetTitle("Embedding: tof_{mc} - tof_{exp} vs tof_{exp}");
  hTofVsExpTof->GetXaxis()->SetRangeUser(13,17);
  hTofVsExpTof->GetYaxis()->SetRangeUser(-1,1);
  c = draw2D(hTofVsExpTof);
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_exptof.png",run_type,run_config));
    }

  // dtof vs module
  TH2F *hTofVsMod = (TH2F*)hnDtof->Projection(0,4);
  hTofVsMod->SetName("Embed_dTof_vs_module");
  hTofVsMod->SetTitle("Embedding: tof_{mc} - tof_{exp} vs backleg");
  hTofVsMod->GetYaxis()->SetRangeUser(-1,1);
  c = draw2D(hTofVsMod);
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_vs_backleg.png",run_type,run_config));
    }

  // dtof intervals
  TList *list = new TList;
  TString legName[3];
  TH1F *histo[3][3];
  double low_bounds[3] = {-5, 0.15, -0.16};
  double up_bounds[3] = {5, 0.16, -0.15};
  char *name[3] = {"mc_tof","exp_tof","pt"};
  double scale[3] = {2,2.5,1.5};
  double min[3] = {12,12,0};
  double max[3]= {18,18,12};
  for(int i=0; i<3; i++)
    {
      list->Clear();
      for(int j=0; j<3; j++)
	{
	  hnDtof->GetAxis(0)->SetRangeUser(low_bounds[j]+0.001,up_bounds[j]-0.001);
	  histo[i][j] = (TH1F*)hnDtof->Projection(i+1);
	  histo[i][j]->SetName(Form("%s_dTofBin%d",name[i],j));
	  histo[i][j]->Scale(1./histo[i][j]->Integral());
	  histo[i][j]->SetLineWidth(2);
	  histo[i][j]->SetMaximum(scale[i]*histo[i][j]->GetMaximum());
	  legName[j] = Form("%2.2f #leq #Deltatof #leq %2.2f ns",low_bounds[j],up_bounds[j]);
	  list->Add(histo[i][j]);
	}
      c = drawHistos(list,name[i],Form("Embedding: %s distributions",name[i]),kTRUE,min[i],max[i],kFALSE,0.1,10,kFALSE,kTRUE,legName,kTRUE,"",0.5,0.7,0.6,0.85,kFALSE);
      if(save)
	{
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.pdf",run_type,run_config,name[i]));
	  c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%s%s_in_dTofBin.png",run_type,run_config,name[i]));
	}
    }
  hnDtof->GetAxis(0)->SetRange(0,-1);

  // dtof in module
  TH1F *hTofInMod[5];
  TH2F *hTofVsProjMod[5];
  for(int i=0; i<5; i++)
    {
      hnDtof->GetAxis(5)->SetRange(i+1,i+1);
      hTofInMod[i] = (TH1F*)hnDtof->Projection(0);
      hTofInMod[i]->SetName(Form("hTof_Mod%d",i+1));
      hTofVsProjMod[i] = (TH2F*)hnDtof->Projection(0,6);
      hTofVsProjMod[i]->SetName(Form("hTofVsProjMod_Mod%d",i+1));
    }
  hnDtof->GetAxis(5)->SetRange(0,-1);
  TCanvas *c = new TCanvas("hTof_in_mod","hTof_in_mod",1100,750);
  c->Divide(3,2);
  for(int i=0; i<5; i++)
    {
      c->cd(i+1);
      gPad->SetLogy();
      hTofInMod[i]->Draw();
      hTofInMod[i]->SetTitle("");
      hTofInMod[i]->GetXaxis()->SetRangeUser(-1,2);
      TPaveText *t1 = GetTitleText(Form("Module %d",i+1),0.05);
      t1->Draw();
    }
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTof_in_module.png",run_type,run_config));
    }

  TCanvas *c = new TCanvas("hTofVsProjMod_in_mod","hTofVsProjMod_in_mod",1100,750);
  c->Divide(3,2);
  for(int i=0; i<5; i++)
    {
      c->cd(i+1);
      gPad->SetLogz();
      hTofVsProjMod[i]->SetTitle(";track module");
      hTofVsProjMod[i]->GetYaxis()->SetRangeUser(-0.5,0.5);
      hTofVsProjMod[i]->Draw("colz");
      TPaveText *t1 = GetTitleText(Form("Hit in module %d",i+1),0.05);
      t1->Draw();

    }
  if(save)
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.pdf",run_type,run_config));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/qa_dTof/%sdTofVsProjMod_in_module.png",run_type,run_config));
    }

}
Exemplo n.º 6
0
TH2F* fixrange(TH2F* old, int numB) {

  float x1, x2;
  string name = old->GetName();

  if (name.find("Ht")!=string::npos) {
    x1 = 30.;
    x2 = 500.;
    if (numB==2) x2 = 400.;
  } else if (name.find("jet_pt")!=string::npos) {
    x1 = 30.;
    x2 = 300.;
    if (numB==2) {
      if (name.find("first")!=string::npos) x2 = 200.;
      if (name.find("second")!=string::npos) x2 = 120.;
    }
  } else if (name.find("pt_Z")!=string::npos) {
    x1 = 0.;
    x2 = 300.;
    if (numB==2) x2 = 230.;
  } else {
    x1 = old->GetXaxis()->GetBinCenter(1);
    x2 = old->GetXaxis()->GetBinCenter(old->GetNbinsX());
  }

  float y1=x1;
  float y2=x2;

  int nx = old->GetXaxis()->FindBin(x2)-old->GetXaxis()->FindBin(x1)+1;
  int ny = old->GetYaxis()->FindBin(y2)-old->GetYaxis()->FindBin(y1)+1;

  x1 = old->GetXaxis()->GetBinLowEdge(old->GetXaxis()->FindBin(x1));
  x2 = old->GetXaxis()->GetBinUpEdge(old->GetXaxis()->FindBin(x2));
  y1 = old->GetYaxis()->GetBinLowEdge(old->GetYaxis()->FindBin(y1));
  y2 = old->GetYaxis()->GetBinUpEdge(old->GetYaxis()->FindBin(y2));

  TH2F* tmp = new TH2F("tmp",old->GetTitle(),nx,x1,x2,ny,y1,y2);
  tmp->Sumw2();

  tmp->GetXaxis()->SetTitle(old->GetXaxis()->GetTitle());
  tmp->GetYaxis()->SetTitle(old->GetYaxis()->GetTitle());

  for (int i=0;i<=old->GetNbinsX()+1;i++) {
    for (int j=0;j<=old->GetNbinsY()+1;j++) {
      int ii = tmp->GetXaxis()->FindBin(old->GetXaxis()->GetBinCenter(i));
      int jj = tmp->GetYaxis()->FindBin(old->GetYaxis()->GetBinCenter(j));
      float c1 = tmp->GetBinContent(ii,jj);
      float e1 = tmp->GetBinError(ii,jj);
      float c2 = old->GetBinContent(i,j);
      float e2 = old->GetBinError(i,j);
//
// underflows and overflows *must* be discarded before the unfolding:
// inefficiencies and fakes/background are taken from the additional entries
// in the 'reco' and 'truth' histograms, respectively
//
      if (ii==0) continue;
      if (ii==tmp->GetNbinsX()+1) continue;
      if (jj==0) continue;
      if (jj==tmp->GetNbinsY()+1) continue;

      tmp->SetBinContent(ii,jj,c1+c2);
      tmp->SetBinError(ii,jj,TMath::Sqrt(e1*e1+e2*e2));
    }
  }

  tmp->SetEntries(old->GetEntries());

  old->Delete();
  tmp->SetName(name.c_str());

  return tmp;
}
Exemplo n.º 7
0
Arquivo: getResV.C Projeto: XuQiao/HI
void getResv(){

	double theta[ntheta];
	TFile *f[nFileAlltrack];
		
	for(int itheta=0;itheta<ntheta;itheta++)
        	theta[itheta]=itheta*TMath::Pi()/ntheta/nn;


	string SumorProd = getenv("SUMORPROD");
	string mdir = getenv("DIR");
	ofstream fstrv;
	if(SumorProd=="Sum")fstrv.open("v.txt");
	else fstrv.open("v_2.txt");
	TVectorD totmult[nbin], totpt[nbin];	TVectorD Nevent, totmultall, totmultall_;
	TVectorD totmulthisto[nbin], totmulthistocorr[nbin];
	TVectorD V_int, V_interr;
	TVectorD V_intcorr, V_intcorrerr;
	TVectorD* V_mean;
	TVectorD* deltaV_mean;
	TVectorD* V[nbin]; TVectorD* chi[nbin];
	TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin];
	TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta];
	TComplex dD[nbin][ntheta], dN[nbin][ntheta][nptv];
	TVectorD avgmult[nbin];	TVectorD avgmultall;
	TVectorD avgpt[nbin];
	TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin];
	if(SumorProd=="Sum")	TFile *infile = TFile::Open("mergedV_Sum.root");
	else	TFile *infile = TFile::Open("mergedV_Prod.root");
	Nevent.ResizeTo(nbin);	Nevent.Zero();
	totmultall.ResizeTo(nbin);	totmultall.Zero();
	totmultall_.ResizeTo(nbin);	totmultall_.Zero();
	avgmultall.ResizeTo(nbin);
	V_int.ResizeTo(nbin);	V_int.Zero();
	V_interr.ResizeTo(nbin);	V_interr.Zero();
	V_intcorr.ResizeTo(nbin);	V_intcorr.Zero();
	V_intcorrerr.ResizeTo(nbin);	V_intcorrerr.Zero();
	for(int ibin=0;ibin<nbin;ibin++){
		totmult[ibin].ResizeTo(nptv);	totmult[ibin].Zero();
		totmulthisto[ibin].ResizeTo(nptv);	
		totmulthistocorr[ibin].ResizeTo(nptv);
		avgmult[ibin].ResizeTo(nptv);	avgpt[ibin].ResizeTo(nptv);
		totpt[ibin].ResizeTo(nptv);	totpt[ibin].Zero();
		vmean[ibin].ResizeTo(nptv);	deltavmean[ibin].ResizeTo(nptv);
		V[ibin] = (TVectorD*) infile->Get(Form("D_%d/D_0/V",ibin));
		chi[ibin] = (TVectorD*) infile->Get(Form("D_%d/chi",ibin));
		V_mean = (TVectorD*) infile->Get(Form("D_%d/Vmean",ibin));
		deltaV_mean = (TVectorD*) infile->Get(Form("D_%d/deltaVmean",ibin));
		for(int itheta=0;itheta<ntheta;itheta++){
			v[ibin][itheta].ResizeTo(nptv);	deltav[ibin][itheta].ResizeTo(nptv);
			dD[ibin][itheta]=0;
			for(int iptbin=0;iptbin<nptv;iptbin++){
				dN[ibin][itheta][iptbin]=0;
			}
		}
	}

        for(int ifile=0; ifile<nFileAlltrack; ifile++){
	        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt01to10tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile));
	        else f[ifile] = TFile::Open(Form("/lio/lfs/cms/store/user/qixu/flow/pbsjoboutput/PFcandpt01to10tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile));
		TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent");	
		TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall");
		for(int ibin=0;ibin<nbin;ibin++){
			TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin));
			TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin));
			dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin));
			dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin));
			Nevent[ibin]+=(*Nevent_t)[ibin];
			totmultall[ibin]+=(*totmultall_t)[ibin];
			for(int iptbin=0;iptbin<nptv;iptbin++){
				totmult[ibin][iptbin]+=(*totmult_t)[iptbin];
				totpt[ibin][iptbin]+=(*totpt_t)[iptbin];
			}
			for(int itheta=0;itheta<ntheta;itheta++){
				dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta));
				dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta));
				dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]);
				for(int iptbin=0;iptbin<nptv;iptbin++)
					dN[ibin][itheta][iptbin]+=TComplex((*dNRe[ibin][itheta])[iptbin],(*dNIm[ibin][itheta])[iptbin]);
			}
		}
	f[ifile]->Close();
	}
	
	TH1D* hpt[nbin];
	TH1D* hpteffcorr[nbin];
	TFile *fhisto = TFile::Open("histomerged.root");
	TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HIJING_538_OFFICIAL_Mar24.root");
	TH2F* heff = (TH2F*)feff->Get("rTotalEff3D");
      	TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o");
	TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins();
	double *ptbinhisto = ptarr->GetArray();
	int NbinX = heff->GetXaxis()->GetNbins();
	int NbinY = heff->GetYaxis()->GetNbins();
	hpteff->Scale(1.0/NbinX);
        
	for(int ibin=0;ibin<nbin;ibin++)
		for(int itheta=0;itheta<ntheta;itheta++)
			dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin];
	
	for(int ibin=0;ibin<nbin;ibin++){
		avgmultall[ibin]=1.0*totmultall[ibin]/Nevent[ibin];
                hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin));
                TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,"hptre",ptbinhisto);
                hpteffcorr[ibin] = (TH1D*)hptre->Clone(Form("hpteffcorr_%d",ibin));
                hpteffcorr[ibin]->Divide(hpteff);
		for(int iptbin=0;iptbin<nptv; iptbin++){
			vmean[ibin][iptbin]=0;
			deltavmean[ibin][iptbin]=0;
			avgmult[ibin][iptbin]=1.0*totmult[ibin][iptbin]/Nevent[ibin];
			avgpt[ibin][iptbin]=1.0*totpt[ibin][iptbin]/totmult[ibin][iptbin];
			for(int itheta=0;itheta<ntheta;itheta++){
				dN[ibin][itheta][iptbin]/=totmult[ibin][iptbin];
				TComplex Res=dN[ibin][itheta][iptbin]/dD[ibin][itheta];
				v[ibin][itheta][iptbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re();
				vmean[ibin][iptbin]+=v[ibin][itheta][iptbin];
				deltav[ibin][itheta][iptbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][iptbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)));
				deltavmean[ibin][iptbin]+=deltav[ibin][itheta][iptbin];
			//	fstrv<<itheta<<"\t"<<v[ibin][itheta][iptbin]<<"\t"<<deltav[ibin][itheta][iptbin]<<endl;
			}
		deltavmean[ibin][iptbin]=TMath::Sqrt(deltavmean[ibin][iptbin])/2./Besselj01(mm);
		//fstrv<<endl;
		vmean[ibin][iptbin]/=ntheta;
		deltavmean[ibin][iptbin]/=TMath::Sqrt(ntheta);
		fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t"<<vmean[ibin][iptbin]<<"\t"<<deltavmean[ibin][iptbin]<<endl;
		if(ptbinv[iptbin+1]>3.0) continue;
                totmulthisto[ibin][iptbin]=hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(ptbinv[iptbin]),hpt[ibin]->GetXaxis()->FindBin(ptbinv[iptbin+1])-1);
                totmulthistocorr[ibin][iptbin]=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[iptbin]),hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[iptbin+1])-1);
		V_int[ibin]+=vmean[ibin][iptbin]*totmult[ibin][iptbin];
		V_interr[ibin]+=deltavmean[ibin][iptbin]*totmult[ibin][iptbin];
		V_intcorr[ibin]+=vmean[ibin][iptbin]*totmulthistocorr[ibin][iptbin];
		V_intcorrerr[ibin]+=deltavmean[ibin][iptbin]*totmulthistocorr[ibin][iptbin];
		totmultall_[ibin]+=totmult[ibin][iptbin];
		}
		V_int[ibin]/=totmultall_[ibin];
		V_interr[ibin]/=totmultall_[ibin];
		V_intcorr[ibin]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);
		V_intcorrerr[ibin]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);
	}

        fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl;
	for(int ibin=0;ibin<nbin;ibin++){
		for(int iptbin=0;iptbin<nptv; iptbin++){
                fstrv<<ptbinv[iptbin]<<"-"<<ptbinv[iptbin+1]<<"\t\t"<<totmult[ibin][iptbin]<<"\t"<<totmulthisto[ibin][iptbin]<<"\t"<<totmulthistocorr[ibin][iptbin]<<endl;
		}
		fstrv<<"Integral\t\t"<<totmultall[ibin]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(ptbinv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1)<<endl;
		fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin]<<"\t"<<"V int corr="<<V_intcorr[ibin]<<endl;
		fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin]<<endl;
	}

	if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2.root","Recreate");
	for(ibin=0;ibin<nbin;ibin++){
	Nevent.Write("Nevent");
	V_int.Write("V_int");
	V_interr.Write("V_interr");
	V_intcorr.Write("V_intcorr");
	V_intcorrerr.Write("V_intcorrerr");
	TDirectory *dir = fout->mkdir(Form("D_%d",ibin));
	dir->cd();
	avgpt[ibin].Write("avgpt");
	totmult[ibin].Write("totmult");
	vmean[ibin].Write("vmean");
	deltavmean[ibin].Write("deltavmean");
	}
	
	infile->Close();
	fout->Close();
	
}
Exemplo n.º 8
0
Bool_t CheckESD(const char* gAliceFileName = "galice.root", 
		const char* esdFileName = "AliESDs.root")
{
// check the content of the ESD
 
  // check values
  Int_t    checkNGenLow = 1;

  Double_t checkEffLow = 0.5;
  Double_t checkEffSigma = 3;
  Double_t checkFakeHigh = 0.5;
  Double_t checkFakeSigma = 3;

  Double_t checkResPtInvHigh = 5;
  Double_t checkResPtInvSigma = 3;
  Double_t checkResPhiHigh = 10;
  Double_t checkResPhiSigma = 3;
  Double_t checkResThetaHigh = 10;
  Double_t checkResThetaSigma = 3;

  Double_t checkPIDEffLow = 0.5;
  Double_t checkPIDEffSigma = 3;
  Double_t checkResTOFHigh = 500;
  Double_t checkResTOFSigma = 3;

  Double_t checkPHOSNLow = 5;
  Double_t checkPHOSEnergyLow = 0.3;
  Double_t checkPHOSEnergyHigh = 1.0;
  Double_t checkEMCALNLow = 50;
  Double_t checkEMCALEnergyLow = 0.05;
  Double_t checkEMCALEnergyHigh = 1.0;

  Double_t checkMUONNLow = 1;
  Double_t checkMUONPtLow = 0.5;
  Double_t checkMUONPtHigh = 10.;

  Double_t cutPtV0 = 0.3;
  Double_t checkV0EffLow = 0.02;
  Double_t checkV0EffSigma = 3;
  Double_t cutPtCascade = 0.5;
  Double_t checkCascadeEffLow = 0.01;
  Double_t checkCascadeEffSigma = 3;

  // open run loader and load gAlice, kinematics and header
  AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
  if (!runLoader) {
    Error("CheckESD", "getting run loader from file %s failed", 
	    gAliceFileName);
    return kFALSE;
  }
  runLoader->LoadgAlice();
  gAlice = runLoader->GetAliRun();
  if (!gAlice) {
    Error("CheckESD", "no galice object found");
    return kFALSE;
  }
  runLoader->LoadKinematics();
  runLoader->LoadHeader();

  // open the ESD file
  TFile* esdFile = TFile::Open(esdFileName);
  if (!esdFile || !esdFile->IsOpen()) {
    Error("CheckESD", "opening ESD file %s failed", esdFileName);
    return kFALSE;
  }
  AliESDEvent * esd = new AliESDEvent;
  TTree* tree = (TTree*) esdFile->Get("esdTree");
  if (!tree) {
    Error("CheckESD", "no ESD tree found");
    return kFALSE;
  }
  esd->ReadFromTree(tree);

  //PMD plots
 TH1F *fhM[48];
  for(Int_t i = 0; i < 48; i++) fhM[i] =  Create1DHistos(i,"hEsDMod");

  // PMD XY Plots histograms

  TH2F *fhEsdXYC = new TH2F("hEsdXYC"," Scattered Plot for CPV (ESD) ",100,-100. ,100.,100,-100.,100.);
  TH2F *fhEsdXYP = new TH2F("hEsdXYP"," Scattered Plot for PRE (ESD) ",100,-100. ,100.,100,-100.,100.);
  
  // efficiency and resolution histograms
  Int_t nBinsPt = 15;
  Float_t minPt = 0.1;
  Float_t maxPt = 3.1;
  TH1F* hGen = CreateHisto("hGen", "generated tracks", 
			   nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
  TH1F* hRec = CreateHisto("hRec", "reconstructed tracks", 
			   nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
  Int_t nGen = 0;
  Int_t nRec = 0;
  Int_t nFake = 0;

  TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10, 
           "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");
  TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20, 
			      "#phi_{rec}-#phi_{sim} [mrad]", "N");
  TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20, 
				"#theta_{rec}-#theta_{sim} [mrad]", "N");

  // PID
  Int_t partCode[AliPID::kSPECIES] = 
    {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
  const char* partName[AliPID::kSPECIES+1] = 
    {"electron", "muon", "pion", "kaon", "proton", "other"};
  Double_t partFrac[AliPID::kSPECIES] = 
    {0.01, 0.01, 0.85, 0.10, 0.05};
  Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES];
  for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
      identified[iGen][iRec] = 0;
    }
  }
  Int_t nIdentified = 0;

  // dE/dx and TOF
  TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400);
  hDEdxRight->SetStats(kFALSE);
  hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]");
  hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}");
  hDEdxRight->SetMarkerStyle(kFullCircle);
  hDEdxRight->SetMarkerSize(0.4);
  TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400);
  hDEdxWrong->SetStats(kFALSE);
  hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]");
  hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}");
  hDEdxWrong->SetMarkerStyle(kFullCircle);
  hDEdxWrong->SetMarkerSize(0.4);
  hDEdxWrong->SetMarkerColor(kRed);
  TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000, 
				   "t_{TOF}-t_{track} [ps]", "N");
  TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000, 
				   "t_{TOF}-t_{track} [ps]", "N");
  hResTOFWrong->SetLineColor(kRed);

  // calorimeters
  TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 50, "E [GeV]", "N");
  TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N");

  // muons
  TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20, 
			      "p_{t} [GeV/c]", "N");

  // V0s and cascades
  TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6, 
			      "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N");
  TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2, 
				  "M(p#pi^{-}) [GeV/c^{2}]", "N");
  TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}", 
				     100, 1.0, 1.2, 
				     "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N");
  Int_t nGenV0s = 0;
  Int_t nRecV0s = 0;
  TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5, 
			      "M(#Lambda#pi) [GeV/c^{2}]", "N");
  TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8, 
				 "M(#LambdaK) [GeV/c^{2}]", "N");
  Int_t nGenCascades = 0;
  Int_t nRecCascades = 0;

  // loop over events
  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
    runLoader->GetEvent(iEvent);

    // select simulated primary particles, V0s and cascades
    AliStack* stack = runLoader->Stack();
    Int_t nParticles = stack->GetNtrack();
    TArrayF vertex(3);
    runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex);
    TObjArray selParticles;
    TObjArray selV0s;
    TObjArray selCascades;
    for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
      TParticle* particle = stack->Particle(iParticle);
      if (!particle) continue;
      if (particle->Pt() < 0.001) continue;
      if (TMath::Abs(particle->Eta()) > 0.9) continue;
      TVector3 dVertex(particle->Vx() - vertex[0], 
		       particle->Vy() - vertex[1],
		       particle->Vz() - vertex[2]);
      if (dVertex.Mag() > 0.0001) continue;

      switch (TMath::Abs(particle->GetPdgCode())) {
      case kElectron:
      case kMuonMinus:
      case kPiPlus:
      case kKPlus:
      case kProton: {
	if (particle->Pt() > minPt) {
	  selParticles.Add(particle);
	  nGen++;
	  hGen->Fill(particle->Pt());
	}
	break;
      }
      case kK0Short:
      case kLambda0: {
	if (particle->Pt() > cutPtV0) {
	  nGenV0s++;
	  selV0s.Add(particle);
	}
	break;
      }
      case kXiMinus:
      case kOmegaMinus: {
	if (particle->Pt() > cutPtCascade) {
	  nGenCascades++;
	  selCascades.Add(particle);
	}
	break;
      }
      default: break;
      }
    }

    // get the event summary data
    tree->GetEvent(iEvent);
    if (!esd) {
      Error("CheckESD", "no ESD object found for event %d", iEvent);
      return kFALSE;
    }

    //------------- Loop over PMD track ----
    Int_t npmdcl = 0;
    npmdcl = esd->GetNumberOfPmdTracks();
    
    
    while (npmdcl--)
      {
        AliESDPmdTrack *pmdtr = esd->GetPmdTrack(npmdcl);
	
        Int_t   det     = pmdtr->GetDetector();
        Int_t   smn     = pmdtr->GetSmn();
        Float_t adc     = pmdtr->GetClusterADC();
	Int_t   ncell   = pmdtr->GetClusterCells();
        Float_t clsX    = pmdtr->GetClusterX();
        Float_t clsY    = pmdtr->GetClusterY();
	
        if(det == 0)
          {
	    fhEsdXYP->Fill(clsX,clsY);
	    if(ncell < 3) fhM[smn]->Fill(adc);
	    
          }
        else if(det == 1)
	  {
            fhEsdXYC->Fill(clsX,clsY);
            if(ncell < 3)fhM[24+smn]->Fill(adc);
	  }
	
      }
    
    //-----------------------

    // loop over tracks
    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
      AliESDtrack* track = esd->GetTrack(iTrack);

      // select tracks of selected particles
      Int_t label = TMath::Abs(track->GetLabel());
      if (label > stack->GetNtrack()) continue;     // background
      TParticle* particle = stack->Particle(label);
      if (!selParticles.Contains(particle)) continue;
      if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;
      if (track->GetConstrainedChi2() > 1e9) continue;
      selParticles.Remove(particle);   // don't count multiple tracks

      nRec++;
      hRec->Fill(particle->Pt());
      if (track->GetLabel() < 0) nFake++;

      // resolutions
      hResPtInv->Fill(100. * (TMath::Abs(track->GetSigned1Pt()) - 1./particle->Pt()) * 
		      particle->Pt());
      hResPhi->Fill(1000. * (track->Phi() - particle->Phi()));
      hResTheta->Fill(1000. * (track->Theta() - particle->Theta()));

      // PID
      if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue;
      Int_t iGen = 5;
      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
	if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i;
      }
      Double_t probability[AliPID::kSPECIES];
      track->GetESDpid(probability);
      Double_t pMax = 0;
      Int_t iRec = 0;
      for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
	probability[i] *= partFrac[i];
	if (probability[i] > pMax) {
	  pMax = probability[i];
	  iRec = i;
	}
      }
      identified[iGen][iRec]++;
      if (iGen == iRec) nIdentified++;

      // dE/dx and TOF
      Double_t time[AliPID::kSPECIES];
      track->GetIntegratedTimes(time);
      if (iGen == iRec) {
	hDEdxRight->Fill(particle->P(), track->GetTPCsignal());
        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
	  hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]);
	}
      } else {
	hDEdxWrong->Fill(particle->P(), track->GetTPCsignal());
        if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
	  hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]);
	}
      }
    }

    // loop over muon tracks
    {
    for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) {
      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
      Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());
      if (ptInv > 0.001) {
	hPtMUON->Fill(1./ptInv);
      }
    }
    }

    // loop over V0s
    for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
      AliESDv0* v0 = esd->GetV0(iV0);
      if (v0->GetOnFlyStatus()) continue;
      v0->ChangeMassHypothesis(kK0Short);
      hMassK0->Fill(v0->GetEffMass());
      v0->ChangeMassHypothesis(kLambda0);
      hMassLambda->Fill(v0->GetEffMass());
      v0->ChangeMassHypothesis(kLambda0Bar);
      hMassLambdaBar->Fill(v0->GetEffMass());

      Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());
      if (negLabel > stack->GetNtrack()) continue;     // background
      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
      if (negMother < 0) continue;
      Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());
      if (posLabel > stack->GetNtrack()) continue;     // background
      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
      if (negMother != posMother) continue;
      TParticle* particle = stack->Particle(negMother);
      if (!selV0s.Contains(particle)) continue;
      selV0s.Remove(particle);
      nRecV0s++;
    }

    // loop over Cascades
    for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades(); 
	 iCascade++) {
      AliESDcascade* cascade = esd->GetCascade(iCascade);
      Double_t v0q;
      cascade->ChangeMassHypothesis(v0q,kXiMinus);
      hMassXi->Fill(cascade->GetEffMassXi());
      cascade->ChangeMassHypothesis(v0q,kOmegaMinus);
      hMassOmega->Fill(cascade->GetEffMassXi());

      Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())
				  ->GetLabel());
      if (negLabel > stack->GetNtrack()) continue;     // background
      Int_t negMother = stack->Particle(negLabel)->GetMother(0);
      if (negMother < 0) continue;
      Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())
				  ->GetLabel());
      if (posLabel > stack->GetNtrack()) continue;     // background
      Int_t posMother = stack->Particle(posLabel)->GetMother(0);
      if (negMother != posMother) continue;
      Int_t v0Mother = stack->Particle(negMother)->GetMother(0);
      if (v0Mother < 0) continue;
      Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())
				  ->GetLabel());
      if (bacLabel > stack->GetNtrack()) continue;     // background
      Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);
      if (v0Mother != bacMother) continue;
      TParticle* particle = stack->Particle(v0Mother);
      if (!selCascades.Contains(particle)) continue;
      selCascades.Remove(particle);
      nRecCascades++;
    }

    // loop over the clusters
    {
      for (Int_t iCluster=0; iCluster<esd->GetNumberOfCaloClusters(); iCluster++) {
	AliESDCaloCluster * clust = esd->GetCaloCluster(iCluster);
	if (clust->IsPHOS()) hEPHOS->Fill(clust->E());
	if (clust->IsEMCAL()) hEEMCAL->Fill(clust->E());
      }
    }

  }

  // perform checks
  if (nGen < checkNGenLow) {
    Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));
  }

  TH1F* hEff = CreateEffHisto(hGen, hRec);

  Info("CheckESD", "%d out of %d tracks reconstructed including %d "
	 "fake tracks", nRec, nGen, nFake);
  if (nGen > 0) {
    // efficiency
    Double_t eff = nRec*1./nGen;
    Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);
    Double_t fake = nFake*1./nGen;
    Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);
    Info("CheckESD", "eff = (%.1f +- %.1f) %%  fake = (%.1f +- %.1f) %%",
	 100.*eff, 100.*effError, 100.*fake, 100.*fakeError);

    if (eff < checkEffLow - checkEffSigma*effError) {
      Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%", 
	      100.*eff, 100.*effError);
    }
    if (fake > checkFakeHigh + checkFakeSigma*fakeError) {
      Warning("CheckESD", "high fake: (%.1f +- %.1f) %%", 
	      100.*fake, 100.*fakeError);
    }

    // resolutions
    Double_t res, resError;
    if (FitHisto(hResPtInv, res, resError)) {
      Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",
	   res, resError);
      if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {
	Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%", 
		res, resError);
      }
    }

    if (FitHisto(hResPhi, res, resError)) {
      Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);
      if (res > checkResPhiHigh + checkResPhiSigma*resError) {
	Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad", 
		res, resError);
      }
    }

    if (FitHisto(hResTheta, res, resError)) {
      Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad", 
	   res, resError);
      if (res > checkResThetaHigh + checkResThetaSigma*resError) {
	Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad", 
		res, resError);
      }
    }

    // PID
    if (nRec > 0) {
      Double_t eff = nIdentified*1./nRec;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);
      Info("CheckESD", "PID eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {
	Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }

    printf("%9s:", "gen\\rec");
    for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
      printf("%9s", partName[iRec]);
    }
    printf("\n");
    for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
      printf("%9s:", partName[iGen]);
      for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
	printf("%9d", identified[iGen][iRec]);
      }
      printf("\n");
    }

    if (FitHisto(hResTOFRight, res, resError)) {
      Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);
      if (res > checkResTOFHigh + checkResTOFSigma*resError) {
	Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps", 
		res, resError);
      }
    }

    // calorimeters
    if (hEPHOS->Integral() < checkPHOSNLow) {
      Warning("CheckESD", "low number of PHOS particles: %d", 
	      Int_t(hEPHOS->Integral()));
    } else {
      Double_t mean = hEPHOS->GetMean();
      if (mean < checkPHOSEnergyLow) {
	Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);
      } else if (mean > checkPHOSEnergyHigh) {
	Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);
      }
    }

    if (hEEMCAL->Integral() < checkEMCALNLow) {
      Warning("CheckESD", "low number of EMCAL particles: %d", 
	      Int_t(hEEMCAL->Integral()));
    } else {
      Double_t mean = hEEMCAL->GetMean();
      if (mean < checkEMCALEnergyLow) {
	Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);
      } else if (mean > checkEMCALEnergyHigh) {
	Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);
      }
    }

    // muons
    if (hPtMUON->Integral() < checkMUONNLow) {
      Warning("CheckESD", "low number of MUON particles: %d", 
	      Int_t(hPtMUON->Integral()));
    } else {
      Double_t mean = hPtMUON->GetMean();
      if (mean < checkMUONPtLow) {
	Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);
      } else if (mean > checkMUONPtHigh) {
	Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);
      }
    }

    // V0s
    if (nGenV0s > 0) {
      Double_t eff = nRecV0s*1./nGenV0s;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);
      if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);
      Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkV0EffLow - checkV0EffSigma*effError) {
	Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }

    // Cascades
    if (nGenCascades > 0) {
      Double_t eff = nRecCascades*1./nGenCascades;
      Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);
      if (effError == 0) effError = checkV0EffLow / 
			   TMath::Sqrt(1.*nGenCascades);
      Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%", 
	   100.*eff, 100.*effError);
      if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {
	Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%", 
		100.*eff, 100.*effError);
      }
    }
  }

  // draw the histograms if not in batch mode
  if (!gROOT->IsBatch()) {
    new TCanvas;
    hEff->DrawCopy();
    new TCanvas;
    hResPtInv->DrawCopy("E");
    new TCanvas;
    hResPhi->DrawCopy("E");
    new TCanvas;
    hResTheta->DrawCopy("E");
    new TCanvas;
    hDEdxRight->DrawCopy();
    hDEdxWrong->DrawCopy("SAME");
    new TCanvas;
    hResTOFRight->DrawCopy("E");
    hResTOFWrong->DrawCopy("SAME");
    new TCanvas;
    hEPHOS->DrawCopy("E");
    new TCanvas;
    hEEMCAL->DrawCopy("E");
    new TCanvas;
    hPtMUON->DrawCopy("E");
    new TCanvas;
    hMassK0->DrawCopy("E");
    new TCanvas;
    hMassLambda->DrawCopy("E");
    new TCanvas;
    hMassLambdaBar->DrawCopy("E");
    new TCanvas;
    hMassXi->DrawCopy("E");
    new TCanvas;
    hMassOmega->DrawCopy("E");
  }

  // write the output histograms to a file
  TFile* outputFile = TFile::Open("check.root", "recreate");
  if (!outputFile || !outputFile->IsOpen()) {
    Error("CheckESD", "opening output file check.root failed");
    return kFALSE;
  }
  hEff->Write();
  hResPtInv->Write();
  hResPhi->Write();
  hResTheta->Write();
  hDEdxRight->Write();
  hDEdxWrong->Write();
  hResTOFRight->Write();
  hResTOFWrong->Write();
  hEPHOS->Write();
  hEEMCAL->Write();
  hPtMUON->Write();
  hMassK0->Write();
  hMassLambda->Write();
  hMassLambdaBar->Write();
  hMassXi->Write();
  hMassOmega->Write();

 for(Int_t i = 0; i < 48; i++) fhM[i]->Write();
  fhEsdXYP->Write();
  fhEsdXYC->Write();

  outputFile->Close();
  delete outputFile;

  // clean up

  delete fhEsdXYC;
  delete fhEsdXYP;
  delete [] fhM;

  delete hGen;
  delete hRec;
  delete hEff;
  delete hResPtInv;
  delete hResPhi;
  delete hResTheta;
  delete hDEdxRight;
  delete hDEdxWrong;
  delete hResTOFRight;
  delete hResTOFWrong;
  delete hEPHOS;
  delete hEEMCAL;
  delete hPtMUON;
  delete hMassK0;
  delete hMassLambda;
  delete hMassLambdaBar;
  delete hMassXi;
  delete hMassOmega;

  delete esd;
  esdFile->Close();
  delete esdFile;

  runLoader->UnloadHeader();
  runLoader->UnloadKinematics();
  delete runLoader;

  // result of check
  Info("CheckESD", "check of ESD was successfull");
  return kTRUE;
}
Exemplo n.º 9
0
void EfficiencyMaps(TString Signal, TString Analysis, TString Channel, bool entries = false) {

  int const nSRs = 12;
  TString SRname[nSRs] = {"SR1_NoJet", "SR1_NoTag", "SR1_Veto", "SR1_Tag", 
			  "SR2_NoJet", "SR2_NoTag", "SR2_Veto", "SR2_Tag", 
			  "SR3_Veto",  "SR3_Tag",   "SR3_Veto_isr", "SR3_Tag_isr"};
  TString SRtitle[nSRs] = {"SR1^{\\text{0Jet}}_{\\text{0Tag}}", "SR1_^{\\text{Jets}}_{\\text{0Tag}}", "SR1_{\\text{0Tag}}", "SR1_{\\text{Tags}}", 
			   "SR2^{\\text{0Jet}}_{\\text{0Tag}}", "SR2_^{\\text{Jets}}_{\\text{0Tag}}", "SR2_{\\text{0Tag}}", "SR2_{\\text{Tags}}", 
			   "SR3_{\\text{0Tag}}", "SR3_{\\text{Tags}}", "SR3^{\\text{ISR}}_{\\text{0Tag}}", "SR3^{\\text{ISR}}_{\\text{Tags}}"};
  bool UseSR[nSRs]; 
  if (Analysis=="_Stop") {
    UseSR[0] = 0; UseSR[1] = 0; UseSR [2] = 1; UseSR [3] = 1;
    UseSR[4] = 0; UseSR[5] = 0; UseSR [6] = 1; UseSR [7] = 1;
    UseSR[8] = 0; UseSR[9] = 0; UseSR[10] = 1; UseSR[11] = 1; 
  } else if (Analysis=="_Chargino") {
    UseSR[0] = 1; UseSR[1] = 1; UseSR [2] = 0; UseSR [3] = 0;
    UseSR[4] = 1; UseSR[5] = 1; UseSR [6] = 0; UseSR [7] = 0;
    UseSR[8] = 1; UseSR[9] = 0; UseSR[10] = 0; UseSR[11] = 0; 
  }

  int nSRsignal = 0;
  for (int sr = 0; sr<nSRs; sr++)
    if (UseSR[sr]) 
      nSRsignal++;

  TH2F *EffMap  = new TH2F("EffMap",  "", 7, 0., 140., nSRsignal, 0., nSRsignal);
  TH2F *StatMap = new TH2F("StatMap", "", 7, 0., 140., nSRsignal, 0., nSRsignal);

  EffMap->SetXTitle("M_{T2}(ll) [GeV]");
  StatMap->SetXTitle("M_{T2}(ll) [GeV]");
  
  TString Syst = entries ? "noweight" : "nominal"; 
  myfile0 = new TFile("../minitrees/rootfilesOct17/" + Syst + "/Stop/" + Signal + ".root", "read");

  int isr = 1;

  for (int sr = 0; sr<nSRs; sr++)
    if (UseSR[sr]) {

      EffMap->GetYaxis()->SetBinLabel(isr, SRtitle[sr]);
      StatMap->GetYaxis()->SetBinLabel(isr, SRtitle[sr]);

      TString HistoName = "Stop/02_" + SRname[sr] + "/h_MT2ll" + Channel; 
      TString HistoNameGen = HistoName; 
      HistoNameGen.ReplaceAll("SR1", "SR1gen");
      HistoNameGen.ReplaceAll("SR2", "SR2gen");
      HistoNameGen.ReplaceAll("SR3", "SR3gen");
      HistoNameGen.ReplaceAll("MT2ll", "MT2llgen");
      if (SRname[sr].Contains("_isr")) {
	HistoName.ReplaceAll("_isr", "");
	HistoName.ReplaceAll("MT2ll", "MT2llisr");
	HistoNameGen.ReplaceAll("_isr", "");
	HistoNameGen.ReplaceAll("MT2ll", "MT2llisr");
      }

      TH1F *ThisHisto = GetHisto(HistoName);
      TH1F *ThisHistoGen = GetHisto(HistoNameGen);

      for (int ib = 1; ib<=7; ib++) {
	
	//float XXX = ThisHisto->GetBinContent(ib);
	//float EEE = ThisHistoGen->GetBinContent(ib);
	float XXX = 35.896*(ThisHisto->GetBinContent(ib)+ThisHistoGen->GetBinContent(ib))/2.;
        float EEE = 35.896*(ThisHisto->GetBinError(ib)+ThisHistoGen->GetBinError(ib))/2.;
	float value = EEE/XXX;
	if (entries) value = ThisHisto->GetBinContent(ib);
	EffMap->SetBinContent(ib, isr, value);
	//EffMap->SetBinError(ib, isr, EEE);
	
      }	

      isr++;
      
    }
  
  gStyle->SetOptStat(0);
  //gStyle->SetPaintTextFormat("5.2f");

  TCanvas *CC = new TCanvas("CC", "", 600, 400);
  CC->Divide(1, 1); 

  EffMap->Draw("COLZtext");
  //EffMap->Draw("COLZtexte");
  
  TString channelFlag = (Channel=="_em") ? "_emu" : "_eemumu";
  TString PlotName = entries ? "SignalEntries" : "SignalStatError";
  CC->Print("../Plots/MapMySignal/" + PlotName + "Map_" + Signal + channelFlag + ".pdf");
  CC->Print("../Plots/MapMySignal/" + PlotName + "Map_" + Signal + channelFlag + ".png");

}
Exemplo n.º 10
0
void rulevisHists( TDirectory *rfdir, TDirectory *vardir, TDirectory *corrdir, TMVAGlob::TypeOfPlot type) {
   //
   if (rfdir==0)   return;
   if (vardir==0)  return;
   if (corrdir==0) return;
   //
   const TString rfName    = rfdir->GetName();
   const TString maintitle = rfName + " : Rule Importance";
   const TString rfNameOpt = "_RF2D_";
   const TString outfname[TMVAGlob::kNumOfMethods] = { "rulevisHists",
                                                       "rulevisHists_decorr",
                                                       "rulevisCorr_pca",
                                                       "rulevisCorr_gaussdecorr" };

   const TString outputName = outfname[type]+"_"+rfdir->GetName();
   //
   TIter rfnext(rfdir->GetListOfKeys());
   TKey *rfkey;
   Double_t rfmax;
   Double_t rfmin;
   Bool_t allEmpty=kTRUE;
   Bool_t first=kTRUE;
   while ((rfkey = (TKey*)rfnext())) {
      // make sure, that we only look at histograms
      TClass *cl = gROOT->GetClass(rfkey->GetClassName());
      if (!cl->InheritsFrom("TH2F")) continue;
      TH2F *hrf = (TH2F*)rfkey->ReadObj();
      TString hname= hrf->GetName();
      if (hname.Contains("__RF_")){ // found a new RF plot
         Double_t valmin = hrf->GetMinimum();
         Double_t valmax = hrf->GetMaximum();
         if (first) {
            rfmin=valmin;
            rfmax=valmax;
            first = kFALSE;
         } else {
            if (valmax>rfmax) rfmax=valmax;
            if (valmin<rfmin) rfmin=valmin;
         }
         if (hrf->GetEntries()>0) allEmpty=kFALSE;
      }
   }
   if (first) {
      cout << "ERROR: no RF plots found..." << endl;
      return;
   }

   const Int_t nContours = 100;
   Double_t contourLevels[nContours];
   Double_t dcl = (rfmax-rfmin)/Double_t(nContours-1);
   //
   for (Int_t i=0; i<nContours; i++) {
      contourLevels[i] = rfmin+dcl*Double_t(i);
   }

   ///////////////////////////
   vardir->cd();
 
   // how many plots are in the directory?
   Int_t noPlots = ((vardir->GetListOfKeys())->GetEntries()) / 2;
 
   // define Canvas layout here!
   // default setting
   Int_t xPad;  // no of plots in x
   Int_t yPad;  // no of plots in y
   Int_t width; // size of canvas
   Int_t height;
   switch (noPlots) {
   case 1:
      xPad = 1; yPad = 1; width = 500; height = 0.7*width; break;
   case 2:
      xPad = 2; yPad = 1; width = 600; height = 0.7*width; break;
   case 3:
      xPad = 3; yPad = 1; width = 900; height = 0.4*width; break;
   case 4:
      xPad = 2; yPad = 2; width = 600; height = width; break;
   default:
      xPad = 3; yPad = 2; width = 800; height = 0.7*width; break;
   }
   Int_t noPad = xPad * yPad ;   

   // this defines how many canvases we need
   const Int_t noCanvas = 1 + (Int_t)((noPlots - 0.001)/noPad);
   TCanvas **c = new TCanvas*[noCanvas];
   for (Int_t ic=0; ic<noCanvas; ic++) c[ic] = 0;

   // counter variables
   Int_t countCanvas = 0;
   Int_t countPad    = 1;

   // loop over all objects in directory
   TIter next(vardir->GetListOfKeys());
   TKey *key;
   TH1F *sigCpy=0;
   TH1F *bgdCpy=0;
   //
   Bool_t first = kTRUE;

   while ((key = (TKey*)next())) {

      // make sure, that we only look at histograms
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TH1")) continue;
      sig = (TH1F*)key->ReadObj();
      TString hname= sig->GetName();

      // check for all signal histograms
      if (hname.Contains("__S")){ // found a new signal plot
         //         sigCpy = new TH1F(*sig);
         // create new canvas
         if ((c[countCanvas]==NULL) || (countPad>noPad)) {
            char cn[20];
            sprintf( cn, "rulehist%d_", countCanvas+1 );
            TString cname(cn);
            cname += rfdir->GetName();
            c[countCanvas] = new TCanvas( cname, maintitle,
                                          countCanvas*50+200, countCanvas*20, width, height ); 
            // style
            c[countCanvas]->Divide(xPad,yPad);
            countPad = 1;
         }       

         // save canvas to file
         TPad *cPad = (TPad *)(c[countCanvas]->GetPad(countPad));
         c[countCanvas]->cd(countPad);
         countPad++;

         // find the corredponding background histo
         TString bgname = hname;
         bgname.ReplaceAll("__S","__B");
         hkey = vardir->GetKey(bgname);
         bgd = (TH1F*)hkey->ReadObj();
         if (bgd == NULL) {
            cout << "ERROR!!! couldn't find backgroung histo for" << hname << endl;
            exit;
         }

         TString rfname = hname;
         rfname.ReplaceAll("__S","__RF");
         TKey *hrfkey = rfdir->GetKey(rfname);
         TH2F *hrf = (TH2F*)hrfkey->ReadObj();
         Double_t wv = hrf->GetMaximum();
         //         if (rfmax>0.0)
         //            hrf->Scale(1.0/rfmax);
         hrf->SetMinimum(rfmin); // make sure it's zero  -> for palette axis
         hrf->SetMaximum(rfmax); // make sure max is 1.0 -> idem
         hrf->SetContour(nContours,&contourLevels[0]);

         // this is set but not stored during plot creation in MVA_Factory
         //         TMVAGlob::SetSignalAndBackgroundStyle( sigK, bgd );
         sig->SetFillStyle(3002);
         sig->SetFillColor(1);
         sig->SetLineColor(1);
         sig->SetLineWidth(2);

         bgd->SetFillStyle(3554);
         bgd->SetFillColor(1);
         bgd->SetLineColor(1);
         bgd->SetLineWidth(2);

         // chop off "signal" 
         TString title(hrf->GetTitle());
         title.ReplaceAll("signal","");

         // finally plot and overlay       
         Float_t sc = 1.1;
         if (countPad==2) sc = 1.3;
         sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
         Double_t smax = sig->GetMaximum();

         if (first) {
            hrf->SetTitle( maintitle );
            first = kFALSE;
         } else {
            hrf->SetTitle( "" );
         }
         hrf->Draw("colz ah");
         TMVAGlob::SetFrameStyle( hrf, 1.2 );

         sig->Draw("same ah");
         bgd->Draw("same ah");
         // draw axis using range [0,smax]
         hrf->GetXaxis()->SetTitle( title );
         hrf->GetYaxis()->SetTitleOffset( 1.30 );
         hrf->GetYaxis()->SetTitle("Events");
         hrf->GetYaxis()->SetLimits(0,smax);
         hrf->Draw("same axis");

         cPad->SetRightMargin(0.13);
         cPad->Update();

         // Draw legend
         if (countPad==2){
            TLegend *legend= new TLegend( cPad->GetLeftMargin(), 
                                          1-cPad->GetTopMargin()-.18, 
                                          cPad->GetLeftMargin()+.4, 
                                          1-cPad->GetTopMargin() );
            legend->AddEntry(sig,"Signal","F");
            legend->AddEntry(bgd,"Background","F");
            legend->Draw("same");
            legend->SetBorderSize(1);
            legend->SetMargin( 0.3 );
            legend->SetFillColor(19);
            legend->SetFillStyle(1);
         } 

         // save canvas to file
         if (countPad > noPad) {
            c[countCanvas]->Update();
            TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 );
            TMVAGlob::imgconv( c[countCanvas], fname );
            //        TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
            countCanvas++;
         }
      }
   }

   if (countPad <= noPad) {
      c[countCanvas]->Update();
      TString fname = Form( "plots/%s_c%i", outputName.Data(), countCanvas+1 );
      TMVAGlob::imgconv( c[countCanvas], fname );
   }
}
//*********************************************************************************
// Start of main function 
// parameters: 
//  * filename         - name of the tree-input file
//  * optionCollSystem - selection of collision system should be either "pp" or 
//		                   "PbPb"
//  * optionTest       - test option will allow not to analyse the full data sample
//                       at first but just 100 events
//  * startCentrality  - gives the starting point of your centrality bin
//  * endCentrality 	  - gives the end point of your centrality bin
//*********************************************************************************
void AnalyseTreeForRAAStudents(TString filename = "MasterClassesTree_LHC10h_Run139036.root", TString optionCollSystem = "PbPb", TString optionTest= "kFALSE", Int_t startCentrality = 0., Int_t endCentrality = 100.){


  //Reset ROOT and connect tree file
  gROOT->Reset();
  StyleSettings();		
  
  gStyle->SetOptStat(1);

	
  cout << "Analysing file " <<  filename.Data() << endl;
  cout << "Collision system chosen: " << optionCollSystem.Data() << endl;
  if (optionCollSystem.CompareTo("PbPb")==0){
    cout << "Centrality chosen between: " << startCentrality << " - " << endCentrality << endl;
  }
  
  TString alice_portal = gSystem->Getenv("ALICE_PORTAL");
  if (alice_portal.IsNull()) {
     printf("ALICE_PORTAL not defined. Exiting.");
     exit(1);
  }
  if (gSystem->AccessPathName(filename)) {
  // Download file from the portal
     TString sfile = Form("%s/eve_files/data/%s", alice_portal.Data(), filename.Data());
     if (!TFile::Cp(sfile,filename, kFALSE)) {
        printf("File %s not available on the ALICE portal", filename.Data());
        exit(1);
     }   
  }
  //*********************************************************************************
  //Attaching the file
  //*********************************************************************************
  TFile *f = new TFile(filename.Data());
   
  //*********************************************************************************
  //Declaration of leaves types for track tree 
  //*********************************************************************************
  Float_t         trackCentrality;  // variable for the centrality in the track tree
  Double_t        trackPt;	    // variable for the transverse momentum of the track

  //*********************************************************************************
  //Declaration of leaves types for event tree
  //*********************************************************************************
  Float_t         eventCentrality;  // variable for the centrality in the event tree
  Int_t           eventMult;	    // variable for the multiplicity in the event
	
  //*********************************************************************************
  // Definition of input trees 
  //*********************************************************************************
  TTree *Track = (TTree*)gDirectory->Get("Track");  // stores track properties
  TTree *Event = (TTree*)gDirectory->Get("Event");  // stores event properties
	
	
  // Set branch addresses for track tree 
  Track->SetBranchAddress("centrality",&trackCentrality);
  Track->SetBranchAddress("trackpt",&trackPt);
  // Set branch addresses for event tree
  Event->SetBranchAddress("nTPCAccepted",&eventMult);
  Event->SetBranchAddress("centrality",&eventCentrality);

  //*********************************************************************************
  // maximum number of files for testing 
  //*********************************************************************************
  ULong64_t nEntriesTest = 1000;
		
  //*********************************************************************************
  // Getting the number of entries in the track tree
  //*********************************************************************************
  ULong64_t nEntriesTrack = Track->GetEntries();
  cout << "You have " << nEntriesTrack << " for the track tree" << endl;
  if (optionTest.CompareTo("kTRUE") == 0){
    cout << "You will at maximum analyse "<< nEntriesTest <<" tracks in the tree for testing "  << endl;
    if (nEntriesTrack > nEntriesTest){
      nEntriesTrack = nEntriesTest;
    }
  }

  //*********************************************************************************
  // Getting the number of entries in the event tree 
  //*********************************************************************************
  ULong64_t nEntriesEvent = Event->GetEntries();
  cout << "You have " << nEntriesEvent << " for the event tree" << endl;
  if (optionTest.CompareTo("kTRUE") == 0){
    cout << "You will at maximum analyse "<< nEntriesTest <<" events in the tree for testing "  << endl;
    if (nEntriesEvent > nEntriesTest){
      nEntriesEvent = nEntriesTest;
    }
  }
  
  //*********************************************************************************
  // Definition of bins in transverse momentum pt, due to steply falling spectrum 
  // and not enough statistics at high pt 
  //*********************************************************************************
  Int_t fNBinsPt = 54; 								 
  Double_t fBinsPt[55] = {0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45,
			  0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
			  1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9,
			  2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8,
			  4, 4.5, 5, 5.5, 6, 6.5, 7, 8, 9, 10, 
			  11, 12, 13, 14, 15};
								 
								 
								 
  //*********************************************************************************
  // Defintion of histograms:
  // * to be filled with trackpt and number of charged tracks in the TPC (TH1*)
  // * correlation between centrality an nTracks TPC (TH2F)							 
  //*********************************************************************************	
								 
  TH1D* htrackPt = new TH1D("htrackPt","track pt",fNBinsPt,fBinsPt);
  TH1F *hNTPC = new TH1F("hNTPC","Number of TPC tracks ",200,0,2000);
  TH2F *hNTPCvsCent = new TH2F("hNTPCvsCent","Number of TPC tracks ",200,0,2000, 100, 0, 100);
	
  //*********************************************************************************
  // Definition of correction histogram in order to normalise for the binwidth in
  // Pt
  //*********************************************************************************
  TH1D* fDeltaPt = new TH1D("deltaPt","",fNBinsPt,fBinsPt);
  for(Int_t iPt=1;iPt<fNBinsPt+1;iPt++){
    fDeltaPt->SetBinContent(iPt,fBinsPt[iPt]-fBinsPt[iPt-1]);
    fDeltaPt->SetBinError(iPt,0);
  }
	
  //*********************************************************************************
  // * Reading the entries form the event tree (extract nTracksTPC) and filling 
  //   it in the multiplicity histograms (hNTPC,hNTPCvsCent)
  // * Distinction between PbPb and pp as for PbPb you need to fill them with 
  //   restriction in centrality
  // * nEntriesPerCent will give you the normalization value for the different 
  //	  centralities
  //*********************************************************************************

  ULong_t nEntriesPerCent= 0;
  ULong64_t nbytes2 = 0;
  for (ULong_t i=0; i<nEntriesEvent;i++) {
    nbytes2 += Event->GetEvent(i);
    if (eventCentrality > startCentrality && eventCentrality < endCentrality){
      hNTPC->Fill(eventMult);
      hNTPCvsCent->Fill(eventMult,eventCentrality);
      nEntriesPerCent++;
    }
    // give an output for every 10Mio events processed to see that is working 
    if ( i%10000000 == 0 ) {
      cout << i/10000000 << " * 10^7 events have been processed" << endl;
    }
  }

	
  //*********************************************************************************
  // * Reading the entries form the track tree (extract pt values) and filling it 
  //   in the pt-histogram
  // * Distinction between PbPb and pp as for PbPb you need to fill them with 
  //   restriction in centrality
  //*********************************************************************************
  ULong64_t nbytes = 0;
  cout << nEntriesTrack/100000000 << " * 10^8 tracks have to be processed" << endl;
  for (ULong_t i=0; i<nEntriesTrack;i++) {
    nbytes += Track->GetEvent(i);
    /// To do: here you need to add something

		
		
		
		
		
		
		
		
		
		
  }

	
  //*********************************************************************************
  //	Definition of canvas
  //*********************************************************************************
  TCanvas *c1 = new TCanvas("c1","Pt");
  TCanvas *c2 = new TCanvas("c2","nTracksTPC");
  TCanvas *c3 = new TCanvas("c3","nTracksTPCvsCent");
  //*********************************************************************************
  // * Axis labeling for multiplicity histogram and plotting it to an eps file with
  //   the name dependent on the collision system and centrality
  //*********************************************************************************
  hNTPC->Sumw2();
  hNTPC->GetYaxis()->SetTitleOffset(1.3);
  hNTPC->Scale(1./nEntriesPerCent);
  hNTPC->SetXTitle("number TPC tracks");
  hNTPC->SetYTitle("Counts/N_{evt}");	
  c2->cd();
  c2->SetLogy(1);
  HistoSetMarkerAndColor( hNTPC, 20, 1., kBlue, kBlue );
  hNTPC->Draw("e1,p");
  c2->SaveAs(Form("nTracksTPC_%i-%i.eps",startCentrality,endCentrality));	
  
  
  hNTPCvsCent->SetXTitle("number TPC tracks");
  hNTPCvsCent->SetYTitle("Centrality");
  hNTPCvsCent->GetYaxis()->SetTitleOffset(1.3);
  c3->cd(); 
  c3->SetLogy(0);
  c3->SetLogz(1);
  c3->SetRightMargin(0.1);
  hNTPCvsCent->Draw("colz");
  c3->SaveAs(Form("nTracksTPCvsCent_%i-%i.eps",startCentrality,endCentrality));	

	
	
  //*********************************************************************************
  // * Normalisation of the pt-histogram to the number of entries in this 
  //   centrality bin and to the bin with in pt by deviding through the created 
  //   histogram for deltaPt (fDeltaPt)
  // * Labeling of the histograms and plotting it to an eps file with the name
  //   dependent on the collision system and the centralities
  //*********************************************************************************
  cout << "Entries total: " << nEntriesEvent << "\t Entries per Centrality: "  << nEntriesPerCent << endl;
  
  /// To do:The following commands need to be uncommented and you need to add the plotting of the 
  ///        pt-histogram, don't forget to label your axis.
  
  //htrackPt->Sumw2();
  //htrackPt->Divide(fDeltaPt);
  //htrackPt->Scale(1./nEntriesPerCent);
  //htrackPt->GetYaxis()->SetTitleOffset(1.3);
  
	
	
	
	
	
	
	
	
	
   
	
  //*********************************************************************************
  // Saving the histograms to a root-file for further processing for the RAA 
  // * the option "UPDATE" in the end will allow to save different centrality classes
  //   in one file as it just creates the file vom scratch if it is non existent
  //   and just overwrites the histograms which are written if it exists
  //*********************************************************************************
	
  TFile* fileOutput = new TFile("RAABaseOutput.root","UPDATE");
  hNTPC->Write(Form("nTracksTPC_%s_%i-%i",optionCollSystem.Data(),startCentrality,endCentrality),TObject::kOverwrite);
  /// To do: uncomment this as soon as you are ready 
  // 		htrackPt->Write(Form("trackPt_%s_%i-%i",optionCollSystem.Data(),startCentrality,endCentrality),TObject::kOverwrite);
  fileOutput->Write();
  fileOutput->Close();

	
	
}
Exemplo n.º 12
0
void plot_efficiencies( TFile* file, Int_t type = 2, TDirectory* BinDir=0)
{
   // input:   - Input file (result from TMVA),
   //          - type = 1 --> plot efficiency(B) versus eff(S)
   //                 = 2 --> plot rejection (B) versus efficiency (S)
   //                 = 3 --> plot 1/eff(B) versus efficiency (S)

   Bool_t __PLOT_LOGO__  = kTRUE;
   Bool_t __SAVE_IMAGE__ = kTRUE;

   // the coordinates
   Float_t x1 = 0;
   Float_t x2 = 1;
   Float_t y1 = 0;
   Float_t y2 = 0.8;

   // reverse order if "rejection"
   if (type == 2) {
      Float_t z = y1;
      y1 = 1 - y2;
      y2 = 1 - z;
      //      cout << "--- type==2: plot background rejection versus signal efficiency" << endl;
   } else if (type == 3) {
      y1 = 0;
      y2 = -1; // will be set to the max found in the histograms

   } else {
      //  cout << "--- type==1: plot background efficiency versus signal efficiency" << endl;
   }
   // create canvas
   TCanvas* c = new TCanvas( "c", "the canvas", 200, 0, 650, 500 );

   // global style settings
   c->SetGrid();
   c->SetTicks();

   // legend
   Float_t x0L = 0.107,     y0H = 0.899;
   Float_t dxL = 0.457-x0L, dyH = 0.22;
   if (type == 2) {
      x0L = 0.15;
      y0H = 1 - y0H + dyH + 0.07;
   }
   TLegend *legend = new TLegend( x0L, y0H-dyH, x0L+dxL, y0H );
   //legend->SetTextSize( 0.05 );
   legend->SetHeader( "MVA Method:" );
   legend->SetMargin( 0.4 );

   TString xtit = "Signal efficiency";
   TString ytit = "Background efficiency";
   if (type == 2) ytit = "Background rejection";
   if (type == 3) ytit = "1/(Background eff.)";
   TString ftit = ytit + " versus " + xtit;

   TString hNameRef = "effBvsS";
   if (type == 2) hNameRef = "rejBvsS";
   if (type == 3) hNameRef = "invBeffvsSeff";


   if (TString(BinDir->GetName()).Contains("multicut")){
      ftit += "  Bin: ";
      ftit += (BinDir->GetTitle());
   }

   TList xhists;
   TList xmethods;
   UInt_t xnm = TMVAGlob::GetListOfMethods( xmethods );
   TIter xnext(&xmethods);
   // loop over all methods
   TKey *xkey;
   while ((xkey = (TKey*)xnext())) {
      TDirectory * mDir = (TDirectory*)xkey->ReadObj();
      TList titles;
      UInt_t ninst = TMVAGlob::GetListOfTitles(mDir,titles);
      TIter nextTitle(&titles);
      TKey *titkey;
      TDirectory *titDir;
      while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
         titDir = (TDirectory *)titkey->ReadObj();
         TString methodTitle;
         TMVAGlob::GetMethodTitle(methodTitle,titDir);
         TIter nextKey( titDir->GetListOfKeys() );
         TKey *hkey2;
         while ((hkey2 = TMVAGlob::NextKey(nextKey,"TH1"))) {
            TH1 *h = (TH1*)hkey2->ReadObj();
            TString hname = h->GetName();
            if (hname.Contains( hNameRef ) && hname.BeginsWith( "MVA_" )) {
               if (type==3 && h->GetMaximum() > y2) y2 = h->GetMaximum();
            }
         }
      }
   }


   // draw empty frame
   if(gROOT->FindObject("frame")!=0) gROOT->FindObject("frame")->Delete();
   TH2F* frame = new TH2F( "frame", ftit, 500, x1, x2, 500, y1, y2 );
   frame->GetXaxis()->SetTitle( xtit );
   frame->GetYaxis()->SetTitle( ytit );
   TMVAGlob::SetFrameStyle( frame, 1.0 );

   frame->Draw();

   Int_t color = 1;
   Int_t nmva  = 0;
   TKey *key, *hkey;

   TList hists;
   TList methods;
   UInt_t nm = TMVAGlob::GetListOfMethods( methods );
   //   TIter next(file->GetListOfKeys());
   TIter next(&methods);

   // loop over all methods
   while ((key = (TKey*)next())) {
      TDirectory * mDir = (TDirectory*)key->ReadObj();
      TList titles;
      UInt_t ninst = TMVAGlob::GetListOfTitles(mDir,titles);
      TIter nextTitle(&titles);
      TKey *titkey;
      TDirectory *titDir;
      while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
         titDir = (TDirectory *)titkey->ReadObj();
         TString methodTitle;
         TMVAGlob::GetMethodTitle(methodTitle,titDir);
         TIter nextKey( titDir->GetListOfKeys() );
         TKey *hkey2;
         while ((hkey2 = TMVAGlob::NextKey(nextKey,"TH1"))) {
            TH1 *h = (TH1*)hkey2->ReadObj();
            TString hname = h->GetName();
            if (hname.Contains( hNameRef ) && hname.BeginsWith( "MVA_" )) {
               h->SetLineWidth(3);
               h->SetLineColor(color);
               color++; if (color == 5 || color == 10 || color == 11) color++;
               h->Draw("csame");
               hists.Add(h);
               nmva++;
            }
         }
      }
   }

   while (hists.GetSize()) {
      TListIter hIt(&hists);
      TH1* hist(0);
      Double_t largestInt=-1;
      TH1* histWithLargestInt(0);
      while ((hist = (TH1*)hIt())!=0) {
         Double_t integral = hist->Integral(1,hist->FindBin(0.9999));
         if (integral>largestInt) {
            largestInt = integral;
            histWithLargestInt = hist;
         }
      }
      if (histWithLargestInt == 0) {
         cout << "ERROR - unknown hist \"histWithLargestInt\" --> serious problem in ROOT file" << endl;
         break;
      }
      legend->AddEntry(histWithLargestInt,TString(histWithLargestInt->GetTitle()).ReplaceAll("MVA_",""),"l");
      hists.Remove(histWithLargestInt);
   }

   // rescale legend box size
   // current box size has been tuned for 3 MVAs + 1 title
   if (type == 1) {
      dyH *= (1.0 + Float_t(nmva - 3.0)/4.0);
      legend->SetY1( y0H - dyH );
   }
   else {
      dyH *= (Float_t(TMath::Min(10,nmva) - 3.0)/4.0);
      legend->SetY2( y0H + dyH);
   }

   // redraw axes
   frame->Draw("sameaxis");
   legend->Draw("same");

   // ============================================================

   if (__PLOT_LOGO__) TMVAGlob::plot_logo();

   // ============================================================

   c->Update();

   TString fname = "plots/" + hNameRef;
   if (TString(BinDir->GetName()).Contains("multicut")){
      TString fprepend(BinDir->GetName());
      fprepend.ReplaceAll("multicutMVA_","");
      fname = "plots/" + fprepend + "_" + hNameRef;
   }
   if (__SAVE_IMAGE__) TMVAGlob::imgconv( c, fname );

   return;
}
Exemplo n.º 13
0
void LxyVsReconstructed() {

	TCanvas *canvas = new TCanvas("Reconstruction of Lxy","Graph2D example",0,0,800,800);
  
  gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");
  gStyle->SetPalette(1);


  Float_t minPt = 350.;
  Float_t maxPt = 1000.;
  Float_t minTrkPt = 0.9;
  Float_t maxEta = 2.1;
  Float_t bEff = 0.70;

	TH2F * LxVsReco = new TH2F("", "", 1000, 0., 100, 1000, 0., 100);
  	LxVsReco->SetTitle("Vertex reconstruction on X axis");
  	LxVsReco->GetXaxis()->SetTitle("Truth level distance from IP on x [mm]");
  	LxVsReco->GetYaxis()->SetTitle("Reconstructed/Truth level distance from the IP");
  	
  TH2F * LyVsReco = new TH2F("", "", 1000, 0., 100, 1000, 0., 100);
  	LyVsReco->SetTitle("Vertex reconstruction on Y axis");
  	LyVsReco->GetXaxis()->SetTitle("Truth level distance from IP on y [mm]");
  	LyVsReco->GetYaxis()->SetTitle("Reconstructed/Truth level distance from the IP");
  	
  TH2F * LxyVsReco = new TH2F("", "", 1000, 0., 50, 1000, 0., 50);
  	LxyVsReco->SetTitle("Vertex reconstruction on XY plane");
  	LxyVsReco->GetXaxis()->SetTitle("Truth level distance from IP on transverse plane [mm]");
  	LxyVsReco->GetYaxis()->SetTitle("Reconstructed level distance from IP on transverse plane [mm]");
	
	////////////////////////////
  // TREE READER
  
  TFile *myStdFile = TFile::Open("flav_Akt4EMTo_tt_Std.root");
  TTreeReader myStdReader("bTag_AntiKt4EMTopoJets", myStdFile);
  
  TTreeReaderValue<vector<float> > jetPt(myStdReader, "jet_pt");
  TTreeReaderValue<vector<float> > jetEta(myStdReader, "jet_eta");
  TTreeReaderValue<vector<float> > jetPhi(myStdReader, "jet_phi");
  TTreeReaderValue<vector<int> >   jetFlav(myStdReader, "jet_truthflav");
  TTreeReaderValue<vector<float> > secVertB(myStdReader, "bH_Lxy");
  TTreeReaderValue<vector<float> > secVertC(myStdReader, "cH_Lxy");
	TTreeReaderValue<vector<vector<float> > >  jetSV0X(myStdReader, "jet_sv0_vtx_x");
  TTreeReaderValue<vector<vector<float> > >  jetSV0Y(myStdReader, "jet_sv0_vtx_y");
  TTreeReaderValue<vector<vector<float> > >  jetSV0Z(myStdReader, "jet_sv0_vtx_z");
  TTreeReaderValue<vector<float> > bHX(myStdReader, "bH_x");
  TTreeReaderValue<vector<float> > bHY(myStdReader, "bH_y");
  TTreeReaderValue<vector<float> > bHZ(myStdReader, "bH_z");
  
  while (myStdReader.Next()) {
  
  	for(int ij = 0; ij < jetPt->size(); ij++){
  		
  		if(bHX->at(ij) > -600) {
  			for(int iv = 0; iv < jetSV0X->at(ij).size(); iv++) {
  				LxVsReco->Fill(bHX->at(ij), jetSV0X->at(ij).at(iv));
  			}
  		}
  			
  		if(bHY->at(ij) > -600) {
  			for(int iv = 0; iv < jetSV0Y->at(ij).size(); iv++) {
  				LyVsReco->Fill(bHY->at(ij), jetSV0Y->at(ij).at(iv));
  			}
  		}
  			
  		if(secVertB->at(ij) >= 0) {
  			for(int iv = 0; iv < jetSV0X->at(ij).size(); iv++) {
  				Float_t distance = sqrt(jetSV0X->at(ij).at(iv)*jetSV0X->at(ij).at(iv) + jetSV0Y->at(ij).at(iv)*jetSV0Y->at(ij).at(iv));
  				LxyVsReco->Fill(bHX->at(ij), distance);
  			}
  		}
  	}
  }

  //LxVsReco->Draw("colz");
  //LyVsReco->Draw("colz");
  LxyVsReco->Draw("colz");
}
Exemplo n.º 14
0
void makeZZPlot(){

  const unsigned int n = 15;
  float x[n];
  float y1[n];
  float y2[n];

  x[0] =130;  y1[0] =27952;  y2[0] =3057;                 
  x[1] =150;  y1[1] = 2951;  y2[1] =1702;              
  x[2] =170;  y1[2] =  993;  y2[2] = 994;           
  x[3] =190;  y1[3] =  501;  y2[3] = 617;        
  x[4] =210;  y1[4] =  348;  y2[4] = 398;     
  x[5] =230;  y1[5] =  287;  y2[5] = 264;  
  x[6] =250;  y1[6] =  240;  y2[6] = 182;
  x[7] =270;  y1[7] =  204;  y2[7] = 128;
  x[8] =290;  y1[8] =  197;  y2[8] =  91;
  x[9] =310;  y1[9] =  179;  y2[9] =  67;
  x[10]=330;  y1[10]=  164;  y2[10]=  49;
  x[11]=350;  y1[11]=  159;  y2[11]=  37;
  x[12]=370;  y1[12]=  152;  y2[12]=  28;
  x[13]=390;  y1[13]=  149;  y2[13]=  21;
  x[14]=410;  y1[14]=  142;  y2[14]=  17;
	   
  TGraph* g1 = new TGraph(n,x,y2);
  TGraph* g2 = new TGraph(n,x,y1);

  TCanvas *c1 = new TCanvas();
  gPad->SetTopMargin(0.1);
  gPad->SetRightMargin(0.05);
  //gPad->SetLogy();
  gPad->SetGridx();
  gPad->SetGridy();

  TH2F* hdummy = new TH2F("hdummy","",100,130,410,100,0,5000);
  hdummy->Draw();

  c1->cd();
  g1->SetLineColor(4);
  g2->SetLineColor(2);
  g1->SetLineWidth(2);
  g2->SetLineWidth(5);
  g2->SetLineStyle(2);

  hdummy->GetXaxis()->SetTitle("m_{#chi} [GeV]");
  hdummy->GetYaxis()->SetTitle("#sigma #times BR [fb]");
  hdummy->GetYaxis()->SetLabelSize(0.04);
  hdummy->GetXaxis()->SetLabelSize(0.04);

  TBox* box = new TBox();
  //box->SetBorderStyle(2);
  //box->SetBorderSize(1);
  //box->SetFillColor(5);
  //box->SetFillStyle(3002);
  box->DrawBox(171,0,221,5000);
  TLine line;
  line.DrawLine(171,0,171,5000);
  line.DrawLine(221,0,221,5000);

  hdummy->Draw("axissame");
  g1->SetMinimum(0);
  g1->SetMaximum(5000);
  g1->Draw("samec");
  g2->Draw("samel");

  //g1->Draw("Al");
  //g2->Draw("samel");
  
  
  TLegend *leg = new TLegend(0.5,0.6,0.9,0.8);
  leg->AddEntry(g2,"observed UL","l");
  leg->AddEntry(g1,"theory","l");
  leg->AddEntry(box,"excluded region","f");
  leg->SetBorderSize(1);
  leg->SetFillColor(0);
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetNDC();								
  t->SetTextSize(0.04);
  t->DrawLatex(0.18,0.92,"CMS Preliminary       #sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.7 fb^{-1}");
  t->SetTextSize(0.04);
  t->DrawLatex(0.46,0.5,"#chi^{0}#chi^{0} #rightarrow ZZ + E_{T}^{miss}");
  t->SetTextSize(0.038);
  t->DrawLatex(0.46,0.45,"GGMSB Z-enriched higgsino");

  c1->Print("GMSB.pdf");
  c1->Print("GMSB.png");
  c1->Print("GMSB.eps");
  gROOT->ProcessLine(".! ps2pdf GMSB.eps GMSB_ppt.pdf");
}	   
Exemplo n.º 15
0
void jpsiAnalize(TFile* f)
{
	TH2F* h = (TH2F*)f->Get("runLumi");
	std::map<int, std::vector < int > > runs;	
	std::map<int, std::vector < int > >::iterator runsIt;
	int nBinY = h->GetNbinsY();
	int nBinX = h->GetNbinsX();
		
	std::vector <int> lumis;
	double x, y;
	//std::cout << "{";
	double prevY=0;
	double lumicount=0;
	double lumMax = 0;
	for(int i = 0; i < nBinX + 4 ;++i)
	{
		prevY=0.0;
		double runcounter = 0;
		//x = h->GetXaxis()->GetBinCenter(i);
		//std::cout << "\""<<x<<"\":[";
		double candcounter=0.;
		for(int j = 0; j< nBinY + 4; ++j)
			{
			
				int bin = h->GetBin(i,j);
				double cont = h->GetBinContent(bin);
			
				x = h->GetXaxis()->GetBinCenter(i);
				candcounter +=cont;
			
				if(cont>0.0)
				{	
					runcounter++;					
					runs[int(x)] = lumis; 
					y = h->GetYaxis()->GetBinCenter(j);	
					if(prevY<y-1 && prevY!=0.0)
					std::cout << x << " " << y << " " << prevY <<std::endl;
					prevY=y;
				}
							
			}
		//std::cout<<"], ";
		if(runcounter >0.0)		
		std::cout << x <<" -> run counter " << runcounter << " -> cand counter :" << candcounter <<std::endl; 
		lumMax = std::max(lumMax,runcounter);
	}
	//std::cout<<"}";
	
	for(int i = 0; i < nBinX + 4 ;++i)
	{
		 for(int j = 0; j< nBinY + 4; ++j)
		 {
			 x = h->GetXaxis()->GetBinCenter(i) ;
			 int bin = h->GetBin(i,j);
			 double cont = h->GetBinContent(bin);
		 	 if(cont>0.0)
			 {
				 y = h->GetYaxis()->GetBinCenter(j);  
				 runs[int(x)].push_back(int(y));
				 ++lumicount;
			 }

		 }
	}

	std::cout << "{";	
	for(runsIt=runs.begin();runsIt!=runs.end();runsIt++)
	{

		std::cout << "\""<<runsIt->first<<"\":[";
		int prevLum=0;
		for(int k = 0; k<runsIt->second.size();k++)
		{
			if(k==0)
			{
				std::cout<<"[";
				std::cout<<(runsIt->second)[k]<<", ";	
			
				if(k==runsIt->second.size()-1)
			                        {
					                                std::cout<<(runsIt->second)[k]<<"]";
							                        }

			}
			else
			if(!((runsIt->second)[k]==prevLum+1))
			{
				std::cout<<prevLum<<"], ["<<(runsIt->second)[k]<<", ";		
				if(k==runsIt->second.size()-1)
				{
					std::cout<<(runsIt->second)[k]<<"]";
				}
				
			}
			else
			{
				if(k==runsIt->second.size()-1)
					                                {
										                                        std::cout<<(runsIt->second)[k]<<"]";
															                                }
			}

			

			prevLum = (runsIt->second)[k];
		}	
			
		
		std::cout << "], ";
	}
	std::cout<<"}";
	std::cout<<std::endl;
	std::cout<<lumicount<<std::endl;
	std::cout<<lumMax<<std::endl;
}
Exemplo n.º 16
0
void PlotEfficiencyMap(const string Label = "") 
{  
  gBenchmark->Start("HZZTemplate");
  string label = Label;
  if (Label != "") label = "_" + Label;

  //--------------------------------------------------------------------------------------------------------------
  // Settings 
  //==============================================================================================================

  //********************************************************
  // Create Arrays to store the map
  //********************************************************
   const UInt_t NPtBins = 15; 
   const UInt_t NEtaBins = 16;
   const UInt_t NPhiBins = 12;
   double ptBins[NPtBins+1] = { 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 50};
   double etaBins[NEtaBins+1] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4442, 1.566, 1.8, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6};
   double phiBins[NPhiBins+1] = { -3.2, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5,  2, 2.5, 3.2 };

   TH2F *ElectronEfficiencyMap = new TH2F("ElectronEfficiencyMap", ";p_{T} [GeV/c];#eta;Efficiency", 50, 0, 100, 50, 0, 2.5);
   TH2F *MuonEfficiencyMap = new TH2F("MuonEfficiencyMap", ";p_{T} [GeV/c];|#eta|;Efficiency", 50, 0, 100, 50, 0, 2.5);

   for (int i=0; i<ElectronEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
     for (int j=0; j<ElectronEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
       double x = ElectronEfficiencyMap->GetXaxis()->GetBinCenter(i);
       double y = ElectronEfficiencyMap->GetYaxis()->GetBinCenter(j);

       double weightModifier = 1.0;
       if (x < 8) weightModifier = 1.25;
       if (x>= 8 && x < 10) weightModifier = 1.03;
       if (x >= 10 &&  x < 16) weightModifier = 1.02;
       if (x >= 16 &&  x < 20) weightModifier = 1.01;
       if (x >= 20 &&  x < 40) weightModifier = 0.975;
       if (x >= 40 ) weightModifier = 0.97;

       ElectronEfficiencyMap->SetBinContent(i,j, weightModifier*GetElectronEfficiencyPtEta(x,y));
       //cout << x << " " << y << " : " << weightModifier*GetElectronEfficiencyPtEta(x,y) << "\n";

     }
   }

   for (int i=0; i<MuonEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
     for (int j=0; j<MuonEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
       double x = MuonEfficiencyMap->GetXaxis()->GetBinCenter(i);
       double y = MuonEfficiencyMap->GetYaxis()->GetBinCenter(j);

       double weightModifier = 1.0;
       if (x < 6) weightModifier *= 1.15;
       if (x >= 6 && x < 7) weightModifier *= 1.05;
       if (x >= 7 && x < 10) weightModifier *= 1.015;
       if (x >= 10 &&  x < 20) weightModifier *= 1.015;
       if (x >= 20 &&  x < 40) weightModifier *= 1.00;
       if (x >= 40 ) weightModifier *= 0.985;

       MuonEfficiencyMap->SetBinContent(i,j, weightModifier*GetMuonEfficiencyPtEta(x,y));
       //cout << x << " " << y << " : " << weightModifier*GetMuonEfficiencyPtEta(x,y) << "\n";

     }
   }


   TCanvas *cv = new TCanvas("cv","cv", 800, 600);
   cv->SetRightMargin(0.15);
   ElectronEfficiencyMap->SetMinimum(0.5);
   ElectronEfficiencyMap->Draw("colz");
   cv->SaveAs("ElectronEfficiencyMap.gif");


   cv = new TCanvas("cv","cv", 800, 600);
   cv->SetRightMargin(0.15);
   MuonEfficiencyMap->SetMinimum(0.5);
   MuonEfficiencyMap->Draw("colz");
   cv->SaveAs("MuonEfficiencyMap.gif");

} 
Exemplo n.º 17
0
void MakePlots(TString filename, TString energy="8TeV", TString lumi=""){
  TString outDir=filename; outDir.ReplaceAll("fitres","img");
  outDir="tmp/";
  //std::map<TString, TH2F *> deltaNLL_map;
  
  /*------------------------------ Plotto */
  TCanvas *c = new TCanvas("c","c");
  
  TFile f_in(filename, "read");
  if(f_in.IsZombie()){
    std::cerr << "File opening error: " << filename << std::endl;
    return;
  }
  
  TList *KeyList = f_in.GetListOfKeys();
  std::cout << KeyList->GetEntries() << std::endl;
  for(int i =0; i <  KeyList->GetEntries(); i++){
    c->Clear();
    TKey *key = (TKey *)KeyList->At(i);
    if(TString(key->GetClassName())!="RooDataSet") continue;
    RooDataSet *dataset = (RooDataSet *) key->ReadObj();
    
    TString constTermName = dataset->GetName();
    TString alphaName=constTermName; alphaName.ReplaceAll("constTerm","alpha");

    TTree *tree = dataset2tree(dataset);
    TGraphErrors bestFit_ = bestFit(tree, alphaName, constTermName);
    TH2F *hist = prof2d(tree, alphaName, constTermName, "nll", "(12,-0.0005,0.0115,29,-0.0025,0.1425)",true);

//     //    deltaNLL_map.insert(std::pair <TString, TH2F *>(keyName,hist));
    hist->SaveAs(outDir+"/deltaNLL-"+constTermName+".root");
    hist->Draw("colz");
    bestFit_.Draw("P same");
    bestFit_.SetMarkerSize(2);

    Int_t iBinX, iBinY;
    Double_t x,y;
    hist->GetBinWithContent2(0,iBinX,iBinY);
    x= hist->GetXaxis()->GetBinCenter(iBinX);
    y= hist->GetYaxis()->GetBinCenter(iBinY);
    TGraph nllBestFit(1,&x,&y);

    nllBestFit.SetMarkerStyle(3);
    nllBestFit.SetMarkerColor(kRed);
    TList* contour68 = contourFromTH2(hist, 0.68);

    hist->Draw("colz");
    hist->GetZaxis()->SetRangeUser(0,50);
    bestFit_.Draw("P same");
    nllBestFit.Draw("P same");
    //contour68->Draw("same");
    c->SaveAs(outDir+"/deltaNLL-"+constTermName+".png");
    hist->SaveAs("tmp/hist-"+constTermName+".root");
    nllBestFit.SaveAs("tmp/nllBestFit.root");
    contour68->SaveAs("tmp/contour68.root");
    delete hist;
    hist = prof2d(tree, alphaName, constTermName, "nll", "(12,-0.0005,0.0115,29,-0.0025,0.1425)");
    RooHistPdf *histPdf = nllToL(hist);
    delete hist;
    RooDataSet *gen_dataset=histPdf->generate(*histPdf->getVariables(),1000000,kTRUE,kFALSE);
    TTree *genTree = dataset2tree(gen_dataset);
    genTree->SaveAs("tmp/genTree-"+constTermName+".root");
    delete gen_dataset;
    delete histPdf;
    
    TGraphErrors toyGraph = g(genTree, constTermName);
    TGraphErrors bestFitGraph = g(tree,alphaName, constTermName);
    TGraphErrors bestFitScanGraph = g(y, x);
    delete genTree;
    delete tree;
    toyGraph.SetFillColor(kGreen);
    toyGraph.SetLineColor(kBlue);
    toyGraph.SetLineStyle(2);
    bestFitGraph.SetLineColor(kBlack);
    bestFitScanGraph.SetLineColor(kRed);
    bestFitScanGraph.SetLineWidth(2);


    
    TMultiGraph g_multi("multigraph","");
    g_multi.Add(&toyGraph,"L3");
    g_multi.Add(&toyGraph,"L");
    g_multi.Add(&bestFitGraph, "L");
    g_multi.Add(&bestFitScanGraph, "L");
   
    g_multi.Draw("A");

    c->Clear();
    g_multi.Draw("A");
    c->SaveAs(outDir+"/smearing_vs_energy-"+constTermName+".png");

    //    TPaveText *pv = new TPaveText(0.7,0.7,1, 0.8);    
//     TLegend *legend = new TLegend(0.7,0.8,0.95,0.92);
//     legend->SetFillStyle(3001);
//     legend->SetFillColor(1);
//     legend->SetTextFont(22); // 132
//     legend->SetTextSize(0.04); // l'ho preso mettendo i punti con l'editor e poi ho ricavato il valore con il metodo GetTextSize()
//   //  legend->SetFillColor(0); // colore di riempimento bianco
//     legend->SetMargin(0.4);  // percentuale della larghezza del simbolo
    //    SetLegendStyle(legend);
	
    //Plot(c, data,mc,mcSmeared,legend, region, filename, energy, lumi);
  }
  
  f_in.Close();
  
  return;
}
Exemplo n.º 18
0
void mass4Chan(){
//=========Macro generated from canvas: ccc/
//=========  (Thu Mar  7 22:11:11 2013) by ROOT version5.34/03
   TCanvas *ccc = new TCanvas("ccc", "",0,0,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   ccc->Range(86.5625,-1.875,92.8125,10.625);
   ccc->SetFillColor(0);
   ccc->SetBorderMode(0);
   ccc->SetBorderSize(2);
   ccc->SetLeftMargin(0.15);
   ccc->SetRightMargin(0.05);
   ccc->SetTopMargin(0.05);
   ccc->SetBottomMargin(0.15);
   ccc->SetFrameFillStyle(0);
   ccc->SetFrameBorderMode(0);
   ccc->SetFrameFillStyle(0);
   ccc->SetFrameBorderMode(0);
   
  

   
   TH2F *hframe = new TH2F("hframe","",100,85,96,100,0,10);
   hframe->SetLineStyle(0);
   hframe->SetMarkerStyle(20);
   hframe->GetXaxis()->SetTitle(" m_{Z} (GeV)");
   hframe->GetXaxis()->SetNdivisions(510);
   hframe->GetXaxis()->SetLabelFont(42);
   hframe->GetXaxis()->SetLabelOffset(0.01);
   hframe->GetXaxis()->SetLabelSize(0.05);
   hframe->GetXaxis()->SetTitleSize(0.05);
   hframe->GetXaxis()->SetTitleOffset(1.15);
   hframe->GetXaxis()->SetTitleFont(42);
   hframe->GetYaxis()->SetTitle(" -2#Delta ln L");
   hframe->GetYaxis()->SetLabelFont(42);
   hframe->GetYaxis()->SetLabelOffset(0.01);
   hframe->GetYaxis()->SetLabelSize(0.05);
   hframe->GetYaxis()->SetTitleSize(0.05);
   hframe->GetYaxis()->SetTitleOffset(1.4);
   hframe->GetYaxis()->SetTitleFont(42);
   hframe->GetZaxis()->SetLabelFont(42);
   hframe->GetZaxis()->SetLabelOffset(0.007);
   hframe->GetZaxis()->SetLabelSize(0.045);
   hframe->GetZaxis()->SetTitleSize(0.05);
   hframe->GetZaxis()->SetTitleFont(42);
   hframe->Draw("");
   
   //4e
   TGraph *graph = new TGraph(211);
   graph->SetName("Graph");
   graph->SetTitle("Graph");
   graph->SetLineColor(kGreen+1);
   graph->SetLineWidth(3);
   graph->SetMarkerStyle(20);
   graph->SetPoint(0,88.01999664,7.234320164);
   graph->SetPoint(1,88.05999756,7.121326923);
   graph->SetPoint(2,88.09999847,7.008939743);
   graph->SetPoint(3,88.13999939,6.897168636);
   graph->SetPoint(4,88.18000031,6.786022186);
   graph->SetPoint(5,88.22000122,6.67550993);
   graph->SetPoint(6,88.26000214,6.565642357);
   graph->SetPoint(7,88.30000305,6.456428051);
   graph->SetPoint(8,88.33999634,6.347877979);
   graph->SetPoint(9,88.37999725,6.240002632);
   graph->SetPoint(10,88.41999817,6.1328125);
   graph->SetPoint(11,88.45999908,6.026317596);
   graph->SetPoint(12,88.5,5.920529366);
   graph->SetPoint(13,88.54000092,5.815458775);
   graph->SetPoint(14,88.58000183,5.711116314);
   graph->SetPoint(15,88.62000275,5.607512951);
   graph->SetPoint(16,88.66000366,5.504659653);
   graph->SetPoint(17,88.69999695,5.402567387);
   graph->SetPoint(18,88.73999786,5.301246643);
   graph->SetPoint(19,88.77999878,5.200707436);
   graph->SetPoint(20,88.81999969,5.100960732);
   graph->SetPoint(21,88.81999969,5.100960732);
   graph->SetPoint(22,88.86000061,5.002016068);
   graph->SetPoint(23,88.90000153,4.903883457);
   graph->SetPoint(24,88.94000244,4.806572437);
   graph->SetPoint(25,88.98000336,4.710093021);
   graph->SetPoint(26,89.01999664,4.614454269);
   graph->SetPoint(27,89.05999756,4.519664764);
   graph->SetPoint(28,89.09999847,4.425733089);
   graph->SetPoint(29,89.13999939,4.332668304);
   graph->SetPoint(30,89.18000031,4.240478516);
   graph->SetPoint(31,89.22000122,4.149171829);
   graph->SetPoint(32,89.26000214,4.058755875);
   graph->SetPoint(33,89.30000305,3.969237804);
   graph->SetPoint(34,89.33999634,3.880625486);
   graph->SetPoint(35,89.37999725,3.792925596);
   graph->SetPoint(36,89.41999817,3.706145048);
   graph->SetPoint(37,89.45999908,3.620290518);
   graph->SetPoint(38,89.5,3.535368204);
   graph->SetPoint(39,89.54000092,3.451384068);
   graph->SetPoint(40,89.58000183,3.368344069);
   graph->SetPoint(41,89.62000275,3.286253691);
   graph->SetPoint(42,89.62000275,3.286253691);
   graph->SetPoint(43,89.66000366,3.205118656);
   graph->SetPoint(44,89.69999695,3.124943733);
   graph->SetPoint(45,89.73999786,3.045734167);
   graph->SetPoint(46,89.77999878,2.967494488);
   graph->SetPoint(47,89.81999969,2.890229225);
   graph->SetPoint(48,89.86000061,2.813942432);
   graph->SetPoint(49,89.90000153,2.738638639);
   graph->SetPoint(50,89.94000244,2.664321423);
   graph->SetPoint(51,89.98000336,2.590994596);
   graph->SetPoint(52,90.01999664,2.518661499);
   graph->SetPoint(53,90.05999756,2.447325468);
   graph->SetPoint(54,90.09999847,2.376989603);
   graph->SetPoint(55,90.13999939,2.307657003);
   graph->SetPoint(56,90.18000031,2.23933053);
   graph->SetPoint(57,90.22000122,2.172012329);
   graph->SetPoint(58,90.26000214,2.105705023);
   graph->SetPoint(59,90.30000305,2.040410995);
   graph->SetPoint(60,90.33999634,1.976132512);
   graph->SetPoint(61,90.37999725,1.912871242);
   graph->SetPoint(62,90.41999817,1.85062921);
   graph->SetPoint(63,90.41999817,1.85062921);
   graph->SetPoint(64,90.45999908,1.789408088);
   graph->SetPoint(65,90.5,1.729209423);
   graph->SetPoint(66,90.54000092,1.670034766);
   graph->SetPoint(67,90.58000183,1.611885428);
   graph->SetPoint(68,90.62000275,1.554762602);
   graph->SetPoint(69,90.66000366,1.498667479);
   graph->SetPoint(70,90.69999695,1.443601012);
   graph->SetPoint(71,90.73999786,1.389564157);
   graph->SetPoint(72,90.77999878,1.336557865);
   graph->SetPoint(73,90.81999969,1.284582734);
   graph->SetPoint(74,90.86000061,1.233639359);
   graph->SetPoint(75,90.90000153,1.183728576);
   graph->SetPoint(76,90.94000244,1.134850621);
   graph->SetPoint(77,90.98000336,1.087006092);
   graph->SetPoint(78,91.01999664,1.040195346);
   graph->SetPoint(79,91.05999756,0.9944185615);
   graph->SetPoint(80,91.09999847,0.9496760368);
   graph->SetPoint(81,91.13999939,0.9059679508);
   graph->SetPoint(82,91.18000031,0.8632944226);
   graph->SetPoint(83,91.22000122,0.8216554523);
   graph->SetPoint(84,91.22000122,0.8216554523);
   graph->SetPoint(85,91.26000214,0.7810510397);
   graph->SetPoint(86,91.30000305,0.7414811254);
   graph->SetPoint(87,91.33999634,0.70294559);
   graph->SetPoint(88,91.37999725,0.6654443145);
   graph->SetPoint(89,91.41999817,0.6289771199);
   graph->SetPoint(90,91.45999908,0.5935436487);
   graph->SetPoint(91,91.5,0.5591436625);
   graph->SetPoint(92,91.54000092,0.5257768631);
   graph->SetPoint(93,91.58000183,0.4934427738);
   graph->SetPoint(94,91.62000275,0.462141037);
   graph->SetPoint(95,91.66000366,0.431871146);
   graph->SetPoint(96,91.69999695,0.4026326835);
   graph->SetPoint(97,91.73999786,0.3744250238);
   graph->SetPoint(98,91.77999878,0.3472476304);
   graph->SetPoint(99,91.81999969,0.3210999072);
   graph->SetPoint(100,91.86000061,0.2959812582);
   graph->SetPoint(101,91.90000153,0.2718909979);
   graph->SetPoint(102,91.94000244,0.2488284409);
   graph->SetPoint(103,91.98000336,0.2267929316);
   graph->SetPoint(104,92.01999664,0.2057837248);
   graph->SetPoint(105,92.01999664,0.2057837248);
   graph->SetPoint(106,92.05999756,0.1858001053);
   graph->SetPoint(107,92.09999847,0.1668412983);
   graph->SetPoint(108,92.13999939,0.1489065737);
   graph->SetPoint(109,92.18000031,0.1319951713);
   graph->SetPoint(110,92.22000122,0.1161063388);
   graph->SetPoint(111,92.26000214,0.1012392938);
   graph->SetPoint(112,92.30000305,0.08739329875);
   graph->SetPoint(113,92.33999634,0.07456759363);
   graph->SetPoint(114,92.37999725,0.06276145577);
   graph->SetPoint(115,92.41999817,0.05197418481);
   graph->SetPoint(116,92.45999908,0.04220509902);
   graph->SetPoint(117,92.5,0.03345353901);
   graph->SetPoint(118,92.54000092,0.02571888082);
   graph->SetPoint(119,92.58000183,0.01900054142);
   graph->SetPoint(120,92.62000275,0.01329800207);
   graph->SetPoint(121,92.66000366,0.008610763587);
   graph->SetPoint(122,92.69999695,0.004938419908);
   graph->SetPoint(123,92.73999786,0.002280603396);
   graph->SetPoint(124,92.77999878,0.0006370125338);
   graph->SetPoint(125,92.81999969,7.419047051e-06);
   //graph->SetPoint(126,92.81999969,7.419047961e-06);
   graph->SetPoint(127,92.82485199,0);
   graph->SetPoint(128,92.82485199,0);
   graph->SetPoint(129,92.82485199,0);
   graph->SetPoint(130,92.82485199,0);
   graph->SetPoint(131,92.82485199,0);
   graph->SetPoint(132,92.82485199,0);
   graph->SetPoint(133,92.82485199,0);
   graph->SetPoint(134,93.05999756,0.01752127893);
   graph->SetPoint(135,93.09999847,0.02399016172);
   graph->SetPoint(136,93.13999939,0.0314742066);
   graph->SetPoint(137,93.18000031,0.03997394815);
   graph->SetPoint(138,93.22000122,0.04949002713);
   graph->SetPoint(139,93.26000214,0.06002314016);
   graph->SetPoint(140,93.30000305,0.07157406956);
   graph->SetPoint(141,93.33999634,0.08414366841);
   graph->SetPoint(142,93.37999725,0.09773286432);
   graph->SetPoint(143,93.41999817,0.1123426482);
   graph->SetPoint(144,93.45999908,0.1279740632);
   graph->SetPoint(145,93.5,0.144628197);
   graph->SetPoint(146,93.54000092,0.1623062044);
   graph->SetPoint(147,93.58000183,0.1810092628);
   graph->SetPoint(148,93.62000275,0.200738579);
   graph->SetPoint(149,93.62000275,0.200738579);
   graph->SetPoint(150,93.66000366,0.2214953899);
   graph->SetPoint(151,93.69999695,0.2432809174);
   graph->SetPoint(152,93.73999786,0.2660964429);
   graph->SetPoint(153,93.77999878,0.2899431586);
   graph->SetPoint(154,93.81999969,0.3148224056);
   graph->SetPoint(155,93.86000061,0.3407353461);
   graph->SetPoint(156,93.90000153,0.367683202);
   graph->SetPoint(157,93.94000244,0.3956672251);
   graph->SetPoint(158,93.98000336,0.4246885478);
   graph->SetPoint(159,94.01999664,0.4547482729);
   graph->SetPoint(160,94.05999756,0.4858476222);
   graph->SetPoint(161,94.09999847,0.5179876089);
   graph->SetPoint(162,94.13999939,0.5511692166);
   graph->SetPoint(163,94.18000031,0.585393548);
   graph->SetPoint(164,94.22000122,0.6206615567);
   graph->SetPoint(165,94.26000214,0.6569740772);
   graph->SetPoint(166,94.30000305,0.6943320632);
   graph->SetPoint(167,94.33999634,0.7327364087);
   graph->SetPoint(168,94.37999725,0.772187829);
   graph->SetPoint(169,94.41999817,0.8126871586);
   graph->SetPoint(170,94.41999817,0.8126871586);
   graph->SetPoint(171,94.45999908,0.8542351723);
   graph->SetPoint(172,94.5,0.8968324661);
   graph->SetPoint(173,94.54000092,0.940479815);
   graph->SetPoint(174,94.58000183,0.985177815);
   graph->SetPoint(175,94.62000275,1.030927062);
   graph->SetPoint(176,94.66000366,1.077728152);
   graph->SetPoint(177,94.69999695,1.125581622);
   graph->SetPoint(178,94.73999786,1.174487948);
   graph->SetPoint(179,94.77999878,1.224447489);
   graph->SetPoint(180,94.81999969,1.27546072);
   graph->SetPoint(181,94.86000061,1.327528);
   graph->SetPoint(182,94.90000153,1.380649686);
   graph->SetPoint(183,94.94000244,1.434825897);
   graph->SetPoint(184,94.98000336,1.490056992);
   graph->SetPoint(185,95.01999664,1.546342969);
   graph->SetPoint(186,95.05999756,1.603683949);
   graph->SetPoint(187,95.09999847,1.66207993);
   graph->SetPoint(188,95.13999939,1.721530676);
   graph->SetPoint(189,95.18000031,1.782036185);
   graph->SetPoint(190,95.22000122,1.843595982);
   graph->SetPoint(191,95.22000122,1.843595982);
   graph->SetPoint(192,95.26000214,1.906209826);
   graph->SetPoint(193,95.30000305,1.969877124);
   graph->SetPoint(194,95.33999634,2.034597158);
   graph->SetPoint(195,95.37999725,2.100369453);
   graph->SetPoint(196,95.41999817,2.167192936);
   graph->SetPoint(197,95.45999908,2.235066652);
   graph->SetPoint(198,95.5,2.30398941);
   graph->SetPoint(199,95.54000092,2.37395978);
   graph->SetPoint(200,95.58000183,2.44497633);
   graph->SetPoint(201,95.62000275,2.517037392);
   graph->SetPoint(202,95.66000366,2.590141296);
   graph->SetPoint(203,95.69999695,2.66428566);
   graph->SetPoint(204,95.73999786,2.739468575);
   graph->SetPoint(205,95.77999878,2.815687418);
   graph->SetPoint(206,95.81999969,2.892939568);
   graph->SetPoint(207,95.86000061,2.971222401);
   graph->SetPoint(208,95.90000153,3.050532341);
   graph->SetPoint(209,95.94000244,3.130866289);
   graph->SetPoint(210,95.98000336,3.212220907);


   graph->Sort();

   cout << "4e: " << graph->Eval(91.1876) << endl;


   //2e2mu
   TGraph *graph1 = new TGraph(211);
   graph1->SetName("Graph1");
   graph1->SetTitle("Graph1");
   graph1->SetFillColor(1);
   graph1->SetLineWidth(3);
   graph1->SetLineColor(kBlue);
   graph1->SetMarkerStyle(20);
   graph1->SetPoint(0,88.01999664,8.795412064);
   graph1->SetPoint(1,88.05999756,8.61370182);
   graph1->SetPoint(2,88.09999847,8.43285656);
   graph1->SetPoint(3,88.13999939,8.252916336);
   graph1->SetPoint(4,88.18000031,8.073918343);
   graph1->SetPoint(5,88.22000122,7.895903111);
   graph1->SetPoint(6,88.26000214,7.718908787);
   graph1->SetPoint(7,88.30000305,7.542974472);
   graph1->SetPoint(8,88.33999634,7.36813879);
   graph1->SetPoint(9,88.37999725,7.194441795);
   graph1->SetPoint(10,88.41999817,7.021921158);
   graph1->SetPoint(11,88.45999908,6.850616932);
   graph1->SetPoint(12,88.5,6.680567265);
   graph1->SetPoint(13,88.54000092,6.51181221);
   graph1->SetPoint(14,88.58000183,6.344389915);
   graph1->SetPoint(15,88.62000275,6.178339481);
   graph1->SetPoint(16,88.66000366,6.013700008);
   graph1->SetPoint(17,88.69999695,5.850510597);
   graph1->SetPoint(18,88.73999786,5.688809872);
   graph1->SetPoint(19,88.77999878,5.528635979);
   graph1->SetPoint(20,88.81999969,5.370028496);
   graph1->SetPoint(21,88.81999969,5.370028496);
   graph1->SetPoint(22,88.86000061,5.21302557);
   graph1->SetPoint(23,88.90000153,5.057665825);
   graph1->SetPoint(24,88.94000244,4.903987885);
   graph1->SetPoint(25,88.98000336,4.752028942);
   graph1->SetPoint(26,89.01999664,4.601828575);
   graph1->SetPoint(27,89.05999756,4.4534235);
   graph1->SetPoint(28,89.09999847,4.306852341);
   graph1->SetPoint(29,89.13999939,4.162151814);
   graph1->SetPoint(30,89.18000031,4.019360065);
   graph1->SetPoint(31,89.22000122,3.87851429);
   graph1->SetPoint(32,89.26000214,3.739651203);
   graph1->SetPoint(33,89.30000305,3.602807283);
   graph1->SetPoint(34,89.33999634,3.468019247);
   graph1->SetPoint(35,89.37999725,3.335323095);
   graph1->SetPoint(36,89.41999817,3.204754591);
   graph1->SetPoint(37,89.45999908,3.076349258);
   graph1->SetPoint(38,89.5,2.950142145);
   graph1->SetPoint(39,89.54000092,2.82616806);
   graph1->SetPoint(40,89.58000183,2.704461336);
   graph1->SetPoint(41,89.62000275,2.58505559);
   graph1->SetPoint(42,89.62000275,2.58505559);
   graph1->SetPoint(43,89.66000366,2.467984438);
   graph1->SetPoint(44,89.69999695,2.353280783);
   graph1->SetPoint(45,89.73999786,2.240977049);
   graph1->SetPoint(46,89.77999878,2.131105185);
   graph1->SetPoint(47,89.81999969,2.023696423);
   graph1->SetPoint(48,89.86000061,1.918781519);
   graph1->SetPoint(49,89.90000153,1.816390634);
   graph1->SetPoint(50,89.94000244,1.716553092);
   graph1->SetPoint(51,89.98000336,1.619297981);
   graph1->SetPoint(52,90.01999664,1.524653077);
   graph1->SetPoint(53,90.05999756,1.432646155);
   graph1->SetPoint(54,90.09999847,1.343303561);
   graph1->SetPoint(55,90.13999939,1.256651402);
   graph1->SetPoint(56,90.18000031,1.17271471);
   graph1->SetPoint(57,90.22000122,1.091517925);
   graph1->SetPoint(58,90.26000214,1.013084531);
   graph1->SetPoint(59,90.30000305,0.9374370575);
   graph1->SetPoint(60,90.33999634,0.864597559);
   graph1->SetPoint(61,90.37999725,0.7945868969);
   graph1->SetPoint(62,90.41999817,0.727425158);
   graph1->SetPoint(63,90.41999817,0.727425158);
   graph1->SetPoint(64,90.45999908,0.6631317139);
   graph1->SetPoint(65,90.5,0.6017247438);
   graph1->SetPoint(66,90.54000092,0.5432218313);
   graph1->SetPoint(67,90.58000183,0.4876395166);
   graph1->SetPoint(68,90.62000275,0.4349934459);
   graph1->SetPoint(69,90.66000366,0.3852983713);
   graph1->SetPoint(70,90.69999695,0.3385681808);
   graph1->SetPoint(71,90.73999786,0.2948157787);
   graph1->SetPoint(72,90.77999878,0.2540532351);
   graph1->SetPoint(73,90.81999969,0.2162916809);
   graph1->SetPoint(74,90.86000061,0.1815413088);
   graph1->SetPoint(75,90.90000153,0.1498114169);
   graph1->SetPoint(76,90.94000244,0.1211103573);
   graph1->SetPoint(77,90.98000336,0.09544557333);
   graph1->SetPoint(78,91.01999664,0.07282357663);
   graph1->SetPoint(79,91.05999756,0.05324992537);
   graph1->SetPoint(80,91.09999847,0.0367292501);
   graph1->SetPoint(81,91.13999939,0.02326522022);
   graph1->SetPoint(82,91.18000031,0.01286056917);
   graph1->SetPoint(83,91.22000122,0.005517064128);
   graph1->SetPoint(84,91.22000122,0.005517064128);
   graph1->SetPoint(85,91.26000214,0.001235519536);
   graph1->SetPoint(86,91.29593658,0);
   graph1->SetPoint(87,91.29593658,0);
   graph1->SetPoint(88,91.29593658,0);
   graph1->SetPoint(89,91.29593658,0);
   graph1->SetPoint(90,91.29593658,0);
   graph1->SetPoint(91,91.29593658,0);
   graph1->SetPoint(92,91.29593658,0);
   graph1->SetPoint(93,91.5,0.03977194428);
   graph1->SetPoint(94,91.54000092,0.05686627701);
   graph1->SetPoint(95,91.58000183,0.07699460536);
   graph1->SetPoint(96,91.62000275,0.1001491994);
   graph1->SetPoint(97,91.66000366,0.1263214052);
   graph1->SetPoint(98,91.69999695,0.1555016339);
   graph1->SetPoint(99,91.73999786,0.1876795292);
   graph1->SetPoint(100,91.77999878,0.2228437364);
   graph1->SetPoint(101,91.81999969,0.260982126);
   graph1->SetPoint(102,91.86000061,0.3020817041);
   graph1->SetPoint(103,91.90000153,0.3461286724);
   graph1->SetPoint(104,91.94000244,0.3931084573);
   graph1->SetPoint(105,91.98000336,0.443005681);
   graph1->SetPoint(106,92.01999664,0.4958042502);
   //graph1->SetPoint(107,92.01999664,0.4958042204);
   graph1->SetPoint(108,92.05999756,0.551487267);
   graph1->SetPoint(109,92.09999847,0.6100373268);
   graph1->SetPoint(110,92.13999939,0.671436131);
   graph1->SetPoint(111,92.18000031,0.7356648445);
   graph1->SetPoint(112,92.22000122,0.802703917);
   graph1->SetPoint(113,92.26000214,0.872533381);
   graph1->SetPoint(114,92.30000305,0.945132494);
   graph1->SetPoint(115,92.33999634,1.020480037);
   graph1->SetPoint(116,92.37999725,1.098554254);
   graph1->SetPoint(117,92.41999817,1.179333091);
   graph1->SetPoint(118,92.45999908,1.262793779);
   graph1->SetPoint(119,92.5,1.348913193);
   graph1->SetPoint(120,92.54000092,1.437667727);
   graph1->SetPoint(121,92.58000183,1.52903378);
   graph1->SetPoint(122,92.62000275,1.622986913);
   graph1->SetPoint(123,92.66000366,1.719502687);
   graph1->SetPoint(124,92.69999695,1.818556309);
   graph1->SetPoint(125,92.73999786,1.920122623);
   graph1->SetPoint(126,92.77999878,2.024176359);
   graph1->SetPoint(127,92.81999969,2.130692005);
   graph1->SetPoint(128,92.81999969,2.130692005);
   graph1->SetPoint(129,92.86000061,2.239643812);
   graph1->SetPoint(130,92.90000153,2.351006031);
   graph1->SetPoint(131,92.94000244,2.464752674);
   graph1->SetPoint(132,92.98000336,2.580857754);
   graph1->SetPoint(133,93.01999664,2.699294806);
   graph1->SetPoint(134,93.05999756,2.820037603);
   graph1->SetPoint(135,93.09999847,2.94306016);
   graph1->SetPoint(136,93.13999939,3.068335533);
   graph1->SetPoint(137,93.18000031,3.195837736);
   graph1->SetPoint(138,93.22000122,3.325540066);
   graph1->SetPoint(139,93.26000214,3.457416296);
   graph1->SetPoint(140,93.30000305,3.591439486);
   graph1->SetPoint(141,93.33999634,3.727583647);
   graph1->SetPoint(142,93.37999725,3.865821838);
   graph1->SetPoint(143,93.41999817,4.006127834);
   graph1->SetPoint(144,93.45999908,4.148474216);
   graph1->SetPoint(145,93.5,4.292835712);
   graph1->SetPoint(146,93.54000092,4.439184189);
   graph1->SetPoint(147,93.58000183,4.587494373);
   graph1->SetPoint(148,93.62000275,4.737738609);
   graph1->SetPoint(149,93.62000275,4.737738609);
   graph1->SetPoint(150,93.66000366,4.889890194);
   graph1->SetPoint(151,93.69999695,5.043922424);
   graph1->SetPoint(152,93.73999786,5.199808598);
   graph1->SetPoint(153,93.77999878,5.357521057);
   graph1->SetPoint(154,93.81999969,5.517033577);
   graph1->SetPoint(155,93.86000061,5.678318024);
   graph1->SetPoint(156,93.90000153,5.841347694);
   graph1->SetPoint(157,93.94000244,6.006094933);
   graph1->SetPoint(158,93.98000336,6.172532082);
   graph1->SetPoint(159,94.01999664,6.340631485);
   graph1->SetPoint(160,94.05999756,6.510365486);
   graph1->SetPoint(161,94.09999847,6.681705952);
   graph1->SetPoint(162,94.13999939,6.854624748);
   graph1->SetPoint(163,94.18000031,7.029093266);
   graph1->SetPoint(164,94.22000122,7.205083847);
   graph1->SetPoint(165,94.26000214,7.382567883);
   graph1->SetPoint(166,94.30000305,7.561516285);
   graph1->SetPoint(167,94.33999634,7.741900921);
   graph1->SetPoint(168,94.37999725,7.923692226);
   graph1->SetPoint(169,94.41999817,8.106862068);
   graph1->SetPoint(170,94.41999817,8.106862068);
   graph1->SetPoint(171,94.45999908,8.291379929);
   graph1->SetPoint(172,94.5,8.477218628);
   graph1->SetPoint(173,94.54000092,8.664347649);
   graph1->SetPoint(174,94.58000183,8.85273838);
   graph1->SetPoint(175,94.62000275,9.042361259);
   graph1->SetPoint(176,94.66000366,9.233187675);
   graph1->SetPoint(177,94.69999695,9.425187111);
   graph1->SetPoint(178,94.73999786,9.618330002);
   graph1->SetPoint(179,94.77999878,9.812587738);
   graph1->SetPoint(180,94.81999969,10.00793171);
   graph1->SetPoint(181,94.86000061,10.20433044);
   graph1->SetPoint(182,94.90000153,10.40175724);
   graph1->SetPoint(183,94.94000244,10.60017967);
   graph1->SetPoint(184,94.98000336,10.79957104);
   graph1->SetPoint(185,95.01999664,10.99990082);
   graph1->SetPoint(186,95.05999756,11.20113945);
   graph1->SetPoint(187,95.09999847,11.40325832);
   graph1->SetPoint(188,95.13999939,11.60622883);
   graph1->SetPoint(189,95.18000031,11.81002045);
   graph1->SetPoint(190,95.22000122,12.01460457);
   graph1->SetPoint(191,95.22000122,12.01460457);
   graph1->SetPoint(192,95.26000214,12.21995258);
   graph1->SetPoint(193,95.30000305,12.42603588);
   graph1->SetPoint(194,95.33999634,12.63282394);
   graph1->SetPoint(195,95.37999725,12.84028816);
   graph1->SetPoint(196,95.41999817,13.04840088);
   graph1->SetPoint(197,95.45999908,13.25713253);
   graph1->SetPoint(198,95.5,13.46645451);
   graph1->SetPoint(199,95.54000092,13.6763382);
   graph1->SetPoint(200,95.58000183,13.88675499);
   graph1->SetPoint(201,95.62000275,14.09767723);
   graph1->SetPoint(202,95.66000366,14.3090744);
   graph1->SetPoint(203,95.69999695,14.5209198);
   graph1->SetPoint(204,95.73999786,14.73318481);
   graph1->SetPoint(205,95.77999878,14.94584179);
   graph1->SetPoint(206,95.81999969,15.15886116);
   graph1->SetPoint(207,95.86000061,15.37221718);
   graph1->SetPoint(208,95.90000153,15.58588123);
   graph1->SetPoint(209,95.94000244,15.79982567);
   graph1->SetPoint(210,95.98000336,16.01402283);

   
   graph1->Sort();
   
   cout<< "2e2mu: " << graph1->Eval(91.1876) << endl;


   //4mu
   TGraph *graph2 = new TGraph(216);
   graph2->SetName("Graph2");
   graph2->SetTitle("Graph2");
   graph2->SetFillColor(1);
   graph2->SetLineWidth(3);
   graph2->SetLineColor(kRed);
   graph2->SetMarkerStyle(20);
   graph2->SetPoint(0,88.01999664,42.99673462);
   graph2->SetPoint(1,88.05999756,42.01807404);
   graph2->SetPoint(2,88.09999847,41.04578781);
   graph2->SetPoint(3,88.13999939,40.08004379);
   graph2->SetPoint(4,88.18000031,39.12101746);
   graph2->SetPoint(5,88.22000122,38.16888046);
   graph2->SetPoint(6,88.26000214,37.22380447);
   graph2->SetPoint(7,88.30000305,36.2859726);
   graph2->SetPoint(8,88.33999634,35.35555267);
   graph2->SetPoint(9,88.37999725,34.43272781);
   graph2->SetPoint(10,88.41999817,33.51767731);
   graph2->SetPoint(11,88.45999908,32.61057281);
   graph2->SetPoint(12,88.5,31.71160507);
   graph2->SetPoint(13,88.54000092,30.82094765);
   graph2->SetPoint(14,88.58000183,29.93878746);
   graph2->SetPoint(15,88.62000275,29.06530762);
   graph2->SetPoint(16,88.66000366,28.20069313);
   graph2->SetPoint(17,88.69999695,27.34512901);
   graph2->SetPoint(18,88.73999786,26.49880409);
   graph2->SetPoint(19,88.77999878,25.66190529);
   graph2->SetPoint(20,88.81999969,24.83462334);
   graph2->SetPoint(21,88.81999969,24.83462334);
   graph2->SetPoint(22,88.86000061,24.01715088);
   graph2->SetPoint(23,88.90000153,23.20967865);
   graph2->SetPoint(24,88.94000244,22.41239929);
   graph2->SetPoint(25,88.98000336,21.62551308);
   graph2->SetPoint(26,89.01999664,20.84921074);
   graph2->SetPoint(27,89.05999756,20.08369446);
   graph2->SetPoint(28,89.09999847,19.32916451);
   graph2->SetPoint(29,89.13999939,18.58581734);
   graph2->SetPoint(30,89.18000031,17.85385895);
   graph2->SetPoint(31,89.22000122,17.13349152);
   graph2->SetPoint(32,89.26000214,16.42491913);
   graph2->SetPoint(33,89.30000305,15.72835064);
   graph2->SetPoint(34,89.33999634,15.04399014);
   graph2->SetPoint(35,89.37999725,14.37204742);
   graph2->SetPoint(36,89.41999817,13.71273041);
   graph2->SetPoint(37,89.45999908,13.0662508);
   graph2->SetPoint(38,89.5,12.43281651);
   graph2->SetPoint(39,89.54000092,11.81264019);
   graph2->SetPoint(40,89.58000183,11.20593262);
   graph2->SetPoint(41,89.62000275,10.6129055);
   graph2->SetPoint(42,89.62000275,10.6129055);
   graph2->SetPoint(43,89.66000366,10.03376961);
   graph2->SetPoint(44,89.69999695,9.468736649);
   graph2->SetPoint(45,89.73999786,8.918016434);
   graph2->SetPoint(46,89.77999878,8.381820679);
   graph2->SetPoint(47,89.81999969,7.860357285);
   graph2->SetPoint(48,89.86000061,7.353835583);
   graph2->SetPoint(49,89.90000153,6.862462997);
   graph2->SetPoint(50,89.94000244,6.386445045);
   graph2->SetPoint(51,89.98000336,5.92598629);
   graph2->SetPoint(52,90.01999664,5.481288433);
   graph2->SetPoint(53,90.05999756,5.0525527);
   graph2->SetPoint(54,90.09999847,4.639976501);
   graph2->SetPoint(55,90.13999939,4.243755817);
   graph2->SetPoint(56,90.18000031,3.864083052);
   graph2->SetPoint(57,90.22000122,3.501147509);
   graph2->SetPoint(58,90.26000214,3.155135393);
   graph2->SetPoint(59,90.30000305,2.826228619);
   graph2->SetPoint(60,90.33999634,2.514605522);
   graph2->SetPoint(61,90.37999725,2.220438957);
   graph2->SetPoint(62,90.41999817,1.943897605);
   graph2->SetPoint(63,90.41999817,1.943897605);
   graph2->SetPoint(64,90.45999908,1.685144305);
   graph2->SetPoint(65,90.5,1.444335938);
   graph2->SetPoint(66,90.54000092,1.221622825);
   graph2->SetPoint(67,90.58000183,1.017148852);
   graph2->SetPoint(68,90.62000275,0.8310500383);
   graph2->SetPoint(69,90.66000366,0.663454473);
   graph2->SetPoint(70,90.69999695,0.5144816637);
   graph2->SetPoint(71,90.73999786,0.3842421472);
   graph2->SetPoint(72,90.77999878,0.2728365958);
   graph2->SetPoint(73,90.81999969,0.1803556085);
   graph2->SetPoint(74,90.86000061,0.1068789586);
   graph2->SetPoint(75,90.90000153,0.05247514695);
   graph2->SetPoint(76,90.94000244,0.01720083691);
   graph2->SetPoint(77,90.98000336,0.00110038009);
   graph2->SetPoint(78,90.9935379,0);
   graph2->SetPoint(79,90.9935379,0);
   graph2->SetPoint(80,90.9935379,0);
   graph2->SetPoint(81,90.9935379,0);
   graph2->SetPoint(82,90.9935379,0);
   graph2->SetPoint(83,90.9935379,0);
   graph2->SetPoint(84,90.9935379,0);
   graph2->SetPoint(85,91.01999664,0.004205350298);
   graph2->SetPoint(86,91.05999756,0.02653408609);
   graph2->SetPoint(87,91.09999847,0.06809128821);
   graph2->SetPoint(88,91.13999939,0.1288676411);
   graph2->SetPoint(89,91.18000031,0.208839491);
   graph2->SetPoint(90,91.22000122,0.3079685569);
   graph2->SetPoint(91,91.22000122,0.3079685569);
   graph2->SetPoint(92,91.26000214,0.4262017608);
   graph2->SetPoint(93,91.30000305,0.5634709001);
   graph2->SetPoint(94,91.33999634,0.7196927667);
   graph2->SetPoint(95,91.37999725,0.8947688341);
   graph2->SetPoint(96,91.41999817,1.088585615);
   graph2->SetPoint(97,91.45999908,1.301014304);
   graph2->SetPoint(98,91.5,1.531911612);
   graph2->SetPoint(99,91.54000092,1.781119347);
   graph2->SetPoint(100,91.58000183,2.048465252);
   graph2->SetPoint(101,91.62000275,2.333762884);
   graph2->SetPoint(102,91.66000366,2.636813402);
   graph2->SetPoint(103,91.69999695,2.957404137);
   graph2->SetPoint(104,91.73999786,3.295311213);
   graph2->SetPoint(105,91.77999878,3.650299788);
   graph2->SetPoint(106,91.81999969,4.022123814);
   graph2->SetPoint(107,91.86000061,4.410528183);
   graph2->SetPoint(108,91.90000153,4.815249443);
   graph2->SetPoint(109,91.94000244,5.23601675);
   graph2->SetPoint(110,91.98000336,5.672553062);
   graph2->SetPoint(111,92.01999664,6.124575138);
   graph2->SetPoint(112,92.01999664,6.124575138);
   graph2->SetPoint(113,92.05999756,6.591795921);
   graph2->SetPoint(114,92.09999847,7.073926449);
   graph2->SetPoint(115,92.13999939,7.570672989);
   graph2->SetPoint(116,92.18000031,8.08174324);
   graph2->SetPoint(117,92.22000122,8.606842995);
   graph2->SetPoint(118,92.26000214,9.145680428);
   graph2->SetPoint(119,92.30000305,9.697964668);
   graph2->SetPoint(120,92.33999634,10.26340675);
   graph2->SetPoint(121,92.37999725,10.84172058);
   graph2->SetPoint(122,92.41999817,11.43262482);
   graph2->SetPoint(123,92.45999908,12.03584099);
   graph2->SetPoint(124,92.5,12.65109539);
   graph2->SetPoint(125,92.54000092,13.27812099);
   graph2->SetPoint(126,92.58000183,13.91665268);
   graph2->SetPoint(127,92.62000275,14.56643105);
   graph2->SetPoint(128,92.66000366,15.22720337);
   graph2->SetPoint(129,92.69999695,15.89872169);
   graph2->SetPoint(130,92.73999786,16.58073997);
   graph2->SetPoint(131,92.77999878,17.2730217);
   graph2->SetPoint(132,92.81999969,17.97533035);
   graph2->SetPoint(133,92.81999969,17.97533035);
   graph2->SetPoint(134,92.86000061,18.68743896);
   graph2->SetPoint(135,92.90000153,19.40911865);
   graph2->SetPoint(136,92.94000244,20.14015007);
   graph2->SetPoint(137,92.98000336,20.88031387);
   graph2->SetPoint(138,93.01999664,21.62939453);
   graph2->SetPoint(139,93.05999756,22.38718414);
   graph2->SetPoint(140,93.09999847,23.15346909);
   graph2->SetPoint(141,93.13999939,23.92804527);
   graph2->SetPoint(142,93.18000031,24.71071243);
   graph2->SetPoint(143,93.22000122,25.50126266);
   graph2->SetPoint(144,93.26000214,26.29950333);
   graph2->SetPoint(145,93.30000305,27.10523224);
   graph2->SetPoint(146,93.33999634,27.91825485);
   graph2->SetPoint(147,93.37999725,28.73837852);
   graph2->SetPoint(148,93.41999817,29.56540871);
   graph2->SetPoint(149,93.45999908,30.39915657);
   graph2->SetPoint(150,93.5,31.23942947);
   graph2->SetPoint(151,93.54000092,32.0860405);
   graph2->SetPoint(152,93.58000183,32.93880081);
   graph2->SetPoint(153,93.62000275,33.79752731);
   graph2->SetPoint(154,93.62000275,33.79752731);
   graph2->SetPoint(155,93.66000366,34.66203308);
   graph2->SetPoint(156,93.69999695,35.53213501);
   graph2->SetPoint(157,93.73999786,36.40764999);
   graph2->SetPoint(158,93.77999878,37.28839874);
   graph2->SetPoint(159,93.81999969,38.17420197);
   graph2->SetPoint(160,93.86000061,39.06488037);
   graph2->SetPoint(161,93.90000153,39.96025848);
   graph2->SetPoint(162,93.94000244,40.86016464);
   graph2->SetPoint(163,93.98000336,41.76441956);
   graph2->SetPoint(164,94.01999664,42.67286301);
   graph2->SetPoint(165,94.05999756,43.5853157);
   graph2->SetPoint(166,94.09999847,44.50161362);
   graph2->SetPoint(167,94.13999939,45.42160034);
   graph2->SetPoint(168,94.18000031,46.34510422);
   graph2->SetPoint(169,94.22000122,47.27197266);
   graph2->SetPoint(170,94.26000214,48.20204544);
   graph2->SetPoint(171,94.30000305,49.13516998);
   graph2->SetPoint(172,94.33999634,50.07119751);
   graph2->SetPoint(173,94.37999725,51.00997925);
   graph2->SetPoint(174,94.41999817,51.95137024);
   graph2->SetPoint(175,94.41999817,51.95137024);
   graph2->SetPoint(176,94.45999908,52.89523315);
   graph2->SetPoint(177,94.5,53.84142303);
   graph2->SetPoint(178,94.54000092,54.789814);
   graph2->SetPoint(179,94.58000183,55.74026871);
   graph2->SetPoint(180,94.62000275,56.69266129);
   graph2->SetPoint(181,94.66000366,57.64687347);
   graph2->SetPoint(182,94.69999695,58.60277939);
   graph2->SetPoint(183,94.73999786,59.5602684);
   graph2->SetPoint(184,94.77999878,60.51922989);
   graph2->SetPoint(185,94.81999969,61.47954941);
   graph2->SetPoint(186,94.86000061,62.44112778);
   graph2->SetPoint(187,94.90000153,63.40386581);
   graph2->SetPoint(188,94.94000244,64.36766815);
   graph2->SetPoint(189,94.98000336,65.33243561);
   graph2->SetPoint(190,95.01999664,66.29808044);
   graph2->SetPoint(191,95.05999756,67.264534);
   graph2->SetPoint(192,95.09999847,68.23168945);
   graph2->SetPoint(193,95.13999939,69.19949341);
   graph2->SetPoint(194,95.18000031,70.16786194);
   graph2->SetPoint(195,95.22000122,71.13671875);
   graph2->SetPoint(196,95.22000122,71.13671875);
   graph2->SetPoint(197,95.26000214,72.10600281);
   graph2->SetPoint(198,95.30000305,73.07565308);
   graph2->SetPoint(199,95.33999634,74.04560852);
   graph2->SetPoint(200,95.37999725,75.01580811);
   graph2->SetPoint(201,95.41999817,75.98619843);
   graph2->SetPoint(202,95.45999908,76.95672607);
   graph2->SetPoint(203,95.5,77.92734528);
   graph2->SetPoint(204,95.54000092,78.89801788);
   graph2->SetPoint(205,95.58000183,79.86868286);
   graph2->SetPoint(206,95.62000275,80.83930969);
   graph2->SetPoint(207,95.66000366,81.80986023);
   graph2->SetPoint(208,95.69999695,82.7802887);
   graph2->SetPoint(209,95.73999786,83.7505722);
   graph2->SetPoint(210,95.77999878,84.72067261);
   graph2->SetPoint(211,95.81999969,85.69055176);
   graph2->SetPoint(212,95.86000061,86.6601944);
   graph2->SetPoint(213,95.90000153,87.62956238);
   graph2->SetPoint(214,95.94000244,88.59862518);
   graph2->SetPoint(215,95.98000336,89.56736755);



   cout<< "4mu: " << graph2->Eval(91.1876) << endl;


   //4l
   TGraph *graph3 = new TGraph(212);
   graph3->SetName("Graph3");
   graph3->SetTitle("Graph3");
   graph3->SetFillColor(1);
   graph3->SetLineWidth(3);
   graph3->SetMarkerStyle(20);
   graph3->SetPoint(0,88.01999664,57.33911514);
   graph3->SetPoint(1,88.05999756,56.08871841);
   graph3->SetPoint(2,88.09999847,54.84604263);
   graph3->SetPoint(3,88.13999939,53.61128998);
   graph3->SetPoint(4,88.18000031,52.38465881);
   graph3->SetPoint(5,88.22000122,51.1663475);
   graph3->SetPoint(6,88.26000214,49.95656586);
   graph3->SetPoint(7,88.30000305,48.75551605);
   graph3->SetPoint(8,88.33999634,47.56340408);
   graph3->SetPoint(9,88.37999725,46.38043976);
   graph3->SetPoint(10,88.41999817,45.20683289);
   graph3->SetPoint(11,88.45999908,44.04279709);
   graph3->SetPoint(12,88.5,42.88854218);
   graph3->SetPoint(13,88.54000092,41.74428558);
   graph3->SetPoint(14,88.58000183,40.61024094);
   graph3->SetPoint(15,88.62000275,39.48662186);
   graph3->SetPoint(16,88.66000366,38.37365723);
   graph3->SetPoint(17,88.69999695,37.27156067);
   graph3->SetPoint(18,88.73999786,36.18055725);
   graph3->SetPoint(19,88.77999878,35.10086823);
   graph3->SetPoint(20,88.81999969,34.03272247);
   graph3->SetPoint(21,88.81999969,34.03272247);
   graph3->SetPoint(22,88.86000061,32.97634506);
   graph3->SetPoint(23,88.90000153,31.93196487);
   graph3->SetPoint(24,88.94000244,30.89981461);
   graph3->SetPoint(25,88.98000336,29.88012505);
   graph3->SetPoint(26,89.01999664,28.87313271);
   graph3->SetPoint(27,89.05999756,27.87907028);
   graph3->SetPoint(28,89.09999847,26.8981781);
   graph3->SetPoint(29,89.13999939,25.93069649);
   graph3->SetPoint(30,89.18000031,24.97686577);
   graph3->SetPoint(31,89.22000122,24.03692818);
   graph3->SetPoint(32,89.26000214,23.11112785);
   graph3->SetPoint(33,89.30000305,22.19971466);
   graph3->SetPoint(34,89.33999634,21.30293083);
   graph3->SetPoint(35,89.37999725,20.42103004);
   graph3->SetPoint(36,89.41999817,19.55426025);
   graph3->SetPoint(37,89.45999908,18.70287132);
   graph3->SetPoint(38,89.5,17.86711502);
   graph3->SetPoint(39,89.54000092,17.04724693);
   graph3->SetPoint(40,89.58000183,16.24351692);
   graph3->SetPoint(41,89.62000275,15.45617962);
   graph3->SetPoint(42,89.62000275,15.45617962);
   graph3->SetPoint(43,89.66000366,14.6854887);
   graph3->SetPoint(44,89.69999695,13.93169785);
   graph3->SetPoint(45,89.73999786,13.19505882);
   graph3->SetPoint(46,89.77999878,12.47582531);
   graph3->SetPoint(47,89.81999969,11.77424908);
   graph3->SetPoint(48,89.86000061,11.09057903);
   graph3->SetPoint(49,89.90000153,10.4250679);
   graph3->SetPoint(50,89.94000244,9.777960777);
   graph3->SetPoint(51,89.98000336,9.149505615);
   graph3->SetPoint(52,90.01999664,8.539945602);
   graph3->SetPoint(53,90.05999756,7.949523926);
   graph3->SetPoint(54,90.09999847,7.378479958);
   graph3->SetPoint(55,90.13999939,6.827050209);
   graph3->SetPoint(56,90.18000031,6.295467854);
   graph3->SetPoint(57,90.22000122,5.783964634);
   graph3->SetPoint(58,90.26000214,5.292765617);
   graph3->SetPoint(59,90.30000305,4.82209301);
   graph3->SetPoint(60,90.33999634,4.37216568);
   graph3->SetPoint(61,90.37999725,3.943194866);
   graph3->SetPoint(62,90.41999817,3.535388231);
   graph3->SetPoint(63,90.41999817,3.535388231);
   graph3->SetPoint(64,90.45999908,3.148947239);
   graph3->SetPoint(65,90.5,2.784065962);
   graph3->SetPoint(66,90.54000092,2.440932035);
   graph3->SetPoint(67,90.58000183,2.119725466);
   graph3->SetPoint(68,90.62000275,1.820617914);
   graph3->SetPoint(69,90.66000366,1.543772101);
   graph3->SetPoint(70,90.69999695,1.28934145);
   graph3->SetPoint(71,90.73999786,1.057468891);
   graph3->SetPoint(72,90.77999878,0.8482871056);
   graph3->SetPoint(73,90.81999969,0.6619167924);
   graph3->SetPoint(74,90.86000061,0.4984668195);
   graph3->SetPoint(75,90.90000153,0.3580331504);
   graph3->SetPoint(76,90.94000244,0.240698427);
   graph3->SetPoint(77,90.98000336,0.1465311348);
   graph3->SetPoint(78,91.01999664,0.07558509707);
   graph3->SetPoint(79,91.05999756,0.02789884619);
   graph3->SetPoint(80,91.09999847,0.003495044075);
   graph3->SetPoint(81,91.12191772,0);
   graph3->SetPoint(82,91.12191772,0);
   graph3->SetPoint(83,91.12191772,0);
   graph3->SetPoint(84,91.12191772,0);
   graph3->SetPoint(85,91.12191772,0);
   graph3->SetPoint(86,91.12191772,0);
   graph3->SetPoint(87,91.12191772,0);
   graph3->SetPoint(88,91.26000214,0.1385737211);
   graph3->SetPoint(89,91.30000305,0.230332002);
   graph3->SetPoint(90,91.33999634,0.345148921);
   graph3->SetPoint(91,91.37999725,0.4829240143);
   graph3->SetPoint(92,91.41999817,0.643538177);
   graph3->SetPoint(93,91.45999908,0.8268537521);
   graph3->SetPoint(94,91.5,1.032714605);
   graph3->SetPoint(95,91.54000092,1.260946751);
   graph3->SetPoint(96,91.58000183,1.511358023);
   graph3->SetPoint(97,91.62000275,1.783738732);
   graph3->SetPoint(98,91.66000366,2.07786274);
   graph3->SetPoint(99,91.69999695,2.39348793);
   graph3->SetPoint(100,91.73999786,2.730356455);
   graph3->SetPoint(101,91.77999878,3.088196516);
   graph3->SetPoint(102,91.81999969,3.466723442);
   graph3->SetPoint(103,91.86000061,3.865639925);
   graph3->SetPoint(104,91.90000153,4.284637928);
   graph3->SetPoint(105,91.94000244,4.723400593);
   graph3->SetPoint(106,91.98000336,5.181601524);
   graph3->SetPoint(107,92.01999664,5.658910275);
   graph3->SetPoint(108,92.01999664,5.658910275);
   graph3->SetPoint(109,92.05999756,6.154988289);
   graph3->SetPoint(110,92.09999847,6.669495583);
   graph3->SetPoint(111,92.13999939,7.202087879);
   graph3->SetPoint(112,92.18000031,7.752422333);
   graph3->SetPoint(113,92.22000122,8.32015419);
   graph3->SetPoint(114,92.26000214,8.904941559);
   graph3->SetPoint(115,92.30000305,9.506444931);
   graph3->SetPoint(116,92.33999634,10.12432957);
   graph3->SetPoint(117,92.37999725,10.75826359);
   graph3->SetPoint(118,92.41999817,11.40792084);
   graph3->SetPoint(119,92.45999908,12.07298279);
   graph3->SetPoint(120,92.5,12.75313663);
   graph3->SetPoint(121,92.54000092,13.44807529);
   graph3->SetPoint(122,92.58000183,14.15750027);
   graph3->SetPoint(123,92.62000275,14.88112068);
   graph3->SetPoint(124,92.66000366,15.61865044);
   graph3->SetPoint(125,92.69999695,16.36981392);
   graph3->SetPoint(126,92.73999786,17.13433838);
   graph3->SetPoint(127,92.77999878,17.91196251);
   graph3->SetPoint(128,92.81999969,18.70242691);
   graph3->SetPoint(129,92.81999969,18.70242691);
   graph3->SetPoint(130,92.86000061,19.50548172);
   graph3->SetPoint(131,92.90000153,20.32088089);
   graph3->SetPoint(132,92.94000244,21.14838409);
   graph3->SetPoint(133,92.98000336,21.98775864);
   graph3->SetPoint(134,93.01999664,22.83877182);
   graph3->SetPoint(135,93.05999756,23.70119667);
   graph3->SetPoint(136,93.09999847,24.57481003);
   graph3->SetPoint(137,93.13999939,25.45939636);
   graph3->SetPoint(138,93.18000031,26.35473442);
   graph3->SetPoint(139,93.22000122,27.2606163);
   graph3->SetPoint(140,93.26000214,28.17682648);
   graph3->SetPoint(141,93.30000305,29.10315895);
   graph3->SetPoint(142,93.33999634,30.03940773);
   graph3->SetPoint(143,93.37999725,30.98536491);
   graph3->SetPoint(144,93.41999817,31.94083023);
   graph3->SetPoint(145,93.45999908,32.9056015);
   graph3->SetPoint(146,93.5,33.87947845);
   graph3->SetPoint(147,93.54000092,34.86225891);
   graph3->SetPoint(148,93.58000183,35.85375214);
   graph3->SetPoint(149,93.62000275,36.85375214);
   graph3->SetPoint(150,93.62000275,36.85375214);
   graph3->SetPoint(151,93.66000366,37.86207199);
   graph3->SetPoint(152,93.69999695,38.87851334);
   graph3->SetPoint(153,93.73999786,39.90288162);
   graph3->SetPoint(154,93.77999878,40.93498611);
   graph3->SetPoint(155,93.81999969,41.97463608);
   graph3->SetPoint(156,93.86000061,43.02164078);
   graph3->SetPoint(157,93.90000153,44.07581329);
   graph3->SetPoint(158,93.94000244,45.13696671);
   graph3->SetPoint(159,93.98000336,46.20491409);
   graph3->SetPoint(160,94.01999664,47.27947617);
   graph3->SetPoint(161,94.05999756,48.360466);
   graph3->SetPoint(162,94.09999847,49.44770813);
   graph3->SetPoint(163,94.13999939,50.54101944);
   graph3->SetPoint(164,94.18000031,51.64023209);
   graph3->SetPoint(165,94.22000122,52.74516296);
   graph3->SetPoint(166,94.26000214,53.85564804);
   graph3->SetPoint(167,94.30000305,54.97151947);
   graph3->SetPoint(168,94.33999634,56.09260941);
   graph3->SetPoint(169,94.37999725,57.21875763);
   graph3->SetPoint(170,94.41999817,58.34980011);
   graph3->SetPoint(171,94.41999817,58.34980011);
   graph3->SetPoint(172,94.45999908,59.48558426);
   graph3->SetPoint(173,94.5,60.62595749);
   graph3->SetPoint(174,94.54000092,61.77076721);
   graph3->SetPoint(175,94.58000183,62.91986847);
   graph3->SetPoint(176,94.62000275,64.07312012);
   graph3->SetPoint(177,94.66000366,65.2303772);
   graph3->SetPoint(178,94.69999695,66.39151001);
   graph3->SetPoint(179,94.73999786,67.55638123);
   graph3->SetPoint(180,94.77999878,68.72486877);
   graph3->SetPoint(181,94.81999969,69.89684296);
   graph3->SetPoint(182,94.86000061,71.07218933);
   graph3->SetPoint(183,94.90000153,72.25079346);
   graph3->SetPoint(184,94.94000244,73.43252563);
   graph3->SetPoint(185,94.98000336,74.61729431);
   graph3->SetPoint(186,95.01999664,75.80497742);
   graph3->SetPoint(187,95.05999756,76.99549103);
   graph3->SetPoint(188,95.09999847,78.18872833);
   graph3->SetPoint(189,95.13999939,79.38459015);
   graph3->SetPoint(190,95.18000031,80.58299255);
   graph3->SetPoint(191,95.22000122,81.78383636);
   graph3->SetPoint(192,95.22000122,81.78383636);
   graph3->SetPoint(193,95.26000214,82.98705292);
   graph3->SetPoint(194,95.30000305,84.19254303);
   graph3->SetPoint(195,95.33999634,85.40024567);
   graph3->SetPoint(196,95.37999725,86.61006927);
   graph3->SetPoint(197,95.41999817,87.82195282);
   graph3->SetPoint(198,95.45999908,89.03581238);
   graph3->SetPoint(199,95.5,90.25159454);
   graph3->SetPoint(200,95.54000092,91.46923065);
   graph3->SetPoint(201,95.58000183,92.68865204);
   graph3->SetPoint(202,95.62000275,93.90979767);
   graph3->SetPoint(203,95.66000366,95.13261414);
   graph3->SetPoint(204,95.69999695,96.35704803);
   graph3->SetPoint(205,95.73999786,97.58303833);
   graph3->SetPoint(206,95.77999878,98.81052399);
   graph3->SetPoint(207,95.81999969,100.0394745);
   graph3->SetPoint(208,95.86000061,101.2698212);
   graph3->SetPoint(209,95.90000153,102.5015259);
   graph3->SetPoint(210,95.94000244,103.7345352);
   graph3->SetPoint(211,95.98000336,104.9688034);



   TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","Graph",212,84.03,95.97);
   Graph_Graph1->SetMinimum(0);
   Graph_Graph1->SetMaximum(57.47094);
   Graph_Graph1->SetDirectory(0);
   Graph_Graph1->SetStats(0);
   Graph_Graph1->SetLineStyle(0);
   Graph_Graph1->SetMarkerStyle(20);
   Graph_Graph1->GetXaxis()->SetLabelFont(42);
   Graph_Graph1->GetXaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetXaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetXaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetXaxis()->SetTitleOffset(0.9);
   Graph_Graph1->GetXaxis()->SetTitleFont(42);
   Graph_Graph1->GetYaxis()->SetLabelFont(42);
   Graph_Graph1->GetYaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetYaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetYaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetYaxis()->SetTitleOffset(1.25);
   Graph_Graph1->GetYaxis()->SetTitleFont(42);
   Graph_Graph1->GetZaxis()->SetLabelFont(42);
   Graph_Graph1->GetZaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetZaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetZaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetZaxis()->SetTitleFont(42);
   Graph_Graph1->GetXaxis()->SetNdivisions(510);
   
   graph->SetHistogram(Graph_Graph1);
   graph->Draw("cx");
   graph1->Draw("cx");
   graph2->Draw("cx");
   graph3->Draw("cx");

   TPaveText *pt = new TPaveText(0.1577181,0.95,0.9580537,0.99,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   TText *text = pt->AddText(0.01,0.5,"CMS");
   text = pt->AddText(0.3,0.6,"#sqrt{s} = 7 TeV, L = 5.1 fb^{-1}  #sqrt{s} = 8 TeV, L = 19.7 fb^{-1}");
   pt->Draw();
   

   TLegend *leg = new TLegend(0.73,0.77,0.94,0.94);
   leg->SetTextSize(0.035);
   leg->SetTextFont(42);
   leg->SetFillColor(kWhite);
   //leg->SetBorderSize(0);
   //leg->SetFillStyle(0);

   leg->AddEntry(graph3,"Combined","L");
   leg->AddEntry(graph,"Z#rightarrow 4e","L");
   leg->AddEntry(graph2,"Z#rightarrow 4#mu","L");
   leg->AddEntry(graph1,"Z#rightarrow 2e2#mu","L");






   double yLow = 0.5;

   

   pt = new TPaveText(0.11,yLow,0.4,yLow+0.04,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kBlue);
   text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.46 GeV");
   //text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.40 #pm 0.16 GeV");
   //stat 91.4315 +0.405948-0.397679
   cout << "Syst 2e2mu: " << findSystErr(0.43,0.40) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.06,0.4,yLow+0.1,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kRed);
   text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.26 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.25 #pm 0.09 GeV");
   //stat 91.0078 +0.255715-0.25533
   cout << "Syst 4mu: " << findSystErr(0.27,0.255) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.12,0.4,yLow+0.16,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kGreen+1);
   text = pt->AddText(0.2,0.2,"m_{4e} = 93.67 #pm 1.08 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4e} = 9 #pm 0.74 #pm 0.30 GeV");
   //stat 91.8026 +0.745333-0.740755
   cout << "Syst 4e: " << findSystErr(0.8,0.74) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.18,0.4,yLow+0.22,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   text = pt->AddText(0.2,0.2,"m_{4l} = 91.15 #pm 0.23 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4l} = 91.17 #pm 0.18 #pm 0.13 GeV");
   //stat  91.1724 +0.168014-0.204439
   cout << "Syst 4l: " << findSystErr(0.22,0.18) << endl;
   //pt->Draw();

   pt = new TPaveText(0.18,yLow+0.24,0.4,yLow+0.28,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.035);
   text = pt->AddText(0.2,0.2,"#chi^{2}/ndof = 1.38/3");
   //pt->Draw();
   
   gPad->SetTicks(1,1);

   TLine *line95 = new TLine(88,3.84,96,3.84);
   line95->SetLineColor(kRed);
   line95->SetLineWidth(2);
   line95->Draw();

   TLine *line68 = new TLine(88,1,96,1);
   line68->SetLineColor(kRed);
   line68->SetLineWidth(3);
   line68->Draw();
   
   TLine *lineZ = new TLine(91.1876,0,91.1876,10);
   lineZ->SetLineColor(kGray+2);
   lineZ->SetLineStyle(7);
   lineZ->Draw();

   leg->Draw();
   hframe->GetXaxis()->SetRangeUser(88,96);
   ccc->Modified();
   ccc->cd();
   ccc->SetSelected(ccc);

   ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.eps");
   ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.png");
}
Exemplo n.º 19
0
void plotHistHi() {


  gStyle->SetOptStat(0);

  set_plot_style();

  TFile *f = new TFile("./trackCorrections.root");

  char ndir[256] = "SimpleTrkCorr";
  double ptmax = 5.;


  // sim-to-reco hists
  TH2F *hSim = (TH2F*) f->Get(Form("%s/hsim",ndir)); hSim->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH2F *hEff = (TH2F*) f->Get(Form("%s/heff",ndir)); hEff->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH2F *hMul = (TH2F*) f->Get(Form("%s/hmul",ndir)); hMul->GetYaxis()->SetRangeUser(0.2,ptmax);

  // reco-to-sim hists
  TH2F *hRec = (TH2F*) f->Get(Form("%s/hrec",ndir)); hRec->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH2F *hFak = (TH2F*) f->Get(Form("%s/hfak",ndir)); hFak->GetYaxis()->SetRangeUser(0.2,ptmax);
  TH2F *hSec = (TH2F*) f->Get(Form("%s/hsec",ndir)); hSec->GetYaxis()->SetRangeUser(0.2,ptmax);

  // ratio histograms
  TH2F *rEff = (TH2F*) hEff->Clone("rEff");
  TH2F *rMul = (TH2F*) hMul->Clone("rMul");
  TH2F *rFak = (TH2F*) hFak->Clone("rFak");
  TH2F *rSec = (TH2F*) hSec->Clone("rSec");

  //---------------------------------------------

  // reco efficiency fraction
  TCanvas *c2 = new TCanvas("c2","Reco Efficiency Fraction",600,500);
  //c2->SetLogy();
  gPad->SetRightMargin(0.15);
  rEff->Divide(hEff,hSim,1,1,"B");
  rEff->SetStats(0);
  rEff->SetMaximum(1.0); rEff->SetMinimum(0.0);
  rEff->SetTitle("Absolute Efficiency");
  rEff->Draw("colz");

  // multiple reco fraction
  TCanvas *c3 = new TCanvas("c3","Multiple Reco Fraction",600,500);
  //c3->SetLogy();
  gPad->SetRightMargin(0.15);
  rMul->Divide(hMul,hSim,1,1,"B");
  rMul->SetStats(0);
  rMul->SetMaximum(0.05); rMul->SetMinimum(0.0);
  rMul->SetTitle("Multiple Reconstruction Fraction");
  rMul->Draw("colz");

  // fake reco fraction
  TCanvas *c4 = new TCanvas("c4","Fake Reco Fraction",600,500);
  //c4->SetLogy();
  gPad->SetRightMargin(0.15);
  rFak->Divide(hFak,hRec,1,1,"B");
  rFak->SetStats(0);
  rFak->SetMaximum(0.25); rFak->SetMinimum(0.0);
  rFak->SetTitle("Fake Reconstruction Fraction");
  rFak->Draw("colz");

  // secondary reco fraction
  TCanvas *c5 = new TCanvas("c5","Secondary Fraction",600,500);  
  //c5->SetLogy();
  gPad->SetRightMargin(0.15);
  rSec->Divide(hSec,hRec,1,1,"B");
  rSec->SetStats(0);
  rSec->SetMaximum(0.05); rSec->SetMinimum(0.0);
  rSec->SetTitle("Non-Primary Reconstruction Fraction");
  rSec->Draw("colz");

  //---------------------------------------------

  // find bins corresponding to projections for below
  Int_t ptbin04=hSim->GetYaxis()->FindBin(0.41);
  Int_t ptbin20=hSim->GetYaxis()->FindBin(2.01);
  Int_t ptbins=hSim->GetYaxis()->GetNbins();
  Int_t etabin24m=hSim->GetXaxis()->FindBin(-2.39);
  Int_t etabin24p=hSim->GetXaxis()->FindBin(2.39);
  Int_t etabin10m=hSim->GetXaxis()->FindBin(-0.99);
  Int_t etabin10p=hSim->GetXaxis()->FindBin(0.99);

  cout << "etabin10m: " << etabin10m << " etabin10p: " << etabin10p << endl;
  cout << "etabin10m: " << etabin24m << " etabin10p: " << etabin24p << endl;

  // projected hists: pt > 0.4 GeV/c
  TH1D* hSimEta = (TH1D*) hSim->ProjectionX("hSimEta",ptbin04,ptbins,"e");
  TH1D* hEffEta = (TH1D*) hEff->ProjectionX("hEffEta",ptbin04,ptbins,"e");
  TH1D* hMulEta = (TH1D*) hMul->ProjectionX("hMulEta",ptbin04,ptbins,"e");
  TH1D* hRecEta = (TH1D*) hRec->ProjectionX("hRecEta",ptbin04,ptbins,"e");
  TH1D* hFakEta = (TH1D*) hFak->ProjectionX("hFakEta",ptbin04,ptbins,"e");
  TH1D* hSecEta = (TH1D*) hSec->ProjectionX("hSecEta",ptbin04,ptbins,"e");

  // projected hists: pt > 2.0 GeV/c
  TH1D* hSimEta2 = (TH1D*) hSim->ProjectionX("hSimEta2",ptbin20,ptbins,"e");
  TH1D* hEffEta2 = (TH1D*) hEff->ProjectionX("hEffEta2",ptbin20,ptbins,"e");
  TH1D* hMulEta2 = (TH1D*) hMul->ProjectionX("hMulEta2",ptbin20,ptbins,"e");
  TH1D* hRecEta2 = (TH1D*) hRec->ProjectionX("hRecEta2",ptbin20,ptbins,"e");
  TH1D* hFakEta2 = (TH1D*) hFak->ProjectionX("hFakEta2",ptbin20,ptbins,"e");
  TH1D* hSecEta2 = (TH1D*) hSec->ProjectionX("hSecEta2",ptbin20,ptbins,"e");

  TH1D* hDumEta = new TH1D("hDumEta",";#eta",60,-2.4,2.4); hDumEta->SetMaximum(1.0);
  hDumEta->GetXaxis()->CenterTitle(); hDumEta->GetYaxis()->SetTitleOffset(1.8);
  TH1D* hDumEta2 = (TH1D*) hDumEta->Clone("hDumEta2"); hDumEta2->SetMaximum(0.1); 
  TH1D* hDumEta3 = (TH1D*) hDumEta->Clone("hDumEta3"); hDumEta3->SetMaximum(0.00049); 


  // projected hists: abs(eta) < 1.0
  TH1D* hSimPt  = (TH1D*) hSim->ProjectionY("hSimPt",etabin10m,etabin10p,"e");
  TH1D* hEffPt  = (TH1D*) hEff->ProjectionY("hEffPt",etabin10m,etabin10p,"e");
  TH1D* hMulPt  = (TH1D*) hMul->ProjectionY("hMulPt",etabin10m,etabin10p,"e");
  TH1D* hRecPt  = (TH1D*) hRec->ProjectionY("hRecPt",etabin10m,etabin10p,"e");
  TH1D* hFakPt  = (TH1D*) hFak->ProjectionY("hFakPt",etabin10m,etabin10p,"e");
  TH1D* hSecPt  = (TH1D*) hSec->ProjectionY("hSecPt",etabin10m,etabin10p,"e");

  // projected hists: abs(eta) < 2.4
  TH1D* hSimPt2  = (TH1D*) hSim->ProjectionY("hSimPt2",etabin24m,etabin24p,"e");
  TH1D* hEffPt2  = (TH1D*) hEff->ProjectionY("hEffPt2",etabin24m,etabin24p,"e");
  TH1D* hMulPt2  = (TH1D*) hMul->ProjectionY("hMulPt2",etabin24m,etabin24p,"e");
  TH1D* hRecPt2  = (TH1D*) hRec->ProjectionY("hRecPt2",etabin24m,etabin24p,"e");
  TH1D* hFakPt2  = (TH1D*) hFak->ProjectionY("hFakPt2",etabin24m,etabin24p,"e");
  TH1D* hSecPt2  = (TH1D*) hSec->ProjectionY("hSecPt2",etabin24m,etabin24p,"e");
  
  TH1D* hDumPt = new TH1D("hDumPt",";p_{T} [GeV/c]",80,0.2,5.0); hDumPt->SetMaximum(1.0);
  hDumPt->GetXaxis()->CenterTitle(); hDumPt->GetYaxis()->SetTitleOffset(1.8);
  TH1D* hDumPt2 = (TH1D*) hDumPt->Clone("hDumPt2"); hDumPt2->SetMaximum(0.1); 
  TH1D* hDumPt3 = (TH1D*) hDumPt->Clone("hDumPt3"); hDumPt3->SetMaximum(0.00049); 



  // Efficiency
  TGraphAsymmErrors *gEffEta = new TGraphAsymmErrors(); gEffEta->SetName("gEffEta");
  gEffEta->BayesDivide(hEffEta,hSimEta);
  gEffEta->SetMarkerStyle(25);
  gEffEta->SetLineStyle(2);
  gEffEta->SetLineColor(2);
  gEffEta->SetMarkerColor(2);

  TGraphAsymmErrors *gEffPt = new TGraphAsymmErrors(); gEffPt->SetName("gEffPt");
  gEffPt->BayesDivide(hEffPt,hSimPt);
  gEffPt->SetMarkerStyle(24);
  gEffPt->SetLineColor(4);
  gEffPt->SetMarkerColor(4);

  TGraphAsymmErrors *gEffEta2 = new TGraphAsymmErrors(); gEffEta2->SetName("gEffEta2");
  gEffEta2->BayesDivide(hEffEta2,hSimEta2);
  gEffEta2->SetMarkerStyle(24);
  gEffEta2->SetLineColor(4);
  gEffEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gEffPt2 = new TGraphAsymmErrors(); gEffPt2->SetName("gEffPt2");
  gEffPt2->BayesDivide(hEffPt2,hSimPt2);
  gEffPt2->SetMarkerStyle(25);
  gEffPt2->SetLineStyle(2);
  gEffPt2->SetLineColor(2);
  gEffPt2->SetMarkerColor(2);

  TLegend *legEta = new TLegend(0.35,0.3,0.65,0.5);
  legEta->SetFillColor(0); legEta->SetBorderSize(0);
  legEta->AddEntry(gEffEta,"p_{T} > 0.4 GeV/c","lp");
  legEta->AddEntry(gEffEta2,"p_{T} > 2.0 GeV/c","lp");

  TLegend *legPt = new TLegend(0.4,0.3,0.6,0.5);
  legPt->SetFillColor(0); legPt->SetBorderSize(0);
  legPt->AddEntry(gEffPt2,"|#eta| < 2.4","lp");
  legPt->AddEntry(gEffPt,"|#eta| < 1.0","lp");

  TCanvas *c7 = new TCanvas("c7","Efficiency Fraction",900,500);
  c7->Divide(2,1);
  hDumEtaEff=(TH1F*) hDumEta->Clone("hDumEtaEff");
  hDumEtaEff->GetYaxis()->SetTitle("Absolute efficiency");
  hDumPtEff=(TH1F*) hDumPt->Clone("hDumPtEff");
  hDumPtEff->GetYaxis()->SetTitle("Absolute efficiency");
  c7->cd(1); hDumEtaEff->Draw(); gEffEta->Draw("pc"); gEffEta2->Draw("pc"); legEta->Draw();
  c7->cd(2); hDumPtEff->Draw(); gEffPt->Draw("pc"); gEffPt2->Draw("pc"); legPt->Draw();
//  c7->GetPad(2)->SetLogx();

  // Multiple Reco
  TGraphAsymmErrors *gMulEta = new TGraphAsymmErrors(); gMulEta->SetName("gMulEta");
  gMulEta->BayesDivide(hMulEta,hSimEta);
  gMulEta->SetMarkerStyle(25);
  gMulEta->SetLineStyle(2);
  gMulEta->SetLineColor(2);
  gMulEta->SetMarkerColor(2);

  TGraphAsymmErrors *gMulPt = new TGraphAsymmErrors(); gMulPt->SetName("gMulPt");
  gMulPt->BayesDivide(hMulPt,hSimPt);
  gMulPt->SetMarkerStyle(24);
  gMulPt->SetLineColor(4);
  gMulPt->SetMarkerColor(4);

  TGraphAsymmErrors *gMulEta2 = new TGraphAsymmErrors(); gMulEta2->SetName("gMulEta2");
  gMulEta2->BayesDivide(hMulEta2,hSimEta2);
  gMulEta2->SetMarkerStyle(24);
  gMulEta2->SetLineColor(4);
  gMulEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gMulPt2 = new TGraphAsymmErrors(); gMulPt2->SetName("gMulPt2");
  gMulPt2->BayesDivide(hMulPt2,hSimPt2);
  gMulPt2->SetMarkerStyle(25);
  gMulPt2->SetLineStyle(2);
  gMulPt2->SetLineColor(2);
  gMulPt2->SetMarkerColor(2);

  TCanvas *c8 = new TCanvas("c8","Multiple Fraction",900,500);
  c8->Divide(2,1);
  hDumEtaMul=(TH1F*) hDumEta3->Clone("hDumEtaMul");
  hDumEtaMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  hDumPtMul=(TH1F*) hDumPt3->Clone("hDumPtMul");
  hDumPtMul->GetYaxis()->SetTitle("Multiple Reconstruction Fraction");
  legEta2 = (TLegend*) legEta->Clone(); legEta2->SetY1(0.65); legEta2->SetY2(0.85);
  legPt2 = (TLegend*) legPt->Clone(); legPt2->SetY1(0.65); legPt2->SetY2(0.85);
  c8->cd(1); hDumEtaMul->Draw(); gMulEta->Draw("pc"); gMulEta2->Draw("pc"); legEta2->Draw();
  c8->cd(2); hDumPtMul->Draw(); gMulPt->Draw("pc"); gMulPt2->Draw("pc"); legPt2->Draw();
//  c8->GetPad(2)->SetLogx();

  // Fakes
  TGraphAsymmErrors *gFakEta = new TGraphAsymmErrors();  gFakEta->SetName("gFakEta");
  gFakEta->BayesDivide(hFakEta,hRecEta);
  gFakEta->SetMarkerStyle(25);
  gFakEta->SetLineStyle(2);
  gFakEta->SetLineColor(2);
  gFakEta->SetMarkerColor(2);

  TGraphAsymmErrors *gFakPt = new TGraphAsymmErrors(); gFakPt->SetName("gFakPt");
  gFakPt->BayesDivide(hFakPt,hRecPt);
  gFakPt->SetMarkerStyle(24);
  gFakPt->SetLineColor(4);
  gFakPt->SetMarkerColor(4);

  TGraphAsymmErrors *gFakEta2 = new TGraphAsymmErrors(); gFakEta2->SetName("gFakEta2");
  gFakEta2->BayesDivide(hFakEta2,hRecEta2);
  gFakEta2->SetMarkerStyle(24);
  gFakEta2->SetLineColor(4);
  gFakEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gFakPt2 = new TGraphAsymmErrors();  gFakPt2->SetName("gFakPt2");
  gFakPt2->BayesDivide(hFakPt2,hRecPt2);
  gFakPt2->SetMarkerStyle(25);
  gFakPt2->SetLineStyle(2);
  gFakPt2->SetLineColor(2);
  gFakPt2->SetMarkerColor(2);

  TCanvas *c9 = new TCanvas("c9","Fake Fraction",900,500);
  c9->Divide(2,1);
  hDumEtaFak=(TH1F*) hDumEta2->Clone("hDumEtaMul");
  hDumEtaFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  hDumPtFak=(TH1F*) hDumPt2->Clone("hDumPtMul");
  hDumPtFak->GetYaxis()->SetTitle("Fake Reconstruction Fraction");
  c9->cd(1); hDumEtaFak->Draw(); gFakEta->Draw("pc"); gFakEta2->Draw("pc"); legEta2->Draw();
  c9->cd(2); hDumPtFak->Draw(); gFakPt->Draw("pc"); gFakPt2->Draw("pc"); legPt2->Draw();
//  c9->GetPad(2)->SetLogx();

  // Secondaries
  TGraphAsymmErrors *gSecEta = new TGraphAsymmErrors(); gSecEta->SetName("gSecEta");
  gSecEta->BayesDivide(hSecEta,hRecEta);
  gSecEta->SetMarkerStyle(25);
  gSecEta->SetLineStyle(2);
  gSecEta->SetLineColor(2);
  gSecEta->SetMarkerColor(2);

  TGraphAsymmErrors *gSecPt = new TGraphAsymmErrors(); gSecPt->SetName("gSecPt");
  gSecPt->BayesDivide(hSecPt,hRecPt);
  gSecPt->SetMarkerStyle(24);
  gSecPt->SetLineColor(4);
  gSecPt->SetMarkerColor(4);

  TGraphAsymmErrors *gSecEta2 = new TGraphAsymmErrors(); gSecEta2->SetName("gSecEta2");
  gSecEta2->BayesDivide(hSecEta2,hRecEta2);
  gSecEta2->SetMarkerStyle(24);
  gSecEta2->SetLineColor(4);
  gSecEta2->SetMarkerColor(4);

  TGraphAsymmErrors *gSecPt2 = new TGraphAsymmErrors();  gSecPt2->SetName("gSecPt2");
  gSecPt2->BayesDivide(hSecPt2,hRecPt2);
  gSecPt2->SetMarkerStyle(25);
  gSecPt2->SetLineStyle(2);
  gSecPt2->SetLineColor(2);
  gSecPt2->SetMarkerColor(2);

  TCanvas *c10 = new TCanvas("c10","Secondary Fraction",900,500);
  c10->Divide(2,1);
  hDumEtaSec=(TH1F*) hDumEta2->Clone("hDumEtaMul");
  hDumEtaSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  hDumPtSec=(TH1F*) hDumPt2->Clone("hDumPtMul");
  hDumPtSec->GetYaxis()->SetTitle("Non-Primary Reconstruction Fraction");
  c10->cd(1); hDumEtaSec->Draw(); gSecEta->Draw("pc"); gSecEta2->Draw("pc"); legEta2->Draw();
  c10->cd(2); hDumPtSec->Draw(); gSecPt->Draw("pc"); gSecPt2->Draw("pc"); legPt2->Draw();
//  c10->GetPad(2)->SetLogx();

  /*
  printCanvases(c1,"hitrk_can1",0,1);
  printCanvases(c2,"hitrk_can2",0,1);
  printCanvases(c3,"hitrk_can3",0,1);
  printCanvases(c4,"hitrk_can4",0,1);
  printCanvases(c5,"hitrk_can5",0,1);
  printCanvases(c6,"hitrk_can6",0,1);
  printCanvases(c7,"hitrk_can7",0,1);
  printCanvases(c8,"hitrk_can8",0,1);
  printCanvases(c9,"hitrk_can9",0,1);
  printCanvases(c10,"hitrk_can10",0,1);
  */


  /*
  TFile *f = new TFile("trkEffPY8.root","RECREATE");
  gAccPt->Write(); gAccPt2->Write(); gAccEta->Write(); gAccEta2->Write();
  gEffPt->Write(); gEffPt2->Write(); gEffEta->Write(); gEffEta2->Write();
  gMulPt->Write(); gMulPt2->Write(); gMulEta->Write(); gMulEta2->Write();
  gFakPt->Write(); gFakPt2->Write(); gFakEta->Write(); gFakEta2->Write();
  gSecPt->Write(); gSecPt2->Write(); gSecEta->Write(); gSecEta2->Write();
  f->Close();
  */
}
Exemplo n.º 20
0
void ComboPlotLQ1()
{
 // **********************************************
 // *            Input parameters                *
 // **********************************************
 
static const int numbetas = 178;


 Double_t beta_vals[178]={0.006,0.008,0.01,0.012,0.014,0.016,0.018,0.02,0.022,0.024,0.026,0.028,0.03,0.032,0.034,0.036,0.038,0.04,0.042,0.044,0.046,0.048,0.05,0.052,0.054,0.056,0.058,0.06,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.078,0.08,0.082,0.084,0.086,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.38,0.39,0.4,0.41,0.42,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.69,0.7,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.902,0.904,0.906,0.908,0.91,0.912,0.914,0.916,0.918,0.92,0.922,0.924,0.926,0.928,0.93,0.932,0.934,0.936,0.938,0.94,0.942,0.944,0.946,0.948,0.95,0.952,0.954,0.956,0.958,0.96,0.962,0.964,0.966,0.968,0.97,0.972,0.974,0.976,0.978,0.98,0.982,0.984,0.986,0.988,0.99,0.992,0.994,0.996,0.998,0.9995};


Double_t m_expected_combo[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,362.1,406.1,437.9,467.2,495.2,512.8,529.0,544.0,556.7,567.6,577.0,587.1,596.5,606.4,615.5,624.1,633.7,641.9,650.0,656.8,663.1,669.8,675.7,681.5,686.9,692.4,698.0,702.4,705.8,709.2,712.7,716.1,719.0,722.4,725.3,728.3,731.3,734.0,737.0,739.9,742.4,754.5,764.3,773.1,781.8,789.3,796.9,803.9,811.4,818.5,825.0,831.4,837.8,843.8,849.0,854.2,859.4,863.8,868.4,872.9,877.2,881.5,885.1,888.6,892.3,895.9,898.9,901.9,904.3,906.9,909.5,911.7,913.9,916.0,918.6,920.5,922.7,925.0,927.0,929.3,931.6,933.3,935.6,937.8,939.8,942.3,944.4,946.6,948.4,951.1,952.5,954.8,956.6,958.9,960.8,962.7,965.1,966.8,968.9,970.9,972.7,974.8,976.2,978.1,980.0,982.1,983.5,985.5,987.6,989.3,991.3,993.3,995.1,996.9,999.1,1000.9,1002.4,1004.0,1005.6,1007.3,1009.2,1009.6,1009.9,1010.6,1010.7,1011.0,1011.7,1011.7,1012.0,1012.4,1012.9,1013.1,1013.8,1014.1,1014.6,1014.8,1015.2,1015.6,1015.8,1016.3,1016.8,1017.1,1017.5,1018.1,1018.5,1019.1,1019.2,1019.6,1020.2,1020.4,1020.9,1021.5,1022.0,1022.2,1022.5,1023.0,1023.5,1024.1,1024.7,1024.8,1025.3,1025.8,1026.0,1026.8,1027.3,1027.6,1028.1,1028.5,1029.3,1029.5,1030.0};
Double_t m_observed_combo[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,354.8,372.6,391.9,418.1,509.8,514.2,518.4,522.4,526.1,529.7,533.2,536.6,539.7,542.8,545.7,548.5,551.4,554.4,557.2,560.0,562.6,565.2,567.6,570.0,572.3,574.6,576.7,578.8,580.9,582.9,584.9,586.9,588.8,590.6,592.4,594.1,595.7,597.3,598.9,607.3,615.0,622.1,628.6,634.4,639.8,644.7,649.2,769.7,774.0,778.0,781.6,785.1,788.4,791.7,794.9,797.9,800.8,803.5,806.2,808.6,810.9,813.0,815.1,817.0,819.0,820.9,822.8,824.5,826.2,827.9,829.6,831.2,833.1,834.7,836.3,837.9,839.5,841.0,842.5,843.9,845.3,846.7,848.1,849.5,860.3,875.3,887.1,900.8,904.9,909.1,913.2,917.3,922.1,926.8,931.8,937.1,942.7,948.7,951.2,952.8,954.4,956.3,957.8,959.2,960.7,962.5,963.8,965.4,967.1,968.7,970.1,971.7,973.5,975.1,976.9,978.6,980.5,982.3,984.1,984.5,984.9,985.3,985.6,986.0,986.4,986.8,987.3,987.7,988.1,988.2,988.7,989.1,989.5,989.9,990.3,990.7,991.2,991.6,992.0,992.5,992.9,993.4,993.8,994.3,994.7,995.2,995.7,996.1,996.6,997.1,997.5,998.0,998.5,999.0,999.5,1000.1,1000.9,1001.1,1001.8,1002.7,1003.3,1004.0,1004.7,1005.3,1005.9,1006.5,1007.2,1007.9,1008.4};
Double_t m_1sigma_combo[356]={300.0,300.0,300.0,300.0,354.0,411.8,457.4,494.2,518.9,540.8,559.6,573.9,588.3,601.1,614.8,627.8,640.5,651.3,660.8,670.6,678.3,687.3,694.9,701.7,706.9,712.1,716.5,721.4,725.8,730.0,734.4,738.5,742.4,746.4,750.1,753.3,756.3,759.3,762.2,765.0,767.8,770.3,773.2,775.8,778.4,781.0,783.2,785.5,796.8,808.5,819.4,829.9,839.8,848.8,857.2,865.0,872.3,879.8,885.6,891.7,897.8,902.4,906.2,910.1,913.5,916.9,920.0,923.1,926.4,929.5,932.3,935.3,938.3,940.9,943.6,946.2,949.0,952.2,955.1,957.8,960.7,963.5,966.2,968.9,971.7,974.1,976.7,979.3,981.5,983.8,986.1,988.4,990.8,993.1,995.2,997.2,999.7,1001.5,1002.9,1004.7,1006.8,1008.0,1009.8,1011.3,1013.0,1014.8,1016.6,1018.2,1020.0,1021.3,1022.8,1024.3,1025.9,1027.3,1028.9,1030.6,1031.9,1033.8,1035.1,1036.8,1038.2,1039.8,1041.5,1043.1,1044.7,1046.3,1048.0,1049.7,1050.4,1050.7,1051.0,1051.4,1051.7,1052.3,1052.3,1052.7,1053.0,1053.6,1053.7,1054.0,1054.3,1055.0,1055.0,1055.3,1055.7,1056.1,1056.4,1057.0,1057.3,1057.7,1058.1,1058.4,1058.7,1059.1,1059.4,1059.8,1060.2,1060.8,1061.1,1061.8,1061.9,1062.3,1062.7,1063.1,1063.7,1064.0,1064.4,1064.8,1065.4,1065.6,1066.2,1066.8,1067.1,1067.7,1067.7,1068.4,1068.8,1069.3,987.6,986.9,986.9,986.1,985.1,984.6,984.1,983.7,983.0,982.6,982.0,981.5,981.2,980.4,980.1,979.3,978.8,978.3,977.9,977.4,976.9,976.3,976.0,975.2,974.7,974.7,973.8,973.4,972.8,972.3,971.9,971.7,970.9,970.5,970.1,969.9,969.3,968.8,968.4,967.6,967.2,966.7,966.3,965.9,965.9,965.1,964.7,964.4,963.8,963.4,963.0,960.8,958.8,956.8,955.2,952.9,951.0,948.7,946.3,943.9,941.2,939.0,937.4,934.6,932.3,930.8,928.3,926.5,924.2,922.4,920.7,918.4,916.8,914.7,913.6,911.1,909.3,907.3,905.4,903.7,901.9,900.2,898.3,895.8,893.9,891.6,889.4,887.6,885.5,883.5,881.4,879.3,876.5,874.1,871.3,868.7,866.3,863.7,861.3,857.9,855.4,852.1,849.8,846.4,843.1,840.4,836.9,833.2,829.3,825.9,822.0,818.1,814.4,809.8,805.2,800.6,796.2,791.6,787.0,782.4,777.3,771.7,766.0,760.2,753.6,746.2,737.1,727.9,717.6,706.8,692.3,688.3,684.3,680.5,676.5,672.9,668.9,664.1,659.9,655.6,650.9,645.5,639.8,633.9,627.4,621.0,614.7,608.4,602.2,596.0,589.2,581.9,575.5,568.5,561.5,554.0,544.8,534.1,522.9,511.8,500.2,479.3,462.6,440.3,417.5,391.3,360.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
Double_t m_2sigma_combo[356]={300.0,300.0,300.0,412.7,469.9,512.5,542.8,564.9,583.8,602.5,620.6,637.4,653.2,665.9,677.8,689.1,700.0,706.8,713.8,720.2,726.0,732.4,737.9,743.8,748.7,753.9,757.6,761.7,765.7,769.3,773.2,776.8,780.3,783.7,786.8,790.2,793.4,796.6,799.4,803.0,806.5,809.6,812.9,815.9,819.2,822.4,825.0,827.9,842.1,855.1,866.3,877.4,886.7,895.7,902.9,908.6,913.8,918.5,922.9,927.5,931.6,935.7,939.7,943.6,947.4,951.2,955.4,959.6,963.6,967.6,971.0,974.9,978.6,982.1,985.4,988.6,992.1,995.0,998.3,1001.0,1003.2,1005.7,1008.0,1010.2,1012.6,1014.8,1017.0,1019.0,1021.2,1023.1,1025.2,1027.1,1029.0,1030.9,1032.8,1034.3,1036.5,1038.1,1039.7,1041.6,1043.5,1044.7,1046.5,1047.9,1050.0,1051.0,1052.5,1054.0,1055.7,1057.1,1058.8,1060.0,1061.5,1062.8,1064.3,1065.8,1067.0,1068.7,1070.0,1071.4,1073.0,1074.2,1075.9,1077.4,1078.8,1080.5,1082.0,1083.8,1084.2,1084.4,1084.8,1085.4,1085.7,1085.9,1086.4,1086.6,1087.0,1087.3,1087.6,1087.9,1088.4,1088.9,1089.0,1089.4,1090.1,1090.3,1090.7,1091.1,1091.3,1091.9,1092.2,1092.6,1092.7,1093.2,1093.5,1094.1,1094.4,1094.8,1095.1,1095.8,1096.0,1096.7,1097.0,1097.7,1098.0,1098.0,1098.7,1099.0,1099.7,1100.0,1100.3,1100.9,1101.6,1102.0,1102.0,1102.5,1103.0,1103.6,945.5,944.4,944.1,942.9,941.5,940.7,940.1,939.2,938.6,938.1,937.1,936.3,935.2,934.4,934.1,933.3,932.8,931.6,930.9,930.3,929.8,928.8,928.1,927.5,926.6,926.0,925.1,924.5,924.0,923.4,922.5,922.5,921.4,921.2,920.2,920.3,919.2,918.7,917.7,917.3,916.4,916.3,915.4,915.2,914.4,914.2,913.2,913.1,912.1,912.1,911.0,908.5,905.8,903.0,900.8,898.8,896.6,894.7,892.9,891.0,889.1,887.2,886.0,884.0,882.2,880.7,878.7,877.0,874.5,872.5,870.7,868.7,867.2,864.9,863.6,861.3,859.5,857.5,855.6,853.9,851.7,850.1,848.1,845.9,844.1,842.2,840.5,838.9,836.5,834.4,832.2,830.0,827.7,825.8,823.5,821.2,818.8,816.6,814.3,811.5,808.8,806.2,803.9,800.6,798.0,795.5,792.3,789.5,786.3,783.4,780.2,776.6,773.6,769.8,766.2,762.5,758.3,754.3,749.8,744.3,738.7,732.4,726.2,719.3,711.9,704.4,693.7,680.8,666.8,651.4,631.6,626.8,622.1,617.2,613.1,608.3,604.6,599.3,594.3,590.2,584.8,580.0,575.0,570.0,565.0,559.8,554.6,548.3,540.8,532.5,524.9,516.8,508.7,501.1,484.7,470.4,459.2,440.8,423.8,407.4,384.1,361.3,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
Double_t m_expected_lljj[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,301.6,306.2,311.1,315.4,338.5,361.9,385.8,407.9,426.6,445.3,462.0,476.9,492.1,508.0,524.6,541.1,555.3,567.1,578.3,589.9,600.5,612.8,624.7,637.1,648.0,659.6,671.8,682.7,694.0,704.3,713.7,723.1,732.2,741.7,750.3,758.6,767.1,775.2,783.2,791.4,800.0,805.2,810.5,815.7,821.0,826.1,831.0,836.4,841.6,846.2,851.5,857.6,862.9,868.0,873.5,878.9,884.0,888.8,893.4,899.0,904.7,911.6,918.0,924.1,929.8,935.7,942.0,947.1,951.9,955.8,959.6,963.5,967.0,970.6,974.1,977.8,981.3,985.1,988.0,991.6,994.7,998.0,1001.1,1004.0,1004.7,1004.9,1005.5,1006.3,1006.8,1007.5,1007.9,1008.5,1008.9,1009.2,1009.9,1010.6,1011.0,1011.7,1012.0,1012.7,1013.0,1013.8,1014.1,1014.8,1015.2,1015.9,1016.3,1017.0,1017.4,1018.0,1018.5,1019.0,1019.8,1020.0,1020.6,1021.1,1021.5,1022.0,1022.6,1023.0,1023.7,1024.3,1024.5,1025.3,1025.6,1026.2,1026.4,1027.3,1027.6,1028.1,1028.5,1029.1,1029.5,1030.0};
Double_t m_observed_lljj[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.6,304.3,307.9,311.4,314.8,332.0,348.7,365.7,382.5,399.0,410.4,420.9,431.0,440.6,450.1,458.0,465.2,472.1,478.8,485.6,492.2,498.5,524.9,551.8,556.8,561.8,566.6,571.2,575.7,580.1,584.5,588.8,592.9,596.9,601.7,609.0,616.3,623.6,630.8,637.8,644.7,713.9,719.8,725.6,731.2,736.9,742.5,748.0,756.6,766.6,777.0,787.3,798.0,802.9,806.5,809.9,813.5,816.9,820.2,823.5,826.8,830.1,833.4,836.7,840.1,843.2,846.2,849.2,864.7,884.0,951.4,954.0,956.6,959.2,961.7,964.2,966.7,969.1,971.5,974.0,976.3,978.7,981.0,983.3,985.6,986.0,986.5,986.9,987.4,987.8,988.3,988.7,989.2,989.6,990.1,990.5,991.0,991.4,991.8,992.3,992.7,993.2,993.6,994.1,994.5,994.9,995.4,995.8,996.2,996.7,997.1,997.5,998.0,998.4,998.8,999.2,999.7,1000.1,1000.6,1001.1,1001.6,1002.1,1002.6,1003.1,1003.6,1004.1,1004.6,1005.1,1005.6,1006.1,1006.6,1007.1,1007.5,1008.0,1008.4};
Double_t m_expected_lvjj[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,362.0,418.0,462.7,496.8,515.1,530.7,546.2,558.2,569.0,578.7,589.4,598.8,608.4,617.5,627.2,636.3,644.2,652.2,658.7,665.4,671.6,676.8,682.4,688.1,694.1,699.4,703.2,706.6,709.9,713.6,716.5,719.7,723.0,725.7,728.9,731.8,734.4,737.1,740.2,742.4,754.5,764.1,772.7,781.0,788.1,795.2,802.3,808.8,815.4,821.8,827.8,833.2,838.7,843.4,847.8,852.0,856.4,859.9,863.3,866.5,869.4,872.4,874.9,877.6,879.8,881.8,883.7,885.2,886.7,888.0,889.1,890.2,891.3,892.4,892.6,893.6,893.9,894.8,894.4,894.8,894.4,894.8,893.9,893.6,892.6,892.4,891.3,890.2,889.1,888.0,886.7,885.2,883.7,881.8,879.8,877.6,874.9,872.4,869.4,866.5,863.3,859.9,856.4,852.0,847.8,843.4,838.7,833.2,827.8,821.8,815.4,808.8,802.3,795.2,788.1,781.0,772.7,764.1,754.5,742.4,740.2,737.1,734.4,731.8,728.9,725.7,723.0,719.7,716.5,713.6,709.9,706.6,703.2,699.4,694.1,688.1,682.4,676.8,671.6,665.4,658.7,652.2,644.2,636.3,627.2,617.5,608.4,598.8,589.4,578.7,569.0,558.2,546.2,530.7,515.1,496.8,462.7,418.0,362.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0};
Double_t m_observed_lvjj[178]={300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,363.2,380.5,398.8,424.8,511.1,515.7,520.1,524.3,528.4,532.2,536.0,539.5,542.9,546.2,549.4,552.5,555.6,558.5,561.3,564.0,566.7,569.3,571.8,574.2,576.5,578.8,581.1,583.3,585.5,587.7,589.8,591.8,593.7,595.6,597.5,599.3,601.2,611.0,619.8,628.1,635.5,642.4,648.7,770.3,775.6,780.5,785.1,789.3,793.4,797.2,800.9,804.9,808.6,812.1,815.4,818.6,821.5,824.2,826.7,829.0,831.3,833.4,835.5,837.3,839.0,840.5,841.8,843.0,844.1,845.0,845.8,846.4,847.0,847.4,847.7,847.9,847.9,847.9,847.7,847.4,847.0,846.4,845.8,845.0,844.1,843.0,841.8,840.5,839.0,837.3,835.5,833.4,831.3,829.0,826.7,824.2,821.5,818.6,815.4,812.1,808.6,804.9,800.9,797.2,793.4,789.3,785.1,780.5,775.6,770.3,648.7,642.4,635.5,628.1,619.8,611.0,601.2,599.3,597.5,595.6,593.7,591.8,589.8,587.7,585.5,583.3,581.1,578.8,576.5,574.2,571.8,569.3,566.7,564.0,561.3,558.5,555.6,552.5,549.4,546.2,542.9,539.5,536.0,532.2,528.4,524.3,520.1,515.7,511.1,424.8,398.8,380.5,363.2,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0,300.0};


// INFORMATION PASTING OVER

Double_t beta_valsdub[numbetas*2];
int ind = numbetas;
for (unsigned int ii = 0; ii < numbetas*2; ++ii){
	if (ii < numbetas) beta_valsdub[ii] = beta_vals[ii];
	else {
		ind = ind -1;
		beta_valsdub[ii] = beta_vals[ind];
	}
}

for (unsigned int ii = 0; ii < numbetas; ++ii){
	if (beta_vals[ii] == 0.5) {
	std::cout<<"## ---------------- B = 1/2 Limits ----------------------"<<std::endl;
	std::cout<<"##   lvjj Expected : "<<m_expected_lvjj[ii]<<std::endl;
	std::cout<<"##   lvjj Observed : "<<m_observed_lvjj[ii]<<std::endl;
	std::cout<<"##  combo Expected : "<<m_expected_combo[ii]<<std::endl;
	std::cout<<"##  combo Observed : "<<m_observed_combo[ii]<<std::endl;
	std::cout<<"##   "<<std::endl;
	}
	if (beta_vals[ii] > 0.999) {
	std::cout<<"## ----------------   B = 1 Limits ----------------------"<<std::endl;
	std::cout<<"##   lljj Expected : "<<m_expected_lljj[ii]<<std::endl;
	std::cout<<"##   lljj Observed : "<<m_observed_lljj[ii]<<std::endl;
	std::cout<<"##  combo Expected : "<<m_expected_combo[ii]<<std::endl;
	std::cout<<"## combo Observed : "<<m_observed_combo[ii]<<std::endl;
	std::cout<<"##   "<<std::endl;

	}	

}

 // filename for the final plot (NB: changing the name extension changes the file format)
 string fileName0 = "LQ1Combination.eps";
 string fileName1 = "LQ1Combination.pdf";
 string fileName2 = "LQ1Combination.png";


 // axes labels for the final plot
 string title = ";M_{LQ} [GeV];#beta";

 // integrated luminosity
 string sqrts = "#sqrt{s} = 8 TeV";

 // region excluded by Tevatron limits (1 fb-1)
 Double_t x_excl_D0[11] = {214.39,235.13,254.08,268.12,275.92,283.95,289.08,293.09,295.99,297.10,298.89};
 Double_t y_excl_D0[11] = {0,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1};

 // region excluded by ATLAS limits (35 pb-1)
 Double_t x_excl_ATLAS[13] = {200,221.91,243.07,254.12,265.17,287.83,304.68,318.54,331.46,342.88,353.75,363.11,375.47};
 Double_t y_excl_ATLAS[13] = {0.095,0.10,0.126,0.151,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.0};
 
 // region excluded by Tevatron limits (5.4 fb-1)
 Double_t x_excl_D0_new[11] = {243.13,275.12,308.18,320.02,325.95,327.96,325.95,320.02,308.18,275.12,243.13};
 Double_t y_excl_D0_new[11] = {0.05,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,0.95};

//Double_t AtlasComboMass[13] = {250,253.997194950912,278.541374474053,305.539971949509,341.374474053296,352.173913043478,362.973352033661,371.318373071529,385.063113604488,395.371669004208,413.534361851332,421.879382889201,250};
//Double_t AtlasComboBeta[13] ={.1,0.12280701754386,0.14619883040936,0.19493177387914,0.34892787524366,0.39766081871345,0.51851851851852,0.60038986354776,0.74269005847953,0.79727095516569,0.93567251461988,0.99805068226121,1.0};

// Double_t AtlasComboMass[34] = {250.88,284.14,00.0,332.10,354.57,357.86,361.14,380.60,401.43,417.33,437.61,459.81,463.92,477.07,493.79,511.05,521.19,541.75,553.81,565.86,581.49,596.29,613.55,629.45,641.50,647.53,653.56,662.61,667.27,674.67,679.87,683.16,250,250};
// Double_t AtlasComboBeta[34] ={0.04541595925297,0.04626485568761,0.04668930390492,0.04711375212224,0.04711375212224,0.04753820033956,0.04881154499151,0.05772495755518,0.06748726655348,0.07555178268251,0.08446519524618,0.09507640067912,0.09847198641766,0.1213921901528,0.14983022071307,0.17996604414261,0.19821731748727,0.26146010186757,0.29966044142615,0.36332767402377,0.4393039049236,0.51273344651952,0.58828522920204,0.65195246179966,0.69694397283531,0.74363327674024,0.78989813242784,0.87054329371817,0.90789473684211,0.94482173174873,0.97453310696095,1.00042444821732,1.00169779286927,0.04499151103565};

// Double_t CMSComboBeta[165]={     0.034,0.036,0.038,0.04,0.042,0.044,0.046,0.048,0.05,0.052,0.054,0.056,0.058,0.06,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.078,0.08,0.082,0.084,0.086,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.38,0.39,0.4,0.41,0.42,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.69,0.7,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.902,0.904,0.906,0.908,0.91,0.912,0.914,0.916,0.918,0.92,0.922,0.924,0.926,0.928,0.93,0.932,0.934,0.936,0.938,0.94,0.942,0.944,0.946,0.948,0.95,0.952,0.954,0.956,0.958,0.96,0.962,0.964,0.966,0.968,0.97,0.972,0.974,0.976,0.978,0.98,0.982,0.984,0.986,0.988,0.99,0.992,0.994,0.996,0.998,0.9995,1.0,0.034};
// Double_t CMSComboMass[165]={    300.,345.9,356.6,363.4,369.9,376.1,382.1,387.8,393.3,398.7,404.2,409.7,414.9,419.3,424.1,429.0,433.8,438.5,443.0,447.2,451.8,457.2,462.4,467.4,471.9,476.6,481.2,485.6,490.0,494.3,498.5,500.7,502.5,504.3,512.4,520.0,527.0,533.3,539.1,545.0,550.1,561.5,573.1,583.2,592.5,600.2,602.4,604.7,607.0,609.1,611.1,613.1,615.0,617.0,618.7,620.5,622.5,624.0,625.7,627.6,628.9,630.8,632.5,634.0,635.6,637.2,638.8,640.3,641.9,643.5,645.2,646.8,648.1,649.8,653.8,657.2,661.5,665.8,673.7,678.0,682.3,686.5,691.2,695.5,699.9,704.8,710.2,714.8,719.6,725.0,730.0,734.8,740.9,746.8,750.5,754.0,757.9,760.9,764.6,767.6,771.4,774.0,777.9,781.0,784.2,787.1,791.0,794.1,797.3,800.8,804.0,807.6,811.2,811.8,812.2,813.3,814.0,814.4,815.0,815.5,816.2,817.2,817.5,818.4,819.3,819.7,820.5,821.0,821.4,822.8,823.2,823.5,824.5,825.4,825.7,826.3,827.3,828.0,828.5,829.2,829.9,830.8,831.0,831.8,832.8,832.7,834.2,834.0,834.7,835.8,836.1,837.0,838.0,838.4,838.6,839.3,840.5,841.2,841.6,841.6,842.1,843.5,844.0,300,300};

 static const int n_exclude = 204;

 Double_t beta_CMSATLAS[n_exclude]={0.018,0.018,0.02,0.022,0.024,0.026,0.028,0.03,0.032,0.034,0.036,0.038,0.04,0.042,0.044,0.046,0.048,0.05,0.052,0.054,0.056,0.058,0.06,0.062,0.064,0.066,0.068,0.07,0.072,0.074,0.076,0.078,0.08,0.082,0.084,0.086,0.088,0.09,0.092,0.094,0.096,0.098,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.21,0.22,0.23,0.24,0.26,0.27,0.28,0.29,0.3,0.31,0.32,0.33,0.34,0.35,0.36,0.37,0.38,0.39,0.4,0.41,0.42,0.43,0.44,0.45,0.46,0.47,0.48,0.49,0.5,0.51,0.52,0.53,0.54,0.55,0.56,0.57,0.58,0.59,0.6,0.61,0.62,0.63,0.64,0.65,0.66,0.67,0.68,0.69,0.7,0.71,0.72,0.73,0.74,0.75,0.76,0.77,0.78,0.79,0.8,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.9,0.902,0.904,0.906,0.908,0.91,0.912,0.914,0.916,0.918,0.92,0.922,0.924,0.926,0.928,0.93,0.932,0.934,0.936,0.938,0.94,0.942,0.944,0.946,0.948,0.95,0.952,0.954,0.956,0.958,0.96,0.962,0.964,0.966,0.968,0.97,0.972,0.974,0.976,0.978,0.98,0.982,0.984,0.986,0.988,0.99,0.992,0.994,0.996,0.998,0.9995,0.9995, 0.9459430964276001, 0.9113315376333271, 0.880788245243444, 0.8298887187568689, 0.7789832314403973, 0.7321489909432641, 0.6934572440848077, 0.6506942504070129, 0.552954522593408, 0.5977471788509756, 0.5020579765217812, 0.4572384965296794, 0.4246416982404375, 0.39408648419076153, 0.3676025169604238, 0.3044564654514025, 0.23723022587819786, 0.34112153014503444, 0.26778842034282224, 0.18626214984781253, 0.20463342758895597, 0.16789087210666898, 0.15155521777519476, 0.13521956344372055, 0.11888390911224611, 0.10254527436582372, 0.09028086685368775, 0.07185892205842359, 0.08412332957055957, 0.06366576136562607, 0.05140135385349032};


 Double_t mass_CMSATLAS [n_exclude]={300.,317.5,342.2,358.0,369.5,379.8,389.5,398.6,407.1,414.6,422.1,429.1,435.6,441.5,447.3,452.8,457.1,461.1,465.1,468.7,472.3,475.7,479.3,482.9,485.9,488.7,491.5,494.1,496.6,499.9,501.4,502.8,504.1,505.4,506.8,508.0,509.6,510.8,511.9,513.0,514.0,515.6,516.6,521.5,525.9,530.2,533.7,537.3,540.3,543.1,545.7,548.1,552.0,561.4,569.0,576.5,583.9,596.0,600.1,603.2,605.6,607.2,609.4,611.8,613.3,615.7,617.6,619.6,621.8,623.1,625.2,626.6,628.6,630.0,632.2,633.5,635.5,636.8,638.8,640.4,642.5,643.8,645.1,646.9,648.7,651.9,655.3,661.7,666.6,671.8,678.4,685.3,693.6,704.1,716.6,729.2,746.9,751.7,753.7,756.1,758.6,760.7,763.3,765.5,767.7,770.0,772.3,774.7,776.9,779.3,781.7,783.9,786.5,788.6,790.9,793.4,795.5,797.7,800.0,802.5,805.2,807.2,807.8,808.6,808.9,809.5,809.9,810.5,810.4,811.3,811.7,812.2,812.9,813.2,813.9,814.4,814.6,815.3,815.8,816.1,816.6,817.2,817.7,818.1,818.4,818.9,819.6,820.2,820.4,821.2,821.7,822.0,822.3,823.0,823.5,823.7,824.2,824.7,825.0,825.8,826.2,826.8,827.1,827.8,828.3,828.6,829.0,829.9,830.3,830.8,831.1,831.3, 659.1508052708638, 654.4655929721814, 652.1229868228403, 648.6090775988287, 645.0951683748169, 639.2386530014641, 633.3821376281112, 627.5256222547583, 621.6691068814055, 609.9560761346999, 613.4699853587115, 607.6134699853586, 593.5578330893118, 583.0161054172767, 574.8169838945827, 566.6178623718887, 550.2196193265007, 530.3074670571009, 559.5900439238652, 539.6778916544655, 499.8535871156661, 519.7657393850658, 479.94143484626636, 460.02928257686676, 440.11713030746705, 420.2049780380672, 399.121522693997, 379.2093704245973, 339.38506588579787, 359.2972181551976, 319.47291361639816, 299.56076134699845};
 




Double_t mass_CMS[116]={300.0000,319.8520,331.7728,339.8246,351.0135,359.7973,370.1496,379.8745,389.8086,399.8472,409.4675,420.0290,429.8584,439.4788,449.3082,460.0788,469.4900,478.3784,486.8485,494.2728,498.7693,501.8018,508.4942,515.2912,522.0882,527.5257,532.4405,536.7278,541.8517,545.7207,549.0669,551.5766,557.4324,564.9614,573.7452,580.5421,586.1889,592.5676,597.2732,600.0965,602.0833,603.2336,605.7432,608.1483,610.8671,613.0631,615.0499,617.0367,618.7098,621.1149,623.7291,625.9250,627.4936,630.2124,633.2449,635.5454,638.2642,640.7738,642.9698,645.8977,647.6754,649.4530,650.0804,653.4266,656.4591,658.1322,660.8510,665.2429,669.6348,673.9221,677.7912,682.0785,685.5293,689.3983,694.5222,699.1232,704.2471,709.3710,713.7629,719.3050,723.5923,728.2979,730.9122,733.5264,736.8726,741.8919,746.8066,750.7802,755.5904,759.5640,761.1326,764.5833,768.8707,772.1123,773.3671,777.8636,782.9875,786.4382,788.9479,793.4443,798.4636,801.7053,806.2017,810.2799,814.7764,817.1815,823.3510,827.6384,832.6577,836.2130,838.1998,840.9186,841.9643,842.2780,300.0000,300.0000};
Double_t beta_CMS[116]={0.0333,0.0337,0.0345,0.0350,0.0357,0.0376,0.0411,0.0445,0.0478,0.0516,0.0550,0.0593,0.0636,0.0681,0.0724,0.0767,0.0804,0.0841,0.0881,0.0914,0.0934,0.0963,0.1043,0.1135,0.1225,0.1303,0.1382,0.1453,0.1541,0.1613,0.1678,0.1710,0.1756,0.1824,0.1903,0.1966,0.2027,0.2098,0.2154,0.2197,0.2271,0.2328,0.2440,0.2547,0.2679,0.2781,0.2896,0.2992,0.3090,0.3218,0.3360,0.3485,0.3591,0.3764,0.3936,0.4092,0.4252,0.4411,0.4563,0.4722,0.4854,0.4974,0.5005,0.5085,0.5167,0.5215,0.5281,0.5378,0.5489,0.5597,0.5697,0.5786,0.5876,0.5956,0.6076,0.6185,0.6279,0.6383,0.6478,0.6586,0.6668,0.6757,0.6811,0.6874,0.6929,0.7014,0.7093,0.7205,0.7330,0.7441,0.7503,0.7589,0.7727,0.7815,0.7886,0.7994,0.8154,0.8281,0.8350,0.8470,0.8626,0.8724,0.8855,0.8974,0.9094,0.9200,0.9356,0.9498,0.9632,0.9746,0.9823,0.9897,0.9961,1.0000,1.0000,0.0333};


 static const int n_ex_atlas = 33;
 
 Double_t mass_ATLAS[n_ex_atlas] = {300.,319.472913616,359.297218155,339.385065886,379.209370425,399.121522694,420.204978038,440.117130307,460.029282577,479.941434846,519.765739385,499.853587116,539.677891654,559.590043924,530.307467057,550.219619327,566.617862372,574.816983895,583.016105417,593.557833089,607.613469985,613.469985359,609.956076135,621.669106881,627.525622255,633.382137628,639.238653001,645.095168375,648.609077599,652.122986823,654.465592972,659.150805271, 300.};
 Double_t beta_ATLAS[n_ex_atlas] = {0.0514013538535,0.0636657613656,0.0841233295706,0.0718589220584,0.0902808668537,0.102545274366,0.118883909112,0.135219563444,0.151555217775,0.167890872107,0.204633427589,0.186262149848,0.267788420343,0.341121530145,0.237230225878,0.304456465451,0.36760251696,0.394086484191,0.42464169824,0.45723849653,0.502057976522,0.597747178851,0.552954522593,0.650694250407,0.693457244085,0.732148990943,0.77898323144,0.829888718757,0.880788245243,0.911331537633,0.945943096428,0.998881226739, 1.};



 // turn on/off batch mode
 gROOT->SetBatch(kTRUE);
 // set ROOT style
//  myStyle();
 setTDRStyle();
//  gStyle->SetPadLeftMargin(0.14);
 gROOT->ForceStyle();

 TH2F *bg = new TH2F("bg",title.c_str(), 20, 300., 1350., 100, 0., 1.);
 bg->SetStats(kFALSE);
 bg->GetXaxis()->CenterTitle();
 bg->GetYaxis()->CenterTitle();
 bg->SetTitleOffset(1.,"X");
 bg->SetTitleOffset(1.05,"Y");
//  bg->GetXaxis()->SetNdivisions(505);

 TCanvas *c = new TCanvas("c","",800,800);
 c->cd();

 bg->Draw();

 TGraph *gr_excl_D0 = new TGraph(11,x_excl_D0,y_excl_D0);
 gr_excl_D0->SetLineWidth(3);
 gr_excl_D0->SetLineColor(49);
 gr_excl_D0->SetLineStyle(6);
 //gr_excl_D0->Draw("C");

 TPolyLine*gr_excl_ATLAS = new TPolyLine(n_ex_atlas,mass_ATLAS,beta_ATLAS,"");
 //gr_excl_ATLAS->SetLineWidth(3);
 gr_excl_ATLAS->SetLineColor(8);
 gr_excl_ATLAS->SetFillColor(8);
 gr_excl_ATLAS->SetFillStyle(3345);


 TPolyLine*gr_excl_CMS = new TPolyLine(116,mass_CMS,beta_CMS,"");
 //gr_excl_CMS->SetLineWidth(3);
 gr_excl_CMS->SetLineColor(14);
 gr_excl_CMS->SetFillColor(14);
 gr_excl_CMS->SetFillStyle(3344);

 TPolyLine*gr_excl_CMSborder = new TPolyLine(n_exclude,mass_CMSATLAS,beta_CMSATLAS,"");
 //gr_excl_CMS->SetLineWidth(3);
 gr_excl_CMSborder->SetLineColor(14);
 gr_excl_CMSborder->SetFillColor(14);
 gr_excl_CMSborder->SetFillStyle(3344);

 TGraph *gr_excl_D0_new = new TGraph(11,x_excl_D0_new,y_excl_D0_new);
 gr_excl_D0_new->SetLineWidth(3);
 gr_excl_D0_new->SetLineColor(30);
 gr_excl_D0_new->SetLineStyle(7);
 //gr_excl_D0_new->Draw("C");


// ------------------------------------ LLJJ CURVES  -------------------------------------//
 TPolyLine *beta_vs_m_lljj_observed = new TPolyLine(numbetas, m_observed_lljj, beta_vals);
 TPolyLine *beta_vs_m_lljj_expected = new TPolyLine(numbetas, m_expected_lljj, beta_vals);
 //TPolyLine *beta_vs_m_lljj_observed_shade = new TPolyLine(numbetas*2, m_2sigma_lljj, beta_valsdub);
 
 beta_vs_m_lljj_observed->SetLineWidth(2);
 beta_vs_m_lljj_observed->SetLineColor(kBlue);
 beta_vs_m_lljj_observed->SetLineStyle(1);

 beta_vs_m_lljj_expected->SetLineWidth(2);
 beta_vs_m_lljj_expected->SetLineColor(kBlue);
 beta_vs_m_lljj_expected->SetLineStyle(2);
 
 
 //beta_vs_m_lljj_observed_shade->SetLineWidth(3);
 //beta_vs_m_lljj_observed_shade->SetLineColor(kGreen+2);
 //beta_vs_m_lljj_observed_shade->SetLineStyle(4);
 //beta_vs_m_lljj_observed_shade->SetFillStyle(3425);
 //beta_vs_m_lljj_observed_shade->SetFillColor(kGreen+2);
 //beta_vs_m_lljj_observed_shade->Draw("f");




// ------------------------------------ LVJJ CURVES  -------------------------------------//

 TPolyLine *beta_vs_m_lvjj_observed = new TPolyLine(numbetas, m_observed_lvjj, beta_vals);
 TPolyLine *beta_vs_m_lvjj_expected = new TPolyLine(numbetas, m_expected_lvjj, beta_vals);
 //TPolyLine *beta_vs_m_lvjj_observed_shade = new TPolyLine(numbetas*2, m_2sigma_lvjj, beta_valsdub);
 
 beta_vs_m_lvjj_observed->SetLineWidth(2);
 beta_vs_m_lvjj_observed->SetLineColor(kRed);
 beta_vs_m_lvjj_observed->SetLineStyle(1);
 
 beta_vs_m_lvjj_expected->SetLineWidth(2);
 beta_vs_m_lvjj_expected->SetLineColor(kRed);
 beta_vs_m_lvjj_expected->SetLineStyle(2);
 
 //beta_vs_m_lvjj_observed_shade->SetFillStyle(3452);
 //beta_vs_m_lvjj_observed_shade->SetFillColor(kRed);
 //beta_vs_m_lvjj_observed_shade->Draw("f");




// ------------------------------------ COMBO CURVES  -------------------------------------//

 TPolyLine *beta_vs_m_comb_observed = new TPolyLine(numbetas, m_observed_combo, beta_vals);
 TPolyLine *beta_vs_m_comb_expected = new TPolyLine(numbetas, m_expected_combo, beta_vals);
 TGraph *beta_vs_m_comb_expected_shade2 = new TGraph(numbetas*2, m_2sigma_combo, beta_valsdub);
 TGraph *beta_vs_m_comb_expected_shade1 = new TGraph(numbetas*2, m_1sigma_combo, beta_valsdub);

 
 beta_vs_m_comb_observed->SetLineWidth(4);
 beta_vs_m_comb_observed->SetLineColor(kBlack);
 beta_vs_m_comb_expected->SetLineStyle(1);

 //beta_vs_m_comb_expected_shade->SetLineWidth(1);
 beta_vs_m_comb_expected_shade1->SetFillStyle(1001);
 beta_vs_m_comb_expected_shade1->SetFillColor(kGreen);
 beta_vs_m_comb_expected_shade2->SetFillStyle(1001);
 beta_vs_m_comb_expected_shade2->SetFillColor(kYellow);

 
 beta_vs_m_comb_expected->SetLineWidth(4);
 beta_vs_m_comb_expected->SetLineColor(kBlack);
 beta_vs_m_comb_expected->SetLineStyle(2);

// ------------------------------------ DRAW  -------------------------------------//

 beta_vs_m_comb_expected_shade2->Draw("f");

 beta_vs_m_comb_expected_shade1->Draw("f");

 gr_excl_ATLAS->Draw("L");
 gr_excl_ATLAS->Draw("F");

 gr_excl_CMSborder->Draw("L");
 gr_excl_CMSborder->Draw("F");

 beta_vs_m_lljj_expected->Draw("C");
 beta_vs_m_lvjj_expected->Draw("C");
 beta_vs_m_comb_expected->Draw("C");
 beta_vs_m_lljj_observed->Draw("C");
 beta_vs_m_lvjj_observed->Draw("C");
 beta_vs_m_comb_observed->Draw("C");




 gPad->RedrawAxis();

 TLegend *legend = new TLegend(.63,.15,.93,.44);
 legend->SetBorderSize(1);
 legend->SetFillColor(0);
 //legend->SetFillStyle(0);
 legend->SetTextFont(42);
 legend->SetMargin(0.15);
 legend->SetHeader("95% CL limits");
 legend->AddEntry(beta_vs_m_comb_observed,"CMS eejj + e#nujj (Obs.)","l");
  legend->AddEntry(beta_vs_m_comb_expected,"CMS eejj + e#nujj (Exp.)","l");

 legend->AddEntry(beta_vs_m_lvjj_observed,"CMS e#nujj (Obs.)","l");
  legend->AddEntry(beta_vs_m_lvjj_expected,"CMS e#nujj (Exp.)","l");

 legend->AddEntry(beta_vs_m_lljj_observed,"CMS eejj (Obs.)","l");
  legend->AddEntry(beta_vs_m_lljj_expected,"CMS eejj (Exp.)","l");

 legend->AddEntry(gr_excl_ATLAS,"ATLAS, 7 TeV, 1.03 fb^{-1}","f");
 legend->AddEntry(gr_excl_CMSborder,"CMS, 7 TeV, 5.0 fb^{-1}","f");

 //legend->AddEntry(gr_excl_D0,"D#oslash (Obs.), 1 fb^{-1}","l");

 legend->Draw();

 TLatex l1;
 l1.SetTextAlign(12);
 l1.SetTextFont(42);
 l1.SetNDC();
 l1.SetTextSize(0.04);
 
 // l1.DrawLatex(0.7,0.41,"CMS 2012");
 // l1.DrawLatex(0.7,0.36,sqrts.c_str());

 // l1.DrawLatex(0.7,0.47,"CMS Preliminary");
 // l1.DrawLatex(0.7,0.41,"Preliminary");
 // l1.DrawLatex(0.7,0.36,sqrts.c_str());
 // l1.DrawLatex(0.14,0.93,"CMS Work In Progress       #sqrt{s} = 8 TeV         19.7 fb^{-1}");
 //l1.DrawLatex(0.14,0.93,"CMS #it{Preliminary}          #sqrt{s} = 8 TeV         19.7 fb^{-1}");
 l1.DrawLatex(0.14,0.93,"CMS                   #sqrt{s} = 8 TeV                  19.7 fb^{-1}");


 TLatex l2;
 l2.SetTextAlign(12);
 l2.SetTextFont(42);
 l2.SetNDC();
 l2.SetTextSize(0.04);
 l2.SetTextColor(kBlue);
 l2.SetTextAngle(30);
 l2.DrawLatex(0.24,0.35,"eejj");
 l2.SetTextColor(kRed);
 l2.SetTextAngle(-20);
 l2.DrawLatex(0.25,0.84,"e#nujj");
 l2.SetTextColor(kBlack);
 l2.SetTextAngle(79);
 l2.DrawLatex(0.65,0.50,"eejj + e#nujj");

 // c->SetGridx();
 // c->SetGridy();
 c->SetLogy(0);
 c->SaveAs(fileName0.c_str());
 c->SaveAs(fileName1.c_str());
 c->SaveAs(fileName2.c_str());


 delete legend;
 delete beta_vs_m_lljj_observed;
 delete beta_vs_m_lvjj_observed;
 delete beta_vs_m_comb_observed;
 delete gr_excl_D0;
 delete gr_excl_ATLAS;
 delete gr_excl_D0_new;
 delete bg;
 delete c;
}
Exemplo n.º 21
0
int RAAweighting()
{
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(0000);
  gStyle->SetEndErrorSize(0);
  gStyle->SetTextSize(0.05);
  gStyle->SetTextFont(42);
  gStyle->SetPadRightMargin(0.043);
  gStyle->SetPadLeftMargin(0.18);
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.145);
  gStyle->SetTitleX(.0f);

  ifstream getdata("theoryRAA/Magdalena.dat");
  if(!getdata.is_open())
    {
      cout<<"  ERROR: Opening the file fails"<<endl;
      return 1;
    }
  Int_t nbin=0;
  while(!getdata.eof())
    {
      getdata>>fpt[nbin]>>fRAA[nbin];
      cout<<fpt[nbin]<<" "<<fRAA[nbin]<<endl;
      nbin++;
    }
  TGraph* gRAA = new TGraph(nbin,fpt,fRAA);
  gRAA->SetMarkerSize(0.8);
  gRAA->SetMarkerStyle(20);
  gRAA->SetMarkerColor(kBlack);

  TCanvas* cRAA = new TCanvas("cRAA","",600,600);
  TH2F* hempty = new TH2F("hempty","",20,0.,55.,10.,0.3,0.8);  
  hempty->GetXaxis()->SetTitle("B^{+} p_{T} (GeV/c)");
  hempty->GetYaxis()->SetTitle("R_{AA}");
  hempty->GetXaxis()->CenterTitle();
  hempty->GetYaxis()->CenterTitle();
  hempty->GetXaxis()->SetTitleOffset(1.3);
  hempty->GetYaxis()->SetTitleOffset(1.8);
  hempty->GetXaxis()->SetTitleSize(0.045);
  hempty->GetYaxis()->SetTitleSize(0.045);
  hempty->GetXaxis()->SetTitleFont(42);
  hempty->GetYaxis()->SetTitleFont(42);
  hempty->GetXaxis()->SetLabelFont(42);
  hempty->GetYaxis()->SetLabelFont(42);
  hempty->GetXaxis()->SetLabelSize(0.04);
  hempty->GetYaxis()->SetLabelSize(0.04);
  hempty->Draw();
  gRAA->Draw("samep");
  TF1* fRAA = new TF1("fRAA","exp([0]+[1]*x+[2]*x*x+[3]*x*x*x)+[4]");
  fRAA->SetLineWidth(2);
  gRAA->Fit("fRAA","","",4.8,50.5);
  gRAA->Fit("fRAA","","",4.8,50.5);

  cout<<endl;
  cout<<"  exp("<<fRAA->GetParameter(0)<<"+"<<fRAA->GetParameter(1)<<"*x+"<<fRAA->GetParameter(2)<<"*x*x+"<<fRAA->GetParameter(3)<<"*x*x*x)+"<<fRAA->GetParameter(4)<<endl;
  cout<<endl;

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} #bf{#it{Preliminary}}");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();

  TLatex* texCol = new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","PbPb"));
  texCol->SetNDC();
  texCol->SetTextAlign(32);
  texCol->SetTextSize(0.04);
  texCol->SetTextFont(42);
  texCol->Draw();

  TLatex* texTheory = new TLatex(0.55,0.80, "Theory");
  texTheory->SetNDC();
  texTheory->SetTextAlign(12);
  texTheory->SetTextSize(0.04);
  texTheory->SetTextFont(42);
  texTheory->Draw();

  TLatex* texArxiv = new TLatex(0.55,0.75, "arXiv:1601.07852");
  texArxiv->SetNDC();
  texArxiv->SetTextAlign(12);
  texArxiv->SetTextSize(0.04);
  texArxiv->SetTextFont(42);
  texArxiv->Draw();

  TString tper = "%";
  TLatex* texCent = new TLatex(0.55,0.70, Form("Cent. 0-10%s",tper.Data()));
  texCent->SetNDC();
  texCent->SetTextAlign(12);
  texCent->SetTextSize(0.04);
  texCent->SetTextFont(42);
  texCent->Draw();

  cRAA->SaveAs("plots/RAAweighting.pdf");

  return 0;
}
Exemplo n.º 22
0
// This ROOT macro plots the stopping depth of the muons in local coordinates
void StoppingDepth(std::string filename) {

  TCanvas* c1 = new TCanvas("c1", "c1");
  c1->SetRightMargin(0.15);
  int n_entries = 100000;

  TFile* file = new TFile(filename.c_str(), "READ");
  TTree* tree = (TTree*) file->Get("tree");
  double n_input_muons = tree->GetEntries();

  size_t secondslash = filename.rfind("/")+1; // don't want to include the slash
  size_t firstdot = filename.rfind(".");
  size_t n_chars = firstdot - secondslash;
  std::string base_filename = filename.substr(secondslash, n_chars);
  std::string histtitle = "Plot of the Stopping Depth of Muons in " + base_filename;
  TH2F* hStopDepth = new TH2F("hStopDepth", histtitle.c_str(), 120,-6,6, 120,-5,55);
  hStopDepth->GetYaxis()->SetTitle("Local Z [#mum]");
  hStopDepth->GetXaxis()->SetTitle("Local X [cm]");
  hStopDepth->GetZaxis()->SetTitle("N_{stop-#mu} / N_{input-#mu}");
  hStopDepth->Scale(1.0 / n_input_muons);
  hStopDepth->SetStats(false);

  tree->Draw("-1*((M_local_Oz*10000)-25):M_local_Ox>>hStopDepth", "M_particleName==\"mu-\" && M_volName==\"Target\" && M_stopped == 1", "COLZ", n_entries);
  
  c1->Update();
  std::string canvasname = "hStopDepth_" + base_filename + ".png";
  //  c1->Print(canvasname.c_str());

  TH1D* hStopZDepth = hStopDepth->ProjectionY();
  hStopZDepth->Draw();
  hStopZDepth->SetStats(false);
  hStopZDepth->GetYaxis()->SetTitle("N_{stop-#mu} / N_{input-#mu}");
  //  hStopZDepth->Scale(1.0 / n_input_muons);
  c1->Update();
  canvasname = "hStopZDepth_" + base_filename + ".png";
  //  c1->Print(canvasname.c_str());

  TH2F* hStopDepthVsTime = new TH2F("hStopDepthVsTime", histtitle.c_str(), 120,-30,30, 120,0,12);
  hStopDepthVsTime->GetXaxis()->SetTitle("Local Z [#mum]");
  hStopDepthVsTime->GetYaxis()->SetTitle("Time [ns]");
  hStopDepthVsTime->GetZaxis()->SetTitle("N_{stop-#mu} / N_{input-#mu}");
  hStopDepthVsTime->Scale(1.0 / n_input_muons);
  hStopDepthVsTime->SetStats(false);

  //  tree->Draw("M_Ot:M_local_Oz*10000>>hStopDepthVsTime", "M_particleName==\"mu-\" && M_volName==\"Target\" && M_stopped == 1", "COLZ", n_entries);
  
  c1->Update();
  canvasname = "hStopDepthVsTime_" + base_filename + ".png";
  //  c1->Print(canvasname.c_str());

  TH2F* hStopDepthVsMomentum = new TH2F("hStopDepthVsMomentum", histtitle.c_str(), 120,-30,30, 120,0,30);
  hStopDepthVsMomentum->GetXaxis()->SetTitle("Local Z [#mum]");
  hStopDepthVsMomentum->GetYaxis()->SetTitle("Momentum [MeV]");
  hStopDepthVsMomentum->GetZaxis()->SetTitle("N_{stop-#mu} / N_{input-#mu}");
  hStopDepthVsMomentum->Scale(1.0 / n_input_muons);
  hStopDepthVsMomentum->SetStats(false);

  //  tree->Draw("sqrt(M_px*M_px + M_py*M_py+ M_pz*M_pz)*1000:M_local_Oz*10000>>hStopDepthVsMomentum", "M_particleName==\"mu-\" && M_volName==\"Target\" && M_stopped == 1", "COLZ", n_entries);
  
  c1->Update();
  canvasname = "hStopDepthVsMomentum_" + base_filename + ".png";
  //  c1->Print(canvasname.c_str());
  //  file->Close();

  std::string outfilename = "plot_" + base_filename + ".root";
  TFile* output = new TFile(outfilename.c_str(), "RECREATE");
  hStopDepth->Write();
  hStopZDepth->Write();
  hStopDepthVsTime->Write();
  hStopDepthVsMomentum->Write();
  output->Close();
}
Exemplo n.º 23
0
/*
 * Main Function
 */
void ratio() {

  gStyle->SetFrameLineWidth(1); 
                                
  //Number of Measurements
  const int NUM = 2;
  
  //Measurements and uncertainties
  // mean, -stat, +stat, -syst, +syst  
  double m[NUM][5] = {
    0.98, 0.10, 0.10, 0.14, 0.14,
    //1.33, 0.32, 0.32, 0.22, 0.22
    1.26, 0.37, 0.37, 0.46, 0.46
  };
  
  //Theory and uncertainties
  // mean, -uncert, +uncert
  double t[NUM][3] = {
    1.0, 0.114, 0.114,
    1.0, 0.111, 0.111
  };

  // label text, sub-label text
  // Note: TString does not work, b/c one cannot pass an array of TStrings
  // as an argument to a function
  char label[NUM][2][100] = {
    "Z#gamma#gamma", "",
    //"W#gamma#gamma", ""
    "W#gamma#gamma (#mu)", ""
  };

  // format: 
  // # color, bgColor, fontSytle, linewidth, markerStyle 
  int aux[NUM][5] = {
    1,  10, 42, 2, 20,
    1,  10, 42, 2, 20
  };

  // determning the x size of the plot
  double lowX = LOW_X;
  double uppX = UPP_X;

  
  TH2F* lft = new TH2F("lft", "", 50, lowX, uppX, 1, 0.0, 1.0);

  // height = NUM*unitHeight + 2*spacers + 1*bottomMargin + 0.5*topMargin
  const double unitHeight = 50.0; // even number
  const double height = (double(NUM)+2.0)*unitHeight+100.0+30.0;
  // how much to step each time to cover the vertical range of the histo in
  // exactly NUM+2 steps
  const double vstep  = unitHeight/(height-100.0-30.0);
  const double width = 800.0;

  printf("Canvas: width=%d, height=%d\n",
	 TMath::Nint(width), TMath::Nint(height));
  printf("Y-step = %6.4f\n", vstep);

  
  // Set canvas and margins
  TCanvas* canvas = new TCanvas("canvas", "canvas", 200, 0,
				TMath::Nint(width), TMath::Nint(height));
  
  canvas->SetFillColor(10);
  canvas->SetRightMargin(20.0/width);
  canvas->SetLeftMargin(20.0/width);
  canvas->SetBottomMargin(56.0/height);
  canvas->SetTopMargin(30.0/height);
  canvas->Draw();
  canvas->cd();

  //printf("TopMargin   : %6.4f\n", canvas->GetTopMargin());
  //printf("BottomMargin: %6.4f\n", canvas->GetBottomMargin());

  TAxis* xaxis = lft->GetXaxis();
  TAxis* yaxis = lft->GetYaxis();
  xaxis->CenterTitle(kTRUE);  
  xaxis->SetTitleSize(0.07);  
  xaxis->SetTitleFont(62);    
  xaxis->SetTitleOffset(1.1); 
  xaxis->SetNdivisions(6,5,0);
    
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize(0.05);
  xaxis->SetLabelFont(42);
  yaxis->SetLabelSize(0.0);
  yaxis->SetNdivisions(-1);

  lft->SetXTitle("Cross Section Ratio  #sigma_{Exp} / #sigma_{Theory}");
  lft->SetYTitle("");
  lft->SetStats(kFALSE);
  lft->SetTitle("");
  lft->Draw();

    
  // Draw Theory Bands
  for (int i=0; i!=NUM; ++i) {
    drawTheory(i, t[i][0], t[i][1], t[i][2], vstep);
  }

  canvas->RedrawAxis(); 
  gPad->RedrawAxis(); 

  // Draw Measurements
  for (int i=0; i!=NUM; ++i) {
    drawMeasurement(i, m[i], label[i], aux[i], vstep, lft, canvas);
  }

  //Set CMS Preliminary marker
  int iPeriod=2; // 8 TeV
  int iPos = 0; //
  CMS_lumi( canvas, iPeriod, iPos );

  // Print
  //canvas->Print("Ratio_CrossSec_Exp_Theory.pdf");
  canvas->Draw();
}
void SUSY_m0_vs_m12_all_withBand_cls( TString fname0 = "mudat_list.root",// nominal
                                      TString fname1 = "",               // Up
                                      TString fname2 = "",               // Down  
                                      TString fname3 = "", // external expection
                                      const char* prefix="test",
                                      const float& lumi = 20,
                                      bool showsig = true,
                                      int discexcl = 1,
                                      int showtevatron = 0,
                                      int showcms = 0,
                                      int showOneSigmaExpBand = 0,
                                      int showfixSigXSecBand = 0,
                                      int channel = -1,
                                      TString hname0 = "sigp1clsf",
                                      TString hname1 = "sigp1expclsf",
                                      TString hname3 = "sigclsu1s",
                                      TString hname5 = "sigclsd1s",
                                      TString hname6 = "sigp1ref",
                                      TString fnameMass= "../../../HistFitterUser/common/mSugraGridtanbeta10_gluinoSquarkMasses.root")
{
   // set style and remove existing canvas'
   CombinationGlob::Initialize();
   
   cout << "--- Plotting m0 versus m12 " << endl;
   
   // --- prepare
   // open reference files, and retrieve histogram
   cout << "--- Reading root base file: " << fname0 << endl;
   TFile* f0 = TFile::Open( fname0, "READ" );
   if (!f0) {
      cout << "*** Error: could not retrieve histogram: " << hname0 << " in file: " << f0->GetName() 
           << " ==> abort macro execution" << endl;
      return;
   }
   
   TFile* f1;
   TFile* f2;
   if(showfixSigXSecBand){
      cout << "--- Reading root base file: " << fname1 << endl;
      f1 = TFile::Open( fname1, "READ" );
      cout << "--- Reading root base file: " << fname2 << endl;
      f2 = TFile::Open( fname2, "READ" );

      if(!f1 || !f2){
         cout << "*** Error: could not open in files: " << f1->GetName() <<" or "<< f2->GetName() 
              << " ==> abort macro execution" << endl;
         return;
      }
   }
   
   TH2F* histecls = (TH2F*)f0->Get( "sigp1expclsf" ); 
   TH2F* histocls = (TH2F*)f0->Get( "sigp1clsf" ); 
   if (histecls!=0) histecls->SetDirectory(0);
   if (histocls!=0) histocls->SetDirectory(0);
   
   // in case we use external expectation!
   TFile* f3 = TFile::Open( fname3, "READ" );
   TH2F* histe(0);
   if (f3) { histe = (TH2F*)f3->Get( hname0 ); }
   TH2F* histe_u1s(0);
   if (f3) { histe_u1s = (TH2F*)f3->Get( hname3 ); }
   TH2F* histe_d1s(0);
   if (f3) { histe_d1s = (TH2F*)f3->Get( hname5 ); }
   
   if (f3) {
      if (histecls!=0) { delete histecls; histecls=0; }
      histecls = (TH2F*)f3->Get( "sigp1expcls" );
      if (histecls!=0) histecls->SetDirectory(0);
      else {
        histecls = (TH2F*)f3->Get( "sigp1expclsf" );
        if (histecls!=0) histecls->SetDirectory(0);
      }
   }
   
   bool extExpectation = (f3!=0) ;
   
   TH2F* hist0 = (TH2F*)f0->Get( hname0 );
   TH2F* hist1 = (TH2F*)f0->Get( hname1 );
   TH2F* hist3 = (TH2F*)f0->Get( hname3 );
   TH2F* hist5 = (TH2F*)f0->Get( hname5 );
   TH2F* hist6 = (TH2F*)f0->Get( hname6 );
   
   if (hist0!=0) hist0->SetDirectory(0);
   if (hist1!=0) hist1->SetDirectory(0);
   if (hist3!=0) hist3->SetDirectory(0);
   if (hist5!=0) hist5->SetDirectory(0);
   if (hist6!=0) hist6->SetDirectory(0);
   f0->Close();

   TH2F* histe_esigxsp1s = (TH2F*)f1->Get( hname0 ); 
   TH2F* histe_esigxsm1s = (TH2F*)f2->Get( hname0 ); 

   if (histe_esigxsp1s!=0) histe_esigxsp1s->SetDirectory(0);
   if (histe_esigxsm1s!=0) histe_esigxsm1s->SetDirectory(0);

   TH2F* contour_esigxsp1s
      = ( histe_esigxsp1s!=0 ? FixAndSetBorders( *histe_esigxsp1s, "contour_esigxsp1s", "contour_esigxsp1s", 0 ) : 0);
   TH2F* contour_esigxsm1s
      = ( histe_esigxsm1s!=0 ? FixAndSetBorders( *histe_esigxsm1s, "contour_esigxsm1s", "contour_esigxsm1s", 0 ) : 0);
   
   TH2F* contour         = ( hist1!=0 ? FixAndSetBorders( *hist1, "contour", "contour", 0 ) : 0);
   TH2F* contour_obs     = ( hist0!=0 ? FixAndSetBorders( *hist0, "contour_obs", "contour_obs") : 0 );
   
   TH2F* contour_ep1s    = ( hist3!=0 ? FixAndSetBorders( *hist3, "contour", "contour", 0 ) : 0 );
   TH2F* contour_em1s    = ( hist5!=0 ? FixAndSetBorders( *hist5, "contour", "contour", 0 ) : 0 );

   // For Band
   TGraph* gr_contour_ep1s = ( contour_ep1s!=0 ? ContourGraph( contour_ep1s ) : 0 ); //ContourGraph( contour_ep1s )->Clone(); 
   TGraph* gr_contour_em1s = ( contour_em1s!=0 ? ContourGraph( contour_em1s ) : 0 ); //ContourGraph( contour_em1s )->Clone(); 
   
   TH2F* contour_exp(0);
   if (histe!=0)     { contour_exp     = FixAndSetBorders( *histe, "contour_exp", "contour_exp", 0 ); } 
   TH2F* contour_au1s(0);
   if (histe_u1s!=0) {  contour_au1s   = FixAndSetBorders( *histe_u1s, "contour", "contour", 0 ); }
   TH2F* contour_ad1s(0);
   if (histe_d1s!=0) {  contour_ad1s   = FixAndSetBorders( *histe_d1s, "contour", "contour", 0 ); }
   
   
   TH2F* contour_expcls(0);
   if (histecls!=0)     { contour_expcls     = FixAndSetBorders( *histecls, "contour_expcls", "contour_expcls", 0 ); }
   TH2F* contour_obscls(0);
   if (histocls!=0)     { contour_obscls     = FixAndSetBorders( *histocls, "contour_obscls", "contour_obscls", 0 ); }

   if (contour_obs==0) { 
      cout << "contour is zero" << endl;
      return;
   }


   
   // set text style
   gStyle->SetPaintTextFormat(".2g");
   if (hist1!=0) hist1->SetMarkerStyle(21);
   if (hist1!=0) hist1->SetMarkerSize(1.5);
   Float_t nsigmax(0)
      if (hist1!=0) nsigmax = hist1->GetMaximum();
   
   // --- draw
   
   // create canvas
   TCanvas* c = new TCanvas( "c", "A scan of m_{0} versus m_{12}", 0, 0, 
                             CombinationGlob::StandardCanvas[0], CombinationGlob::StandardCanvas[1] );  
  //c->SetGrayscale();
  
  // create and draw the frame
  //TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 100., 1400., 100, 115., 500. );
  TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 100., 3750., 100, 115., 700. );
  //TH2F *frame = new TH2F("frame", "m_{0} vs m_{12} - ATLAS work in progress", 100, 100., 600., 100, 240., 500. );
  
  // set common frame style
  CombinationGlob::SetFrameStyle2D( frame, 1.0 ); // the size (scale) is 1.0
  
  frame->SetXTitle( "m_{0} [GeV]" );
  frame->SetYTitle( "m_{1/2} [GeV]" );
  frame->GetYaxis()->SetTitleOffset(1.35);

  //frame->SetTextFont( 42 );
  frame->GetXaxis()->SetTitleFont( 42 );
  frame->GetYaxis()->SetTitleFont( 42 );
  frame->GetXaxis()->SetLabelFont( 42 );
  frame->GetYaxis()->SetLabelFont( 42 );

  frame->GetXaxis()->SetTitleSize( 0.04 );
  frame->GetYaxis()->SetTitleSize( 0.04 );
  frame->GetXaxis()->SetLabelSize( 0.04 );
  frame->GetYaxis()->SetLabelSize( 0.04 );

  frame->Draw();
    
  const int nsig(3);
  //TH2F *chist[3];
  // draw contours
  //!instead of printing sigma in 68% 95% 98% levels now printing +1 sigma deviations 
  //for (Int_t nsigma=1; nsigma<=nsig; nsigma++)
  //  DrawContourSameColor( contour, nsigma, "blue", kFALSE, (nsigma==1?inverse:0) ) ;

  TString basecolor="yellow";
  Int_t nsigma=2;

  //  TLegend *leg = new TLegend(0.7,0.77,0.95,0.915);
  TLegend *leg = new TLegend(0.57,0.52,0.85,0.915);//(0.565,0.47,0.925,0.915);//(0.59,0.47,0.92,0.915);

  leg->SetTextSize( CombinationGlob::DescriptionTextSize );
  leg->SetTextSize( 0.03 );
  leg->SetTextFont( 42 );
  leg->SetFillColor( 0 );
  leg->SetFillStyle(1001);
  
  // add squark, gluino mass contour lines HERE (TILL)
  TFile* f4 = TFile::Open( fnameMass, "READ" );
  TH2F* histSq = (TH2F*)f4->Get( "mSugraGrid_squarkMasses" );
  TH2F* histGl = (TH2F*)f4->Get( "mSugraGrid_gluinoMasses" );
  histSq->SetDirectory(0);
  histGl->SetDirectory(0);
  f4->Close();

  TH2F* histSquarkMass   = FixAndSetBorders( *histSq, "SquarkMass", "SquarkMass", 10000 );
  TH2F* histGluinoMass   = FixAndSetBorders( *histGl, "GluinoMass", "GluinoMass", 10000 );
  
//  DrawContourMassLine( histSquarkMass, 400.0 );
//  DrawContourMassLine( histSquarkMass, 500.0 );
  DrawContourMassLine( histSquarkMass, 600.0 );
//  DrawContourMassLine( histSquarkMass, 700.0 );
  DrawContourMassLine( histSquarkMass, 800.0 , 17);
//  DrawContourMassLine( histSquarkMass, 900.0 );
  DrawContourMassLine( histSquarkMass, 1000.0 );  
//  DrawContourMassLine( histSquarkMass, 1100.0 ); 
  DrawContourMassLine( histSquarkMass, 1200.0 , 17);
//  DrawContourMassLine( histSquarkMass, 1300.0 );    
  DrawContourMassLine( histSquarkMass, 1400.0 );
//  DrawContourMassLine( histSquarkMass, 1500.0 );
  DrawContourMassLine( histSquarkMass, 1600.0 , 17);
//  DrawContourMassLine( histSquarkMass, 1700.0 );
  DrawContourMassLine( histSquarkMass, 1800.0 );
//  DrawContourMassLine( histSquarkMass, 1900.0 );
  DrawContourMassLine( histSquarkMass, 2000.0 , 17);  
//  DrawContourMassLine( histSquarkMass, 2100.0 ); 
  DrawContourMassLine( histSquarkMass, 2200.0 );  
//  DrawContourMassLine( histSquarkMass, 2300.0 );     
  DrawContourMassLine( histSquarkMass, 2400.0 , 17);
//  DrawContourMassLine( histSquarkMass, 2500.0 );
  DrawContourMassLine( histSquarkMass, 2600.0 );
//  DrawContourMassLine( histSquarkMass, 2700.0 );
  DrawContourMassLine( histSquarkMass, 2800.0 , 17);
//  DrawContourMassLine( histSquarkMass, 2900.0 );
  DrawContourMassLine( histSquarkMass, 3000.0 );   
//  DrawContourMassLine( histSquarkMass, 3100.0 ); 
  DrawContourMassLine( histSquarkMass, 3200.0 , 17);  
//  DrawContourMassLine( histSquarkMass, 2300.0 );     
  DrawContourMassLine( histSquarkMass, 3400.0 );
//  DrawContourMassLine( histSquarkMass, 3500.0 );
//  DrawContourMassLine( histSquarkMass, 3600.0 , 17);
//  DrawContourMassLine( histSquarkMass, 3700.0 );
//  DrawContourMassLine( histSquarkMass, 3800.0 );
//  DrawContourMassLine( histSquarkMass, 3900.0 );
//  DrawContourMassLine( histSquarkMass, 4000.0 );        

  DrawContourMassLine( histGluinoMass, 400.0 );
  DrawContourMassLine( histGluinoMass, 500.0 , 17);
  DrawContourMassLine( histGluinoMass, 600.0 );
  DrawContourMassLine( histGluinoMass, 700.0 , 17);
  DrawContourMassLine( histGluinoMass, 800.0 );
  DrawContourMassLine( histGluinoMass, 900.0 , 17);
  DrawContourMassLine( histGluinoMass, 1000.0 );  
  DrawContourMassLine( histGluinoMass, 1100.0 , 17);  
  DrawContourMassLine( histGluinoMass, 1200.0 );  
  DrawContourMassLine( histGluinoMass, 1300.0 , 17);      
  DrawContourMassLine( histGluinoMass, 1400.0 );
  DrawContourMassLine( histGluinoMass, 1500.0 , 17);
  DrawContourMassLine( histGluinoMass, 1600.0 );
//  DrawContourMassLine( histGluinoMass, 1700.0 );
//  DrawContourMassLine( histGluinoMass, 1800.0 );
//  DrawContourMassLine( histGluinoMass, 1900.0 );
//  DrawContourMassLine( histGluinoMass, 2000.0 );  
//  DrawContourMassLine( histGluinoMass, 2100.0 ); 

  // find gluino ~ squark mass exclusion limit
  //DrawContourMassLine( histSquarkMass, 820.0 );
  //DrawContourMassLine( histGluinoMass, 820.0 );

/*  TLatex * s400 = new TLatex( 140, 167 , "#tilde{q} (400 GeV)" );
  s400->SetTextAlign( 11 );
  s400->SetTextSize( 0.025 );
  s400->SetTextColor( TColor::GetColor("#dddddd") );
  s400->Draw();*/
/*  TLatex * s500 = new TLatex( 150, 220, "#tilde{q} (500 GeV)" );
  s500->SetTextAlign( 11 );
  s500->SetTextSize( 0.025 );
  s500->SetTextColor( TColor::GetColor("#dddddd") );
  s500->Draw();*/
  TLatex * s600 = new TLatex( 340, 230, "#tilde{q} (600 GeV)" );
  s600->SetTextAlign( 11 );
  s600->SetTextAngle(-60);
  s600->SetTextSize( 0.025 );
  s600->SetTextColor( 16 ); //12
  s600->Draw();
  /*TLatex * s700 = new TLatex( 545, 315, "#tilde{q} (700 GeV)" );
  s700->SetTextAlign( 11 );
  s700->SetTextSize( 0.025 );
  s700->SetTextColor( TColor::GetColor("#dddddd") );
  s700->Draw();*/
  /*TLatex * s800 = new TLatex( 250, 270, "#tilde{q} (800 GeV)" );
  s800->SetTextAlign( 11 );
  s800->SetTextSize( 0.025 );
  s800->SetTextColor( 203 );
  s800->Draw();*/
  /*
  TLatex * s900 = new TLatex( 330, 400, "#tilde{q} (900 GeV)" );
  s900->SetTextAlign( 11 );
  s900->SetTextSize( 0.025 );
  s900->SetTextColor( TColor::GetColor("#dddddd") );
  s900->Draw();*/
   TLatex * s1000 = new TLatex( 550, 408, "#tilde{q} (1000 GeV)" );
  s1000->SetTextAlign( 11 );
  s1000->SetTextAngle(-60);
  s1000->SetTextSize( 0.025 );
  s1000->SetTextColor( 16 );
  s1000->Draw(); 
   TLatex * s1400 = new TLatex( 790, 580, "#tilde{q} (1400 GeV)" );
  s1400->SetTextAlign( 11 );
  s1400->SetTextAngle(-60);
  s1400->SetTextSize( 0.025 );
  s1400->SetTextColor( 16 );
  s1400->Draw();   

  /*TLatex * g400 = new TLatex( 1100, 140, "#tilde{g} (400 GeV)" );
  g400->SetTextAlign( 11 );
  g400->SetTextSize( 0.025 );
  g400->SetTextColor( 203 );
  g400->Draw();*/
  /*TLatex * g500 = new TLatex( 1000, 185, "#tilde{g} (500 GeV)" );
  g500->SetTextAlign( 11 );
  g500->SetTextSize( 0.025 );
  g500->SetTextColor( TColor::GetColor("#dddddd") );
  g500->Draw();*/
  TLatex * g600 = new TLatex( 1100, 225, "#tilde{g} (600 GeV)" );
  g600->SetTextAlign( 11 );
  g600->SetTextAngle(-4);
  g600->SetTextSize( 0.025 );
  g600->SetTextColor( 16 );
  g600->Draw();
  /*TLatex * g900 = new TLatex( 550, 380, "#tilde{g} (900 GeV)" );
  g900->SetTextAlign( 11 );
  g900->SetTextSize( 0.025 );
  g900->SetTextColor( TColor::GetColor("#dddddd") );
  g900->Draw();*/
  TLatex * g800 = new TLatex( 690, 330, "#tilde{g} (800 GeV)" );
  g800->SetTextAlign( 11 );
  g800->SetTextSize( 0.025 );
  g800->SetTextColor( 16 );
  //g800->Draw();
  TLatex * g1000 = new TLatex( 1400, 399, "#tilde{g} (1000 GeV)" );
  g1000->SetTextAlign( 11 );
  g1000->SetTextAngle(-5); 
  g1000->SetTextSize( 0.025 );
  g1000->SetTextColor( 16 );
  g1000->Draw();
  TLatex * g1200 = new TLatex( 1550, 489, "#tilde{g} (1200 GeV)" );
  g1200->SetTextAlign( 11 );
  g1200->SetTextAngle(-6); 
  g1200->SetTextSize( 0.025 );
  g1200->SetTextColor( 16 );
  //g1200->Draw();  
  TLatex * g1400 = new TLatex( 1650, 582, "#tilde{g} (1400 GeV)" );
  g1400->SetTextAlign( 11 );
  g1400->SetTextAngle(-6); 
  g1400->SetTextSize( 0.025 );
  g1400->SetTextColor( 16 );
  g1400->Draw();
  
  // island hacks
  if (true && channel==4) { // muon fixes 
    cout << "removing islands in muon channel ..." << endl;
    // contour line is drawn for values at 1.64485
    TAxis* ax = contour_obs->GetXaxis();
    TAxis* ay = contour_obs->GetYaxis();

    TH2F* contour_fix = contour_em1s;

    for (int xbin = 1; xbin <= contour_fix->GetNbinsX(); xbin++) {
      for (int ybin = 1; ybin <= contour_fix->GetNbinsY(); ybin++) {
	// island 1
	if ( ax->GetBinCenter( xbin) > 1350.  && ax->GetBinCenter( xbin) < 1500. && ay->GetBinCenter( ybin) < 130. && ay->GetBinCenter( ybin) > 89. ) {
	  cout << "Found spot here: " << xbin << " (" << ax->GetBinCenter( xbin)  << "), "
	       << ybin << " (" << ay->GetBinCenter( ybin) << "), "
	       << " value: " << contour_fix->GetBinContent(xbin,ybin) <<   endl;
	  cout << "   HACK : Setting above point by hand to 1.65 (!)" << endl;
	  if (contour_fix->GetBinContent(xbin,ybin)<1.65) contour_fix->SetBinContent(xbin, ybin, 1.66);
	}

      }
    }

  } 
  if (false && channel==1) { // electron

    cout << "removing islands in electron channel ..." << endl;
    // contour line is drawn for values at 1.64485
    TAxis* ax = contour_obs->GetXaxis();
    TAxis* ay = contour_obs->GetYaxis();

    contour_em1s

    for (int xbin = 1; xbin <= contour_obs->GetNbinsX(); xbin++) {
      for (int ybin = 1; ybin <= contour_obs->GetNbinsY(); ybin++) {
	// island 2
	if ( ax->GetBinCenter( xbin) > 420. && ax->GetBinCenter( xbin) < 480. &&
	     ay->GetBinCenter( ybin) > 140. && ay->GetBinCenter( ybin) < 160. ) {
	  cout << "Found spot here: " << xbin << " (" << ax->GetBinCenter( xbin)  << "), "
	       << ybin << " (" << ay->GetBinCenter( ybin) << "), "
	       << " value: " << contour->GetBinContent(xbin,ybin) <<   endl;
	  cout << "   HACK : Setting above point by hand to 1.50 (!)" << endl;
	  contour->SetBinContent(xbin, ybin, 1.50);
	}
      }
    }

  }
void SUSY_bRPV_m0_vs_m12_all_withBand_cls( TString fname0="", TString fname1="",
        TString fname2="",
        TString gridname="",
        const char* prefix="test",
        const float& lumi = 20.3,
        bool showsig = true,
        int discexcl = 1,
        int showtevatron = 0,
        int showcms = 0,
        int showOneSigmaExpBand = 0,
        bool showSR = false,
        bool useShape = false,
        int channel = -1,
        TString hname0 = "sigp1clsf",
        TString hname1 = "sigp1expclsf",
        TString hname3 = "sigclsu1s",
        TString hname5 = "sigclsd1s",
        TString hname6 = "sigp1ref",
        TString fnameMass= "contourmacros/mSugraGridtanbeta10_gluinoSquarkMasses.root")
{
    // set style and remove existing canvas'
    CombinationGlob::Initialize();

    cout << "--- Plotting m0 versus m12 " << endl;

    // --- prepare
    // open reference files, and retrieve histogram
    cout << "--- Reading root base file: " << fname0 << endl;
    TFile* f0 = TFile::Open( fname0, "READ" );
    if (!f0) {
        cout << "*** Error: could not retrieve histogram: " << hname0 << " in file: " << f0->GetName() 
            << " ==> abort macro execution" << endl;
        return;
    }
    
    TFile *f1; TFile *f2;

    if(fname1 != "")
        f1 = TFile::Open( fname1, "READ" );
        if(!f1) cout << "Warning: could not open " << fname1 << endl;
    if(fname2 != "")
        f2 = TFile::Open( fname2, "READ" );
        if(!f2) cout << "Warning: could not open " << fname2 << endl;

    TH2F* histecls = (TH2F*)f0->Get( "sigp1expclsf" ); 
    TH2F* histocls = (TH2F*)f0->Get( "sigp1clsf" ); 
    if (histecls!=0) histecls->SetDirectory(0);
    if (histocls!=0) histocls->SetDirectory(0);

    TH2F* histe_esigxsp1s;
    if (fname1 != "" && f1)  {
        histe_esigxsp1s = (TH2F*)f1->Get( hname0 );
        cout << "Read up histogram " << histe_esigxsp1s << endl;
    }

    TH2F* histe_esigxsm1s;
    if (fname2 != "" && f2) { 
        histe_esigxsm1s = (TH2F*)f2->Get( hname0 ); 
        cout << "Read down histogram " << histe_esigxsm1s << endl;
    }

    if (histe_esigxsp1s!=0) histe_esigxsp1s->SetDirectory(0);
    if (histe_esigxsm1s!=0) histe_esigxsm1s->SetDirectory(0);

    TH2F* contour_esigxsp1s
        = ( histe_esigxsp1s!=0 ? FixAndSetBorders( *histe_esigxsp1s, "contour_esigxsp1s", "contour_esigxsp1s", 0 ) : 0);
    TH2F* contour_esigxsm1s
        = ( histe_esigxsm1s!=0 ? FixAndSetBorders( *histe_esigxsm1s, "contour_esigxsm1s", "contour_esigxsm1s", 0 ) : 0);

    //    TFile* f3 = TFile::Open( fname3, "READ" );
    TH2F* histe(0);
    TH2F* histe_u1s(0);
    TH2F* histe_d1s(0);

    //    TFile* f4 = TFile::Open( fname4, "READ" );

    bool extExpectation = 0;

    TH2F* hist0 = (TH2F*)f0->Get( hname0 );
    TH2F* hist1 = (TH2F*)f0->Get( hname1 );
    TH2F* hist3 = (TH2F*)f0->Get( hname3 );
    TH2F* hist5 = (TH2F*)f0->Get( hname5 );
    TH2F* hist6 = (TH2F*)f0->Get( hname6 );



    if (hist0!=0) hist0->SetDirectory(0);
    if (hist1!=0) hist1->SetDirectory(0);
    if (hist3!=0) hist3->SetDirectory(0);
    if (hist5!=0) hist5->SetDirectory(0);
    if (hist6!=0) hist6->SetDirectory(0);
    f0->Close();

    TH2F* histe_esigxsp1s; 
    if (fname1!="" && f1) histe_esigxsp1s  = (TH2F*)f1->Get( hname0 ); 
    TH2F* histe_esigxsm1s; 
    if (fname2!="" && f2) histe_esigxsm1s  = (TH2F*)f2->Get( hname0 ); 

    if (fname1!="" &&histe_esigxsp1s!=0) histe_esigxsp1s->SetDirectory(0);
    if (fname2!="" && histe_esigxsm1s!=0) histe_esigxsm1s->SetDirectory(0);

    TH2F* contour_esigxsp1s
        = ( histe_esigxsp1s!=0 ? FixAndSetBorders( *histe_esigxsp1s, "contour_esigxsp1s", "contour_esigxsp1s", 0 ) : 0);
    TH2F* contour_esigxsm1s
        = ( histe_esigxsm1s!=0 ? FixAndSetBorders( *histe_esigxsm1s, "contour_esigxsm1s", "contour_esigxsm1s", 0 ) : 0);

    TH2F* contour         = ( hist1!=0 ? FixAndSetBorders( *hist1, "contour", "contour", 0 ) : 0);
    TH2F* contour_obs     = ( hist0!=0 ? FixAndSetBorders( *hist0, "contour_obs", "contour_obs") : 0 );

    TH2F* contour_ep1s    = ( hist3!=0 ? FixAndSetBorders( *hist3, "contour", "contour", 0 ) : 0 );
    TH2F* contour_em1s    = ( hist5!=0 ? FixAndSetBorders( *hist5, "contour", "contour", 0 ) : 0 );

    // For Band
    if (showOneSigmaExpBand){
        TGraph* gr_contour_ep1s = ContourGraph( contour_ep1s )->Clone(); 
        TGraph* gr_contour_em1s= ContourGraph( contour_em1s )->Clone(); 
    }
    TH2F* contour_exp(0);
    if (histe!=0)     { contour_exp     = FixAndSetBorders( *histe, "contour_exp", "contour_exp", 0 ); } 
    TH2F* contour_au1s(0);
    if (histe_u1s!=0) {  contour_au1s   = FixAndSetBorders( *histe_u1s, "contour", "contour", 0 ); }
    TH2F* contour_ad1s(0);
    if (histe_d1s!=0) {  contour_ad1s   = FixAndSetBorders( *histe_d1s, "contour", "contour", 0 ); }


    TH2F* contour_expcls(0);
    if (histecls!=0)     { contour_expcls     = FixAndSetBorders( *histecls, "contour_expcls", "contour_expcls", 0 ); }
    TH2F* contour_obscls(0);
    if (histocls!=0)     { contour_obscls     = FixAndSetBorders( *histocls, "contour_obscls", "contour_obscls", 0 ); }


    if (contour_obs==0) { 
        cout << "contour is zero" << endl;
        return;
    }

    // set text style
    gStyle->SetPaintTextFormat(".2g");
    if (hist1!=0) hist1->SetMarkerStyle(21);
    if (hist1!=0) hist1->SetMarkerSize(1.5);
    Float_t nsigmax(0)
        if (hist1!=0) nsigmax = hist1->GetMaximum();

    // --- draw

    // create canvas
    TCanvas* c = new TCanvas( "c", "A scan of "+gridname, 0, 0, 
            CombinationGlob::StandardCanvas[0], CombinationGlob::StandardCanvas[1] );  
    //c->SetGrayscale();

    // create and draw the frame
    double plotrange=2250.;
    TH2F *frame = new TH2F("frame", "m_{gluino} vs. m_{lsp} - ATLAS work in progress", 100, 350.,plotrange, 100, 200., 900. );
    // set common frame style
    CombinationGlob::SetFrameStyle2D( frame, 1.0 ); // the size (scale) is 1.0
    
    frame->SetXTitle( "m_{0} [GeV]" );
    frame->SetYTitle( "m_{1/2} [GeV]" );
    frame->GetYaxis()->SetTitleOffset(1.35);

    //frame->SetTextFont( 42 );
    frame->GetXaxis()->SetTitleFont( 42 );
    frame->GetYaxis()->SetTitleFont( 42 );
    frame->GetXaxis()->SetLabelFont( 42 );
    frame->GetYaxis()->SetLabelFont( 42 );

    frame->GetXaxis()->SetTitleSize( 0.04 );
    frame->GetYaxis()->SetTitleSize( 0.04 );
    frame->GetXaxis()->SetLabelSize( 0.04 );
    frame->GetYaxis()->SetLabelSize( 0.04 );

    frame->Draw();

    const int nsig(3);
    //TH2F *chist[3];
    // draw contours
    //!instead of printing sigma in 68% 95% 98% levels now printing +1 sigma deviations 
    //for (Int_t nsigma=1; nsigma<=nsig; nsigma++)
    //  DrawContourSameColor( contour, nsigma, "blue", kFALSE, (nsigma==1?inverse:0) ) ;

    TString basecolor="yellow";
    Int_t nsigma=2;

    TLegend *leg = new TLegend(0.6,0.7,0.92,0.9);

    leg->SetTextSize( CombinationGlob::DescriptionTextSize );
    leg->SetTextSize( 0.03 );
    leg->SetTextFont( 42 );
    leg->SetFillColor( 0 );
    leg->SetFillStyle(1001);

    if (false && channel==1) { // electron

        cout << "removing islands in electron channel ..." << endl;
        // contour line is drawn for values at 1.64485
        TAxis* ax = contour_obs->GetXaxis();
        TAxis* ay = contour_obs->GetYaxis();
        /*     
               contour_em1s

               for (int xbin = 1; xbin <= contour_obs->GetNbinsX(); xbin++) {
               for (int ybin = 1; ybin <= contour_obs->GetNbinsY(); ybin++) {
        // island 2
        if ( ax->GetBinCenter( xbin) > 420. && ax->GetBinCenter( xbin) < 480. &&
        ay->GetBinCenter( ybin) > 140. && ay->GetBinCenter( ybin) < 160. ) {
        cout << "Found spot here: " << xbin << " (" << ax->GetBinCenter( xbin)  << "), "
        << ybin << " (" << ay->GetBinCenter( ybin) << "), "
        << " value: " << contour->GetBinContent(xbin,ybin) <<   endl;
        cout << "   HACK : Setting above point by hand to 1.50 (!)" << endl;
        contour->SetBinContent(xbin, ybin, 1.50);
        }
        }
        }
        */

    }

    if (false && channel==2) { // combined
        cout << "removing islands in combined channel ..." << endl;
    }


    /////////////////////////////////////////////////////////
    //// add 2011 results 


    Int_t c_myYellow   = TColor::GetColor("#ffe938");
    Int_t c_myRed      = TColor::GetColor("#aa000");

    // turn off yellow band    
    if (showOneSigmaExpBand) TGraph* grshadeExp= DrawExpectedBand( gr_contour_ep1s, gr_contour_em1s, CombinationGlob::c_DarkYellow , 1001 , 0)->Clone();


    if (discexcl==1) {
        DrawContourLine95( leg, contour_obs,     "Observed limit (#pm1 #sigma^{SUSY}_{theory})", c_myRed, 1, 4 );   // 95% CL_{S}
        
        
        if (contour_esigxsp1s)
            DrawContourLine95( leg, contour_esigxsp1s, "", c_myRed, 3, 2 );    // Observed limit #pm 1 #sigma^{SUSY}_{theory}
        if (contour_esigxsm1s)
            DrawContourLine95( leg, contour_esigxsm1s, "", c_myRed, 3, 2 );    // Observed limit #pm 1 #sigma^{SUSY}_{theory}
        
        if (!extExpectation) { 
            // Compare the expected limits!
            if (contour_expcls!=0) { 
                //DrawContourLine95( leg, contour_expcls, fname0, CombinationGlob::c_DarkGray, 6 );
                DrawContourLine95( leg, contour_expcls, fname0, CombinationGlob::c_DarkBlueT3, 6 );
            }
            
            if (showOneSigmaExpBand) {
                if (contour_ep1s!=0) {	   
                    DrawContourLine95( leg, contour_ep1s, "", c_myYellow, 1 ); 
                }

                if (contour_em1s!=0)  {	   
                    DrawContourLine95( leg, contour_em1s, "", c_myYellow, 1 );
                }
                DummyLegendExpected(leg, "Expected limit (#pm1 #sigma_{exp})", c_myYellow, 1001, CombinationGlob::c_DarkBlueT3, 6, 2);

            } else {
                //if (contour!=0) DrawContourLine68( leg, contour, "exp. limit 68% CL", CombinationGlob::c_DarkBlueT3, 2 );
                //if (contour!=0) DrawContourLine99( leg, contour, "exp. limit 99% CL", CombinationGlob::c_DarkBlueT3, 3 );
            }

        } else { // expectation from asimov
            if (contour_exp!=0) DrawContourLine95( leg, contour_exp, "Median expected limit", CombinationGlob::c_DarkBlueT3, 6);
            if (showOneSigmaExpBand) {
                if (contour_au1s!=0) DrawContourLine95( leg, contour_au1s, "Expected limit #pm1#sigma", CombinationGlob::c_DarkBlueT3, 3 );
                if (contour_ad1s!=0) DrawContourLine95( leg, contour_ad1s, "", CombinationGlob::c_DarkBlueT3, 3 );
            }
        }
    }


    // plot tevatron limits
    TGraph* lep2slep(0);
    TGraph* lep2char(0);
    TGraph* d0o(0);
    TGraph* d0graph(0);
    TGraph* cdfgraph(0);
    TGraph* atlas(0);
    TGraph* atlasexp(0);

    if (showtevatron==1 && discexcl==1) {
        lep2char = ol1();
        d0graph = d0tanb3muneg();
        cdfgraph = cdftanb5();
        //atlas = ATLAS10_1lepton();
        //atlasexp = ATLAS10_1leptonexp();
    }

    //:w(void) stautanb3();

    TGraph* cmscurve(0);
    if (showcms==1) { 
        //cmscurve = cmsoff();
        cmscurve = cms();
    }


    // legend
    Float_t textSizeOffset = +0.000;
    Double_t xmax = frame->GetXaxis()->GetXmax();
    Double_t xmin = frame->GetXaxis()->GetXmin();
    Double_t ymax = frame->GetYaxis()->GetXmax();
    Double_t ymin = frame->GetYaxis()->GetXmin();
    Double_t dx   = xmax - xmin;
    Double_t dy   = ymax - ymin;

    //TString t1a = "99%, 95%, 68% CL fit contour (excluded)" ;
    // TString t1a = "-1#sigma, central, +1#sigma  fit contour (excluded)" ;
    TString t1b = "tan#beta = 3, A_{0}= 0, #mu < 0" ;
    Float_t nbkg(0);
    if( hist5!=0) nbkg = hist5->GetMaximum();
    TString t1c = Form("MC: n_{bkg}= %.1f", nbkg) ;

    // TLatex* text1a = new TLatex( 70, 260, t1a );
    TLatex* text1b = new TLatex( 150, ymax + dy*0.025, t1b );
    TLatex* text1c = new TLatex( 70, 280, t1c );

    // text1a->SetTextColor( 1 ); //CombinationGlob::c_VDarkGreen );
    text1b->SetTextColor( 1 ); //CombinationGlob::c_VDarkGreen );
    text1c->SetTextColor( 1 );
    text1b->SetTextFont( 42 ); //CombinationGlob::c_VDarkGreen );

    // text1a->SetTextAlign( 11 );
    text1b->SetTextAlign( 11 );
    text1c->SetTextAlign( 11 );

    //  text1a->SetTextSize( CombinationGlob::DescriptionTextSize + textSizeOffset );
    text1b->SetTextSize( CombinationGlob::DescriptionTextSize  );
    text1c->SetTextSize( CombinationGlob::DescriptionTextSize  );
    
    TString plottitle="bRPV-MSUGRA: tan #beta = 30, A_{0}= -2m_{0}, #mu>0";
    
    if(showSR){
        std::cout << "--- printing best SRs" << std::endl;
        Show_SR(fname0, c, xmin, xmax, ymin, ymax, useShape, leg);
        
    } 
    
    TLatex *Leg0 = new TLatex( xmin, ymax + dy*0.025,plottitle );
    Leg0->SetTextAlign( 11 );
    Leg0->SetTextFont( 42 );
    Leg0->SetTextSize( CombinationGlob::DescriptionTextSize);
    Leg0->SetTextColor( 1 );
    Leg0->AppendPad();


    TLatex *Leg1 = new TLatex();
    Leg1->SetNDC();
    Leg1->SetTextAlign( 11 );
    Leg1->SetTextFont( 42 );
    Leg1->SetTextSize( CombinationGlob::DescriptionTextSize );
    Leg1->SetTextColor( 1 );
    Leg1->DrawLatex(0.15,0.78, Form("#int L dt = %1.1f fb^{-1},  #sqrt{s}=8 TeV",lumi));  // 0.32,0.87
    if(useShape){
        Leg1->DrawLatex(0.15,0.72, "0 leptons, 2-6 jets, 5-bin");  // 0.32,0.87
    } else {
        Leg1->DrawLatex(0.15,0.72, "0 leptons, 2-6 jets");  // 0.32,0.87
    }    

    Leg1->AppendPad();

    TLatex *Leg2 = new TLatex();
    Leg2->SetNDC();
    Leg2->SetTextAlign( 11 );
    Leg2->SetTextSize( CombinationGlob::DescriptionTextSize );
    Leg2->SetTextColor( 1 );
    Leg2->SetTextFont(70);
    if (prefix!=0) { 
        Leg2->DrawLatex(0.7,0.85,prefix); // 0.15,0.81
        Leg2->AppendPad(); 
    }

    TLatex *atlasLabel = new TLatex();
    atlasLabel->SetNDC();
    atlasLabel->SetTextFont( 42 );
    atlasLabel->SetTextColor( 1 );
    atlasLabel->SetTextSize( 0.05 );
    atlasLabel->DrawLatex(0.15,0.87, "#bf{#it{ATLAS}} Internal"); // 0.15,0.87

    atlasLabel->AppendPad();

    //// draw number of signal events
    if (nsigmax>0 && showsig) {  hist1->Draw("textsame"); }
    //else {
    //  // draw grid for clarity
    //  c->SetGrid();
    //}
    //reddraw cahnnel label
    //  c->SetGrid();

    if (prefix!=0) { Leg2->AppendPad(); }

    // redraw axes
    frame->Draw( "sameaxis" );


    //  leg->Draw("same");


    // update the canvas
    double xline=1000.;
    double yline=1000.;
    if (fname0.Contains("SS")) {
        xline=800.; 
        yline=800.;
    }
    TLine *line=new TLine(200.,200.,xline,yline);
    line->SetLineStyle(3);
    //line->Draw();
    c->Update();


    gPad->RedrawAxis("same");
    c->Update();
    gPad->Update();

    ////////////////////////////////////////////////////////////////////////////////////////////

    //gROOT->GetListOfSpecials()->Print();

    TObjArray *contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
    if (contours!=0) {
        //contours->Print("v");

        TList *lcontour1 = (TList*)contours->At(0);
        //lcontour1->Print();
        if (lcontour1!=0) {
            TGraph *gc1 = (TGraph*)lcontour1->First();
            if (gc1!=0) { 
                //gc1->Print();
                //if (gc1->GetN() < 10) return;
                //gc1->SetMarkerStyle(21);
                //gc1->Draw("alp");
            }
        }
    }

    ////////////////////////////////////////////////////////////////////////////////////////////

    // create plots
    // store histograms to output file
    TObjArray* arr = fname0.Tokenize("/");
    TObjString* objstring = (TObjString*)arr->At( arr->GetEntries()-1 );
    TString outfile = TString(Form("%1.2finvfb_",lumi)) + TString(Form("wband%d_",showOneSigmaExpBand)) + TString(Form("showcms%d_",showcms)) + objstring->GetString().ReplaceAll(".root","");
    delete arr;
    
    if(!showSR) outfile += TString("_noLabel");
    TString prefixsave = TString(prefix).ReplaceAll(" ","_") + Form("%1.2finvfb_",lumi) + Form("wband%d_",showOneSigmaExpBand);
    CombinationGlob::imgconv( c, Form("plots/atlascls_m0m12_%s",outfile.Data()) );   

}
void draw() {

  gROOT->Reset();

// first make a canvas and a 2D histogram for the axes

  TCanvas* canvas = new TCanvas("canvas", "canvas", 10, 10, 500, 500);
  canvas->SetFillColor(0);
  canvas->SetBorderMode(0);  
  canvas->SetFrameBorderMode(0);   // need this to turn off red hist frame!

  gROOT->SetStyle("Plain");
  canvas->UseCurrentStyle();

  gPad->SetLeftMargin(0.15);
  gPad->SetRightMargin(0.05);
  gPad->SetTopMargin(0.07);
  gPad->SetBottomMargin(0.17);

  gStyle->SetOptStat(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleSize(0.04);

  gStyle->SetTextFont(42);
  gStyle->SetTextSize(0.04);
  gStyle->SetTitleFont(42, "hxy");    // for histogram and axis title
  gStyle->SetLabelFont(42, "xyz");    // for axis labels (values)

  gStyle->SetTitleOffset(0.8, "h");        // what does this do?
  gStyle->SetTitleX(0.15);
  gStyle->SetTitleY(0.99);

  gROOT->ForceStyle();

  // can make histogram or alternatively use the histograms automatically
  // connected to the TF1 or TGraph objects

  double xMin = 0.1;
  double xMax = 100.;
  // double yMin = 0.1;
  // double yMax = 10.;
  double yMin = 0.;
  double yMax = 8.;
  TH2F* axhist = new TH2F("axhist", "title", 10, xMin, xMax, 10, yMin, yMax);
  axhist->SetTitle("");
  axhist->SetXTitle("b");
  axhist->SetYTitle("med[Z|s]");
  gPad->SetLogx(1);
  gPad->SetLogy(0);

  double u[20];
  double x[20][500];

  // Read in data from file and insert in TTree

  TString fileName;
  // cout << "Enter file name: ";
  // cin >> fileName;
  fileName = "medsig_s5_rel_bi.txt";

  ifstream inFile;
  inFile.open(fileName);
  if (inFile.fail()) { 
    cout << "Couldn't open file!" << endl;
    exit(1); 
  }

  bool readLine = true;
  int lineNum = 0;
  int ncol;
  while ( readLine ){

    TString line;
    stringstream ss;
    line.ReadLine(inFile);
    readLine = inFile.good();

    if ( readLine ) {

      TString firstChar = line(0,1);
      bool useLine = firstChar != "#";

      if ( useLine ){

        int i = 0;
        stringstream ss;
        ss << line;              // put whole line into ss
        TString token;
        bool getToken = true;

        while ( getToken ) {
          ss >> token;           // extracts one token
          if ( token.Length() > 0 ) {
            u[i] = token.Atof();
            i++;
          } 
          else {
            getToken = false;
          }
        }             // getToken
        ncol = i;  

        for (int i=0; i<ncol; i++){
          x[i][lineNum] = u[i];
        }
        lineNum++;

      }               // useLine

    }         // readLine

  }           // readLine

  int n = lineNum;
  inFile.close();

  //  for (int i=0; i<n; i++){
  //  cout << i << "  " << x[0][i] << "  " << x[3][i] << "  " 
  //	 << x[4][i] << endl;
  //  }

  TGraph* tg1 = new TGraph(n, x[0], x[1]);
  TGraph* tg2 = new TGraph(n, x[0], x[2]);
  TGraph* tg3 = new TGraph(n, x[0], x[3]);
  TGraph* tg4 = new TGraph(n, x[0], x[4]);
  TGraph* tg5 = new TGraph(n, x[0], x[5]);
  TGraph* tg6 = new TGraph(n, x[0], x[6]);
  TGraph* tg7 = new TGraph(n, x[0], x[7]);
  TGraph* tg8 = new TGraph(n, x[0], x[8]);
  TGraph* tg9 = new TGraph(n, x[0], x[9]);
  TGraph* tg10 = new TGraph(n, x[0], x[10]);
  TGraph* tg11 = new TGraph(n, x[0], x[11]);
  TGraph* tg12 = new TGraph(n, x[0], x[12]);
  TGraph* tg13 = new TGraph(n, x[0], x[13]);
  TGraph* tg14 = new TGraph(n, x[0], x[14]);
  TGraph* tg15 = new TGraph(n, x[0], x[15]);

  TAxis* xa = axhist->GetXaxis();
  TAxis* ya = axhist->GetYaxis();

  xa->SetTitleOffset(1.2);    //  factor multiplies default offset
  ya->SetTitleOffset(1.1);

  xa->SetLabelOffset(0.005);
  ya->SetLabelOffset(0.005);

  xa->SetTickLength(0.015);  // default  = 0.03
  ya->SetTickLength(0.015);  // default  = 0.03

  xa->SetTitleSize(0.05);
  ya->SetTitleSize(0.05);

  //  gPad->SetLogx(1);
  //  xa->SetLimits(90., 700.);

  xa->SetNdivisions(-5); // negative value should force number of divisions?
  ya->SetNdivisions(-4);

  xa->SetLabelSize(0.05);
  ya->SetLabelSize(0.05);

  // Draw axes and then add stuff

  // kDot=1, kPlus, kStar, kCircle=4, kMultiply=5,
  // kFullDotSmall=6, kFullDotMedium=7, kFullDotLarge=8,
  // kFullCircle=20, kFullSquare=21, kFullTriangleUp=22,
  // kFullTriangleDown=23, kOpenCircle=24, kOpenSquare=25,
  // kOpenTriangleUp=26, kOpenDiamond=27, kOpenCross=28,
  // kFullStar=29, kOpenStar=30

  axhist->Draw();

  tg1->SetLineColor(kRed);
  tg1->SetLineWidth(2);
  tg1->SetLineStyle(2);
  tg1->SetMarkerColor(kRed);
  tg1->SetMarkerSize(0.8);
  tg1->SetMarkerStyle(20);
  tg1->Draw("L,same");              // or P for points

  tg2->SetLineColor(kRed);
  tg2->SetLineWidth(2);
  tg2->SetLineStyle(2);
  tg2->SetMarkerColor(kRed);
  tg2->SetMarkerSize(0.8);
  tg2->SetMarkerStyle(20);
  tg2->Draw("L,same");              // or P for points

  tg3->SetLineColor(kRed);
  tg3->SetLineWidth(2);
  tg3->SetLineStyle(2);
  tg3->SetMarkerColor(kRed);
  tg3->SetMarkerSize(0.8);
  tg3->SetMarkerStyle(20);
  // tg3->Draw("L,same");              // or P for points

  tg4->SetLineColor(kBlue);
  tg4->SetLineWidth(2);
  tg4->SetLineStyle(1);
  tg4->SetMarkerColor(kBlue);
  tg4->SetMarkerSize(0.8);
  tg4->SetMarkerStyle(20);
  tg4->Draw("L,same");              // or P for points

  tg5->SetLineColor(kBlue);
  tg5->SetLineWidth(2);
  tg5->SetLineStyle(1);
  tg5->SetMarkerColor(kBlue);
  tg5->SetMarkerSize(0.8);
  tg5->SetMarkerStyle(20);
  tg5->Draw("L,same");              // or P for points

  tg6->SetLineColor(kBlue);
  tg6->SetLineWidth(2);
  tg6->SetLineStyle(1);
  tg6->SetMarkerColor(kBlue);
  tg6->SetMarkerSize(0.8);
  tg6->SetMarkerStyle(20);
  // tg6->Draw("L,same");              // or P for points

  tg7->SetLineColor(kRed);
  tg7->SetLineWidth(2);
  tg7->SetLineStyle(1);
  tg7->SetMarkerColor(kRed);
  tg7->SetMarkerSize(0.8);
  tg7->SetMarkerStyle(21);
  // tg7->Draw("P,same");              // or P for points

  tg8->SetLineColor(kRed);
  tg8->SetLineWidth(2);
  tg8->SetLineStyle(1);
  tg8->SetMarkerColor(kRed);
  tg8->SetMarkerSize(0.8);
  tg8->SetMarkerStyle(21);
  // tg8->Draw("P,same");              // or P for points

  tg9->SetLineColor(kRed);
  tg9->SetLineWidth(2);
  tg9->SetLineStyle(2);
  tg9->SetMarkerColor(kRed);
  tg9->SetMarkerSize(0.8);
  tg9->SetMarkerStyle(21);
  // tg9->Draw("P,same");              // or P for points

  tg10->SetLineColor(kBlack);
  tg10->SetLineWidth(2);
  tg10->SetLineStyle(2);
  tg10->SetMarkerColor(kBlack);
  tg10->SetMarkerSize(0.8);
  tg10->SetMarkerStyle(20);
  tg10->Draw("P,same");              // or P for points

  tg11->SetLineColor(kBlack);
  tg11->SetLineWidth(2);
  tg11->SetLineStyle(2);
  tg11->SetMarkerColor(kBlack);
  tg11->SetMarkerSize(0.8);
  tg11->SetMarkerStyle(20);
  tg11->Draw("P,same");              // or P for points

  tg12->SetLineColor(kBlack);
  tg12->SetLineWidth(2);
  tg12->SetLineStyle(2);
  tg12->SetMarkerColor(kBlack);
  tg12->SetMarkerSize(0.8);
  tg12->SetMarkerStyle(20);
  // tg12->Draw("P,same");              // or P for points

  tg13->SetLineColor(kBlack);
  tg13->SetLineWidth(2);
  tg13->SetLineStyle(3);
  tg13->SetMarkerColor(kBlack);
  tg13->SetMarkerSize(0.8);
  tg13->SetMarkerStyle(20);
  // tg13->Draw("L,same");              // or P for points

  tg14->SetLineColor(kBlack);
  tg14->SetLineWidth(2);
  tg14->SetLineStyle(3);
  tg14->SetMarkerColor(kBlack);
  tg14->SetMarkerSize(0.8);
  tg14->SetMarkerStyle(20);
  // tg14->Draw("L,same");              // or P for points

  tg15->SetLineColor(kBlack);
  tg15->SetLineWidth(2);
  tg15->SetLineStyle(3);
  tg15->SetMarkerColor(kBlack);
  tg15->SetMarkerSize(0.8);
  tg15->SetMarkerStyle(20);
  // tg15->Draw("L,same");              // or P for points


  TLegend* leg = new TLegend(0.53, 0.48, 0.95, .73); // x1, y1, x2, y2
  leg->SetTextSize(0.05);
  leg->SetTextFont(42);
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->AddEntry(tg1, " s / #sqrt{b + #sigma_{b}^{2}}", "l");
  leg->AddEntry(tg4, "  Z_{A}", "l");
  // leg->AddEntry(tg7, " #sqrt{q0}, MC median", "p");
  leg->AddEntry(tg10, " Monte Carlo", "p");
  // leg->AddEntry(tg13, " Z_{bi}" , "l");
  // leg->AddEntry(tg4, "s = 0.03", "l");
  leg->Draw();

  TLatex* tl = new TLatex();
  tl->SetTextAlign(11);
  tl->SetTextSize(0.05);
  tl->SetTextFont(42);
  tl->SetNDC();
  // tl->DrawLatex(.76, 0.33, "s = 2");  
  // tl->DrawLatex(.76, 0.465, "s = 5");  
  // tl->DrawLatex(.76, 0.6, "s = 10");  
  //   tl->DrawLatex(.76, 0.73, "s = 20");  

  // tl->DrawLatex(.5, .77, "#sigma_{b}/b = 0.2, 0.5, 1");
  tl->DrawLatex(.5, .77, "#sigma_{b}/b = 0.2, 0.5");
  tl->DrawLatex(.5, .85, "s = 5");

  // Fix idiotic problem with frame

  TLine* tli = new TLine();
  tli->SetLineStyle(1);
  tli->SetLineWidth(1);
  tli->DrawLine(xMin, yMin, xMax, yMin);
  tli->DrawLine(xMax, yMin, xMax, yMax);
  tli->DrawLine(xMin, yMax, xMax, yMax);
  tli->DrawLine(xMin, yMin, xMin, yMax);

  TPostScript psfile("medsig_s5_rel_bi.eps", 113);     // 113 makes eps
  canvas->Draw();
  psfile.Close();
  // canvas->Print("plot.gif", "gif");

}
Exemplo n.º 27
0
/*main{{{*/
int main()
{
	/*ROOT Define{{{*/
	// Fill color
	gStyle->SetStatColor(0);
	gStyle->SetTitleFillColor(0);
	gStyle->SetCanvasColor(0);
	gStyle->SetPadColor(0);
	gStyle->SetFrameFillColor(0);

	// Border mode
	gStyle->SetCanvasBorderMode(0);
	gStyle->SetPadBorderMode(0);
	gStyle->SetFrameBorderMode(0);
	gStyle->SetPalette(1,0);

	// Font
	gStyle->SetTextFont(32);
	gStyle->SetLabelFont(32, "xyz");
	gStyle->SetTitleFont(22, "xyz");
	gStyle->SetStatFont(32);
	gStyle->SetTitleFillColor(0);

	// Opt
	//    gStyle->SetOptDate(0);
	//    gStyle->SetOptTitle(1);
	//    gStyle->SetOptStat(1);
	//    gStyle->SetOptFit(1);
	//    // Margin
	// //    gStyle->SetPadLeftMargin(0.1);
	// //    gStyle->SetPadRightMargin(0.1);
	// //    gStyle->SetPadTopMargin(0.1);
	// //    gStyle->SetPadBottomMargin(0.1);


	//void HallA_style() {
	gROOT->SetStyle("Plain");
	gStyle->SetPaperSize(TStyle::kUSLetter);
	gStyle->SetPaperSize(18,22);
	gStyle->SetOptFit(1111);
	gStyle->SetPalette(1);
	gStyle->SetNdivisions(505);

	gStyle->SetCanvasColor(0);
	gStyle->SetPadTopMargin(.05);
	gStyle->SetPadLeftMargin(.15);
	gStyle->SetPadRightMargin(.1);
	gStyle->SetPadBottomMargin(.15);
	gStyle->SetTitleYOffset(1.3);
	gStyle->SetLabelFont(32,"X");
	gStyle->SetLabelFont(32,"Y");

	// prepare gStyle to be useful
	//   1 = solid
	//   2 = long dash (30 10)
	gStyle->SetTitleFillColor(-1); 
	//   3 = dotted (4 8)
	//   4 = dash-dot (15 12 4 12)
	//   5 = short dash ( 15 15 )
	//   6 = dash-dot-dot 
	gStyle->SetLineStyleString(1,"[]");
	gStyle->SetLineStyleString(2,"[30 10]");
	gStyle->SetLineStyleString(3,"[4 8]");
	gStyle->SetLineStyleString(4,"[15 12 4 12]");
	gStyle->SetLineStyleString(5,"[15 15]");
	gStyle->SetLineStyleString(6,"[15 12 4 12 4 12]");
	gStyle->SetLabelSize(0.05,"X");
	gStyle->SetLabelSize(0.05,"Y");
	gStyle->SetNdivisions(505,"Y");
	gStyle->SetOptDate(0);
	gStyle->SetDateY(.98);
	gStyle->SetStripDecimals(kFALSE);

	gStyle->SetHistFillColor(0); 
	gStyle->SetFillColor(0); 
	gStyle->SetFillStyle(4000); 
	gStyle->SetStatStyle(0); 
	gStyle->SetTitleStyle(0); 
	gStyle->SetCanvasBorderSize(0); 
	gStyle->SetFrameBorderSize(0); 
	gStyle->SetLegendBorderSize(0); 
	gStyle->SetStatBorderSize(0); 
	gStyle->SetTitleBorderSize(0); 

	/*}}}*/

	TString Target; cerr<<" Which Target? (H2,He3,He4,C12,Ca40,Ca48) "; cin >> Target;
	ofstream outfile(Form("XS_%s.dat",Target.Data()));
	outfile << Form("%4s %7s %4s %7s %7s %7s %16s %16s %16s", 
			"Target",  "Angle","E0","Ep","Nu","xbj","XS","XS_Err","XS_MC")
		<< endl;
	
	cerr<<"--- Comment = "; cin>>Com;
	//bool bMC = kTRUE;
	//bool bMC = kFALSE;
	//double Theta =21;
	//double Zero[100] = {100*0.0};
    double E0 = 3.356;

	/*Merge{{{*/

	/*Degree 21 {{{*/
	double xbj_21[100], Ep_21[100], Nu_21[100], XS_EX_21[100], XS_EX_Err_21[100], XS_MC_21[100];
	int N_21 = 0;
	if(Target=="H2" ||Target=="He3" ||  Target=="He4" || Target=="C12"||Target=="Ca40"||Target=="Ca48"){
		Merge(Form("R21_%s.dat",Target.Data()), xbj_21, Ep_21, XS_EX_21, XS_EX_Err_21, XS_MC_21, &N_21);
		cerr<<"=== 21: Total Points = "<<N_21<<endl;
		for(int i=0;i<N_21;i++){
			Nu_21[i] = E0 - Ep_21[i];
			cerr    << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e",
				   	Target.Data(),21.00, E0, Ep_21[i], Nu_21[i], xbj_21[i],XS_EX_21[i],XS_EX_Err_21[i],XS_MC_21[i] )
				<< endl;
			outfile << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),21.00, E0, Ep_21[i], Nu_21[i], xbj_21[i],XS_EX_21[i],XS_EX_Err_21[i],XS_MC_21[i] )
				<< endl;
		}
	}
	double Q2_21_D = 4.0*E0*Ep_Cut_21_1[0]*pow(TMath::Sin(21.*3.1415926/180.0*0.5),2);
	double Q2_21_U = 4.0*E0*Ep_Cut_21_2[3]*pow(TMath::Sin(21.*3.1415926/180.0*0.5),2);
	/*}}}*/

	/*Degree 23 {{{*/
	double xbj_23[100], Nu_23[100], Ep_23[100], XS_EX_23[100], XS_EX_Err_23[100], XS_MC_23[100];
	int N_23 = 0;
	if(Target=="He3" ||  Target=="He4" || Target=="C12"||Target=="Ca40"||Target=="Ca48"){
		Merge(Form("R23_%s.dat",Target.Data()), xbj_23, Ep_23, XS_EX_23, XS_EX_Err_23, XS_MC_23, &N_23);
		cerr<<"=== 23: Total Points = "<<N_23<<endl;
		for(int i=0;i<N_23;i++){
			Nu_23[i] = E0 - Ep_23[i];
			cerr    << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),23.00, E0, Ep_23[i], Nu_23[i], xbj_23[i],XS_EX_23[i],XS_EX_Err_23[i],XS_MC_23[i] )
				<< endl;
			outfile << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),23.00, E0, Ep_23[i], Nu_23[i], xbj_23[i],XS_EX_23[i],XS_EX_Err_23[i],XS_MC_23[i] )
				<< endl;
		}
	}
	double Q2_23_D = 4.0*E0*Ep_Cut_23_1[0]*pow(TMath::Sin(23.*3.1415926/180.0*0.5),2);
	double Q2_23_U = 4.0*E0*Ep_Cut_23_2[3]*pow(TMath::Sin(23.*3.1415926/180.0*0.5),2);
		/*}}}*/

	/*QE{{{*/
	double xbj_QE[100], Nu_QE[100], Ep_QE[100], XS_EX_QE[100], XS_EX_Err_QE[100], XS_MC_QE[100];
	int N_QE = 0;
	if(Target=="He3" ||  Target=="He4" || Target=="C12"||Target=="Ca40"||Target=="Ca48"){
		Merge(Form("RQE_%s.dat",Target.Data()), xbj_QE, Ep_QE, XS_EX_QE, XS_EX_Err_QE, XS_MC_QE, &N_QE);
		cerr<<"=== QE: Total Points = "<<N_QE<<endl;
		for(int i=0;i<N_QE;i++){
			Nu_QE[i] = E0 - Ep_QE[i];
			cerr    << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", Target.Data(),25.00, E0, Ep_QE[i], Nu_QE[i], xbj_QE[i],XS_EX_QE[i],XS_EX_Err_QE[i],XS_MC_QE[i] )
				<< endl;

			outfile << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", Target.Data(),25.00, E0, Ep_QE[i], Nu_QE[i], xbj_QE[i],XS_EX_QE[i],XS_EX_Err_QE[i],XS_MC_QE[i] )
				<< endl;
		}
	}
	double Q2_25_D = 4.0*E0*Ep_Cut_QE_1[0]*pow(TMath::Sin(25.*3.1415926/180.0*0.5),2);
	/*}}}*/

	/*Degree 25 {{{*/
	double xbj_25[100], Ep_25[100], Nu_25[100], XS_EX_25[100], XS_EX_Err_25[100], XS_MC_25[100];
	int N_25 = 0;
	if(Target=="H2" ||Target=="He3" ||  Target=="He4" || Target=="C12"||Target=="Ca40"||Target=="Ca48"){
		Merge(Form("R25_%s.dat",Target.Data()), xbj_25, Ep_25, XS_EX_25, XS_EX_Err_25, XS_MC_25, &N_25);
		cerr<<"=== 25: Total Points = "<<N_25<<endl;
		for(int i=0;i<N_25;i++){
			Nu_25[i] = E0 - Ep_25[i];
			cerr    << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),25.00, E0, Ep_25[i], Nu_25[i], xbj_25[i],XS_EX_25[i],XS_EX_Err_25[i],XS_MC_25[i] )
				<< endl;
			outfile << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),25.00, E0, Ep_25[i], Nu_25[i], xbj_25[i],XS_EX_25[i],XS_EX_Err_25[i],XS_MC_25[i] )
				<< endl;
		}
	}
	double Q2_25_U = 4.0*E0*Ep_Cut_25_2[3]*pow(TMath::Sin(25.*3.1415926/180.0*0.5),2);
	/*}}}*/

	/*Degree 28 {{{*/
	double xbj_28[100], Nu_28[100], Ep_28[100], XS_EX_28[100], XS_EX_Err_28[100], XS_MC_28[100];
	int N_28 = 0;
	if(Target=="He3" || Target=="C12"){
		Merge(Form("R28_%s.dat",Target.Data()), xbj_28, Ep_28, XS_EX_28, XS_EX_Err_28, XS_MC_28, &N_28);
		cerr<<"=== 28: Total Points = "<<N_28<<endl;
		for(int i=0;i<N_28;i++){
			Nu_28[i] = E0 - Ep_28[i];
			cerr    << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),28.00, E0, Ep_28[i], Nu_28[i], xbj_28[i],XS_EX_28[i],XS_EX_Err_28[i],XS_MC_28[i] )
				<< endl;
			outfile << Form("%4s %7.3f %7.3f %7.3f %7.3f %7.3f %16e %16e %16e", 
					Target.Data(),28.00, E0, Ep_28[i], Nu_28[i], xbj_28[i],XS_EX_28[i],XS_EX_Err_28[i],XS_MC_28[i] )
				<< endl;
		}
	}
	double Q2_28_D = 4.0*E0*Ep_Cut_28_1[0]*pow(TMath::Sin(28.*3.1415926/180.0*0.5),2);
	double Q2_28_U = 4.0*E0*Ep_Cut_28_1[3]*pow(TMath::Sin(28.*3.1415926/180.0*0.5),2);
	/*}}}*/

	/*}}}*/

    /*Plot{{{*/
    /*Range{{{*/
	double Min = 1000, Max =-1000;
	for(int i=0; i<N_21;i++){
		Min = Min<XS_EX_21[i]?Min:XS_EX_21[i];
		Max = Max>XS_EX_21[i]?Max:XS_EX_21[i];
	}
	for(int i=0; i<N_23;i++){
		Min = Min<XS_EX_23[i]?Min:XS_EX_23[i];
		Max = Max>XS_EX_23[i]?Max:XS_EX_23[i];
	}
	for(int i=0; i<N_QE;i++){
		Min = Min<XS_EX_QE[i]?Min:XS_EX_QE[i];
		Max = Max>XS_EX_QE[i]?Max:XS_EX_QE[i];
	}
	for(int i=0; i<N_25;i++){
		Min = Min<XS_EX_25[i]?Min:XS_EX_25[i];
		Max = Max>XS_EX_25[i]?Max:XS_EX_25[i];
	}
	for(int i=0; i<N_28;i++){
		Min = Min<XS_EX_28[i]?Min:XS_EX_28[i];
		Max = Max>XS_EX_28[i]?Max:XS_EX_28[i];
	}
/*}}}*/

	/*Xbj{{{*/
	double xbj_err[200];
	for(int i=0;i<200;i++)
       xbj_err[200]=0;

	Double_t Xbj_Max = 2.2;
	Double_t Xbj_Min = 0.5;
	if(Target=="H2")
		Xbj_Max = 2.2;
	else if(Target=="He3"){
		Xbj_Max = 3.5;
		Max*=3.0;
	}
	else if(Target=="He4")
		Xbj_Max = 4.3;
	else
		Xbj_Max = 5.3;

	TCanvas *c1 = new TCanvas("c1","c1",1200,800);
	TH2F* xs = new TH2F("xs","",1000,Xbj_Min,Xbj_Max,1000,Min/2.1,Max*2.1);
	xs->SetStats(kFALSE);
	xs->SetXTitle("x_{bj}");
	xs->GetXaxis()->CenterTitle(1);
	xs->GetXaxis()->SetTitleFont(32);
	xs->GetXaxis()->SetTitleSize(0.06);
	xs->SetYTitle("#frac{d#sigma}{dE'd#Omega} (nb/MeV/sr)");
	xs->GetYaxis()->CenterTitle(1);
	xs->GetYaxis()->SetTitleFont(32);
	xs->GetYaxis()->SetTitleSize(0.04);
	xs->Draw(); 
	//gPad->SetLogy(1);
	gPad->SetLogy(1);

	TLegend *l1 = new TLegend(0.60,0.59,0.75, 0.94,Form("%s Target",Target.Data()));
	l1->SetBorderSize(0);
	l1->SetTextSize(0.03);
	l1->SetTextFont(32);

	TGraphErrors *pl_21 = new TGraphErrors(N_21,xbj_21,XS_EX_21,xbj_err,XS_EX_Err_21);
	pl_21-> SetMarkerSize(1.0);
	pl_21-> SetMarkerStyle(24);
	pl_21-> SetMarkerColor(2);
	pl_21-> GetXaxis()->SetTitle("x_{bj}");
	pl_21-> GetYaxis()->SetTitle("#sigma");
	pl_21->Draw("P");
	l1->AddEntry(pl_21, Form("21^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_21_D,Q2_21_U),"p");

	TGraph *p1_21_mc = new TGraphErrors(N_21,xbj_21,XS_MC_21);
	p1_21_mc-> SetLineWidth(2);
	p1_21_mc-> SetLineStyle(2);
	//p1_21_mc-> SetLineColor(2);
	p1_21_mc-> SetLineColor(1);
	p1_21_mc-> GetXaxis()->SetTitle("x_{bj}");
	p1_21_mc-> GetYaxis()->SetTitle("#sigma");
	p1_21_mc->Draw("L");
	
	TGraphErrors *pl_23 = new TGraphErrors(N_23,xbj_23,XS_EX_23,xbj_err,XS_EX_Err_23);
	if(!(Target=="H2")){
		pl_23-> SetMarkerSize(1.0);
		pl_23-> SetMarkerStyle(25);
		pl_23-> SetMarkerColor(3);
		pl_23-> GetXaxis()->SetTitle("x_{bj}");
		pl_23-> GetYaxis()->SetTitle("#sigma");
		pl_23->Draw("P");
		l1->AddEntry(pl_23, Form("23^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_23_D,Q2_23_U),"p");
		
		TGraph *p1_23_mc = new TGraphErrors(N_23,xbj_23,XS_MC_23);
		p1_23_mc-> SetLineWidth(2);
		p1_23_mc-> SetLineStyle(2);
		//p1_23_mc-> SetLineColor(3);
		p1_23_mc-> SetLineColor(1);
		p1_23_mc-> GetXaxis()->SetTitle("x_{bj}");
		p1_23_mc-> GetYaxis()->SetTitle("#sigma");
		p1_23_mc->Draw("L");
	}

	TGraphErrors *pl_QE = new TGraphErrors(N_QE,xbj_QE,XS_EX_QE,xbj_err,XS_EX_Err_QE);
	pl_QE-> SetMarkerSize(1.0);
	pl_QE-> SetMarkerStyle(26);
	pl_QE-> SetMarkerColor(4);
	pl_QE-> GetXaxis()->SetTitle("x_{bj}");
	pl_QE-> GetYaxis()->SetTitle("#sigma");
	pl_QE->Draw("P");

	TGraph *p1_QE_mc = new TGraphErrors(N_QE,xbj_QE,XS_MC_QE);
	p1_QE_mc-> SetLineWidth(2);
	p1_QE_mc-> SetLineStyle(2);
	//p1_QE_mc-> SetLineColor(4);
	p1_QE_mc-> SetLineColor(1);
	p1_QE_mc-> GetXaxis()->SetTitle("x_{bj}");
	p1_QE_mc-> GetYaxis()->SetTitle("#sigma");
	p1_QE_mc->Draw("L");

	TGraphErrors *pl_25 = new TGraphErrors(N_25,xbj_25,XS_EX_25,xbj_err,XS_EX_Err_25);
	pl_25-> SetMarkerSize(1.0);
	pl_25-> SetMarkerStyle(26);
	pl_25-> SetMarkerColor(4);
	pl_25-> GetXaxis()->SetTitle("x_{bj}");
	pl_25-> GetYaxis()->SetTitle("#sigma");
	pl_25->Draw("P");
	l1->AddEntry(pl_25, Form("25^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_25_D,Q2_25_U),"p");

	TGraph *p1_25_mc = new TGraphErrors(N_25,xbj_25,XS_MC_25);
	p1_25_mc-> SetLineWidth(2);
	p1_25_mc-> SetLineStyle(2);
	//p1_25_mc-> SetLineColor(4);
	p1_25_mc-> SetLineColor(1);
	p1_25_mc-> GetXaxis()->SetTitle("x_{bj}");
	p1_25_mc-> GetYaxis()->SetTitle("#sigma");
	p1_25_mc->Draw("L");
	
	TGraphErrors *pl_28 = new TGraphErrors(N_28,xbj_28,XS_EX_28,xbj_err,XS_EX_Err_28);
	if(Target=="He3" || Target=="C12"){
		pl_28-> SetMarkerSize(1.0);
		pl_28-> SetMarkerStyle(28);
		pl_28-> SetMarkerColor(6);
		pl_28-> GetXaxis()->SetTitle("x_{bj}");
		pl_28-> GetYaxis()->SetTitle("#sigma");
		pl_28->Draw("P");
		l1->AddEntry(pl_28, Form("28^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_28_D,Q2_28_U),"p");

		TGraph *p1_28_mc = new TGraphErrors(N_28,xbj_28,XS_MC_28);
		p1_28_mc-> SetLineWidth(2);
		p1_28_mc-> SetLineStyle(2);
		//p1_28_mc-> SetLineColor(6);
		p1_28_mc-> SetLineColor(1);
		p1_28_mc-> GetXaxis()->SetTitle("x_{bj}");
		p1_28_mc-> GetYaxis()->SetTitle("#sigma");
		p1_28_mc->Draw("L");
	}

	//l1->AddEntry(p1_21_mc, "Theory","l");
	l1->AddEntry(p1_21_mc, "Model","l");
	l1->Draw();
	c1->Print(Form("%s_XS_All_xbj.pdf",Target.Data()));
	c1->Print(Form("%s_XS_All_xbj.png",Target.Data()));
	/*}}}*/

	/*Ep{{{*/
	const double Ep_Min = 2.30;
	const double Ep_Max = 3.30;

	TCanvas *c2 = new TCanvas("c2","c2",1200,800);
	TH2F* ep = new TH2F("ep","",1000,E0-Ep_Max,E0-Ep_Min,1000,Min/2.1,Max*2.1);
	ep->SetStats(kFALSE);
	ep->SetXTitle("#nu");
	ep->GetXaxis()->CenterTitle(1);
	ep->GetXaxis()->SetTitleFont(32);
	ep->GetXaxis()->SetTitleSize(0.06);
	ep->SetYTitle("#frac{d#sigma}{dE'd#Omega} (nb/MeV/sr)");
	ep->GetYaxis()->CenterTitle(1);
	ep->GetYaxis()->SetTitleFont(32);
	ep->GetYaxis()->SetTitleSize(0.04);
	ep->Draw(); 
	//gPad->SetLogy(1);
	gPad->SetLogy(1);

	TLegend *l2 = new TLegend(0.60,0.19,0.75, 0.54,Form("%s Target",Target.Data()));
	l2->SetBorderSize(0);
	l2->SetTextSize(0.03);
	l2->SetTextFont(32);

	TGraphErrors *p2_21 = new TGraphErrors(N_21,Nu_21,XS_EX_21,xbj_err,XS_EX_Err_21);
	p2_21-> SetMarkerSize(1.0);
	p2_21-> SetMarkerStyle(24);
	p2_21-> SetMarkerColor(2);
	p2_21-> GetXaxis()->SetTitle("#nu");
	p2_21-> GetYaxis()->SetTitle("#sigma");
	p2_21->Draw("P");
	l2->AddEntry(p2_21, Form("21^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_21_D,Q2_21_U),"p");

	TGraph *p2_21_mc = new TGraphErrors(N_21,Nu_21,XS_MC_21);
	p2_21_mc-> SetLineWidth(2);
	p2_21_mc-> SetLineStyle(2);
	//p2_21_mc-> SetLineColor(2);
	p2_21_mc-> SetLineColor(1);
	p2_21_mc-> GetXaxis()->SetTitle("#nu");
	p2_21_mc-> GetYaxis()->SetTitle("#sigma");
	p2_21_mc->Draw("L");
	
	TGraphErrors *p2_23 = new TGraphErrors(N_23,Nu_23,XS_EX_23,xbj_err,XS_EX_Err_23);
	if(!(Target=="H2")){
		p2_23-> SetMarkerSize(1.0);
		p2_23-> SetMarkerStyle(25);
		p2_23-> SetMarkerColor(3);
		p2_23-> GetXaxis()->SetTitle("#nu");
		p2_23-> GetYaxis()->SetTitle("#sigma");
		p2_23->Draw("P");
		l2->AddEntry(p2_23, Form("23^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_23_D,Q2_23_U),"p");
	
		TGraph *p2_23_mc = new TGraphErrors(N_23,Nu_23,XS_MC_23);
		p2_23_mc-> SetLineWidth(2);
		p2_23_mc-> SetLineStyle(2);
		//p2_23_mc-> SetLineColor(3);
		p2_23_mc-> SetLineColor(1);
		p2_23_mc-> GetXaxis()->SetTitle("#nu");
		p2_23_mc-> GetYaxis()->SetTitle("#sigma");
		p2_23_mc->Draw("L");

}

	TGraphErrors *p2_QE = new TGraphErrors(N_QE,Nu_QE,XS_EX_QE,xbj_err,XS_EX_Err_QE);
	p2_QE-> SetMarkerSize(1.0);
	p2_QE-> SetMarkerStyle(26);
	p2_QE-> SetMarkerColor(4);
	p2_QE-> GetXaxis()->SetTitle("#nu");
	p2_QE-> GetYaxis()->SetTitle("#sigma");
	p2_QE->Draw("P");
	TGraphErrors *p2_25 = new TGraphErrors(N_25,Nu_25,XS_EX_25,xbj_err,XS_EX_Err_25);
	p2_25-> SetMarkerSize(1.0);
	p2_25-> SetMarkerStyle(26);
	p2_25-> SetMarkerColor(4);
	p2_25-> GetXaxis()->SetTitle("#nu}");
	p2_25-> GetYaxis()->SetTitle("#sigma");
	p2_25->Draw("P");
	l2->AddEntry(p2_25, Form("25^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_25_D,Q2_25_U),"p");

	TGraph *p2_QE_mc = new TGraphErrors(N_QE,Nu_QE,XS_MC_QE);
	p2_QE_mc-> SetLineWidth(2);
	p2_QE_mc-> SetLineStyle(2);
	//p2_QE_mc-> SetLineColor(4);
	p2_QE_mc-> SetLineColor(1);
	p2_QE_mc-> GetXaxis()->SetTitle("#nu");
	p2_QE_mc-> GetYaxis()->SetTitle("#sigma");
	p2_QE_mc->Draw("L");

	TGraph *p2_25_mc = new TGraphErrors(N_25,Nu_25,XS_MC_25);
	p2_25_mc-> SetLineWidth(2);
	p2_25_mc-> SetLineStyle(2);
	p2_25_mc-> SetLineColor(1);
	//p2_25_mc-> SetLineColor(4);
	p2_25_mc-> GetXaxis()->SetTitle("#nu");
	p2_25_mc-> GetYaxis()->SetTitle("#sigma");
	p2_25_mc->Draw("L");

	TGraphErrors *p2_28 = new TGraphErrors(N_28,Nu_28,XS_EX_28,xbj_err,XS_EX_Err_28);
	if(Target=="He3" || Target=="C12"){
		p2_28-> SetMarkerSize(1.0);
		p2_28-> SetMarkerStyle(28);
		p2_28-> SetMarkerColor(6);
		p2_28-> GetXaxis()->SetTitle("#nu");
		p2_28-> GetYaxis()->SetTitle("#sigma");
		p2_28->Draw("P");
		l2->AddEntry(p2_28, Form("28^{o}: %4.3f<Q^{2}<%4.3f (GeV/c^{2})",Q2_28_D,Q2_28_U),"p");

		TGraph *p2_28_mc = new TGraphErrors(N_28,Nu_28,XS_MC_28);
		p2_28_mc-> SetLineWidth(2);
		p2_28_mc-> SetLineStyle(2);
		//p2_28_mc-> SetLineColor(6);
		p2_28_mc-> SetLineColor(1);
		p2_28_mc-> GetXaxis()->SetTitle("#nu");
		p2_28_mc-> GetYaxis()->SetTitle("#sigma");
		p2_28_mc->Draw("L");
	}

    //l2->AddEntry(p2_21_mc,"Theory","l");
    l2->AddEntry(p2_21_mc,"Model","l");

    l2->Draw();
    c2->Print(Form("%s_XS_All.png",Target.Data()));
	c2->Print(Form("%s_XS_All.pdf",Target.Data()));
 	/*}}}*/
	/*}}}*/

	outfile.close();

	return 0;
}
Exemplo n.º 28
0
void plot_cent(char* etaWidth = (char*)"10_eta_18", Int_t radius = 3){

  TStopwatch timer;
  gStyle->SetOptStat(0);
  TH1::SetDefaultSumw2();

  //  cout<<"etaWidth = "<<etaWidth<<endl;
  bool isAnalysisBin = false; 

  TDatime date;
  
  TFile * ffileAll=TFile::Open("test.root");
  TFile *ffileMN = TFile::Open("HIMinBiaswithoutHLT80JetDeltaEtaPlotswithcent.root");
  TFile *ffile = TFile::Open("HI80JetDeltaEtaPlotswithcent.root");
   TFile *filecomp=TFile::Open("HIMinBiasJetDeltaEtaPlotswithcentwoleading.root");
   TFile *ffileMock = TFile::Open("mockfake/MinBiasSpectrawiLJcut.root");
   
  //   TFile *filecomp=TFile::Open("HIMinBiasJetDeltaEtaPlotswithcentwoleadingandalso40.root");
//  fMinBias = TFile::Open(Form("Pawan_ntuple_PbPb_MinBiasData_spectra_JetID_CutA_finebins_CentralityWeighted_%s_R0p%d.root",etaWidth,radius));
  // fJetTrig = TFile::Open(Form("/export/d00/scratch/rkunnawa/rootfiles/RAA/Pawan_ntuple_PbPb_data_MC_subid0_spectra_JetID_CutA_finebins_%s_R0p%d.root",etaWidth,radius));

  // get the histograms
  TH1F * hspectra[nbins_cent], * hdeltaphi[nbins_cent];
  TH1F * hspectraMB[nbins_cent];
  TH1F * hspectraAll[nbins_cent];
  
  TH1F * hspectraLMR[nbins_cent];

  TH1F * hspectrawol[nbins_cent];
  TH1F * hspectrawil[nbins_cent];

  Float_t bin_no = 1;

  for(int i = 0; i<nbins_cent-1; ++i){
    hspectraAll[i] = (TH1F*)ffileAll->Get(Form("hptspectra_cent%d",i));
    hspectra[i] = (TH1F*)ffile->Get(Form("hptspectra_cent%d",i));
    hspectraMB[i] = (TH1F*)ffileMN->Get(Form("hptspectra_cent%d",i));
    hdeltaphi[i]   =  (TH1F*)ffileAll->Get(Form("hdphipt_cent%d",i));
  
    hspectrawol[i] = (TH1F*)filecomp->Get(Form("hptspectrawoleading_cent%d",i));
    hspectrawil[i] = (TH1F*)filecomp->Get(Form("hptspectra_cent%d",i));

    hspectraLMR[i] = (TH1F*)ffileMock->Get(Form("hptspectrawoleading_cent%d",i));
  }


  TH2F * hBlankSpectra = new TH2F("hBlankSpectra","",400,0,150,100,1e-6,5e3);
  TCanvas * cFakeSub = new TCanvas("cFakeSub","",1000,800);
  makeMultiPanelCanvasWithGap(cFakeSub,3,2,0.01,0.01,0.16,0.2,0.04,0.04);
  //cFakeSub->Divide(3,2);
  float scale=1;
  //  float scale=1.14218775734552442e-03;
  TLegend * lSub = myLegend(0.5,0.7,0.9,0.9);
  makeHistTitle(hBlankSpectra," ","Jet p_{T} (GeV/c)","Arb. Units");
  // hBlankSpectra->GetYaxis()->SetNdivisions(1000); 
  hBlankSpectra->GetYaxis()->SetMoreLogLabels(kFALSE);
  hBlankSpectra->GetYaxis()->SetTitleOffset(2.5);
  lSub->AddEntry(hspectraAll[0]," MinBias ","pl");
  lSub->AddEntry(hspectra[0]," HLT80 ","pl");
  lSub->AddEntry(hspectraMB[0],"MinBias && !HLT80 ","pl");
    //lSub->AddEntry(hSubtracted[0],"Jet Triggered - MinBias","pl");
    //lSub->SetTextSiz

  for(int i = 0; i<6; ++i){
    //cout<< "    i values "<<i<<endl;
    cFakeSub->cd(6-i);
    cFakeSub->cd(6-i)->SetLogy();
    hBlankSpectra->Draw();
    hspectraMB[i]->SetMarkerStyle(24);    
    hspectraMB[i]->SetMarkerColor(kRed);
    
    hspectraAll[i]->SetMarkerStyle(25);    
    hspectraAll[i]->SetMarkerColor(kBlack);
    
    hspectra[i]->Scale(scale);
    hspectra[i]->SetMarkerStyle(33);    
    hspectra[i]->SetMarkerColor(kBlue);
    //hspectra[i]->SetAxisRange(13,299,"X");
    makeHistTitle(hspectra[i]," ","Jet p_{T} (GeV/c)","Arb. Units");
    Double_t boundaries_cent[nbins_cent+1] = {0,2,4,12,20,28,36,40};

    hspectraMB[i]->Rebin(4);
    hspectraMB[i]->Scale(0.25);
    hspectra[i]->Rebin(4);
    hspectra[i]->Scale(0.25);
    hspectraAll[i]->Rebin(4);
    hspectraAll[i]->Scale(0.25);

    //  hspectraAll[i]->Draw("same");
    hspectraMB[i]->Draw("same");
    hspectra[i]->Draw("same");
    hspectraAll[i]->Draw("same");
   
    lSub->Draw();
    //cout<<"working here   too"<<endl; 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.8,0.85,20);    
    
  }


  cFakeSub->cd(1);
  putCMSPrel();
  
  //  lSub->AddEntry(hJetTrigComb[0],"Jet Triggered Data","pl");
  //lSub->AddEntry(hMinBias[0],"MinBias data","pl");
  //lSub->AddEntry(hSubtracted[0],"Jet Triggered - MinBias","pl");
  lSub->SetTextSize(0.04);
  cFakeSub->SaveAs("MBandHLT80_spectra.pdf","RECREATE");

  //  lSub->Draw();
 
 
  if(false){
  //float pi=TMath::pi();
  TH2F * hBlankSpectra2 = new TH2F("hBlankSpectra2","",400,0,100,100,0,3.2);
  TCanvas * cFakeSub2 = new TCanvas("cFakeSub2","",1000,800);
  makeMultiPanelCanvasWithGap(cFakeSub2,3,2,0.01,0.01,0.16,0.2,0.04,0.04);
  //cFakeSub->Divide(3,2);
  
  
  TLegend * lSub2 = myLegend(0.5,0.7,0.9,0.9);
  makeHistTitle(hBlankSpectra2," ","Jet p_{T} (GeV/c)","#Delta #phi");
  // hBlankSpectra->GetYaxis()->SetNdivisions(1000); 
  hBlankSpectra2->GetYaxis()->SetMoreLogLabels(kFALSE);
  hBlankSpectra2->GetYaxis()->SetTitleOffset(2.5);
  
  for(int i = 0; i<6; ++i){
    //cout<< "    i values "<<i<<endl;
    cFakeSub2->cd(6-i);
    cFakeSub2->cd(6-i)->SetLogz();
    hBlankSpectra2->Draw();
    
    //    hdeltaphi[i]->SetMarkerStyle(24);    
    // hdeltaphi[i]->SetMarkerColor(kBlack);
    
    makeHistTitle(hdeltaphi[i]," ","Jet p_{T} (GeV/c)","#Delta #phi");
    //  hdeltaphi[i]->SetAxisRange(1e-4,1e+2,"Z");
    hdeltaphi[i]->Draw("samecolz");
    //cout<<"working here   too"<<endl; 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.8,0.85,20);    
    
  }


  // cFakeSub2->cd(1);
  //putCMSPrel();
  
  cFakeSub2->SaveAs("MBandHLT80_deltaphi.pdf","RECREATE");
 
  }



  if(true){
  //float pi=TMath::pi();
  //TH2F * hBlankSpectra10 = new TH2F("hBlankSpectra10","",400,0,100,100,1e-5,5e3);
  TH2F * hBlankSpectra10 = new TH2F("hBlankSpectra10","",400,0,150,100,1e-6,5e3);
  TCanvas * cFakeSub10 = new TCanvas("cFakeSub10","",1000,800);
  makeMultiPanelCanvasWithGap(cFakeSub10,3,2,0.01,0.01,0.16,0.2,0.04,0.04);
  //cFakeSub->Divide(3,2);
  
  TLegend * lSub10 = myLegend(0.4,0.6,0.9,0.9);
  makeHistTitle(hBlankSpectra10," ","Jet p_{T} (GeV/c)","Arb. Units.");

  lSub10->AddEntry(hspectrawol[0]," w/o leading jet ","pl");
  lSub10->AddEntry(hspectraLMR[0]," w/o leading jet (Mock scaled) ","pl");
  lSub10->AddEntry(hspectraMB[0],"MinBias && !HLT80 ","pl");
  lSub10->AddEntry(hspectrawil[0],"MinBias ","pl");


// hBlankSpectra->GetYaxis()->SetNdivisions(1000); 
  hBlankSpectra10->GetYaxis()->SetMoreLogLabels(kFALSE);
  hBlankSpectra10->GetYaxis()->SetTitleOffset(2.5);
  
  for(int i = 0; i<6; ++i){
    //cout<< "    i values "<<i<<endl;
    cFakeSub10->cd(6-i);
    cFakeSub10->cd(6-i)->SetLogy();
    hBlankSpectra10->Draw();
    
    hspectrawol[i]->SetMarkerStyle(25);    
    hspectrawol[i]->SetMarkerColor(kRed);
    
    hspectrawol[i]->Rebin(4);
    hspectrawol[i]->Scale(0.25);
    
    hspectrawil[i]->SetMarkerStyle(33);  
    hspectrawil[i]->Rebin(4);
    hspectrawil[i]->Scale(0.25);

    //hspectraAll[i]->Rebin(4);
    //hspectraAll[i]->Scale(0.25);
    hspectraMB[i]->Draw("same");
    //makeHistTitle( hspectrawol[i]," ","Jet p_{T} (GeV/c)","#Delta #phi");
    //  hdeltaphi[i]->SetAxisRange(1e-4,1e+2,"Z");
     hspectrawol[i]->Draw("same");
     hspectrawil[i]->Draw("same");
    

     hspectraLMR[i]->SetMarkerStyle(34); 
     hspectraLMR[i]->SetMarkerColor(kBlue);
     hspectraLMR[i]->Rebin(4);
     hspectraLMR[i]->Scale(0.25);
     hspectraLMR[i]->Draw("same");

     lSub10->Draw();
    //cout<<"working here   too"<<endl; 
    drawText(Form("%2.0f-%2.0f%%",2.5*boundaries_cent[i],2.5*boundaries_cent[i+1]),0.8,0.85,20);    
    
  }
   lSub10->SetTextSize(0.04);
   cFakeSub10->SaveAs("MBandOtherMethods_spectra.pdf","RECREATE");
  // cFakeSub2->cd(1);
  //putCMSPrel();
  
 
 
  }



  // 
  //  cFakeSub->SaveAs("MBandHLT80_spectra.pdf","RECREATE");



  //cFakeSub->SaveAs(Form("PbPb_FakeMinBias_SubtractedFrom_Data_R%d_%s_%d.pdf",radius, etaWidth, date.GetDate()),"RECREATE");
  
  //  create output root file to write the output histogram. 
  // TFile fout(Form("PbPb_FakeMinBias_SubtractedFrom_Data_R%d_%s_%d.root",radius, etaWidth, date.GetDate()),"RECREATE");
  //fout.cd();

  //for(int i = 0; i<nbins_cent-1; ++i){

    //  hSubtracted[i]->Write();
    //JetTrigComb[i]->Write();
      //hMinBias[i]->Write();

  //}

  //  fout.Close();

  //macro end. 
  timer.Stop();
  cout<<"Macro finished: "<<endl;
  cout<<"CPU time (min)  = "<<(Float_t)timer.CpuTime()/60<<endl;
  cout<<"Real time (min) = "<<(Float_t)timer.RealTime()/60<<endl;
  
}
Exemplo n.º 29
0
// input: - Input file (result from TMVA)
//        - use of TMVA plotting TStyle
void probas( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
{
    // set style and remove existing canvas'
    TMVAGlob::Initialize( useTMVAStyle );

    // switches
    const Bool_t Draw_CFANN_Logy = kFALSE;
    const Bool_t Save_Images     = kTRUE;

    // checks if file with name "fin" is already open, and if not opens one
    TFile* file = TMVAGlob::OpenFile( fin );

    // define Canvas layout here!
    Int_t xPad = 1; // no of plots in x
    Int_t yPad = 1; // no of plots in y
    Int_t noPad = xPad * yPad ;
    const Int_t width = 600;   // size of canvas

    // this defines how many canvases we need
    TCanvas *c = 0;

    // counter variables
    Int_t countCanvas = 0;

    // list of existing MVAs
    const Int_t nveto = 1;
    TString suffixSig = "_tr_S";
    TString suffixBgd = "_tr_B";

    // search for the right histograms in full list of keys
    TList methods;
    UInt_t nmethods = TMVAGlob::GetListOfMethods( methods );
    if (nmethods==0) {
        cout << "--- Probas.C: no methods found!" << endl;
        return;
    }
    TIter next(&methods);
    TKey *key, *hkey;
    char fname[200];
    TH1* sig(0);
    TH1* bgd(0);
    while ((key = (TKey*)next())) {
        TDirectory * mDir = (TDirectory*)key->ReadObj();
        TList titles;
        UInt_t ni = TMVAGlob::GetListOfTitles( mDir, titles );
        TString methodName;
        TMVAGlob::GetMethodName(methodName,key);
        if (ni==0) {
            cout << "+++ No titles found for classifier: " << methodName << endl;
            return;
        }
        TIter nextTitle(&titles);
        TKey *instkey;
        TDirectory *instDir;
        while ((instkey = (TKey *)nextTitle())) {
            instDir = (TDirectory *)instkey->ReadObj();
            TString instName = instkey->GetName();
            TList h1hists;
            UInt_t nhists = TMVAGlob::GetListOfKeys( h1hists, "TH1", instDir );
            if (nhists==0) cout << "*** No histograms found!" << endl;
            TIter nextInDir(&h1hists);
            TString methodTitle;
            TMVAGlob::GetMethodTitle(methodTitle,instDir);
            while (hkey = (TKey*)nextInDir()) {
                TH1 *th1 = (TH1*)hkey->ReadObj();
                TString hname= th1->GetName();
                if (hname.Contains( suffixSig ) && !hname.Contains( "Cut") &&
                        !hname.Contains("original") && !hname.Contains("smoothed")) {

                    // retrieve corresponding signal and background histograms
                    TString hnameS = hname;
                    TString hnameB = hname;
                    hnameB.ReplaceAll("_S","_B");

                    sig = (TH1*)instDir->Get( hnameS );
                    bgd = (TH1*)instDir->Get( hnameB );

                    if (sig == 0 || bgd == 0) {
                        cout << "*** probas.C: big troubles in probas.... histogram: " << hname << " not found" << endl;
                        return;
                    }

                    TH1* sigF(0);
                    TH1* bkgF(0);
                    for (int i=0; i<= 5; i++) {
                        TString hspline = hnameS + Form("_smoothed_hist_from_spline%i",i);
                        sigF = (TH1*)instDir->Get( hspline );

                        if (sigF) {
                            bkgF = (TH1*)instDir->Get( hspline.ReplaceAll("_tr_S","_tr_B") );
                            break;
                        }
                    }
                    if ((sigF == NULL || bkgF == NULL) &&!hname.Contains("hist") ) {
                        cout << "*** probas.C: big troubles - did not found histogram " << hspline.Data() << " "
                             << sigF << " " << bkgF << endl;
                        return;
                    }
                    else  {
                        // remove the signal suffix

                        // check that exist
                        if (NULL != sigF && NULL != bkgF && NULL!=sig && NULL!=bgd) {

                            TString hname = sig->GetName();

                            // chop off useless stuff
                            sig->SetTitle( TString("TMVA output for classifier: ") + methodTitle );

                            // create new canvas
                            cout << "--- Book canvas no: " << countCanvas << endl;
                            char cn[20];
                            sprintf( cn, "canvas%d", countCanvas+1 );
                            c = new TCanvas( cn, Form("TMVA Output Fit Variables %s",methodTitle.Data()),
                                             countCanvas*50+200, countCanvas*20, width, width*0.78 );

                            // set the histogram style
                            TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
                            TMVAGlob::SetSignalAndBackgroundStyle( sigF, bkgF );

                            // frame limits (choose judicuous x range)
                            Float_t nrms = 4;
                            Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
                                                                  bgd->GetMean() - nrms*bgd->GetRMS() ),
                                                       sig->GetXaxis()->GetXmin() );
                            Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
                                                                  bgd->GetMean() + nrms*bgd->GetRMS() ),
                                                       sig->GetXaxis()->GetXmax() );
                            Float_t ymin = 0;
                            Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*1.5;

                            if (Draw_CFANN_Logy && mvaName[imva] == "CFANN") ymin = 0.01;

                            // build a frame
                            Int_t nb = 500;
                            TH2F* frame = new TH2F( TString("frame") + sig->GetName() + "_proba", sig->GetTitle(),
                                                    nb, xmin, xmax, nb, ymin, ymax );
                            frame->GetXaxis()->SetTitle(methodTitle);
                            frame->GetYaxis()->SetTitle("Normalized");
                            TMVAGlob::SetFrameStyle( frame );

                            // eventually: draw the frame
                            frame->Draw();

                            if (Draw_CFANN_Logy && mvaName[imva] == "CFANN") c->SetLogy();

                            // overlay signal and background histograms
                            sig->SetMarkerColor( TMVAGlob::c_SignalLine );
                            sig->SetMarkerSize( 0.7 );
                            sig->SetMarkerStyle( 20 );
                            sig->SetLineWidth(1);

                            bgd->SetMarkerColor( TMVAGlob::c_BackgroundLine );
                            bgd->SetMarkerSize( 0.7 );
                            bgd->SetMarkerStyle( 24 );
                            bgd->SetLineWidth(1);

                            sig->Draw("samee");
                            bgd->Draw("samee");

                            sigF->SetFillStyle( 0 );
                            bkgF->SetFillStyle( 0 );
                            sigF->Draw("samehist");
                            bkgF->Draw("samehist");

                            // redraw axes
                            frame->Draw("sameaxis");

                            // Draw legend
                            TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.2,
                                                          c->GetLeftMargin() + 0.4, 1 - c->GetTopMargin() );
                            legend->AddEntry(sig,"Signal data","P");
                            legend->AddEntry(sigF,"Signal PDF","L");
                            legend->AddEntry(bgd,"Background data","P");
                            legend->AddEntry(bkgF,"Background PDF","L");
                            legend->Draw("same");
                            legend->SetBorderSize(1);
                            legend->SetMargin( 0.3 );

                            // save canvas to file
                            c->Update();
                            TMVAGlob::plot_logo();
                            sprintf( fname, "plots/mva_pdf_%s_c%i", methodTitle.Data(), countCanvas+1 );
                            if (Save_Images) TMVAGlob::imgconv( c, fname );
                            countCanvas++;
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 30
0
void getResvsub(int ispt=1){

	double theta[ntheta];
	TFile *f[nFileAll];
		
	for(int itheta=0;itheta<ntheta;itheta++)
        	theta[itheta]=itheta*TMath::Pi()/ntheta/nn;

        int nvv;
        const double *binv;

        if(ispt){             nvv = nptv;       binv = ptbinv;}
            else{             nvv = netav;          binv = etabinv;}

	string SumorProd = getenv("SUMORPROD");
	string mdir = getenv("DIR");
	ofstream fstrv;
        if(ispt){
	if(SumorProd=="Sum")fstrv.open("v_sub.txt");
	else fstrv.open("v_2_sub.txt");
        }
        else{
	if(SumorProd=="Sum")fstrv.open("v_eta_sub.txt");
	else fstrv.open("v_2_coarse_eta_sub.txt");
        }
	
	TVectorD Nevent[nbin], totmultall[nbin], totmultall_[nbin];
	TVectorD totmult[nbin], totpt[nbin],toteta[nbin];
	TVectorD totmulthisto[nbin], totmulthistocorr[nbin];
	TVectorD V_int[nbin], V_interr[nbin];
	TVectorD V_intcorr[nbin], V_intcorrerr[nbin];
	TVectorD* V_mean;
	TVectorD* deltaV_mean;
	TVectorD vmeanmean[nbin], deltavmeanmean[nbin], sigmavmeanmean[nbin], avgavgpt[nbin], avgavgeta[nbin];
	TVectorD* V[nbin]; TVectorD* chi[nbin];
	TVectorD* dDRe[nbin]; TVectorD* dDIm[nbin];
	TVectorD* dNRe[nbin][ntheta]; TVectorD* dNIm[nbin][ntheta];
	TComplex dD[nbin][ntheta], dN[nbin][ntheta][nvv];
	TVectorD avgmult[nbin];	TVectorD avgmultall;
	TVectorD avgpt[nbin],avgeta[nbin];
	TVectorD v[nbin][ntheta],vmean[nbin],deltav[nbin][ntheta],deltavmean[nbin];
	TVectorD IFILE[nbin];
	if(SumorProd=="Sum")	TFile *infile = TFile::Open("mergedV_Sum.root");
	else	TFile *infile = TFile::Open("mergedV_Prod.root");
        if(ispt){
	if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_sub.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2_sub.root","Recreate");
        }
        else{
	if(SumorProd=="Sum")TFile *fout = new TFile("mergedv_Prod_eta_sub.root","Recreate");
	else TFile *fout = new TFile("mergedv_Prod2_coarse_eta_sub.root","Recreate");
        }

	TVectorD Nevent_;       Nevent_.ResizeTo(nbin);  Nevent_.Zero();
	TH1D* hpt[nbin];
	TH1D* hpteffcorr[nbin];
	for(int ibin=0;ibin<nbin;ibin++){
        for(int ifile=0; ifile<nFileAll; ifile++){
            if(ispt){
        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile));
        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile));
            }
            else{
        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6c/coarsebins/%s/Anaveta_Prod_%d.root",mdir.c_str(),ifile));
        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod2_%d.root",mdir.c_str(),ifile));
            }
        TVectorD* Nevent_t =  (TVectorD*)f[ifile]->Get(Form("Nevent"));
        Nevent_[ibin]+=(*Nevent_t)[ibin];
        f[ifile]->Close();
        }
	IFILE[ibin].ResizeTo(nsamples);
        Nevent[ibin].ResizeTo(nsamples);  Nevent[ibin].Zero();
        totmultall[ibin].ResizeTo(nsamples);      totmultall[ibin].Zero();
        totmultall_[ibin].ResizeTo(nsamples);      totmultall_[ibin].Zero();
        TDirectory *dir0 = fout->mkdir(Form("D_%d",ibin));


      	vmeanmean[ibin].ResizeTo(nvv);  vmeanmean[ibin].Zero();
        deltavmeanmean[ibin].ResizeTo(nvv);  deltavmeanmean[ibin].Zero();
       	sigmavmeanmean[ibin].ResizeTo(nvv);  sigmavmeanmean[ibin].Zero();
	avgavgpt[ibin].ResizeTo(nvv);	avgavgpt[ibin].Zero();
	avgavgeta[ibin].ResizeTo(nvv);	avgavgeta[ibin].Zero();
	V_interr[ibin].ResizeTo(nsamples);	V_interr[ibin].Zero();
	V_int[ibin].ResizeTo(nsamples);	V_int[ibin].Zero();
        if(ispt){
	V_intcorr[ibin].ResizeTo(nsamples);	V_intcorr[ibin].Zero();
	V_intcorrerr[ibin].ResizeTo(nsamples);	V_intcorrerr[ibin].Zero();
        }
        for(int isample=0;isample<nsamples;isample++){

	TVectorD Nevent0; Nevent0.ResizeTo(nbin);	Nevent0.Zero();
	avgmultall.ResizeTo(nbin);
		totmult[ibin].ResizeTo(nvv);	totmult[ibin].Zero();
                if(ispt){
		totmulthisto[ibin].ResizeTo(nvv); totmulthisto[ibin].Zero();
		totmulthistocorr[ibin].ResizeTo(nvv);totmulthistocorr[ibin].Zero();
                }
		avgmult[ibin].ResizeTo(nvv);	avgpt[ibin].ResizeTo(nvv);  avgeta[ibin].ResizeTo(nvv);
		totpt[ibin].ResizeTo(nvv);	totpt[ibin].Zero();
		toteta[ibin].ResizeTo(nvv);	toteta[ibin].Zero();
		vmean[ibin].ResizeTo(nvv);	deltavmean[ibin].ResizeTo(nvv);
		V[ibin] = (TVectorD*) infile->Get(Form("D_%d/V",ibin,isample));
		chi[ibin] = (TVectorD*) infile->Get(Form("chi",ibin,isample));
		V_mean = (TVectorD*) infile->Get(Form("Vmean",ibin,isample));
		deltaV_mean = (TVectorD*) infile->Get(Form("deltaVmean",ibin,isample));
		for(int itheta=0;itheta<ntheta;itheta++){
			v[ibin][itheta].ResizeTo(nvv);	deltav[ibin][itheta].ResizeTo(nvv);
			dD[ibin][itheta]=0;
			for(int ivbin=0;ivbin<nvv;ivbin++){
				dN[ibin][itheta][ivbin]=0;
			}
		}

        for(int ifile=0; ifile<nFileAll; ifile++){
            if(ispt){
	        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod_%d.root",mdir.c_str(),ifile));
	        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/%s/Anav_Prod2_%d.root",mdir.c_str(),ifile));
            }
            else{
	        if(SumorProd=="Sum") f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod_%d.root",mdir.c_str(),ifile));
	        else f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/pbsjoboutput/tracknormcpt03to6/coarsebins/%s/Anaveta_Prod2_%d.root",mdir.c_str(),ifile));
            }
		TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get("Nevent");	
		TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get("totmultall");
		Nevent0[ibin] += (*Nevent_t)[ibin];
                double start=isample*Nevent_[ibin]/nsamples;
                double end=(isample+1)*Nevent_[ibin]/nsamples;
                if(Nevent0[ibin]>start && Nevent0[ibin]<=end){
                        IFILE[ibin][isample]=(double)ifile;
                        Nevent[ibin][isample] += (*Nevent_t)[ibin];
			TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin));
			TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin));
			TVectorD* toteta_t = (TVectorD*)f[ifile]->Get(Form("toteta_%d",ibin));
			dDRe[ibin] = (TVectorD*)f[ifile]->Get(Form("dDRe_%d",ibin));
			dDIm[ibin] = (TVectorD*)f[ifile]->Get(Form("dDIm_%d",ibin));
			totmultall[ibin][isample]+=(*totmultall_t)[ibin];
			for(int ivbin=0;ivbin<nvv;ivbin++){
				totmult[ibin][ivbin]+=(*totmult_t)[ivbin];
				totpt[ibin][ivbin]+=(*totpt_t)[ivbin];
				toteta[ibin][ivbin]+=(*toteta_t)[ivbin];
			}
			for(int itheta=0;itheta<ntheta;itheta++){
				dNRe[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNRe_%d_%d",ibin,itheta));
				dNIm[ibin][itheta] = (TVectorD*)f[ifile]->Get(Form("dNIm_%d_%d",ibin,itheta));
				dD[ibin][itheta]+=TComplex((*dDRe[ibin])[itheta],(*dDIm[ibin])[itheta]);
				for(int ivbin=0;ivbin<nvv;ivbin++){
					if(ifile<188) dN[ibin][itheta][ivbin]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]);
                                        else dN[ibin][itheta][nvv-ivbin-1]+=TComplex((*dNRe[ibin][itheta])[ivbin],(*dNIm[ibin][itheta])[ivbin]);
                                }
			}
		}
	f[ifile]->Close();
	}
	
	TFile *fhisto = TFile::Open("histomerged.root");
	TFile *feff = TFile::Open("/home/xuq7/HI/flow/LYZ/v2/TrackCorrections_HIJING_538_OFFICIAL_Mar24.root");
	TH2F* heff = (TH2F*)feff->Get("rTotalEff3D");
      	TH1D* hpteff = (TH1D*)heff->ProjectionY("hpteff",heff->GetXaxis()->FindBin(-2.4),heff->GetXaxis()->FindBin(2.4)-1,"o");
	TArrayD *ptarr = (TArrayD*)heff->GetYaxis()->GetXbins();
	double *ptbinhisto = ptarr->GetArray();
	int NbinX = heff->GetXaxis()->GetNbins();
	int NbinY = heff->GetYaxis()->GetNbins();
	hpteff->Scale(1.0/NbinX);
        
		for(int itheta=0;itheta<ntheta;itheta++)
			dD[ibin][itheta]*=TComplex::Power(TComplex::I(),mm-1)/(Double_t)Nevent[ibin][isample];
	
		avgmultall[ibin]=1.0*totmultall[ibin][isample]/Nevent[ibin][isample];
                hpt[ibin] = (TH1D*)fhisto->Get(Form("D_%d/hpt",ibin));
                //TH1D* hptre = (TH1D*)hpt[ibin]->Rebin(NbinY,"hptre",ptbinhisto);
                //hpteffcorr[ibin] = (TH1D*)hptre->Clone(Form("hpteffcorr_%d",ibin));
                //hpteffcorr[ibin]->Divide(hpteff);
		for(int ivbin=0;ivbin<nvv; ivbin++){
			vmean[ibin][ivbin]=0;
			deltavmean[ibin][ivbin]=0;
			avgmult[ibin][ivbin]=1.0*totmult[ibin][ivbin]/Nevent[ibin][isample];
			avgpt[ibin][ivbin]=1.0*totpt[ibin][ivbin]/totmult[ibin][ivbin];
			avgeta[ibin][ivbin]=1.0*toteta[ibin][ivbin]/totmult[ibin][ivbin];
			for(int itheta=0;itheta<ntheta;itheta++){
				dN[ibin][itheta][ivbin]/=totmult[ibin][ivbin];
				TComplex Res=dN[ibin][itheta][ivbin]/dD[ibin][itheta];
				v[ibin][itheta][ivbin]=(*V[ibin])[itheta]*avgmultall[ibin]*TMath::BesselJ1(j01)/Besselj01(mm)*Res.Re();
				vmean[ibin][ivbin]+=v[ibin][itheta][ivbin];
				deltav[ibin][itheta][ivbin]=TMath::Cos(mm*nn*theta[itheta])/totmult[ibin][ivbin]*(TMath::Exp(j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Sin(nn*theta[itheta]/2.))+TMath::Power(-1,mm)*TMath::Exp(-j01*j01/2./(*chi[ibin])[0]/(*chi[ibin])[0]*TMath::Cos(nn*theta[itheta]))*TMath::BesselJ0(2*j01*TMath::Cos(nn*theta[itheta]/2.)));
				deltavmean[ibin][ivbin]+=deltav[ibin][itheta][ivbin];
			//	fstrv<<itheta<<"\t"<<v[ibin][itheta][ivbin]<<"\t"<<deltav[ibin][itheta][ivbin]<<endl;
			}
		deltavmean[ibin][ivbin]=TMath::Sqrt(deltavmean[ibin][ivbin])/2./Besselj01(mm);
		//fstrv<<endl;
		vmean[ibin][ivbin]/=ntheta;
		deltavmean[ibin][ivbin]/=TMath::Sqrt(ntheta);
		fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t"<<vmean[ibin][ivbin]<<"\t"<<deltavmean[ibin][ivbin]<<endl;
                if(ispt){
		if(binv[ivbin+1]>3.0) continue;
                totmulthisto[ibin][ivbin]=hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpt[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1);
//                totmulthistocorr[ibin][ivbin]=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin]),hpteffcorr[ibin]->GetXaxis()->FindBin(binv[ivbin+1])-1);
                totmulthistocorr[ibin][ivbin]=totmulthisto[ibin][ivbin]/hpteff->GetBinContent(hpteff->FindBin((binv[ivbin]+binv[ivbin+1])/2));
		V_int[ibin][isample]+=vmean[ibin][ivbin]*totmult[ibin][ivbin];
		V_interr[ibin][isample]+=deltavmean[ibin][ivbin]*totmult[ibin][ivbin];
		V_intcorr[ibin][isample]+=vmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
		V_intcorrerr[ibin][isample]+=deltavmean[ibin][ivbin]*totmulthistocorr[ibin][ivbin];
                }
		totmultall_[ibin][isample]+=totmult[ibin][ivbin];
		}
		V_int[ibin][isample]/=totmultall_[ibin][isample];
		V_interr[ibin][isample]/=totmultall_[ibin][isample];
		//V_intcorr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);
		//V_intcorr[ibin][isample]/=totmulthistocorr[ibin];
		//V_intcorrerr[ibin][isample]/=hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1);

                if(ispt){
        fstrv<<endl<<"pt range\t\t"<<"totmult"<<"\t\t"<<"totmult from histo"<<"\t"<<"totmult corrected"<<endl;
		for(int ivbin=0;ivbin<nvv; ivbin++){
                fstrv<<binv[ivbin]<<"-"<<binv[ivbin+1]<<"\t\t"<<totmult[ibin][ivbin]<<"\t"<<totmulthisto[ibin][ivbin]<<"\t"<<totmulthistocorr[ibin][ivbin]<<endl;
		}
		//fstrv<<"Integral\t\t"<<totmultall[ibin][isample]<<"\t"<<hpt[ibin]->Integral(hpt[ibin]->GetXaxis()->FindBin(binv[0]),hpt[ibin]->GetXaxis()->FindBin(3.0)-1)<<"\t"<<hpteffcorr[ibin]->Integral(hpteffcorr[ibin]->GetXaxis()->FindBin(binv[0]),hpteffcorr[ibin]->GetXaxis()->FindBin(3.0)-1)<<endl;
		fstrv<<"V ref="<<(*V_mean)[ibin]<<"\t"<<"V int="<<V_int[ibin][isample]<<"\t"<<"V int corr="<<V_intcorr[ibin][isample]<<endl;
		fstrv<<"V ref err="<<(*deltaV_mean)[ibin]<<"\t"<<"V int err="<<V_interr[ibin][isample]<<"\t"<<"V int corr err="<<V_intcorrerr[ibin][isample]<<endl;
                }
	TDirectory *dirsample = dir0->mkdir(Form("s_%d",isample));
        dirsample->cd();
	avgpt[ibin].Write("avgpt");
	avgeta[ibin].Write("avgeta");
	totmult[ibin].Write("totmult");
	vmean[ibin].Write("vmean");
	deltavmean[ibin].Write("deltavmean");
	for(int ivbin=0;ivbin<nvv; ivbin++){
		avgavgpt[ibin][ivbin]+=avgpt[ibin][ivbin]*Nevent[ibin][isample];
		avgavgeta[ibin][ivbin]+=avgeta[ibin][ivbin]*Nevent[ibin][isample];
		vmeanmean[ibin][ivbin]+=vmean[ibin][ivbin]/nsamples;
        	deltavmeanmean[ibin][ivbin]+=deltavmean[ibin][ivbin]/nsamples;
	        sigmavmeanmean[ibin][ivbin]+=TMath::Power(vmean[ibin][ivbin]/nsamples,2);
	}
	}//subsample loop
	dir0->cd();
        IFILE[ibin].Write("IFILE");
	V_int[ibin].Write("V_int");
	V_interr[ibin].Write("V_interr");
	V_intcorr[ibin].Write("V_intcorr");
	V_intcorrerr[ibin].Write("V_intcorrerr");
	Nevent[ibin].Write("Nevent");
	totmultall[ibin].Write("totmultall");
	for(int ivbin=0;ivbin<nvv; ivbin++){
		avgavgpt[ibin][ivbin]/=Nevent_[ibin];
		avgavgeta[ibin][ivbin]/=Nevent_[ibin];
        	sigmavmeanmean[ibin][ivbin]=TMath::Sqrt(sigmavmeanmean[ibin][ivbin]*nsamples-vmeanmean[ibin][ivbin]*vmeanmean[ibin][ivbin])/TMath::Sqrt(nsamples);
		}
	avgavgpt[ibin].Write("avgavgpt");
	avgavgeta[ibin].Write("avgavgeta");
        vmeanmean[ibin].Write("vmeanmean");
	deltavmeanmean[ibin].Write("deltavmeanmean");
        sigmavmeanmean[ibin].Write("sigmavmeanmean");
	}//ntrk bin loop
	infile->Close();
	fout->Close();
}