Changeset 22 in huonglan for SPLOT/NEWREALEASE/MERGEFILES/MakeFakeData.C
- Timestamp:
- Sep 2, 2011, 3:07:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SPLOT/NEWREALEASE/MERGEFILES/MakeFakeData.C
r21 r22 39 39 40 40 TString s3 = "v3.root"; 41 TString ver = " ToTestEfficiency";41 TString ver = "v3"; 42 42 43 43 //set the name of 78 files … … 144 144 //################################### 145 145 146 TFile *fData = new TFile("res_Data"+ver+".root","RECREATE");146 TFile *fData = new TFile("res_FakeData"+ver+".root","RECREATE"); 147 147 TTree *tWeiD = new TTree("T","T"); 148 float b_wei D= -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 D,"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"); 159 159 tWeiD->Branch("mtophad", &b_mtophad, "mtophad/F"); 160 160 tWeiD->Branch("HT", &b_HT, "HT/F"); … … 172 172 countD++; 173 173 tData->GetEntry(ifi); 174 b_mtophad = t Sig->GetLeaf("mtophad")->GetValue();175 b_HT = tSig->GetLeaf("HT")->GetValue();174 b_mtophad = tData->GetLeaf("mtophad")->GetValue(); 175 b_HT = tData->GetLeaf("HT")->GetValue(); 176 176 177 177 //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(); 198 205 199 206 //################################### … … 201 208 //################################### 202 209 203 TFile *fSig = new TFile("res_Signal"+ver+".root","RECREATE"); 210 TFile *fSig = new TFile("res_Signal"+s2[0]+ver+".root","RECREATE"); 211 204 212 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"); 216 214 tWeiS->Branch("mtophad", &b_mtophad, "mtophad/F"); 217 215 tWeiS->Branch("HT", &b_HT, "HT/F"); … … 230 228 tSig->GetEntry(ifi); 231 229 b_mtophad = tSig->GetLeaf("mtophad")->GetValue(); 232 b_HT = tSig->GetLeaf("HT")->GetValue();230 b_HT = tSig->GetLeaf("HT")->GetValue(); 233 231 234 232 //if (b_mtophad<250 || b_HT<620) continue; … … 237 235 //TString currentFile = tSig->GetTree()->GetCurrentFile()->GetName(); 238 236 239 b_wei S= 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(); 244 242 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(); 247 245 248 246 tWeiS->Fill(); … … 271 269 272 270 TTree *tWeiB = new TTree("T","T"); 273 tWeiB->Branch("wei", &b_wei S, "wei/F");271 tWeiB->Branch("wei", &b_wei, "wei/F"); 274 272 tWeiB->Branch("mtophad", &b_mtophad, "mtophad/F"); 275 273 tWeiB->Branch("HT", &b_HT, "HT/F"); … … 303 301 304 302 if (fname[i]==currentFile) 305 b_wei S= 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; 306 304 } 307 305 b_cos1 = tAllBkg->GetLeaf("cos_tlepCMtpair")->GetValue(); … … 337 335 338 336 TTree *tWeiT = new TTree("T","T"); 339 tWeiT->Branch("wei", &b_wei S, "wei/F");337 tWeiT->Branch("wei", &b_wei, "wei/F"); 340 338 tWeiT->Branch("mtophad", &b_mtophad, "mtophad/F"); 341 339 tWeiT->Branch("HT", &b_HT, "HT/F"); … … 364 362 for (int i = 0; i < 78; i++){ 365 363 if (fname[i]==currentFile) 366 b_wei S= Wei[i]*(tTop->GetLeaf("WeiEvent")->GetValue());364 b_wei = Wei[i]*(tTop->GetLeaf("WeiEvent")->GetValue()); 367 365 } 368 366 b_cos1 = tTop->GetLeaf("cos_tlepCMtpair")->GetValue(); … … 386 384 387 385 TTree *tWeiW = new TTree("T","T"); 388 tWeiW->Branch("wei", &b_wei S, "wei/F");386 tWeiW->Branch("wei", &b_wei, "wei/F"); 389 387 tWeiW->Branch("mtophad", &b_mtophad, "mtophad/F"); 390 388 tWeiW->Branch("HT", &b_HT, "HT/F"); … … 417 415 418 416 if (fname[i]==currentFile) 419 b_wei S= 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; 420 418 } 421 419 b_cos1 = tAllW->GetLeaf("cos_tlepCMtpair")->GetValue(); … … 435 433 //*********** File Single Top ***************** 436 434 //############################################## 437 TFile *fSingT = new TFile("res_Sing leTop"+ver+".root","RECREATE");435 TFile *fSingT = new TFile("res_SingT"+ver+".root","RECREATE"); 438 436 439 437 TTree *tWeiST = new TTree("T","T"); 440 tWeiST->Branch("wei", &b_wei S, "wei/F");438 tWeiST->Branch("wei", &b_wei, "wei/F"); 441 439 tWeiST->Branch("mtophad", &b_mtophad, "mtophad/F"); 442 440 tWeiST->Branch("HT", &b_HT, "HT/F"); … … 465 463 for (int i = 0; i < 78; i++){ 466 464 if (fname[i]==currentFile) 467 b_wei S= Wei[i]*(tSingT->GetLeaf("WeiEvent")->GetValue());465 b_wei = Wei[i]*(tSingT->GetLeaf("WeiEvent")->GetValue()); 468 466 } 469 467 b_hfor = (short)tSingT->GetLeaf("hfor")->GetValue(); … … 487 485 488 486 TTree *tWeiZ = new TTree("T","T"); 489 tWeiZ->Branch("wei", &b_wei S, "wei/F");487 tWeiZ->Branch("wei", &b_wei, "wei/F"); 490 488 tWeiZ->Branch("mtophad", &b_mtophad, "mtophad/F"); 491 489 tWeiZ->Branch("HT", &b_HT, "HT/F"); … … 518 516 519 517 if (fname[i]==currentFile) 520 b_wei S= 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; 521 519 } 522 520 b_cos1 = tAllZ->GetLeaf("cos_tlepCMtpair")->GetValue(); … … 539 537 540 538 TTree *tWeiQCD = new TTree("T","T"); 541 tWeiQCD->Branch("wei", &b_wei S, "wei/F");539 tWeiQCD->Branch("wei", &b_wei, "wei/F"); 542 540 tWeiQCD->Branch("mtophad", &b_mtophad, "mtophad/F"); 543 541 tWeiQCD->Branch("HT", &b_HT, "HT/F"); … … 566 564 for (int i = 0; i < 78; i++){ 567 565 if (fname[i]==currentFile) 568 b_wei S= Wei[i]*(tQCD->GetLeaf("WeiEvent")->GetValue());566 b_wei = Wei[i]*(tQCD->GetLeaf("WeiEvent")->GetValue()); 569 567 } 570 568 b_cos1 = tQCD->GetLeaf("cos_tlepCMtpair")->GetValue();
Note: See TracChangeset
for help on using the changeset viewer.