LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliAnalysisTaskBadChunkID.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 62 1.6 %
Date: 2016-06-14 17:26:59 Functions: 1 11 9.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      17             : //
      18             : // MC bad chunk identifier 
      19             : // --- david.dobrigkeit.chinellato@cern.ch
      20             : //
      21             : // Loops over all chunks and fills a TTree object with a TString locating 
      22             : // chunk name for each event and a "number of global tracks" variable. 
      23             : //
      24             : // TTree is filled event-by-event but has only very few data members, 
      25             : // so memory consumption should still be reasonable. 
      26             : //
      27             : // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      28             : 
      29             : class TTree;
      30             : class TParticle;
      31             : 
      32             : #include <Riostream.h>
      33             : #include "TList.h"
      34             : #include "TH1.h"
      35             : #include "TFile.h"
      36             : #include "TString.h"
      37             : #include "AliLog.h"
      38             : #include "AliESDEvent.h"
      39             : #include "AliESDtrack.h"
      40             : #include "AliInputEventHandler.h"
      41             : #include "AliAnalysisManager.h"
      42             : //#include "AliMCEventHandler.h"
      43             : //#include "AliMCEvent.h"
      44             : //#include "AliStack.h"
      45             : #include "AliAnalysisTaskBadChunkID.h"
      46             : 
      47             : using std::cout;
      48             : using std::endl;
      49             : 
      50         170 : ClassImp(AliAnalysisTaskBadChunkID)
      51             : 
      52             : AliAnalysisTaskBadChunkID::AliAnalysisTaskBadChunkID() 
      53           0 : : AliAnalysisTaskSE(), fList(0), fTree(0),
      54           0 :   fHistNEvents(0),
      55           0 :   fRunNumber(0),
      56           0 :   fFileName(0),
      57           0 :   fNGlobalTracks(0),
      58           0 :   fNTracks(0)
      59           0 : {
      60             :   // Dummy Constructor
      61             : 
      62           0 : }
      63             : 
      64             : AliAnalysisTaskBadChunkID::AliAnalysisTaskBadChunkID(const char *name) 
      65           0 :   : AliAnalysisTaskSE(name), fList(0), fTree(0),
      66           0 :     fHistNEvents(0),
      67           0 :     fRunNumber(0),
      68           0 :     fFileName(0),
      69           0 :     fNGlobalTracks(0),
      70           0 :     fNTracks(0)
      71           0 : {
      72             :   // Constructor
      73             :   // Output slot #0 writes into a TList container (Cascade)
      74           0 :   DefineOutput(1, TList::Class());
      75           0 :   DefineOutput(2, TTree::Class());
      76           0 : }
      77             : 
      78             : 
      79             : AliAnalysisTaskBadChunkID::~AliAnalysisTaskBadChunkID()
      80           0 : {
      81             : //------------------------------------------------
      82             : // DESTRUCTOR
      83             : //------------------------------------------------
      84             : 
      85           0 :    if (fList){
      86           0 :       delete fList;
      87           0 :       fList = 0x0;
      88           0 :    }
      89             :    /*
      90             :    if (fTree){
      91             :       delete fTree;
      92             :       fTree = 0x0;
      93             :    }
      94             :    */
      95           0 : }
      96             : 
      97             : //________________________________________________________________________
      98             : void AliAnalysisTaskBadChunkID::UserCreateOutputObjects()
      99             : {
     100             : 
     101             :    
     102             :    // Create histograms
     103           0 :    OpenFile(1);
     104           0 :    fList = new TList();
     105           0 :    fList->SetOwner();  // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
     106             : 
     107           0 :    if(! fHistNEvents) {
     108           0 :       fHistNEvents = new TH1F("fHistNEvents", 
     109             :          "NumberOfEvents", 
     110             :          1, 0, 1);              
     111           0 :       fList->Add(fHistNEvents);
     112           0 :    }
     113             : 
     114           0 :    OpenFile(2); 
     115             :    // Called once
     116             : 
     117             : //------------------------------------------------
     118             : 
     119           0 :    fTree = new TTree("fTree","V0Candidates");
     120             : 
     121             : //------------------------------------------------
     122             : // fTree Branch definitions - V0 Tree
     123             : //------------------------------------------------
     124             : 
     125             : //-----------BASIC-INFO---------------------------
     126           0 :    /*1*/ fTree->Branch("fNGlobalTracks",&fNGlobalTracks,"fNGlobalTracks/I"); 
     127           0 :    /*2*/ fTree->Branch("fNTracks",&fNTracks,"fNTracks/I");   
     128           0 :    /*3*/ fTree->Branch("fRunNumber",&fRunNumber,"fRunNumber/I");     
     129           0 :    /*4*/ fTree->Branch("fFileName",&fFileName,16000,0);        
     130             : 
     131             :    //List of Histograms: Normal
     132           0 :    PostData(1, fList);
     133             : 
     134             :    //TTree Object: Saved to base directory. Should cache to disk while saving. 
     135             :    //(Important to avoid excessive memory usage, particularly when merging)
     136           0 :    PostData(2, fTree);
     137             : 
     138           0 : }// end UserCreateOutputObjects
     139             : 
     140             : 
     141             : //________________________________________________________________________
     142             : void AliAnalysisTaskBadChunkID::UserExec(Option_t *) 
     143             : {
     144             :   // Main loop
     145             :   // Called for each event
     146             : 
     147             :    AliESDEvent *lESDevent = 0x0;
     148             :    //AliMCEvent  *lMCevent  = 0x0;
     149             :    //AliStack    *lMCstack  = 0x0;
     150             : 
     151             :   // Connect to the InputEvent   
     152             :   // After these lines, we should have an ESD/AOD event
     153             : 
     154             :    // Appropriate for ESD analysis! 
     155             :       
     156           0 :    lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
     157           0 :    if (!lESDevent) {
     158           0 :       AliWarning("ERROR: lESDevent not available \n");
     159           0 :       return;
     160             :    }
     161             : 
     162             : /* Anyhow not needed for cross-check
     163             :  
     164             :    lMCevent = MCEvent();
     165             :    if (!lMCevent) {
     166             :       Printf("ERROR: Could not retrieve MC event \n");
     167             :       cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;   
     168             :       return;
     169             :    }
     170             : 
     171             :    lMCstack = lMCevent->Stack();
     172             :    if (!lMCstack) {
     173             :       Printf("ERROR: Could not retrieve MC stack \n");
     174             :       cout << "Name of the file with pb :" <<  fInputHandler->GetTree()->GetCurrentFile()->GetName() << endl;
     175             :       return;
     176             :    }
     177             :  
     178             : */
     179             : //------------------------------------------------
     180             : // Track Multiplicity Information Acquistion
     181             : //------------------------------------------------
     182             : 
     183             :    Int_t lNTracks = -1; 
     184             :    Int_t lNGlobalTracks = 0;
     185             : 
     186           0 :    lNTracks = lESDevent->GetNumberOfTracks();
     187             : 
     188             : //----- Loop on Tracks --------------------------------------------------------------
     189           0 :    for (Int_t iCurrentTrack = 0; iCurrentTrack < lNTracks; iCurrentTrack++) 
     190             :    {// This is the begining of the loop on tracks
     191           0 :       AliESDtrack *lThisTrack=((AliESDEvent*)lESDevent)->GetTrack(iCurrentTrack);
     192             : 
     193             :       // kITSrefit refit condition: Global Track
     194           0 :       if( !(lThisTrack->GetStatus() & AliESDtrack::kITSrefit)) continue; 
     195           0 :       lNGlobalTracks++;
     196           0 :    }
     197             : //----- End Loop on Tracks ----------------------------------------------------------
     198             : 
     199           0 :   fHistNEvents->Fill(0.5); // valid event
     200           0 :   fNGlobalTracks  = lNGlobalTracks;
     201           0 :   fNTracks        = lNTracks;
     202           0 :   fRunNumber      = lESDevent->GetRunNumber();
     203             : 
     204             :   //Gymnastics to get the chunk number...
     205           0 :   TString lFileName = CurrentFileName();
     206             :   //  TObjArray *lLocationArray = lFileName.Tokenize("/");
     207           0 :   fFileName = fInputHandler->GetTree()->GetCurrentFile()->GetName();
     208             :   //  delete lLocationArray;
     209           0 :   fTree->Fill();
     210             : 
     211             :   //Printf("%i in run %i, Nglob = %i, Ntrack = %i \n",fChunkNumber,fRunNumber,fNGlobalTracks,fNTracks);
     212             : 
     213             :    // Post output data.
     214           0 :   PostData(1, fList);
     215           0 :   PostData(2, fTree);
     216           0 : }
     217             : 
     218             : //________________________________________________________________________
     219             : void AliAnalysisTaskBadChunkID::Terminate(Option_t *)
     220             : {
     221             :    // Draw result to the screen
     222             :    // Called once at the end of the query
     223             : 
     224             :    // Not interesting at this point.
     225           0 : }

Generated by: LCOV version 1.11