Changeset 467 in svn
- Timestamp:
- Jul 10, 2009, 5:57:55 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGELOG
r466 r467 7 7 - it is now possible to read "delphes root files" as an input for Delphes (GEN tree) 8 8 - bug fix: number of events to process is correct event if multiple files in the inputlist 9 - updates in Resolution.cpp & Resolution_ATLAS.cpp 9 10 10 11 /-----------------------------------------\ -
trunk/Resolutions.cpp
r458 r467 38 38 #include "TApplication.h" 39 39 #include "TFile.h" 40 #include "TStopwatch.h" 40 41 41 42 #include "ExRootTreeReader.h" 42 43 #include "ExRootTreeWriter.h" 43 44 #include "ExRootTreeBranch.h" 45 #include "ExRootProgressBar.h" 44 46 #include "TreeClasses.h" 45 47 … … 189 191 { 190 192 int appargc = 2; 191 char *appName = "Resolution"; 192 char *appargv[] = {appName, "-b"}; 193 char *appName= new char[20]; 194 char *appOpt= new char[20]; 195 sprintf(appName,"Resolution_ATLAS"); 196 sprintf(appOpt,"-b"); 197 char *appargv[] = {appName,appOpt}; 193 198 TApplication app(appName, &appargc, appargv); 194 199 delete [] appName; 200 delete [] appOpt; 201 195 202 if(argc != 3) { 196 203 cout << " Usage: " << argv[0] << " input_file" << " output_file" << endl; 197 cout << " input_ list - list of files inroot format," << endl;204 cout << " input_file - input file in Delphes-root format," << endl; 198 205 cout << " output_file - output file." << endl; 199 206 exit(1); 200 207 } 201 208 202 srand (time (NULL)); /* Initialisation du générateur */ 203 204 //read the input TROOT file 209 210 // 1. ********** initialisation *********** 211 212 srand (time (NULL)); 213 TStopwatch globalwatch; 214 globalwatch.Start(); 215 205 216 string inputfilename(argv[1]), outputfilename(argv[2]); 206 217 218 // 1.1 checks the input file 219 if(inputfilename.find(".root") > inputfilename.length() ) { 220 cout << "input_file should be a .root file from Delphes!\n"; 221 return -1; 222 } 223 TFile f(inputfilename.c_str()); 224 if (!f.FindKey("GEN") || !f.FindKey("Analysis") ) { 225 cout << "input_file should be a .root file from Delphes!\n"; 226 cout << "it should contain both \"GEN\" and \"Analysis\" trees at least.\n"; 227 return -1; 228 } 229 f.Close(); 230 231 // 1.2 checks the output file 207 232 if(outputfilename.find(".root") > outputfilename.length() ) { 208 233 cout << "output_file should be a .root file!\n"; 209 234 return -1; 210 235 } 211 212 213 214 236 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after 215 237 outputFile->Close(); 216 238 239 // 1.3 Reads the trees in input file 217 240 TChain chainGEN("GEN"); 218 241 chainGEN.Add(inputfilename.c_str()); … … 229 252 TIter itGen((TCollection*)branchGen); 230 253 231 //write the output root file 254 255 // 1.4 Prepares the output root file 232 256 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis"); 233 257 ExRootTreeBranch *branchjet = treeWriter->NewBranch("JetPTResol", RESOLJET::Class()); … … 236 260 ExRootTreeBranch *branchtaujet = treeWriter->NewBranch("TauJetPTResol", TAUHAD::Class()); 237 261 ExRootTreeBranch *branchetmis = treeWriter->NewBranch("ETmisResol",ETMIS::Class()); 238 262 263 // 1.5 other initialisations 239 264 TRootGenParticle *particle; 240 241 265 RESOLELEC * elementElec; 242 266 RESOLMUON *elementMuon; … … 245 269 ETMIS *elementEtmis; 246 270 247 int numTau=0; 248 int numTauRec=0; 271 int numTau=0, numTauRec=0; 249 272 250 273 RESOLution *DET = new RESOLution(); 274 /* 275 string detectorcard = "data/DetectorCard_CMS.dat"; 276 const float dR_jetpairing = 0.25; 277 const float jet_pt_cut = 1; 278 */ 251 279 DET->ReadDataCard("data/DetectorCard_CMS.dat"); 252 280 253 281 254 //Jet information255 282 JetsUtil *JETRUN = new JetsUtil("data/DetectorCard_CMS.dat"); 256 283 257 TLorentzVector genMomentum(0,0,0,0); //TLorentzVector containinggenerator level information258 TLorentzVector recoMomentum(0,0,0,0);// TLorentzVector containing generatorlevel information284 TLorentzVector genMomentum(0,0,0,0); //generator level information 285 TLorentzVector recoMomentum(0,0,0,0);//reconstructed level information 259 286 LorentzVector jetMomentum; 260 287 261 288 vector<fastjet::PseudoJet> input_particlesGEN;//for FastJet algorithm 262 289 vector<fastjet::PseudoJet> sorted_jetsGEN; 263 264 290 vector<int> NTrackJet; 265 266 291 vector<TLorentzVector> towers; 267 292 268 // Loop over all events293 // 2. Loop over all events 269 294 Long64_t entry, allEntries = treeReader->GetEntries(); 270 cout << "** Chain contains " << allEntries << " events" << endl; 295 cout << endl << endl; 296 cout <<"*********************************************************************"<< endl; 297 cout <<"** **"<< endl; 298 cout <<"** **"<< endl; 299 cout <<"** **"<< endl; 300 cout <<"** ####### Start resolution processing ######## **"<< endl; 301 cout << left << setw(52) <<"** Total number of events to run: "<<"" 302 << left << setw(15) << allEntries <<"" 303 << right << setw(2) <<"**"<<endl; 304 305 ExRootProgressBar *Progress = new ExRootProgressBar(allEntries); 306 271 307 for(entry = 0; entry < allEntries; ++entry) 272 308 { 309 Progress->Update(entry); 273 310 TLorentzVector PTmisReco(0,0,0,0); 274 311 TLorentzVector PTmisGEN(0,0,0,0); … … 276 313 treeReaderGEN->ReadEntry(entry); 277 314 treeWriter->Clear(); 278 if((entry % 100) == 0 && entry > 0 ) cout << "** Processing element # " << entry << endl;279 315 280 316 TSimpleArray<TRootGenParticle> bGen; … … 301 337 //Calculate ETMIS from generated particles 302 338 if((pid == pNU1) || (pid == pNU2) || (pid == pNU3))PTmisGEN = PTmisGEN + genMomentum; 303 339 340 //Electrons and muons 304 341 if( (particle->Status == 1) && 305 342 ((pid != pNU1) && (pid != pNU2) && (pid != pNU3)) && … … 320 357 case pMU: // all muons with eta < DET->MAX_MU 321 358 PairingMuon(recoMomentum,genMomentum,branchMuon); 322 if(recoMomentum.E() 359 if(recoMomentum.E()!=0){ 323 360 elementMuon = (RESOLMUON*) branchmuon->NewEntry(); 324 elementMuon->OverPT = (1/genMomentum.Pt());325 elementMuon->OverSmearedPT = (1/recoMomentum.Pt());}361 elementMuon->OverPT = 1./genMomentum.Pt(); 362 elementMuon->OverSmearedPT = 1./recoMomentum.Pt();} 326 363 break; // case pMU 327 364 default: … … 354 391 elementEtmis->Ex = (-PTmisGEN).Px(); 355 392 elementEtmis->SEt = ScalarEt; 356 357 393 elementEtmis->EtSmeare = (PTmisReco).Pt()-(PTmisGEN).Pt(); 358 394 elementEtmis->ExSmeare = (-PTmisReco).Px()-(PTmisGEN).Px(); … … 362 398 363 399 TSimpleArray<TRootGenParticle> TausHadr = TauHadr(branchGen); 364 365 400 TLorentzVector JETreco(0,0,0,0); 366 401 for (unsigned int i = 0; i < sorted_jetsGEN.size(); i++) { … … 372 407 elementJet= (RESOLJET*) branchjet->NewEntry(); 373 408 elementJet->PT = JETgen.Et(); 374 elementJet->SmearedPT = JETreco.Et()/JETgen.Et(); 409 elementJet->SmearedPT = JETreco.Et()/JETgen.Et(); //// la difference pourrait être ici 375 410 } 376 411 } 377 numTau = numTau+TausHadr.GetEntries();412 numTau += TausHadr.GetEntries(); 378 413 379 414 TIter itJet((TCollection*)branchJet); … … 391 426 { 392 427 elementTaujet= (TAUHAD*) branchtaujet->NewEntry(); 393 elementTaujet->EnergieCen = (EnergySmallCone(towers,JETT.Eta(),JETT.Phi(),DET->TAU_energy_scone,DET->JET_seed)/JETT.E());428 elementTaujet->EnergieCen = EnergySmallCone(towers,JETT.Eta(),JETT.Phi(),DET->TAU_energy_scone,DET->JET_seed)/JETT.E(); 394 429 elementTaujet->NumTrack = NumTracks(branchTracks,DET->TAU_track_pt,JETT.Eta(),JETT.Phi(),DET->TAU_track_scone); 395 430 if( (EnergySmallCone(towers,JETT.Eta(),JETT.Phi(),DET->TAU_energy_scone,DET->JET_seed)/JETT.E()) > 0.95 … … 401 436 402 437 } // for itJet : loop on all jets 403 //cout<<"i"<<endl;404 438 405 439 treeWriter->Fill(); 406 440 } // Loop over all events 407 441 treeWriter->Write(); 408 float frac = numTauRec/numTau; 409 cout<<numTauRec<<endl; 410 cout<<numTau<<endl; 411 412 cout << "** Exiting..." << endl; 413 cout<<frac<<endl; 442 globalwatch.Stop(); 443 444 445 // Screen output 446 cout <<"** **"<< endl; 447 cout <<"** **"<< endl; 448 cout <<"** ################## Time report ################# **"<< endl; 449 cout << left << setw(32) <<"** Time report for "<<"" 450 << left << setw(15) << allEntries <<"" 451 << right << setw(22) <<"events **"<<endl; 452 cout <<"** **"<< endl; 453 cout << left << setw(10) <<"**"<<"" 454 << left << setw(15) <<"Time (s):"<<"" 455 << right << setw(15) <<"CPU"<<"" 456 << right << setw(15) <<"Real"<<"" 457 << right << setw(14) <<"**"<<endl; 458 cout << left << setw(10) <<"**"<<"" 459 << left << setw(15) <<" + Global:"<<"" 460 << right << setw(15) <<globalwatch.CpuTime()<<"" 461 << right << setw(15) <<globalwatch.RealTime()<<"" 462 << right << setw(14) <<"**"<<endl; 463 464 465 string tempstring = detectorcard + " has been used."; 466 cout <<"** ################## Configuration ############### **"<< endl; 467 cout << left << setw(16) << "** " << "" 468 << left << setw(51) << tempstring << "**" << endl; 469 470 tempstring = outputfilename + " has been created."; 471 cout << left << setw(16) << "** " << "" 472 << left << setw(51) << tempstring << "**" << endl; 473 474 cout << left << setw(16) << "** " << "" 475 << left << setw(51) << get_time_date() << "**" << endl; 476 477 478 cout <<"** **"<< endl; 479 cout <<"** Exiting ... **"<< endl; 480 cout <<"** **"<< endl; 481 cout <<"** **"<< endl; 482 cout <<"*********************************************************************"<< endl; 483 414 484 415 485 -
trunk/Resolutions_ATLAS.cpp
r458 r467 38 38 #include "TApplication.h" 39 39 #include "TFile.h" 40 #include "TStopwatch.h" 40 41 41 42 #include "ExRootTreeReader.h" 42 43 #include "ExRootTreeWriter.h" 43 44 #include "ExRootTreeBranch.h" 45 #include "ExRootProgressBar.h" 44 46 #include "TreeClasses.h" 45 47 … … 189 191 { 190 192 int appargc = 2; 191 char *appName = "Resolution"; 192 char *appargv[] = {appName, "-b"}; 193 char *appName= new char[20]; 194 char *appOpt= new char[20]; 195 sprintf(appName,"Resolution_ATLAS"); 196 sprintf(appOpt,"-b"); 197 char *appargv[] = {appName,appOpt}; 193 198 TApplication app(appName, &appargc, appargv); 194 199 delete [] appName; 200 delete [] appOpt; 201 195 202 if(argc != 3) { 196 203 cout << " Usage: " << argv[0] << " input_file" << " output_file" << endl; … … 200 207 } 201 208 202 srand (time (NULL)); /* Initialisation du générateur */ 209 210 // 1. ********** initialisation *********** 211 212 srand (time (NULL)); 213 TStopwatch globalwatch; 214 globalwatch.Start(); 203 215 204 //read the input TROOT file205 216 string inputfilename(argv[1]), outputfilename(argv[2]); 206 217 218 // 1.1 checks the input file 219 if(inputfilename.find(".root") > inputfilename.length() ) { 220 cout << "input_file should be a .root file from Delphes!\n"; 221 return -1; 222 } 223 TFile f(inputfilename.c_str()); 224 if (!f.FindKey("GEN") || !f.FindKey("Analysis") ) { 225 cout << "input_file should be a .root file from Delphes!\n"; 226 cout << "it should contain both \"GEN\" and \"Analysis\" trees at least.\n"; 227 return -1; 228 } 229 f.Close(); 230 231 // 1.2 checks the output file 207 232 if(outputfilename.find(".root") > outputfilename.length() ) { 208 233 cout << "output_file should be a .root file!\n"; 209 234 return -1; 210 235 } 211 212 213 214 236 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE");// Creates the file, but should be closed just after 215 237 outputFile->Close(); 216 238 239 // 1.3 Reads the trees in input file 217 240 TChain chainGEN("GEN"); 218 241 chainGEN.Add(inputfilename.c_str()); … … 228 251 const TClonesArray *branchGen = treeReaderGEN->UseBranch("Particle"); 229 252 TIter itGen((TCollection*)branchGen); 230 231 //write the output root file 253 254 255 // 1.4 Prepares the output root file 232 256 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis"); 233 257 ExRootTreeBranch *branchjet = treeWriter->NewBranch("JetPTResol", RESOLJET::Class()); … … 236 260 ExRootTreeBranch *branchtaujet = treeWriter->NewBranch("TauJetPTResol", TAUHAD::Class()); 237 261 ExRootTreeBranch *branchetmis = treeWriter->NewBranch("ETmisResol",ETMIS::Class()); 238 262 263 // 1.5 other initialisations 239 264 TRootGenParticle *particle; 240 241 265 RESOLELEC * elementElec; 242 266 RESOLMUON *elementMuon; … … 245 269 ETMIS *elementEtmis; 246 270 247 int numTau=0; 248 int numTauRec=0; 271 int numTau=0, numTauRec=0; 249 272 250 273 RESOLution *DET = new RESOLution(); … … 259 282 DET->ReadDataCard(detectorcard); 260 283 261 262 //Jet information263 284 JetsUtil *JETRUN = new JetsUtil(detectorcard); 264 285 265 TLorentzVector genMomentum(0,0,0,0); //TLorentzVector containinggenerator level information266 TLorentzVector recoMomentum(0,0,0,0);// TLorentzVector containing generatorlevel information286 TLorentzVector genMomentum(0,0,0,0); // generator level information 287 TLorentzVector recoMomentum(0,0,0,0);// reconstruction level information 267 288 LorentzVector jetMomentum; 268 289 … … 272 293 vector<TLorentzVector> towers; 273 294 274 // Loop over all events295 // 2. Loop over all events 275 296 Long64_t entry, allEntries = treeReader->GetEntries(); 276 cout << "** Chain contains " << allEntries << " events" << endl; 297 cout << endl << endl; 298 cout <<"*********************************************************************"<< endl; 299 cout <<"** **"<< endl; 300 cout <<"** **"<< endl; 301 cout <<"** **"<< endl; 302 cout <<"** ####### Start resolution processing ######## **"<< endl; 303 cout << left << setw(52) <<"** Total number of events to run: "<<"" 304 << left << setw(15) << allEntries <<"" 305 << right << setw(2) <<"**"<<endl; 306 307 ExRootProgressBar *Progress = new ExRootProgressBar(allEntries); 308 277 309 for(entry = 0; entry < allEntries; ++entry) 278 310 { 311 Progress->Update(entry); 279 312 TLorentzVector PTmisReco(0,0,0,0); 280 313 TLorentzVector PTmisGEN(0,0,0,0); … … 282 315 treeReaderGEN->ReadEntry(entry); 283 316 treeWriter->Clear(); 284 if((entry % 100) == 0 && entry > 0 ) cout << "** Processing element # " << entry << endl;285 317 286 318 TSimpleArray<TRootGenParticle> bGen; … … 372 404 TLorentzVector JETgen(0,0,0,0); 373 405 JETgen.SetPxPyPzE(sorted_jetsGEN[i].px(),sorted_jetsGEN[i].py(),sorted_jetsGEN[i].pz(),sorted_jetsGEN[i].E()); 374 PairingJet(JETreco,JETgen,branchJet );406 PairingJet(JETreco,JETgen,branchJet,dR_jetpairing); 375 407 if(JETreco.Pt()>jet_pt_cut) 376 408 { … … 383 415 } 384 416 } 385 numTau = numTau+TausHadr.GetEntries();417 numTau += TausHadr.GetEntries(); 386 418 387 419 TIter itJet((TCollection*)branchJet); … … 413 445 } // Loop over all events 414 446 treeWriter->Write(); 415 416 cout << detectorcard << " has been used.\n"; 417 cout << "** Exiting..." << endl; 447 globalwatch.Stop(); 448 449 450 // Screen output 451 cout <<"** **"<< endl; 452 cout <<"** **"<< endl; 453 cout <<"** ################## Time report ################# **"<< endl; 454 cout << left << setw(32) <<"** Time report for "<<"" 455 << left << setw(15) << allEntries <<"" 456 << right << setw(22) <<"events **"<<endl; 457 cout <<"** **"<< endl; 458 cout << left << setw(10) <<"**"<<"" 459 << left << setw(15) <<"Time (s):"<<"" 460 << right << setw(15) <<"CPU"<<"" 461 << right << setw(15) <<"Real"<<"" 462 << right << setw(14) <<"**"<<endl; 463 cout << left << setw(10) <<"**"<<"" 464 << left << setw(15) <<" + Global:"<<"" 465 << right << setw(15) <<globalwatch.CpuTime()<<"" 466 << right << setw(15) <<globalwatch.RealTime()<<"" 467 << right << setw(14) <<"**"<<endl; 468 469 470 string tempstring = detectorcard + " has been used."; 471 cout <<"** ################## Configuration ############### **"<< endl; 472 cout << left << setw(16) << "** " << "" 473 << left << setw(51) << tempstring << "**" << endl; 474 475 tempstring = outputfilename + " has been created."; 476 cout << left << setw(16) << "** " << "" 477 << left << setw(51) << tempstring << "**" << endl; 478 479 cout << left << setw(16) << "** " << "" 480 << left << setw(51) << get_time_date() << "**" << endl; 481 482 cout <<"** **"<< endl; 483 cout <<"** Exiting ... **"<< endl; 484 cout <<"** **"<< endl; 485 cout <<"** **"<< endl; 486 cout <<"*********************************************************************"<< endl; 487 418 488 419 489 delete treeWriter; … … 422 492 } 423 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
Note:
See TracChangeset
for help on using the changeset viewer.