]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added HLT MC event, as AliMCEvent can not used as container
authorjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Mar 2009 11:35:03 +0000 (11:35 +0000)
committerjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Mar 2009 11:35:03 +0000 (11:35 +0000)
HLT/BASE/util/AliHLTESDMCEventPublisherComponent.cxx
HLT/BASE/util/AliHLTESDMCEventPublisherComponent.h
HLT/BASE/util/AliHLTMCEvent.cxx [new file with mode: 0644]
HLT/BASE/util/AliHLTMCEvent.h [new file with mode: 0644]
HLT/CMake_libAliHLTUtil.txt
HLT/libAliHLTUtil.pkg

index 93af204d439cb4b70dc136a54732818115408a11..716ecbfb41729516607c90b9be36c749d3e36092 100644 (file)
@@ -60,7 +60,8 @@ AliHLTESDMCEventPublisherComponent::AliHLTESDMCEventPublisherComponent()
   fpTreeTR(NULL),
   fpESD(NULL),
   fpHLTESD(NULL),
-  fpMC(NULL) {
+  fpMC(NULL),
+  fpHLTMC(NULL) {
   // see header file for class documentation
   // or
   // refer to README to build package
@@ -247,6 +248,11 @@ Int_t AliHLTESDMCEventPublisherComponent::DoDeinit() {
     delete fpMC;
   fpMC = NULL;
 
+  if ( fpHLTMC ) 
+    delete fpHLTMC;
+  fpHLTMC = NULL;
+
+
   CloseCurrentFileList();
   
   AliHLTFilePublisher::DoDeinit();
@@ -461,8 +467,16 @@ Int_t AliHLTESDMCEventPublisherComponent::GetEvent( const AliHLTComponentEventDa
        iResult=-EFAULT;
       }
 
-      if ( iResult>=0 && fpMC )
+      // -- Fill AliHLTMCEvent 
+      if ( iResult>=0 && fpMC ) {
        PushBack( fpMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginOffline , fSpecification ); 
+
+       fpHLTMC = new AliHLTMCEvent(fpMC);
+       
+       if ( fpHLTMC )
+         PushBack( fpHLTMC, kAliHLTDataTypeMCObject|kAliHLTDataOriginHLT , fSpecification ); 
+      }
+
     } // if ( fPublishMC ) {
     
     // -- Next Event in Folder, 
index fb12aa262aae8b2ba324d5cb84e546807a7accb9..db980e399e30ae065f72f98ce69db839bf557d61 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliESDEvent.h"
 #include "AliMCEvent.h"
 
+#include "AliHLTMCEvent.h"
 
 /**
  * @class AliHLTESDMCEventPublisherComponent
  * Library: \b libAliHLTUtil.so     <br>
  * Input Data Types: none <br>
  * Output Data Types: according to arguments <br>
- *  - AliESDEvent -> kAliHLTDataTypeESDObject
- *     - HLTESD   -> kAliHLTDataOriginHLT
- *     - ESD      -> kAliHLTDataOriginOffline
+ *  - AliESDEvent    -> kAliHLTDataTypeESDObject
+ *     - HLTESD      -> kAliHLTDataOriginHLT
+ *     - ESD         -> kAliHLTDataOriginOffline
  *
- *  - AliMCEvent  -> kAliHLTDataTypeMCObject
- *                -> kAliHLTDataOriginOffline
+ *  - AliMCEvent     -> kAliHLTDataTypeMCObject
+ *                   -> kAliHLTDataOriginOffline
+ *
+ *  - AliHLTMCEvent  -> kAliHLTDataTypeMCObject
+ *                   -> kAliHLTDataOriginHLT
+ * 
  *
  * <h2>Mandatory arguments:</h2>
  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
@@ -47,7 +52,7 @@
  *      Can be one, all or some of :<br>
  *      - ESD<br>
  *      - HLTESD<br>
- *      - MC<br>
+ *      - MC (publishes both AliHLTMCEvent and AliMCEvent) <br>
  *
  * \li -datapath     <i> Path to list of data files     </i><br>
  *      - AliESDs.root<br>
@@ -280,6 +285,9 @@ class AliHLTESDMCEventPublisherComponent : public AliHLTFilePublisher  {
   /* Ptr to current AliMCEvent, to be shipped out*/
   AliMCEvent* fpMC;                          //! transient
   
+  /* Ptr to current AliHLTMCEvent, to be shipped out*/
+  AliHLTMCEvent* fpHLTMC;                    //! transient
+
   ClassDef(AliHLTESDMCEventPublisherComponent, 0)
 };
 #endif
diff --git a/HLT/BASE/util/AliHLTMCEvent.cxx b/HLT/BASE/util/AliHLTMCEvent.cxx
new file mode 100644 (file)
index 0000000..5fedda9
--- /dev/null
@@ -0,0 +1,217 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTMCEvent.cxx  $
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
+ *                  for The ALICE HLT Project.                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/** @file   AliHLTMCEvent.h
+    @author Jochen Thaeder
+    @date   
+    @brief  Container class for an AliMCEvent
+*/
+
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
+
+#if __GNUC__ >= 3
+using namespace std;
+#endif
+
+#include "AliHLTMCEvent.h"
+#include "AliStack.h"
+
+#include "TParticlePDG.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTMCEvent)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+  
+// #################################################################################
+AliHLTMCEvent::AliHLTMCEvent()
+  :
+  fNParticles(0),
+  fCurrentParticleIndex(-1),
+  fCurrentParticle(NULL),
+  fStack( new TClonesArray("TParticle", 1000 ) ) {
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+}
+
+// #################################################################################
+AliHLTMCEvent::AliHLTMCEvent( Int_t iNumberTracks)
+  :
+  fNParticles(0),
+  fCurrentParticleIndex(-1),
+  fCurrentParticle(NULL),
+  fStack( new TClonesArray("TParticle", iNumberTracks ) ) {
+  // see header file for class documentation
+
+}
+// #################################################################################
+AliHLTMCEvent::AliHLTMCEvent( AliMCEvent *pMCEvent )
+  :
+  fNParticles(0),
+  fCurrentParticleIndex(-1),
+  fCurrentParticle(NULL),
+  fStack(NULL) {
+  // see header file for class documentation
+
+  FillMCEvent( pMCEvent );
+}
+
+// #################################################################################
+AliHLTMCEvent::~AliHLTMCEvent() {
+  // see header file for class documentation
+
+  if ( fStack ) {
+    fStack->Delete();
+    delete fStack;
+  }
+  fStack = NULL;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                                     Getter
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+TParticle* AliHLTMCEvent::Particle( Int_t iParticle ) {
+  // see header file for class documentation
+  if ( iParticle >= fNParticles || !fStack  )
+    return NULL;
+  return (TParticle*) (*fStack)[iParticle];
+}
+
+// #################################################################################
+TParticle* AliHLTMCEvent::NextParticle() {
+  // see header file for class documentation
+
+  fCurrentParticleIndex++;
+  
+  return Particle( fCurrentParticleIndex );
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                                     Setter
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+void AliHLTMCEvent::AddParticle( const TParticle* particle ) {
+  // see header file for class documentation
+  
+  new( (*fStack) [fNParticles] ) TParticle( *particle );
+  fNParticles++;
+
+  return;
+}
+
+// #################################################################################
+void AliHLTMCEvent::FillMCEvent( AliMCEvent *pMCEvent ) {
+  // see header file for class documentation
+  
+  AliStack *stack = pMCEvent->Stack();
+
+  // -- Create local stack
+  if ( stack && stack->GetNtrack() > 0 )
+    fStack = new TClonesArray("TParticle", stack->GetNtrack() );
+  else
+    return;
+  
+  // -- Loop over off-line stack and fill local stack
+  for (Int_t iterStack = 0; iterStack < stack->GetNtrack(); iterStack++) {
+
+    TParticle *particle = stack->Particle(iterStack);
+    if ( !particle) {
+      printf( "Error reading particle %i out of %i \n", iterStack,stack->GetNtrack() );
+      continue;
+    }
+
+    // ----------------
+    // -- Apply cuts         --> Do be done better XXX
+    // ----------------
+
+    TParticlePDG * foo = particle->GetPDG();
+    printf (" Particle2 -- %i - (PHI:%f - ETA:%f - PT:%f) \n",
+           iterStack, 
+           particle->Phi(), particle->Eta(), particle->Pt() );
+
+    if ( foo )
+      printf (" Particle3 -- %i - (MASS:%f - CHARGE:%f - PDGCODE:%i) \n",
+             iterStack,
+             foo->Mass(), foo->Charge(), foo->PdgCode() );
+    else
+      printf (" Particle3 -- %i - (MASS:xx - CHARGE:xx - PDGCODE:xx) \n",
+             iterStack);
+
+    // -- only charged particles
+    //if ( !(particle->GetPDG()->Charge()) )
+    //continue;
+  
+    // -- primary
+    if ( !(stack->IsPhysicalPrimary(iterStack)) )
+      continue;
+      
+    // -- final state
+    if ( particle->GetNDaughters() != 0 )
+      continue;
+
+
+    // -- Add particle after cuts
+    AddParticle ( particle );
+  }
+
+  Compress();
+
+  return;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                                    Helper
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+void AliHLTMCEvent::Compress() {
+  // see header file for class documentation
+
+  fStack->Compress();
+}
+
+// #################################################################################
+void AliHLTMCEvent::Reset() {
+  // see header file for class documentation
+
+  fCurrentParticleIndex = -1; 
+  fCurrentParticle      = NULL;
+}
diff --git a/HLT/BASE/util/AliHLTMCEvent.h b/HLT/BASE/util/AliHLTMCEvent.h
new file mode 100644 (file)
index 0000000..bacb05f
--- /dev/null
@@ -0,0 +1,145 @@
+//-*- Mode: C++ -*-
+
+// $Id: AliHLTEventStatistics.h 25559 2008-05-02 13:49:18Z richterm $
+
+#ifndef ALIHLTMCEVENT_H
+#define ALIHLTMCEVENT_H
+
+/* This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ * See cxx source for full Copyright notice                               */
+
+/** @file   AliHLTMCEvent.h
+    @author Jochen Thaeder
+    @date   
+    @brief  Container class for an AliMCEvent
+*/
+
+#include "TObject.h"
+#include "TParticle.h"
+#include "TClonesArray.h"
+
+#include "AliMCEvent.h"
+
+/**
+ * @class  AliHLTMCEvent
+ * Container class for off-line AliMCEvent, as this class is coupled to 
+ * TTrees an can not be easily copied and send via the HLT chain.
+ *
+ * This class as the complete functionality as the off-line class,
+ * only the ones needed so far.
+ *
+ * There is no extra "stack" class, the stack is included in this class 
+ * a TClonesArray of TParticles
+ *
+ */
+
+class AliHLTMCEvent : public TObject {
+  
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** standard constructor */
+  AliHLTMCEvent();
+
+  /** constructor 
+   *  @param iNumberTracks number of initial tracks
+   */
+  AliHLTMCEvent( Int_t iNumberTracks );
+  /** constructor 
+   *  @param pMCEvent ptr to off-line AliMCEvent
+   */
+  AliHLTMCEvent( AliMCEvent *pMCEvent );
+
+  /** destructor */
+  virtual ~AliHLTMCEvent();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                                     Getter
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Get number of particles
+   *  @return number of particles
+   */
+  Int_t GetNumberOfTracks() const { return fNParticles; }
+
+  /** Return particle at index iParticle
+   *  @param iParticle Particle index in local stack
+   *  @return ptr on success, NULL on failure
+   */
+  TParticle* Particle( Int_t iParticle );
+  
+  /** Return next particle
+   *  @return ptr on success, NULL on failure
+   */
+  TParticle* NextParticle();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                                     Setter
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** Add a prticle to this container
+   *  @param particle ptr to TParticle classs
+   */
+  void AddParticle( const TParticle* particle);
+  
+  /** Fill the off-line MC event in to this class
+   *  @param pMCEvent ptr to off-line AliMCEvent
+   */
+  void FillMCEvent( AliMCEvent *pMCEvent );
+  
+  /*
+   * ---------------------------------------------------------------------------------
+   *                                    Helper
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Compress the TClonesArray fStack */
+  void Compress();
+
+  /** Reset index for next particle */
+  void Reset();
+
+  ///////////////////////////////////////////////////////////////////////////////////
+
+private:
+
+  /** copy constructor prohibited */
+  AliHLTMCEvent (const AliHLTMCEvent&);
+
+  /** assignment operator prohibited */
+  AliHLTMCEvent& operator= (const AliHLTMCEvent&);
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Members - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Number of particles */
+  Int_t           fNParticles;                   // see above
+
+  /** Current particle */
+  Int_t           fCurrentParticleIndex;         // see above
+
+  /** Ptr to current particle */
+  TParticle      *fCurrentParticle;              // see above
+
+  /** Stack of particles */
+  TClonesArray   *fStack;                        // see above
+
+  ClassDef(AliHLTMCEvent, 1)
+
+};
+#endif
+
index 882c56e6d1e5004b85fff875dd5e7517c2b82e47..ac508e0c2d48290b70a28ad0121ab07d8fe4a9de 100644 (file)
@@ -3,6 +3,7 @@
 set(SRCS
   BASE/util/AliHLTFilePublisher.cxx
   BASE/util/AliHLTFileWriter.cxx
+  BASE/util/AliHLTMCEvent.cxx
   BASE/util/AliHLTRootFilePublisherComponent.cxx
   BASE/util/AliHLTESDMCEventPublisherComponent.cxx
   BASE/util/AliHLTRootFileWriterComponent.cxx
index eb0697a248886cbb3e31ebacdf29a03c4bd41b93..7a9f26b6a13a46d728425f4794a4f10823b8e646 100644 (file)
@@ -3,6 +3,7 @@
 
 CLASS_HDRS:=   AliHLTFilePublisher.h \
                AliHLTFileWriter.h \
+               AliHLTMCEvent.h \
                AliHLTRootFilePublisherComponent.h \
                AliHLTESDMCEventPublisherComponent.h \
                AliHLTRootFileWriterComponent.h \