test_Ids.C 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Do not forget to source setPicoDst.sh script
  2. void test_Ids(TString infile)
  3. {
  4. TStopwatch timer;
  5. timer.Start();
  6. TFile *fi = new TFile(infile.Data(),"read");
  7. TTree *tree = (TTree*) fi->Get("picodst");
  8. TClonesArray *recoTracks = nullptr;
  9. TClonesArray *mcTracks = nullptr;
  10. tree->SetBranchAddress("mctracks",&mcTracks);
  11. tree->SetBranchAddress("recotracks",&recoTracks);
  12. bool is_success = true;
  13. int n_entries = tree->GetEntriesFast();
  14. for (int iEv=0; iEv<n_entries; iEv++)
  15. {
  16. tree->GetEntry(iEv);
  17. std::cout << "Event [" << iEv << "/" << n_entries << "]\r" << std::flush;
  18. for (int i=0; i<recoTracks->GetEntriesFast(); i++)
  19. {
  20. auto recoTrack = (PicoDstRecoTrack*) recoTracks->UncheckedAt(i);
  21. auto mcTrack = (PicoDstMCTrack*) mcTracks->UncheckedAt(recoTrack->GetMcId());
  22. if (recoTrack->GetInitialMcId() != mcTrack->GetInitialId())
  23. {
  24. is_success = false;
  25. std::cout << "[WARNING] Event " << iEv << ", recotrack " << i << ": InitMcId(reco)= " << recoTrack->GetInitialMcId() << ", InitMcId(mc)= " << mcTrack->GetInitialId() << ", McId= " << recoTrack->GetMcId() << std::endl;
  26. }
  27. }
  28. }
  29. std::cout << "Total number of events: " << n_entries << std::endl;
  30. if (is_success)
  31. std::cout << "SUCCESS: MC and RECO tracks are linked correctly." << std::endl;
  32. if (!is_success)
  33. std::cout << "FAILED." << std::endl;
  34. timer.Stop();
  35. timer.Print();
  36. }