How to use MC Propagation

If you want to use MC Propagation for your data classes you first have to follow the description on Howto implement MC Propagation . After this you have to initialize your new data classes in the InitBranches method of the two tasks: PndMCMatchCreatorTask and PndMCMatchLoaderTask. This steps have to be done once for each new data class.

The base class which contains all the link informations is PndMCMatch. It is filled by the two Tasks: PndMCMatchCreatorTask and PndMCMatchLoaderTask

PndMCMatchCreatorTask runs through all initialized branches and extracts the stored FairLinks into the PndMCMatch class. After this the link information is stored in an individual branch so that it can be accessed without touching the original data. If this task is called in addition with other simulation tasks, it should be called as the last one, otherwise it will not contain the link information of the tasks coming after it. If you do not want to store the link data in the same root file as your data you should call PndMCMatchCreatorTask in an individual macro with a new output file name. You can work with this new file without loading the data files.

PndMCMatchLoaderTask reads in the links from a link root file or from a data file which contains a link branch. PndMCMatchLoaderTask is automatically called if you use the PndMCMatchCreatorTask.

After you have loaded the link information you can use either the GetMCInfo or the GetMCInfoSingle method of PndMCMatch to access the wanted link information:

PndMCResult GetMCInfo(TString start, TString stop) needs two parameters: the start branch from where you want to have your links and the stop branch where the links should point to. So if you want to know which MC track belongs to your reconstructed tracks start would be "PndTrack" and stop "MCTrack". The output is of type PndMCResult. Basically this is an array of FairLinks. The FairLinks are ordered in the same way as the start data. So if you want to know which MC tracks belong to your reconstructed track 2 you call GetEntry(2). Be careful: this can be more than one! So the output is a FairLink array which you can iterate by calling GetLink(index). These links come with a weight which tells you how much influence the link data had to your output. The weighting of links is quite complicated and will be covered in an own wiki page.

PndMCEntry GetMCInfoSingle(FairLink aLink, TString stop)has the same functionality as GetMCInfo. The only difference is that you start with an individual FairLink to a specific data object and you get only the FairLinks for this object. Let us take the same example like before: reconstructed track 2 -> MC tracks. Then your code would look like GetMCInfoSingle(FairLink(kTrack, 2), kMCTrack);.



void PndMCTestMomentumCompare::Exec(Option_t* opt)
   PndMCResult myResult = fMCMatch->GetMCInfo("PndTrack", "MCTrack");
   std::cout << myResult;
   for (int i = 0; i < myResult.GetNEntries(); i++){
      PndMCEntry myLinks = myResult.GetEntry(i);
      PndTrack* myTrack = (PndTrack*)fTrack->At(i);
      std::cout << "TrackMatch for Track " << i << std::endl;
      std::cout << "P: " << myTrack->GetParamFirst().GetSDMomentum().Mag() << std::endl;
      std::cout << "Belongs to: " << std::endl;
      for (int j = 0; j < myLinks.GetNLinks(); j++){
         if (myLinks.GetLink(j).GetType() == kMCTrack){
            std::cout << "MCTrack " << myLinks.GetLink(j).GetIndex() << std::endl;
            PndMCTrack* myMCTrack = (PndMCTrack*)fMCTrack->At(myLinks.GetLink(j).GetIndex());
            std::cout << "P: " << myMCTrack->GetMomentum().Mag() << " PID: " << myMCTrack->GetPdgCode() << std::endl;
            std::cout << "--------------------------------" << std::endl;
      std::cout << std::endl;