Ignore:
Timestamp:
Sep 2, 2011, 3:07:15 PM (13 years ago)
Author:
huonglan
Message:

sPlots_NewRel improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SPLOT/NEWREALEASE/MERGEFILES/MakeFakeData.C

    r21 r22  
    3939
    4040  TString s3 = "v3.root";
    41   TString ver = "ToTestEfficiency";
     41  TString ver = "v3";
    4242
    4343  //set the name of 78 files
     
    144144  //###################################
    145145
    146   TFile *fData    = new TFile("res_Data"+ver+".root","RECREATE");
     146  TFile *fData   = new TFile("res_FakeData"+ver+".root","RECREATE");
    147147  TTree *tWeiD   = new TTree("T","T");
    148   float b_weiD  = -100;
    149   float b_mtophad= -100;   
    150   float b_HT= -100;         
    151   float b_cos1= -100;       
    152   float b_cos2= -100;       
    153   float b_MinLep1= -100;   
    154   short b_hfor= -100;       
    155   short b_hasBadJet= -100; 
    156   short b_isEleEvent= -100;
    157   int b_RunNumber= -100; 
    158   tWeiD->Branch("wei",        &b_weiD,               "wei/F");
     148  float b_wei        = -100;
     149  float b_mtophad    = -100;   
     150  float b_HT         = -100;         
     151  float b_cos1       = -100;       
     152  float b_cos2       = -100;       
     153  float b_MinLep1    = -100;   
     154  short b_hfor       = -100;       
     155  short b_hasBadJet  = -100; 
     156  short b_isEleEvent = -100;
     157  int b_RunNumber    = -100; 
     158  tWeiD->Branch("wei",        &b_wei,                "wei/F");
    159159  tWeiD->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    160160  tWeiD->Branch("HT",         &b_HT,                  "HT/F");
     
    172172    countD++;
    173173    tData->GetEntry(ifi);
    174     b_mtophad = tSig->GetLeaf("mtophad")->GetValue();
    175     b_HT = tSig->GetLeaf("HT")->GetValue();
     174    b_mtophad = tData->GetLeaf("mtophad")->GetValue();
     175    b_HT      = tData->GetLeaf("HT")->GetValue();
    176176
    177177    //if (b_mtophad<250 || b_HT<620) continue;
    178     if (ifi%1000==0) cout << "Reading event " << ifi << " from Signal tree" << endl;
    179 
    180     //TString currentFile = tSig->GetTree()->GetCurrentFile()->GetName();
    181 
    182     b_weiS = Wei[0]*tSig->GetLeaf("WeiEvent")->GetValue();
    183     b_cos1 = tSig->GetLeaf("cos_tlepCMtpair")->GetValue();
    184     b_cos2 = tSig->GetLeaf("cosWqq")->GetValue();
    185     b_MinLep1 = tSig->GetLeaf("MinLep1")->GetValue();           
    186     b_hfor = (short)tSig->GetLeaf("hfor")->GetValue();
    187     b_isEleEvent = (short)tSig->GetLeaf("isEleEvent")->GetValue();
    188     b_hasBadJet = (short)tSig->GetLeaf("hasBadJet")->GetValue();
    189     b_RunNumber = (int)tSig->GetLeaf("RunNumber_ana")->GetValue();
    190 
    191     tWeiS->Fill();
    192   }
    193 
    194   fSig->cd();
    195   tWeiS->Write();
    196   fSig->Close();
    197 
     178    if (ifi%1000==0) cout << "Reading event " << ifi << " from Data tree" << endl;
     179
     180    TString currentFile = tData->GetTree()->GetCurrentFile()->GetName();
     181
     182    b_hfor       = (short)tData->GetLeaf("hfor")->GetValue();
     183    for (int i = 0; i < 78; i++){
     184      double kfac = 1, ksE = 1, ksM = 1;
     185      if (i>=2 && i<=32)  {kfac = 1.2; ksE = 0.906; ksM = 0.814;}//k factor for W+jets
     186      if (i>=40 && i<=69) {kfac = 1.25;}//Zjets
     187
     188      if (fname[i]==currentFile)
     189        b_wei = Wei[i]*(tData->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
     190    }
     191    b_cos1       = tData->GetLeaf("cos_tlepCMtpair")->GetValue();
     192    b_cos2       = tData->GetLeaf("cosWqq")->GetValue();
     193    b_MinLep1    = tData->GetLeaf("MinLep1")->GetValue();           
     194    b_hfor       = (short)tData->GetLeaf("hfor")->GetValue();
     195    b_isEleEvent = (short)tData->GetLeaf("isEleEvent")->GetValue();
     196    b_hasBadJet  = (short)tData->GetLeaf("hasBadJet")->GetValue();
     197    b_RunNumber  = (int)tData->GetLeaf("RunNumber_ana")->GetValue();
     198
     199    tWeiD->Fill();
     200  }
     201
     202  fData->cd();
     203  tWeiD->Write();
     204  fData->Close();
    198205
    199206  //###################################
     
    201208  //###################################
    202209
    203   TFile *fSig    = new TFile("res_Signal"+ver+".root","RECREATE");
     210  TFile *fSig    = new TFile("res_Signal"+s2[0]+ver+".root","RECREATE");
     211
    204212  TTree *tWeiS   = new TTree("T","T");
    205   float b_weiS  = -100;
    206   float b_mtophad= -100;   
    207   float b_HT= -100;         
    208   float b_cos1= -100;       
    209   float b_cos2= -100;       
    210   float b_MinLep1= -100;   
    211   short b_hfor= -100;       
    212   short b_hasBadJet= -100; 
    213   short b_isEleEvent= -100;
    214   int b_RunNumber= -100; 
    215   tWeiS->Branch("wei",        &b_weiS,               "wei/F");
     213  tWeiS->Branch("wei",        &b_wei,                "wei/F");
    216214  tWeiS->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    217215  tWeiS->Branch("HT",         &b_HT,                  "HT/F");
     
    230228    tSig->GetEntry(ifi);
    231229    b_mtophad = tSig->GetLeaf("mtophad")->GetValue();
    232     b_HT = tSig->GetLeaf("HT")->GetValue();
     230    b_HT      = tSig->GetLeaf("HT")->GetValue();
    233231
    234232    //if (b_mtophad<250 || b_HT<620) continue;
     
    237235    //TString currentFile = tSig->GetTree()->GetCurrentFile()->GetName();
    238236
    239     b_weiS = Wei[0]*tSig->GetLeaf("WeiEvent")->GetValue();
    240     b_cos1 = tSig->GetLeaf("cos_tlepCMtpair")->GetValue();
    241     b_cos2 = tSig->GetLeaf("cosWqq")->GetValue();
    242     b_MinLep1 = tSig->GetLeaf("MinLep1")->GetValue();           
    243     b_hfor = (short)tSig->GetLeaf("hfor")->GetValue();
     237    b_wei        = Wei[0]*tSig->GetLeaf("WeiEvent")->GetValue();
     238    b_cos1       = tSig->GetLeaf("cos_tlepCMtpair")->GetValue();
     239    b_cos2       = tSig->GetLeaf("cosWqq")->GetValue();
     240    b_MinLep1    = tSig->GetLeaf("MinLep1")->GetValue();           
     241    b_hfor       = (short)tSig->GetLeaf("hfor")->GetValue();
    244242    b_isEleEvent = (short)tSig->GetLeaf("isEleEvent")->GetValue();
    245     b_hasBadJet = (short)tSig->GetLeaf("hasBadJet")->GetValue();
    246     b_RunNumber = (int)tSig->GetLeaf("RunNumber_ana")->GetValue();
     243    b_hasBadJet  = (short)tSig->GetLeaf("hasBadJet")->GetValue();
     244    b_RunNumber  = (int)tSig->GetLeaf("RunNumber_ana")->GetValue();
    247245
    248246    tWeiS->Fill();
     
    271269
    272270  TTree *tWeiB   = new TTree("T","T");
    273   tWeiB->Branch("wei",        &b_weiS,               "wei/F");
     271  tWeiB->Branch("wei",        &b_wei,               "wei/F");
    274272  tWeiB->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    275273  tWeiB->Branch("HT",         &b_HT,                  "HT/F");
     
    303301
    304302      if (fname[i]==currentFile)
    305         b_weiS = Wei[i]*(tAllBkg->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
     303        b_wei = Wei[i]*(tAllBkg->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
    306304    }
    307305    b_cos1       = tAllBkg->GetLeaf("cos_tlepCMtpair")->GetValue();
     
    337335
    338336  TTree *tWeiT   = new TTree("T","T");
    339   tWeiT->Branch("wei",        &b_weiS,               "wei/F");
     337  tWeiT->Branch("wei",        &b_wei,               "wei/F");
    340338  tWeiT->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    341339  tWeiT->Branch("HT",         &b_HT,                  "HT/F");
     
    364362    for (int i = 0; i < 78; i++){
    365363      if (fname[i]==currentFile)
    366         b_weiS = Wei[i]*(tTop->GetLeaf("WeiEvent")->GetValue());
     364        b_wei = Wei[i]*(tTop->GetLeaf("WeiEvent")->GetValue());
    367365    }
    368366    b_cos1       = tTop->GetLeaf("cos_tlepCMtpair")->GetValue();
     
    386384
    387385  TTree *tWeiW   = new TTree("T","T");
    388   tWeiW->Branch("wei",        &b_weiS,               "wei/F");
     386  tWeiW->Branch("wei",        &b_wei,               "wei/F");
    389387  tWeiW->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    390388  tWeiW->Branch("HT",         &b_HT,                  "HT/F");
     
    417415
    418416      if (fname[i]==currentFile)
    419         b_weiS = Wei[i]*(tAllW->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
     417        b_wei = Wei[i]*(tAllW->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
    420418    }
    421419    b_cos1       = tAllW->GetLeaf("cos_tlepCMtpair")->GetValue();
     
    435433  //*********** File Single Top  *****************
    436434  //##############################################
    437   TFile *fSingT   = new TFile("res_SingleTop"+ver+".root","RECREATE");
     435  TFile *fSingT   = new TFile("res_SingT"+ver+".root","RECREATE");
    438436
    439437  TTree *tWeiST   = new TTree("T","T");
    440   tWeiST->Branch("wei",        &b_weiS,               "wei/F");
     438  tWeiST->Branch("wei",        &b_wei,               "wei/F");
    441439  tWeiST->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    442440  tWeiST->Branch("HT",         &b_HT,                  "HT/F");
     
    465463    for (int i = 0; i < 78; i++){
    466464      if (fname[i]==currentFile)
    467         b_weiS = Wei[i]*(tSingT->GetLeaf("WeiEvent")->GetValue());
     465        b_wei = Wei[i]*(tSingT->GetLeaf("WeiEvent")->GetValue());
    468466    }
    469467    b_hfor       = (short)tSingT->GetLeaf("hfor")->GetValue();
     
    487485
    488486  TTree *tWeiZ   = new TTree("T","T");
    489   tWeiZ->Branch("wei",        &b_weiS,               "wei/F");
     487  tWeiZ->Branch("wei",        &b_wei,               "wei/F");
    490488  tWeiZ->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    491489  tWeiZ->Branch("HT",         &b_HT,                  "HT/F");
     
    518516
    519517      if (fname[i]==currentFile)
    520         b_weiS = Wei[i]*(tAllZ->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
     518        b_wei = Wei[i]*(tAllZ->GetLeaf("WeiEvent")->GetValue())*WJet_SF(b_hfor)*kfac*ksE*ksM;
    521519    }
    522520    b_cos1       = tAllZ->GetLeaf("cos_tlepCMtpair")->GetValue();
     
    539537
    540538  TTree *tWeiQCD   = new TTree("T","T");
    541   tWeiQCD->Branch("wei",        &b_weiS,               "wei/F");
     539  tWeiQCD->Branch("wei",        &b_wei,               "wei/F");
    542540  tWeiQCD->Branch("mtophad",    &b_mtophad,        "mtophad/F");
    543541  tWeiQCD->Branch("HT",         &b_HT,                  "HT/F");
     
    566564    for (int i = 0; i < 78; i++){
    567565      if (fname[i]==currentFile)
    568         b_weiS = Wei[i]*(tQCD->GetLeaf("WeiEvent")->GetValue());
     566        b_wei = Wei[i]*(tQCD->GetLeaf("WeiEvent")->GetValue());
    569567    }
    570568    b_cos1       = tQCD->GetLeaf("cos_tlepCMtpair")->GetValue();
Note: See TracChangeset for help on using the changeset viewer.