Changeset 467 in svn for trunk/Resolutions_ATLAS.cpp
- Timestamp:
- Jul 10, 2009, 5:57:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.