GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » General » Access to MC information after the digitization stage
Re: Access to MC information after the digitization stage [message #18409 is a reply to message #18400] Tue, 11 August 2015 15:47 Go to previous messageGo to previous message
Dominik Steinschaden is currently offline  Dominik Steinschaden
Messages: 28
Registered: April 2015
continuous participant
From: *smi.oeaw.ac.at
Meanwhile I solved my problem accessing the data and linking the MC data.
I don't know if someone else may have similar troubles with the FairLinks so i post my solutions. Maybe someone can make use out of it.

Attached and on the end of the Post you find a basic root macro which gives access to the sorted data in the digitization output and also to the linked simulation and MC output.
(For a solution using the Pandaroot classes look at the following post)

This macro does not make use out of special Panda or FairRoot classes, but mostly uses basic root commands. Therefore one has more direct access to the data but on the other side loose some comfort.

to use the Fairlinks it is important that already in the simulation stage and all ongoing data processing stages "fRun->SetUseFairLinks(kTRUE);" is set!


void link_basic_1(){

  TString InputSimFile ="data_sim/sim_s_gc_G4_6.root";
  TString InputDigFile ="data_digi/digi_s_gc_G4_6_1000.root";

  TFile *simFile = TFile::Open(InputSimFile); 
  TTree *simTree = (TTree*) simFile->Get("cbmsim");

  TFile *digFile = TFile::Open(InputDigFile); 
  TTree *digTree = (TTree*) digFile->Get("cbmsim");

  FairMCEventHeader* simEvHeader = NULL;
  FairEventHeader* digEvHeader = NULL;

  TClonesArray* mcTrackArray = new TClonesArray("PndMCTrack");
  TClonesArray* scitPointArray = new TClonesArray("PndSciTPoint");
  TClonesArray* scitHitArray = new TClonesArray("PndSciTHit");

  TBranch* mcTrackBranch = (TBranch*) simTree->GetBranch("MCTrack");
  TBranch* scitPointBranch = (TBranch*) simTree->GetBranch("SciTPoint");
  TBranch* scitHitBranch = (TBranch*) digTree->GetBranch("SciTSortedHit");

  simTree->SetBranchAddress("MCTrack",&mcTrackArray);
  simTree->SetBranchAddress("SciTPoint",&scitPointArray);
  simTree->SetBranchAddress("MCEventHeader.",&simEvHeader);

  digTree->SetBranchAddress("SciTSortedHit",&scitHitArray);
  digTree->SetBranchAddress("EventHeader.",&digEvHeader);


  PndMCTrack* mcTrack = NULL;
  PndSciTPoint* scitPoint = NULL;
  PndSciTHit* scitHit = NULL;


  for (Int_t i_Event=0; i_Event<scitHitBranch->GetEntries();i_Event++){ // ----- loop oveer digitized events ---
    
   scitHitBranch->GetEntry(i_Event);

    for (Int_t i_hitArray=0; i_hitArray < scitHitArray->GetEntries() ;i_hitArray++){     
      scitHit = (PndSciTHit*) scitHitArray->At(i_hitArray);

 // ------------- do some stuff with the SciTHit data here -------------
      
      // be carefull there are more links stored. 
      // GetLink(0) seems to point to the MC Track 
      // GetLink(1) seems to point to the SciTPoint (the simulation output)
      // I guess this is different for the reco or pid Output files and maybe also for other detectors

      scitPointBranch->GetEntry(scitHit->GetLink(1).GetEntry());
      scitPoint = (PndSciTPoint*) scitPointArray->At(scitHit->GetLink(1).GetIndex());

      // ------------- do some stuff with the SciTPoint data here -------------


      mcTrackBranch->GetEntry(scitPoint->GetLink(0).GetEntry());
      mcTrack = (PndMCTrack*) mcTrackArray->At(scitPoint->GetLink(0).GetIndex());
      
      //-------------- do some stuff with the corresponding mcTrack data here ---------------

    }
  } // ----- loop oveer digitized events --- END ---

  simFile->Close();
  digFile->Close();

}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Update on the SciTil Detector
Next Topic: momentum vs beta for barrel TOF
Goto Forum:
  


Current Time: Fri Apr 19 05:21:43 CEST 2024

Total time taken to generate the page: 0.01091 seconds