LCOV - code coverage report
Current view: top level - STEER/ESD - AliESDHandler.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 60 1.7 %
Date: 2016-06-14 17:26:59 Functions: 1 13 7.7 %

          Line data    Source code
       1             : 
       2             : /**************************************************************************
       3             :  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
       4             :  *                                                                        *
       5             :  * Author: The ALICE Off-line Project.                                    *
       6             :  * Contributors are mentioned in the code where appropriate.              *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : /*$Id$*/
      18             : 
      19             : //-------------------------------------------------------------------------
      20             : //
      21             : //     Implementation of the Virtual Event Handler Interface for ESD
      22             : //
      23             : //-------------------------------------------------------------------------
      24             : 
      25             : 
      26             : #include <TTree.h>
      27             : #include <TFile.h>
      28             : #include <TString.h>
      29             : #include <TROOT.h>
      30             : 
      31             : #include "AliLog.h"
      32             : #include "AliESDHandler.h"
      33             : #include "AliESDEvent.h"
      34             : #include "AliESDfriend.h"
      35             : 
      36         172 : ClassImp(AliESDHandler)
      37             : 
      38             : //______________________________________________________________________________
      39             : AliESDHandler::AliESDHandler() :
      40           0 :         AliVEventHandler(),
      41           0 :         fesdf(NULL),
      42           0 :         fTreeEF(NULL),
      43           0 :         fFileEF(NULL),
      44           0 :         fFileName("AliESDfriends_v1.root"),
      45           0 :         fIsEventSelectedForFriends(kFALSE)
      46           0 : {
      47             : 
      48             :         // default constructor
      49           0 : }
      50             : 
      51             : //______________________________________________________________________________
      52             : AliESDHandler::AliESDHandler(const char* name, const char* title):
      53           0 :         AliVEventHandler(name, title),
      54           0 :         fesdf(NULL),
      55           0 :         fTreeEF(NULL),
      56           0 :         fFileEF(NULL),
      57           0 :         fFileName("AliESDfriends_v1.root"),
      58           0 :         fIsEventSelectedForFriends(kFALSE)
      59           0 : {
      60             : 
      61             :         // constructor with name and title
      62             : 
      63           0 : }
      64             : 
      65             : //______________________________________________________________________________
      66             : AliESDHandler::~AliESDHandler() 
      67           0 : {
      68             :         // Destructor.
      69           0 :         delete fesdf;
      70           0 :         if(fFileEF){
      71             :                 // is already handled in TerminateIO
      72           0 :                 fFileEF->Close();
      73           0 :                 delete fFileEF;
      74             :         }
      75           0 :         delete fTreeEF;
      76           0 : }
      77             : 
      78             : //______________________________________________________________________________
      79             : Bool_t AliESDHandler::Init(Option_t* opt)
      80             : {
      81             :         //
      82             :         // Initialize IO
      83             :         //
      84             :         
      85             :         // File opening according to execution mode
      86           0 :         TString option(opt);
      87           0 :         option.ToLower();
      88           0 :         TDirectory *owd = gDirectory;
      89             : 
      90           0 :         fesdf = new AliESDfriend();
      91             : 
      92             :         // Open the file with friends
      93           0 :         if (option.Contains("proof")) {
      94             :                 // proof
      95             :                 // Merging via files. Need to access analysis manager via interpreter.
      96           0 :                 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(\"%s\", \"RECREATE\");", fFileName.Data()));
      97           0 :                 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->GetCommonOutputContainer()->SetFile((TFile*)0x%p);", gFile));
      98           0 :                 fFileEF = gFile;
      99           0 :         } else {
     100             :                 // local and grid
     101           0 :                 fFileEF = new TFile(fFileName.Data(), "RECREATE");
     102             :         }
     103             : 
     104             :         // Create the friends tree
     105           0 :         fFileEF->cd();
     106           0 :         fTreeEF = new TTree("esdFriendTree", "Tree with ESD friends");
     107           0 :         fTreeEF->Branch("ESDfriend.","AliESDfriend", &fesdf);
     108             : 
     109           0 :         owd->cd();
     110             :         
     111             :         return kTRUE;
     112           0 : }
     113             : 
     114             : 
     115             : //______________________________________________________________________________
     116             : Bool_t AliESDHandler::FinishEvent()
     117             : {
     118             :         //
     119             :         // Fill the tree 
     120             :         //
     121             : 
     122           0 :         FillTree();
     123             :         
     124             :         // resetting
     125           0 :         if (fesdf) fesdf->~AliESDfriend();
     126           0 :         new(fesdf) AliESDfriend();  
     127           0 :         return kTRUE;
     128           0 : }
     129             : 
     130             : //______________________________________________________________________________
     131             : Bool_t AliESDHandler::Terminate()
     132             : {
     133             :         //
     134             :         // Terminate 
     135             :         //
     136             : 
     137           0 :         return kTRUE;
     138             : }
     139             : 
     140             : //______________________________________________________________________________
     141             : Bool_t AliESDHandler::TerminateIO()
     142             : {
     143             :         //
     144             :         // Terminate IO
     145             :         //
     146             : 
     147           0 :         if (fFileEF) {
     148           0 :                 fFileEF->cd();
     149           0 :                 fTreeEF->Write();
     150           0 :                 fFileEF->Close();
     151           0 :                 delete fFileEF;
     152           0 :                 fFileEF = 0;
     153           0 :         }
     154             : 
     155           0 :         return kTRUE;
     156             : }
     157             : 
     158             : //______________________________________________________________________________
     159             : void AliESDHandler::FillTree()
     160             : {
     161             :         //
     162             :         // Fill the ESD Tree
     163             :         //
     164           0 :         if (fIsEventSelectedForFriends){
     165           0 :                 AliDebug(2,Form("number of friend tracks = %d\n",fesdf->GetNumberOfTracks()));
     166             :         }
     167             :         else {
     168           0 :                 fesdf->SetSkipBit(kTRUE);
     169             :         }
     170           0 :         AliDebug(2,Form("friend = %p",fesdf));
     171           0 :         fFileEF->cd();
     172           0 :         fTreeEF->Fill();
     173           0 : }

Generated by: LCOV version 1.11