]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
First version of esd input handler reading recpoints in parallel.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 20 Mar 2008 15:31:22 +0000 (15:31 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 20 Mar 2008 15:31:22 +0000 (15:31 +0000)
Works for TPC only.
General case will be implemented in short.

STEER/AliESDInputHandlerRP.cxx [new file with mode: 0644]
STEER/AliESDInputHandlerRP.h [new file with mode: 0644]
STEER/ESDLinkDef.h
STEER/libESD.pkg

diff --git a/STEER/AliESDInputHandlerRP.cxx b/STEER/AliESDInputHandlerRP.cxx
new file mode 100644 (file)
index 0000000..fbab91e
--- /dev/null
@@ -0,0 +1,203 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliESDInputHandler.cxx 24521 2008-03-14 16:43:54Z morsch $ */
+
+//-------------------------------------------------------------------------
+//     Event handler for ESD input reading the RecPoint Trees in parallel
+//     Author: Andreas Morsch, CERN
+//-------------------------------------------------------------------------
+
+#include <TTree.h>
+#include <TList.h>
+#include <TFile.h>
+#include <TString.h>
+#include <TObjString.h>
+#include <TProcessID.h>
+
+#include "AliESDInputHandlerRP.h"
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliLog.h"
+
+ClassImp(AliESDInputHandlerRP)
+
+//______________________________________________________________________________
+AliESDInputHandlerRP::AliESDInputHandlerRP() :
+    AliESDInputHandler(),
+    fRTrees(new TList()),
+    fRFiles(new TList()),
+    fDirR(0),
+    fEventNumber(-1),
+    fNEvent(-1),
+    fFileNumber(0),
+    fEventsPerFile(0),
+    fExtension(""),
+    fPathName(new TString("./"))
+{
+  // default constructor
+}
+
+//______________________________________________________________________________
+AliESDInputHandlerRP::~AliESDInputHandlerRP() 
+{
+  // destructor
+}
+
+//______________________________________________________________________________
+AliESDInputHandlerRP::AliESDInputHandlerRP(const char* name, const char* title):
+    AliESDInputHandler(name, title),
+    fRTrees(new TList()),
+    fRFiles(new TList()),
+    fDirR(0),
+    fEventNumber(-1),
+    fNEvent(-1),
+    fFileNumber(0),
+    fEventsPerFile(0),
+    fExtension(""),
+    fPathName(new TString("./"))
+{
+    // Constructor
+}
+
+Bool_t AliESDInputHandlerRP::Init(Option_t* opt)
+{
+    //
+    // Initialize input
+    //
+    if (!(strcmp(opt, "proof")) || !(strcmp(opt, "local"))) return kTRUE;
+    //
+    TFile* file;
+    
+    file = TFile::Open(Form("%sTPC.RecPoints.root", fPathName->Data()));
+    if (!file) AliFatal(Form("AliESDInputHandlerRP: TPC.RecPoints.root not found in %s ! \n", fPathName->Data()));
+    fRFiles->Add(file);
+    fEventsPerFile = file->GetNkeys() - file->GetNProcessIDs();
+    // Reset the event number
+    fEventNumber      = -1;
+    fFileNumber       =  0;
+    fNEvent           =  fTree->GetEntries();
+    
+    printf("AliESDInputHandler::Init() %d\n",__LINE__);
+    return kTRUE;
+}
+
+Bool_t AliESDInputHandlerRP::BeginEvent(Long64_t entry)
+{
+    // Begin the next event
+    // Delegate to base class
+    AliESDInputHandler::BeginEvent(entry);
+//
+    if (entry == -1) {
+       fEventNumber++;
+       entry = fEventNumber;
+    } else {
+       fEventNumber = entry;
+    }
+    
+    if (entry >= fNEvent) {
+       AliWarning(Form("AliESDInputHandlerRP: Event number out of range %5d %5d\n", entry, fNEvent));
+       return kFALSE;
+    }
+    return GetEvent(entry);
+}
+
+Bool_t AliESDInputHandlerRP::GetEvent(Int_t iev)
+{
+    // Load the event number iev
+    //
+    // Calculate the file number
+    Int_t inew  = iev / fEventsPerFile;
+    if (inew != fFileNumber) {
+       fFileNumber = inew;
+       if (!OpenFile(fFileNumber)){
+           return kFALSE;
+       }
+    }
+    // Folder name
+    char folder[20];
+    sprintf(folder, "Event%d", iev);
+    // Tree R
+    TFile* file = (TFile*) (fRFiles->At(0));
+    
+    file->GetObject(folder, fDirR);
+    if (!fDirR) {
+       AliWarning(Form("AliESDInputHandlerRP: Event #%5d not found\n", iev));
+       return kFALSE;
+    }
+    
+    TTree* tree;
+    fDirR ->GetObject("TreeR", tree);
+    fRTrees->Add(tree);
+    tree->ls();
+    
+    return kTRUE;
+}
+
+Bool_t AliESDInputHandlerRP::OpenFile(Int_t i)
+{
+    // Open file i
+    Bool_t ok = kTRUE;
+    if (i > 0) {
+       fExtension = Form("%d", i);
+    } else {
+       fExtension = "";
+    }
+    
+    fRFiles->Delete();
+    TFile* file;
+    file = TFile::Open(Form("%sTPC.RecPoints%s.root", fPathName->Data(), fExtension));
+    if (!file) {
+       AliFatal(Form("AliESDInputHandlerRP: TPC.RecPoints.root not found in %s ! \n", fPathName->Data()));
+       ok = kFALSE;
+    }
+    return ok;
+}
+
+Bool_t AliESDInputHandlerRP::Notify(const char *path)
+{
+  // Notify about directory change
+  // The directory is taken from the 'path' argument
+  // Reconnect trees
+    TString fileName(path);
+    if(fileName.Contains("AliESDs.root")){
+       fileName.ReplaceAll("AliESDs.root", "");
+    }
+
+    *fPathName = fileName;
+
+    printf("AliESDInputHandlerRP::Notify() Path: %s\n", fPathName->Data());
+    
+    ResetIO();
+    InitIO("");
+
+    return kTRUE;
+}
+
+Bool_t AliESDInputHandlerRP::FinishEvent()
+{
+    // Clean-up after each event
+    delete fDirR;  fDirR = 0;
+    AliESDInputHandler::FinishEvent();
+    return kTRUE;
+}
+
+void AliESDInputHandlerRP::ResetIO()
+{
+// Delete trees and files
+    fRTrees->Delete();
+    fRFiles->Delete();
+    fExtension="";
+}
diff --git a/STEER/AliESDInputHandlerRP.h b/STEER/AliESDInputHandlerRP.h
new file mode 100644 (file)
index 0000000..2dff28f
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef ALIESDINPUTHANDLERRP_H
+#define ALIESDINPUTHANDLERRP_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliESDInputHandler.h 24521 2008-03-14 16:43:54Z morsch $ */
+
+//-------------------------------------------------------------------------
+//     ESD Input Handler realisation of the AliVEventHandler interface
+//     Automatic loading of RecPoint Trees
+//     Author: Andreas Morsch, CERN
+//-------------------------------------------------------------------------
+
+#include "AliESDInputHandler.h"
+#include "AliESDEvent.h"
+class TList;
+class TTree;
+class TDirectoryFile;
+class TString;
+
+
+class AliESDInputHandlerRP : public AliESDInputHandler {
+
+ public:
+    AliESDInputHandlerRP();
+    AliESDInputHandlerRP(const char* name, const char* title);
+    virtual ~AliESDInputHandlerRP();
+    virtual Bool_t       Init(Option_t* opt);
+    virtual Bool_t       InitIO(Option_t* opt) {return Init(opt);};
+    virtual Bool_t       BeginEvent(Long64_t entry);
+    virtual Bool_t       FinishEvent();
+    virtual Bool_t       GetEvent(Int_t iev);
+    virtual Bool_t       Notify(const char* path);
+    virtual void         ResetIO();
+ private:
+    Bool_t      OpenFile(Int_t i);
+    AliESDInputHandlerRP(const AliESDInputHandlerRP& handler);             
+    AliESDInputHandlerRP& operator=(const AliESDInputHandlerRP& handler);  
+ private:
+    TList*          fRTrees;           // List of RecPoint Trees
+    TList*          fRFiles;           // List of RecPoint Files
+    TDirectoryFile* fDirR;             //! Directory for RP Tree
+    Int_t           fEventNumber;      //! Current event number
+    Int_t           fNEvent;           //! Number of events in current directory
+    Int_t           fFileNumber;       //! Input file number
+    Int_t           fEventsPerFile;    //! Number of events per file
+    char            *fExtension;       //! File name extension
+    TString         *fPathName;        //! Input file path 
+    ClassDef(AliESDInputHandlerRP, 1);
+};
+
+#endif
index 15bb219b05bad5d53bfc474638ea30707abc7438..45360bf540918047036e79950d5c5c14b3eac920 100644 (file)
@@ -14,6 +14,7 @@
 #pragma link C++ class  AliESD+;
 #pragma link C++ class  AliESDEvent+;
 #pragma link C++ class  AliESDInputHandler+;
 #pragma link C++ class  AliESD+;
 #pragma link C++ class  AliESDEvent+;
 #pragma link C++ class  AliESDInputHandler+;
+#pragma link C++ class  AliESDInputHandlerRP+;
 #pragma link C++ class  AliESDRun+;
 #pragma link C++ class  AliESDHeader+;
 #pragma link C++ class  AliESDZDC+;
 #pragma link C++ class  AliESDRun+;
 #pragma link C++ class  AliESDHeader+;
 #pragma link C++ class  AliESDZDC+;
index ddd8bc99220c018bbebfe355c1e9fadc23620aa2..3311fd72791f860ef11ead557b9a577113db5bce 100644 (file)
@@ -1,6 +1,6 @@
 #-*- Mode: Makefile -*-
 
 #-*- Mode: Makefile -*-
 
-SRCS = AliESDEvent.cxx AliESDInputHandler.cxx AliESDfriend.cxx AliESD.cxx \
+SRCS = AliESDEvent.cxx AliESDInputHandler.cxx AliESDInputHandlerRP.cxx AliESDfriend.cxx AliESD.cxx \
        AliESDtrack.cxx AliESDfriendTrack.cxx\
        AliESDMuonTrack.cxx AliESDPmdTrack.cxx AliESDTrdTrack.cxx AliESDHLTtrack.cxx \
        AliESDv0.cxx AliESDcascade.cxx AliVertex.cxx AliESDVertex.cxx \
        AliESDtrack.cxx AliESDfriendTrack.cxx\
        AliESDMuonTrack.cxx AliESDPmdTrack.cxx AliESDTrdTrack.cxx AliESDHLTtrack.cxx \
        AliESDv0.cxx AliESDcascade.cxx AliVertex.cxx AliESDVertex.cxx \