]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Merge remote-tracking branch 'origin/master' into flatdev
authormkrzewic <mikolaj.krzewicki@cern.ch>
Mon, 29 Sep 2014 09:49:08 +0000 (11:49 +0200)
committermkrzewic <mikolaj.krzewicki@cern.ch>
Mon, 29 Sep 2014 09:49:08 +0000 (11:49 +0200)
Conflicts:
PWGCF/FEMTOSCOPY/ESE/AliAnalysisTaskFemtoESE.cxx

163 files changed:
ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisManager.h
ANALYSIS/AliAnalysisSelector.cxx
ANALYSIS/AliAnalysisTask.h
HLT/AliHLTITSLinkDef.h
HLT/BASE/AliHLTComponentBenchmark.cxx
HLT/BASE/AliHLTComponentBenchmark.h
HLT/BASE/AliHLTDataTypes.cxx
HLT/BASE/AliHLTDataTypes.h
HLT/CMakelibAliHLTGlobal.pkg
HLT/CMakelibAliHLTITS.pkg
HLT/ITS/AliHLTITSAgent.cxx
HLT/ITS/AliHLTITSVertexerSPDComponent.cxx
HLT/ITS/AliHLTSAPTrackerData.h [new file with mode: 0644]
HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.cxx [new file with mode: 0644]
HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.h [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPAux.cxx [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPAux.h [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPLayer.cxx [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPLayer.h [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPTracker.cxx [new file with mode: 0644]
HLT/ITS/trackingSAP/AliITSSAPTracker.h [new file with mode: 0644]
HLT/ITS/trackingSAP/Process.C [new file with mode: 0644]
HLT/ITS/trackingSAP/README [new file with mode: 0644]
HLT/ITS/trackingSAP/TestHLTITSSAP.C [new file with mode: 0644]
HLT/ITS/trackingSAP/TestITSSAP.C [new file with mode: 0644]
HLT/global/.rootrc [new file with mode: 0644]
HLT/global/AliFlatESDEvent.cxx [new file with mode: 0644]
HLT/global/AliFlatESDEvent.h [new file with mode: 0644]
HLT/global/AliFlatESDFriend.cxx [new file with mode: 0644]
HLT/global/AliFlatESDFriend.h [new file with mode: 0644]
HLT/global/AliFlatESDFriendTrack.cxx [new file with mode: 0644]
HLT/global/AliFlatESDFriendTrack.h [new file with mode: 0644]
HLT/global/AliFlatESDTrack.cxx [new file with mode: 0644]
HLT/global/AliFlatESDTrack.h [new file with mode: 0644]
HLT/global/AliFlatESDTrigger.cxx [new file with mode: 0644]
HLT/global/AliFlatESDTrigger.h [new file with mode: 0644]
HLT/global/AliFlatESDV0.cxx [new file with mode: 0644]
HLT/global/AliFlatESDV0.h [new file with mode: 0644]
HLT/global/AliFlatESDVertex.cxx [new file with mode: 0644]
HLT/global/AliFlatESDVertex.h [new file with mode: 0644]
HLT/global/AliFlatExternalTrackParam.cxx [new file with mode: 0644]
HLT/global/AliFlatExternalTrackParam.h [new file with mode: 0644]
HLT/global/AliFlatTPCCluster.h [new file with mode: 0644]
HLT/global/AliFlatTPCseed.cxx [new file with mode: 0644]
HLT/global/AliFlatTPCseed.h [new file with mode: 0644]
HLT/global/AliHLTGlobalAgent.cxx
HLT/global/AliHLTGlobalCompareFlatComponent.cxx [new file with mode: 0644]
HLT/global/AliHLTGlobalCompareFlatComponent.h [new file with mode: 0644]
HLT/global/AliHLTGlobalEsdConverterComponent.cxx
HLT/global/AliHLTGlobalEsdConverterComponent.h
HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx [new file with mode: 0644]
HLT/global/AliHLTGlobalEsdToFlatConverterComponent.h [new file with mode: 0644]
HLT/global/AliHLTGlobalFlatEsdConverterComponent.cxx [new file with mode: 0644]
HLT/global/AliHLTGlobalFlatEsdConverterComponent.h [new file with mode: 0644]
HLT/global/AliHLTGlobalFlatEsdTestComponent.cxx [new file with mode: 0644]
HLT/global/AliHLTGlobalFlatEsdTestComponent.h [new file with mode: 0644]
HLT/global/AliHLTGlobalTrackMergerComponent.cxx
HLT/global/AliVVVZEROfriend.h [new file with mode: 0644]
HLT/global/CompareFlatESDs.C [new file with mode: 0644]
HLT/global/FlatESDConverter.C [new file with mode: 0644]
HLT/global/LoadLibs.C [new file with mode: 0644]
HLT/global/ReadFlatESD.C [new file with mode: 0644]
HLT/global/fladevMacros/compare/command.sh [new file with mode: 0755]
HLT/global/fladevMacros/esdToFlat/command_list.sh [new file with mode: 0755]
HLT/global/fladevMacros/plot/createHistos.C [new file with mode: 0644]
HLT/global/fladevMacros/rawToHltEsd/command_list.sh [new file with mode: 0755]
HLT/global/fladevMacros/rawToHltEsd/config_Flat.C [new file with mode: 0644]
HLT/global/fladevMacros/rawToNormalEsd/command_list.sh [new file with mode: 0755]
HLT/global/fladevMacros/rawToNormalEsd/rec.C [new file with mode: 0644]
HLT/global/fladevMacros/readFlat.sh [new file with mode: 0755]
HLT/global/physics/AliHLTAnaManagerComponent.cxx [new file with mode: 0644]
HLT/global/physics/AliHLTAnaManagerComponent.h [new file with mode: 0644]
HLT/global/physics/AliHLTFlatAnaManagerComponent.cxx [new file with mode: 0644]
HLT/global/physics/AliHLTFlatAnaManagerComponent.h [new file with mode: 0644]
HLT/global/physics/macros/README_AliHLTAnaManagerComponent [new file with mode: 0644]
HLT/global/physics/macros/runTaskOffline.C [new file with mode: 0644]
HLT/global/physics/macros/testconfig.C [new file with mode: 0644]
HLT/global/physics/macros/testconfigFlat.C [new file with mode: 0644]
ITS/AliITStrackV2.h
PWG/DevNanoAOD/AliNanoAODTrack.h
PWG/EMCAL/AliAnalysisTaskEMCALClusterizeFast.cxx
PWG/EMCAL/AliPicoTrack.h
PWG/FLOW/Tasks/AliFlowTrackCuts.h
PWGHF/vertexingHF/AliAnalysisVertexingHF.h
PWGJE/EMCALJetTasks/AliEmcalJet.h
STEER/AOD/AliAODEvent.cxx
STEER/AOD/AliAODEvent.h
STEER/AOD/AliAODRecoDecay.h
STEER/AOD/AliAODTrack.cxx
STEER/AOD/AliAODTrack.h
STEER/CMakelibSTEER.pkg
STEER/CMakelibSTEERBase.pkg
STEER/ESD/AliESDEvent.cxx
STEER/ESD/AliESDEvent.h
STEER/ESD/AliESDInputHandler.cxx
STEER/ESD/AliESDInputHandler.h
STEER/ESD/AliESDfriend.cxx
STEER/ESD/AliESDfriend.h
STEER/ESD/AliESDfriendTrack.cxx
STEER/ESD/AliESDfriendTrack.h
STEER/ESD/AliESDkink.h
STEER/ESD/AliESDtrack.cxx
STEER/ESD/AliESDtrack.h
STEER/ESD/AliESDv0.h
STEER/ESD/AliKalmanTrack.h
STEER/ESD/AliTrackPointArray.h
STEER/STEER/AliHLTTestInputHandler.cxx [new file with mode: 0644]
STEER/STEER/AliHLTTestInputHandler.h [new file with mode: 0644]
STEER/STEERBase/AliExternalTrackParam.h
STEER/STEERBase/AliInputEventHandler.h
STEER/STEERBase/AliMCEvent.cxx
STEER/STEERBase/AliMCEvent.h
STEER/STEERBase/AliMixedEvent.cxx
STEER/STEERBase/AliMixedEvent.h
STEER/STEERBase/AliTPCPIDResponse.cxx
STEER/STEERBase/AliVEvent.cxx
STEER/STEERBase/AliVEvent.h
STEER/STEERBase/AliVEventHandler.h
STEER/STEERBase/AliVMisc.cxx [new file with mode: 0644]
STEER/STEERBase/AliVMisc.h [new file with mode: 0644]
STEER/STEERBase/AliVParticle.h
STEER/STEERBase/AliVTPCseed.cxx [new file with mode: 0644]
STEER/STEERBase/AliVTPCseed.h [new file with mode: 0644]
STEER/STEERBase/AliVTrack.cxx
STEER/STEERBase/AliVTrack.h
STEER/STEERBase/AliVVertex.h
STEER/STEERBase/AliVfriendEvent.cxx [new file with mode: 0644]
STEER/STEERBase/AliVfriendEvent.h [new file with mode: 0644]
STEER/STEERBase/AliVfriendTrack.cxx [new file with mode: 0644]
STEER/STEERBase/AliVfriendTrack.h [new file with mode: 0644]
STEER/STEERLinkDef.h
TPC/CMakelibTPCcalib.pkg
TPC/Calib/AliAnalysisTaskPt.cxx [new file with mode: 0644]
TPC/Calib/AliAnalysisTaskPt.h [new file with mode: 0644]
TPC/Calib/AliTPCAnalysisTaskcalib.cxx
TPC/Calib/AliTPCAnalysisTaskcalib.h
TPC/Calib/AliTPCcalibAlign.cxx
TPC/Calib/AliTPCcalibAlign.h
TPC/Calib/AliTPCcalibBase.cxx
TPC/Calib/AliTPCcalibBase.h
TPC/Calib/AliTPCcalibCalib.cxx
TPC/Calib/AliTPCcalibCalib.h
TPC/Calib/AliTPCcalibCosmic.cxx
TPC/Calib/AliTPCcalibCosmic.h
TPC/Calib/AliTPCcalibGainMult.cxx
TPC/Calib/AliTPCcalibGainMult.h
TPC/Calib/AliTPCcalibLaser.cxx
TPC/Calib/AliTPCcalibLaser.h
TPC/Calib/AliTPCcalibTime.cxx
TPC/Calib/AliTPCcalibTime.h
TPC/Calib/AliTPCcalibTimeGain.cxx
TPC/Calib/AliTPCcalibTimeGain.h
TPC/Calib/AliTPCcalibTracks.cxx
TPC/Calib/AliTPCcalibTracks.h
TPC/Calib/AliTPCcalibTracksCuts.cxx
TPC/Calib/AliTPCcalibTracksCuts.h
TPC/Calib/AliTPCcalibTracksGain.h
TPC/Calib/AliTPCcalibV0.cxx
TPC/Calib/AliTPCcalibV0.h
TPC/Rec/AliTPCseed.cxx
TPC/Rec/AliTPCseed.h
TPC/TPCcalibLinkDef.h

index 9ba3e8860938cd21c08b1221880903be5623ba9a..c1f004dde5e8fef0245d140ae0566c146f0e80e7 100644 (file)
@@ -54,6 +54,8 @@
 #include "AliVEventPool.h"
 #include "AliSysInfo.h"
 #include "AliAnalysisStatistics.h"
+#include "AliVEvent.h"
+#include "AliHLTTestInputHandler.h"
 
 using std::ofstream;
 using std::ios;
@@ -2296,7 +2298,7 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option)
          return;
       }   
       cont->SetData(fTree); // This set activity for all tasks reading only from the top container
-      Long64_t entry = fTree->GetTree()->GetReadEntry();      
+      Long64_t entry = fTree->GetTree()->GetReadEntry();
 //
 //    Call BeginEvent() for optional input/output and MC services 
       if (fInputEventHandler)   fInputEventHandler  ->BeginEvent(entry);
@@ -2315,7 +2317,7 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option)
       Int_t itask = 0;
       while ((task=(AliAnalysisTask*)next1())) {
          task->SetActive(kTRUE);
-         if (fDebug >1) {
+         if (fDebug >1) {
             cout << "    Executing task " << task->GetName() << endl;
          }
          if (fStatistics) fStatistics->StartTimer(GetTaskIndex(task), task->GetName(), task->ClassName());
@@ -2953,3 +2955,26 @@ void AliAnalysisManager::Changed()
 // in case the lock was set.
    if (fLocked) Fatal("Changed","Critical setter called in locked mode");
 }
+
+//______________________________________________________________________________
+void AliAnalysisManager::InitInputData(AliVEvent* esdEvent, AliVfriendEvent* esdFriend)
+{
+
+// Method to propagte to all the connected tasks the HLT event.
+// This method expects that the input hanlder is of type HLT, should 
+// not be used otherwise
+
+  if (fInputEventHandler)  {
+    TString classInputHandler = fInputEventHandler->ClassName();
+    if (classInputHandler.Contains("HLT")){
+      TObjArray* arrTasks = GetTasks();
+      fInputEventHandler->InitTaskInputData(esdEvent, esdFriend, arrTasks);
+    }
+    else {
+      Fatal("PropagateHLTEvent", "Input Handler not of type HLT, we cannot use this method!");
+    }
+  }
+  else {
+    Fatal("PropagateHLTEvent", "Input Handler not found, we cannot use this method!");
+  }
+}
index 941388ac4abbaf94cb6ee86a52fb2c9f31371f0c..dddb3719bb80eec69ed70facecb031b9c14a9c98 100644 (file)
@@ -36,7 +36,8 @@ class AliVEventHandler;
 class AliVEventPool;
 class AliAnalysisGrid;
 class AliAnalysisStatistics;
-
+class AliVfriendEvent;
+class AliVEvent;
 
 class AliAnalysisManager : public TNamed {
 
@@ -229,6 +230,7 @@ enum EAliAnalysisFlags {
    void                 Lock();
    void                 UnLock();
    void                 Changed();
+   void                 InitInputData(AliVEvent* esdEvent, AliVfriendEvent* esdFriend);
 protected:
    void                 CreateReadCache();
    void                 ImportWrappers(TList *source);
@@ -290,6 +292,6 @@ private:
    static TString          fgCommonFileName;     //! Common output file name (not streamed)
    static TString          fgMacroNames;         //! Loaded macro names
    static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
-   ClassDef(AliAnalysisManager,20)  // Analysis manager class
+   ClassDef(AliAnalysisManager, 21)  // Analysis manager class
 };   
 #endif
index b9d18f5b11f49cf53481372afc6bf1afad415c2b..3873dcf5c6bafc6ccefaafa28bddd2c0eca85c1a 100644 (file)
@@ -182,7 +182,7 @@ void AliAnalysisSelector::RestoreAnalysisManager()
             fAnalysis->SetSelector(this);
             if (fAnalysis->GetDebugLevel()>1) {
                cout << "->AliAnalysisSelector->RestoreAnalysisManager: Analysis manager restored" << endl;
-            }   
+            }
             break;
          }
       }
index 5f41560a1b870a745e24b6acfe2df08cd7fd9b0d..d7efbd75a1de856546550ebd5b53f8c853b0dfe1 100644 (file)
@@ -34,6 +34,12 @@ class AliAnalysisTask : public TTask {
     kTaskPostEventLoop = BIT(17)
   };
 
+  //=====================================================================
+  // === OVERLOAD THIS TO CONNECT TREE BRANCHES AT INPUT SLOTS. YOU
+  // SHOULD DEFINE HERE ALSO THE OBJECTS TO BE CONNECTED TO YOUR OUTPUTS
+  virtual void              ConnectInputData(Option_t *option="");
+  //=====================================================================
+  
  protected:
   Bool_t                    fReady;         // Flag if the task is ready
   Bool_t                    fInitialized;   // True if Init() was called
@@ -50,12 +56,6 @@ class AliAnalysisTask : public TTask {
   void                      DefineInput(Int_t islot, TClass *type);
   void                      DefineOutput(Int_t islot, TClass *type);
   
-  //=====================================================================
-  // === OVERLOAD THIS TO CONNECT TREE BRANCHES AT INPUT SLOTS. YOU
-  // SHOULD DEFINE HERE ALSO THE OBJECTS TO BE CONNECTED TO YOUR OUTPUTS
-  virtual void              ConnectInputData(Option_t *option="");
-  //=====================================================================
-  
   // Post output data (called by Exec() when data is ready)
   //=== CALL IN EXEC() FOR EACH OUTPUT WHEN READY ===
   Bool_t                    PostData(Int_t iout, TObject *data, Option_t *option="");
index 9eda232ba98ed61a5ebf6f9396a0d7934a0ecdd9..5e156e0e42779a9563021456aee5011a7d18bcae 100644 (file)
 #pragma link C++ class AliITStrackerHLT+;
 #pragma link C++ class AliHLTITSTrack+;
 #pragma link C++ class AliHLTITSQAComponent;
+//
+#pragma ling C++ class AliITSSAPAux;
+#pragma ling C++ class AliITSSAPLayer;
+#pragma ling C++ class AliITSSAPTracker;
+#pragma ling C++ class AliHLTITSSAPTrackerComponent;
+
 #endif
index ef79df17f6d986641d0ed3415f3887381c534c73..a2da3ddab7f2ccc36c18f8bbe273370738fdd2a4 100644 (file)
@@ -120,3 +120,23 @@ const char *AliHLTComponentBenchmark::GetStatistics()
   fStatistics+=")";
   return fStatistics.Data();
 }
+
+
+void AliHLTComponentBenchmark::GetStatisticsData( Double_t* statistics, TString* names )
+{
+  // !
+  if( fNEvents<=0 ) return ;
+
+  statistics[0] = fNEvents;
+  statistics[1] = fTotalInput/fNEvents;
+  statistics[2] = fTotalOutput/fNEvents;
+  
+  if( fNTimers<=0 ) return ;
+  
+  for( int i=0; i<fNTimers; i++ ){
+       names[i] = fNames[i];
+    statistics[3+i] = fTotalRealTime[i]/fNEvents*1.e3;
+       statistics[4+i] = fTotalCPUTime[i]/fNEvents*1.e3;    
+  }
+  return ;
+}
index a862e0b85ffc18148dfdc20adabfc2ab57c5fc2b..d2f55db0d702d792805aa0d13e576f577e4e42ae 100644 (file)
@@ -35,6 +35,18 @@ class AliHLTComponentBenchmark
   void AddInput( Double_t x );
   void AddOutput( Double_t x );
   const char *GetStatistics();
+  /**
+  *
+  * returns satistics:
+  * 0: number of events
+  * 1: input file size per event
+  * 2: output file size per event
+  * 3: ratio output/input
+  * 4+i: real time per event of counter i
+  * 5+i: cpu time per event of counter i
+  *
+  **/
+  void GetStatisticsData(Double_t* statistics, TString* names);
 
   private:
 
index 14bec23b2278b7e9cb7ea0e6c2f64f9bd845d88a..17bb1f7857f192b8de7a6eabca0f259b5d644181 100644 (file)
@@ -118,6 +118,18 @@ const AliHLTComponentDataType kAliHLTDataTypeV0Finder = AliHLTComponentDataTypeI
 const char kAliHLTESDObjectDataTypeIDstring[8] = kAliHLTESDObjectDataTypeID;
 const AliHLTComponentDataType kAliHLTDataTypeESDObject = AliHLTComponentDataTypeInitializer(kAliHLTESDObjectDataTypeIDstring, kAliHLTDataOriginAny);
 
+/** ESD friend data specification */
+const char kAliHLTESDfriendObjectDataTypeIDstring[8] = kAliHLTESDfriendObjectDataTypeID;
+const AliHLTComponentDataType kAliHLTDataTypeESDfriendObject = AliHLTComponentDataTypeInitializer(kAliHLTESDfriendObjectDataTypeIDstring, kAliHLTDataOriginAny);
+
+/** Flat ESD data specification */
+const char kAliHLTFlatESDDataTypeIDstring[8] = kAliHLTFlatESDDataTypeID;
+const AliHLTComponentDataType kAliHLTDataTypeFlatESD = AliHLTComponentDataTypeInitializer(kAliHLTFlatESDDataTypeIDstring, kAliHLTDataOriginAny);
+
+/** Flat ESD Vertex data specification */
+const char kAliHLTFlatESDVertexDataTypeIDstring[8] = kAliHLTFlatESDVertexDataTypeID;
+const AliHLTComponentDataType kAliHLTDataTypeFlatESDVertex = AliHLTComponentDataTypeInitializer(kAliHLTFlatESDVertexDataTypeIDstring, kAliHLTDataOriginAny);
+
 /** ESD content specification */
 const char kAliHLTESDContentDataTypeIDstring[8] = kAliHLTESDContentDataTypeID;
 const AliHLTComponentDataType kAliHLTDataTypeESDContent = AliHLTComponentDataTypeInitializer(kAliHLTESDContentDataTypeIDstring, kAliHLTDataOriginAny);
@@ -221,6 +233,9 @@ const AliHLTComponentDataType kAliHLTDataTypeJet = AliHLTComponentDataTypeInitia
 /** Container of HLT ITS tracks */
 const AliHLTComponentDataType fgkITSTracksDataType = AliHLTComponentDataTypeInitializer( "ITSTRACK", kAliHLTDataOriginITS );
 
+/** Container of HLT ITS SAP tracker data */
+const AliHLTComponentDataType kAliHLTDataTypeITSSAPData = AliHLTComponentDataTypeInitializer( "SAPTRACK", kAliHLTDataOriginITS );
+
 /** Container of HLT calorimeter clusters */
 const AliHLTComponentDataType kAliHLTDataTypeCaloCluster = AliHLTComponentDataTypeInitializer( "CALOCLUS", kAliHLTDataOriginAny );
 
index 0eb46050f6374ad02f870456ee0ccab4f1d97a34..ba19d88ebe9ad45f7923a4b1d0550232e3f0167f 100644 (file)
@@ -383,6 +383,26 @@ const int kAliHLTComponentDataTypefIDsize=8;
  */
 # define kAliHLTESDObjectDataTypeID    {'A','L','I','E','S','D','V','0'}
 
+/** ESD friend data block
+ * an AliESDfriend object of varying origin
+ * The 'V0' at the end allows a versioning
+ * @ingroup alihlt_component_datatypes
+ */
+# define kAliHLTESDfriendObjectDataTypeID    {'E','S','D','F','R','N','D','0'}
+
+/** Flat ESD Vertex data block
+ * The '0' at the end allows a versioning
+ * @ingroup alihlt_component_datatypes
+ */
+# define kAliHLTFlatESDVertexDataTypeID    {'F','L','A','T','V','T','X','0'}
+
+/** Flat ESD data block
+ * an AliFlatESD object of varying origin
+ * The '0' at the end allows a versioning
+ * @ingroup alihlt_component_datatypes
+ */
+# define kAliHLTFlatESDDataTypeID    {'F','L','A','T','E','S','D','0'}
+
 /** ESD 
  * data blocks designated for the ESD
  * @ingroup alihlt_component_datatypes
@@ -1099,11 +1119,26 @@ extern "C" {
    */
   extern const AliHLTComponentDataType kAliHLTDataTypeV0Finder;
 
+  /** flat ESD object data specification, origin is 'any' 
+   * @ingroup alihlt_component_datatypes
+   */
+  extern const AliHLTComponentDataType kAliHLTDataTypeFlatESD;
+
+  /** flat ESD vertex object data specification, origin is 'any' 
+   * @ingroup alihlt_component_datatypes
+   */
+  extern const AliHLTComponentDataType kAliHLTDataTypeFlatESDVertex;
+
   /** ESD object data specification, origin is 'any' 
    * @ingroup alihlt_component_datatypes
    */
   extern const AliHLTComponentDataType kAliHLTDataTypeESDObject;
 
+  /** ESD friend object data specification, origin is 'any' 
+   * @ingroup alihlt_component_datatypes
+   */
+  extern const AliHLTComponentDataType kAliHLTDataTypeESDfriendObject;
+
   /** ESD content data specification, origin is 'any' 
    * @ingroup alihlt_component_datatypes
    */
@@ -1270,6 +1305,11 @@ extern "C" {
    */  
   extern const AliHLTComponentDataType fgkITSTracksDataType;
 
+  /** Container of ITS SAP tracker data
+   * @ingroup alihlt_component_datatypes
+   */  
+  extern const AliHLTComponentDataType kAliHLTDataTypeITSSAPData;
+
   /** Container of calorimeter clusters
    * @ingroup alihlt_component_datatypes
    */  
index 5f8f166520f115d5c4bfd77e8db52f3e3a0c075c..21458759144a7a961a9f7ca5bcc2b5808399f88c 100644 (file)
 #--------------------------------------------------------------------------------#
 
 set ( CLASS_HDRS
+    AliHLTGlobalCompareFlatComponent.h
+    AliHLTGlobalFlatEsdTestComponent.h
+    AliHLTGlobalFlatEsdConverterComponent.h
+    AliHLTGlobalEsdToFlatConverterComponent.h
     AliHLTGlobalEsdConverterComponent.h
     AliHLTGlobalTrackMergerComponent.h
     AliHLTGlobalTrackMerger.h
@@ -44,6 +48,15 @@ set ( CLASS_HDRS
     AliHLTVertexFinderBase.h
     AliHLTPrimaryVertexFinderComponent.h
     AliHLTV0FinderComponent.h
+    AliFlatESDEvent.h
+    AliFlatESDVertex.h
+    AliFlatESDTrigger.h
+    AliFlatESDTrack.h
+    AliFlatESDV0.h
+    AliFlatESDFriend.h
+    AliFlatESDFriendTrack.h
+    AliFlatExternalTrackParam.h
+    AliFlatTPCseed.h
     physics/AliHLTV0HistoComponent.h
     physics/AliHLTCaloHistoComponent.h
     physics/AliHLTCaloHistoProducer.h
@@ -53,6 +66,8 @@ set ( CLASS_HDRS
     physics/AliHLTCaloHistoCellEnergy.h
     physics/AliHLTMultiplicityCorrelations.h
     physics/AliHLTMultiplicityCorrelationsComponent.h
+    physics/AliHLTAnaManagerComponent.h
+    physics/AliHLTFlatAnaManagerComponent.h
     )
 
 string ( REPLACE ".h" ".cxx" MODULE_SRCS "${CLASS_HDRS}" )
@@ -61,7 +76,7 @@ set ( MODULE_HDRS     ${CLASS_HDRS})
 
 set ( MODULE_DHDR )
 
-set ( EINCLUDE  HLT/global HLT/global/physics HLT/BASE HLT/BASE/util TPC RAW TRD PHOS STEER/ESD STEER/STEERBase ANALYSIS)
+set ( EINCLUDE  HLT/global HLT/global/physics HLT/BASE HLT/BASE/util HLT/TPCLib TPC RAW TRD PHOS STEER/ESD STEER/STEERBase ANALYSIS)
 
 set ( ELIBS  "HLTbase AliHLTUtil CDB ESD STEER STEERBase TPCrec TPCcalib TPCbase RAWDatarec RAWDatabase TRDbase -lEG")
 
index 07b7fcc68a0d079b1ab81fd291fada84a1273053..a8febf33500606e22d7fe361c6394d9dbbca6c70 100644 (file)
@@ -47,6 +47,10 @@ set ( CLASS_HDRS
     clusterfinders/AliHLTITSClusterFinderSPD.h
     clusterfinders/AliHLTITSClusterFinderSSD.h
     AliHLTITSVertexerSPDComponent.h
+    trackingSAP/AliITSSAPLayer.h
+    trackingSAP/AliITSSAPAux.h
+    trackingSAP/AliITSSAPTracker.h
+    trackingSAP/AliHLTITSSAPTrackerComponent.h
     )
 
 string ( REPLACE ".h" ".cxx" MODULE_SRCS "${CLASS_HDRS}" )
@@ -55,7 +59,7 @@ set ( MODULE_HDRS     ${CLASS_HDRS} AliHLTITSSpacePointData.h AliHLTITSClusterData
 
 set ( MODULE_DHDR )
 
-set ( EINCLUDE  HLT/BASE HLT/BASE/util HLT/ITS HLT/TPCLib HLT/ITS/tracking HLT/ITS/clusterfinders ITS RAW STEER/STEER STEER/ESD STEER/STEERBase)
+set ( EINCLUDE  HLT/BASE HLT/BASE/util HLT/ITS HLT/TPCLib HLT/ITS/tracking HLT/ITS/trackingSAP HLT/ITS/clusterfinders ITS RAW STEER/STEER STEER/ESD STEER/STEERBase)
 
 set ( ELIBS  "HLTbase AliHLTUtil RAWDatarec RAWDatabase ITSrec ITSbase ESD STEER STEERBase -lEG")
 
index 25c06ce5cd92ecd2ddb5fd600af23d4d644c9512..c0d76e4d5abb2093f83dc111cd2b78866b17fa57 100644 (file)
@@ -35,6 +35,7 @@
 #include "AliHLTITSClusterFinderComponent.h"
 #include "AliHLTITSClusterHistoComponent.h"
 #include "AliHLTITSTrackerComponent.h"
+#include "AliHLTITSSAPTrackerComponent.h"
 #include "AliHLTITSVertexerSPDComponent.h"
 #include "AliHLTITSDigitPublisherComponent.h"
 
@@ -84,6 +85,7 @@ int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
   // to run on digits, a digit publisher needs to be implemented
 
   TString trackerInput="";
+  TString trackerSAPInput="";
   TString vertexerSPDInput="";
   if (rawReader || !runloader) {
     // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
@@ -119,6 +121,7 @@ int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
     // define the ITS tracker input
     //
     trackerInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
+    trackerSAPInput="ITS-SPD-CF ITS-SDD-CF ITS-SSD-CF";
   }
   else if (runloader && !rawReader) {
     // indicates AliSimulation with no RawReader available -> run on digits
@@ -146,6 +149,8 @@ int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
     // Currently there is a seg fault in the TTree access from the DigitClusterFinder
     // needs first to be investigated
     trackerInput="DigitClusterFinder";
+    trackerSAPInput="DigitClusterFinder";
+    vertexerSPDInput="DigitClusterFinder";
   }
 
   ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -171,6 +176,11 @@ int AliHLTITSAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
     }
     handler->CreateConfiguration("ITS-tracker","ITSTracker",trackerInput.Data(),"");
   }
+  
+  if( !trackerSAPInput.IsNull() ) trackerSAPInput+=" ";
+  trackerSAPInput+="ITS-SPD-vertexer";
+
+  handler->CreateConfiguration("ITS-SAPtracker","ITSSAPTracker",trackerSAPInput.Data(),"");
 
   return iResult;
 }
@@ -212,6 +222,7 @@ int AliHLTITSAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
   pHandler->AddComponent(new AliHLTITSClusterFinderComponent(AliHLTITSClusterFinderComponent::kClusterFinderDigits));
   pHandler->AddComponent(new AliHLTITSClusterHistoComponent);
   pHandler->AddComponent(new AliHLTITSTrackerComponent);
+  pHandler->AddComponent(new AliHLTITSSAPTrackerComponent);
   pHandler->AddComponent(new AliHLTITSVertexerSPDComponent);
   pHandler->AddComponent(new AliHLTITSDigitPublisherComponent);
 
index 9f3a52a83b544bdb06c27cdc31dadfab4da51e50..3cac629c5ee19be336305861b6fef425e43d1ff8 100644 (file)
@@ -135,6 +135,7 @@ void AliHLTITSVertexerSPDComponent::GetInputDataTypes( vector<AliHLTComponentDat
   // see header file for class documentation
   list.clear();
   list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD );
+  list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITS );
 }
 
 AliHLTComponentDataType AliHLTITSVertexerSPDComponent::GetOutputDataType()
@@ -413,7 +414,8 @@ int AliHLTITSVertexerSPDComponent::DoEvent
  
     // Read ITS SPD clusters
 
-    if ( iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ){
+    if ( ( iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) ||
+        ( iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITS) ) ) {
 
       AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr );
       int nClusters = inPtr->fSpacePointCnt;
@@ -664,7 +666,7 @@ int AliHLTITSVertexerSPDComponent::DoEvent
     double s = 400.E-4;
     double cov[6] = {s*s,0,s*s,0,0,s*s};
     AliESDVertex v(pos, cov, 0, fSumN[bestBin]);
-    PushBack( (TObject*) &v, kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS,0 );
+    PushBack( (TObject*) &v, kAliHLTDataTypeESDVertex|kAliHLTDataOriginITSSPD,0 );
 
     //cout<<"ITSVertexerSPD: vtx found "<<vtxX<<" "<<vtxY<<" "<<vtxZ<<endl;
   }
diff --git a/HLT/ITS/AliHLTSAPTrackerData.h b/HLT/ITS/AliHLTSAPTrackerData.h
new file mode 100644 (file)
index 0000000..3a328f2
--- /dev/null
@@ -0,0 +1,35 @@
+// $Id$
+//* 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                               *
+
+#ifndef ALIHLTITSSAPTRACKERDATA_H
+#define ALIHLTITSSAPTRACKERDATA_H
+
+#include "AliHLTDataTypes.h"
+#include "AliFlatExternalTrackParam.h"
+#include "AliHLTStdIncludes.h"
+
+struct AliHLTITSSAPTrackerData
+{ 
+  AliFlatExternalTrackParam paramOut;
+  AliFlatExternalTrackParam paramInw;
+  float chi2;
+  short ncl;
+  int   label;
+};
+
+typedef struct AliHLTITSSAPTrackerData AliHLTITSSAPTrackerData;
+
+struct AliHLTITSSAPTrackerDataContainer {
+  AliHLTUInt32_t fCount; // number of tracklets
+#if defined(__HP_aCC) || defined(__DECCXX) || defined(__SUNPRO_CC)
+  AliHLTITSSAPTrackerData fTracks[1]; // array of tracklets
+#else
+  AliHLTITSSAPTrackerData fTracks[0]; // array of tracklets
+#endif
+};
+
+typedef struct AliHLTITSSAPTrackerDataContainer AliHLTITSSAPTrackerDataContainer;
+
+#endif
diff --git a/HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.cxx b/HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.cxx
new file mode 100644 (file)
index 0000000..5d805cd
--- /dev/null
@@ -0,0 +1,482 @@
+// **************************************************************************
+// This file is property of and copyright by the ALICE HLT Project          *
+// ALICE Experiment at CERN, All rights reserved.                           *
+//                                                                          *
+// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
+//                  Ivan Kisel <kisel@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   AliHLTITSSAPTrackerComponent.h
+///  @author Ruben Shahoyan <ruben.shahoyan@cern.ch>
+///  @date   August 2014
+///  @brief  An ITS standalone primaries tracker/vertexer processing component for the HLT
+///  Adapted from HLT/ITS/tracking/AliHLTITSSAPTrackerComponent component
+
+/////////////////////////////////////////////////////
+//                                                 //
+// a ITS tracker processing component for the HLT  //
+//                                                 //
+/////////////////////////////////////////////////////
+
+#include "AliHLTITSSAPTrackerComponent.h"
+#include "AliHLTArray.h"
+#include "AliExternalTrackParam.h"
+#include "TStopwatch.h"
+#include "TMath.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliGeomManager.h"
+#include "TObjString.h"
+#include <TClonesArray.h>
+#include <TGeoGlobalMagField.h>
+#include "AliITSSAPTracker.h"
+#include "AliHLTITSSpacePointData.h"
+#include "AliHLTITSClusterDataFormat.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTExternalTrackParam.h"
+#include "AliGeomManager.h"
+#include "AliHLTTrackMCLabel.h"
+#include "AliITSRecPoint.h"
+#include "AliHLTSAPTrackerData.h"
+#include "AliHLTMessage.h"
+#include "AliFlatESDVertex.h"
+#include <map>
+
+using namespace std;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp( AliHLTITSSAPTrackerComponent )
+AliHLTITSSAPTrackerComponent::AliHLTITSSAPTrackerComponent()
+: fSolenoidBz( 0 ),
+  fBenchmark("ITSSAPTracker"),
+  fTracker(0),
+  fClusters(0)
+
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTITSSAPTrackerComponent::AliHLTITSSAPTrackerComponent( const AliHLTITSSAPTrackerComponent& )
+  :AliHLTProcessor(),
+   fSolenoidBz( 0 ),
+   fBenchmark("ITSSAPTracker"),
+   fTracker(0),
+   fClusters(0)
+{
+  // see header file for class documentation
+  HLTFatal( "copy constructor untested" );
+}
+
+AliHLTITSSAPTrackerComponent& AliHLTITSSAPTrackerComponent::operator=( const AliHLTITSSAPTrackerComponent& )
+{
+  // see header file for class documentation
+  HLTFatal( "assignment operator untested" );
+  return *this;
+}
+
+AliHLTITSSAPTrackerComponent::~AliHLTITSSAPTrackerComponent()
+{
+  // see header file for class documentation
+  delete fTracker;
+  delete fClusters;
+}
+
+//
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+//
+
+const char* AliHLTITSSAPTrackerComponent::GetComponentID()
+{
+  // see header file for class documentation
+  return "ITSSAPTracker";
+}
+
+void AliHLTITSSAPTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
+{
+  // see header file for class documentation
+  list.clear();
+  list.push_back( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS );
+  list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD );
+  list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD );
+  list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD );
+  list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITS );
+}
+
+AliHLTComponentDataType AliHLTITSSAPTrackerComponent::GetOutputDataType()
+{
+  // see header file for class documentation  
+  return kAliHLTMultipleDataType;
+}
+
+int AliHLTITSSAPTrackerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+  // see header file for class documentation  
+  tgtList.clear();
+  tgtList.push_back(kAliHLTDataTypeITSSAPData|kAliHLTDataOriginITS);
+  tgtList.push_back(kAliHLTDataTypeFlatESDVertex|kAliHLTDataOriginITS ); // RS??: is this correct?
+  return tgtList.size();
+}
+
+void AliHLTITSSAPTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // define guess for the output data size
+  constBase = 200;       // minimum size
+  inputMultiplier = 2.; // size relative to input
+}
+
+AliHLTComponent* AliHLTITSSAPTrackerComponent::Spawn()
+{
+  // see header file for class documentation
+  return new AliHLTITSSAPTrackerComponent;
+}
+
+void AliHLTITSSAPTrackerComponent::SetDefaultConfiguration()
+{
+  // Set default configuration for the CA tracker component
+  // Some parameters can be later overwritten from the OCDB
+
+  fSolenoidBz = -5.00668;
+  
+}
+
+int AliHLTITSSAPTrackerComponent::ReadConfigurationString(  const char* arguments )
+{
+  // Set configuration parameters for the CA tracker component from the string
+
+  int iResult = 0;
+  if ( !arguments ) return iResult;
+
+  TString allArgs = arguments;
+  TString argument;
+  int bMissingParam = 0;
+
+  TObjArray* pTokens = allArgs.Tokenize( " " );
+
+  int nArgs =  pTokens ? pTokens->GetEntries() : 0;
+
+  for ( int i = 0; i < nArgs; i++ ) {
+    argument = ( ( TObjString* )pTokens->At( i ) )->GetString();
+    if ( argument.IsNull() ) continue;
+
+    if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
+      if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
+      HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
+      continue;
+    }
+
+    HLTError( "Unknown option \"%s\"", argument.Data() );
+    iResult = -EINVAL;
+  }
+  delete pTokens;
+
+  if ( bMissingParam ) {
+    HLTError( "Specifier missed for parameter \"%s\"", argument.Data() );
+    iResult = -EINVAL;
+  }
+
+  return iResult;
+}
+
+
+int AliHLTITSSAPTrackerComponent::ReadCDBEntry( const char* cdbEntry, const char* chainId )
+{
+  // see header file for class documentation
+
+  const char* defaultNotify = "";
+
+  if ( !cdbEntry ) {
+    return 0;// need to add the HLT/ConfigITS/ITSTracker directory to cdb SG!!!
+    //cdbEntry = "HLT/ConfigITS/ITSTracker";
+    //defaultNotify = " (default)";
+    //chainId = 0;
+  }
+
+  HLTInfo( "configure from entry \"%s\"%s, chain id %s", cdbEntry, defaultNotify, ( chainId != NULL && chainId[0] != 0 ) ? chainId : "<none>" );
+  AliCDBEntry *pEntry = AliCDBManager::Instance()->Get( cdbEntry );//,GetRunNo());
+
+  if ( !pEntry ) {
+    HLTError( "cannot fetch object \"%s\" from CDB", cdbEntry );
+    return -EINVAL;
+  }
+
+  TObjString* pString = dynamic_cast<TObjString*>( pEntry->GetObject() );
+
+  if ( !pString ) {
+    HLTError( "configuration object \"%s\" has wrong type, required TObjString", cdbEntry );
+    return -EINVAL;
+  }
+
+  HLTInfo( "received configuration object string: \"%s\"", pString->GetString().Data() );
+
+  return  ReadConfigurationString( pString->GetString().Data() );
+}
+
+
+int AliHLTITSSAPTrackerComponent::Configure( const char* cdbEntry, const char* chainId, const char *commandLine )
+{
+  // Configure the component
+  // There are few levels of configuration,
+  // parameters which are set on one step can be overwritten on the next step
+
+  //* read hard-coded values
+
+  SetDefaultConfiguration();
+
+  //* read the default CDB entry
+
+  int iResult1 = ReadCDBEntry( NULL, chainId );
+
+  //* read magnetic field
+
+  fSolenoidBz = GetBz();
+
+  //* read the actual CDB entry if required
+
+  int iResult2 = ( cdbEntry ) ? ReadCDBEntry( cdbEntry, chainId ) : 0;
+
+  //* read extra parameters from input (if they are)
+
+  int iResult3 = 0;
+
+  if ( commandLine && commandLine[0] != '\0' ) {
+    HLTInfo( "received configuration string from HLT framework: \"%s\"", commandLine );
+    iResult3 = ReadConfigurationString( commandLine );
+  }
+
+  // Initialise the tracker here
+
+  return iResult1 ? iResult1 : ( iResult2 ? iResult2 : iResult3 );
+}
+
+
+
+int AliHLTITSSAPTrackerComponent::DoInit( int argc, const char** argv )
+{
+  // Configure the ITS tracker component
+
+  if ( fTracker ) return -EINPROGRESS;
+
+  if(AliGeomManager::GetGeometry()==NULL){
+    AliGeomManager::LoadGeometry();
+  }
+  AliGeomManager::ApplyAlignObjsFromCDB("ITS");
+
+  TString arguments = "";
+  for ( int i = 0; i < argc; i++ ) {
+    if ( !arguments.IsNull() ) arguments += " ";
+    arguments += argv[i];
+  }
+
+  int ret = Configure( NULL, NULL, arguments.Data() );
+
+  // Check field
+  if (!TGeoGlobalMagField::Instance()) {
+    HLTError("magnetic field not initialized, please set up TGeoGlobalMagField and AliMagF");
+    return -ENODEV;
+  }
+  fSolenoidBz=GetBz();
+
+  fTracker = new AliITSSAPTracker();
+  fTracker->Init();
+  fBenchmark.Reset();
+  fBenchmark.SetTimer(0,"total");
+  fBenchmark.SetTimer(1,"reco");
+  return ret;
+}
+
+
+int AliHLTITSSAPTrackerComponent::DoDeinit()
+{
+  // see header file for class documentation
+  delete fTracker;
+  fTracker = 0;
+  return 0;
+}
+
+
+
+int AliHLTITSSAPTrackerComponent::Reconfigure( const char* cdbEntry, const char* chainId )
+{
+  // Reconfigure the component from OCDB .
+
+  return Configure( cdbEntry, chainId, NULL );
+}
+
+
+
+int AliHLTITSSAPTrackerComponent::DoEvent
+(
+  const AliHLTComponentEventData& evtData,
+  const AliHLTComponentBlockData* blocks,
+  AliHLTComponentTriggerData& /*trigData*/,
+  AliHLTUInt8_t* outputPtr,
+  AliHLTUInt32_t& size,
+  vector<AliHLTComponentBlockData>& outputBlocks )
+{
+  //* process event
+
+  AliHLTUInt32_t maxBufferSize = size;
+  size = 0; // output size
+  
+  if (!IsDataEvent()) return 0;
+
+  if ( evtData.fBlockCnt <= 0 ) {
+    HLTWarning( "no blocks in event" );
+    return 0;
+  }
+
+  fBenchmark.StartNewEvent();
+  fBenchmark.Start(0);
+
+  // Event reconstruction in ITS
+
+  int iResult=0;
+
+
+  // Check if there is an SPD vertex
+  const AliESDVertex *vertexSPD = 0;
+
+  {
+    const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDVertex|kAliHLTDataOriginITSSPD);
+    if( iter != NULL  ) {
+      if( !( vertexSPD = dynamic_cast<AliESDVertex*>(const_cast<TObject*>( iter ) ) ) ){    
+       HLTError("ITS SPD vertex object is corrupted");
+       iResult = -EINVAL;    
+      }
+    }
+    else {
+      HLTWarning("No SPD vertex, skip ITS standalone reconstruction");
+      return 0;
+    }
+  }  
+
+  int nBlocks = evtData.fBlockCnt;
+  if (!fClusters) fClusters = new TClonesArray("AliITSRecPoint",1000);
+  //
+  int nClTotal = 0;
+  for (int ndx=0; ndx<nBlocks && iResult>=0; ndx++) {
+
+    const AliHLTComponentBlockData* iter = blocks+ndx;
+    
+    // Read ITS clusters
+
+    if ( (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD) ) || 
+        (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD) ) ||
+        (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD) ) ||
+        (iter->fDataType == (kAliHLTDataTypeClusters|kAliHLTDataOriginITS) ) 
+        ){
+      
+      fBenchmark.AddInput(iter->fSize);
+
+      AliHLTITSClusterData *inPtr=reinterpret_cast<AliHLTITSClusterData*>( iter->fPtr );
+      int nClusters = inPtr->fSpacePointCnt;
+      for( int icl=0; icl<nClusters; icl++ ){
+       AliHLTITSSpacePointData &d = inPtr->fSpacePoints[icl];
+
+       Int_t lab[4] = { d.fTracks[0], d.fTracks[1], d.fTracks[2], d.fIndex };
+       Int_t info[3] = { d.fNy, d.fNz, d.fLayer };
+       Float_t hit[6] = { d.fY, d.fZ, d.fSigmaY2, d.fSigmaZ2, d.fQ, d.fSigmaYZ };
+       if( d.fLayer==4 ) hit[5] = -hit[5];
+       // tracker does not out the clusters, add them to transient array
+       fTracker->AddCluster( new((*fClusters)[nClTotal++]) AliITSRecPoint(lab,hit,info) );
+      }   
+    }
+    
+  }// end read input blocks
+  
+  // Reconstruct the event
+  
+  fBenchmark.Start(1);
+  fTracker->SetSPDVertex(vertexSPD);
+  fTracker->ProcessEvent();
+  fBenchmark.Stop(1);
+
+  
+  // Fill output tracks
+  int nAddedTracks = 0;
+  {  
+    int nFoundTracks = fTracker->GetNTracks();
+    AliHLTUInt32_t blockSize = sizeof(AliHLTITSSAPTrackerDataContainer) + nFoundTracks*sizeof(AliHLTITSSAPTrackerData);
+    if( size + blockSize + AliFlatESDVertex::GetSize() > maxBufferSize ){      
+      HLTWarning( "Output buffer size exceed (buffer size %d, current size %d), %d tracks are not stored", 
+                 maxBufferSize, size + blockSize, nFoundTracks);
+      iResult = -ENOSPC;
+    }    
+    if( iResult>=0 ){
+      blockSize = sizeof(AliHLTITSSAPTrackerDataContainer);
+      AliHLTITSSAPTrackerDataContainer *data = reinterpret_cast<AliHLTITSSAPTrackerDataContainer*>(outputPtr);
+      data->fCount=0;
+      for (int itr=0;itr<nFoundTracks;itr++) {
+       const AliITSSAPTracker::ITStrack_t& track = fTracker->GetTrack(itr);
+       // the track is just a struct of 2 AliExternalTrackParams (params at vertex and at the outer ITS layer)
+       // + some extra info, see "struct ITStrack" in the AliITSSAPTracker.h
+       if ( track.paramOut.TestBit(AliITSSAPTracker::kInvalidBit) || 
+            track.paramInw.TestBit(AliITSSAPTracker::kInvalidBit)) continue;
+       // use only those tracks whose both inward and outward params are OK.
+       AliHLTITSSAPTrackerData &trcHLT = data->fTracks[data->fCount];
+       trcHLT.paramOut.SetExternalTrackParam(&track.paramOut);
+       trcHLT.paramInw.SetExternalTrackParam(&track.paramInw);
+       trcHLT.chi2 = track.chi2;
+       trcHLT.ncl  = track.ncl;
+       trcHLT.label = track.label;
+       data->fCount++;
+       blockSize += sizeof(AliHLTITSSAPTrackerData);
+       nAddedTracks++;
+      }
+      
+      AliHLTComponentBlockData resultData;
+      FillBlockData( resultData );
+      resultData.fOffset = size;
+      resultData.fSize = blockSize;      
+      resultData.fDataType = kAliHLTDataTypeITSSAPData|kAliHLTDataOriginITS;
+      fBenchmark.AddOutput(resultData.fSize);
+      outputBlocks.push_back( resultData );
+      size += resultData.fSize;
+    }
+  }
+
+  Bool_t vtxOK = kFALSE;
+  { // Fill output vertexTracks  
+    AliESDVertex& vtxTracks = fTracker->GetTrackVertex();
+    if ( iResult>=0 && vtxTracks.GetStatus()==1 ) {
+      AliFlatESDVertex *flatVtx = reinterpret_cast<AliFlatESDVertex*>( outputPtr + size );
+      flatVtx->SetFromESDVertex( vtxTracks );
+      AliHLTComponentBlockData resultData;
+      FillBlockData( resultData );
+      resultData.fOffset = size;
+      resultData.fSize = flatVtx->GetSize();      
+      resultData.fDataType = kAliHLTDataTypeFlatESDVertex|kAliHLTDataOriginITS;
+      fBenchmark.AddOutput(resultData.fSize);
+      outputBlocks.push_back( resultData );
+      size += resultData.fSize;
+      vtxOK = kTRUE;
+    }
+  }
+  //
+  fTracker->Clear();
+  fClusters->Clear();
+  //  
+  fBenchmark.Stop(0);
+
+  // Set log level to "Warning" for on-line system monitoring
+  HLTWarning( "ITS SAP Tracker: output %d tracks;  input %d clusters, VertexTracks: %s",
+          nAddedTracks, nClTotal, vtxOK ? "OK" : "Found" );
+
+  HLTInfo(fBenchmark.GetStatistics());
+  return iResult;
+}
diff --git a/HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.h b/HLT/ITS/trackingSAP/AliHLTITSSAPTrackerComponent.h
new file mode 100644 (file)
index 0000000..22c9886
--- /dev/null
@@ -0,0 +1,156 @@
+//-*- Mode: C++ -*-
+// $Id$
+// ************************************************************************
+// 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   AliHLTITSSAPTrackerComponent.h
+///  @author Ruben Shahoyan <ruben.shahoyan@cern.ch>
+///  @date   August 2014
+///  @brief  An ITS standalone primaries tracker/vertexer processing component for the HLT
+///  Adapted from HLT/ITS/tracking/AliHLTITSTrackerComponent component
+
+#ifndef ALIHLTITSSAPTRACKERCOMPONENT_H
+#define ALIHLTITSSAPTRACKERCOMPONENT_H
+
+#include "AliHLTProcessor.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTComponentBenchmark.h"
+class AliITSSAPTracker;
+class TClonesArray;
+
+/**
+ * @class AliHLTITSSAPTrackerComponent
+ * The HL ITS standalone primaries tracker/vertexer component.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b ITSSAPTracker                              <br>
+ * Library: \b libAliHLTITS.so                              <br>
+ * Input Data Types:                                        <br> 
+ *    kAliHLTDataTypeTrack|kAliHLTDataOriginTPC             <br>
+ *    kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD       <br>
+ *    kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD       <br>
+ *    kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD       <br>
+ *      
+ * Output Data Types:                                       <br>
+ *    kAliHLTDataTypeTrack|kAliHLTDataOriginITS             <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Optional arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -config1      <i> teststring   </i> <br>
+ *      a configuration argument with one parameter
+ * \li -config2                            <br>
+ *      a configuration argument without parameters
+ *
+ * <h2>Default CDB entries:</h2>
+ *
+ * ITS/Align/Data
+ * ITS/Calib/SPDNoisy
+ * ITS/Calib/SPDDead
+ * ITS/Calib/PITConditions
+ * ITS/Calib/CalibSDD
+ * ITS/Calib/RespSDD
+ * ITS/Calib/DriftSpeedSDD
+ * ITS/Calib/DDLMapSDD
+ * ITS/Calib/MapsTimeSDD
+ * ITS/Calib/NoiseSSD
+ * ITS/Calib/GainSSD
+ * ITS/Calib/BadChannelsSSD
+ * ITS/Calib/RecoParam
+ *
+ * <h2>Performance:</h2>
+ * TODO
+ *
+ * <h2>Memory consumption:</h2>
+ * TODO
+ *
+ * <h2>Output size:</h2>
+ * TODO
+ * 
+ * @ingroup alihlt_its_components
+ */
+class AliHLTITSSAPTrackerComponent : public AliHLTProcessor
+{
+public:
+  /** standard constructor */
+  AliHLTITSSAPTrackerComponent();
+
+  /** dummy copy constructor, defined according to effective C++ style */
+  AliHLTITSSAPTrackerComponent( const AliHLTITSSAPTrackerComponent& );
+
+  /** dummy assignment op, but defined according to effective C++ style */
+  AliHLTITSSAPTrackerComponent& operator=( const AliHLTITSSAPTrackerComponent& );
+
+  /** standard destructor */
+  virtual ~AliHLTITSSAPTrackerComponent();
+
+  // Public functions to implement AliHLTComponent's interface.
+  // These functions are required for the registration process
+
+  /** @see component interface @ref AliHLTComponent::GetComponentID */
+  const char* GetComponentID() ;
+
+  /** @see component interface @ref AliHLTComponent::GetInputDataTypes */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list )  ;
+
+  /** @see component interface @ref AliHLTComponent::GetOutputDataType */
+  AliHLTComponentDataType GetOutputDataType() ;
+
+  /** @see component interface @ref AliHLTComponent::GetOutputDataType */
+  int  GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+
+  /** @see component interface @ref AliHLTComponent::GetOutputDataSize */
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) ;
+
+  /** @see component interface @ref AliHLTComponent::Spawn */
+  AliHLTComponent* Spawn() ;
+
+protected:
+
+  // Protected functions to implement AliHLTComponent's interface.
+  // These functions provide initialization as well as the actual processing
+  // capabilities of the component.
+
+  /** @see component interface @ref AliHLTComponent::DoInit */
+  int DoInit( int argc, const char** argv );
+
+  /** @see component interface @ref AliHLTComponent::DoDeinit */
+  int DoDeinit();
+
+  /** reconfigure **/
+  int Reconfigure( const char* cdbEntry, const char* chainId );
+
+  /** @see component interface @ref AliHLTProcessor::DoEvent */
+  int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
+              AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
+              AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
+
+private:
+
+  /** magnetic field */
+  double fSolenoidBz;                                            // see above
+  AliHLTComponentBenchmark fBenchmark;// benchmark
+  AliITSSAPTracker *fTracker; // the tracker itself
+
+  /** set configuration parameters **/
+  void SetDefaultConfiguration();
+  int ReadConfigurationString(  const char* arguments );
+  int ReadCDBEntry( const char* cdbEntry, const char* chainId );
+  int Configure( const char* cdbEntry, const char* chainId, const char *commandLine  );
+
+  TClonesArray* fClusters;
+
+  ClassDef( AliHLTITSSAPTrackerComponent, 0 );
+
+};
+#endif
diff --git a/HLT/ITS/trackingSAP/AliITSSAPAux.cxx b/HLT/ITS/trackingSAP/AliITSSAPAux.cxx
new file mode 100644 (file)
index 0000000..3cfc936
--- /dev/null
@@ -0,0 +1,10 @@
+#include "AliITSSAPAux.h"
+#include <stdio.h>
+
+//_______________________________________________________________
+void AliITSSAPAux::PrintBits(unsigned long long patt, int maxBits)
+{
+  // print maxBits of the pattern
+  maxBits = maxBits>64 ? 64:maxBits;
+  for (int i=0;i<maxBits;i++) printf("%c",((patt>>i)&0x1) ? '+':'-');
+}
diff --git a/HLT/ITS/trackingSAP/AliITSSAPAux.h b/HLT/ITS/trackingSAP/AliITSSAPAux.h
new file mode 100644 (file)
index 0000000..01cf41f
--- /dev/null
@@ -0,0 +1,168 @@
+#ifndef ALIITSSAPAUX_H
+#define ALIITSSAPAUX_H
+
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+//  Namespace AliITSSAPAux                                             //
+//  Set of utilities for the XXX classes                            //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+
+namespace AliITSSAPAux {
+  void   BringTo02Pi(double &phi);
+  void   BringTo02Pi(float  &phi);
+  bool   OKforPhiMin(double phiMin,double phi);
+  bool   OKforPhiMax(double phiMax,double phi);
+  double MeanPhiSmall(double phi0, double phi1);
+  double DeltaPhiSmall(double phi0, double phi1);
+  //
+  bool   OKforPhiMin(float phiMin,float phi);
+  bool   OKforPhiMax(float phiMax,float phi);
+  float  MeanPhiSmall(float phi0, float phi1);
+  float  DeltaPhiSmall(float phi0, float phi1);
+
+  unsigned int PackCluster(int lr, int clID);
+  int    UnpackCluster(unsigned int p, int &lr);
+  int    UnpackLayer(unsigned int p);
+  int    UnpackCluster(unsigned int p);
+  bool   IsCluster(unsigned int p);
+  int    NumberOfBitsSet(unsigned int x);
+  void   PrintBits(unsigned long long patt, int maxBits);
+  //
+  const double   kNominalBz = 5.01;           // nominal field
+  const double   kPionMass  = 1.3957e-01;
+  const double   kPi  = 3.14159265358979312e+00;
+  const double   k2Pi = 2*kPi;
+  const unsigned int   kLrBitLow  = 28;             // layer mask lowest bit
+  const unsigned int   kLrMask    = 0xf0000000;     // layer mask
+  const unsigned int   kClMask    = 0x0fffffff;     // cluster mask
+  const unsigned int   kMaxLayers = 15;             // max number of active layers
+  const unsigned int   kMaxLrMask = 0x7fff;         // bitmask for allowed layers
+}
+
+//_________________________________________________________________________________
+inline void AliITSSAPAux::BringTo02Pi(double &phi) {   
+  // bring phi to 0-2pi range
+  if (phi<0) phi+=k2Pi; else if (phi>k2Pi) phi-=k2Pi;
+}
+
+//_________________________________________________________________________________
+inline void AliITSSAPAux::BringTo02Pi(float &phi) {   
+  // bring phi to 0-2pi range
+  if (phi<0) phi+=k2Pi; else if (phi>k2Pi) phi-=k2Pi;
+}
+
+//_________________________________________________________________________________
+inline bool AliITSSAPAux::OKforPhiMin(double phiMin,double phi) {
+  // check if phi is above the phiMin, phi's must be in 0-2pi range
+  double dphi = phi-phiMin;
+  return ((dphi>0 && dphi<kPi) || dphi<-kPi) ? true:false;
+}
+
+//_________________________________________________________________________________
+inline bool AliITSSAPAux::OKforPhiMin(float phiMin,float phi) {
+  // check if phi is above the phiMin, phi's must be in 0-2pi range
+  float dphi = phi-phiMin;
+  return ((dphi>0 && dphi<kPi) || dphi<-kPi) ? true:false;
+}
+
+//_________________________________________________________________________________
+inline bool AliITSSAPAux::OKforPhiMax(double phiMax,double phi) {
+  // check if phi is below the phiMax, phi's must be in 0-2pi range
+  double dphi = phi-phiMax;
+  return ((dphi<0 && dphi>-kPi) || dphi>kPi) ? true:false;
+}
+
+//_________________________________________________________________________________
+inline bool AliITSSAPAux::OKforPhiMax(float phiMax,float phi) {
+  // check if phi is below the phiMax, phi's must be in 0-2pi range
+  float dphi = phi-phiMax;
+  return ((dphi<0 && dphi>-kPi) || dphi>kPi) ? true:false;
+}
+
+//_________________________________________________________________________________
+inline unsigned int AliITSSAPAux::PackCluster(int lr, int clID) {
+  // pack layer/cluster into single uint
+  unsigned int p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
+  return p;
+}
+
+//_________________________________________________________________________________
+inline int AliITSSAPAux::UnpackCluster(unsigned int p, int &lr) {
+  // unpack layer/cluster
+  lr = (p&kLrMask)>>kLrBitLow;
+  p &= kClMask;
+  return int(p)-1;
+}
+
+//_________________________________________________________________________________
+inline int AliITSSAPAux::UnpackLayer(unsigned int p) {
+  // unpack layer
+  return (p&kLrMask)>>kLrBitLow;
+}
+
+//_________________________________________________________________________________
+inline int AliITSSAPAux::UnpackCluster(unsigned int p) {
+  // unpack cluster
+  return int(p&kClMask)-1;
+}
+
+//_________________________________________________________________________________
+inline bool AliITSSAPAux::IsCluster(unsigned int p) {
+  // does it correspond to cluster?
+  return (p&kClMask);
+}
+
+//_________________________________________________________________________________
+inline int AliITSSAPAux::NumberOfBitsSet(unsigned int x) {
+  // count number of non-0 bits in 32bit word
+  x = x - ((x >> 1) & 0x55555555);
+  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+  return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
+}
+
+//_________________________________________________________________________________
+inline double AliITSSAPAux::MeanPhiSmall(double phi0, double phi1) {
+  // return mean phi, assume phis in 0:2pi
+  double phi;
+  if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
+  if (phi0>phi1) phi = (phi1 - (k2Pi-phi0))/2; // wrap
+  else           phi = (phi0+phi1)/2;
+  BringTo02Pi(phi);
+  return phi;
+}
+
+//_________________________________________________________________________________
+inline float AliITSSAPAux::MeanPhiSmall(float phi0, float phi1) {
+  // return mean phi, assume phis in 0:2pi
+  float phi;
+  if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
+  if (phi0>phi1) phi = (phi1 - (k2Pi-phi0))/2; // wrap
+  else           phi = (phi0+phi1)/2;
+  BringTo02Pi(phi);
+  return phi;
+}
+
+//_________________________________________________________________________________
+inline double AliITSSAPAux::DeltaPhiSmall(double phi0, double phi1) {
+  // return delta phi, assume phis in 0:2pi
+  double del;
+  if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
+  del = phi1 - phi0;
+  if (del<0) del += k2Pi;
+  return del;
+}
+
+//_________________________________________________________________________________
+inline float AliITSSAPAux::DeltaPhiSmall(float phi0, float phi1) {
+  // return delta phi, assume phis in 0:2pi
+  float del;
+  if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
+  del = phi1 - phi0;
+  if (del<0) del += k2Pi;
+  return del;
+}
+
+
+#endif
diff --git a/HLT/ITS/trackingSAP/AliITSSAPLayer.cxx b/HLT/ITS/trackingSAP/AliITSSAPLayer.cxx
new file mode 100644 (file)
index 0000000..cde288f
--- /dev/null
@@ -0,0 +1,327 @@
+#include <TMath.h>
+#include "AliITSSAPLayer.h"
+#include "AliITSSAPAux.h"
+#include "AliITSRecPoint.h"
+#include "AliITSgeomTGeo.h"
+#include "AliVertex.h"
+#include <TRandom.h>
+#include <TStopwatch.h>
+#include <TString.h>
+
+
+using namespace AliITSSAPAux;
+
+//_________________________________________________________________
+AliITSSAPLayer::AliITSSAPLayer() :
+  fClusters(0)
+  ,fLrID(-1)
+  ,fVIDOffset(0)
+  ,fNClusters(0)
+  ,fZMin(0)
+  ,fZMax(0)
+  ,fDZInv(-1)
+  ,fDPhiInv(-1)
+  ,fNZBins(20)
+  ,fNPhiBins(20)
+  ,fQueryZBmin(-1)
+  ,fQueryZBmax(-1)
+  ,fQueryPhiBmin(-1)
+  ,fQueryPhiBmax(-1)
+  ,fBins(0)
+  ,fOccBins(0)
+  ,fNOccBins(0)
+  ,fNFoundClusters(0)
+  ,fFoundClusterIterator(0)
+  ,fFoundBinIterator(0)
+  ,fFoundBins()
+  ,fSortedClInfo()
+  ,fDetectors()
+{
+  // def. c-tor
+}
+
+//_________________________________________________________________
+AliITSSAPLayer::AliITSSAPLayer(int id, float zspan,int nzbins,int nphibins, int buffer) :
+  fClusters(0)
+  ,fLrID(id)
+  ,fVIDOffset((id+1)*2048)
+  ,fNClusters(0)
+  ,fZMin(-zspan)
+  ,fZMax(zspan)
+  ,fDZInv(-1)
+  ,fDPhiInv(-1)
+  ,fNZBins(nzbins)
+  ,fNPhiBins(nphibins)
+  ,fQueryZBmin(-1)
+  ,fQueryZBmax(-1)
+  ,fQueryPhiBmin(-1)
+  ,fQueryPhiBmax(-1)
+  ,fBins(0)
+  ,fOccBins(0)
+  ,fNOccBins(0)
+  ,fNFoundClusters(0)
+  ,fFoundClusterIterator(0)
+  ,fFoundBinIterator(0)
+  ,fFoundBins()
+  ,fSortedClInfo()
+  ,fDetectors()
+{
+  // c-tor
+  Init(buffer);
+}
+
+//_________________________________________________________________
+AliITSSAPLayer::~AliITSSAPLayer()
+{
+  // d-tor
+  delete[] fBins;
+  delete[] fOccBins;
+  delete fClusters;
+}
+
+//_________________________________________________________________
+void AliITSSAPLayer::Init(int buffer)
+{
+  if (fClusters) {
+    printf("Already initialized\n");
+    return;
+  }
+  if (fNZBins<1)   fNZBins = 2;
+  if (fNPhiBins<1) fNPhiBins = 1;
+  fDZInv   = fNZBins/(fZMax-fZMin);
+  fDPhiInv = fNPhiBins/TMath::TwoPi();
+  //
+  fBins = new ClBinInfo_t[fNZBins*fNPhiBins];
+  fOccBins = new int[fNZBins*fNPhiBins];
+  if (buffer<100) buffer = 100;
+  fClusters = new TObjArray(buffer);
+  fSortedClInfo.reserve(buffer);
+  //
+  // prepare detectors info
+  int id1 = fLrID+1;
+  Int_t nlad=AliITSgeomTGeo::GetNLadders(id1);
+  Int_t ndet=AliITSgeomTGeo::GetNDetectors(id1);
+  int detID = 0;
+  for (Int_t j=1; j<nlad+1; j++) {
+    for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
+      ITSDetInfo_t det;
+      det.index = detID++;
+      //
+      TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(id1,j,k,m);
+      const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(id1,j,k);
+      m.Multiply(tm);
+      Double_t txyz[3] = {0.}, xyz[3] = {0.};
+      m.LocalToMaster(txyz,xyz);
+      det.xTF = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+      det.phiTF = TMath::ATan2(xyz[1],xyz[0]);
+      //BringTo02Pi(det.phiTF);
+      det.sinTF = TMath::Sin(det.phiTF);
+      det.cosTF = TMath::Cos(det.phiTF);
+      //
+      // compute the real radius (with misalignment)
+      TGeoHMatrix mmisal(*(AliITSgeomTGeo::GetMatrix(id1,j,k)));
+      mmisal.Multiply(tm);
+      xyz[0]=0.;xyz[1]=0.;xyz[2]=0.;
+      mmisal.LocalToMaster(txyz,xyz);
+      det.xTFmisal=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);      
+      //
+      fDetectors.push_back(det);
+    } // end loop on detectors
+  } // end loop on ladders 
+
+}
+
+//_________________________________________________________________
+void AliITSSAPLayer::SortClusters(const AliVertex* vtx)
+{
+  // sort clusters and build fast lookup table
+  //
+  ClearSortedInfo();
+  fSortedClInfo.reserve(fNClusters);
+  //
+  ClsInfo_t cl;
+  for (int icl=fNClusters;icl--;) {
+    AliITSRecPoint* cluster = (AliITSRecPoint*)fClusters->UncheckedAt(icl);
+    cluster->GetGlobalXYZ( (float*)&cl );
+    //
+    if (vtx) { // phi and r will be computed wrt vertex
+      cl.x -= vtx->GetX();
+      cl.y -= vtx->GetY();
+    }
+    //
+    cl.r = TMath::Sqrt(cl.x*cl.x + cl.y*cl.y);
+    cl.phi = TMath::ATan2(cl.y,cl.x);
+    BringTo02Pi(cl.phi);
+    cl.index = icl;
+    cl.zphibin = GetBinIndex(GetZBin(cl.z),GetPhiBin(cl.phi));
+    cl.detid = cluster->GetVolumeId() - fVIDOffset;
+    //
+    fSortedClInfo.push_back( cl );
+    //
+  }
+  sort(fSortedClInfo.begin(), fSortedClInfo.end()); // sort in phi, z
+  //
+  // fill cells in phi,z
+  int currBin = -1;
+  for (int icl=0;icl<fNClusters;icl++) {
+    ClsInfo_t &t = fSortedClInfo[icl]; 
+    if (t.zphibin>currBin) { // register new occupied bin
+      currBin = t.zphibin;
+      fBins[currBin].first = icl;
+      fBins[currBin].index = fNOccBins;
+      fOccBins[fNOccBins++] = currBin;
+    }
+    fBins[currBin].ncl++;
+  }
+  //  Print("clb"); //RS
+}
+
+//_________________________________________________________________
+void AliITSSAPLayer::Clear(Option_t *)
+{
+  // clear cluster info
+  ClearSortedInfo();
+  fNClusters = 0;
+  if (fClusters) fClusters->Clear();
+  //
+}
+
+//_________________________________________________________________
+void AliITSSAPLayer::ClearSortedInfo()
+{
+  // clear cluster info
+  fSortedClInfo.clear();
+  memset(fBins,0,fNZBins*fNPhiBins*sizeof(ClBinInfo_t));
+  memset(fOccBins,0,fNZBins*fNPhiBins*sizeof(int));
+  fNOccBins = 0;
+}
+
+//_________________________________________________________________
+void AliITSSAPLayer::Print(Option_t *opt) const
+{
+  // dump cluster bins info
+  TString opts = opt;
+  opts.ToLower();
+  printf("Stored %d clusters in %d occupied bins\n",fNClusters,fNOccBins);
+  //
+  if (opts.Contains("c")) {
+    printf("\nCluster info\n");
+    for (int i=0;i<fNClusters;i++) {
+      const ClsInfo_t &t = fSortedClInfo[i];
+      printf("#%5d Bin(phi/z):%03d/%03d Z:%+8.3f Phi:%+6.3f R:%7.3f Ind:%d ",
+            i,t.zphibin/fNZBins,t.zphibin%fNZBins,t.z,t.phi,t.r,t.index);
+      if (opts.Contains("l")) { // mc labels
+       AliITSRecPoint* rp = (AliITSRecPoint*)fClusters->UncheckedAt(t.index);
+       for (int l=0;l<3;l++) if (rp->GetLabel(l)>=0) printf("| %d ",rp->GetLabel(l));
+      }
+      printf("\n");
+    }
+  }
+  //
+  if (opts.Contains("b")) {
+    printf("\nBins info (occupied only)\n");
+    for (int i=0;i<fNOccBins;i++) {
+      printf("%4d %5d(phi/z: %03d/%03d) -> %3d cl from %d\n",i,fOccBins[i],fOccBins[i]/fNZBins,fOccBins[i]%fNZBins,
+            fBins[fOccBins[i]].ncl,fBins[fOccBins[i]].first);
+    }
+  }
+  //
+}
+//_____________________________________________________________
+int AliITSSAPLayer::SelectClusters(float zmin,float zmax,float phimin,float phimax)
+{
+  // prepare occupied bins in the requested region
+  //printf("Select: Z %f %f | Phi: %f %f\n",zmin,zmax,phimin,phimax);
+  if (!fNOccBins) return 0;
+  if (zmax<fZMin || zmin>fZMax || zmin>zmax) return 0;
+  fFoundBins.clear();
+
+  fQueryZBmin = GetZBin(zmin);
+  if (fQueryZBmin<0) fQueryZBmin = 0;
+  fQueryZBmax = GetZBin(zmax);
+  if (fQueryZBmax>=fNZBins) fQueryZBmax = fNZBins-1;
+  BringTo02Pi(phimin);
+  BringTo02Pi(phimax);
+  fQueryPhiBmin = GetPhiBin(phimin);
+  fQueryPhiBmax = GetPhiBin(phimax);
+  int dbz=0;
+  fNFoundClusters = 0;
+  int nbcheck = fQueryPhiBmax - fQueryPhiBmin + 1;
+  if (nbcheck>0) { // no wrapping around 0-2pi, fast case
+    for (int ip=fQueryPhiBmin;ip<=fQueryPhiBmax;ip++) {
+      int binID = GetBinIndex(fQueryZBmin,ip);
+      if ( !(dbz=(fQueryZBmax-fQueryZBmin)) ) { // just one Z bin in the query range 
+       ClBinInfo_t& binInfo = fBins[binID];
+       if (!binInfo.ncl) continue;
+       fNFoundClusters += binInfo.ncl;
+       fFoundBins.push_back(binID);
+       continue;
+      }
+      int binMax = binID+dbz;
+      for (;binID<=binMax;binID++) {
+       ClBinInfo_t& binInfo = fBins[binID];
+       if (!binInfo.ncl) continue;
+       fNFoundClusters += binInfo.ncl;
+       fFoundBins.push_back(binID);
+      }      
+    }
+  }
+  else {  // wrapping
+    nbcheck += fNPhiBins;
+    for (int ip0=0;ip0<=nbcheck;ip0++) {
+      int ip = fQueryPhiBmin+ip0;
+      if (ip>=fNPhiBins) ip -= fNPhiBins;
+      int binID = GetBinIndex(fQueryZBmin,ip);
+      if ( !(dbz=(fQueryZBmax-fQueryZBmin)) ) { // just one Z bin in the query range 
+       ClBinInfo_t& binInfo = fBins[binID];
+       if (!binInfo.ncl) continue;
+       fNFoundClusters += binInfo.ncl;
+       fFoundBins.push_back(binID);
+       continue;
+      }
+      int binMax = binID+dbz;
+      for (;binID<=binMax;binID++) {
+       ClBinInfo_t& binInfo = fBins[binID];
+       if (!binInfo.ncl) continue;
+       fNFoundClusters += binInfo.ncl;
+       fFoundBins.push_back(binID);
+      }
+    }
+  }
+  fFoundClusterIterator = fFoundBinIterator = 0;
+  /*
+  //printf("Selected -> %d cl in %d bins\n",fNFoundClusters,(int)fFoundBins.size());
+  for (int i=0;i<(int)fFoundBins.size();i++) {
+  int bn = fFoundBins[i];
+  ClBinInfo_t& bin=fBins[bn];
+  printf("#%d b:%d 1st: %3d Ncl:%d\n",i,bn,bin.first,bin.ncl);
+  }
+  printf("\n");
+  */
+  return fNFoundClusters;
+}
+
+//_____________________________________________________________
+int AliITSSAPLayer::GetNextClusterInfoID()
+{
+  if (fFoundBinIterator<0) return 0;
+  int currBin = fFoundBins[fFoundBinIterator];
+  if (fFoundClusterIterator<fBins[currBin].ncl) { // same bin
+    return fBins[currBin].first+fFoundClusterIterator++;
+  }
+  if (++fFoundBinIterator<int(fFoundBins.size())) {  // need to change bin
+    currBin = fFoundBins[fFoundBinIterator];
+    fFoundClusterIterator = 1;
+    return fBins[currBin].first;
+  }
+  fFoundBinIterator = -1;
+  return -1;
+}
+
+//_____________________________________________________________
+void AliITSSAPLayer::ResetFoundIterator()
+{
+  // prepare for a new loop over found clusters
+  if (fNFoundClusters)  fFoundClusterIterator = fFoundBinIterator = 0;
+}
diff --git a/HLT/ITS/trackingSAP/AliITSSAPLayer.h b/HLT/ITS/trackingSAP/AliITSSAPLayer.h
new file mode 100644 (file)
index 0000000..f409889
--- /dev/null
@@ -0,0 +1,145 @@
+#ifndef ALIITSSAPLAYER_H
+#define ALIITSSAPLAYER_H
+
+#include <algorithm>
+#include <vector>
+#include <TObject.h>
+#include <TObjArray.h>
+#include "AliITSRecPoint.h"
+class AliVertex;
+class AliITSSAPLayer 
+{
+
+ public:
+  struct ClsInfo   // cluster info, optionally XY origin at vertex
+  { 
+    float x,y,z,phi,r;    // lab params
+    int   zphibin; // bins is z,phi
+    int   index;          // index in RecPoints array
+    int   detid;          // detector index //RS ??? Do we need it?
+    bool operator<(const ClsInfo &rhs) const {return zphibin<rhs.zphibin;}
+    //
+  };
+  typedef struct ClsInfo ClsInfo_t;
+  //
+  struct ClBinInfo  // info on bin clusters start, number of clusters
+  {
+    unsigned short ncl;    // number of clusters
+    unsigned short first;  // entry of 1st cluster in sorted vector of ClsInfo
+    int            index;  // index in the vector containing cells with non-0 occupancy
+  };
+  typedef struct ClBinInfo ClBinInfo_t;
+  //
+  struct ITSDetInfo  // info on sensor
+  {
+    int index; // sensor vid
+    float xTF,xTFmisal,phiTF,sinTF,cosTF; //tracking frame parameters of the detector
+  };
+  typedef struct ITSDetInfo ITSDetInfo_t;
+
+
+  AliITSSAPLayer();
+  AliITSSAPLayer(int id, float zspan,int nzbins,int nphibins, int buffer=100);
+  virtual ~AliITSSAPLayer();
+  //
+  int     GetVIDOffset()                const {return fVIDOffset;}
+  int     GetNClusters()                const {return fNClusters;}
+  int     GetNZBins()                   const {return fNZBins;}
+  int     GetNPhiBins()                 const {return fNPhiBins;}
+  float   GetZMin()                     const {return fZMin;}
+  float   GetZMax()                     const {return fZMax;}
+  //
+  void    SetNZBins(int v)                    {fNZBins = v;}
+  void    SetNPhiBins(int v)                  {fNPhiBins = v;}
+  void    SetZMin(float v)                    {fZMin = v;}
+  void    SetZMax(float v)                    {fZMax = v;}
+  //
+  void Init(int buffer=100);
+  //
+  void AddCluster(AliITSRecPoint *cl)         {fClusters->AddAtAndExpand(cl,fNClusters++);}
+  //
+  void SortClusters(const AliVertex* vtx=0);
+  int  GetPhiBin(float phi)             const {return phi*fDPhiInv;}
+  int  GetZBin  (float z)               const {return (z-fZMin)*fDZInv;}
+  int  GetBinIndex(int iz, int iphi)    const {return iphi*fNZBins + iz;}
+  int  GetBinZ(int ipz)                 const {return ipz%fNZBins;}
+  int  GetBinPhi(int ipz)               const {return ipz/fNZBins;}
+  void GetBinZPhi(int ipz,int &iz,int &iphi) const {iz = GetBinZ(ipz); iphi=GetBinPhi(ipz);}
+  //
+  int  SelectClusters(float zmin,float zmax,float phimin,float phimax);
+  int  GetNFoundBins()                  const {return fFoundBins.size();}
+  int  GetFoundBin(int i)               const {return fFoundBins[i];}
+  int  GetFoundBinClusters(int i, int &first)  const;
+  void ResetFoundIterator();
+  AliITSSAPLayer::ClsInfo_t* GetClusterInfo(int i) const {return (AliITSSAPLayer::ClsInfo_t*)&fSortedClInfo[i];}
+  AliITSSAPLayer::ClsInfo_t* GetNextClusterInfo();
+  int                     GetNextClusterInfoID();
+  AliITSRecPoint*         GetNextCluster();
+  AliITSRecPoint*         GetClusterSorted(int i)   const {return (AliITSRecPoint*)fClusters->UncheckedAt(fSortedClInfo[i].index);}
+  AliITSRecPoint*         GetClusterUnSorted(int i) const {return (AliITSRecPoint*)fClusters->UncheckedAt(i);}
+  //
+  AliITSSAPLayer::ITSDetInfo_t& GetDetInfo(int id)     const {return (ITSDetInfo_t&)fDetectors[id];}
+  Int_t                   GetNDetectors()           const {return fDetectors.size();}
+
+  void         ClearSortedInfo();
+  virtual void Clear(Option_t *opt="");
+  virtual void Print(Option_t *opt="")  const;
+
+ private:
+  AliITSSAPLayer(const AliITSSAPLayer&);
+  AliITSSAPLayer& operator=(const AliITSSAPLayer&);
+  //
+ protected:
+  TObjArray* fClusters;       // externally supplied clusters
+  int   fLrID;                // layer id
+  int   fVIDOffset;           // offset of VID for detectors of this layer
+  int   fNClusters;           // N clusters
+  //
+  float fZMin;                // Zmin
+  float fZMax;                // Zmax
+  float fDZInv;               // inverse size of Z bin
+  float fDPhiInv;             // inverse size of Phi bin
+  int   fNZBins;             // N cells in Z
+  int   fNPhiBins;           // N cells in Phi
+  //
+  int   fQueryZBmin;         // min bin in Z of the query
+  int   fQueryZBmax;         // max bin in Z of the query
+  int   fQueryPhiBmin;       // min bin in phi of the query
+  int   fQueryPhiBmax;       // max bin in phi of the query
+  ClBinInfo_t* fBins;           // 2D (z,phi) grid of clusters binned in z,phi
+  int* fOccBins;              // id's of bins with non-0 occupancy
+  int  fNOccBins;             // number of occupied bins
+  int  fNFoundClusters;       // number of found clusters in the query zone
+  int  fFoundClusterIterator; // at which cluster within the bin we are?
+  int  fFoundBinIterator;     // at which foune bin we are?
+  std::vector<int>     fFoundBins;    // occupied bins satisfying to query
+  std::vector<ClsInfo_t> fSortedClInfo; // processed cluster info
+  std::vector<ITSDetInfo_t> fDetectors; // detector params
+  //
+};
+
+//_____________________________________________________ 
+inline int AliITSSAPLayer::GetFoundBinClusters(int i, int &first)  const {
+  // set the entry of the first cl.info in the fSortedClInfo 
+  // and return n clusters in the bin
+  ClBinInfo_t& bin=fBins[GetFoundBin(i)];
+  first = bin.first;
+  return bin.ncl;
+}
+
+//_____________________________________________________ 
+inline AliITSRecPoint* AliITSSAPLayer::GetNextCluster() {
+  // return next cluster
+  ClsInfo_t* cli=GetNextClusterInfo(); 
+  return cli ? (AliITSRecPoint*)fClusters->UncheckedAt(cli->index) : 0;
+}
+
+//_____________________________________________________________
+inline AliITSSAPLayer::ClsInfo_t* AliITSSAPLayer::GetNextClusterInfo()
+{
+  // return cluster info for next matching cluster
+  int id = GetNextClusterInfoID();
+  return id<0 ? 0 : (AliITSSAPLayer::ClsInfo_t*)&fSortedClInfo[id];
+}
+
+#endif
diff --git a/HLT/ITS/trackingSAP/AliITSSAPTracker.cxx b/HLT/ITS/trackingSAP/AliITSSAPTracker.cxx
new file mode 100644 (file)
index 0000000..9853a22
--- /dev/null
@@ -0,0 +1,1467 @@
+#include "AliITSSAPTracker.h"
+#include "AliITSSAPLayer.h"
+#include "AliITSRecPoint.h"
+#include "AliGeomManager.h"
+#include "AliVParticle.h"
+#include "AliSymMatrix.h"
+//
+#include "AliRunLoader.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+#include "AliStack.h"
+#include <TParticle.h>
+#include <TParticlePDG.h>
+#include <TFile.h>
+
+
+ClassImp(AliITSSAPTracker)
+
+const Float_t AliITSSAPTracker::fgkZSpanITS[AliITSSAPTracker::kMaxLrITS] = 
+{ 36. ,14.1,14.1,  38., 22.2,29.7, 51.   ,43.1,48.9};
+
+const Float_t AliITSSAPTracker::fgkRLayITS[AliITSSAPTracker::kMaxLrITS] = 
+  { 2.94, 3.9,7.6, 11.04, 15.0,23.9, 29.44 ,38.0,43.0};
+
+const Float_t AliITSSAPTracker::fgkRSpanITS[AliITSSAPTracker::kMaxLrITS] = // half span in R
+  { 0.04, 0.5,0.5, 0.5, 0.8, 0.8, 0.5 ,0.6,0.6};
+
+const Int_t    AliITSSAPTracker::fgkPassivLrITS[AliITSSAPTracker::kNLrPassive] = 
+  {AliITSSAPTracker::kLrBeamPime,AliITSSAPTracker::kLrShield1,AliITSSAPTracker::kLrShield2};
+
+const Int_t    AliITSSAPTracker::fgkActiveLrITS[AliITSSAPTracker::kNLrActive] = 
+  {AliITSSAPTracker::kLrSPD1,AliITSSAPTracker::kLrSPD2,
+   AliITSSAPTracker::kLrSDD1,AliITSSAPTracker::kLrSDD2,
+   AliITSSAPTracker::kLrSSD1,AliITSSAPTracker::kLrSSD2};
+
+const Int_t    AliITSSAPTracker::fgkLr2Active[AliITSSAPTracker::kMaxLrITS] = // conversion to active lr.
+  {-1, 0, 1, -1, 2, 3, -1, 4, 5};
+
+const Float_t AliITSSAPTracker::fgkRhoLITS[AliITSSAPTracker::kMaxLrITS] = {
+  0.162802, 0.321960,0.354588, 0.274995, 0.193789,0.198168, 0.435372, 0.195828,0.226940};
+
+const Float_t AliITSSAPTracker::fgkX2X0ITS[AliITSSAPTracker::kMaxLrITS] = {
+  0.002757, 0.011660,0.012614, 0.006488, 0.007714,0.007916, 0.012689, 0.007849,0.009128};
+
+
+const Double_t AliITSSAPTracker::fgkClSystYErr2[AliITSSAPTracker::kNLrActive] = 
+  {0.0010*0.0010, 0.0030*0.0030, 0.0500*0.0500, 0.0500*0.0500, 0.0020*0.0020, 0.0020*0.0020};
+
+const Double_t AliITSSAPTracker::fgkClSystZErr2[AliITSSAPTracker::kNLrActive] = 
+  {0.0050*0.0050, 0.0050*0.0050, 0.0050*0.0050, 0.0050*0.0050, 0.1000*0.1000, 0.1000*0.1000};
+
+
+const Int_t    AliITSSAPTracker::fgkLrDefBins[AliITSSAPTracker::kNLrActive][2] = // n bins in z, phi
+  { {20,20}, {20,20}, {20,20}, {20,20}, {20,20}, {20,20} };
+
+const Float_t AliITSSAPTracker::fgkDefMass = 0.14;
+const Int_t   AliITSSAPTracker::fgkDummyLabel = -3141593;
+
+#ifdef _TIMING_
+const char* AliITSSAPTracker::fgkSWNames[AliITSSAPTracker::kNSW] = {
+  "Total"
+  ,"Tracklets"
+  ,"Tracks"
+  ,"Vertex"
+};
+#endif
+
+
+//______________________________________________
+AliITSSAPTracker::AliITSSAPTracker() :
+  fSPD2Discard()
+  ,fTracklets()
+  ,fSPD1Tracklet()
+  ,fBlacklist(0)
+  ,fPhiShift(0.0045)
+  ,fSigThetaTracklet(0.025)
+  ,fSigPhiTracklet(0.08)
+  ,fChi2CutTracklet(1.5)
+  ,fPhiShiftSc(0.)
+  ,fDThetaTrackletSc(0)
+  ,fDPhiTrackletSc(0)
+  ,fBz(5.0)
+  ,fDPhiTol(0.)
+  ,fDThSig2Inv(0.)
+  ,fDPhSig2Inv(0.)
+  //
+  ,fMinPt(0.3)
+  ,fCurvMax(0)
+  ,fZSPD2CutMin(1e9)
+  ,fZSPD2CutMax(-1e9)
+  ,fMaxChi2Tr2Cl(40)
+  ,fAddErr2YspdVtx(0.02*0.02)
+  ,fAddErr2ZspdVtx(0.04*0.04)
+  //
+  ,fMissChi2Penalty(3)
+  ,fMaxMissedLayers(1)
+  ,fNTracks(0)
+  ,fTracks()
+  ,fTrackVertex()
+  ,fFitVertex(kTRUE)
+  //
+  ,fSPDVertex(0)
+#ifdef _CONTROLH_
+  ,fHTrackletMC(0),fHTrackletAll(0),fHTrackletFake(0),fHTrackMC(0),fHTrackAll(0),fHTrackFake(0)
+  ,fHVtxDiffXY(0)
+  ,fHVtxDiffXMlt(0),fHVtxDiffYMlt(0),fHVtxDiffZMlt(0)
+  ,fHVtxPullXMlt(0),fHVtxPullYMlt(0),fHVtxPullZMlt(0)
+  ,fHVtxMCSPDDiffXY(0)
+  ,fHVtxMCSPDDiffXMlt(0),fHVtxMCSPDDiffYMlt(0),fHVtxMCSPDDiffZMlt(0)
+  ,fHVtxMCSPDPullXMlt(0),fHVtxMCSPDPullYMlt(0),fHVtxMCSPDPullZMlt(0)
+  ,fHChi2NDFvsPT(0),fHChi2vsNC(0)
+  ,fHVtxMltRef(0),fHVtxOKMlt(0),fHVtxDiffZ(0),fHVtxMCSPDDiffZ(0)
+#endif
+{
+  // def. c-tor
+  for (int i=kNLrActive;i--;) fLayers[i] = 0;
+}
+
+//______________________________________________
+AliITSSAPTracker::~AliITSSAPTracker()
+{
+  // d-tor
+  for (int i=0;i<kNLrActive;i++) delete fLayers[i];
+}
+
+//______________________________________________
+void AliITSSAPTracker::Init()
+{
+  // init tracker
+  //
+  if (!AliGeomManager::GetGeometry()) {
+    AliGeomManager::LoadGeometry("geometry.root");
+    AliGeomManager::ApplyAlignObjsFromCDB("ITS");
+  }
+  //
+  for (int i=0;i<kNLrActive;i++) {
+    int iAct = fgkActiveLrITS[i];
+    fLayers[i] = new AliITSSAPLayer(i,fgkZSpanITS[iAct]+1,fgkLrDefBins[i][0],fgkLrDefBins[i][1]);
+    fSkipLayer[i] = kFALSE;
+    fNSigma2[i] = 7*7;
+    fYToler2[i] = 0.2*0.2;
+    fZToler2[i] = 0.2*0.2;
+    fChi2TotCut[i] = 0;
+  }  
+  fChi2TotCut[1] = 40; // 2 cl+vtx -> NDF=1
+  fChi2TotCut[2] = 40; 
+  fChi2TotCut[3] = 30; 
+  fChi2TotCut[4] = 35; 
+  fChi2TotCut[5] = 40; 
+  //
+  fMissChi2Penalty = 3;
+  fMaxMissedLayers = 1;
+  //
+  // auxialary precalculated variables
+  if (fChi2CutTracklet<0.1) fChi2CutTracklet = 0.1;
+  double scl = TMath::Sqrt(fChi2CutTracklet);
+  fDThetaTrackletSc = fSigThetaTracklet*scl;
+  fDPhiTrackletSc   = fSigPhiTracklet*scl;
+  //
+  fDThSig2Inv = 1./(fSigThetaTracklet*fSigThetaTracklet);
+  fDPhSig2Inv = 1./(fSigPhiTracklet*fSigPhiTracklet);
+  //
+  fBlacklist = new TBits(100*100);
+  //
+#ifdef _TIMING_
+  for (int i=kNSW;i--;) {
+    fSW[i].Stop();
+    fSW[i].Reset();
+  }
+#endif
+  //
+#ifdef _CONTROLH_
+  BookHistos();
+#endif
+}
+
+//______________________________________________
+void AliITSSAPTracker::ProcessEvent()
+{
+  // do full reconstruction
+#ifdef _TIMING_
+  fSW[kSWTotal].Start(0);
+  fSW[kSWTracklets].Start(0);
+#endif
+  //
+  fNTracks = 0;  
+  FindTracklets();
+  //
+#ifdef _TIMING_
+  fSW[kSWTracklets].Stop();
+  fSW[kSWTracks].Start(0);
+#endif
+  //
+  Tracklets2Tracks();
+  RefitInward();
+#ifdef _TIMING_
+  fSW[kSWTracks].Stop();
+  fSW[kSWVertex].Start(0);
+#endif
+  if (fFitVertex) {
+    if (FitTrackVertex()) {
+#ifdef _DEBUG_
+      printf("FittedVertex: "); fTrackVertex.Print();
+      printf("SPD   Vertex: "); fSPDVertex->Print();
+#endif
+    }
+  }
+  //
+  //
+#ifdef _TIMING_
+  fSW[kSWVertex].Stop();
+  fSW[kSWTotal].Stop();
+  PrintTiming();
+#endif
+  //
+#ifdef _CONTROLH_
+  FillRecoStat();
+#endif
+  /*
+  PrintTracklets();
+  PrintTracks();  
+  if (fSPDVertex) {printf("SPDvtx: "); fSPDVertex->Print();}
+  printf("TRKVtx: "); fTrackVertex.Print();
+  */
+}
+
+
+//______________________________________________
+void AliITSSAPTracker::Clear(Option_t*)
+{
+  // reset event info
+  ClearTracklets();
+  ClearTracks();
+  for (int i=kNLrActive;i--;) {
+    fNClusters[i] = 0;
+    if (fLayers[i]) fLayers[i]->Clear();
+  }
+}
+
+//______________________________________________
+void AliITSSAPTracker::ClearTracklets()
+{
+  // reset tracklets info
+  fSPD2Discard.clear();
+  fTracklets.clear();
+  fSPD1Tracklet.clear();
+  if (fBlacklist) fBlacklist->ResetAllBits();
+}
+
+
+//______________________________________________
+void AliITSSAPTracker::AddCluster(AliITSRecPoint* cl)
+{
+  // add cluster to corresponding layer
+  if (!cl->Misalign()) AliWarning("Can't misalign this cluster !"); 
+  fLayers[cl->GetLayer()]->AddCluster(cl); 
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::FindTracklets()
+{
+  // find SPD tracklets
+  //
+  if (!fSPDVertex) {
+    //    AliInfo("No SPD vertex set");
+    return kFALSE;
+  }
+  float rv2 = fSPDVertex->GetX()*fSPDVertex->GetX()+fSPDVertex->GetY()*fSPDVertex->GetY();
+  if (rv2>0.25*fgkRLayITS[kLrBeamPime]*fgkRLayITS[kLrBeamPime]) {
+    //    AliInfo("SPD vertex is too far from beam line");
+    fSPDVertex->Print();
+    return kFALSE;    
+  } 
+  fPhiShiftSc = fPhiShift*TMath::Abs(fBz/5.0);
+  fDPhiTol = fDPhiTrackletSc + fPhiShiftSc;
+  //
+  AliITSSAPLayer &spdL1 = *fLayers[kALrSPD1];
+  AliITSSAPLayer &spdL2 = *fLayers[kALrSPD2];
+  spdL1.SortClusters(fSPDVertex);
+  spdL2.SortClusters(fSPDVertex);
+  fNClusters[0] = spdL1.GetNClusters();
+  fNClusters[1] = spdL2.GetNClusters();
+  //
+  if (fNClusters[0]<1 || fNClusters[1]<1) return kFALSE;
+  //
+  fSPD2Discard.resize(fNClusters[1]);
+  fSPD1Tracklet.resize(fNClusters[0]);
+  //
+  fBlacklist->SetBitNumber(TMath::Max(fNClusters[0]*fNClusters[1],10000),kFALSE); // to reserve the space
+  //
+  int nfound;
+  do {
+    nfound = 0;
+    for (int icl2=fNClusters[1];icl2--;) if (!fSPD2Discard[icl2]) nfound += AssociateClusterOfL2(icl2);
+  } while(nfound);
+  //
+  for (int itr=GetNTracklets();itr--;) CookLabel(fTracklets[itr]); 
+  //
+  return kTRUE;
+}
+
+//______________________________________________
+Int_t AliITSSAPTracker::AssociateClusterOfL2(int icl2)
+{
+  // find SPD1 cluster matching to SPD2 cluster icl2
+  AliITSSAPLayer &spdL1 = *fLayers[kALrSPD1];
+  AliITSSAPLayer &spdL2 = *fLayers[kALrSPD2];
+  AliITSSAPLayer::ClsInfo* cli2 = spdL2.GetClusterInfo(icl2);
+  // expected z at SPD1
+  float zV = fSPDVertex->GetZ();
+  float z2 = cli2->z - zV;
+  float tg2Inv = z2/cli2->r;
+  float dzt = (1.+tg2Inv*tg2Inv)*fDThetaTrackletSc;
+  float dz = dzt*fgkRLayITS[kLrSPD1] + TMath::Abs(tg2Inv)*fgkRSpanITS[kLrSPD1]; // uncertainty from dTheta and from Layer1 R spread
+  float zL1 = zV + tg2Inv*fgkRLayITS[kLrSPD1]; // center of expected Z1
+  int nsel1 = spdL1.SelectClusters(zL1-dz,zL1+dz, cli2->phi-fDPhiTol,cli2->phi+fDPhiTol);
+  if (!nsel1) {
+    fSPD2Discard[icl2] = true;
+    return 0; // no candidates
+  }
+  float chiBest = 9999;
+  SPDtracklet_t trk;
+  trk.id1 = -1;
+  int icl1,nCand=0;
+  while ( (icl1=spdL1.GetNextClusterInfoID())!=-1) {  // loop over matching clusters of lr1
+    if (IsBlacklisted(icl1,icl2)) continue;
+    AliITSSAPLayer::ClsInfo* cli1 = spdL1.GetClusterInfo(icl1);
+    float z1 = cli1->z - zV;
+    float tg1Inv = z1/cli1->r;
+    //
+    float dTheta = (tg2Inv-tg1Inv)/(1.+tg1Inv*tg1Inv);        // fast check on theta
+    if (TMath::Abs(dTheta)>fDThetaTrackletSc) continue;
+    //
+    float dPhi = cli1->phi - cli2->phi;                       // fast check on phi
+    if (dPhi>TMath::Pi()) dPhi = TMath::TwoPi()-dPhi;
+    else if (dPhi<-TMath::Pi()) dPhi += TMath::TwoPi();
+    double dPhiS = TMath::Abs(dPhi)-fPhiShiftSc;
+    if (TMath::Abs(dPhiS)>fDPhiTrackletSc) continue;
+    //
+    float chi2 = dTheta*dTheta*fDThSig2Inv + dPhiS*dPhiS*fDPhSig2Inv; // check final chi2
+    if (chi2>1.) {
+      Blacklist(icl1,icl2);
+      continue;
+    }
+    nCand++;
+    if (chi2>chiBest) continue;
+    // check if cl1 is already associated with better 
+    trk.id1 = icl1;
+    trk.id2 = icl2;
+    trk.dtht = dTheta;
+    trk.dphi = dPhi;
+    trk.chi2 = chiBest = chi2;
+  }
+  //
+  if (trk.id1!=-1) { // check if there is no better icl1 candidate for icl2
+    int oldId = fSPD1Tracklet[trk.id1];
+    if (!oldId) { // store new tracklet
+      fTracklets.push_back(trk);
+      fSPD1Tracklet[trk.id1] = fTracklets.size(); // refer from clusters to tracklet (id+1)
+      fSPD2Discard[icl2] = true; // mark as used
+      Blacklist(trk.id1,trk.id2);
+      return 1;
+    }
+    SPDtracklet_t& oldTrk = (SPDtracklet_t&)fTracklets[--oldId];
+    if (oldTrk.chi2 < trk.chi2) { // previous is better 
+      Blacklist(trk.id1,trk.id2);  // shall we blacklist new combination?
+      if (nCand==1)  fSPD2Discard[icl2] = true; // there was just 1 candidate and it is discarded
+      return 0;
+    }
+    // new combination is better, overwrite the old one with new one, marking old L2 cluster free
+    fSPD2Discard[oldTrk.id2] = false; // mark as free
+    fSPD2Discard[icl2] = true; // mark as used
+    oldTrk = trk;         // new combination is better, overwrite it with new one
+    Blacklist(trk.id1,trk.id2);
+    return 1;
+  }
+  //
+  fSPD2Discard[icl2] = true; // no chance to find partner for this cluster
+  return 0;
+  //
+}
+
+
+//______________________________________________
+void AliITSSAPTracker::Tracklets2Tracks()
+{
+  // try to extend tracklets to outer layers
+  int nTrk = GetNTracklets();
+  if (!nTrk) return;
+  //
+  CalcAuxTracking(); // RS??? do we need to repeat this?
+  //
+  for (int ila=kALrSDD1;ila<kNLrActive;ila++) {
+    if (fSkipLayer[ila]) continue;
+    fLayers[ila]->SortClusters(0);
+    fNClusters[ila] = fLayers[ila]->GetNClusters();
+  }
+  //
+  fTracks.resize(nTrk);
+
+  //
+  for (int itr=0;itr<nTrk;itr++) {
+    SPDtracklet_t& trlet = fTracklets[itr];
+    //
+#ifdef _DEBUG_
+    printf("TestTracklet %d\t|",itr);
+    int stat = GetTrackletMCTruth(trlet);
+    //
+    int nmiss=0;
+    for (int i=2;i<kNLrActive;i++) {
+      printf("%c", (stat&(0x1<<i)) ? '*':'-'); 
+      if (!(stat&(0x1<<i))) nmiss++;
+    }
+    printf("|\n");
+    PrintTracklet(itr);
+#endif
+    //
+    float zspd2 = fLayers[kALrSPD2]->GetClusterInfo(trlet.id2)->z;
+    if (zspd2<fZSPD2CutMin || zspd2>fZSPD2CutMax) continue;
+    ITStrack_t &track = fTracks[fNTracks];
+    if (!CreateTrack(track, trlet)) continue;
+    track.trackletID = itr;
+    Bool_t res;
+#ifdef _DEBUG_
+    double xyz[3];
+    track.paramOut.GetXYZAt(0,fBz,xyz);
+    printf("process track pt:%f XYZ: %+.4f %+.4f %+.4f\n",track.paramOut.Pt(),xyz[0],xyz[1],xyz[2]);
+#endif
+    for (int lrID=kLrShield1;lrID<kMaxLrITS;lrID++) {
+      res = FollowToLayer(track,lrID) && IsAcceptableTrack(track);
+      if (!res) break;
+    }
+#ifdef _DEBUG_
+    printf("%s:%d\n",res ? "OK" : "Fail",nmiss<=fMaxMissedLayers);
+#endif
+    if (!res) continue;
+    track.paramOut.ResetBit(kInvalidBit); // flag that outward fit succeeded
+    CookLabel(track);
+    fNTracks++;
+    //
+  }  
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::IsAcceptableTrack(const AliITSSAPTracker::ITStrack_t& /*track*/) const
+{
+  // check if the track is acceptable
+  return kTRUE;
+}
+
+//______________________________________________
+void AliITSSAPTracker::PrintTrack(const AliITSSAPTracker::ITStrack_t& track) const
+{
+  // print track info
+  printf("Chi2 = %f for %d clusters. Tracklet %d\n",track.chi2,track.ncl,track.trackletID);
+  //  
+  for (int ilr=0;ilr<kNLrActive;ilr++) {
+    if (track.clID[ilr]<0) continue;
+    AliITSRecPoint* cl = fLayers[ilr]->GetClusterSorted(track.clID[ilr]);
+    printf("L%d #%4d ",ilr,track.clID[ilr]);
+    for (int i=0;i<3;i++) printf("%d ",cl->GetLabel(i)); printf("\n");
+  }
+  track.paramOut.Print();
+  track.paramInw.Print();  
+}
+
+//______________________________________________
+void AliITSSAPTracker::PrintTracklets() const
+{
+  // print traklets info
+  int ntr = fTracklets.size();
+  printf("NTracklets: %d\n",ntr);
+  printf("Nspd1: %4d Nspd2: %4d, Ntracklets: %d\n",fNClusters[0],fNClusters[1],ntr);
+  for (int itr=0;itr<ntr;itr++) PrintTracklet(itr);
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::PrintTracklet(Int_t itr) const
+{
+  // print single tracklet
+  const SPDtracklet_t* trk = &fTracklets[itr];
+  AliITSRecPoint* cl1 = fLayers[kALrSPD1]->GetClusterSorted(trk->id1);
+  AliITSRecPoint* cl2 = fLayers[kALrSPD2]->GetClusterSorted(trk->id2);
+  AliITSSAPLayer::ClsInfo_t* cli0 = fLayers[kALrSPD1]->GetClusterInfo(trk->id1);
+  printf("#%3d Phi:%+.3f Eta:%+.3f Dphi:%+.3f Dtht:%+.3f Chi2:%.3f | Lbl:",
+        itr,cli0->phi,
+        -TMath::Log(TMath::Tan(TMath::ATan2(cli0->r,cli0->z-fSPDVertex->GetZ())/2.)),
+        trk->dphi,trk->dtht,trk->chi2);
+  int lab=-1,lb = -1;
+  for (int i=0;i<3;i++) if ( (lb=cl1->GetLabel(i))>=0 ) {if (lab<0)lab=lb; printf(" %5d",lb);} printf("|");
+  for (int i=0;i<3;i++) if ( (lb=cl2->GetLabel(i))>=0 ) printf(" %5d",lb); 
+  printf("| ->%d\n",trk->label);
+  lab = TMath::Abs(trk->label);
+  //
+  AliStack* stack = 0;
+  AliRunLoader* rl = AliRunLoader::Instance();
+  if (lab>=0 && rl && (stack=rl->Stack())) {
+    TParticle* mctr = stack->Particle(lab);
+    if (mctr) {
+      TParticlePDG* mctrPDG = mctr->GetPDG();
+      if (mctrPDG) {
+       double qpt = mctrPDG->Charge()>0 ? mctr->Pt() : -mctr->Pt();
+       printf("MCTrack: Prim:%d Vxyz: {%+.4f %+.4f %+.4f} 1/pt: %.3f tgl: %.3f\n",
+              stack->IsPhysicalPrimary(lab),
+              mctr->Vx(),mctr->Vy(),mctr->Vz(),
+              TMath::Abs(qpt)>0 ? 1./qpt : 9999., TMath::Tan(TMath::Pi()/2. - mctr->Theta()));
+      }
+    }
+  }
+}
+
+
+//______________________________________________
+void AliITSSAPTracker::PrintTracks() const
+{
+  // print tracks info
+  printf("NTracks: %d\n",fNTracks);
+  for (int itr=0;itr<fNTracks;itr++) PrintTrack(fTracks[itr]);
+  //
+}
+
+
+//______________________________________________
+void AliITSSAPTracker::CalcAuxTracking()
+{
+  // precalculate auxilarry variables for tracking
+  //
+  // largest track curvature to search
+  const double ztolerEdge = 1.0;
+  fCurvMax = TMath::Abs(fBz*kB2C/fMinPt);
+  double thMin =-1e9;
+  double thMax = 1e9;
+  for (int ilA=kNLrActive-1;ilA>kALrSPD2;ilA--) {
+    if (!IsObligatoryLayer(ilA)) continue;
+    int ilr=fgkActiveLrITS[ilA];
+    double r   = fgkRLayITS[ilr] - fgkRSpanITS[ilr];
+    double dz = fgkZSpanITS[ilr]+ztolerEdge+fDThetaTrackletSc*r;
+    double ri  = 1./r;
+    double tmin= (-dz-fSPDVertex->GetZ())*ri;
+    double tmax= ( dz-fSPDVertex->GetZ())*ri;
+    if (tmin>thMin) thMin = tmin;
+    if (tmax<thMax) thMax = tmax;
+  }
+  double r = fgkRLayITS[kLrSPD2] + fgkRSpanITS[kLrSPD2];
+  fZSPD2CutMin = fSPDVertex->GetZ()+thMin*r; // min Z of SPD2 in tracklet to consider tracking
+  fZSPD2CutMax = fSPDVertex->GetZ()+thMax*r; // max Z of SPD2 in tracklet to consider tracking
+  //
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::CreateTrack(AliITSSAPTracker::ITStrack_t& track, 
+                                    AliITSSAPTracker::SPDtracklet_t& trlet)
+{
+  // create track seed from tracklet
+  // init track
+  track.label = trlet.label;
+  //
+  AliITSSAPLayer::ClsInfo_t *cli1=fLayers[kALrSPD1]->GetClusterInfo(trlet.id1);
+  AliITSSAPLayer::ClsInfo_t *cli2=fLayers[kALrSPD2]->GetClusterInfo(trlet.id2);
+  AliITSRecPoint *cl1=fLayers[kALrSPD1]->GetClusterUnSorted(cli1->index);
+  AliITSRecPoint *cl2=fLayers[kALrSPD2]->GetClusterUnSorted(cli2->index);
+  int det1 = cl1->GetVolumeId()-fLayers[kALrSPD1]->GetVIDOffset();
+  int det2 = cl2->GetVolumeId()-fLayers[kALrSPD2]->GetVIDOffset();
+  AliITSSAPLayer::ITSDetInfo_t& detInfo1 = fLayers[kALrSPD1]->GetDetInfo(det1);
+  AliITSSAPLayer::ITSDetInfo_t& detInfo2 = fLayers[kALrSPD2]->GetDetInfo(det2);
+  //
+  // crude momentun estimate
+  float dx=cli1->x-cli2->x,dy=cli1->y-cli2->y,d=TMath::Sqrt(dx*dx+dy*dy);
+  float qptInv = fBz ? 2*TMath::Sin(cli2->phi-cli1->phi)/d/fBz/kB2C : 0; // positive particle goes anticlockwise in B+
+  //
+  // we initialize the seed in the tracking frame of 1st detector
+  float xv= fSPDVertex->GetX()*detInfo1.cosTF + fSPDVertex->GetY()*detInfo1.sinTF;
+  float yv=-fSPDVertex->GetX()*detInfo1.sinTF + fSPDVertex->GetY()*detInfo1.cosTF;
+  float zv= fSPDVertex->GetZ();
+  float par[5] = {yv, zv, (float)TMath::Sin(cli1->phi-detInfo1.phiTF), (cli1->z-zv)/cli1->r, qptInv};
+  double covVtx[6]; 
+  fSPDVertex->GetCovarianceMatrix(covVtx);
+  float cov[15] = {float(covVtx[0]+covVtx[2] + fAddErr2YspdVtx),
+                  0, float(covVtx[5] + fAddErr2ZspdVtx),
+                  0,0,1,
+                  0,0,0,1,
+                  0,0,0,0,100*100};
+  AliExternalTrackParam& param = track.paramOut;
+  param.Set(xv, detInfo1.phiTF, par, cov);
+  track.chi2 = 0;   // chi2 at 1st two point is 0
+  // go to 1st layer, ignoring the MS (errors are anyway not defined)
+  if (!param.PropagateTo(detInfo1.xTF+cl1->GetX(), fBz)) return kFALSE;
+  Double_t cpar0[2]={ cl1->GetY(), cl1->GetZ()};
+  Double_t ccov0[3]={ cl1->GetSigmaY2() + GetClSystYErr2(kALrSPD1), 0., cl1->GetSigmaZ2() + GetClSystZErr2(kALrSPD1)};
+  if (!param.Update(cpar0,ccov0)) return kFALSE;
+  if (!param.CorrectForMeanMaterial(fgkX2X0ITS[kLrSPD1],-fgkRhoLITS[kLrSPD1],fgkDefMass)) return kFALSE;
+  // go to 2nd layer
+  if (!param.Rotate(detInfo2.phiTF)) return kFALSE;
+  if (!param.PropagateTo(detInfo2.xTF+cl2->GetX(), fBz)) return kFALSE;
+  Double_t cpar1[2]={ cl2->GetY(), cl2->GetZ()};
+  Double_t ccov1[3]={ cl2->GetSigmaY2() + GetClSystYErr2(kALrSPD2), 0., cl2->GetSigmaZ2() + GetClSystZErr2(kALrSPD2)};
+  track.chi2 += param.GetPredictedChi2(cpar1,ccov1);
+  if (!param.Update(cpar1,ccov1)) return kFALSE;
+#ifdef _CONTROLH_
+  FillTrackingControlHistos(1,track.label,&param,cpar1,ccov1,cl2);
+#endif  
+  //
+  track.clID[0] = trlet.id1;
+  track.clID[1] = trlet.id2;
+  track.clID[2] = track.clID[3] = track.clID[4] = track.clID[5] = -1;
+  track.ncl = 2;
+  track.nmiss=0;
+  //
+  param.SetBit(kInvalidBit); // flag that track is not yer refitted outward 
+  track.paramOut.SetBit(kInvalidBit); // flag that track was not refitter inward
+  return kTRUE;
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::CrossPassiveLayer(AliExternalTrackParam& param, Int_t lrID)
+{
+  // cross the layer, applying mat. corrections
+  double xStart=param.GetX();
+  double xToGo = GetXatLabRLin(param,fgkRLayITS[lrID]);
+  if (xToGo<0 || !param.PropagateTo(xToGo,fBz)) return kFALSE;
+  double x2x0=fgkX2X0ITS[lrID],xrho=fgkRhoLITS[lrID];
+  if (xStart<xToGo) xrho = -xrho; // inward propagation
+  return param.CorrectForMeanMaterial(x2x0,xrho,fgkDefMass,kFALSE);
+//
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::FollowToLayer(AliITSSAPTracker::ITStrack_t& track, Int_t lrID)
+{
+  // take track to given layer, searching hits if needed and applying mat. corrections
+  int lrIDA = fgkLr2Active[lrID]; // active layer ID
+  if (lrIDA<0 || fSkipLayer[lrIDA]) return CrossPassiveLayer(track.paramOut,lrID);
+  //
+  AliExternalTrackParam trCopy(track.paramOut);
+  double xToGo = GetXatLabRLin(trCopy,fgkRLayITS[lrID]); // aproximate X at lrID
+  if (!trCopy.PropagateTo(xToGo,fBz)) return kFALSE;
+  double xyz[3];
+  trCopy.GetXYZ(xyz);
+  double phi=TMath::ATan2(xyz[1],xyz[0]),z=trCopy.GetZ();
+  // we need track errors in the plane nearly tangential to crossing point
+  if (!trCopy.Rotate(phi)) return kFALSE;
+  double dphi = TMath::Sqrt(trCopy.GetSigmaY2()*fNSigma2[lrIDA]+fYToler2[lrIDA])/fgkRLayITS[lrID];
+  double dz   = TMath::Sqrt(trCopy.GetSigmaZ2()*fNSigma2[lrIDA]+fZToler2[lrIDA]);
+  AliITSSAPLayer* lrA = fLayers[lrIDA];
+  int nCl = lrA->SelectClusters(z-dz,z+dz,phi-dphi,phi+dphi);
+  Bool_t updDone = kFALSE;
+  //
+#ifdef _DEBUG_
+  printf("at Lr%d, Ncl:%d ",lrIDA,nCl);
+  trCopy.Print();
+#endif
+  //
+  if (nCl) {
+    int icl,iclBest=-1;
+    double chi2Best = fMaxChi2Tr2Cl;
+    AliITSRecPoint* bestCl = 0;
+    AliExternalTrackParam bestTr;
+    //
+#ifdef _DEBUG_
+    int iclt=0;
+#endif
+    while ( (icl=lrA->GetNextClusterInfoID())!=-1) {
+      AliITSSAPLayer::ClsInfo_t *cli = lrA->GetClusterInfo(icl);
+      AliITSRecPoint *cl=lrA->GetClusterUnSorted(cli->index);
+      int detId = cl->GetVolumeId()-lrA->GetVIDOffset();
+      AliITSSAPLayer::ITSDetInfo_t& detInfo = lrA->GetDetInfo(detId);
+      trCopy = track.paramOut;
+      if (!trCopy.Propagate(detInfo.phiTF, detInfo.xTF+cl->GetX(), fBz)) continue;
+      double cpar[2]={ cl->GetY(), cl->GetZ()};
+      double ccov[3]={ cl->GetSigmaY2() + GetClSystYErr2(lrIDA) , 0., cl->GetSigmaZ2() + GetClSystZErr2(lrIDA)};
+      double chi2cl = trCopy.GetPredictedChi2(cpar,ccov);
+      //
+#ifdef _DEBUG_      
+      float clXYZ[3]; cl->GetGlobalXYZ(clXYZ);
+      double trXYZ[3]; trCopy.GetXYZ(trXYZ);
+      Float_t xCl, alphaCl; 
+      cl->GetXAlphaRefPlane(xCl,alphaCl);
+      //
+      printf("cl%d Chi2:%.2f Dyz: %+e %+e Err: %e %e %e |Lb:",iclt++,chi2cl, 
+            cl->GetY()-trCopy.GetY(),cl->GetZ()-trCopy.GetZ(),
+            TMath::Sqrt(ccov[0]),ccov[1],TMath::Sqrt(ccov[2])); //TMP
+      for (int j=0;j<3;j++) if (cl->GetLabel(j)>=0) printf(" %d",cl->GetLabel(j)); printf("\n");
+      printf("CL: X:%.4f Alp:%+.4f XYZ: %+.4f %+.4f %+.4f\n",xCl,alphaCl,clXYZ[0],clXYZ[1],clXYZ[2]);
+      printf("TR: X:%.4f Alp:%+.4f XYZ: %+.4f %+.4f %+.4f\n",detInfo.xTF,detInfo.phiTF,trXYZ[0],trXYZ[1],trXYZ[2]);
+      trCopy.Print();
+#endif
+      //
+#ifdef _CONTROLH_
+      FillTrackingControlHistos(lrIDA,track.label,&trCopy,cpar,ccov,cl);
+#endif 
+      //
+      if (chi2cl>fMaxChi2Tr2Cl) continue;
+      //    SaveCandidate(lrIDA,trCopy,chi2cl,icl);  // RS: do we need this?
+      if (chi2cl>chi2Best) continue;
+      chi2Best = chi2cl;
+      iclBest = icl;
+      bestCl = cl;
+      bestTr = trCopy;
+      if (nCl==1) { // in absence of competitors, do the fit on spot
+       if (!bestTr.Update(cpar,ccov)) return kFALSE;
+       updDone = kTRUE;
+      }
+    }
+#ifdef _DEBUG_
+    printf("Lr%d -> %f\n",lrIDA,chi2Best);
+#endif
+    //
+    if (bestCl) {
+      if (!updDone) {
+       double cpar[2]={ bestCl->GetY(), bestCl->GetZ()};
+       double ccov[3]={ bestCl->GetSigmaY2(), 0., bestCl->GetSigmaZ2()}; // RS: add syst errors    
+       if (!bestTr.Update(cpar,ccov)) return kFALSE;
+       updDone = kTRUE;
+      }
+      track.paramOut = bestTr;
+      track.clID[lrIDA] = iclBest;      
+      track.ncl++;
+      track.chi2 += chi2Best;      
+    }
+  }
+  //
+  if (!updDone) {
+    if (++track.nmiss > fMaxMissedLayers)  return kFALSE;
+    track.paramOut = trCopy;
+    track.chi2 += fMissChi2Penalty;
+  }
+  //
+#ifdef _CONTROLH_
+  int ndf = 2*track.ncl-5;
+  if (ndf>0) {
+    fHChi2vsNC->Fill(track.ncl,track.chi2); 
+    if (lrID==kNLrActive-1) fHChi2NDFvsPT->Fill(track.paramOut.Pt(),track.chi2/ndf);
+  }
+#endif
+  if (track.chi2 > GetChi2TotCut(track.ncl+1)) return kFALSE;
+  //
+  return track.paramOut.CorrectForMeanMaterial(fgkX2X0ITS[lrID],-fgkRhoLITS[lrID],fgkDefMass,kFALSE);
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::CookLabel(AliITSSAPTracker::ITStrack_t& track)
+{
+  // cook mc label for the track
+  track.label = fgkDummyLabel;
+  if (!track.ncl) return;
+  const int kMaxLbPerCl = 3;
+  int lbID[kNLrActive*6],lbStat[kNLrActive*6];
+  Int_t nLab=0;
+  for (int i=kNLrActive;i--;) {
+    int clid = track.clID[i];
+    if (clid<0) continue;
+    AliITSRecPoint* cl = fLayers[i]->GetClusterSorted(clid);
+    for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
+      int trLb = cl->GetLabel(imc);
+      if (trLb<0) break;
+      // search this mc track in already accounted ones
+      int iLab;
+      for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
+      if (iLab<nLab) lbStat[iLab]++;
+      else {
+       lbID[nLab] = trLb;
+       lbStat[nLab++] = 1;
+      }
+    } // loop over given cluster's labels
+  } // loop over all clusters
+  //
+  if (nLab) {
+    int maxLab=0;
+    for (int ilb=nLab;ilb--;) if (lbStat[maxLab]<lbStat[ilb]) maxLab=ilb;
+    track.label = lbStat[maxLab]==track.ncl ? lbID[maxLab] : -lbID[maxLab];
+  }
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::CookLabel(AliITSSAPTracker::SPDtracklet_t& tracklet)
+{
+  // cook mc label for the tracklet
+  tracklet.label = fgkDummyLabel;
+  const int kMaxLbPerCl = 3;
+  int lbID[kNLrActive*6],lbStat[kNLrActive*6];
+  Int_t nLab=0;
+  for (int i=2;i--;) {
+    int clid = i ? tracklet.id2 : tracklet.id1;
+    AliITSRecPoint* cl = fLayers[i]->GetClusterSorted(clid);
+    for (int imc=0;imc<kMaxLbPerCl;imc++) { // labels within single cluster
+      int trLb = cl->GetLabel(imc);
+      if (trLb<0) break;
+      // search this mc track in already accounted ones
+      int iLab;
+      for (iLab=0;iLab<nLab;iLab++) if (lbID[iLab]==trLb) break;
+      if (iLab<nLab) lbStat[iLab]++;
+      else {
+       lbID[nLab] = trLb;
+       lbStat[nLab++] = 1;
+      }
+    } // loop over given cluster's labels
+  } // loop over all clusters
+  //
+  if (nLab) {
+    int maxLab=0;
+    for (int ilb=nLab;ilb--;) if (lbStat[maxLab]<lbStat[ilb]) maxLab=ilb;
+    tracklet.label = lbStat[maxLab]==2 ? lbID[maxLab] : -lbID[maxLab];
+  }
+  //
+}
+
+//______________________________________________
+Double_t AliITSSAPTracker::GetXatLabRLin(AliExternalTrackParam& track, double r)
+{
+  // X of track circle intersection in current tracking frame, neglecting the curvature
+  // Solution of equation (x+d)^2+(y+b*d)^2 - r^2, where x,y are current coordinates of 
+  // track and d=X-x0. b = tg(phi)
+  //double sn=tr.GetSnp();
+  double sn=track.GetSnp();
+  if (TMath::Abs(sn)>kAlmost1) return -999;
+  double x=track.GetX(), y=track.GetY();
+  double cs2=(1.-sn)*(1.+sn), tg=sn/TMath::Sqrt(cs2);
+  double t0=x+tg*y, t1=x*x+y*y-r*r, det=t0*t0-t1/cs2;
+  if (det<0) return -999; // does not touch circle
+  det = TMath::Sqrt(det);
+  return x+(det-t0)*cs2;
+  //
+}
+
+//______________________________________________
+Int_t AliITSSAPTracker::GetTrackletMCTruth(AliITSSAPTracker::SPDtracklet_t& trlet) const
+{
+  int status = 0;
+  AliITSSAPLayer::ClsInfo_t *cli1=fLayers[kALrSPD1]->GetClusterInfo(trlet.id1);
+  AliITSSAPLayer::ClsInfo_t *cli2=fLayers[kALrSPD2]->GetClusterInfo(trlet.id2);
+  AliITSRecPoint *cl1=fLayers[kALrSPD1]->GetClusterUnSorted(cli1->index);
+  AliITSRecPoint *cl2=fLayers[kALrSPD2]->GetClusterUnSorted(cli2->index);
+  //
+  int lab = -1;
+  //
+  for (int i=0;i<3;i++) {
+    int lb1 = cl1->GetLabel(i); 
+    if (lb1<0) continue;
+    for (int j=0;j<3;j++) {
+      int lb2 = cl2->GetLabel(i); 
+      if (lb2<0) break;
+      if (lb1==lb2) {lab = lb1; break;}
+    }
+    if (lab>=0) break;
+  }
+  if (lab<0) return 0;
+  //
+  for (int ila=kALrSDD1;ila<kNLrActive;ila++) {
+    for (int icl=fNClusters[ila];icl--;) {
+      AliITSRecPoint *cl=fLayers[ila]->GetClusterUnSorted(icl);
+      for (int i=0;i<3;i++) {
+       if (cl->GetLabel(i)<0) break;
+       if (cl->GetLabel(i)==lab) {status |= 0x1<<ila; break;}
+      }
+      if (status & (0x1<<ila)) break;
+    }
+  }
+  return status;
+}
+
+//______________________________________________
+Bool_t AliITSSAPTracker::RefitInward(int itr)
+{
+  // refit track inward with material correction
+  ITStrack_t &track = fTracks[itr];
+  AliExternalTrackParam &trout = track.paramOut;
+  if (trout.TestBit(kInvalidBit)) return kFALSE;
+  AliExternalTrackParam &trin  = track.paramInw;
+  trin = trout;
+  int ilA = kNLrActive;
+  for (;ilA--;) {                    // find outermost layer with cluster
+    if (track.clID[ilA]<0) continue;
+    break;
+  }
+  int ilStart = fgkActiveLrITS[ilA]; // corresponding total lr id 
+  AliITSSAPLayer* lrA = fLayers[ilA];
+  AliITSRecPoint *cl=lrA->GetClusterSorted(track.clID[ilA]);
+  AliITSSAPLayer::ITSDetInfo_t& detInfo = lrA->GetDetInfo(cl->GetVolumeId()-lrA->GetVIDOffset());
+  if (!trin.RotateParamOnly(detInfo.phiTF)) return kFALSE;
+  if (!trin.PropagateParamOnlyTo(detInfo.xTF+cl->GetX(), fBz)) return kFALSE;
+  // init with outer cluster y,z and slopes, q/pt of outward track
+  double par[5] = {cl->GetY(), cl->GetZ(), trin.GetSnp(), trin.GetTgl(), trin.GetSigned1Pt()}; 
+  double cov[15] = {cl->GetSigmaY2() + GetClSystYErr2(kALrSPD1), 
+                  0., cl->GetSigmaZ2() + GetClSystZErr2(kALrSPD1),
+                  0,0,1,
+                  0,0,0,1,
+                  0,0,0,0,100*100};
+  trin.Set(double(detInfo.xTF+cl->GetX()),double(detInfo.phiTF), par, cov);
+  // !!! no material correction is needed: errors are not defined yer
+  //
+  for (int ilr=ilStart;ilr--;) {
+    //
+    if ( (ilA=fgkLr2Active[ilr])<0 || track.clID[ilA]<0) { // either passive layer or no cluster
+      if (CrossPassiveLayer(trin,ilr)) continue;
+      else return kFALSE;
+    }
+    // there is a cluster, need to update
+    lrA = fLayers[ilA];
+    cl = lrA->GetClusterSorted(track.clID[ilA]);
+    AliITSSAPLayer::ITSDetInfo_t& detInfo1 = lrA->GetDetInfo(cl->GetVolumeId()-lrA->GetVIDOffset());
+    if (!trin.Propagate(detInfo1.phiTF, detInfo1.xTF+cl->GetX(), fBz)) return kFALSE;
+    double cpar[2]={ cl->GetY(), cl->GetZ()};
+    double ccov[3]={ cl->GetSigmaY2() + GetClSystYErr2(ilA) , 0., cl->GetSigmaZ2() + GetClSystZErr2(ilA)};
+    if (!trin.Update(cpar,ccov)) return kFALSE;
+    //
+    // correct for layer materials
+    if (!trin.CorrectForMeanMaterial(fgkX2X0ITS[ilr],fgkRhoLITS[ilr],fgkDefMass,kFALSE)) return kFALSE;
+    //
+  }
+  //
+  // now go to PCA to vertex
+  //double dca[2],dcaCov[3];
+  if (!trin.PropagateToDCA(fSPDVertex,fBz,fgkRLayITS[kLrBeamPime])) return kFALSE; //,dca,dcaCov);
+  //
+  trin.ResetBit(kInvalidBit); // flag that inward fit succeeded
+  return kTRUE;
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::RefitInward()
+{
+  // refit tracks inward with material correction
+  for (int itr=fNTracks;itr--;) {
+    if (!RefitInward(itr)) {
+#ifdef _DEBUG_
+      printf("RefitInward failed for track %d\n",itr);
+      PrintTrack(fTracks[itr]);
+#endif
+    }
+  }
+  //
+}
+
+
+//______________________________________________
+Bool_t AliITSSAPTracker::FitTrackVertex()
+{
+  // Fit the vertexTracks. The inner tracks must be already propagated to the SPD vertex.
+  // In this case straight line extrapolation can be used
+  //
+  fTrackVertex.SetNContributors(0); // invalidate
+  //
+  if (fNTracks<3) return kFALSE;
+  double cxx=0,cxy=0,cxz=0,cx0=0,cyy=0,cyz=0,cy0=0,czz=0,cz0=0;
+  //
+  int ntAcc = 0;
+  for (int itr=fNTracks;itr--;) {
+    //
+    AliExternalTrackParam& trc = fTracks[itr].paramInw;
+    if (trc.TestBit(kInvalidBit)) continue; // the track is invalidated, skip
+    double *param = (double*)trc.GetParameter();
+    double *covar = (double*)trc.GetCovariance();
+    //
+    double  x0=trc.GetX();
+    double &y0=param[0];
+    double &z0=param[1];
+    double sn=param[2];
+    double cs2=(1.-sn)*(1.+sn);
+    if (cs2<kAlmost0) continue;
+    double cs=TMath::Sqrt(cs2), tgp=sn/cs, tgl=trc.GetTgl()/cs;
+    // assume straight track equation Y=y0+tgp*X, Z=z0+tgl*X in tracking frame
+    //
+    double alp = trc.GetAlpha();
+    sn = TMath::Sin(alp); // parameters for rotation of vertex to
+    cs = TMath::Cos(alp); // tracking frame
+    //
+    double &syy=covar[0], &syz=covar[1], &szz=covar[2];
+    double detI = syy*szz - syz*syz;
+    if (TMath::Abs(detI)<kAlmost0) return kFALSE;
+    detI = 1./detI;
+    double syyI = szz*detI;
+    double szzI = syy*detI;
+    double syzI =-syz*detI;
+    //
+    double tmpSP = sn*tgp;
+    double tmpCP = cs*tgp;
+    double tmpSC = sn+tmpCP;
+    double tmpCS =-cs+tmpSP;
+    double tmpCL = cs*tgl;
+    double tmpSL = sn*tgl;
+    double tmpYXP = y0-tgp*x0;
+    double tmpZXL = z0-tgl*x0;
+    //
+    double tmpCLzz = tmpCL*szzI;
+    double tmpSLzz = tmpSL*szzI;
+    double tmpSCyz = tmpSC*syzI;
+    double tmpCSyz = tmpCS*syzI;
+    double tmpCSyy = tmpCS*syyI;
+    double tmpSCyy = tmpSC*syyI;
+    double tmpSLyz = tmpSL*syzI;
+    double tmpCLyz = tmpCL*syzI;
+    //
+    cxx += tmpCL*(tmpCLzz+tmpSCyz+tmpSCyz)+tmpSC*tmpSCyy;          // dchi^2/dx/dx
+    cxy += tmpCL*(tmpSLzz+tmpCSyz)+tmpSL*tmpSCyz+tmpSC*tmpCSyy;    // dchi^2/dx/dy
+    cxz += -sn*syzI-tmpCLzz-tmpCP*syzI;                            // dchi^2/dx/dz
+    cx0 += -(tmpCLyz+tmpSCyy)*tmpYXP-(tmpCLzz+tmpSCyz)*tmpZXL;     // RHS 
+    //
+    //double cyx
+    cyy += tmpSL*(tmpSLzz+tmpCSyz+tmpCSyz)+tmpCS*tmpCSyy;          // dchi^2/dy/dy
+    cyz += -(tmpCSyz+tmpSLzz);                                     // dchi^2/dy/dz
+    cy0 += -tmpYXP*(tmpCSyy+tmpSLyz)-tmpZXL*(tmpCSyz+tmpSLzz);     // RHS
+    //
+    //double czx
+    //double czy
+    czz += szzI;                                                    // dchi^2/dz/dz
+    cz0 += tmpZXL*szzI+tmpYXP*syzI;                                 // RHS
+    //
+    ntAcc++;
+  }
+  //
+  double vec[3] = {cx0,cy0,cz0};
+  AliSymMatrix mat(3);
+  mat(0,0) = cxx;
+  mat(0,1) = cxy;
+  mat(0,2) = cxz;
+  mat(1,1) = cyy;
+  mat(1,2) = cyz;
+  mat(2,2) = czz;
+
+  //-------------------------TMP>>>
+  AliRunLoader* rl = AliRunLoader::Instance();
+  AliHeader* hd = 0;
+  AliGenEventHeader* hdmc=0;
+  TArrayF vtxMC(3);
+  if (rl && (hd=rl->GetHeader()) && (hdmc=hd->GenEventHeader())) {
+    hdmc->PrimaryVertex(vtxMC);
+  }
+  //-------------------------TMP<<<
+#ifdef _DEBUG_
+  printf("MatBefore: \n"); mat.Print("d");
+#endif
+  if (mat.SolveChol(vec,kTRUE)) {
+#ifdef _DEBUG_
+    printf("MatAfter : \n"); mat.Print("d");
+#endif
+    //
+    double vtCov[6] = {mat(0,0),mat(0,1),mat(1,1),mat(0,2),mat(1,2),mat(2,2)};
+    fTrackVertex.SetXYZ(vec);
+    fTrackVertex.SetCovarianceMatrix(vtCov);
+    fTrackVertex.SetNContributors(ntAcc);
+    //
+    // calculate explicitly chi2
+    double chiTRC = 0;
+    double chiSPD = 0;
+    //
+    for (int itr=fNTracks;itr--;) {
+      AliExternalTrackParam& trc = fTracks[itr].paramInw;
+      if (trc.TestBit(kInvalidBit)) continue; // the track is invalidated, skip
+      AliExternalTrackParam trT(trc);
+      AliExternalTrackParam trS(trc);
+      double dz[2],covdum[3],*covt;
+      trT.PropagateToDCA(&fTrackVertex,fBz,10,dz,covdum);
+      covt = (double*)trT.GetCovariance();
+      double detI = covt[0]*covt[2] - covt[1]*covt[1];
+      detI = 1./detI;
+      double syyI = covt[2]*detI;
+      double szzI = covt[0]*detI;
+      double syzI =-covt[1]*detI;
+      chiTRC += dz[0]*dz[0]*syyI + dz[1]*dz[1]*szzI + 2*dz[0]*dz[1]*syzI;
+      //
+      trS.PropagateToDCA(fSPDVertex,fBz,10,dz,covdum);
+      covt = (double*)trT.GetCovariance();
+      detI = covt[0]*covt[2] - covt[1]*covt[1];
+      detI = 1./detI;
+      syyI = covt[2]*detI;
+      szzI = covt[0]*detI;
+      syzI =-covt[1]*detI;
+      chiSPD += dz[0]*dz[0]*syyI + dz[1]*dz[1]*szzI + 2*dz[0]*dz[1]*syzI;
+    }
+#ifdef _DEBUG_    
+    printf("VTFIT %f %f %f %d %8.2f %8.2f   %.4f %.4f %.4f   %.4f %.4f %.4f\n",
+          vtxMC[0],vtxMC[1],vtxMC[2],
+          ntAcc,chiTRC,chiSPD,
+          fTrackVertex.GetX(),fTrackVertex.GetY(),fTrackVertex.GetZ(),
+          fSPDVertex->GetX(),fSPDVertex->GetY(),fSPDVertex->GetZ());
+#endif
+    //
+    return kTRUE;
+  }
+  //
+  return kFALSE;
+}
+
+#ifdef _CONTROLH_
+//______________________________________________
+void AliITSSAPTracker::FillRecoStat()
+{
+  // fill data for preformance study
+  //
+  AliStack* stack = 0;
+  AliRunLoader* rl = AliRunLoader::Instance();
+  if (!rl || !(stack=rl->Stack())) return;
+  //
+  TBits patternMC;
+  enum {kIsPrim=kNLrActive,kValidTracklet,kValidTrack,kRecDone,kBitPerTrack};
+  int nTrkMC = stack->GetNtrack();
+  patternMC.SetBitNumber(nTrkMC*kBitPerTrack,0);
+  //
+  // fill MC track patterns
+  for (int ilr=kNLrActive;ilr--;) {
+    AliITSSAPLayer *lr = fLayers[ilr];
+    int ncl = lr->GetNClusters();
+    for (int icl=ncl;icl--;) {
+      AliITSRecPoint* cl = lr->GetClusterUnSorted(icl);
+      for (int j=0;j<3;j++) {
+       int lb = cl->GetLabel(j);
+       if (lb<0 || lb>=nTrkMC) break;
+       patternMC.SetBitNumber(lb*kBitPerTrack+ilr,kTRUE);
+      }
+    }
+  }
+  // set reconstructability
+  for (int itr=nTrkMC;itr--;) {
+    int bitoffs = itr*kBitPerTrack;
+    Bool_t isPrim = stack->IsPhysicalPrimary(itr);
+    patternMC.SetBitNumber(bitoffs+kIsPrim,isPrim);
+    if (patternMC.TestBitNumber(bitoffs+kALrSPD1) && patternMC.TestBitNumber(bitoffs+kALrSPD2)) {
+      patternMC.SetBitNumber(bitoffs+kValidTracklet,kTRUE);
+      //
+      TParticle* mctr = stack->Particle(itr);
+      fHTrackletMC->Fill(mctr->Pt(),isPrim);
+      // check outer layers reconstructability
+      int nmiss = 0;
+      for (int il=kALrSDD1;il<=kALrSSD2;il++) if (!fSkipLayer[il] && !patternMC.TestBitNumber(bitoffs+il)) nmiss++;
+      if (nmiss<=fMaxMissedLayers) {
+       patternMC.SetBitNumber(bitoffs+kValidTrack);
+       fHTrackMC->Fill(mctr->Pt(),isPrim);
+      }
+    }
+  }
+  //
+  int nTrk = GetNTracklets();
+  if (!nTrk) return;
+  for (int itr=0;itr<nTrk;itr++) {
+    SPDtracklet_t& trlet = fTracklets[itr];
+    //    PrintTracklet(itr);
+    //
+    int lbl = trlet.label;
+    if (lbl==fgkDummyLabel) continue;
+    int lblA = TMath::Abs(lbl);
+    int bitoffs = lblA*kBitPerTrack;
+    Bool_t isPrim = patternMC.TestBitNumber(bitoffs+kIsPrim);
+    TParticle* mctr = stack->Particle(lblA);
+    double pt = mctr->Pt();
+    fHTrackletAll->Fill(pt,isPrim);
+    if (lbl<0) fHTrackletFake->Fill(pt,isPrim);
+  }
+  //
+  nTrk = GetNTracks();
+  for (int itr=0;itr<nTrk;itr++) {
+    ITStrack_t &track = fTracks[itr];
+    CookLabel(track);
+    //
+    int lbl = track.label;
+    if (lbl==fgkDummyLabel) continue;
+    int lblA = TMath::Abs(lbl);
+    int bitoffs = lblA*kBitPerTrack;
+    Bool_t isPrim = patternMC.TestBitNumber(bitoffs+kIsPrim);
+    TParticle* mctr = stack->Particle(lblA);
+    double pt = mctr->Pt();
+    Bool_t clone = patternMC.TestBitNumber(bitoffs+kRecDone); // was the track already reconstructed?
+    float bn = isPrim ? (clone ? 2:1):(clone ? -1:0);  // fill clones in over/underflow
+    fHTrackAll->Fill(pt,bn);
+    patternMC.SetBitNumber(bitoffs+kRecDone);
+    if (lbl<0) fHTrackFake->Fill(pt,bn);
+  }
+  //
+  AliHeader* hd = rl->GetHeader();
+  AliGenEventHeader* hdmc;
+  TArrayF vtxMC;
+  if (hd && (hdmc=hd->GenEventHeader())) hdmc->PrimaryVertex(vtxMC);
+  //
+  nTrk = GetNTracklets();
+  fHVtxMltRef->Fill(nTrk);
+  if (fTrackVertex.GetStatus()==1) {
+    if (hdmc) {
+      double dx = vtxMC[0]-fTrackVertex.GetX();
+      double dy = vtxMC[1]-fTrackVertex.GetY();
+      double dz = vtxMC[2]-fTrackVertex.GetZ();
+      fHVtxDiffXY->Fill(dx,dy);
+      fHVtxDiffZ->Fill(dz);
+      fHVtxDiffXMlt->Fill(nTrk, dx);
+      fHVtxDiffYMlt->Fill(nTrk, dy);
+      fHVtxDiffZMlt->Fill(nTrk, dz);
+      //
+      double sig[3];
+      fTrackVertex.GetSigmaXYZ(sig);    
+      if (sig[0]>0) fHVtxPullXMlt->Fill(nTrk, dx/sig[0]);
+      if (sig[1]>0) fHVtxPullYMlt->Fill(nTrk, dy/sig[1]);
+      if (sig[2]>0) fHVtxPullZMlt->Fill(nTrk, dz/sig[2]);
+    }
+    fHVtxOKMlt->Fill(nTrk);
+  } 
+  //
+  if (fSPDVertex->GetStatus()==1 && hdmc) {
+    double dx = vtxMC[0]-fSPDVertex->GetX();
+    double dy = vtxMC[1]-fSPDVertex->GetY();
+    double dz = vtxMC[2]-fSPDVertex->GetZ();
+    fHVtxMCSPDDiffXY->Fill(dx,dy);
+    fHVtxMCSPDDiffZ->Fill(dz);
+    fHVtxMCSPDDiffXMlt->Fill(nTrk, dx);
+    fHVtxMCSPDDiffYMlt->Fill(nTrk, dy);
+    fHVtxMCSPDDiffZMlt->Fill(nTrk, dz);
+    //
+    double sig[3];
+    fSPDVertex->GetSigmaXYZ(sig);    
+    if (sig[0]>0) fHVtxMCSPDPullXMlt->Fill(nTrk, dx/sig[0]);
+    if (sig[1]>0) fHVtxMCSPDPullYMlt->Fill(nTrk, dy/sig[1]);
+    if (sig[2]>0) fHVtxMCSPDPullZMlt->Fill(nTrk, dz/sig[2]);
+    //
+  }
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::BookHistos()
+{
+  // book control histos
+  const int kNBinMlt=20, kNBPt=15, kNBDiffVtx=50, kNResBins=250,kNPullBins=50,kNChiClBins=50,kNBPullVtx=50;
+  const double kMinMlt=1,kMaxMlt=5000,kMinPt=0.01,kMaxPt=3, kMaxDiffVtx=0.05, kMaxResidYZ=2.5,kMaxPullYZ=10,kChiClMax=100,kMaxPullVtx=10;
+  //
+  double* axLogPt  = DefLogAx(kMinPt,kMaxPt,kNBPt);
+  double* axLogMlt = DefLogAx(kMinMlt,kMaxMlt,kNBinMlt);
+
+  for (int ilr=0;ilr<kNLrActive;ilr++) {
+    //
+    // ----------------- These are histos to be filled during tracking
+    // PropagateBack and RefitInward will be stored among the histos of 1st pass
+    //
+    int ilrS = ilr*10;
+    TString ttl = Form("residY%d",ilr);
+    TH2F* hdy = new TH2F(ttl.Data(),ttl.Data(),kNBPt,axLogPt,kNResBins,-kMaxResidYZ,kMaxResidYZ);
+    fArrHisto.AddAtAndExpand(hdy,ilrS+kHResidY);
+    hdy->SetDirectory(0);
+    //
+    ttl = Form("residYPull%d",ilr);    
+    TH2F* hdyp = new TH2F(ttl.Data(),ttl.Data(),kNBPt,axLogPt,kNPullBins,-kMaxPullYZ,kMaxPullYZ);
+    fArrHisto.AddAtAndExpand(hdyp,ilrS+kHPullY);
+    hdyp->SetDirectory(0);
+    //
+    ttl = Form("residZ%d",ilr);        
+    TH2F* hdz = new TH2F(ttl.Data(),ttl.Data(),kNBPt,axLogPt,kNResBins,-kMaxResidYZ,kMaxResidYZ);
+    fArrHisto.AddAtAndExpand(hdz,ilrS+kHResidZ);
+    hdz->SetDirectory(0);
+    //
+    ttl = Form("residZPull%d",ilr);            
+    TH2F* hdzp = new TH2F(ttl.Data(),ttl.Data(),kNBPt,axLogPt,kNPullBins,-kMaxPullYZ,kMaxPullYZ);
+    hdzp->SetDirectory(0);
+    fArrHisto.AddAtAndExpand(hdzp,ilrS+kHPullZ);
+    //
+    ttl = Form("chi2Cl%d",ilr);                
+    TH2F* hchi = new TH2F(ttl.Data(),ttl.Data(),kNBPt,axLogPt, kNChiClBins,0.,kChiClMax);
+    hchi->SetDirectory(0);
+    fArrHisto.AddAtAndExpand(hchi,ilrS+kHChi2Cl);
+  } // loop over layers
+  //
+  fHChi2NDFvsPT = new TH2F("chi2ndfPT","chi2/ndf total vs pt",kNBPt,axLogPt, kNChiClBins,0.,kChiClMax);
+  fArrHisto.AddLast(fHChi2NDFvsPT);
+  fHChi2NDFvsPT->SetDirectory(0);
+  //
+  fHChi2vsNC = new TH2F("chi2NC","chi2 total vs NCl",kNLrActive-2,2.5,kNLrActive+0.5, kNChiClBins,0.,kChiClMax);
+  fArrHisto.AddLast(fHChi2vsNC);
+  fHChi2vsNC->SetDirectory(0);
+
+  // SPDvertex vs MC
+  fHVtxMCSPDDiffXY = new TH2F("vtxMCSPDDiffXY","vtxMC-vtxSPD XY",kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx,
+                           kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxMCSPDDiffXY);
+  fHVtxMCSPDDiffXY->SetDirectory(0);
+  //
+  fHVtxMCSPDDiffZ = new TH1F("vtxMCSPDDiffZ","vtxMC-vtxSPD Z",kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxMCSPDDiffZ);
+  fHVtxMCSPDDiffZ->SetDirectory(0);
+  //
+  fHVtxMCSPDDiffXMlt = new TH2F("VtxMCSPDDiffXMlt","vX_{MC}-vX_{SPD} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxMCSPDDiffXMlt);
+  fHVtxMCSPDDiffXMlt->SetDirectory(0);
+  //
+  fHVtxMCSPDDiffYMlt = new TH2F("VtxMCSPDDiffYMlt","vY_{MC}-vY_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxMCSPDDiffYMlt);
+  fHVtxMCSPDDiffYMlt->SetDirectory(0);
+  //
+  fHVtxMCSPDDiffZMlt = new TH2F("VtxMCSPDDiffZMlt","vZ_{MC}-vZ_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxMCSPDDiffZMlt);
+  fHVtxMCSPDDiffZMlt->SetDirectory(0);
+  //
+  //
+  fHVtxMCSPDPullXMlt = new TH2F("VtxMCSPDPullXMlt","Pull vX_{MC}-vX_{SPD} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxMCSPDPullXMlt);
+  fHVtxMCSPDPullXMlt->SetDirectory(0);
+  //
+  fHVtxMCSPDPullYMlt = new TH2F("VtxMCSPDPullYMlt","Pull vY_{MC}-vY_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxMCSPDPullYMlt);
+  fHVtxMCSPDPullYMlt->SetDirectory(0);
+  //
+  fHVtxMCSPDPullZMlt = new TH2F("VtxMCSPDPullZMlt","Pull vZ_{MC}-vZ_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxMCSPDPullZMlt);
+  fHVtxMCSPDPullZMlt->SetDirectory(0);
+   //
+  fHTrackletMC = new TH2F("MCRefTracklet","MCRef Tracklet",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackletMC->SetXTitle("p_{T}");
+  fHTrackletMC->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackletMC->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackletMC);
+  fHTrackletMC->SetDirectory(0);
+  //
+  fHTrackletAll = new TH2F("TrackletAll","Tracklet All rec",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackletAll->SetXTitle("p_{T}");
+  fHTrackletAll->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackletAll->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackletAll);
+  fHTrackletAll->SetDirectory(0);
+  //
+  fHTrackletFake = new TH2F("TrackletFake","Tracklet Fake rec",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackletFake->SetXTitle("p_{T}");
+  fHTrackletFake->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackletFake->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackletFake);
+  fHTrackletFake->SetDirectory(0);
+  //
+  fHTrackMC = new TH2F("MCRefTrack","MCRef Track",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackMC->SetXTitle("p_{T}");
+  fHTrackMC->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackMC->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackMC);
+  fHTrackMC->SetDirectory(0);
+  //
+  fHTrackAll = new TH2F("TrackAll","Track All rec",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackAll->SetXTitle("p_{T}");
+  fHTrackAll->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackAll->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackAll);
+  fHTrackAll->SetDirectory(0);
+  //
+  fHTrackFake = new TH2F("TrackFake","Track Fake rec",kNBPt,axLogPt, 2, -0.5, 1.5);
+  fHTrackFake->SetXTitle("p_{T}");
+  fHTrackFake->GetYaxis()->SetBinLabel(1,"sec");
+  fHTrackFake->GetYaxis()->SetBinLabel(2,"prim");
+  fArrHisto.AddLast(fHTrackFake);
+  fHTrackFake->SetDirectory(0);
+  //
+  fHVtxMltRef = new TH1F("vtxRef","vtxRef",kNBinMlt,axLogMlt);
+  fHVtxMltRef->SetXTitle("sqrt(Ntracklets)");
+  fArrHisto.AddLast(fHVtxMltRef);
+  fHVtxMltRef->SetDirectory(0);
+  //
+  fHVtxOKMlt = new TH1F("vtxOK","vtxOK",kNBinMlt,axLogMlt);
+  fHVtxOKMlt->SetXTitle("sqrt(Ntracklets)");
+  fArrHisto.AddLast(fHVtxOKMlt);
+  fHVtxOKMlt->SetDirectory(0);
+  //
+  fHVtxDiffXY = new TH2F("vtxMCDiffXY","vtxMC-vtxRec XY",kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx,
+                        kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxDiffXY);
+  fHVtxDiffXY->SetDirectory(0);
+  //
+  fHVtxDiffZ = new TH1F("vtxMCDiffZ","vtxMC-vtxRec Z",kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxDiffZ);
+  fHVtxDiffZ->SetDirectory(0);
+  //
+  fHVtxDiffXMlt = new TH2F("VtxDiffXMlt","vX_{MC}-vX_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxDiffXMlt);
+  fHVtxDiffXMlt->SetDirectory(0);
+  //
+  fHVtxDiffYMlt = new TH2F("VtxDiffYMlt","vY_{MC}-vY_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxDiffYMlt);
+  fHVtxDiffYMlt->SetDirectory(0);
+  //
+  fHVtxDiffZMlt = new TH2F("VtxDiffZMlt","vZ_{MC}-vZ_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBDiffVtx,-kMaxDiffVtx,kMaxDiffVtx);
+  fArrHisto.AddLast(fHVtxDiffZMlt);
+  fHVtxDiffZMlt->SetDirectory(0);
+  //
+  fHVtxPullXMlt = new TH2F("VtxPullXMlt","Pull vX_{MC}-vX_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxPullXMlt);
+  fHVtxPullXMlt->SetDirectory(0);
+  //
+  fHVtxPullYMlt = new TH2F("VtxPullYMlt","Pull vY_{MC}-vY_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxPullYMlt);
+  fHVtxPullYMlt->SetDirectory(0);
+  //
+  fHVtxPullZMlt = new TH2F("VtxPullZMlt","Pull vZ_{MC}-vZ_{rec} vs mlt",kNBinMlt,axLogMlt, 
+                          kNBPullVtx,-kMaxPullVtx,kMaxPullVtx);
+  fArrHisto.AddLast(fHVtxPullZMlt);
+  fHVtxPullZMlt->SetDirectory(0);
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::SaveHistos(const char* outFName)
+{
+  // save control histos
+  TString fnms = outFName;
+  if (fnms.IsNull()) fnms = "XXXITSTrackerControlH.root";
+  TFile* fl = TFile::Open(fnms.Data(),"recreate");
+  if (!fl) {
+    printf("Failed to open output file %s\n",fnms.Data());
+    return;
+  }
+  fArrHisto.Write();
+  fl->Close();
+  delete fl;
+  printf("Stored control histos in %s\n",fnms.Data());
+  //
+}
+
+//______________________________________________
+void AliITSSAPTracker::FillTrackingControlHistos(int lrID,int lbl,const AliExternalTrackParam* track,
+                                                const double cpar[2],const double ccov[3], 
+                                                const AliITSRecPoint* bestCl)
+{
+  // fill control histos for tracking for correct matches
+  Bool_t corr = kFALSE;
+  for (int i=0;i<3;i++) if (bestCl->GetLabel(i)==lbl) {corr=kTRUE; break;}
+  if (!corr) return;
+  double pt = track->Pt();
+  double dy = cpar[0]-track->GetY();
+  double dz = cpar[1]-track->GetZ();
+  double sgy = TMath::Sqrt(ccov[0]+track->GetSigmaY2());
+  double sgz = TMath::Sqrt(ccov[2]+track->GetSigmaZ2());
+  int lrIDS = lrID*10;
+  ((TH2F*)fArrHisto[lrIDS+kHResidY])->Fill(pt,dy);
+  ((TH2F*)fArrHisto[lrIDS+kHPullY])->Fill(pt,dy/sgy);
+  ((TH2F*)fArrHisto[lrIDS+kHResidZ])->Fill(pt,dz);
+  ((TH2F*)fArrHisto[lrIDS+kHPullZ])->Fill(pt,dz/sgz);
+  ((TH2F*)fArrHisto[lrIDS+kHChi2Cl])->Fill(pt,track->GetPredictedChi2(cpar,ccov));
+  //
+}
+
+//______________________________________________
+Double_t* AliITSSAPTracker::DefLogAx(double xMn,double xMx, int nbin)
+{
+  // get array for log axis
+  if (xMn<=0 || xMx<=xMn || nbin<2) {
+    printf("Wrong axis request: %f %f %d\n",xMn,xMx,nbin);
+    return 0;
+  }
+  double dx = log(xMx/xMn)/nbin;
+  double *xax = new Double_t[nbin+1];
+  for (int i=0;i<=nbin;i++) xax[i]= xMn*exp(dx*i);
+  return xax;
+}
+
+#endif
+//
+#ifdef _TIMING_
+//______________________________________________
+void AliITSSAPTracker::PrintTiming()
+{
+  // print timing info
+  for (int i=0;i<kNSW;i++) {printf("%-10s:\t",fgkSWNames[i]); fSW[i].Print();}
+}
+#endif
diff --git a/HLT/ITS/trackingSAP/AliITSSAPTracker.h b/HLT/ITS/trackingSAP/AliITSSAPTracker.h
new file mode 100644 (file)
index 0000000..19e1935
--- /dev/null
@@ -0,0 +1,254 @@
+#ifndef ALIITSSAPTRACKER_H
+#define ALIITSSAPTRACKER_H
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TBits.h>
+#include <TStopwatch.h>
+#include <TObjArray.h>
+#include <algorithm>
+#include <vector>
+#include "AliExternalTrackParam.h"
+#include "AliESDVertex.h"
+
+//------- compilation options, comment out all for best performance ------
+#define _TIMING_                            // print timing info, use only in offline mode
+//#define _CONTROLH_                          // fill control histos, use only in offline mode
+//#define _DEBUG_                             // print debug info, use only in offline mode
+//------------------------------------------------------------------------
+
+class AliITSRecPoint;
+class AliESDVertex;
+class AliITSSAPLayer;
+
+class AliITSSAPTracker : public TObject
+{
+ public:
+  enum {kALrSPD1,kALrSPD2, kALrSDD1,kALrSDD2, kALrSSD1,kALrSSD2,kNLrActive};
+  enum {kLrBeamPime, kLrSPD1,kLrSPD2, kLrShield1, kLrSDD1,kLrSDD2, kLrShield2, kLrSSD1,kLrSSD2,
+       kMaxLrITS,kNLrPassive=kMaxLrITS-kNLrActive};
+  enum {kInvalidBit=BIT(14)};
+  //
+  struct SPDtracklet {
+    int id1;
+    int id2;
+    int label;
+    float dphi;
+    float dtht;
+    float chi2;
+  };
+  typedef struct SPDtracklet SPDtracklet_t;
+  //
+  struct ITStrack {
+  ITStrack() : paramOut(),paramInw(),chi2(0),ncl(0),nmiss(0),label(0),trackletID(0) {}
+    AliExternalTrackParam paramOut;
+    AliExternalTrackParam paramInw;
+    float chi2;
+    short ncl;
+    short nmiss;
+    int clID[6];
+    int label;
+    int trackletID;
+  };
+  typedef struct ITStrack ITStrack_t;
+  //
+  AliITSSAPTracker();
+  virtual ~AliITSSAPTracker();
+  //
+  void ProcessEvent();
+  void Init();
+  void Clear(Option_t *opt="");
+  void ClearTracklets();
+  void ClearTracks()                               {fTracks.clear();}
+  //
+  void SetSPDVertex(const AliESDVertex* v)         {fSPDVertex = v;}
+  const AliESDVertex* GetSPDVertex()  const        {return fSPDVertex;}
+  void AddCluster(AliITSRecPoint* cl);
+  void SetBz(float v)                              {fBz = v;}
+  //
+  // methods for trackleting ---------------->>>
+  Bool_t FindTracklets();
+  Int_t  AssociateClusterOfL2(int icl2);
+  Bool_t IsBlacklisted(int id1,int id2);
+  void   Blacklist(int id1,int id2);
+  //
+  void SetPhiShift(float v=0.0045)                  {fPhiShift = v;}
+  void SetSigThetaTracklet(float v=0.025)           {fSigThetaTracklet = v;}
+  void SetSigPhiTracklet(float v=0.08)              {fSigPhiTracklet = v;}
+  void SetChi2CutTracklet(float v=1.5)              {fChi2CutTracklet = v;}
+  //
+  Double_t GetClSystYErr2(Int_t lr)    const        {return fgkClSystYErr2[lr];}
+  Double_t GetClSystZErr2(Int_t lr)    const        {return fgkClSystZErr2[lr];}
+  //
+  int  GetNTracklets()                 const        {return (int)fTracklets.size();}
+  int  GetNTracks()                    const        {return fNTracks;}
+  void PrintTracklets()                const;
+  void PrintTracklet(Int_t itr)        const;
+  const AliITSSAPTracker::SPDtracklet_t& GetTracklet(int i) const {return fTracklets[i];}
+  // methods for trackleting ----------------<<<
+  //
+  // methods for track reconstruction ------->>>
+  Float_t GetMinPt()                   const        {return fMinPt;}
+  void    SetMinPt(Float_t v=0.3)                   {fMinPt = v<0.2 ? 0.2 : v;}
+  void    CalcAuxTracking();
+  Bool_t  CreateTrack(AliITSSAPTracker::ITStrack_t& track, AliITSSAPTracker::SPDtracklet_t& trlet);
+  void    Tracklets2Tracks();
+  AliITSSAPLayer* GetLayer(int i)         const        {return (AliITSSAPLayer*)fLayers[i];}
+  Int_t   GetActiveLayerID(int i)      const        {return fgkLr2Active[i];}
+  Float_t GetChi2TotCut(int ncl)       const;
+  Bool_t  CrossPassiveLayer(AliExternalTrackParam& track, Int_t lrID);
+  Bool_t  FollowToLayer(AliITSSAPTracker::ITStrack_t& track, Int_t lrID);
+  Double_t GetXatLabRLin(AliExternalTrackParam& track, double r);
+  void    CookLabel(AliITSSAPTracker::ITStrack_t& track);
+  void    CookLabel(AliITSSAPTracker::SPDtracklet_t& tracklet);
+  void    PrintTrack(const AliITSSAPTracker::ITStrack_t& track) const;
+  Bool_t  IsObligatoryLayer(int lr)    const        {return !fSkipLayer[lr];}
+  Bool_t  IsAcceptableTrack(const AliITSSAPTracker::ITStrack_t& track) const;
+  void    PrintTracks()                const;
+  Int_t   GetTrackletMCTruth(AliITSSAPTracker::SPDtracklet_t& trlet) const;
+  void    RefitInward();
+  Bool_t  RefitInward(int itr);
+  void    SetMaxMissedLayers(int n=0)  { fMaxMissedLayers = n;}
+  Int_t   GetMaxMissedLayers()    const  { return fMaxMissedLayers;}
+  AliITSSAPTracker::ITStrack_t& GetTrack(int i) const {return (ITStrack_t &)fTracks[i];}
+  // methods for track reconstruction -------<<<
+  //
+  // methods for vertex reconstruction ------>>>
+  Bool_t  FitTrackVertex();
+  AliESDVertex& GetTrackVertex()      const       {return (AliESDVertex&)fTrackVertex;}
+  // methods for vertex reconstruction ------<<<
+  //
+ protected:
+  //
+  AliITSSAPLayer* fLayers[kNLrActive];
+  Bool_t    fSkipLayer[kNLrActive];                     //! skip layer
+  Int_t     fNClusters[kNLrActive];                     //! number of clusters per event
+  //
+  // for SPD trackleting ----------------- >>>
+  std::vector<bool> fSPD2Discard;                       //! status of SPD2 clusters during trackleting
+  std::vector<SPDtracklet_t> fTracklets;                //! found tracklets
+  std::vector<int> fSPD1Tracklet;                       //! id+1 of traclet using this SPD1 cluster
+  TBits*   fBlacklist;                            //! blacklisted combinations
+  Float_t  fPhiShift;                             //! Phi shift reference value (at 0.5 T)
+  Float_t  fSigThetaTracklet;                     //! sigTheta for tracklets
+  Float_t  fSigPhiTracklet;                       //! sigPhi for tracklets
+  Float_t  fChi2CutTracklet;                      //! cut on tracklet total chi2
+  Float_t  fPhiShiftSc;                           //! dPhi offset to account for bending
+  Float_t  fDThetaTrackletSc;                     //! max dTheta for tracklets with scaling from chi2 cut
+  Float_t  fDPhiTrackletSc;                       //! max dPhi for tracklets with scaling from chi2 cut
+  Float_t  fBz;                                   //! Bz field in ITS
+  //
+  // auxilary precomputed stuff
+  Float_t  fDPhiTol;                              //! tolerance on phi, accounting for bending
+  Float_t  fDThSig2Inv;                           //! inverse of sigma dTheta
+  Float_t  fDPhSig2Inv;                           //! inverse of sigma dPhi
+  // for SPD trackleting ----------------- <<<
+  //
+  // for track reconstruction ------------ >>>
+  Float_t  fMinPt;                                //! user pt cutoff
+  Float_t  fCurvMax;                              //! max curvature to reconstruct
+  Float_t  fZSPD2CutMin;                          //! min Z of tracklet SPD2 to consider tracking
+  Float_t  fZSPD2CutMax;                          //! max Z of tracklet SPD2 to consider tracking
+  Float_t  fMaxChi2Tr2Cl;                         //! cut on cluster-to-track chi2
+  Float_t  fAddErr2YspdVtx;                       //! additional error to Y of the SPD vertex in track fit
+  Float_t  fAddErr2ZspdVtx;                       //! additional error to Z of the SPD vertex in track fit
+  Float_t  fChi2TotCut[kNLrActive];               //! cut on total chi2 depending on track length
+  //
+  Float_t  fNSigma2[kNLrActive];                  //! N^2 sigma margin for cluster search
+  Float_t  fYToler2[kNLrActive];                  //! Y additional margin^2 for cluster search
+  Float_t  fZToler2[kNLrActive];                  //! Z additional margin^2 for cluster search
+
+  Float_t  fMSDist[kNLrActive];                   //! shift due to the MS for 1 GeV particle
+  Float_t  fMSPhi[kNLrActive];                    //! dphi due to the MS for 1 GeV particle
+  Float_t  fTolPhiCrude[kNLrActive];              //! tolerance in dphi for particle of unknown momentum
+  Float_t  fTolZCrude[kNLrActive];                //! tolerance in Z for particle of unknown momentum
+  Float_t fMissChi2Penalty;                          //! penalize missed clusters
+  Int_t     fMaxMissedLayers;                        //! allow to miss at most this number of layers
+  Int_t     fNTracks;                                        //! n found tracks
+  std::vector<ITStrack_t> fTracks;                //! found tracks container
+  AliESDVertex fTrackVertex;                      //! fitted track vertex
+  Bool_t    fFitVertex;                           //! fit vertex with tracks
+  // for track reconstruction ------------ <<<
+  //                 
+                     
+  const AliESDVertex* fSPDVertex;                  //! external vertex
+
+  static const Float_t fgkRhoLITS[kMaxLrITS];      // <rho*L> for each material layer
+  static const Float_t fgkX2X0ITS[kMaxLrITS];      // <x/x0> for each material layer
+  static const Float_t fgkRLayITS[kMaxLrITS];     // radii of material layers
+  static const Float_t fgkRSpanITS[kMaxLrITS];    // half R span of the material layer
+  static const Float_t fgkZSpanITS[kMaxLrITS];    // half Z span of the material layer
+  static const Int_t   fgkPassivLrITS[kNLrPassive];  // list of passive layer enums
+  static const Int_t   fgkActiveLrITS[kNLrActive]; // list of active layer enums
+  static const Double_t fgkClSystYErr2[kNLrActive]; // syst error^2 for Y direction
+  static const Double_t fgkClSystZErr2[kNLrActive]; // syst error^2 for Y direction
+
+  static const Int_t   fgkLr2Active[kMaxLrITS]; // conversion from LrID to ActiveLr ID
+  static const Int_t   fgkLrDefBins[kNLrActive][2]; // default binning for cluster navigator
+  static const Int_t   fgkDummyLabel;               // dummy MC label
+  static const Float_t fgkDefMass;                  // default mass for tracking
+  //
+#ifdef _TIMING_
+ public:
+  enum {kSWTotal,kSWTracklets,kSWTracks,kSWVertex,kNSW};
+  void PrintTiming();
+  const TStopwatch& GetStopwatch(int i)     const {return fSW[i];}
+  const char*       GetStopwatchName(int i) const {return fgkSWNames[i];}
+ protected:
+  static const char* fgkSWNames[kNSW];
+  TStopwatch fSW[kNSW];
+#endif
+  //
+#ifdef _CONTROLH_
+ protected:
+  TObjArray fArrHisto;
+  TH2F *fHTrackletMC,*fHTrackletAll,*fHTrackletFake,*fHTrackMC,*fHTrackAll,*fHTrackFake,*fHVtxDiffXY
+    ,*fHVtxDiffXMlt,*fHVtxDiffYMlt,*fHVtxDiffZMlt
+    ,*fHVtxPullXMlt,*fHVtxPullYMlt,*fHVtxPullZMlt
+    ,*fHVtxMCSPDDiffXY
+    ,*fHVtxMCSPDDiffXMlt,*fHVtxMCSPDDiffYMlt,*fHVtxMCSPDDiffZMlt
+    ,*fHVtxMCSPDPullXY
+    ,*fHVtxMCSPDPullXMlt,*fHVtxMCSPDPullYMlt,*fHVtxMCSPDPullZMlt
+    ,*fHChi2NDFvsPT,*fHChi2vsNC;
+  TH1F *fHVtxMltRef,*fHVtxOKMlt,*fHVtxDiffZ,*fHVtxMCSPDDiffZ;
+  //
+  void FillRecoStat();
+  void FillTrackingControlHistos(int lrID,int lbl,const AliExternalTrackParam* bestTr,
+                                const double cpar[2],const double ccov[3],const AliITSRecPoint* bestCl);
+  void BookHistos();
+  Double_t* DefLogAx(double xMn,double xMx, int nbin);
+ public:
+  void SaveHistos(const char* outFName="XXXITSTrackerControlH.root");
+  TObjArray* GetHistos() const {return (TObjArray*)&fArrHisto;}
+  enum {kHResidY,kHPullY,kHResidZ,kHPullZ,kHChi2Cl};
+#endif
+
+ private:
+  AliITSSAPTracker(const AliITSSAPTracker&);
+  AliITSSAPTracker& operator=(const AliITSSAPTracker&);
+  ClassDef(AliITSSAPTracker,0) // ITS SA primaries tracker/vertexer
+};
+
+
+//______________________________________________
+inline Bool_t AliITSSAPTracker::IsBlacklisted(int id1,int id2)
+{
+  // check if this combination is blacklisted
+  return fBlacklist->TestBitNumber(UInt_t(id1*fNClusters[0])+id2);
+}
+
+//______________________________________________
+inline void AliITSSAPTracker::Blacklist(int id1,int id2)
+{
+  // blacklist this combination
+  return fBlacklist->SetBitNumber(UInt_t(id1*fNClusters[0])+id2);
+}
+
+//______________________________________________
+inline Float_t AliITSSAPTracker::GetChi2TotCut(int ncl) const
+{
+  // return chi2 cut for given number of clusters. Min ncl=3
+  return fChi2TotCut[ncl-2];
+}
+
+#endif
diff --git a/HLT/ITS/trackingSAP/Process.C b/HLT/ITS/trackingSAP/Process.C
new file mode 100644 (file)
index 0000000..f9023db
--- /dev/null
@@ -0,0 +1,503 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TH1F.h>
+#include <TH1I.h>
+#include <TH2D.h>
+#include <TFile.h>
+#include <Riostream.h>
+#include <TParticle.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+#include <TSystem.h>
+#include <TROOT.h>
+#include <TClonesArray.h>
+#include <TTree.h>
+#include <TArrayF.h>
+#include <TStyle.h>
+#include <TString.h>
+#include <TStopwatch.h>
+#include <TParticlePDG.h>
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliMultiplicity.h"
+#include "AliESDtrackCuts.h"
+#include "AliStack.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliITSRecPointContainer.h"
+#include "AliITSgeomTGeo.h"
+#include "AliITSRecPoint.h"
+#include "AliCDBManager.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+//
+
+#include "../HLT/ITS/trackingSAP/AliITSSAPAux.h"
+#include "../HLT/ITS/trackingSAP/AliITSSAPLayer.h"
+#include "../HLT/ITS/trackingSAP/AliITSSAPTracker.h"
+#include "TProfile.h"
+#include "TStopwatch.h"
+#endif
+
+
+AliITSSAPTracker* tracker=0;
+
+TTree* treeInp = 0;
+AliRunLoader* runLoader = 0;
+AliESDEvent* esd=0;
+typedef struct {
+  Bool_t  validSPD;
+  Bool_t  validTrc;
+  Bool_t  isPrim;
+  Char_t  ntlC;
+  Char_t  ntlF;
+  Char_t  mtlC;
+  Char_t  mtlF;
+  Char_t  ntrC;
+  Char_t  ntrF;
+  Int_t   pdg;
+  Int_t   evID;
+  Int_t   mult;
+  Float_t pt;
+  Float_t eta;
+  Float_t phi;
+  Float_t zv;
+  //
+  Float_t spdDPhi;
+  Float_t spdDTht;
+  Float_t spdChi2;
+} tres_t;
+
+tres_t tres;
+TFile* flOut = 0;
+TTree* trOut = 0;
+
+
+void ProcessEvent(int iev);
+void Process(const char* path);
+void ProcChunk(const char* path);
+void TestTracker(TTree* tRP, const AliESDVertex* vtx);
+void LoadClusters(TTree* tRP);
+Double_t* DefLogAx(double xMn,double xMx, int nbin);
+void CheckRecStatus();
+void InitOutTree(const char* fname="rcInfo.root");
+void SaveOutTree();
+void InitTracker(int runNumber);
+
+
+
+#ifdef _TIMING_
+TProfile* hTiming[AliITSSAPTracker::kNSW];
+#endif
+
+void Process(const char* inpData)
+{
+  //
+  InitOutTree();
+  TString inpDtStr = inpData;
+  if (inpDtStr.EndsWith(".root") || inpDtStr.EndsWith(".zip#")) {
+    ProcChunk(inpDtStr.Data());
+  }
+  else {
+    ifstream inpf(inpData);
+    if (!inpf.good()) {
+      printf("Failed on input filename %s\n",inpData);
+      return;
+    }
+    //
+    inpDtStr.ReadLine(inpf);
+    while ( !inpDtStr.IsNull() ) {
+      inpDtStr = inpDtStr.Strip(TString::kBoth,' ');
+      if (inpDtStr.BeginsWith("//") || inpDtStr.BeginsWith("#")) {inpDtStr.ReadLine(inpf); continue;}
+      inpDtStr = inpDtStr.Strip(TString::kBoth,',');
+      inpDtStr = inpDtStr.Strip(TString::kBoth,'"');
+      ProcChunk(inpDtStr.Data());
+      inpDtStr.ReadLine(inpf);
+    }
+  }
+#ifdef _CONTROLH_
+  tracker->SaveHistos();
+#endif
+  SaveOutTree();
+}
+
+void ProcChunk(const char* path)
+{
+  //
+  TString dir=path;
+  //
+  printf("Processing %s\n",dir.Data());
+  //
+  if (dir.EndsWith("AliESDs.root")) {
+    dir.ReplaceAll("AliESDs.root","");
+  }
+  //
+  esd = new AliESDEvent();
+  //
+  runLoader = AliRunLoader::Open(Form("%sgalice.root",dir.Data()));
+  if (!runLoader) {
+    printf("galice not found\n");
+    return;
+  }
+  runLoader->LoadgAlice();
+  gAlice = runLoader->GetAliRun();
+  runLoader->LoadHeader();
+  runLoader->LoadKinematics();
+  runLoader->LoadRecPoints("ITS");
+  // ESD
+  TFile* esdFile = TFile::Open(Form("%sAliESDs.root",dir.Data()));
+  if (!esdFile || !esdFile->IsOpen()) {
+    printf("Error in opening ESD file\n");
+    runLoader->UnloadKinematics();
+    runLoader->UnloadHeader();
+    runLoader->UnloadgAlice();
+    delete runLoader;
+    return;
+  }
+  treeInp = (TTree*) esdFile->Get("esdTree");
+  if (!treeInp) {
+    printf("Error: no ESD tree found\n");
+    runLoader->UnloadKinematics();
+    runLoader->UnloadHeader();
+    runLoader->UnloadgAlice();
+    delete runLoader;
+    return;
+  }
+  esd->ReadFromTree(treeInp);
+  //
+  for (int iEv=0;iEv<runLoader->GetNumberOfEvents(); iEv++) {
+    printf("ev %d\n",iEv);
+    ProcessEvent(iEv);
+  }
+  runLoader->UnloadRecPoints("all");
+  runLoader->UnloadKinematics();
+  runLoader->UnloadHeader();
+  runLoader->UnloadgAlice();
+  delete runLoader; 
+  runLoader = 0;
+  esdFile->Close();
+  delete esdFile;
+}
+
+//_______________________________________________
+void ProcessEvent(int iEv)
+{
+  runLoader->GetEvent(iEv);
+  treeInp->GetEvent(iEv);
+  //
+  if (!tracker) InitTracker(esd->GetRunNumber());
+  //
+  AliStack *stack = runLoader->Stack(); 
+  Int_t nParticles = stack ? stack->GetNtrack() : 0;
+  Int_t nTracks= esd->GetNumberOfTracks();
+  printf("Ntr: %d NPartMC: %d\n",nTracks,nParticles);
+  const AliESDVertex* vtx = esd->GetPrimaryVertexSPD();
+  if (!vtx || !vtx->GetStatus()) return;
+  //
+  TTree* treeITSRP = runLoader->GetTreeR("ITS",kFALSE);
+  if (!treeITSRP) {
+    printf("Failed to fetch ITS recpoints\n");
+    exit(1);
+  }
+  //
+#ifdef _TIMING_
+  static Double_t cpuTime[AliITSSAPTracker::kNSW] = {0};
+#endif
+  printf("\n\n\nEvent: %d\n",iEv);
+  TestTracker(treeITSRP, vtx);
+  //
+#ifdef _TIMING_
+  if (vtx->GetStatus()==1) {
+    double mlt = esd->GetMultiplicity()->GetNumberOfTracklets();
+    for (int i=0;i<AliITSSAPTracker::kNSW;i++) {
+      TStopwatch& sw = (TStopwatch&)tracker->GetStopwatch(i);
+      double tm = sw.CpuTime();
+      hTiming[i]->Fill(mlt, tm - cpuTime[i]);
+      cpuTime[i] = tm;
+    }
+  }
+#endif
+  //
+  CheckRecStatus();
+  //esd->Reset();
+  //
+}
+
+//_________________________________________________
+void TestTracker(TTree* tRP, const AliESDVertex* vtx)
+{
+  tracker->Clear(); 
+  LoadClusters(tRP); 
+  tracker->SetSPDVertex(vtx);
+  tracker->SetBz(esd->GetMagneticField());
+  tracker->ProcessEvent();
+  //
+  tracker->PrintTracklets();
+  tracker->PrintTracks();  
+  //
+  //
+  //  vtx->Print();
+  //  esd->GetMultiplicity()->Print("t");
+  //
+  /*
+  AliHeader* hd = runLoader->GetHeader();
+  AliGenEventHeader* hdmc;
+  if (tracker->GetTrackVertex().GetStatus()==1 && hd && (hdmc=hd->GenEventHeader()) ) {
+    TArrayF vtxMC;
+    hdmc->PrimaryVertex(vtxMC);
+    printf("MCvtx: %f %f %f\n",vtxMC[0],vtxMC[1],vtxMC[2]);
+  }
+  */
+}
+
+//_________________________________________________
+void LoadClusters(TTree* tRP)
+{
+  //  AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance();
+  //  TClonesArray* itsClusters = rpcont->FetchClusters(0,tRP);
+  //  if(!rpcont->IsSPDActive()){
+  //    printf("No SPD rec points found, multiplicity not calculated\n");
+  //    tRP->Print();
+  //    return;
+  //  }
+  //  else printf("NSP0: %d\n",itsClusters->GetEntriesFast());
+  static TClonesArray* itsModAdd[2198] = {0};
+  static Bool_t first = kTRUE;
+  if (first) {
+    first = 0;
+    for (int i=0;i<2198;i++) itsModAdd[i] = new TClonesArray("AliITSRecPoint");
+  }
+  int nMod = AliITSgeomTGeo::GetNModules();
+  for (int imd=0;imd<nMod;imd++) {
+    TClonesArray* itsClusters = itsModAdd[imd];
+    tRP->SetBranchAddress("ITSRecPoints",&itsClusters);    
+    tRP->GetEntry(imd);
+    //    itsClusters = rpcont->UncheckedGetClusters(imd);
+    
+    int nClusters = itsClusters->GetEntriesFast();
+    if (!nClusters) continue;
+    while(nClusters--) {
+      AliITSRecPoint* cluster = (AliITSRecPoint*)itsClusters->UncheckedAt(nClusters);
+      if (!cluster) continue;
+      tracker->AddCluster(cluster);
+    }
+  }
+  //
+}
+
+//______________________________________________
+Double_t* DefLogAx(double xMn,double xMx, int nbin)
+{
+  // get array for log axis
+  if (xMn<=0 || xMx<=xMn || nbin<2) {
+    printf("Wrong axis request: %f %f %d\n",xMn,xMx,nbin);
+    return 0;
+  }
+  double dx = log(xMx/xMn)/nbin;
+  double *xax = new Double_t[nbin+1];
+  for (int i=0;i<=nbin;i++) xax[i]= xMn*exp(dx*i);
+  return xax;
+}
+//______________________________________________
+void CheckRecStatus()
+{
+  //
+  static int nev = -1;
+  static TBits patternMC;
+  static vector<char> ntrCorr;
+  static vector<char> ntrFake;
+  static vector<char> mtlCorr;
+  static vector<char> mtlFake;
+  static vector<char> ntlCorr;
+  static vector<char> ntlFake;
+  static vector<float> spdDPhi;
+  static vector<float> spdDTht;
+  static vector<float> spdChi2;
+  //
+  AliStack* stack = 0;
+  AliRunLoader* rl = AliRunLoader::Instance();
+  if (!rl || !(stack=rl->Stack())) return;
+  nev++;
+  //
+  enum {kIsPrim=AliITSSAPTracker::kNLrActive,kValidTracklet,kValidTrack,kRecDone,kBitPerTrack};
+  int nTrkMC = stack->GetNtrack();
+  patternMC.SetBitNumber(nTrkMC*kBitPerTrack,0);
+  patternMC.ResetAllBits();
+  //
+  ntrCorr.clear();
+  ntrFake.clear();
+  ntlCorr.clear();
+  ntlFake.clear();
+  mtlCorr.clear();
+  mtlFake.clear();
+  //
+  spdDPhi.clear();
+  spdDTht.clear();
+  spdChi2.clear();
+  //  
+  ntrCorr.resize(nTrkMC,0);
+  ntrFake.resize(nTrkMC,0);
+  ntlCorr.resize(nTrkMC,0);
+  ntlFake.resize(nTrkMC,0);
+  mtlCorr.resize(nTrkMC,0);
+  mtlFake.resize(nTrkMC,0);
+  spdDPhi.resize(nTrkMC,0);
+  spdDTht.resize(nTrkMC,0);
+  spdChi2.resize(nTrkMC,0);
+  
+  //
+  // fill MC track patterns
+  for (int ilr=6;ilr--;) {
+    AliITSSAPLayer *lr = tracker->GetLayer(ilr);
+    int ncl = lr->GetNClusters();
+    for (int icl=ncl;icl--;) {
+      AliITSRecPoint* cl = lr->GetClusterUnSorted(icl);
+      for (int j=0;j<3;j++) {
+       int lb = cl->GetLabel(j);
+       if (lb<0 || lb>=nTrkMC) break;
+       patternMC.SetBitNumber(lb*kBitPerTrack+ilr,kTRUE);
+      }
+    }
+  }
+  //
+  int nTrk = tracker->GetNTracklets();
+  if (!nTrk) return;
+  for (int itr=0;itr<nTrk;itr++) {
+    const AliITSSAPTracker::SPDtracklet_t& trlet = tracker->GetTracklet(itr);
+    //    PrintTracklet(itr);
+    //
+    int lbl = trlet.label;
+    if (lbl==-3141593) continue;
+    int lblA = TMath::Abs(lbl);
+    if (lblA==lbl) ntlCorr[lblA]++;
+    else           ntlFake[lblA]++;
+    //
+    if (spdChi2[lblA]==0 || spdChi2[lblA]<trlet.chi2) {
+      spdChi2[lblA] = trlet.chi2;
+      spdDPhi[lblA] = trlet.dphi;
+      spdDTht[lblA] = trlet.dtht;
+    }
+  }
+  //
+  AliITSSAPLayer* lr0 = tracker->GetLayer(0);
+  AliITSSAPLayer* lr1 = tracker->GetLayer(1);
+  for (int itrm=0;itrm<nTrkMC;itrm++) {
+    if (ntlCorr[itrm]+ntlFake[itrm]<2) continue;
+    printf("\nExtra for tr %d nC:%d nF:%d\n",itrm,ntlCorr[itrm],ntlFake[itrm]);
+    //
+    int cnt = 0;
+    for (int itr=0;itr<nTrk;itr++) {
+      const AliITSSAPTracker::SPDtracklet_t& trlet = tracker->GetTracklet(itr);
+      if (TMath::Abs(trlet.label)!=itrm) continue;
+      AliITSSAPLayer::ClsInfo_t* clinf0 = lr0->GetClusterInfo(trlet.id1);
+      AliITSSAPLayer::ClsInfo_t* clinf1 = lr1->GetClusterInfo(trlet.id2);
+      printf("#%2d%s%4d chi:%.2f [%4d/%3d] [%4d/%3d]\n",cnt++,trlet.label<0 ? "-":"+",itr,trlet.chi2,
+             trlet.id1,clinf0->detid,
+             trlet.id2,clinf1->detid);
+    }
+  }
+  //
+  const AliMultiplicity* mltESD = esd->GetMultiplicity();
+  nTrk = mltESD->GetNumberOfTracklets();
+  for (int itr=0;itr<nTrk;itr++) {
+    int lb0 = mltESD->GetLabel(itr,0);
+    int lb1 = mltESD->GetLabel(itr,1);    
+    if (lb0==lb1) mtlCorr[lb1]++;
+    else          mtlFake[lb1]++;
+  }
+  //
+  nTrk = tracker->GetNTracks();
+  for (int itr=0;itr<nTrk;itr++) {
+    const AliITSSAPTracker::ITStrack_t &track = tracker->GetTrack(itr);
+    //
+    int lbl = track.label;
+    if (lbl==-3141593) continue;
+    int lblA = TMath::Abs(lbl);
+    if (lblA==lbl) ntrCorr[lblA]++;
+    else           ntrFake[lblA]++;
+  }
+  //
+  // set reconstructability
+  for (int itr=nTrkMC;itr--;) {
+    int bitoffs = itr*kBitPerTrack;
+    //
+    tres.validSPD = patternMC.TestBitNumber(bitoffs+AliITSSAPTracker::kALrSPD1) && 
+      patternMC.TestBitNumber(bitoffs+AliITSSAPTracker::kALrSPD2);
+    int nmiss = 0;
+    for (int il=AliITSSAPTracker::kALrSDD1;il<=AliITSSAPTracker::kALrSSD2;il++) 
+      if (tracker->IsObligatoryLayer(il) && !patternMC.TestBitNumber(bitoffs+il)) nmiss++;
+    tres.validTrc = tres.validSPD && (nmiss<=tracker->GetMaxMissedLayers());
+    //
+    if ( !tres.validSPD && !tres.validTrc && 
+        (ntlCorr[itr]+ntlFake[itr])==0 && 
+        (ntrCorr[itr]+ntrFake[itr])==0 &&
+        (mtlCorr[itr]+mtlFake[itr])==0 ) continue;
+    //
+    TParticle* mctr = stack->Particle(itr);
+    tres.isPrim = stack->IsPhysicalPrimary(itr);
+    tres.pdg = mctr->GetPdgCode();
+    tres.pt =  mctr->Pt();
+    tres.eta = mctr->Eta();
+    tres.phi = mctr->Phi();
+    //
+    tres.ntlC = ntlCorr[itr];
+    tres.ntlF = ntlFake[itr];
+    tres.ntrC = ntrCorr[itr];
+    tres.ntrF = ntrFake[itr];
+    //
+    tres.mtlC = mtlCorr[itr];
+    tres.mtlF = mtlFake[itr];
+    //
+    tres.evID = nev;
+    tres.mult = tracker->GetNTracklets();
+    tres.zv = tracker->GetSPDVertex()->GetZ();
+    //
+    tres.spdDPhi = spdDPhi[itr];
+    tres.spdDTht = spdDTht[itr];
+    tres.spdChi2 = spdChi2[itr];
+    //
+    trOut->Fill();
+  }
+  //
+}
+
+//___________________________________________________
+void InitOutTree(const char* fname)
+{
+  // output tree
+  flOut = TFile::Open(fname,"recreate");
+  trOut = new TTree("rcinfo","rcinfo");
+  trOut->Branch("res",&tres);
+}
+
+//___________________________________________________
+void SaveOutTree()
+{
+  if (!trOut) return;
+  flOut->cd();
+  trOut->Write();
+  delete trOut;
+  flOut->Close();
+  delete flOut;
+  trOut = 0;
+  flOut = 0;
+}
+
+
+//______________________________________________
+void InitTracker(int runNumber)
+{
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetRun(runNumber);
+  tracker = new AliITSSAPTracker(); 
+  tracker->Init();
+  //
+  //
+#ifdef _TIMING_
+  int nbMlt = 100;
+  double *mltAx = DefLogAx(1,6000,nbMlt);
+  for (int i=0;i<AliITSSAPTracker::kNSW;i++) {
+    hTiming[i] = new TProfile(tracker->GetStopwatchName(i),tracker->GetStopwatchName(i),nbMlt,mltAx);
+  }
+#endif
+  //  
+}
diff --git a/HLT/ITS/trackingSAP/README b/HLT/ITS/trackingSAP/README
new file mode 100644 (file)
index 0000000..35235d6
--- /dev/null
@@ -0,0 +1,10 @@
+To test tracker in the offline mode, run the TestITSSAP.C
+macro as
+aliroot 'TestITSSAP.C(<path>)'
+where the <path> is the directory cotaining the output of the standard
+reconstruction, including the ITS.RecPoints.root file
+
+
+To test tracker in the HLT simulation, generate some MC (e.g. ppbench),
+copy the macro TestHLTITSSAP.C to the generation directory and run
+aliroot TestHLTITSSAP.C
diff --git a/HLT/ITS/trackingSAP/TestHLTITSSAP.C b/HLT/ITS/trackingSAP/TestHLTITSSAP.C
new file mode 100644 (file)
index 0000000..e8070c9
--- /dev/null
@@ -0,0 +1,44 @@
+void TestHLTITSSAP() {
+
+  gSystem->Load("liblhapdf");
+  gSystem->Load("libEGPythia6");
+  gSystem->Load("libpythia6");
+  gSystem->Load("libAliPythia6");
+  gSystem->Load("libhijing");
+  gSystem->Load("libTHijing");
+  gSystem->Load("libgeant321");
+
+  if (gSystem->Getenv("EVENT"))
+   nev = atoi(gSystem->Getenv("EVENT")) ;   
+  
+  AliSimulation simulator;
+  simulator.SetRunGeneration(0);
+  simulator.SetRunSimulation(0);
+  simulator.SetMakeDigits("");
+  simulator.SetMakeSDigits("");
+  simulator.SetMakeDigitsFromHits("");
+  //simulator.SetWriteRawData("ALL","raw.root",kTRUE);
+
+  simulator.SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  simulator.SetSpecificStorage("GRP/GRP/Data",
+                              Form("local://%s",gSystem->pwd()));
+  simulator.SetSpecificStorage("ITS/Align/Data",
+                              "alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
+  
+  simulator.SetRunQA(":") ; 
+
+  AliHLTConfigurationHandler::CreateHandler();
+  AliHLTConfigurationHandler *handler = AliHLTConfigurationHandler::Instance();
+
+  handler->CreateConfiguration("ITS-SAPtracker1","ITSSAPTracker","DigitClusterFinder ITS-SPD-vertexer",
+                              "");
+
+
+  simulator.SetRunHLT("chains=ITS-SAPtracker1");
+  
+  TStopwatch timer;
+  timer.Start();
+  simulator.Run();
+  timer.Stop();
+  timer.Print();
+}
diff --git a/HLT/ITS/trackingSAP/TestITSSAP.C b/HLT/ITS/trackingSAP/TestITSSAP.C
new file mode 100644 (file)
index 0000000..1aeb12c
--- /dev/null
@@ -0,0 +1,32 @@
+// macro to test AliITSSAPTracker in offline mode using already reconstructed data 
+// The input should be either
+// 1) directory containing the output of the reconstruction, e.g. ppbench/
+// (we need AliESDs.root to obtain the input SPD vertex and ITS.RecPoints.root)
+// 2) for multiple input files: text file with paths to AliESDs.root files, 
+// e.g. /data1/LHC10h8/137366/003/AliESDs.root etc.
+// Full reconstruction output should be in these directories (including galice.root)
+
+void TestITSSAP(const char *datapath = "~/ppbench"){
+  //
+  TString dtPath = datapath; 
+  //
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  //  man->SetDefaultStorage("local:///home/shahoian/ALICE/Aliroot/OCDB");
+  //  man->SetSpecificStorage("ITS/Align/Data","alien://folder=/alice/simulation/2008/v4-15-Release/Residual");
+  //  man->SetSpecificStorage("ITS/Align/Data","alien://folder=/alice/simulation/2008/v4-15-Release/Ideal");
+  //  man->SetSpecificStorage("ITS/Align/Data","local:///alice/simulation/2008/v4-15-Release/Ideal");
+  //man->SetSpecificStorage("ITS/Align/Data","local:///alice/simulation/2008/v4-15-Release/Residual");
+  //
+  TString inpData;
+  if (!(dtPath.EndsWith(".txt")||dtPath.EndsWith(".dat"))) {
+    inpData = Form("%s/AliESDs.root",dtPath.Data());
+    gSystem->Exec(Form("ln -s -f %s/geometry.root ./",dtPath.Data()));
+  }
+  else inpData = dtPath;
+  printf("InputData : %s\n",inpData.Data());
+  gSystem->Load("libAliHLTITS.so");
+  gROOT->ProcessLine(".L Process.C+");
+  Process(inpData.Data());
+  //
+}
diff --git a/HLT/global/.rootrc b/HLT/global/.rootrc
new file mode 100644 (file)
index 0000000..09e33a3
--- /dev/null
@@ -0,0 +1,2 @@
+#root include path
+ACLiC.IncludePaths: -I$(ALICE_ROOT)/include -I$(ALICE_ROOT)/HLT/BASE -I$(ALICE_ROOT)/HLT/TPCLib -I$(ALICE_ROOT)/HLT/global -I$(ALICE_ROOT)/STEER/ESD
diff --git a/HLT/global/AliFlatESDEvent.cxx b/HLT/global/AliFlatESDEvent.cxx
new file mode 100644 (file)
index 0000000..174dd90
--- /dev/null
@@ -0,0 +1,355 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing an ESD <<
+ *
+ * To be used in the online and offline calibration schema.
+ *
+ * Class provides interface methods for 
+ *   - Filling from AliESDEvent, but also from HLT (to be added)
+ *   - Getter methods
+ *
+ * In the online case, the structure can be directly written into a shared 
+ * memory, in the offline case, the size has to be estimated first.
+ *
+ * 
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ * ************************************************************************
+ * Offline usage:
+ *
+ *  ...
+ *  AliESDEvent* esd = ....;
+ *  Bool_t useESDFriends = kTRUE;
+ *
+ *  // -- Book memory for AliFlatESDEvent
+ *  Byte_t *mem = new Byte_t[AliFlatESDEvent::EstimateSize(esd, useESDFriends)];
+ *  AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem);
+ *
+ *  // -- Fill AliFlatESDEvent
+ *  flatEsd->Fill(esd, useESDFriends);  
+ *  ...
+ *
+ **************************************************************************/
+
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDfriend.h"
+#include "AliESDv0.h"
+
+#include "AliFlatESDEvent.h"
+#include "AliFlatESDTrack.h"
+#include "AliFlatTPCCluster.h"
+#include "AliFlatExternalTrackParam.h"
+#include "Riostream.h"
+
+#include "AliFlatESDVertex.h"
+
+#include "AliFlatESDV0.h"
+#include "AliFlatESDTrigger.h"
+
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
+
+// _______________________________________________________________________________________________________
+AliFlatESDEvent::AliFlatESDEvent() 
+  :
+  fContentSize(0),
+  fMagneticField(0),
+  fPeriodNumber(0),
+  fRunNumber(0),
+  fOrbitNumber(0),
+  fTimeStamp(0),
+  fEventSpecie(0),
+  fBunchCrossNumber(0),
+  fPrimaryVertexMask(0),
+  fTriggerMask(0),
+  fTriggerMaskNext50(0),
+  fNTriggerClasses(0),
+  fNPrimaryVertices(0),
+  fNTracks(0),
+  fNV0s(0),
+  fTriggerPointer(0),
+  fPrimaryVertexTracksPointer(0),
+  fPrimaryVertexSPDPointer(0),
+  fTrackTablePointer(0),
+  fTracksPointer(0),
+  fV0Pointer(0),
+  fFriendEvent(NULL)
+{
+  // Default constructor
+  fContent[0]=0;
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+AliFlatESDEvent::AliFlatESDEvent( AliVConstructorReinitialisationFlag /*f*/ ) 
+  :
+ fFriendEvent(NULL)
+{
+  // Constructor for reinitialisation of vtable
+  
+  // Reinitialise trigger information  
+  {
+    AliFlatESDTrigger * trigger =  reinterpret_cast< AliFlatESDTrigger*>( fContent + fTriggerPointer ); 
+    for( UInt_t i=0; i<fNTriggerClasses; i++ ){
+      trigger->Reinitialize();
+      trigger = trigger->GetNextTriggerNonConst();
+    }
+  }
+
+  // Reinitialise primary vertices
+
+  if( fPrimaryVertexMask & 0x1 ){
+    AliFlatESDVertex *vtxSPD = reinterpret_cast<AliFlatESDVertex*>(fContent + fPrimaryVertexSPDPointer);
+    vtxSPD->Reinitialize();
+  }
+  if( fPrimaryVertexMask & 0x2 ){
+    AliFlatESDVertex *vtxTracks = reinterpret_cast<AliFlatESDVertex*>(fContent + fPrimaryVertexTracksPointer);
+    vtxTracks->Reinitialize();
+  }
+
+  // Reinitialise tracks 
+  {
+    AliFlatESDTrack *track = reinterpret_cast<AliFlatESDTrack*>( fContent + fTracksPointer );
+    for( UInt_t i=0; i<fNTracks; i++ ){
+      track->Reinitialize();
+      track = track->GetNextTrackNonConst();
+    }
+  }
+
+  // Reinitialise V0s
+  {
+    AliFlatESDV0 *v0 = reinterpret_cast<AliFlatESDV0*>( fContent + fV0Pointer ); 
+    for( UInt_t i=0; i < fNV0s; i++){
+      v0->Reinitialize();
+      v0 = v0->GetNextV0NonConst();
+    }
+  }
+}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+
+TString AliFlatESDEvent::GetFiredTriggerClasses() const 
+{ 
+  // Fired trigger classes
+  TString trclasses; 
+  const AliFlatESDTrigger *tr = GetTriggerClasses();
+  ULong64_t mask = GetTriggerMask() | GetTriggerMaskNext50();
+  for(Int_t i = 0; i < GetNumberOfTriggerClasses(); i++) {
+    int index = tr->GetTriggerIndex();    
+    if( mask & (1ull<<index) ){
+      trclasses += " ";
+      trclasses += tr->GetTriggerClassName();
+      trclasses += " ";
+    }
+  }
+  tr = tr->GetNextTrigger();
+  return trclasses;
+}
+
+
+void AliFlatESDEvent::Reset()
+{
+  // Init
+
+  fContentSize = 0;
+  fMagneticField = 0;
+  fPeriodNumber = 0;
+  fRunNumber = 0;
+  fOrbitNumber = 0;
+  fTimeStamp = 0;
+  fBunchCrossNumber = 0;
+  fPrimaryVertexMask = 0;
+  fTriggerMask = 0;
+  fTriggerMaskNext50 = 0;
+  fNTriggerClasses = 0;
+  fNPrimaryVertices = 0;
+  fNTracks = 0;
+  fNV0s = 0;
+  fTriggerPointer = 0;
+  fPrimaryVertexTracksPointer = 0;
+  fPrimaryVertexSPDPointer = 0;
+  fTrackTablePointer = 0;
+  fTracksPointer = 0;
+  fV0Pointer = 0;
+}
+
+// _______________________________________________________________________________________________________
+  ULong64_t AliFlatESDEvent::EstimateSize(AliESDEvent *esd, Bool_t fillV0s) 
+{
+  // Estimate upper limit of the object size
+  // -> Added objects have to be added here as well
+  
+  ULong64_t size = sizeof(AliFlatESDEvent);
+  size += 2 * sizeof( AliFlatESDVertex );
+  size += esd->GetNumberOfTracks() * ( AliFlatESDTrack::EstimateSize() + sizeof(Long64_t) );
+  size += AliESDRun::kNTriggerClasses * sizeof(AliFlatESDTrigger) ;
+  if( fillV0s ) size += esd->GetNumberOfV0s()*sizeof(AliFlatESDV0);
+  return size;
+}
+
+Int_t AliFlatESDEvent::SetPrimaryVertexTracks( const AliESDVertex *vtx, size_t allocatedVtxMemory )
+{
+  // fill primary vertex tracks
+  if( !vtx ) return 0;
+       if(!vtx->GetStatus()) return 0;
+  if( allocatedVtxMemory < sizeof(AliFlatESDVertex) ) return -1;
+  fPrimaryVertexMask |= 0x1;
+  fPrimaryVertexTracksPointer = fContentSize;
+  AliFlatESDVertex *flatVtx = reinterpret_cast<AliFlatESDVertex*> (fContent + fContentSize);
+  flatVtx->SetFromESDVertex( *vtx );
+  fContentSize += flatVtx->GetSize();
+  return 0;
+}
+
+Int_t AliFlatESDEvent::SetPrimaryVertexSPD( const AliESDVertex *vtx, size_t allocatedVtxMemory  )
+{
+  // fill primary vertex SPD
+  if( !vtx ) return 0;
+       if(!vtx->GetStatus()) return 0;
+  if( allocatedVtxMemory < sizeof(AliFlatESDVertex) ) return -1;
+  fPrimaryVertexMask |= 0x2;
+  fPrimaryVertexSPDPointer = fContentSize;
+  AliFlatESDVertex *flatVtx = reinterpret_cast<AliFlatESDVertex*> (fContent + fContentSize);
+  flatVtx->SetFromESDVertex( *vtx );
+  fContentSize += flatVtx->GetSize();
+  return 0;
+}
+
+
+// _______________________________________________________________________________________________________
+Int_t AliFlatESDEvent::SetFromESD( const size_t allocatedMemorySize, const AliESDEvent *esd, const Bool_t fillV0s)
+{
+  // Fill flat ESD event from normal ALiESDEvent
+  // - Fill tracks + v0s
+  // -> Added objects have to be added here as well
+  if( allocatedMemorySize < sizeof(AliFlatESDEvent) ) return -1;
+
+  Reset();
+  
+  if( !esd ) return 0;
+  
+  Int_t err = 0;
+  size_t freeSpace = allocatedMemorySize - GetSize();
+
+  // fill run info
+  {
+    SetMagneticField( esd->GetMagneticField() );
+    SetPeriodNumber( esd->GetPeriodNumber() );
+    SetRunNumber( esd->GetRunNumber() );
+    SetOrbitNumber( esd->GetOrbitNumber() );
+    SetBunchCrossNumber( esd->GetBunchCrossNumber() );
+    SetTimeStamp( esd->GetTimeStamp() );
+    SetEventSpecie( esd->GetEventSpecie() );
+    SetTriggerMask( esd->GetTriggerMask() );
+    SetTriggerMaskNext50( esd->GetTriggerMaskNext50() );
+  }
+  // Fill trigger information  
+  {
+    size_t triggerSize = 0;
+    int nTriggers = 0;
+    AliFlatESDTrigger *trigger = SetTriggersStart();
+    const AliESDRun*  esdRun = esd->GetESDRun();
+    if( esdRun ){ 
+      for( int index=0; index<AliESDRun::kNTriggerClasses; index++){
+        const char* name = esdRun->GetTriggerClass(index);
+       if( name && name[0]!='\0' ){
+          err = trigger->SetTriggerClass( name, index, freeSpace );
+         if( err!=0 ) return err;
+         nTriggers++;
+         freeSpace -= trigger->GetSize();
+         triggerSize += trigger->GetSize();
+         trigger = trigger->GetNextTriggerNonConst();
+        }
+      }
+    }
+    SetTriggersEnd( nTriggers, triggerSize );    
+  }
+
+  // fill primary vertices
+
+  err = SetPrimaryVertexTracks( esd->GetPrimaryVertexTracks(), freeSpace );
+  if( err!=0 ) return err;
+  freeSpace = allocatedMemorySize - GetSize();
+
+  err = SetPrimaryVertexSPD( esd->GetPrimaryVertexSPD(), freeSpace );
+  if( err!=0 ) return err;
+  freeSpace = allocatedMemorySize - GetSize();
+
+  // fill tracks 
+  {
+   size_t trackSize = 0;
+   int nTracks = 0;
+   Long64_t *table = NULL;
+   AliFlatESDTrack *flatTrack = NULL;
+   err = SetTracksStart( flatTrack, table, esd->GetNumberOfTracks(), freeSpace );
+   if( err!=0 ) return err;
+   freeSpace = allocatedMemorySize - GetSize();
+
+   for (Int_t idxTrack = 0; idxTrack < esd->GetNumberOfTracks(); ++idxTrack) {
+     AliESDtrack *esdTrack = esd->GetTrack(idxTrack);
+     table[idxTrack] = -1;
+     if (esdTrack) {
+       table[idxTrack] = trackSize;
+       if( freeSpace<flatTrack->EstimateSize() ) return -1;
+       new (flatTrack) AliFlatESDTrack;       
+       flatTrack->SetFromESDTrack( esdTrack );
+       trackSize += flatTrack->GetSize();
+       freeSpace -= flatTrack->GetSize();
+       nTracks++;
+       flatTrack = flatTrack->GetNextTrackNonConst();
+     }
+   }
+   SetTracksEnd( nTracks, trackSize );
+  }
+
+  // fill V0s
+
+  if( fillV0s ){
+    size_t v0size = 0;
+    int nV0s = 0; 
+    AliFlatESDV0 *flatV0 = SetV0sStart();
+    for( int i=0; i < esd->GetNumberOfV0s(); i++){
+      AliESDv0 *esdV0 = esd->GetV0( i );
+      if( !esdV0 || freeSpace < flatV0->GetSize() ) return -1;
+      new (flatV0) AliFlatESDV0;
+      flatV0->SetNegTrackID( esdV0->GetNindex());
+      flatV0->SetPosTrackID( esdV0->GetPindex());
+      nV0s++;
+      v0size += flatV0->GetSize();
+      freeSpace -= flatV0->GetSize(); 
+      flatV0 = flatV0->GetNextV0NonConst();
+    }
+    SetV0sEnd( nV0s, v0size );
+  }
+  
+  return 0;
+}
+
+AliVParticle* AliFlatESDEvent::GetTrack(Int_t i) const
+{
+  return const_cast<AliFlatESDTrack*>(GetFlatTrack(i));
+}
+  
+AliVEvent::EDataLayoutType AliFlatESDEvent::GetDataLayoutType() const 
+{
+  return AliVEvent::kFlat;
+}
+
diff --git a/HLT/global/AliFlatESDEvent.h b/HLT/global/AliFlatESDEvent.h
new file mode 100644 (file)
index 0000000..605ad33
--- /dev/null
@@ -0,0 +1,309 @@
+#ifndef ALIFLATESDEVENT_H
+#define ALIFLATESDEVENT_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include "AliVEvent.h"
+#include "AliFlatESDTrack.h"
+#include "AliFlatESDVertex.h"
+#include "AliFlatESDFriend.h"
+#include "AliESDVertex.h"
+
+class AliFlatESDV0;
+class AliFlatESDTrigger;
+
+class AliESDEvent;
+class AliESDVertex;
+
+class AliFlatESDEvent :public AliVEvent {
+ public:
+  // --------------------------------------------------------------------------------
+  // -- Constructor / Destructors
+  AliFlatESDEvent();
+  ~AliFlatESDEvent() {}
+
+  // constructor and method for reinitialisation of virtual table
+  AliFlatESDEvent( AliVConstructorReinitialisationFlag );
+  void Reinitialize() { new (this) AliFlatESDEvent( AliVReinitialize ); }
+
+  // --------------------------------------------------------------------------------
+
+  Double_t  GetMagneticField() const { return fMagneticField; }
+  UInt_t    GetPeriodNumber()  const { return fPeriodNumber; }
+  Int_t     GetRunNumber()     const { return fRunNumber; }
+  UInt_t    GetOrbitNumber()   const { return fOrbitNumber; }
+  UShort_t  GetBunchCrossNumber() const { return fBunchCrossNumber; }
+  ULong64_t GetTriggerMask()      const { return fTriggerMask; }  
+  ULong64_t GetTriggerMaskNext50()   const { return fTriggerMaskNext50; }  
+  TString   GetFiredTriggerClasses() const ;
+  Int_t GetNumberOfTracks() const { return fNTracks; }
+  Int_t GetNumberOfV0s()    const { return fNV0s; }
+
+  void Reset();
+  void ConnectTracks(){} // initialisation, needed by the ESD event, part of VVevent interface
+
+  UInt_t GetTimeStamp()     const { return fTimeStamp; }
+  UInt_t GetEventSpecie()   const { return fEventSpecie; }
+  Int_t  GetNumberOfKinks() const { return 0; }  
+
+  AliVTrack  *GetVTrack( Int_t i ) const { return GetFlatTrackNonConst(i); }
+  AliESDkink *GetKink(Int_t /*i*/) const { return NULL;}
+
+  using AliVEvent::GetPrimaryVertex;
+  using AliVEvent::GetPrimaryVertexTPC;
+  using AliVEvent::GetPrimaryVertexSPD;
+  using AliVEvent::GetPrimaryVertexTracks;
+  Int_t GetPrimaryVertex( AliESDVertex &v ) const ;
+  Int_t GetPrimaryVertexTPC( AliESDVertex &v ) const ;
+  Int_t GetPrimaryVertexSPD( AliESDVertex &v ) const ;
+  Int_t GetPrimaryVertexTracks( AliESDVertex &v ) const ;
+
+  AliVfriendEvent* FindFriend() const { return fFriendEvent; }
+
+  // --------------------------------------------------------------------------------
+  // Own methods 
+
+  // -- Set methods
+
+  Int_t SetFromESD( size_t allocatedMemorySize, const AliESDEvent *esd, const Bool_t fillV0s=kTRUE );
+
+  void SetFriendEvent( AliFlatESDFriend *f ) { fFriendEvent=f; }
+
+  void  SetMagneticField( Double_t mf ){ fMagneticField = mf; }
+  void  SetPeriodNumber( Int_t n ) { fPeriodNumber = n; }
+  void  SetRunNumber( Int_t n ) { fRunNumber = n; }
+  void  SetOrbitNumber( UInt_t n ) { fOrbitNumber = n; }
+  void  SetBunchCrossNumber( UShort_t n ) { fBunchCrossNumber = n; }
+  void  SetTimeStamp( UInt_t timeStamp ){ fTimeStamp = timeStamp; }
+  void  SetEventSpecie(UInt_t eventSpecie){ fEventSpecie = eventSpecie; }
+  void  SetTriggerMask(ULong64_t n) { fTriggerMask = n; }
+  void  SetTriggerMaskNext50(ULong64_t n) { fTriggerMaskNext50 = n; }
+  
+  Int_t  SetPrimaryVertexTracks( const AliESDVertex *v, size_t allocatedVtxMemory );
+  Int_t  SetPrimaryVertexSPD( const AliESDVertex *v, size_t allocatedVtxMemory  );
+
+  AliFlatESDTrigger *SetTriggersStart();
+  void SetTriggersEnd( Int_t nTriggerClasses, size_t triggersSize );
+
+  Int_t SetTracksStart( AliFlatESDTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem);
+  void SetTracksEnd( Int_t nTracks, size_t tracksSize );
+
+  AliFlatESDV0 *SetV0sStart();
+  void SetV0sEnd( Int_t nV0s, size_t v0sSize );
+
+  // --------------------------------------------------------------------------------
+  // -- Getter methods
+
+  const AliFlatESDVertex* GetFlatPrimaryVertexSPD() const ;
+  const AliFlatESDVertex* GetFlatPrimaryVertexTracks() const ;
+
+  Int_t GetNumberOfTriggerClasses() const { return fNTriggerClasses; }
+   
+  const AliFlatESDTrigger *GetTriggerClasses() const { return reinterpret_cast<const AliFlatESDTrigger*>( fContent + fTriggerPointer ); }
+  const AliFlatESDTrack   *GetTracks() const { return reinterpret_cast<const AliFlatESDTrack*>( fContent + fTracksPointer ); }
+  const AliFlatESDV0      *GetV0s() const { return reinterpret_cast<const AliFlatESDV0*>( fContent + fV0Pointer ); }
+
+  const AliFlatESDTrack  *GetFlatTrack( Int_t i ) const ;
+  AliFlatESDTrack  *GetFlatTrackNonConst( Int_t i ) const;
+
+  // --------------------------------------------------------------------------------
+  // -- Size methods
+
+  ULong64_t  GetSize()  const { return fContent + fContentSize - reinterpret_cast<const Byte_t*>(this); }
+
+  static ULong64_t EstimateSize(AliESDEvent*esd, Bool_t fillV0s=kTRUE );
+
+  // --------------------------------------------------------------------------------
+  // AliVEvent interface
+  virtual void Print(Option_t *option="") const {if (option){}; return;}
+  virtual void AddObject(TObject* /*obj*/) {}
+  virtual TObject* FindListObject(const char* /*name*/) const {return NULL;}
+  virtual TList* GetList() const {return NULL;}
+  virtual void CreateStdContent() {}
+  virtual void GetStdContent() {}
+  virtual void ReadFromTree(TTree* /*tree*/, Option_t* /*opt*/) {}
+  virtual void WriteToTree(TTree* /*tree*/) const {}
+  virtual void SetStdNames() {}
+  virtual AliVHeader* GetHeader() const {return NULL;}
+  virtual void SetPeriodNumber(UInt_t) {}
+  virtual void SetEventType(UInt_t) {}
+  virtual void SetTriggerCluster(UChar_t) {}
+  virtual UInt_t GetEventType() const {return 0;}
+  virtual UChar_t GetTriggerCluster() const {return 0;}
+  virtual Double_t GetZDCN1Energy() const {return 0.;}
+  virtual Double_t GetZDCP1Energy() const {return 0.;}
+  virtual Double_t GetZDCN2Energy() const {return 0.;}
+  virtual Double_t GetZDCP2Energy() const {return 0.;}
+  virtual Double_t GetZDCEMEnergy(Int_t) const {return 0.;}
+  virtual AliVParticle* GetTrack(Int_t) const;
+  virtual Int_t GetNumberOfCascades() const {return 0;}
+  virtual AliCentrality* GetCentrality() {return NULL;}
+  virtual AliEventplane* GetEventplane() {return NULL;}
+  virtual Int_t EventIndex(Int_t) const {return 0;}
+  virtual Int_t EventIndexForCaloCluster(Int_t) const {return 0;}
+  virtual Int_t EventIndexForPHOSCell(Int_t) const {return 0;}
+  virtual Int_t EventIndexForEMCALCell(Int_t) const {return 0;}
+  virtual AliVVZERO* GetVZEROData() const {return NULL;}
+  virtual AliVZDC   *GetZDCData() const {return NULL;}
+  virtual AliVEvent::EDataLayoutType GetDataLayoutType() const;
+
+ private:
+
+  AliFlatESDEvent( const AliFlatESDEvent& );
+  AliFlatESDEvent& operator=( const AliFlatESDEvent& );
+
+  // --------------------------------------------------------------------------------
+
+  // -- Fixed size member objects ( try to align in memory )
+
+  size_t     fContentSize;     // Size of fContent
+  Double32_t fMagneticField;   // Solenoid Magnetic Field in kG : for compatibility with AliMagF
+  UInt_t     fPeriodNumber;    // PeriodNumber
+  Int_t      fRunNumber;       // Run Number
+  UInt_t     fOrbitNumber;     // Orbit Number
+  UInt_t     fTimeStamp;         // Time stamp
+  UInt_t     fEventSpecie;       // Reconstruction event specie (1-default,2-lowM,4-highM,8-cosmic,16-cal)
+  UShort_t   fBunchCrossNumber;  // Bunch Crossing Number
+  Byte_t     fPrimaryVertexMask;            // Bit mask specfifying which primary vertices are present
+  ULong64_t  fTriggerMask;      // Trigger mask, first 50 bits
+  ULong64_t  fTriggerMaskNext50;      // Trigger mask, next 50 bits
+
+  UInt_t  fNTriggerClasses;  // N trigger classes
+  UInt_t  fNPrimaryVertices; // Number of primary vertices in array
+  UInt_t  fNTracks;          // Number of tracks in array
+  UInt_t  fNV0s;             // Number of v0's
+  
+  // Pointers to specific data in fContent
+  
+  size_t fTriggerPointer;        // position of the first trigger description in fContent
+  size_t fPrimaryVertexTracksPointer; // position of primary vertex tracks in fContent
+  size_t fPrimaryVertexSPDPointer;  // position of primary vertex SPD in fContent
+  size_t fTrackTablePointer;     // position of the first track pointer in fContent
+  size_t fTracksPointer;         // position of the first track in fContent
+  size_t fV0Pointer;             // position of the first V0 in fContent  
+  
+  //
+  AliFlatESDFriend *fFriendEvent;
+
+  // --------------------------------------------------------------------------------
+
+  // -- Variable Size Object
+
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+  ClassDef(AliFlatESDEvent,0)
+};
+
+// Inline implementations 
+
+inline AliFlatESDTrack  *AliFlatESDEvent::GetFlatTrackNonConst( Int_t i ) const 
+{ 
+  const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
+  if( i<0 || i>(int) fNTracks || table[i]<0 ) return NULL;
+  return reinterpret_cast<AliFlatESDTrack*>( const_cast<Byte_t*>(fContent + table[i]) );
+}
+
+inline const AliFlatESDTrack  *AliFlatESDEvent::GetFlatTrack( Int_t i ) const 
+{ 
+  const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
+  if( i<0 || i>(int) fNTracks || table[i]<0 ) return NULL;
+  return reinterpret_cast<const AliFlatESDTrack*>( fContent + table[i] );
+}
+
+
+inline Int_t AliFlatESDEvent::SetTracksStart( AliFlatESDTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem)
+{
+  fNTracks = 0;
+  if( nTracks*sizeof(Long64_t)  > freeMem ) return -1;
+  fTrackTablePointer = fContentSize;
+  fContentSize += nTracks*sizeof(Long64_t);
+  fTracksPointer = fContentSize;
+  table = reinterpret_cast< Long64_t* >( fContent + fTrackTablePointer );
+  t = reinterpret_cast< AliFlatESDTrack* >( fContent + fTracksPointer );
+  return 0;
+}
+
+inline void AliFlatESDEvent::SetTracksEnd( Int_t nTracks, size_t tracksSize )
+{
+  if( nTracks<0 ) return;
+  Long64_t *table = reinterpret_cast< Long64_t*> (fContent + fTrackTablePointer);
+  for( int i=0; i<nTracks; i++ ) table[i]+=fTracksPointer;
+  fNTracks = nTracks;
+  fContentSize += tracksSize;
+}
+
+inline AliFlatESDV0 *AliFlatESDEvent::SetV0sStart()
+{
+  fNV0s = 0;
+  fV0Pointer = fContentSize;
+  return reinterpret_cast< AliFlatESDV0* >( fContent + fContentSize );
+}
+   
+inline void AliFlatESDEvent::SetV0sEnd( Int_t nV0s, size_t v0sSize )
+{
+  fNV0s = nV0s;
+  fContentSize += v0sSize;
+}
+  
+inline AliFlatESDTrigger *AliFlatESDEvent::SetTriggersStart()
+{
+  fNTriggerClasses = 0;
+  fTriggerPointer = fContentSize;
+  return reinterpret_cast< AliFlatESDTrigger* >( fContent + fContentSize );
+}
+
+inline void AliFlatESDEvent::SetTriggersEnd( Int_t nTriggerClasses, size_t triggersSize )
+{
+  fNTriggerClasses = nTriggerClasses;
+  fContentSize += triggersSize;
+}
+
+inline const AliFlatESDVertex* AliFlatESDEvent::GetFlatPrimaryVertexTracks() const 
+{ 
+  return (fPrimaryVertexMask & 0x1) ? (reinterpret_cast<const AliFlatESDVertex*>(fContent + fPrimaryVertexTracksPointer)  ) : NULL;
+} 
+
+inline const AliFlatESDVertex* AliFlatESDEvent::GetFlatPrimaryVertexSPD() const 
+{
+  return (fPrimaryVertexMask & 0x2) ? reinterpret_cast<const AliFlatESDVertex*>(fContent + fPrimaryVertexSPDPointer) : NULL;
+} 
+
+inline Int_t AliFlatESDEvent::GetPrimaryVertexSPD( AliESDVertex &v ) const 
+{
+  const AliFlatESDVertex* flatVertex = GetFlatPrimaryVertexSPD();
+  if( !flatVertex ) return -1;
+  flatVertex->GetESDVertex( v );
+  return 0;
+}
+
+inline Int_t AliFlatESDEvent::GetPrimaryVertexTracks( AliESDVertex &v ) const 
+{
+  const AliFlatESDVertex* flatVertex = GetFlatPrimaryVertexTracks();
+  if( !flatVertex ) return -1;
+  flatVertex->GetESDVertex( v );
+  return 0;
+}
+
+inline Int_t AliFlatESDEvent::GetPrimaryVertexTPC( AliESDVertex &/*v*/ ) const 
+{
+  return -1;
+}
+
+inline Int_t AliFlatESDEvent::GetPrimaryVertex( AliESDVertex &v ) const 
+{
+  int ret = GetPrimaryVertexTracks( v );
+  if( ret<0 ) ret = GetPrimaryVertexSPD( v );
+  return ret;
+}
+
+
+#endif
diff --git a/HLT/global/AliFlatESDFriend.cxx b/HLT/global/AliFlatESDFriend.cxx
new file mode 100644 (file)
index 0000000..5e3bd93
--- /dev/null
@@ -0,0 +1,112 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing an ESD friend <<
+ *
+ * To be used in the online and offline calibration schema.
+ *
+ * Class provides interface methods for 
+ *   - Filling from AliESDfriend, but also from HLT 
+ *   - Getter methods
+ *
+ * In the online case, the structure can be directly written into a shared 
+ * memory, in the offline case, the size has to be estimated first.
+ *
+ * 
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ * ************************************************************************
+ **/
+
+#include "AliFlatESDFriend.h"
+#include "AliFlatESDFriendTrack.h"
+#include "Riostream.h"
+#include "AliESDfriend.h"
+
+// _______________________________________________________________________________________________________
+
+
+
+
+
+
+void AliFlatESDFriend::Ls() const
+{
+  cout<<"Flat ESD friend: "<<endl;
+  cout<<"  N tracks: "<<fNTracks<<endl;
+  cout<<"  N track entries: "<<fNTrackEntries<<endl;
+}
+
+
+// _______________________________________________________________________________________________________
+
+Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, const AliESDfriend *esdFriend )
+{
+  // Fill flat ESD friend from ALiESDfriend
+  if( allocatedMemorySize < sizeof(AliFlatESDFriend ) ) return -1;
+
+  Reset();
+  
+  if( !esdFriend ) return 0;
+  
+  Int_t err = 0;
+  size_t freeSpace = allocatedMemorySize - GetSize();
+
+  // fill event info
+  {
+    SetSkipBit( esdFriend->TestSkipBit() );
+    for( int iSector=0; iSector<72; iSector++ ){
+      SetNclustersTPC( iSector, esdFriend->GetNclustersTPC(iSector) );
+      SetNclustersTPCused( iSector, esdFriend->GetNclustersTPCused(iSector) );
+    }
+  }
+  // fill track friends
+  {
+   size_t trackSize = 0;
+   int nTracks = 0;
+   int nTrackEntries = 0;
+   Long64_t *table = NULL;
+   AliFlatESDFriendTrack *flatTrack = NULL;
+   err = SetTracksStart( flatTrack, table, esdFriend->GetNumberOfTracks(), freeSpace );
+   if( err!=0 ) return err;
+   freeSpace = allocatedMemorySize - GetSize();
+   
+   for (Int_t idxTrack = 0; idxTrack < esdFriend->GetNumberOfTracks(); ++idxTrack) {
+     const AliESDfriendTrack *esdTrack = esdFriend->GetTrack(idxTrack);
+     table[idxTrack] = -1;
+     if (esdTrack) {
+       table[idxTrack] = trackSize;
+       if( freeSpace<flatTrack->EstimateSize() ) return -1;
+       new (flatTrack) AliFlatESDFriendTrack;       
+       //flatTrack->SetFromESDTrack( esdTrack );
+       trackSize += flatTrack->GetSize();
+       freeSpace -= flatTrack->GetSize();
+       nTrackEntries++;
+       flatTrack = flatTrack->GetNextTrackNonConst();
+     }
+     nTracks++;
+    }
+   
+   SetTracksEnd( nTracks, nTrackEntries, trackSize );
+  }
+
+  return 0;
+}
+
diff --git a/HLT/global/AliFlatESDFriend.h b/HLT/global/AliFlatESDFriend.h
new file mode 100644 (file)
index 0000000..48b6fd7
--- /dev/null
@@ -0,0 +1,187 @@
+#ifndef ALIFLATESDFRIEND_H
+#define ALIFLATESDFRIEND_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include "AliVfriendEvent.h"
+#include "AliFlatESDFriendTrack.h"
+
+
+class AliESDfriend;
+//class AliESDVZEROfriend;
+//class AliESDTZEROfriend;
+
+
+//_____________________________________________________________________________
+class AliFlatESDFriend : public AliVfriendEvent {
+public:
+  AliFlatESDFriend();
+  ~AliFlatESDFriend() {}
+   // constructor and method for reinitialisation of virtual table
+   AliFlatESDFriend( AliVConstructorReinitialisationFlag );
+   void Reinitialize(){ new (this) AliFlatESDFriend(AliVReinitialize); }
+
+  // Implementation of virtual methods of AliVfriend
+
+  Int_t GetNumberOfTracks() const { return fNTracks; }
+  const AliVfriendTrack* GetTrack(Int_t i) const {return GetFlatTrack(i); }
+  Int_t GetEntriesInTracks() const { return fNTrackEntries; }
+  //AliESDVZEROfriend *GetVZEROfriend(){ return NULL; }
+  //AliESDTZEROfriend *GetTZEROfriend(){ return NULL; }
+
+  void Ls() const;
+  void Reset();
+
+  // bit manipulation for filtering
+  void SetSkipBit(Bool_t skip){ fBitFlags = skip; }
+  Bool_t TestSkipBit() const { return (fBitFlags!=0); }
+
+  //TPC cluster occupancy
+  Int_t GetNclustersTPC(UInt_t sector) const { return (sector<72)?fNclustersTPC[sector]:0; }
+  Int_t GetNclustersTPCused(UInt_t sector) const { return (sector<72)?fNclustersTPCused[sector]:0; }
+  
+  // -- Own methods  -- 
+
+  // Set methods
+
+  Int_t SetFromESDfriend( size_t allocatedMemorySize, const AliESDfriend *esdFriend );
+    
+  void SetNclustersTPC(UInt_t sector, Int_t occupancy ) { if (sector<72) fNclustersTPC[sector]=occupancy; }
+  void SetNclustersTPCused(UInt_t sector, Int_t occupancy ) {if (sector<72) fNclustersTPCused[sector]=occupancy; }
+
+  Int_t SetTracksStart( AliFlatESDFriendTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem );
+  void  SetTracksEnd( Int_t nTracks, Int_t nTrackEntries, size_t tracksSize );
+
+  // other methods
+
+  const AliFlatESDFriendTrack  *GetFlatTrack( Int_t i ) const { 
+    const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
+    if( i<0 || i>fNTracks || table[i]<0 ) return NULL;
+    return reinterpret_cast<const AliFlatESDFriendTrack*>( fContent + table[i] );
+  }
+  const AliFlatESDFriendTrack  *GetFlatTrackEntry( Int_t i ) const { 
+    if( i<0 || i>fNTrackEntries ) return NULL;
+    return reinterpret_cast<const AliFlatESDFriendTrack*>( fContent + i );
+  }
+
+  // -- Size methods
+
+  ULong64_t  GetSize()  const { return fContent - reinterpret_cast<const Byte_t*>(this) + fContentSize; }
+
+
+private: 
+
+  AliFlatESDFriend(const AliFlatESDFriend&);
+  AliFlatESDFriend& operator=(const AliFlatESDFriend& );  
+
+  AliFlatESDFriendTrack  *GetFlatTrackNonConst( Int_t i ){ 
+    const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
+    if( i<0 || i>fNTracks || table[i]<0 ) return NULL;
+    return reinterpret_cast<AliFlatESDFriendTrack*>( fContent + table[i] );
+  }
+
+  AliFlatESDFriendTrack  *GetFlatTrackEntryNonConst( Int_t i ){ 
+    if( i<0 || i>fNTrackEntries ) return NULL;
+    return reinterpret_cast< AliFlatESDFriendTrack*>( fContent + i );
+  }
+
+  size_t fContentSize;     // Size of fContent
+  UInt_t fBitFlags; // bit flags
+  Int_t fNTracks;                   // Number of tracks in vector
+  Int_t fNTrackEntries;             // Number of non-empty track friends in vector
+  Int_t fNclustersTPC[72]; //cluster occupancy per sector per sector
+  Int_t fNclustersTPCused[72]; //number of clusters used in tracking per sector
+  // Pointers to specific data in fContent
+  
+  size_t fTrackTablePointer;     // position of the first track in fContent
+  size_t fTracksPointer;         // position of the first track in fContent
+
+  // -- Variable Size Object
+
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+  ClassDef(AliFlatESDFriend,0)
+};
+
+
+inline AliFlatESDFriend::AliFlatESDFriend() 
+:
+  fContentSize(0),
+  fBitFlags(0),
+  fNTracks(0),
+  fNTrackEntries(0),
+  fTrackTablePointer(0),
+  fTracksPointer(0)
+{
+  // Default constructor
+  Reset();
+}
+
+inline void AliFlatESDFriend::Reset() 
+{
+  fBitFlags = 0;
+  fNTracks = 0;
+  fNTrackEntries = 0; 
+  fTrackTablePointer = 0;
+  fTracksPointer = 0;
+  for( int i=0; i<72; i++ ){
+    fNclustersTPC[i]=0;
+    fNclustersTPCused[i]=0;
+  }
+  // We set size of the fContent array such, that it reaches the end of the AliFlatESDFriend structure. 
+  // To be sure that actual GetSize() is always >= size of the structure. 
+  // First, it makes the memory alignment better. Second, just for a case..
+  fContentSize = sizeof(AliFlatESDFriend) - (fContent - reinterpret_cast<const Byte_t*>(this));
+  for( UInt_t i=0; i<fContentSize; i++ ) fContent[i]=0;
+}
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatESDFriend::AliFlatESDFriend(AliVConstructorReinitialisationFlag f)
+:
+  AliVfriendEvent(f)
+{
+  //special constructor, used to restore the vtable pointer
+  for( int i=0; i<fNTrackEntries; i++ ){
+    AliFlatESDFriendTrack  *tr = GetFlatTrackEntryNonConst(i);
+    if( tr ) tr->Reinitialize();
+  }
+}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+
+inline Int_t AliFlatESDFriend::SetTracksStart( AliFlatESDFriendTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem)
+{
+  fNTracks = 0;
+  fNTrackEntries = 0;
+  if( nTracks*sizeof(Long64_t)  > freeMem ) return -1;
+  fTrackTablePointer = fContentSize;
+  fContentSize += nTracks*sizeof(Long64_t);
+  fTracksPointer = fContentSize;
+  table = reinterpret_cast< Long64_t* >( fContent + fTrackTablePointer );
+  t = reinterpret_cast< AliFlatESDFriendTrack* >( fContent + fTracksPointer );
+  return 0;
+}
+
+inline void AliFlatESDFriend::SetTracksEnd( Int_t nTracks, Int_t nTrackEntries, size_t tracksSize )
+{
+  if( nTracks<0 ) return;
+  Long64_t *table = reinterpret_cast< Long64_t*> (fContent + fTrackTablePointer);
+  for( int i=0; i<nTracks; i++ ) table[i]+=fTracksPointer;
+  fNTracks = nTracks;
+  fNTrackEntries = nTrackEntries;
+  fContentSize += tracksSize;
+}
+
+#endif
diff --git a/HLT/global/AliFlatESDFriendTrack.cxx b/HLT/global/AliFlatESDFriendTrack.cxx
new file mode 100644 (file)
index 0000000..0367608
--- /dev/null
@@ -0,0 +1,99 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing an ESDTrack <<
+ *
+ * To be used in the online and offline calibration schema.
+ *
+ * Class provides interface methods for 
+ *   - Filling from AliESDtrack and AliExternalTrackParam, as well 
+ *     as clusters from ESD friends (if requested)
+ *   - HLT Filling to be added
+ * 
+ *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ **************************************************************************/
+
+
+#include "AliFlatESDFriendTrack.h"
+#include "AliExternalTrackParam.h"
+#include "AliESDfriendTrack.h"
+#include "AliTPCseed.h"
+#include "Riostream.h"
+
+// _______________________________________________________________________________________________________
+ AliFlatESDFriendTrack::AliFlatESDFriendTrack()
+:
+ AliVfriendTrack()
+ ,fContentSize(0),
+ fTPCOutPointer(-1),
+ fITSOutPointer(-1),
+ fTRDInPointer(-1),
+ fTPCseedPointer(-1),
+ fBitFlags(0)
+{
+  // Default constructor
+  fContent[0]=0;
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+AliFlatESDFriendTrack::AliFlatESDFriendTrack( AliVConstructorReinitialisationFlag f ) 
+  :
+  AliVfriendTrack( f )
+{
+  // constructor for reinitialisation of vtable
+  if( fTPCseedPointer >= 0 ){
+    AliFlatTPCseed *fp = reinterpret_cast< AliFlatTPCseed* >( fContent + fTPCseedPointer );
+    fp->Reinitialize();
+  }
+}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+void AliFlatESDFriendTrack::Reset()
+{
+  // reset
+  fContentSize = 0;
+  fTPCOutPointer = -1;
+  fITSOutPointer = -1;
+  fTRDInPointer = -1;
+  fTPCseedPointer = -1;
+  fBitFlags = 0; 
+}
+
+Int_t AliFlatESDFriendTrack::SetFromESDfriendTrack( const AliESDfriendTrack* track, size_t allocatedMemory )
+{
+  if( allocatedMemory < EstimateSize() ) return -1;
+  Reset();
+  if( !track ) return 0;
+  SetSkipBit(track->TestSkipBit() );
+  SetTrackParamTPCOut( track->GetTPCOut() );
+  SetTrackParamITSOut( track->GetITSOut() );
+  SetTrackParamTRDIn( track->GetTRDIn() );
+  const AliTPCseed* seedP = NULL;
+  {
+    TObject* calibObject = NULL;
+    for (Int_t idx = 0; (calibObject = track->GetCalibObject(idx)); ++idx) {
+      if ((seedP = dynamic_cast<const AliTPCseed*>(calibObject))) {
+       break;
+      }
+    }
+  }
+  SetTPCseed( seedP );
+  return 0;
+}
diff --git a/HLT/global/AliFlatESDFriendTrack.h b/HLT/global/AliFlatESDFriendTrack.h
new file mode 100644 (file)
index 0000000..569a39b
--- /dev/null
@@ -0,0 +1,146 @@
+#ifndef ALIFLATESDFRIENDTRACK_H
+#define ALIFLATESDFRIENDTRACK_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+
+#include "Rtypes.h"
+
+#include "AliVfriendTrack.h"
+#include "AliVMisc.h"
+#include "AliFlatTPCseed.h"
+
+class AliESDtrack;
+class AliESDfriendTrack;
+class AliExternalTrackParam;
+class AliTrackPointArray;
+class AliTPCseed;
+
+class AliFlatESDFriendTrack :public AliVfriendTrack 
+{
+ public:
+
+  // --------------------------------------------------------------------------------
+  // -- Constructor / Destructors
+  AliFlatESDFriendTrack();
+  ~AliFlatESDFriendTrack() {}
+  // constructor and method for reinitialisation of virtual table  
+  AliFlatESDFriendTrack( AliVConstructorReinitialisationFlag );
+  void Reinitialize() { new (this) AliFlatESDFriendTrack( AliVReinitialize ); }
+
+  // --------------------   AliVfriendTrack interface    ---------------------------------
+
+  Int_t GetTPCseed( AliTPCseed &) const;
+  Int_t GetTrackParamTPCOut( AliExternalTrackParam &p ) const { return GetTrackParam( fTPCOutPointer, p ); }
+  Int_t GetTrackParamITSOut( AliExternalTrackParam &p ) const { return GetTrackParam( fITSOutPointer, p ); }
+  Int_t GetTrackParamTRDIn( AliExternalTrackParam &p )  const { return GetTrackParam( fTRDInPointer,  p ); }
+
+  //virtual const AliVtrackPointArray *GetTrackPointArray() const {return NULL;}
+
+  TObject* GetCalibObject(Int_t) const {return NULL;}
+  const AliExternalTrackParam* GetTPCOut() const {return NULL;}
+  const AliExternalTrackParam* GetITSOut() const {return NULL;}
+
+  
+  // bit manipulation for filtering
+
+  void SetSkipBit(Bool_t skip){ fBitFlags = skip; }
+  Bool_t TestSkipBit() const { return (fBitFlags!=0); }
+  
+  // ------------------- Own methods  ---------------------------------------------------------
+
+  // -- Set methods
+  void Reset();
+
+  Int_t SetFromESDfriendTrack( const AliESDfriendTrack* track, size_t allocatedMemory );
+
+  void SetTrackParamTPCOut( const AliExternalTrackParam *p ){ SetTrackParam( fTPCOutPointer, p ); }
+  void SetTrackParamITSOut( const AliExternalTrackParam *p ){ SetTrackParam( fITSOutPointer, p ); }
+  void SetTrackParamTRDIn ( const AliExternalTrackParam *p ){ SetTrackParam( fTRDInPointer,  p );  }
+  void SetTPCseed         ( const AliTPCseed *p );
+
+  // -- 
+  
+  const AliFlatESDFriendTrack *GetNextTrack() const { return reinterpret_cast<const AliFlatESDFriendTrack*>(fContent+fContentSize); }
+  AliFlatESDFriendTrack *GetNextTrackNonConst() { return reinterpret_cast<AliFlatESDFriendTrack*>(fContent+fContentSize); }
+  // --------------------------------------------------------------------------------
+  // -- Size methods
+
+  static size_t EstimateSize(){
+    return sizeof(AliFlatESDFriendTrack) + 3*sizeof(AliFlatExternalTrackParam) + AliFlatTPCseed::EstimateSize();
+  }
+
+  size_t GetSize() const { return fContent -  reinterpret_cast<const Byte_t*>(this) + fContentSize; }
+
+ private: 
+
+  AliFlatESDFriendTrack(const AliFlatESDFriendTrack &);
+  AliFlatESDFriendTrack& operator=(const AliFlatESDFriendTrack& ); 
+
+  Int_t GetTrackParam( Long64_t ptr, AliExternalTrackParam &param ) const;
+  void  SetTrackParam( Long64_t &ptr, const AliExternalTrackParam *p );
+
+  // --------------------------------------------------------------------------------
+
+  ULong64_t fContentSize;                      // Size of this object
+  Long64_t  fTPCOutPointer;        // pointer to TPCOut track param in fContent
+  Long64_t  fITSOutPointer;        // pointer to ITSOut track param in fContent
+  Long64_t  fTRDInPointer;        // pointer to TRDIn track param in fContent
+  Long64_t  fTPCseedPointer;       // pointer to TPCseed in fContent
+  Bool_t    fBitFlags; // bit flags
+
+  // --------------------------------------------------------------------------------
+  
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+  //ClassDef(AliFlatESDFriendTrack, 0)
+
+};
+
+inline Int_t AliFlatESDFriendTrack::GetTrackParam( Long64_t ptr, AliExternalTrackParam &param ) const
+{
+  if( ptr<0 ) return -1;
+  const AliFlatExternalTrackParam *fp = reinterpret_cast< const AliFlatExternalTrackParam* >( fContent + ptr );
+  fp->GetExternalTrackParam( param );
+}
+
+inline void AliFlatESDFriendTrack::SetTrackParam( Long64_t &ptr, const AliExternalTrackParam *p )
+{
+  if(!p ) return;
+  if( ptr<0 ){
+    ptr = fContentSize;
+    fContentSize += sizeof(AliFlatExternalTrackParam);
+  }
+  AliFlatExternalTrackParam *fp = reinterpret_cast< AliFlatExternalTrackParam* >( fContent + ptr );
+  fp->SetExternalTrackParam( p );
+}
+
+inline void AliFlatESDFriendTrack::SetTPCseed( const AliTPCseed *p )
+{
+  fTPCseedPointer = -1;
+  if(!p ) return;
+  fTPCseedPointer = fContentSize;
+  AliFlatTPCseed *fp = reinterpret_cast< AliFlatTPCseed* >( fContent + fTPCseedPointer );
+  fp->SetFromTPCseed( p );
+  fContentSize += fp->GetSize();  
+}
+
+inline Int_t AliFlatESDFriendTrack::GetTPCseed( AliTPCseed &s ) const
+{
+  if( fTPCseedPointer<0 ) return -1;
+  const AliFlatTPCseed *fp = reinterpret_cast< const AliFlatTPCseed* >( fContent + fTPCseedPointer );
+  fp->GetTPCseed( &s );
+  return 0;
+}
+
+#endif
diff --git a/HLT/global/AliFlatESDTrack.cxx b/HLT/global/AliFlatESDTrack.cxx
new file mode 100644 (file)
index 0000000..34a9935
--- /dev/null
@@ -0,0 +1,130 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing an ESDTrack <<
+ *
+ * To be used in the online and offline calibration schema.
+ *
+ * Class provides interface methods for 
+ *   - Filling from AliESDtrack and AliExternalTrackParam, as well 
+ *     as clusters from ESD friends (if requested)
+ *   - HLT Filling to be added
+ * 
+ *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ **************************************************************************/
+
+#include "Rtypes.h"
+#include "AliFlatESDTrack.h"
+#include "AliFlatExternalTrackParam.h"
+#include "AliESDtrack.h"
+#include "AliExternalTrackParam.h"
+#include "Riostream.h"
+
+
+
+
+// _______________________________________________________________________________________________________
+
+
+// _______________________________________________________________________________________________________
+Int_t AliFlatESDTrack::SetFromESDTrack(const AliESDtrack* track)
+{
+  // Fill external track parameters 
+  fTrackParamMask = 0;
+  fNTPCClusters = 0;
+  fNITSClusters = 0;
+  fContentSize = 0;
+  
+  if( !track ) return 0;
+
+  Int_t iResult = SetExternalTrackParam( track,
+                                        track->GetInnerParam(),
+                                        track->GetTPCInnerParam(),
+                                        track->GetOuterParam(),
+                                        track->GetConstrainedParam(), NULL );
+  fNITSClusters = track->GetTPCNcls();
+
+  return iResult;
+}
+
+// _______________________________________________________________________________________________________
+Int_t AliFlatESDTrack::SetExternalTrackParam( 
+                                            const AliExternalTrackParam* refittedParam,
+                                            const AliExternalTrackParam* innerParam,
+                                            const AliExternalTrackParam* innerTPC,
+                                            const AliExternalTrackParam* outerParam,
+                                            const AliExternalTrackParam* constrainedParam,
+                                            const AliExternalTrackParam* outerITS
+                                             ){
+  // Fill external track parameters 
+
+  fTrackParamMask = 0;
+  fNTPCClusters = 0;
+  fContentSize = 0;
+
+  Int_t iResult = 0;
+
+  Byte_t flag = 0x1;
+  iResult = FillExternalTrackParam(refittedParam, flag);
+
+  flag = 0x2;
+  iResult = FillExternalTrackParam(innerParam, flag);
+  
+  flag = 0x4;
+  iResult = FillExternalTrackParam(innerTPC, flag);
+  
+  flag = 0x8;
+  iResult = FillExternalTrackParam(outerParam, flag);
+
+  flag = 0x10;
+  iResult = FillExternalTrackParam(constrainedParam, flag);
+
+  flag = 0x20;
+  iResult = FillExternalTrackParam(outerITS, flag);
+
+  return iResult;
+}
+
+// _______________________________________________________________________________________________________
+Int_t AliFlatESDTrack::FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag) {
+  // Fill external track parameters
+
+  if (!param) return -1;
+
+  //Printf("  DEBUG: CONTENT %d >> %p + 0x%07llx = %p", flag, fContent, fContentSize, fContent + fContentSize);
+
+  AliFlatExternalTrackParam * current = reinterpret_cast<AliFlatExternalTrackParam*> (fContent + fContentSize);
+  current->SetExternalTrackParam( param );    
+  fTrackParamMask |= flag;
+  fContentSize += sizeof(AliFlatExternalTrackParam);
+
+  return 0;
+}
+
+
+// _______________________________________________________________________________________________________
+Bool_t AliFlatESDTrack::GetXYZ(Double_t *p) const {
+  const AliFlatExternalTrackParam *f = GetFlatTrackParam();
+  if (!f) { return kFALSE; }
+  p[0]=f->GetX();
+  p[1]=f->GetY();
+  p[2]=f->GetZ();
+  return kTRUE;
+}
diff --git a/HLT/global/AliFlatESDTrack.h b/HLT/global/AliFlatESDTrack.h
new file mode 100644 (file)
index 0000000..2128df2
--- /dev/null
@@ -0,0 +1,209 @@
+#ifndef ALIFLATESDTRACK_H
+#define ALIFLATESDTRACK_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+/*
+Cp - Track parameters constrained to the primary vertex
+Ip - Track parameters estimated at the inner wall of TPC
+TPCInner - Track parameters estimated at the inner wall of TPC using the TPC stand-alone 
+Op - Track parameters estimated at the point of maximal radial coordinate reached during the tracking
+*/
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include "AliVParticle.h"
+#include "AliFlatExternalTrackParam.h"
+
+class AliESDtrack;
+class AliExternalTrackParam;
+class AliFlatESDTrack;
+
+class AliFlatESDTrack :public AliVTrack {
+ public:
+  // --------------------------------------------------------------------------------
+  // -- Constructor / Destructors
+
+  AliFlatESDTrack();
+  virtual ~AliFlatESDTrack() {}  
+
+  // constructor and method for reinitialisation of virtual table
+  AliFlatESDTrack( AliVConstructorReinitialisationFlag );
+  void Reinitialize() { new (this) AliFlatESDTrack( AliVReinitialize ); }
+
+  // --------------------------------------------------------------------------------
+
+  // -- Set methods
+  Int_t SetFromESDTrack( const AliESDtrack* track );
+
+  Int_t SetExternalTrackParam( 
+                             const AliExternalTrackParam* refittedParam,
+                             const AliExternalTrackParam* innerParam,
+                             const AliExternalTrackParam* innerTPC,
+                             const AliExternalTrackParam* outerParam,
+                             const AliExternalTrackParam* constrainedParam,
+                             const AliExternalTrackParam* outerITSParam
+                              );
+
+  void SetNumberOfTPCClusters( Int_t nCl ) { fNTPCClusters = nCl; } 
+  void SetNumberOfITSClusters( Int_t nCl ) { fNITSClusters = nCl; } 
+
+  
+  // --------------------------------------------------------------------------------
+  // -- Getter methods
+
+  const AliFlatExternalTrackParam* GetFlatTrackParam()         const { return GetFlatParam( 0x0  ); }
+  const AliFlatExternalTrackParam* GetFlatTrackParamRefitted() const { return GetFlatParam( 0x1  ); }
+  const AliFlatExternalTrackParam* GetFlatTrackParamIp()       const { return GetFlatParam( 0x2  ); } 
+  const AliFlatExternalTrackParam* GetFlatTrackParamTPCInner() const { return GetFlatParam( 0x4  ); } 
+  const AliFlatExternalTrackParam* GetFlatTrackParamOp()       const { return GetFlatParam( 0x8  ); }     
+  const AliFlatExternalTrackParam* GetFlatTrackParamCp()       const { return GetFlatParam( 0x10 ); }
+  const AliFlatExternalTrackParam* GetFlatTrackParamITSOut()   const { return GetFlatParam( 0x20 ); }
+
+  // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
+
+  Int_t GetNumberOfTPCClusters() const { return fNTPCClusters; } 
+  Int_t GetNumberOfITSClusters() const { return fNITSClusters; } 
+    
+  // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
+  
+  const AliFlatESDTrack *GetNextTrack() const { return reinterpret_cast<const AliFlatESDTrack*>(fContent+fContentSize); }
+  AliFlatESDTrack *GetNextTrackNonConst() { return reinterpret_cast<AliFlatESDTrack*>(fContent+fContentSize); }
+  // --------------------------------------------------------------------------------
+  // -- Size methods
+
+  static size_t EstimateSize(){
+    return sizeof(AliFlatESDTrack) + 6*sizeof(AliFlatExternalTrackParam);
+  }
+
+  size_t GetSize() const { return fContent -  reinterpret_cast<const Byte_t*>(this) + fContentSize; }
+    
+  // -------------------------------------------------------------------------------
+  // the calibration interface methods:
+  Int_t GetTrackParam         ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x0  ); }
+  Int_t GetTrackParamRefitted ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x1  ); }
+  Int_t GetTrackParamIp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x2  ); }
+  Int_t GetTrackParamTPCInner ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x4  ); }
+  Int_t GetTrackParamOp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x8  ); }
+  Int_t GetTrackParamCp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x10 ); }
+  Int_t GetTrackParamITSOut   ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x20 ); }
+  UShort_t GetTPCNcls() const {return GetNumberOfTPCClusters(); }
+  Double_t GetPt() const {
+    const AliFlatExternalTrackParam *f = GetFlatTrackParam();
+    return (f) ?f->GetPt() : kVeryBig;
+  }
+  virtual Bool_t GetXYZ(Double_t *p) const;
+  // -------------------------------------------------------------------------------
+
+  // ---------------------------------------------------------------------------------
+  // AliVParticle interface
+  virtual Double_t Pt() const {const AliFlatExternalTrackParam* p=GetFlatTrackParam(); return (p)?p->GetPt():kVeryBig;}
+  virtual Double_t GetTgl()  const {const AliFlatExternalTrackParam* p=GetFlatTrackParam(); return (p)?p->GetTgl():kVeryBig;}
+  using AliVTrack::GetImpactParameters;
+  virtual void GetImpactParameters(Float_t &xy,Float_t &z) const {xy=0.; z=0.;}
+  virtual Double_t Px() const {return 0.;}
+  virtual Double_t Py() const {return 0.;}
+  virtual Double_t Pz() const {return 0.;}
+  virtual Double_t P() const {return 0.;}
+  virtual Bool_t PxPyPz(Double_t*) const {return kFALSE;}
+  virtual Double_t Xv() const {return 0.;}
+  virtual Double_t Yv() const {return 0.;}
+  virtual Double_t Zv() const {return 0.;}
+  virtual Bool_t XvYvZv(Double_t*) const {return 0.;}
+  virtual Double_t OneOverPt() const {return 0.;}
+  virtual Double_t Phi() const {return 0.;}
+  virtual Double_t Theta() const {return 0.;}
+  virtual Double_t E() const {return 0.;}
+  virtual Double_t M() const {return 0.;}
+  virtual Double_t Eta() const {return 0.;}
+  virtual Double_t Y() const {return 0.;}
+  virtual Short_t Charge() const {return 0.;}
+  virtual Int_t GetLabel() const {return 0.;}
+  virtual Int_t PdgCode() const {return 0.;}
+  virtual const Double_t* PID() const {return NULL;} 
+  virtual Int_t    GetID() const {return 0.;}
+  virtual UChar_t  GetITSClusterMap() const {return 0.;}
+  virtual ULong_t  GetStatus() const {return 0.;}
+  virtual Bool_t   GetCovarianceXYZPxPyPz(Double_t cv[21]) const {if (cv[0]){}; return kFALSE;}
+  virtual Bool_t   PropagateToDCA(const AliVVertex* /*vtx*/, Double_t /*b*/, Double_t /*maxd*/, Double_t dz[2], Double_t covar[3]) {if (dz[0]==covar[3]){}; return kFALSE;}
+
+ private:
+
+  AliFlatESDTrack(const AliFlatESDTrack&);
+  AliFlatESDTrack& operator=(const AliFlatESDTrack&);
+
+  const AliFlatExternalTrackParam* GetFlatParam( UShort_t flag ) const {
+    if( flag==0 ) return ( fTrackParamMask ) ? reinterpret_cast<const AliFlatExternalTrackParam*>(fContent) : NULL;
+    else return (fTrackParamMask & flag) ? reinterpret_cast<const AliFlatExternalTrackParam*>(fContent) + CountBits(fTrackParamMask, flag-1) : NULL;
+  }
+
+  Int_t GetExternalTrackParam( AliExternalTrackParam &p, UShort_t flag  ) const;
+
+  Int_t FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag);
+
+  static UInt_t CountBits(Byte_t field, UInt_t mask = 0xFFFFFFFF);
+  // --------------------------------------------------------------------------------
+  // -- Fixed size member objects
+  //    -> Try to align in memory
+
+  Byte_t   fTrackParamMask;            // Bit mask specfifying which ExternalTrackParam are present
+  Int_t    fNTPCClusters;                 // Number of TPC clusters in track
+  Int_t    fNITSClusters;                 // Number of ITS clusters in track
+  // Bool_t   fMCLabels;
+
+  ULong64_t fContentSize;                      // Size of this object
+  
+  // --------------------------------------------------------------------------------
+  // -- Variable Size Object
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+  ClassDef(AliFlatESDTrack,0)
+
+};
+
+// _______________________________________________________________________________________________________
+inline AliFlatESDTrack::AliFlatESDTrack() :
+  fTrackParamMask(0),
+  fNTPCClusters(0),
+  fNITSClusters(0),
+  fContentSize(0)
+{
+  // Default constructor
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatESDTrack::AliFlatESDTrack( AliVConstructorReinitialisationFlag f )
+ :
+ AliVTrack(f)
+{
+  // Constructor for reinitialisation of vtable
+}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+inline UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
+  // Count bits in field
+  UInt_t count = 0, reg = field & mask;
+  for (; reg; count++) reg &= reg - 1; 
+  return count;
+}
+
+inline Int_t AliFlatESDTrack::GetExternalTrackParam( AliExternalTrackParam &p, UShort_t flag) const
+{
+  // Get external track parameters  
+  const AliFlatExternalTrackParam *f = GetFlatParam ( flag );
+  if( !f ) return -1;
+  f->GetExternalTrackParam( p );
+  return 0;
+}
+
+
+#endif
diff --git a/HLT/global/AliFlatESDTrigger.cxx b/HLT/global/AliFlatESDTrigger.cxx
new file mode 100644 (file)
index 0000000..1e19832
--- /dev/null
@@ -0,0 +1,27 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing an ESD Trigger Classes <<
+ *
+ * To be used by AliFlatESD class 
+ *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ **************************************************************************/
+
+#include "AliFlatESDTrigger.h"
+
+// all the methods are inlined at the moment
diff --git a/HLT/global/AliFlatESDTrigger.h b/HLT/global/AliFlatESDTrigger.h
new file mode 100644 (file)
index 0000000..6476139
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef ALIFLATESDTRIGGER_H
+#define ALIFLATESDTRIGGER_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+/*
+*/
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include <string>
+
+class AliFlatESDTrigger{
+
+ public:
+
+  // --------------------------------------------------------------------------------
+  // -- Constructor / Destructors
+  AliFlatESDTrigger();   
+  ~AliFlatESDTrigger();
+
+  // constructor and method for reinitialisation of virtual table
+  AliFlatESDTrigger( AliVConstructorReinitialisationFlag );
+  void Reinitialize() const {} // no virtual table - do nothing
+
+  // --------------------------------------------------------------------------------
+  // -- Fill / Set methods
+
+  Int_t SetTriggerClass(  const char *TriggerClassName, Int_t TriggerIndex, ULong64_t MaxSize );
+  
+  // --------------------------------------------------------------------------------
+  // -- Getter methods
+
+  Int_t GetTriggerIndex() const { return fTriggerIndex; } 
+  
+  const Char_t *GetTriggerClassName() const { return reinterpret_cast<const Char_t*>( fContent ); } 
+  
+  // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
+  
+  const AliFlatESDTrigger *GetNextTrigger() const { return reinterpret_cast<const AliFlatESDTrigger*>(fContent+fContentSize); }
+  AliFlatESDTrigger *GetNextTriggerNonConst() { return reinterpret_cast<AliFlatESDTrigger*>(fContent+fContentSize); }
+  // --------------------------------------------------------------------------------
+  // -- Size methods
+
+  ULong64_t GetSize()  {return fContent + fContentSize -  reinterpret_cast<Byte_t*>(this) ;}
+    
+ private:
+
+  AliFlatESDTrigger(const AliFlatESDTrigger&);
+  AliFlatESDTrigger& operator=(const AliFlatESDTrigger&);
+
+  // --------------------------------------------------------------------------------
+  // -- Fixed size member objects
+  
+  UInt_t fContentSize;                      // Size of this object
+  Int_t  fTriggerIndex; // trigger index  
+   
+  // --------------------------------------------------------------------------------
+  // -- Variable Size Object
+
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+};
+
+
+// _______________________________________________________________________________________________________
+// inline implementation of some methods 
+
+inline AliFlatESDTrigger::AliFlatESDTrigger():
+  fContentSize(1),
+  fTriggerIndex(0)
+{   
+  // Default constructor
+  fContent[0] = '\0';
+}
+
+inline AliFlatESDTrigger::~AliFlatESDTrigger() 
+{
+  // Destructor  
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatESDTrigger::AliFlatESDTrigger( AliVConstructorReinitialisationFlag ) {} // do nothing
+#pragma GCC diagnostic warning "-Weffc++" 
+
+inline Int_t AliFlatESDTrigger::SetTriggerClass(  const char *TriggerClassName, Int_t TriggerIndex, ULong64_t MaxSize )
+{
+  // Set trigger class, returns non-zero when the memory needed exeeeds MaxSize
+       
+       
+  size_t len = strlen( TriggerClassName ) ;
+       
+       // strlen does not count the terminating \0 character, but this has to be safed too
+       len ++;
+    
+  if( ( fContent + len ) > reinterpret_cast<Byte_t*>(this) + MaxSize ) return -1;
+  
+  fTriggerIndex = TriggerIndex;
+  fContentSize =len;
+  strcpy( reinterpret_cast<char*>(fContent), TriggerClassName );
+  return 0;
+}
+
+#endif
diff --git a/HLT/global/AliFlatESDV0.cxx b/HLT/global/AliFlatESDV0.cxx
new file mode 100644 (file)
index 0000000..cb7f653
--- /dev/null
@@ -0,0 +1,20 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+#include "AliFlatESDV0.h"
+
+
diff --git a/HLT/global/AliFlatESDV0.h b/HLT/global/AliFlatESDV0.h
new file mode 100644 (file)
index 0000000..05cdae7
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef ALIFLATESDV0_H
+#define ALIFLATESDV0_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/**
+ * >> Flat structure representing a ESD v0 vertex <<
+ */
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+
+class AliFlatESDV0
+{
+ public:
+
+  // -- Constructor / Destructors
+  AliFlatESDV0(): fNegTrackID(-1), fPosTrackID(-1) {}
+  ~AliFlatESDV0(){}
+  // constructor and method for reinitialisation of virtual table
+  AliFlatESDV0( AliVConstructorReinitialisationFlag );
+  void Reinitialize() const {} // no virtual table - do nothing
+  //--
+  static size_t GetSize(){ return sizeof(AliFlatESDV0); }
+
+  void SetNegTrackID( Int_t id ){ fNegTrackID = id; }
+  void SetPosTrackID( Int_t id ){ fPosTrackID = id; }
+
+  Int_t GetNegTrackID() const { return fNegTrackID; }
+  Int_t GetPosTrackID() const { return fPosTrackID; }
+
+  // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
+  
+  const AliFlatESDV0 *GetNextV0() const { return reinterpret_cast<const AliFlatESDV0*>( this+1 ); }
+  AliFlatESDV0 *GetNextV0NonConst() { return reinterpret_cast<AliFlatESDV0*>( this+1 ); }
+
+
+ private:
+
+  AliFlatESDV0(const AliFlatESDV0&);
+  AliFlatESDV0& operator=(const AliFlatESDV0&);
+
+  Int_t fNegTrackID;
+  Int_t fPosTrackID;
+};
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatESDV0::AliFlatESDV0( AliVConstructorReinitialisationFlag ){} 
+#pragma GCC diagnostic warning "-Weffc++" 
+
+#endif
diff --git a/HLT/global/AliFlatESDVertex.cxx b/HLT/global/AliFlatESDVertex.cxx
new file mode 100644 (file)
index 0000000..8dc235a
--- /dev/null
@@ -0,0 +1 @@
+#include "AliFlatESDVertex.h"
diff --git a/HLT/global/AliFlatESDVertex.h b/HLT/global/AliFlatESDVertex.h
new file mode 100644 (file)
index 0000000..74b3ab6
--- /dev/null
@@ -0,0 +1,142 @@
+#ifndef ALIFLATESDVERTEX_H
+#define ALIFLATESDVERTEX_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/**
+ * >> Flat structure representing a ESD vertex <<
+ */
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include "AliESDVertex.h"
+
+struct AliFlatESDVertex
+{
+  // -- Constructor / Destructors
+  AliFlatESDVertex();
+ ~AliFlatESDVertex() {}
+
+  // constructor and method for reinitialisation of virtual table
+  AliFlatESDVertex( AliVConstructorReinitialisationFlag );
+  void Reinitialize() const {} // no virtual table - do nothing
+
+  //--
+
+  Double32_t fPosition[3];    // vertex position
+  Double32_t fCov[6];  // vertex covariance matrix
+  Int_t    fNContributors;  // # of tracklets/tracks used for the estimate   
+  Double32_t fChi2;  // chi2 of vertex fit
+  /*
+    Double32_t fSigma;          // track dispersion around found vertex
+    Char_t fID;       // ID of this vertex within an ESD event
+    Char_t fBCID;     // BC ID assigned to vertex
+  */
+
+
+  void SetFromESDVertex(const AliESDVertex &v );
+  void GetESDVertex( AliESDVertex &v ) const;
+
+  Double32_t GetX() const { return fPosition[0]; }
+  Double32_t GetY() const { return fPosition[1]; }
+  Double32_t GetZ() const { return fPosition[2]; }
+  
+  void GetXYZ(Double_t pos[3]) const { for(Int_t j=0; j<3; j++) pos[j]=fPosition[j]; }
+  void SetXYZ(Double_t pos[3]) { for(Int_t j=0; j<3; j++) fPosition[j]=pos[j]; }
+
+  void   SetX(Double_t xVert) {fPosition[0]=xVert; }
+  void   SetY(Double_t yVert) {fPosition[1]=yVert; }
+  void   SetZ(Double_t zVert) {fPosition[2]=zVert; } 
+  void   SetNContributors(Int_t nContr) {fNContributors=nContr; }
+
+
+  Int_t    GetNContributors() const { return fNContributors; }
+
+  /*
+  void     GetCovarianceMatrix(Double_t covmatrix[6]) const;
+  void     SetCovarianceMatrix(const Double_t *) {}
+  
+  Double_t GetChi2perNDF() const {return -999.;}
+  Double_t GetChi2() const {return -999.;}
+  void     SetChi2(Double_t ) {}
+  Int_t    GetNDF() const {return -999;}
+
+  void     GetSigmaXYZ(Double_t sigma[3]) const;
+  void     GetCovMatrix(Double_t covmatrix[6]) const;
+  void     GetCovarianceMatrix(Double_t covmatrix[6]) const 
+                    {GetCovMatrix(covmatrix);}
+  void     GetSNR(Double_t snr[3]) const;
+  void     SetCovarianceMatrix(const Double_t *cov);
+
+  Double_t GetXRes() const {return TMath::Sqrt(fCovXX);}
+  Double_t GetYRes() const {return TMath::Sqrt(fCovYY);}
+  Double_t GetZRes() const {return TMath::Sqrt(fCovZZ);}
+  Double_t GetXSNR() const { return fSNR[0]; }
+  Double_t GetYSNR() const { return fSNR[1]; }
+  Double_t GetZSNR() const { return fSNR[2]; }
+  void     SetSNR(double snr, int i) {if (i<3 && i>=0) fSNR[i] = snr;}
+
+  Double_t GetChi2() const { return fChi2; }
+  void     SetChi2(Double_t chi) { fChi2 = chi; }
+  Double_t GetChi2toNDF() const 
+    { return fChi2/(2.*(Double_t)fNContributors-3.); }
+  Double_t GetChi2perNDF() const { return GetChi2toNDF();}
+  Int_t    GetNDF() const {return (2*fNContributors-3);}
+
+  void     Print(Option_t* option = "") const;
+  void     PrintStatus() const {Print();}
+
+  void     Reset() { SetToZero(); SetName("Vertex"); }
+
+  void     SetID(Char_t id) {fID=id;}
+  Char_t   GetID() const {return fID;}
+  //
+  Double_t GetWDist(const AliESDVertex* v) const;
+  */
+
+  static size_t GetSize() { return sizeof(AliFlatESDVertex); }
+};
+
+inline AliFlatESDVertex::AliFlatESDVertex() :
+fNContributors(0), 
+fChi2(0)
+{
+  for( int i=0; i<3; i++) fPosition[i] = -9999;
+  for( int i=0; i<6; i++) fCov[i] = -9999;
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatESDVertex::AliFlatESDVertex( AliVConstructorReinitialisationFlag ){}  // do nothing
+#pragma GCC diagnostic warning "-Weffc++" 
+
+inline void AliFlatESDVertex::SetFromESDVertex(const AliESDVertex &v )
+{
+  fPosition[0] = v.GetX();
+  fPosition[1] = v.GetY();
+  fPosition[2] = v.GetZ();
+  Double_t c[6]; 
+  v.GetCovarianceMatrix( c ); 
+  for( int i=0; i<6; i++) fCov[i] = c[i];
+  fNContributors = v.GetNContributors();
+  fChi2 = v.GetChi2();
+}
+
+inline void AliFlatESDVertex::GetESDVertex( AliESDVertex &v ) const
+{
+  v.Reset();
+  Double_t p[3] = { fPosition[0], fPosition[1], fPosition[2] }; 
+  v.SetXYZ( p );
+  Double_t c[6]; 
+  for( int i=0; i<6; i++) c[i] = fCov[i];
+  v.SetCovarianceMatrix( c );
+  v.SetNContributors( fNContributors );
+  v.SetChi2( fChi2 );
+}
+
+typedef struct AliFlatESDVertex AliFlatESDVertex;
+
+#endif
diff --git a/HLT/global/AliFlatExternalTrackParam.cxx b/HLT/global/AliFlatExternalTrackParam.cxx
new file mode 100644 (file)
index 0000000..ea1e883
--- /dev/null
@@ -0,0 +1 @@
+#include "AliFlatExternalTrackParam.h"
\ No newline at end of file
diff --git a/HLT/global/AliFlatExternalTrackParam.h b/HLT/global/AliFlatExternalTrackParam.h
new file mode 100644 (file)
index 0000000..9cea8c0
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef ALIFLATEXTERNALTRACKPARAM_H
+#define ALIFLATEXTERNALTRACKPARAM_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/**
+ * >> Flat structure representing parameters of an external track  <<
+ */
+
+#include "Rtypes.h"
+#include "AliExternalTrackParam.h"
+
+class AliFlatExternalTrackParam
+{
+ public:
+
+  AliFlatExternalTrackParam();
+  ~AliFlatExternalTrackParam() {}
+
+  // constructor and method for reinitialisation of virtual table
+  AliFlatExternalTrackParam( AliVConstructorReinitialisationFlag );
+  void Reinitialize() { new (this) AliFlatExternalTrackParam( AliVReinitialize ); }
+  void SetAlpha(Float_t alpha)             {fAlpha = alpha;}
+  void SetX(Float_t x)                     {fX = x;}
+  void SetY(Float_t y)                     {fY = y;}
+  void SetZ(Float_t z)                     {fZ = z;}
+  void SetSnp(Float_t snp)                 {fSnp = snp;}
+  void SetTgl(Float_t tgl)                 {fTgl = tgl;}
+  void SetSigned1Pt(Float_t signed1Pt)     {fSigned1Pt = signed1Pt;}
+  void SetCovEntry(Int_t idx, Float_t cov) {(idx >= 0 && idx < 15) ? fC[idx] = cov : 0.;}
+
+  Float_t  GetAlpha()             const {return fAlpha;}
+  Float_t  GetX()                 const {return fX;}
+  Float_t  GetY()                 const {return fY;}
+  Float_t  GetZ()                 const {return fZ;}
+  Float_t  GetSnp()               const {return fSnp;}
+  Float_t  GetTgl()               const {return fTgl;}
+  Float_t  GetSigned1Pt()         const {return fSigned1Pt;}
+  Float_t* GetCov()               const {return const_cast<Float_t*>(fC);}
+  Float_t  GetCovEntry(Int_t idx) const {return (idx >= 0 && idx < 15) ? fC[idx] : 0.;}
+  Float_t  GetPt()                const {
+    Double_t pt1 = fabs( fSigned1Pt );
+    return (pt1>kAlmost0) ? 1./pt1 : kVeryBig;
+  }
+  void GetExternalTrackParam( AliExternalTrackParam &p ) const;
+  void SetExternalTrackParam( const AliExternalTrackParam *p );
+
+ private:
+
+  Float_t fAlpha;     // azimuthal angle of reference frame
+  Float_t fX;         // x: radial distance
+  Float_t fY;         // local Y-coordinate of a track (cm)
+  Float_t fZ;         // local Z-coordinate of a track (cm)
+  Float_t fSnp;       // local sine of the track momentum azimuthal angle
+  Float_t fTgl;       // tangent of the track momentum dip angle
+  Float_t fSigned1Pt; // 1/pt (1/(GeV/c))
+  Float_t fC[15];     // covariance matrix
+};
+
+inline AliFlatExternalTrackParam::AliFlatExternalTrackParam()
+ :
+ fAlpha(0),  
+ fX(0),                                 
+ fY(0),
+ fZ(0),
+ fSnp(0),
+ fTgl(0),
+ fSigned1Pt(0)
+{
+  for( int i=0; i<15; i++ ) fC[i]=0;
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatExternalTrackParam::AliFlatExternalTrackParam( AliVConstructorReinitialisationFlag ){}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+inline void AliFlatExternalTrackParam::GetExternalTrackParam( AliExternalTrackParam &p ) const
+{
+ // Get external track parameters  
+  Float_t par[5] = { fY, fZ, fSnp, fTgl, fSigned1Pt };
+  p.Set( fX, fAlpha, par, fC );
+}
+
+inline void AliFlatExternalTrackParam::SetExternalTrackParam( const AliExternalTrackParam *p ) 
+{
+  // Set external track parameters
+  if( !p ) return;
+  fAlpha = p->GetAlpha();
+  fX = p->GetX();
+  fY = p->GetY();
+  fZ = p->GetZ();
+  fSnp = p->GetSnp();
+  fTgl = p->GetTgl();
+  fSigned1Pt = p->GetSigned1Pt();  
+  for (Int_t idx = 0; idx <15; ++idx) fC[idx] = p->GetCovariance()[idx];
+}
+
+#endif
diff --git a/HLT/global/AliFlatTPCCluster.h b/HLT/global/AliFlatTPCCluster.h
new file mode 100644 (file)
index 0000000..c5b9c57
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef ALIFLATTPCCLUSTER_H
+#define ALIFLATTPCCLUSTER_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/**
+ * >> Flat structure representing a TPC cluster <<
+ */
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+#include "AliTPCclusterMI.h"
+
+class AliFlatTPCCluster
+{
+  public:
+
+  AliFlatTPCCluster() : fX(0.), fY(0.), fZ(0.), fSector(0), fPadRow(0), fSigmaY2(0.), fSigmaZ2(0.), fCharge(0), fQMax(0) {}
+
+  AliFlatTPCCluster(AliVConstructorReinitialisationFlag ); // do nothing
+  void Reinitialize(){} // do nothing
+
+  ~AliFlatTPCCluster() {}
+
+  void SetX(Float_t x)             {fX = x;}
+  void SetY(Float_t y)             {fY = y;}
+  void SetZ(Float_t z)             {fZ = z;}
+  void SetSector(UShort_t sector)  {fSector = sector;}
+  void SetPadRow(UShort_t padrow)  {fPadRow = padrow;}
+  void SetSigmaY2(Float_t sigmaY2) {fSigmaY2 = sigmaY2;}
+  void SetSigmaZ2(Float_t sigmaZ2) {fSigmaZ2 = sigmaZ2;}
+  void SetCharge(UShort_t charge)  {fCharge = charge;}
+  void SetQMax(UShort_t qmax)      {fQMax = qmax;}
+  
+  Float_t  GetX()       const      {return fX;}
+  Float_t  GetY()       const      {return fY;}
+  Float_t  GetZ()       const      {return fZ;}
+  UShort_t GetSector()  const      {return fSector;}
+  UShort_t GetPadRow()  const      {return fPadRow;}
+  Float_t  GetSigmaY2() const      {return fSigmaY2;}
+  Float_t  GetSigmaZ2() const      {return fSigmaZ2;}
+  UShort_t GetCharge()  const      {return fCharge;}
+  UShort_t GetQMax()    const      {return fQMax;}
+
+  void SetTPCCluster( const AliTPCclusterMI *c );
+  void GetTPCCluster( AliTPCclusterMI *c ) const;
+
+  private:
+
+  Float_t fX;       // X coordinate in local coordinates
+  Float_t fY;       // Y coordinate in local coordinates
+  Float_t fZ;       // Z coordinate in local coordinates
+  UChar_t fSector;  // TPC sector
+  UChar_t fPadRow;  // Pad row number withing the sector
+  Float_t fSigmaY2; // error (former width) of the clusters
+  Float_t fSigmaZ2; // error (former width) of the clusters
+  UInt_t  fCharge;  // total charge of cluster
+  UInt_t  fQMax;    // QMax of cluster
+  
+};
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatTPCCluster::AliFlatTPCCluster(AliVConstructorReinitialisationFlag ){}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+inline void AliFlatTPCCluster::SetTPCCluster( const AliTPCclusterMI *c )
+{
+  SetX( c->GetX() );
+  SetY( c->GetY() );
+  SetZ( c->GetZ() );
+  SetSector( c->GetDetector() );
+  SetPadRow( c->GetRow() );
+  SetSigmaY2( c->GetSigmaY2() );
+  SetSigmaZ2( c->GetSigmaZ2() );
+  SetCharge( c->GetQ() );
+  SetQMax( c->GetMax() );
+}
+inline void AliFlatTPCCluster::GetTPCCluster( AliTPCclusterMI *c ) const
+{
+  if( !c ) return;
+  c->SetX( GetX() );
+  c->SetY( GetY() );
+  c->SetZ( GetZ() );
+  c->SetDetector( GetSector() );
+  c->SetRow( GetPadRow() );
+  c->SetSigmaY2( GetSigmaY2() );
+  c->SetSigmaZ2( GetSigmaZ2() );
+  c->SetQ( GetCharge() );
+  c->SetMax( GetQMax() );
+}
+
+#endif
diff --git a/HLT/global/AliFlatTPCseed.cxx b/HLT/global/AliFlatTPCseed.cxx
new file mode 100644 (file)
index 0000000..b42e8b3
--- /dev/null
@@ -0,0 +1,78 @@
+/* $Id$ */
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/**
+ * >> Flat structure representing a TPC seed <<
+ *
+ * To be used in the online and offline calibration schema.
+ *
+ *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ **************************************************************************/
+
+#include "AliFlatTPCseed.h"
+#include "AliTPCseed.h"
+#include "AliHLTTPCTransform.h"
+#include "Riostream.h"
+
+
+void AliFlatTPCseed::SetFromTPCseed( const AliTPCseed *p )
+{
+  // initialise from AliTPCseed
+
+  Reset();
+  if( !p ) return;
+
+  fParam.SetExternalTrackParam(  p );
+  fLabel = p->GetLabel();
+  AliFlatTPCCluster *clusters = reinterpret_cast< AliFlatTPCCluster* >( fContent );  
+  for( Int_t irow=0; irow<160; irow++ ){
+    const AliTPCclusterMI *cl = p->GetClusterPointer(irow);
+    if( !cl ) continue;
+    AliFlatTPCCluster &flatCluster = clusters[fNTPCClusters];
+    flatCluster.SetTPCCluster( cl );
+    fNTPCClusters++;
+  }
+}
+
+void AliFlatTPCseed::GetTPCseed( AliTPCseed *p ) const
+{
+   // write to AliTPCseed
+  if( !p ) return;
+  p->Reset();
+
+  AliTPCseed seed;
+
+  fParam.GetExternalTrackParam( seed );
+  seed.SetLabel(fLabel);  
+  seed.SetNumberOfClusters(fNTPCClusters);
+
+  AliTPCclusterMI clusters[fNTPCClusters];
+
+  const AliFlatTPCCluster *flatClusters = reinterpret_cast< const AliFlatTPCCluster* >( fContent );
+
+  for( Int_t ic=0; ic<fNTPCClusters; ic++){
+    const AliFlatTPCCluster &flatCluster = flatClusters[ic];    
+    flatCluster.GetTPCCluster( &(clusters[ic]) );
+    int sec = flatCluster.GetSector();
+    int row = flatCluster.GetPadRow();
+    if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow();
+    if( row<160 ) seed.SetClusterPointer( row , &(clusters[ic]) );
+  }
+  new (p) AliTPCseed( seed, kTRUE ); // true means that p creates its own cluster objects
+}
diff --git a/HLT/global/AliFlatTPCseed.h b/HLT/global/AliFlatTPCseed.h
new file mode 100644 (file)
index 0000000..5889736
--- /dev/null
@@ -0,0 +1,108 @@
+#ifndef ALIFLATTPCSEED_H
+#define ALIFLATTPCSEED_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
+
+/*
+ * See implementation file for documentation
+ */
+
+
+#include "Rtypes.h"
+
+#include "AliFlatTPCCluster.h"
+#include "AliVfriendTrack.h"
+#include "AliVMisc.h"
+#include "AliFlatExternalTrackParam.h"
+
+class AliESDtrack;
+class AliESDfriendTrack;
+class AliExternalTrackParam;
+class AliTrackPointArray;
+class AliTPCseed;
+
+class AliFlatTPCseed  
+{
+ public:
+
+  // --------------------------------------------------------------------------------
+  // -- Constructor / Destructors
+  AliFlatTPCseed();
+  ~AliFlatTPCseed() {}
+  // constructor and method for reinitialisation of virtual table  
+  AliFlatTPCseed( AliVConstructorReinitialisationFlag );
+  void Reinitialize() { new (this) AliFlatTPCseed( AliVReinitialize ); }
+
+  // -- Set methods
+  void Reset();
+
+  void SetFromTPCseed( const AliTPCseed *p );
+  void GetTPCseed( AliTPCseed *p ) const;
+
+  Int_t GetLabel() const { return fLabel; }
+  Int_t GetNClusters() const { return fNTPCClusters; }
+
+  // --------------------------------------------------------------------------------
+  // -- Size methods
+
+  static size_t EstimateSize(){
+    return sizeof(AliFlatTPCseed) + 160*sizeof(AliFlatTPCCluster);
+  }
+
+  size_t GetSize() const { return fContent -  reinterpret_cast<const Byte_t*>(this) + fContentSize; }
+
+ private: 
+
+  AliFlatTPCseed(const AliFlatTPCseed &);
+  AliFlatTPCseed& operator=(const AliFlatTPCseed& ); 
+
+  // --------------------------------------------------------------------------------
+
+  ULong64_t fContentSize;                      // Size of this object
+  
+  // --------------------------------------------------------------------------------
+  
+  AliFlatExternalTrackParam fParam;
+  Int_t fLabel;
+  Int_t fNTPCClusters;
+  Byte_t fContent[1];                  // Variale size object, which contains all data
+
+};
+
+inline AliFlatTPCseed::AliFlatTPCseed()
+  :
+  fContentSize(0),
+  fParam(),
+  fLabel(-1),
+  fNTPCClusters(0)
+{
+  // constructor
+  fContent[0]=0;
+}
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliFlatTPCseed::AliFlatTPCseed( AliVConstructorReinitialisationFlag  )
+{
+  // reinitialise vtable
+  fParam.Reinitialize();
+  AliFlatTPCCluster *clusters = reinterpret_cast< AliFlatTPCCluster* >( fContent );  
+  for( Int_t ic=0; ic<fNTPCClusters; ic++ ){
+    clusters[ic].Reinitialize();
+  }
+}
+#pragma GCC diagnostic warning "-Weffc++" 
+
+
+inline void AliFlatTPCseed::Reset()
+{
+  // Reset
+  fContentSize = 0;
+  fNTPCClusters = 0;
+  fLabel=-1;
+}
+
+#endif
index 416fb062602f6dfa58a0249158f7034bfe51666b..bb90c95e8a1cbfe92bc162789657f12b9c4e4f62 100644 (file)
 #include "AliHLTConfigurationHandler.h"
 #include "TObjString.h"
 #include "TObjArray.h"
+#include "AliHLTGlobalFlatEsdTestComponent.h"
 
 // header files of library components
 #include "AliHLTGlobalTrackMergerComponent.h"
+#include "AliHLTGlobalCompareFlatComponent.h"
+#include "AliHLTGlobalEsdToFlatConverterComponent.h"
+#include "AliHLTGlobalFlatEsdConverterComponent.h"
 #include "AliHLTGlobalEsdConverterComponent.h"
 #include "AliHLTGlobalVertexerComponent.h"
 #include "AliHLTGlobalOfflineVertexerComponent.h"
@@ -43,6 +47,8 @@
 #include "AliHLTMultiplicityCorrelationsComponent.h"
 #include "AliHLTPrimaryVertexFinderComponent.h"
 #include "AliHLTV0FinderComponent.h"
+#include "AliHLTAnaManagerComponent.h"
+#include "AliHLTFlatAnaManagerComponent.h"
 
 // header file for preprocessor plugin
 #include "AliHLTGlobalPreprocessor.h"
@@ -74,7 +80,11 @@ int AliHLTGlobalAgent::RegisterComponents(AliHLTComponentHandler* pHandler) cons
   // see header file for class documentation
   assert(pHandler);
   if (!pHandler) return -EINVAL;
+  pHandler->AddComponent(new AliHLTGlobalEsdToFlatConverterComponent);
+  pHandler->AddComponent(new AliHLTGlobalCompareFlatComponent);
+  pHandler->AddComponent(new AliHLTGlobalFlatEsdTestComponent);
   pHandler->AddComponent(new AliHLTGlobalTrackMergerComponent);
+  pHandler->AddComponent(new AliHLTGlobalFlatEsdConverterComponent);
   pHandler->AddComponent(new AliHLTGlobalEsdConverterComponent);
   pHandler->AddComponent(new AliHLTGlobalVertexerComponent);
   pHandler->AddComponent(new AliHLTGlobalOfflineVertexerComponent);
@@ -88,6 +98,8 @@ int AliHLTGlobalAgent::RegisterComponents(AliHLTComponentHandler* pHandler) cons
   pHandler->AddComponent(new AliHLTV0FinderComponent);
   pHandler->AddComponent(new AliHLTGlobalHistoCollector );
   pHandler->AddComponent(new AliHLTGlobalDCSPublisherComponent );
+  pHandler->AddComponent(new AliHLTAnaManagerComponent);
+  pHandler->AddComponent(new AliHLTFlatAnaManagerComponent);
   return 0;
 }
 
@@ -120,11 +132,12 @@ int AliHLTGlobalAgent::CreateConfigurations(AliHLTConfigurationHandler* pHandler
     delete pTokens;
     pTokens=NULL;
   }
+  cout<<endl<<"\n\nConfiguring inputs to global HLT Vertexer: %s\n\n"<<vertexerInputs.Data()<<endl<<endl;
   if (!vertexerInputs.IsNull()) {
-    HLTInfo("Configuring inputs to global HLT Vertexer: %s", vertexerInputs.Data());
+    HLTInfo("\n\nConfiguring inputs to global HLT Vertexer: %s\n\n", vertexerInputs.Data());
     pHandler->CreateConfiguration("GLOBAL-vertexer","GlobalVertexer",vertexerInputs,"");
   } else {
-    HLTWarning("No inputs to global HLT Vertexer found");
+    HLTWarning("\n\nNo inputs to global HLT Vertexer found\n\n");
   }
 
   /////////////////////////////////////////////////////////////////////////////////////
@@ -132,7 +145,7 @@ int AliHLTGlobalAgent::CreateConfigurations(AliHLTConfigurationHandler* pHandler
   // assembly of the global ESD
 
   // define the inputs to the global ESD
-  TString esdInputs="TPC-globalmerger TPC-mcTrackMarker ITS-tracker GLOBAL-vertexer ITS-SPD-vertexer TPC-dEdx VZERO-RECO";
+  TString esdInputs="TPC-globalmerger TPC-mcTrackMarker ITS-tracker TPC-ClusterTransformation GLOBAL-vertexer ITS-SPD-vertexer TPC-dEdx VZERO-RECO ITS-SAPtracker";
 
   // check for the availibility
   pTokens=esdInputs.Tokenize(" ");
@@ -150,12 +163,18 @@ int AliHLTGlobalAgent::CreateConfigurations(AliHLTConfigurationHandler* pHandler
   }
 
   if (esdInputs.Length()>0) {
+    esdInputs+=" TPC-ClusterTransformation";
     HLTInfo("Configuring inputs to global HLT ESD: %s", esdInputs.Data());
   } else {
     HLTWarning("No inputs to global HLT ESD found");
   }
-
+  
+  pHandler->CreateConfiguration("GLOBAL-flat-esd-converter", "GlobalFlatEsdConverter", esdInputs.Data(), "");
   pHandler->CreateConfiguration("GLOBAL-esd-converter", "GlobalEsdConverter", esdInputs.Data(), "");
+  pHandler->CreateConfiguration("GLOBAL-flat-esd-test", "GlobalFlatEsdTest", "GLOBAL-esd-converter GLOBAL-flat-esd-converter", "");
+  pHandler->CreateConfiguration("esd-to-flat-conversion", "GlobalEsdToFlatConverter", "GLOBAL-esd-converter", "");
+  pHandler->CreateConfiguration("compare-flat", "GlobalCompareFlat", "GLOBAL-flat-esd-converter esd-to-flat-conversion", "");
+  //pHandler->CreateConfiguration("compare-flat", "GlobalCompareFlat", "GLOBAL-flat-esd-converter", "");
 
   ///////////////////////////////////////////////////////////////////////////////////////////////////
   //
diff --git a/HLT/global/AliHLTGlobalCompareFlatComponent.cxx b/HLT/global/AliHLTGlobalCompareFlatComponent.cxx
new file mode 100644 (file)
index 0000000..c88de9b
--- /dev/null
@@ -0,0 +1,343 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTGlobalCompareFlatComponent.cxx $
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Steffen Weber                                         *
+ *                                                                        *
+ * 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    AliHLTGlobalCompareFlatComponent.cxx
+    @author  Steffen Weber
+    @brief   Compare flat events from different inputs
+*/
+
+#include "TMap.h"
+#include "TSystem.h"
+#include "TTimeStamp.h"
+#include "TObjString.h"
+#include "TList.h"
+#include "THnSparse.h"
+#include "AliESDEvent.h"
+#include "AliFlatESDEvent.h"
+#include "AliFlatESDTrigger.h"
+#include "AliFlatESDV0.h"
+#include "AliFlatESDVertex.h"
+#include "AliHLTErrorGuard.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTGlobalCompareFlatComponent.h"
+#include "AliHLTITSClusterDataFormat.h"
+#include "AliHLTTPCDefinitions.h"
+#include "TTree.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+
+using namespace std;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTGlobalCompareFlatComponent)
+
+void AliHLTGlobalCompareFlatComponent::printDiff( string name, double val1, double val2){
+       double relDiff = ( val1 != 0 || val2!=0 ) ? (val1-val2)/(fabs(val1) + fabs(val2)): 0;
+       int diff = 0;
+       if (relDiff > 1e-6) diff = 1;
+       else if(relDiff < -1e-6) diff = -1;
+       outFile<<name<<"\t" << val1 << "\t" << val2 <<"\t" << diff << "\n";
+}
+void AliHLTGlobalCompareFlatComponent::printDiff( string name, TString val1, TString val2){
+       outFile << name << "\t" << "\t\"" << val1 <<"\"\t\"" << val2 <<"\"\t" << (val1.EqualTo(val2) ?0:1)<<"\n";
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+AliHLTGlobalCompareFlatComponent::AliHLTGlobalCompareFlatComponent() :
+  AliHLTProcessor()
+  {
+  // an example component which implements the ALICE HLT processor
+  // interface and does some analysis on the input raw data
+  //
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+// #################################################################################
+AliHLTGlobalCompareFlatComponent::~AliHLTGlobalCompareFlatComponent() {
+  // see header file for class documentation
+
+       
+       
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Public functions to implement AliHLTComponent's interface.
+ * These functions are required for the registration process
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+const Char_t* AliHLTGlobalCompareFlatComponent::GetComponentID() { 
+  // see header file for class documentation
+  return "GlobalCompareFlat";
+}
+
+// #################################################################################
+void AliHLTGlobalCompareFlatComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
+  // see header file for class documentation
+       list.push_back(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut );
+}
+
+// #################################################################################
+AliHLTComponentDataType AliHLTGlobalCompareFlatComponent::GetOutputDataType() {
+  // see header file for class documentation
+  return kAliHLTDataTypeTObject|kAliHLTDataOriginOut;
+}
+
+// #################################################################################
+void AliHLTGlobalCompareFlatComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
+  // see header file for class documentation
+  constBase = 100000;
+  inputMultiplier = 10.0;
+}
+
+
+// #################################################################################
+AliHLTComponent* AliHLTGlobalCompareFlatComponent::Spawn() {
+  // see header file for class documentation
+  return new AliHLTGlobalCompareFlatComponent;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Protected functions to implement AliHLTComponent's interface.
+ * These functions provide initialization as well as the actual processing
+ * capabilities of the component. 
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+Int_t AliHLTGlobalCompareFlatComponent::DoInit( Int_t argc, const Char_t** argv ) {
+  // see header file for class documentation
+  printf("AliHLTGlobalCompareFlatComponent::DoInit\n");
+  // see header file for class documentation
+  int iResult=0;
+
+/*
+       
+               Int_t bins[fDim] = {3};
+               Double_t mins[fDim] = {0};
+               Double_t maxs[fDim] = {2};
+               fhDiff = new THnSparseD("Differences","Differences",fDim,bins,mins,maxs);
+               
+               
+               Int_t tmp = 0;
+               
+               fhDiff->GetAxis(tmp)->SetName("Overall");
+               fhDiff->GetAxis(tmp)->SetBinLabel(1,"no differences");
+               fhDiff->GetAxis(tmp)->SetBinLabel(2,"sizes differ");
+               fhDiff->GetAxis(tmp)->SetBinLabel(3,"other differences");
+               
+               fhDiff->GetAxis(++tmp)->SetName("GetSize");
+               fhDiff->GetAxis(++tmp)->SetName("GetMagneticField");
+               fhDiff->GetAxis(++tmp)->SetName("GetPeriodNumber");
+               fhDiff->GetAxis(++tmp)->SetName("GetRunNumber");
+               fhDiff->GetAxis(++tmp)->SetName("GetOrbitNumber");
+               fhDiff->GetAxis(++tmp)->SetName("GetBunchCrossNumber");
+               fhDiff->GetAxis(++tmp)->SetName("GetTriggerMask");
+               fhDiff->GetAxis(++tmp)->SetName("GetTriggerMaskNext50");
+               fhDiff->GetAxis(++tmp)->SetName("GetFiredTriggerClasses");
+               fhDiff->GetAxis(++tmp)->SetName("GetNumberOfTracks");
+               fhDiff->GetAxis(++tmp)->SetName("GetNumberOfV0s");
+               fhDiff->GetAxis(++tmp)->SetName("GetTimeStamp");
+               fhDiff->GetAxis(++tmp)->SetName("GetEventSpecie");
+       */
+
+
+
+               
+               
+  return iResult;
+}
+
+
+
+// #################################################################################
+Int_t AliHLTGlobalCompareFlatComponent::DoDeinit() {
+  // see header file for class documentation
+  printf("AliHLTGlobalCompareFlatComponent::DoDeInit\n");
+
+       Int_t iResult = 0;
+       /*
+       TFile * f = TFile::Open("histograms.root","RECREATE");
+       f->Add(fhDiff);
+       f->Write();
+       f->Close();
+       */
+  //delete fhDiff;
+       
+  return iResult;
+}
+
+// #################################################################################
+Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
+                                                   const AliHLTComponentBlockData* /*blocks*/, 
+                                                   AliHLTComponentTriggerData& /*trigData*/,
+                                                   AliHLTUInt8_t* /*outputPtr*/, 
+                                                   AliHLTUInt32_t& /*size*/,
+                                                   AliHLTComponentBlockDataList& /*outputBlocks*/) {
+  // see header file for class documentation
+
+  printf("AliHLTGlobalCompareFlatComponent::DoEvent\n");
+  Int_t iResult=0;
+       
+       
+  // -- Only use data event
+ if (!IsDataEvent()) 
+   return 0;
+
+ AliFlatESDEvent *flatEsd[2] ;
+       
+  printf("search for input onbjects\n");
+       {
+        int i=0;
+       for ( const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
+    pBlock!=NULL && i<2; pBlock = GetNextInputBlock(),i++ ) {
+                       flatEsd[i] = reinterpret_cast<AliFlatESDEvent*>( pBlock->fPtr );
+  }
+       }
+ cout<<"size event 1: "<<flatEsd[0]->GetSize()<<endl;
+ cout<<"size event 2: "<<flatEsd[1]->GetSize()<<endl;
+
+
+ cout<<"nTracks event 1: "<<flatEsd[0]->GetNumberOfTracks()<<endl;
+ cout<<"nTracks event 2: "<<flatEsd[1]->GetNumberOfTracks()<<endl;
+ outFile.open("comparison.txt",ios::app);
+ // Compare Event variables
+ outFile<<"\n\n------------------\nnew AliFlatESDEvent\n------------------\n";
+ printDiff( "AliFlatESDEvent::GetSize" ,flatEsd[0]->GetSize(), flatEsd[1]->GetSize() ) ;
+       printDiff( "AliFlatESDEvent::GetMagneticField",flatEsd[0]->GetMagneticField(),flatEsd[1]->GetMagneticField() );
+       printDiff( "AliFlatESDEvent::GetPeriodNumber",flatEsd[0]->GetPeriodNumber(),flatEsd[1]->GetPeriodNumber() );
+       printDiff( "AliFlatESDEvent::GetRunNumber",flatEsd[0]->GetRunNumber(),  flatEsd[1]->GetRunNumber() );
+       printDiff( "AliFlatESDEvent::GetOrbitNumber",flatEsd[0]->GetOrbitNumber(),flatEsd[1]->GetOrbitNumber() );
+       printDiff( "AliFlatESDEvent::GetBunchCrossNumber",flatEsd[0]->GetBunchCrossNumber(),flatEsd[1]->GetBunchCrossNumber() );
+       printDiff( "AliFlatESDEvent::GetTriggerMask",flatEsd[0]->GetTriggerMask(),flatEsd[1]->GetTriggerMask() );
+       printDiff( "AliFlatESDEvent::GetTriggerMaskNext50",flatEsd[0]->GetTriggerMaskNext50(),flatEsd[1]->GetTriggerMaskNext50() );
+       printDiff( "AliFlatESDEvent::GetFiredTriggerClasses",flatEsd[0]->GetFiredTriggerClasses() ,flatEsd[1]->GetFiredTriggerClasses() );
+       printDiff( "AliFlatESDEvent::GetNumberOfTracks",flatEsd[0]->GetNumberOfTracks(),        flatEsd[1]->GetNumberOfTracks() );
+       printDiff( "AliFlatESDEvent::GetNumberOfV0s",flatEsd[0]->GetNumberOfV0s(),flatEsd[1]->GetNumberOfV0s() );
+       printDiff( "AliFlatESDEvent::GetTimeStamp",flatEsd[0]->GetTimeStamp(),flatEsd[1]->GetTimeStamp() );
+       printDiff( "AliFlatESDEvent::GetEventSpecie",flatEsd[0]->GetEventSpecie(),flatEsd[1]->GetEventSpecie() ); 
+       printDiff( "AliFlatESDEvent::GetNumberOfTriggerClasses",flatEsd[0]->GetNumberOfTriggerClasses(),flatEsd[1]->GetNumberOfTriggerClasses() ); 
+       
+ const AliFlatESDVertex * vertexTracks[2] = {flatEsd[0]->GetFlatPrimaryVertexTracks(), flatEsd[1]->GetFlatPrimaryVertexTracks()};
+       printDiff("AliFlatESDEvent::GetFlatPrimaryVertexTracks", (vertexTracks[0] ? 1:0), (vertexTracks[1] ? 1:0) );
+       
+ const AliFlatESDVertex * vertexSPD[2] = {flatEsd[0]->GetFlatPrimaryVertexSPD(), flatEsd[1]->GetFlatPrimaryVertexSPD()};
+       printDiff("AliFlatESDEvent::GetFlatPrimaryVertexSPD", (vertexSPD[0] ? 1:0), (vertexSPD[1] ? 1:0) );
+       
+ // Compare primary vertices
+       
+       if(vertexTracks[0] && vertexTracks[1]){
+      outFile<<"\nnew AliFlatESDVertexTracks\n";
+                       printDiff( "AliFlatESDVertexTracks::GetSize",vertexTracks[0]->GetSize(),vertexTracks[1]->GetSize() ); 
+                       printDiff( "AliFlatESDVertexTracks::GetX",vertexTracks[0]->GetX(),vertexTracks[1]->GetX() ); 
+                       printDiff( "AliFlatESDVertexTracks::GetY",vertexTracks[0]->GetY(),vertexTracks[1]->GetY() ); 
+                       printDiff( "AliFlatESDVertexTracks::GetZ",vertexTracks[0]->GetZ(),vertexTracks[1]->GetZ() ); 
+       }
+       if(vertexSPD[0] && vertexSPD[1]){
+      outFile<<"\nnew AliFlatESDVertexSPD\n";
+                       printDiff( "AliFlatESDVertexSPD::GetSize",vertexSPD[0]->GetSize(),vertexSPD[1]->GetSize() ); 
+                       printDiff( "AliFlatESDVertexSPD::GetX",vertexSPD[0]->GetX(),vertexSPD[1]->GetX() ); 
+                       printDiff( "AliFlatESDVertexSPD::GetY",vertexSPD[0]->GetY(),vertexSPD[1]->GetY() ); 
+                       printDiff( "AliFlatESDVertexSPD::GetZ",vertexSPD[0]->GetZ(),vertexSPD[1]->GetZ() ); 
+       }
+ // Compare triggers
+       
+       if(flatEsd[0]->GetNumberOfTriggerClasses()  && flatEsd[1]->GetNumberOfTriggerClasses() ){
+               outFile<<"------------------\ntriggers\n------------------\n";
+    AliFlatESDTrigger * trigger[2] = { const_cast<AliFlatESDTrigger*>(flatEsd[0]->GetTriggerClasses() ) , const_cast<AliFlatESDTrigger*>(flatEsd[1]->GetTriggerClasses() ) };
+    for( Int_t i = 0; i < flatEsd[0]->GetNumberOfTriggerClasses()  && i < flatEsd[1]->GetNumberOfTriggerClasses()  ; i++ ){
+      outFile<<"\nnew AliFlatESDTrigger\n";
+                       printDiff( "AliFlatESDTrigger::GetSize",trigger[0]->GetSize(),trigger[1]->GetSize() ); 
+                       printDiff( "AliFlatESDTrigger::GetTriggerIndex",trigger[0]->GetTriggerIndex(),trigger[1]->GetTriggerIndex() ); 
+                       printDiff( "AliFlatESDTrigger::GetTriggerClassName",trigger[0]->GetTriggerClassName(),trigger[1]->GetTriggerClassName() ); 
+                       
+      trigger[0] = trigger[0]->GetNextTriggerNonConst();
+                       trigger[1] = trigger[1]->GetNextTriggerNonConst();
+    }
+       }
+       
+ // Compare v0s
+       
+       if(flatEsd[0]->GetNumberOfV0s()  && flatEsd[1]->GetNumberOfV0s() ){
+               outFile<<"------------------\nv0s\n------------------\n";
+               
+    AliFlatESDV0 * v0[2] = { const_cast<AliFlatESDV0*>(flatEsd[0]->GetV0s() ) , const_cast<AliFlatESDV0*>(flatEsd[1]->GetV0s() ) };
+    for( Int_t i = 0; i < flatEsd[0]->GetNumberOfV0s()  && i < flatEsd[1]->GetNumberOfV0s()  ; i++ ){
+      outFile<<"\nnew AliFlatESDV0\n";
+                       printDiff( "AliFlatESDV0::GetSize",v0[0]->GetSize(),v0[1]->GetSize() ); 
+                       printDiff( "AliFlatESDV0::GetNegTrackID",v0[0]->GetNegTrackID(),v0[1]->GetNegTrackID() ); 
+                       printDiff( "AliFlatESDV0::GetPosTrackID",v0[0]->GetPosTrackID(),v0[1]->GetPosTrackID() ); 
+                       
+      v0[0] = v0[0]->GetNextV0NonConst();
+                       v0[1] = v0[1]->GetNextV0NonConst();
+    }
+       }
+       
+       
+ outFile.close();
+  return iResult;
+}
+
+
+// #################################################################################
+Int_t AliHLTGlobalCompareFlatComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
+  // see header file for class documentation
+  ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
+  return 0;
+}
+
+
+int AliHLTGlobalCompareFlatComponent::Configure(const char*/* arguments*/)
+{
+  // see header file for class documentation
+  int iResult=0;
+
+  return iResult;
+}
+
+int AliHLTGlobalCompareFlatComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
+{
+  // see header file for class documentation
+  int iResult=0;
+  
+  return iResult;
+}
+
+
diff --git a/HLT/global/AliHLTGlobalCompareFlatComponent.h b/HLT/global/AliHLTGlobalCompareFlatComponent.h
new file mode 100644 (file)
index 0000000..77416b6
--- /dev/null
@@ -0,0 +1,160 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTGlobalCompareFlatComponent $
+
+#ifndef ALIHLTGLOBALCOMPAREFLATCOMPONENT_H
+#define ALIHLTGLOBALCOMPAREFLATCOMPONENT_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    AliHLTGlobalCompareFlatComponent.h
+    @author  Steffen Weber <s.weber@gsi.de>
+    @brief   Compare flat events from different inputs
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+
+class THnSparse;
+
+class AliESDVZERO;
+class AliESDtrackCuts;
+class AliHLTCTPData;
+class AliHLTMultiplicityCorrelations;
+class AliHLTGlobalTriggerDecision;
+class AliHLTTestInputHandler;
+
+
+class AliHLTGlobalCompareFlatComponent : public AliHLTProcessor {
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** constructor */
+  AliHLTGlobalCompareFlatComponent();
+  
+  /** destructor */
+  virtual ~AliHLTGlobalCompareFlatComponent();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Public functions to implement AliHLTComponent's interface.
+   * These functions are required for the registration process
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** interface function, see @ref AliHLTComponent for description */
+  const Char_t* GetComponentID();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier );
+
+  /** interface function, see @ref AliHLTComponent for description */
+ // void GetOCDBObjectDescription( TMap* const targetMap);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+ protected:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Protected functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  // AliHLTComponent interface functions
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoInit( Int_t /*argc*/, const Char_t** /*argv*/ );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoDeinit();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  int DoEvent( const AliHLTComponentEventData& evtData,
+              const AliHLTComponentBlockData* blocks, 
+              AliHLTComponentTriggerData& trigData,
+              AliHLTUInt8_t* outputPtr, 
+              AliHLTUInt32_t& size,
+              AliHLTComponentBlockDataList& outputBlocks);
+
+  using AliHLTProcessor::DoEvent;
+
+
+  /**
+   * Configure the component.
+   * Parse a string for the configuration arguments and set the component
+   * properties.
+   */
+  int Configure(const char* arguments);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t Reconfigure(const Char_t* cdbEntry, const Char_t* chainId);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t ReadPreprocessorValues(const Char_t* modules);
+  ///////////////////////////////////////////////////////////////////////////////////
+  
+private:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Private functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** copy constructor prohibited */
+  AliHLTGlobalCompareFlatComponent(const AliHLTGlobalCompareFlatComponent&);
+
+  /** assignment operator prohibited */
+  AliHLTGlobalCompareFlatComponent& operator=(const AliHLTGlobalCompareFlatComponent&);
+void printDiff( string name, double val1, double val2);
+void printDiff( string name, TString val1, TString val2);
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                              Helper
+   * ---------------------------------------------------------------------------------
+   */
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Members - private
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** UID for merging */
+
+       /*
+       THnSparse * fhDiff;
+       
+       static const    Int_t fDim = 14;
+       */
+       ofstream outFile;
+       
+       
+  ClassDef(AliHLTGlobalCompareFlatComponent, 0)
+};
+#endif
index f474419edab40242f640eaee4015c0ebaad9156e..fe1cc92d0880ab6fe87252879690f80f4dcc8dd2 100644 (file)
 #include "AliHLTExternalTrackParam.h"
 #include "AliHLTTrackMCLabel.h"
 #include "AliHLTCTPData.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliTPCclusterMI.h"
+#include "AliTPCseed.h"
+#include "AliITStrackV2.h"
+#include "AliESDfriend.h"
+#include "AliESDfriendTrack.h"
+#include "AliHLTTPCTransform.h"
 #include "AliHLTErrorGuard.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
@@ -45,6 +54,8 @@
 #include "TTree.h"
 #include "TList.h"
 #include "TClonesArray.h"
+#include "TTimeStamp.h"
+#include "THnSparse.h"
 #include "AliHLTESDCaloClusterMaker.h"
 #include "AliHLTCaloClusterDataStruct.h"
 #include "AliHLTCaloClusterReader.h"
@@ -52,6 +63,9 @@
 #include "AliESDVZERO.h"
 #include "AliHLTGlobalVertexerComponent.h"
 #include "AliHLTVertexFinderBase.h"
+#include "AliSysInfo.h"
+#include "AliHLTSAPTrackerData.h"
+#include "AliFlatESDVertex.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTGlobalEsdConverterComponent)
@@ -61,7 +75,9 @@ AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent()
   , fWriteTree(0)
   , fVerbosity(0)
   , fESD(NULL)
+  , fESDfriend(NULL)
   , fSolenoidBz(-5.00668)
+  , fMakeFriends(1)
   , fBenchmark("EsdConverter")
 {
   // see header file for class documentation
@@ -69,13 +85,20 @@ AliHLTGlobalEsdConverterComponent::AliHLTGlobalEsdConverterComponent()
   // refer to README to build package
   // or
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  for( int i=0; i<fkNPartition; i++ ){
+       fPartitionClusters[i]  = 0;    
+       fNPartitionClusters[i] = 0;    
+  }  
 }
 
 AliHLTGlobalEsdConverterComponent::~AliHLTGlobalEsdConverterComponent()
 {
   // see header file for class documentation
-  if (fESD) delete fESD;
-  fESD=NULL;
+  delete fESD;
+  delete fESDfriend;
+  for( int i=0; i<fkNPartition; i++ ){
+    delete[] fPartitionClusters[i];
+  }
 }
 
 int AliHLTGlobalEsdConverterComponent::Configure(const char* arguments)
@@ -158,12 +181,24 @@ void AliHLTGlobalEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTyp
   list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
   list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
   list.push_back(kAliHLTDataTypeESDContent);
+  list.push_back( AliHLTTPCDefinitions::fgkClustersDataType   );
+  list.push_back(kAliHLTDataTypeFlatESDVertex); // VertexTracks resonctructed using SAP ITS tracks
+  list.push_back(kAliHLTDataTypeITSSAPData);    // SAP ITS tracks
 }
 
 AliHLTComponentDataType AliHLTGlobalEsdConverterComponent::GetOutputDataType()
 {
   // see header file for class documentation
-  return kAliHLTDataTypeESDObject|kAliHLTDataOriginOut;
+  return kAliHLTMultipleDataType;
+}
+
+int AliHLTGlobalEsdConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){ 
+// see header file for class documentation
+
+  tgtList.clear();
+  tgtList.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
+  tgtList.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
+  return tgtList.size();
 }
 
 void AliHLTGlobalEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
@@ -243,6 +278,11 @@ int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
 
   fSolenoidBz=GetBz();
 
+  delete fESD;
+  fESD = NULL;
+  delete fESDfriend;
+  fESDfriend=0;
+
   if (iResult>=0) {
     fESD = new AliESDEvent;
     if (fESD) {
@@ -276,6 +316,10 @@ int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
 
     SetupCTPData();
   }
+  
+  if( iResult>=0 && fMakeFriends ){
+    fESDfriend = new AliESDfriend();
+  }
 
   fBenchmark.SetTimer(0,"total");
 
@@ -285,24 +329,38 @@ int AliHLTGlobalEsdConverterComponent::DoInit(int argc, const char** argv)
 int AliHLTGlobalEsdConverterComponent::DoDeinit()
 {
   // see header file for class documentation
-  if (fESD) delete fESD;
+  delete fESD;
   fESD=NULL;
-
+  delete fESDfriend;
+  fESDfriend = NULL;
   return 0;
 }
 
-int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/
+int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& evtData
                                               AliHLTComponentTriggerData& trigData)
 {
   // see header file for class documentation
   int iResult=0;
+
+
+  AliSysInfo::AddStamp("AliHLTGlobalEsdConverterComponent::DoEvent.Start", evtData.fStructSize);
+
+  bool benchmark = true;
+
   if (!fESD) return -ENODEV;
 
-  if (IsDataEvent()) fBenchmark.StartNewEvent();
+  if (!IsDataEvent()) return iResult;
+  fBenchmark.StartNewEvent();
   fBenchmark.Start(0);
 
+  for(Int_t i=0; i<fkNPartition; i++){
+    delete[] fPartitionClusters[i];    
+    fPartitionClusters[i]  = 0;
+    fNPartitionClusters[i] = 0;    
+  }  
+  
   AliESDEvent* pESD = fESD;
-
+  
   pESD->Reset(); 
   pESD->SetMagneticField(fSolenoidBz);
   pESD->SetRunNumber(GetRunNo());
@@ -335,7 +393,9 @@ int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /
     pTree->SetDirectory(0);
   }
 
-  if ((iResult=ProcessBlocks(pTree, pESD))>=0) {
+  if( fESDfriend ) fESDfriend->Reset();
+
+  if ((iResult=ProcessBlocks(pTree, pESD, fESDfriend))>=0) {
     // TODO: set the specification correctly
     if (pTree) {
       // the esd structure is written to the user info and is
@@ -344,9 +404,15 @@ int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /
       pESD->WriteToTree(pTree);
       iResult=PushBack(pTree, kAliHLTDataTypeESDTree|kAliHLTDataOriginOut, 0);
     } else {
+      cout<<"Write ESD block: n tracks "<<pESD->GetNumberOfTracks()<<endl;
       iResult=PushBack(pESD, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0);
     }
     fBenchmark.AddOutput(GetLastObjectSize());
+    if( iResult>=0 && fMakeFriends ){
+      cout<<"Write ESD friend block: n friend tracks "<<fESDfriend->GetNumberOfTracks()<<endl;
+      iResult=PushBack(fESDfriend, kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut, 0);
+      fBenchmark.AddOutput(GetLastObjectSize());
+     }
   }
   if (pTree) {
     // clear user info list to prevent objects from being deleted
@@ -355,12 +421,37 @@ int AliHLTGlobalEsdConverterComponent::DoEvent(const AliHLTComponentEventData& /
   }
 
   fBenchmark.Stop(0);
-  HLTInfo( fBenchmark.GetStatistics() );
+  HLTWarning( fBenchmark.GetStatistics() );
+  
+    
+  
+  
+  
+  
+    if(benchmark){
+       
+       
+       Double_t statistics[10]; 
+       TString names[10];
+       fBenchmark.GetStatisticsData(statistics, names);
+         fBenchmark.Reset();
+  
+       AliSysInfo::AddStamp("AliHLTGlobalEsdConverterComponent::DoEvent.Stop", (int)(statistics[1]), (int)(statistics[2]),pESD->GetNumberOfV0s(),pESD->GetNumberOfTracks() );
+  }
+  
+  for(Int_t i=0; i<fkNPartition; i++){
+      delete[] fPartitionClusters[i];    
+      fPartitionClusters[i]  = 0;
+      fNPartitionClusters[i] = 0;    
+  }
+
+  if( fESDfriend ) fESDfriend->Reset();
+  if( fESD ) fESD->Reset();
 
   return iResult;
 }
 
-int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD)
+int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent* pESD, AliESDfriend *pESDfriend )
 {
   // see header file for class documentation
 
@@ -403,6 +494,75 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
   // 5) Add Trigger Detectors 
   //    VZERO, ZDC
 
+  // read the clusters
+  // ---------- Access to clusters --------------------//
+  /*
+  const AliHLTComponentBlockData* pBl0=GetFirstInputBlock();
+  int cnt = 0;
+  while (pBl0) {
+    char tp[9],org[5];
+    strncpy(tp,pBl0->fDataType.fID,8);
+    tp[8] = '0';
+    strncpy(org,pBl0->fDataType.fOrigin,4);
+    org[4] = '0';
+    //
+    printf(">>> Bl%3d %8s|%4s of size %d\n",cnt++,tp,org,pBl0->fSize);
+    pBl0 = GetNextInputBlock();
+  };
+  */
+  for(Int_t i=0; i<fkNPartition; i++){
+    delete[] fPartitionClusters[i];    
+    fPartitionClusters[i]  = 0;
+    fNPartitionClusters[i] = 0;    
+  }
+
+  if( pESDfriend ){
+
+    int nInputClusters = 0;
+    
+    for(const AliHLTComponentBlockData *iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
+      
+      if(iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType) continue;    
+      Int_t slice     = AliHLTTPCDefinitions::GetMinSliceNr(iter->fSpecification);
+      Int_t partition = AliHLTTPCDefinitions::GetMinPatchNr(iter->fSpecification);    
+      Int_t slicepartition = slice*6+partition;      
+      if(slicepartition<0 || slicepartition > fkNPartition){
+       HLTWarning("Wrong header of TPC cluster data, slice %d, partition %d", slice, partition );
+       continue;
+      }
+      
+      AliHLTTPCClusterData *inPtrSP = ( AliHLTTPCClusterData* )( iter->fPtr );
+      nInputClusters += inPtrSP->fSpacePointCnt;
+      
+      delete[] fPartitionClusters[slicepartition];
+      fPartitionClusters[slicepartition]  = new AliTPCclusterMI[inPtrSP->fSpacePointCnt];
+      fNPartitionClusters[slicepartition] = inPtrSP->fSpacePointCnt;
+    
+      // create  offline clusters out of the HLT clusters
+
+      for ( unsigned int i = 0; i < inPtrSP->fSpacePointCnt; i++ ) {
+       AliHLTTPCSpacePointData *chlt = &( inPtrSP->fSpacePoints[i] );
+       AliTPCclusterMI *c = fPartitionClusters[slicepartition]+i;
+       c->SetX(chlt->fX);
+       c->SetY(chlt->fY);
+       c->SetZ(chlt->fZ);
+       c->SetSigmaY2(chlt->fSigmaY2);
+       c->SetSigmaYZ( 0 );
+       c->SetSigmaZ2(chlt->fSigmaZ2);
+       c->SetQ( chlt->fCharge );
+       c->SetMax( chlt->fQMax );
+       Int_t sector, row;
+       Float_t padtime[3] = {0,chlt->fY,chlt->fZ};
+       AliHLTTPCTransform::Slice2Sector(slice,chlt->fPadRow, sector, row);
+       AliHLTTPCTransform::Local2Raw( padtime, sector, row);
+       c->SetDetector( sector );
+       c->SetRow( row );
+       c->SetPad( (Int_t) padtime[1] );
+       c->SetTimeBin( (Int_t) padtime[2] );
+      }
+    } // end of loop over blocks of clusters    
+  }
+
   // 1) first read MC information (if present)
   std::map<int,int> mcLabelsTPC;
   std::map<int,int> mcLabelsITS;
@@ -465,6 +625,7 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
     fBenchmark.AddInput(pBlock->fSize);
     vector<AliHLTGlobalBarrelTrack> tracks;
     if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>=0) {
+      cout<<"\n\n ESD converter: input "<<tracks.size()<<" TPC tracks"<<endl;
       for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
           element!=tracks.end(); element++) {
        Float_t points[4] = {
@@ -537,7 +698,70 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
        iotrack.SetLabel(mcLabel);
        pESD->AddTrack(&iotrack);
        if (fVerbosity>0) element->Print();
+      
+       if( pESDfriend ){ // create friend track
+
+         AliHLTGlobalBarrelTrack gb(*element);
+         AliTPCseed tTPC;
+         tTPC.Set( gb.GetX(), gb.GetAlpha(), gb.GetParameter(), gb.GetCovariance() );    
+         tTPC.SetLabel(mcLabel);
+         
+         // set the clusters 
+         UInt_t nClusters = element->GetNumberOfPoints();
+         const UInt_t*clusterIDs = element->GetPoints();
+
+         tTPC.SetNumberOfClusters(nClusters);
+
+         for(UInt_t ic=0; ic<nClusters; ic++){  
+
+           UInt_t id      = clusterIDs[ic];         
+           int iSlice = AliHLTTPCSpacePointData::GetSlice(id);
+           int iPartition = AliHLTTPCSpacePointData::GetPatch(id);
+           int iCluster = AliHLTTPCSpacePointData::GetNumber(id);
+           
+           if(iSlice<0 || iSlice>36 || iPartition<0 || iPartition>5){
+             HLTError("Corrupted TPC cluster Id: slice %d, partition %d, cluster %d", iSlice, iPartition, iCluster);
+             continue;
+           }
+           
+           AliTPCclusterMI *patchClusters = fPartitionClusters[iSlice*6 + iPartition];
+           if(!patchClusters){
+             HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition );
+             continue;
+           }
+           
+           if(iCluster >= fNPartitionClusters[iSlice*6 + iPartition]){
+             HLTError("TPC slice %d, partition %d: ClusterID==%d >= N Cluaters==%d ", iSlice, iPartition,iCluster, fNPartitionClusters[iSlice*6 + iPartition] );
+             continue;
+           }
+       
+           AliTPCclusterMI *c = &(patchClusters[iCluster]);            
+           int sec = c->GetDetector();
+           int row = c->GetRow();
+           if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow();
+         
+           tTPC.SetClusterPointer(row, c);     
+       
+           AliTPCTrackerPoint &point = *( tTPC.GetTrackPoint( row ) );
+           //tTPC.Propagate( TMath::DegToRad()*(sec%18*20.+10.), c->GetX(), fSolenoidBz );
+           Double_t angle2 = tTPC.GetSnp()*tTPC.GetSnp();
+           angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.; 
+           point.SetAngleY( angle2 );
+           point.SetAngleZ( tTPC.GetTgl() );
+         } // end of associated cluster loop
+         
+         // Cook dEdx
+         
+         AliTPCseed *seed = &(tTPC);      
+         //fSeedArray->AddAt( seed, TMath::Abs(seed->GetLabel()) );
+         //fdEdx->Fill( seed->P()*seed->Charge(), seed->CookdEdx(0.02, 0.6) );
+
+         AliESDfriendTrack friendTrack;
+         friendTrack.AddCalibObject(&tTPC);
+         pESDfriend->AddTrack(&friendTrack);
+       }
       }
+
       HLTInfo("converted %d track(s) to AliESDtrack and added to ESD", tracks.size());
       iAddedDataBlocks++;
     } else if (iResult<0) {
@@ -557,6 +781,55 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
     pESD->SetPrimaryVertexSPD( vtx );
   }
 
+  // Get ITS Standalone primaries (SAP) vertexTracks
+  {
+    const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESDVertex|kAliHLTDataOriginITS);
+    if (pBlock) {
+      fBenchmark.AddInput(pBlock->fSize);
+      AliFlatESDVertex *vtxFlat =  reinterpret_cast<AliFlatESDVertex*>( pBlock->fPtr );
+      if (vtxFlat->GetNContributors()>0) {
+       cout<<"\n\n ESD converter: input vertexTrackSAP with "<<vtxFlat->GetNContributors()<<" contributors"<<endl;
+       AliESDVertex vtx;
+       vtxFlat->GetESDVertex(vtx);
+       vtx.SetTitle("vertexITSSAP");
+       pESD->SetPrimaryVertexSPD( &vtx );
+      }
+    }
+  }
+
+  // Get ITS Standalone primary (SAP) Tracks
+  {
+    const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeITSSAPData|kAliHLTDataOriginITS);
+    if (pBlock) {
+      fBenchmark.AddInput(pBlock->fSize);
+      const AliHLTITSSAPTrackerDataContainer *dataSAP = reinterpret_cast<const AliHLTITSSAPTrackerDataContainer*>(pBlock->fPtr);
+      AliITStrackV2 trcV2;
+      int ntrITSSAP = dataSAP->fCount;
+      cout<<"\n\n ESD converter: input "<<ntrITSSAP<<" ITS SAP tracks"<<endl;
+      for (int itr=0;itr<ntrITSSAP;itr++) {
+       const AliHLTITSSAPTrackerData& trcFlatSAP = dataSAP->fTracks[itr];
+       AliESDtrack inpESDtrc;
+       inpESDtrc.SetID(pESD->GetNumberOfTracks());
+       trcFlatSAP.paramInw.GetExternalTrackParam(trcV2); // track at the vertex
+       trcV2.SetLabel(trcFlatSAP.label);
+       trcV2.SetNumberOfClusters(trcFlatSAP.ncl);
+       trcV2.SetChi2(trcFlatSAP.chi2);
+       inpESDtrc.UpdateTrackParams(&trcV2,AliESDtrack::kITSrefit);
+       inpESDtrc.SetStatus( (AliESDtrack::kITSin|AliESDtrack::kITSout|AliESDtrack::kITSpureSA) );
+       pESD->AddTrack(&inpESDtrc);
+       //
+       if( pESDfriend ) {
+         AliESDfriendTrack friendTrack;
+         trcFlatSAP.paramOut.GetExternalTrackParam(trcV2); // track at the vertex
+         friendTrack.SetITSOut(trcV2);
+         pESDfriend->AddTrack(&friendTrack);
+       }
+      }
+    }
+  }
+  
+
+
   // 3.1. now update ESD tracks with the ITSOut info
   // updating track parameters with flag kITSout will overwrite parameter set above with flag kTPCout
   // TODO 2010-07-12 there are some issues with this updating sequence, for the moment update with
@@ -631,6 +904,7 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
 
   // update with  vertices and vertex-fitted tracks
   // output of PrimaryVertexer and V0Finder components
+  
   TObject* pBase = (TObject*)GetFirstInputObject(kAliHLTDataTypeKFVertex | kAliHLTDataOriginOut);
   if (pBase) {
     AliKFVertex* kfVertex = dynamic_cast<AliKFVertex *>(pBase);
@@ -856,11 +1130,17 @@ int AliHLTGlobalEsdConverterComponent::ProcessBlocks(TTree* pTree, AliESDEvent*
       }
     }
   }
+
+  if( fMakeFriends && pESDfriend ){ // create friend track
+    pESD->SetESDfriend( pESDfriend );
+    // cout<<"\n\n ESD Friend: "<<pESDfriend->GetNumberOfTracks()<<endl;
+ }
   
   if (iAddedDataBlocks>0 && pTree) {
     pTree->Fill();
-  }
+  }  
   
   if (iResult>=0) iResult=iAddedDataBlocks;
   return iResult;
-}
+}
\ No newline at end of file
index f70000084d05b1a93caedcdf886890abd87b35c4..1a5dae57b6ff133abfd1c6f878ac144efbdb9759 100644 (file)
@@ -1,5 +1,6 @@
 //-*- Mode: C++ -*-
 // $Id$
+
 #ifndef ALIHLTGLOBALESDCONVERTERCOMPONENT_H
 #define ALIHLTGLOBALESDCONVERTERCOMPONENT_H
 //* This file is property of and copyright by the ALICE HLT Project        * 
 
 // forward declarations
 class AliESDEvent;
+class AliESDfriend;
 class TTree;
 struct AliHLTTracksData;
+class AliTPCclusterMI;
 
 /**
  * @class AliHLTGlobalEsdConverterComponent
@@ -53,6 +56,7 @@ class AliHLTGlobalEsdConverterComponent : public AliHLTProcessor
   const char* GetComponentID() {return "GlobalEsdConverter";};
   void GetInputDataTypes(AliHLTComponentDataTypeList& list);
   AliHLTComponentDataType GetOutputDataType();
+  int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
   void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
   AliHLTComponent* Spawn() {return new AliHLTGlobalEsdConverterComponent;}
 
@@ -71,8 +75,9 @@ class AliHLTGlobalEsdConverterComponent : public AliHLTProcessor
    * @param pESD     ESD to be filled
    * @return neg. error code if failed
    */
-  int ProcessBlocks(TTree* pTree, AliESDEvent* pESD);
+  int ProcessBlocks(TTree* pTree, AliESDEvent* pESD, AliESDfriend *pESDfriend);
 
+ // void FillBenchmarkHistos(Double_t *statistics, TString *names);
  private:
   /** copy constructor prohibited */
   AliHLTGlobalEsdConverterComponent(const AliHLTGlobalEsdConverterComponent&);
@@ -101,11 +106,21 @@ class AliHLTGlobalEsdConverterComponent : public AliHLTProcessor
 
 protected:
 
+  static const Int_t fkNPartition = 36*6;           // number of patches in TPC
+
   /// the ESD
   AliESDEvent* fESD; //! transient value
 
+  /// the ESD friend
+  AliESDfriend* fESDfriend; //! transient value
+
   /// solenoid b field
   Double_t fSolenoidBz; //! transient
+
+  Bool_t fMakeFriends; // flag to create friends
+  AliTPCclusterMI   *fPartitionClusters[fkNPartition];  //! arrays of cluster data for each TPC partition
+  Int_t              fNPartitionClusters[fkNPartition]; //! number of clusters for each TPC partition
   AliHLTComponentBenchmark fBenchmark; // benchmark
 
   ClassDef(AliHLTGlobalEsdConverterComponent, 0)
diff --git a/HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx b/HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx
new file mode 100644 (file)
index 0000000..59c0ef3
--- /dev/null
@@ -0,0 +1,341 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTGlobalEsdToFlatConverterComponent.cxx $
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Steffen Weber                                         *
+ *                                                                        *
+ * 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    AliHLTGlobalEsdToFlatConverterComponent.cxx
+    @author  Steffen Weber
+    @brief   Component to convert ESD objects to flatESD objects
+*/
+
+#include "TMap.h"
+#include "TSystem.h"
+#include "TTimeStamp.h"
+#include "TObjString.h"
+#include "TList.h"
+#include "AliESDEvent.h"
+#include "AliFlatESDEvent.h"
+#include "AliHLTErrorGuard.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTGlobalEsdToFlatConverterComponent.h"
+#include "AliHLTITSClusterDataFormat.h"
+#include "AliHLTTPCDefinitions.h"
+#include "TTree.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliSysInfo.h"
+
+using namespace std;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTGlobalEsdToFlatConverterComponent)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+AliHLTGlobalEsdToFlatConverterComponent::AliHLTGlobalEsdToFlatConverterComponent() :
+  AliHLTProcessor()
+  {
+  // an example component which implements the ALICE HLT processor
+  // interface and does some analysis on the input raw data
+  //
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+// #################################################################################
+AliHLTGlobalEsdToFlatConverterComponent::~AliHLTGlobalEsdToFlatConverterComponent() {
+  // see header file for class documentation
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Public functions to implement AliHLTComponent's interface.
+ * These functions are required for the registration process
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+const Char_t* AliHLTGlobalEsdToFlatConverterComponent::GetComponentID() { 
+  // see header file for class documentation
+  return "GlobalEsdToFlatConverter";
+}
+
+// #################################################################################
+void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
+  // see header file for class documentation
+       list.push_back(kAliHLTDataTypeESDTree|kAliHLTDataOriginOut );
+  list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
+  list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
+}
+
+// #################################################################################
+AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
+  // see header file for class documentation
+  return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+}
+
+// #################################################################################
+void AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
+  // see header file for class documentation
+  constBase = 10000;
+  inputMultiplier = 10.0;
+}
+
+
+// #################################################################################
+AliHLTComponent* AliHLTGlobalEsdToFlatConverterComponent::Spawn() {
+  // see header file for class documentation
+  return new AliHLTGlobalEsdToFlatConverterComponent;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Protected functions to implement AliHLTComponent's interface.
+ * These functions provide initialization as well as the actual processing
+ * capabilities of the component. 
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+Int_t AliHLTGlobalEsdToFlatConverterComponent::DoInit( Int_t argc, const Char_t** argv ) {
+  // see header file for class documentation
+  printf("AliHLTGlobalEsdToFlatConverterComponent::DoInit\n");
+  // see header file for class documentation
+  int iResult=0;
+  TString argument="";
+  int bMissingParam=0;
+
+  // default list of skiped ESD objects
+  TString skipObjects=
+    // "AliESDRun,"
+    // "AliESDHeader,"
+    // "AliESDZDC,"
+    "AliESDFMD,"
+    // "AliESDVZERO,"
+    // "AliESDTZERO,"
+    // "TPCVertex,"
+    // "SPDVertex,"
+    // "PrimaryVertex,"
+    // "AliMultiplicity,"
+    // "PHOSTrigger,"
+    // "EMCALTrigger,"
+    // "SPDPileupVertices,"
+    // "TrkPileupVertices,"
+    "Cascades,"
+    "Kinks,"
+    "AliRawDataErrorLogs,"
+    "AliESDACORDE";
+
+  iResult=Reconfigure(NULL, NULL);
+  TString allArgs = "";
+  for ( int i = 0; i < argc; i++ ) {
+    if ( !allArgs.IsNull() ) allArgs += " ";
+    allArgs += argv[i];
+  }
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;
+ if (argument.Contains("-skipobject=")) {
+       argument.ReplaceAll("-skipobject=", "");
+       skipObjects=argument;
+      } else {
+       HLTError("unknown argument %s", argument.Data());
+       iResult=-EINVAL;
+       break;
+      }
+    }
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+
+  if (iResult>=0) {
+    SetupCTPData();
+  }
+
+  return iResult;
+}
+
+
+
+// #################################################################################
+Int_t AliHLTGlobalEsdToFlatConverterComponent::DoDeinit() {
+  // see header file for class documentation
+
+       
+  return 0;
+}
+
+// #################################################################################
+Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
+                                                   const AliHLTComponentBlockData* /*blocks*/, 
+                                                   AliHLTComponentTriggerData& /*trigData*/,
+                                                   AliHLTUInt8_t* outputPtr, 
+                                                   AliHLTUInt32_t& size,
+                                                   AliHLTComponentBlockDataList& outputBlocks) {
+  // see header file for class documentation
+
+       
+       
+       
+  AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Start");
+  Int_t iResult=0;
+
+       
+       
+  size_t maxOutputSize = size;
+  size = 0;
+       
+  // -- Only use data event
+  if (!IsDataEvent()) 
+    return 0;
+  
+   AliESDEvent *esd;
+       
+       
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
+    esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));
+    if( esd ){
+      esd->GetStdContent();
+                       iResult=1;
+    } else {
+    }
+  }
+
+   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {     
+     //fBenchmark.AddInput(pBlock->fSize);
+    const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
+    if( esdFriend ){
+    } else {
+    }
+  }
+           
+ AliFlatESDEvent *flatEsd ;
+
+    flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
+    new (flatEsd) AliFlatESDEvent;
+  flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE); 
+                
+       
+       if( maxOutputSize > flatEsd->GetSize() ){
+       
+    AliHLTComponentBlockData outBlock;
+    FillBlockData( outBlock );
+    outBlock.fOffset = size;
+    outBlock.fSize = flatEsd->GetSize();
+    outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+    outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
+
+    outputBlocks.push_back( outBlock );
+
+    size += outBlock.fSize;
+               
+       }
+       
+       else {
+               
+       return 0;       
+       }
+       
+  AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Stop",0, flatEsd->GetSize(),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks());
+  return iResult;
+}
+
+
+// #################################################################################
+Int_t AliHLTGlobalEsdToFlatConverterComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
+  // see header file for class documentation
+  ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
+  return 0;
+}
+
+
+int AliHLTGlobalEsdToFlatConverterComponent::Configure(const char* arguments)
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!arguments) return iResult;
+
+  TString allArgs=arguments;
+  TString argument;
+  int bMissingParam=0;
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;      
+      HLTError("unknown argument %s", argument.Data());
+      iResult=-EINVAL;
+      break;
+    }  
+    delete pTokens;
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+  return iResult;
+}
+
+int AliHLTGlobalEsdToFlatConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // see header file for class documentation
+  int iResult=0;
+  const char* path=NULL;
+  const char* defaultNotify="";
+  if (cdbEntry) {
+    path=cdbEntry;
+    defaultNotify=" (default)";
+  }
+  if (path) {
+    HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+    if (pEntry) {
+      TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+      if (pString) {
+       HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
+       iResult=Configure(pString->String().Data());
+      } else {
+       HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+      }
+    } else {
+      HLTError("can not fetch object \"%s\" from CDB", path);
+    }
+  }
+  
+  return iResult;
+}
diff --git a/HLT/global/AliHLTGlobalEsdToFlatConverterComponent.h b/HLT/global/AliHLTGlobalEsdToFlatConverterComponent.h
new file mode 100644 (file)
index 0000000..63641a6
--- /dev/null
@@ -0,0 +1,151 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTGlobalEsdToFlatConverterComponent $
+
+#ifndef ALIHLTESDTOFLATCONVERTERCOMPONENT_H
+#define ALIHLTESDTOFLATCONVERTERCOMPONENT_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    AliHLTGlobalEsdToFlatConverterComponent.h
+    @author  Steffen Weber <s.weber@gsi.de>
+    @brief   Component to convert ESD objects to flatESD objects
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+
+class TH1F;
+class TList;
+
+class AliESDVZERO;
+class AliESDtrackCuts;
+class AliHLTCTPData;
+class AliHLTMultiplicityCorrelations;
+class AliHLTGlobalTriggerDecision;
+class AliHLTTestInputHandler;
+
+class AliHLTGlobalEsdToFlatConverterComponent : public AliHLTProcessor {
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** constructor */
+  AliHLTGlobalEsdToFlatConverterComponent();
+  
+  /** destructor */
+  virtual ~AliHLTGlobalEsdToFlatConverterComponent();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Public functions to implement AliHLTComponent's interface.
+   * These functions are required for the registration process
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** interface function, see @ref AliHLTComponent for description */
+  const Char_t* GetComponentID();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier );
+
+  /** interface function, see @ref AliHLTComponent for description */
+ // void GetOCDBObjectDescription( TMap* const targetMap);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+ protected:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Protected functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  // AliHLTComponent interface functions
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoInit( Int_t /*argc*/, const Char_t** /*argv*/ );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoDeinit();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  int DoEvent( const AliHLTComponentEventData& evtData,
+              const AliHLTComponentBlockData* blocks, 
+              AliHLTComponentTriggerData& trigData,
+              AliHLTUInt8_t* outputPtr, 
+              AliHLTUInt32_t& size,
+              AliHLTComponentBlockDataList& outputBlocks);
+
+  using AliHLTProcessor::DoEvent;
+
+
+  /**
+   * Configure the component.
+   * Parse a string for the configuration arguments and set the component
+   * properties.
+   */
+  int Configure(const char* arguments);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t Reconfigure(const Char_t* cdbEntry, const Char_t* chainId);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t ReadPreprocessorValues(const Char_t* modules);
+  ///////////////////////////////////////////////////////////////////////////////////
+  
+private:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Private functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** copy constructor prohibited */
+  AliHLTGlobalEsdToFlatConverterComponent(const AliHLTGlobalEsdToFlatConverterComponent&);
+
+  /** assignment operator prohibited */
+  AliHLTGlobalEsdToFlatConverterComponent& operator=(const AliHLTGlobalEsdToFlatConverterComponent&);
+
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                              Helper
+   * ---------------------------------------------------------------------------------
+   */
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Members - private
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** UID for merging */
+
+  ClassDef(AliHLTGlobalEsdToFlatConverterComponent, 0)
+};
+#endif
diff --git a/HLT/global/AliHLTGlobalFlatEsdConverterComponent.cxx b/HLT/global/AliHLTGlobalFlatEsdConverterComponent.cxx
new file mode 100644 (file)
index 0000000..73157dd
--- /dev/null
@@ -0,0 +1,664 @@
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  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   AliHLTGlobalFlatEsdConverterComponent.cxx
+//  @author Matthias Richter
+//  @date   
+//  @brief  Global ESD converter component.
+// 
+
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include <cassert>
+#include "AliHLTGlobalFlatEsdConverterComponent.h"
+#include "AliFlatESDEvent.h"
+#include "AliFlatESDTrigger.h"
+#include "AliFlatESDVertex.h"
+#include "AliFlatESDV0.h"
+#include "AliFlatESDTrack.h"
+#include "AliFlatExternalTrackParam.h"
+#include "AliExternalTrackParam.h"
+
+#include "AliHLTGlobalBarrelTrack.h"
+#include "AliHLTExternalTrackParam.h"
+#include "AliHLTTrackMCLabel.h"
+#include "AliHLTCTPData.h"
+#include "AliHLTErrorGuard.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliESDMuonTrack.h"
+#include "AliESDMuonCluster.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliPID.h"
+#include "TTree.h"
+#include "TList.h"
+#include "TClonesArray.h"
+//#include "AliHLTESDCaloClusterMaker.h"
+//#include "AliHLTCaloClusterDataStruct.h"
+//#include "AliHLTCaloClusterReader.h"
+//#include "AliESDCaloCluster.h"
+//#include "AliESDVZERO.h"
+#include "AliHLTGlobalVertexerComponent.h"
+#include "AliHLTVertexFinderBase.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCClusterMCData.h"
+#include "AliHLTTPCTransform.h"
+#include "AliSysInfo.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTGlobalFlatEsdConverterComponent)
+
+AliHLTGlobalFlatEsdConverterComponent::AliHLTGlobalFlatEsdConverterComponent()
+  : AliHLTProcessor()
+  , fWriteClusters(0)
+  , fVerbosity(0)  
+  , fSolenoidBz(-5.00668)
+  , fBenchmark("FlatEsdConverter")
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTGlobalFlatEsdConverterComponent::~AliHLTGlobalFlatEsdConverterComponent()
+{
+  // see header file for class documentation
+}
+
+int AliHLTGlobalFlatEsdConverterComponent::Configure(const char* arguments)
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!arguments) return iResult;
+
+  TString allArgs=arguments;
+  TString argument;
+  int bMissingParam=0;
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;      
+      HLTError("unknown argument %s", argument.Data());
+      iResult=-EINVAL;
+      break;
+    }  
+    delete pTokens;
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+  return iResult;
+}
+
+int AliHLTGlobalFlatEsdConverterComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // see header file for class documentation
+  int iResult=0;
+  const char* path=NULL;
+  const char* defaultNotify="";
+  if (cdbEntry) {
+    path=cdbEntry;
+    defaultNotify=" (default)";
+  }
+  if (path) {
+    HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+    if (pEntry) {
+      TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+      if (pString) {
+       HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
+       iResult=Configure(pString->String().Data());
+      } else {
+       HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+      }
+    } else {
+      HLTError("can not fetch object \"%s\" from CDB", path);
+    }
+  }
+  
+  return iResult;
+}
+
+void AliHLTGlobalFlatEsdConverterComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
+{
+  // see header file for class documentation
+  list.push_back(kAliHLTDataTypeTrack);
+  list.push_back(kAliHLTDataTypeTrackMC);
+  list.push_back(kAliHLTDataTypeCaloCluster);
+  list.push_back(kAliHLTDataTypedEdx );
+  list.push_back(kAliHLTDataTypeESDVertex );
+  list.push_back(kAliHLTDataTypeESDObject);
+  list.push_back(kAliHLTDataTypeTObject);
+  list.push_back(kAliHLTDataTypeGlobalVertexer);
+  list.push_back(kAliHLTDataTypeV0Finder); // array of track ids for V0s
+  list.push_back(kAliHLTDataTypeKFVertex); // KFVertex object from vertexer
+  list.push_back(kAliHLTDataTypePrimaryFinder); // array of track ids for prim vertex
+  list.push_back(kAliHLTDataTypeESDContent);
+  list.push_back(AliHLTTPCDefinitions::fgkClustersDataType| kAliHLTDataOriginTPC);
+  list.push_back(AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo| kAliHLTDataOriginTPC);
+}
+
+AliHLTComponentDataType AliHLTGlobalFlatEsdConverterComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+}
+
+void AliHLTGlobalFlatEsdConverterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+  // see header file for class documentation
+  constBase=2000000;
+  inputMultiplier=10.0;
+}
+
+int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
+{
+  // see header file for class documentation
+  int iResult=0;
+  TString argument="";
+  int bMissingParam=0;
+
+  // default list of skiped ESD objects
+  TString skipObjects=
+    // "AliESDRun,"
+    // "AliESDHeader,"
+    // "AliESDZDC,"
+    "AliESDFMD,"
+    // "AliESDVZERO,"
+    // "AliESDTZERO,"
+    // "TPCVertex,"
+    // "SPDVertex,"
+    // "PrimaryVertex,"
+    // "AliMultiplicity,"
+    // "PHOSTrigger,"
+    // "EMCALTrigger,"
+    // "SPDPileupVertices,"
+    // "TrkPileupVertices,"
+    "Cascades,"
+    "Kinks,"
+    "AliRawDataErrorLogs,"
+    "AliESDACORDE";
+
+  iResult=Reconfigure(NULL, NULL);
+  TString allArgs = "";
+  for ( int i = 0; i < argc; i++ ) {
+    if ( !allArgs.IsNull() ) allArgs += " ";
+    allArgs += argv[i];
+  }
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;
+
+      // -noclusters
+      if (argument.CompareTo("-noclusters")==0) {
+       fWriteClusters=0;       
+       // -clusters
+      } else if (argument.CompareTo("-clusters")==0) {
+       fWriteClusters=1;
+      } else if (argument.Contains("-skipobject=")) {
+       argument.ReplaceAll("-skipobject=", "");
+       skipObjects=argument;
+      } else {
+       HLTError("unknown argument %s", argument.Data());
+       iResult=-EINVAL;
+       break;
+      }
+    }
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+  fSolenoidBz=GetBz();
+
+  if (iResult>=0) {
+    SetupCTPData();
+  }
+
+  fBenchmark.SetTimer(0,"total");
+
+  return iResult;
+}
+
+int AliHLTGlobalFlatEsdConverterComponent::DoDeinit()
+{
+  // see header file for class documentation
+
+  return 0;
+}
+
+int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
+                                                   const AliHLTComponentBlockData* /*blocks*/, 
+                                                   AliHLTComponentTriggerData& trigData,
+                                                   AliHLTUInt8_t* outputPtr, 
+                                                   AliHLTUInt32_t& size,
+                                                   AliHLTComponentBlockDataList& outputBlocks )
+{
+  // see header file for class documentation
+
+  AliSysInfo::AddStamp("AliHLTGlobalFlatEsdConverterComponent::DoEvent.Start");
+       
+       
+  int iResult=0;
+       bool benchmark = true;
+
+  if (!IsDataEvent()) return iResult;
+
+  fBenchmark.StartNewEvent();
+  fBenchmark.Start(0);
+
+  size_t maxOutputSize = size;
+  size = 0;
+
+  // Read part of the input  data to local arrays
+  
+  // 1) first, read MC information if present
+
+  std::map<int,int> mcLabelsTPC;
+  std::map<int,int> mcLabelsITS;
+
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginTPC);
+       pBlock!=NULL; pBlock=GetNextInputBlock()) {
+    fBenchmark.AddInput(pBlock->fSize);
+    AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
+    if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
+      for( unsigned int il=0; il<dataPtr->fCount; il++ ){
+       AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
+       mcLabelsTPC[lab.fTrackID] = lab.fMCLabel;
+      }
+    } else {
+      HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", 
+                DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, 
+                dataPtr->fCount, pBlock->fSize);
+    }
+  }
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrackMC|kAliHLTDataOriginITS);
+       pBlock!=NULL; pBlock=GetNextInputBlock()) {
+    fBenchmark.AddInput(pBlock->fSize);
+    AliHLTTrackMCData* dataPtr = reinterpret_cast<AliHLTTrackMCData*>( pBlock->fPtr );
+    if (sizeof(AliHLTTrackMCData)+dataPtr->fCount*sizeof(AliHLTTrackMCLabel)==pBlock->fSize) {
+      for( unsigned int il=0; il<dataPtr->fCount; il++ ){
+       AliHLTTrackMCLabel &lab = dataPtr->fLabels[il];
+       mcLabelsITS[lab.fTrackID] = lab.fMCLabel;
+      }
+    } else {
+      HLTWarning("data mismatch in block %s (0x%08x): count %d, size %d -> ignoring track MC information", 
+                DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, 
+                dataPtr->fCount, pBlock->fSize);
+    }
+  }
+
+  // 2) read dEdx information (if present)
+
+  AliHLTFloat32_t *dEdxTPC = 0; 
+  Int_t ndEdxTPC = 0;
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypedEdx|kAliHLTDataOriginTPC);
+       pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
+    fBenchmark.AddInput(pBlock->fSize);
+    dEdxTPC = reinterpret_cast<AliHLTFloat32_t*>( pBlock->fPtr );
+    ndEdxTPC = pBlock->fSize / (3*sizeof(AliHLTFloat32_t));
+  }
+
+  // 3) read  TPC tracks, ITS refitted tracks, ITS OUT tracks
+
+  vector<AliHLTGlobalBarrelTrack> tracksTPC;
+  vector<AliHLTGlobalBarrelTrack> tracksITS;
+  vector<AliHLTGlobalBarrelTrack> tracksITSOut;
+
+  if( iResult>=0 ){
+
+    const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
+    if( pBlock ){
+      fBenchmark.AddInput(pBlock->fSize);
+      iResult = AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksTPC);
+    }  
+    if( iResult>=0 ) { 
+      pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
+      if( pBlock ){
+       fBenchmark.AddInput(pBlock->fSize);
+       iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITS);
+      }
+    }
+
+    if( iResult>=0 ) { 
+      pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITSOut);
+      if( pBlock ){
+       fBenchmark.AddInput(pBlock->fSize);
+       iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracksITSOut);
+      }
+    }
+  
+    if( iResult<0 ){
+      HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", 
+              DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);  
+    }
+  }
+
+  HLTWarning("converted %d TPC %d ITS %d ITSout track(s) to GlobalBarrelTrack", tracksTPC.size(), tracksITS.size(), tracksITSOut.size() );
+
+  // ---------------------------------------------
+  //
+  // Start to fill the flat ESD structure
+  //
+
+  Int_t err = 0;
+  AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr); 
+
+  do{ // single loop for easy break in case of output buffer overflow
+
+    err = ( maxOutputSize < sizeof( AliFlatESDEvent ) );    
+    if( err ) break;
+
+    new (flatEsd) AliFlatESDEvent;    
+    size_t freeSpace = maxOutputSize - flatEsd->GetSize();
+  
+    // fill run info
+    {
+      flatEsd->SetMagneticField( fSolenoidBz );
+      flatEsd->SetPeriodNumber( GetPeriodNumber() );
+      flatEsd->SetRunNumber( GetRunNo() );
+      flatEsd->SetOrbitNumber( GetOrbitNumber() );
+      flatEsd->SetBunchCrossNumber( GetBunchCrossNumber() );
+      flatEsd->SetTimeStamp( GetTimeStamp() );
+      //flatEsd->SetEventSpecie( GetEventSpecie() ); !!SG!! to do
+    }
+
+    // Fill trigger information  
+    {
+      const AliHLTCTPData* pCTPData=CTPData();
+      if (pCTPData) {
+       size_t triggerSize = 0;
+       int nTriggers = 0;
+       AliFlatESDTrigger *trigger = flatEsd->SetTriggersStart();
+       AliHLTTriggerMask_t mask = pCTPData->ActiveTriggers(trigData);
+       for (int index=0; index<gkNCTPTriggerClasses; index++) {
+         if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
+         const char* name = pCTPData->Name(index);
+         if( name && name[0]!='\0' ){
+           err = trigger->SetTriggerClass( name, index, freeSpace );
+           if( err != 0 ) break;
+           nTriggers++;
+           freeSpace -= trigger->GetSize();
+           triggerSize += trigger->GetSize();
+           trigger = trigger->GetNextTriggerNonConst();
+         }
+       }    
+       flatEsd->SetTriggersEnd( nTriggers, triggerSize );
+       //first 50 triggers
+       AliHLTTriggerMask_t mask50;
+       mask50.set(); // set all bits
+       mask50 >>= 50; // shift 50 right
+       flatEsd->SetTriggerMask((mask&mask50).to_ulong());
+       //next 50
+       flatEsd->SetTriggerMaskNext50((mask>>50).to_ulong());
+      }
+    }
+    if( err ) break;
+    
+    const AliESDVertex *primaryVertex = 0;
+
+    { // fill primary vertex Tracks
+
+      const AliESDVertex *primaryVertexTracks = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut ) );               
+      primaryVertex = primaryVertexTracks;
+      err = flatEsd->SetPrimaryVertexTracks( primaryVertexTracks, freeSpace );
+      freeSpace = maxOutputSize - flatEsd->GetSize();
+    }
+
+    if( err ) break;
+
+    { // fill primary vertex SPD
+    
+      const AliESDVertex *primaryVertexSPD = dynamic_cast<const AliESDVertex*>( GetFirstInputObject( kAliHLTDataTypeESDVertex|kAliHLTDataOriginITS ) );
+      if( !primaryVertex ) primaryVertex = primaryVertexSPD;  
+      err = flatEsd->SetPrimaryVertexSPD( primaryVertexSPD, freeSpace );
+      freeSpace = maxOutputSize - flatEsd->GetSize();     
+    }  
+    
+    if( err ) break;
+
+
+    { // Fill track information to the flat ESD structure
+     
+      size_t trackSize = 0;
+      int nTracks = 0;
+      Long64_t *table = NULL;
+      AliFlatESDTrack *flatTrack = NULL;
+      err = flatEsd->SetTracksStart( flatTrack, table, tracksTPC.size(), freeSpace );
+      freeSpace = maxOutputSize - flatEsd->GetSize();
+    
+      if( err ) break;
+
+      for( UInt_t tpcIter=0, itsIter = 0, itsOutIter = 0; tpcIter < tracksTPC.size(); tpcIter++) {       
+       
+       // TPC track parameters
+       
+       AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
+       Float_t tpcPoints[4];
+       Float_t tpcDeDx[3]={0,0,0};
+       Int_t tpcLabel = -1;
+       AliHLTGlobalBarrelTrack tpcOutTrack(*tpcTrack);
+       
+       if (fVerbosity>0) tpcTrack->Print();  
+       
+       {       
+         tpcPoints[0] = static_cast<Float_t>(tpcTrack->GetX());
+         tpcPoints[1] = static_cast<Float_t>(tpcTrack->GetY());
+         tpcPoints[2] = static_cast<Float_t>(tpcTrack->GetLastPointX());
+         tpcPoints[3] = static_cast<Float_t>(tpcTrack->GetLastPointY());
+       
+         if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() ) tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
+         
+         tpcTrack->SetLabel( tpcLabel );
+       
+         { // TPC out - just propagate to the outermost TPC cluster
+           //tpcOutTrack.AliExternalTrackParam::PropagateTo( tpcTrack->GetLastPointX(), fSolenoidBz );
+           const Int_t N=10; // number of steps.
+           const Float_t xRange = tpcTrack->GetLastPointX() - tpcTrack->GetX();
+           const Float_t xStep = xRange / N ;
+           for(int i = 1; i <= N; ++i) {
+             if(!tpcOutTrack.AliExternalTrackParam::PropagateTo(tpcTrack->GetX() + xStep * i, fSolenoidBz)) break;
+           }
+           tpcOutTrack.SetLabel(tpcTrack->GetLabel());
+         }
+         
+         if( tpcTrack->TrackID()<ndEdxTPC ){
+           AliHLTFloat32_t *val = &(dEdxTPC[3*tpcTrack->TrackID()]);
+           tpcDeDx[0] = val[0];
+           tpcDeDx[1] = val[1];
+           tpcDeDx[2] = val[2];
+           //AliTPCseed s;
+           //s.Set( tpcTrack->GetX(), tpcTrack->GetAlpha(),
+           //tpcTrack->GetParameter(), tpcTrack->GetCovariance() );
+           //s.SetdEdx( val[0] );
+           //s.CookPID();
+           //iotrack.SetTPCpid(s.TPCrPIDs() );
+         } else {
+           if( dEdxTPC ) HLTWarning("Wrong number of dEdx TPC labels");
+         }
+       }
+
+       // ITS track parameters
+       
+       AliHLTGlobalBarrelTrack *itsRefit=0;
+       AliHLTGlobalBarrelTrack *itsOut=0;
+       Int_t itsLabel = tpcLabel;
+       
+       {
+         // ITS Refit & mc label
+         
+         for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
+         
+         if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
+           itsRefit = &(tracksITS[itsIter]);
+           if( mcLabelsITS.find(tpcIter)!=mcLabelsITS.end() ) itsLabel = mcLabelsITS[tpcIter];
+           itsIter++;
+         }
+         
+         // ITS Out track
+         
+         for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
+         
+         if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
+           itsOut = &(tracksITSOut[itsOutIter]);
+           itsOutIter++;
+         }     
+       
+         if( itsRefit ) itsRefit->SetLabel( itsLabel );
+         if( itsOut ) itsOut->SetLabel( itsLabel );
+       }
+      
+       // vertex-constrained parameters for TPC tracks 
+
+       const AliExternalTrackParam *tpcConstrained=0;
+       
+       AliESDtrack esdTrack;
+       esdTrack.SetID( tpcTrack->TrackID() );
+       esdTrack.UpdateTrackParams(&tpcOutTrack,AliESDtrack::kTPCout);
+       esdTrack.UpdateTrackParams(&(*tpcTrack),AliESDtrack::kTPCin);
+       esdTrack.UpdateTrackParams(&(*tpcTrack),AliESDtrack::kTPCrefit);
+       esdTrack.SetTPCPoints(tpcPoints);
+       esdTrack.SetTPCsignal( tpcDeDx[0], tpcDeDx[1], (UChar_t) tpcDeDx[2] );
+       if( itsOut ) esdTrack.UpdateTrackParams( itsOut, AliESDtrack::kITSout );
+       if( itsRefit ) esdTrack.UpdateTrackParams( itsRefit, AliESDtrack::kITSin );
+       esdTrack.SetLabel(tpcLabel);
+      
+       if( primaryVertex ){
+         //iotrack.UpdateTrackParams( (itsRefit ?itsRefit :tpcTrack), AliESDtrack::kTPCin );
+         esdTrack.RelateToVertex( primaryVertex, fSolenoidBz, 1000 );          
+         tpcConstrained = esdTrack.GetConstrainedParam();
+       }       
+
+       UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
+       UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
+
+       // fill flat track
+
+       table[tpcIter] = trackSize;
+       err = ( freeSpace < flatTrack->EstimateSize() );
+       if( err ) break;
+       
+       new (flatTrack) AliFlatESDTrack;       
+       
+       flatTrack->SetExternalTrackParam( itsRefit, itsRefit, tpcTrack, &tpcOutTrack, tpcConstrained, itsOut );
+       flatTrack->SetNumberOfTPCClusters( nClustersTPC );
+       flatTrack->SetNumberOfITSClusters( nClustersITS );
+       trackSize += flatTrack->GetSize();
+       freeSpace -= flatTrack->GetSize();
+       nTracks++;
+       flatTrack = flatTrack->GetNextTrackNonConst();    
+      }
+      flatEsd->SetTracksEnd( nTracks, trackSize );
+    }       
+
+    if( err ) break;
+
+    // Fill v0's
+  
+    {    
+      size_t v0size = 0;
+      int nV0s = 0; 
+      AliFlatESDV0 *flatV0 = flatEsd->SetV0sStart();
+
+      const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
+      if ( pBlock && pBlock->fSize && pBlock->fPtr) {
+       fBenchmark.AddInput(pBlock->fSize);
+       const AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerData*>(pBlock->fPtr);
+       const int* v0s = data->fTrackIndices + data->fNPrimTracks;
+       for (int i = 0; i < data->fNV0s; ++i) {
+         if(  freeSpace < flatV0->GetSize() ) { err = -1; break; }
+         new (flatV0) AliFlatESDV0;
+         flatV0->SetNegTrackID( v0s[2 * i] );
+         flatV0->SetPosTrackID( v0s[2 * i + 1] );
+         nV0s++;
+         v0size += flatV0->GetSize();
+         freeSpace -= flatV0->GetSize(); 
+         flatV0 = flatV0->GetNextV0NonConst();   
+       }
+      } else {
+       HLTWarning("xxx No V0 data block");
+      }
+
+      flatEsd->SetV0sEnd( nV0s, v0size );
+      cout<<"\nxxxx Found "<<nV0s<<" V0's\n"<<endl;
+    }
+    
+    if( err ) break;
+
+  }while(0);
+  
+  if( err ){
+    HLTWarning( "Output buffer size %d exceeded, flat ESD event is not stored", maxOutputSize );
+    return -ENOSPC;
+  } 
+
+  { // set up the output block description
+    
+    AliHLTComponentBlockData outBlock;
+    FillBlockData( outBlock );
+    outBlock.fOffset = size;
+    outBlock.fSize = flatEsd->GetSize();
+    outBlock.fDataType = kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+    outBlock.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( 0, 35, 0, 5 );
+
+    outputBlocks.push_back( outBlock );
+
+    fBenchmark.AddOutput(outBlock.fSize);      
+
+    size += outBlock.fSize;
+  }
+      if(benchmark){
+       
+       
+       Double_t statistics[10]; 
+       TString names[10];
+       fBenchmark.GetStatisticsData(statistics, names);
+         fBenchmark.Reset();
+  
+       AliSysInfo::AddStamp("AliHLTGlobalFlatEsdConverterComponent::DoEvent.Stop", (int)(statistics[1]), (int)(statistics[2]),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks() );
+  }
+  
+  
+  
+  fBenchmark.Stop(0);
+  HLTWarning( fBenchmark.GetStatistics() );
+
+  return 0;
+}
+
diff --git a/HLT/global/AliHLTGlobalFlatEsdConverterComponent.h b/HLT/global/AliHLTGlobalFlatEsdConverterComponent.h
new file mode 100644 (file)
index 0000000..474e550
--- /dev/null
@@ -0,0 +1,102 @@
+//-*- Mode: C++ -*-
+// $Id$
+#ifndef ALIHLTGLOBALFLATESDCONVERTERCOMPONENT_H
+#define ALIHLTGLOBALFLATESDCONVERTERCOMPONENT_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   AliHLTGlobalFlatEsdConverterComponent.h
+//  @author Matthias Richter
+//  @date   
+//  @brief  Global ESD converter component.
+//  @note
+
+#include "AliHLTProcessor.h"
+#include "AliHLTComponentBenchmark.h"
+#include <vector>
+
+
+/**
+ * @class AliHLTGlobalFlatEsdConverterComponent
+ * Global collector for information designated for the HLT ESD.
+ *
+ * componentid: \b GlobalEsdConverter <br>
+ * componentlibrary: \b libAliHLTGlobal.so <br>
+ * Arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -notree                                                          <br>
+ *      write ESD directly to output (::kAliHLTDataTypeESDObject)
+ *      this has been made the default behavior in Sep 2008.
+ * \li -tree                                                            <br>
+ *      write ESD directly to TTree and to output (::kAliHLTDataTypeESDTree)
+ * \li -skipobject=name1,name2,...                                   <br>
+ *      comma separated list of ESD object names to be skipped, default is
+ *      AliESDZDC,AliESDFMD,Cascades,Kinks,AliRawDataErrorLogs,AliESDACORDE
+ *      leave blank to disable the option
+ *
+ * @ingroup alihlt_tpc_components
+ */
+class AliHLTGlobalFlatEsdConverterComponent : public AliHLTProcessor
+{
+ public:
+  /** standard constructor */
+  AliHLTGlobalFlatEsdConverterComponent();
+  /** destructor */
+  virtual ~AliHLTGlobalFlatEsdConverterComponent();
+
+  // interface methods of base class
+  const char* GetComponentID() {return "GlobalFlatEsdConverter";};
+  void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+  AliHLTComponentDataType GetOutputDataType();
+  void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
+  AliHLTComponent* Spawn() {return new AliHLTGlobalFlatEsdConverterComponent;}
+
+ protected:
+  // interface methods of base class
+  int DoInit(int argc, const char** argv);
+  int DoDeinit();
+  int DoEvent( const AliHLTComponentEventData& evtData,
+              const AliHLTComponentBlockData* blocks, 
+              AliHLTComponentTriggerData& trigData,
+              AliHLTUInt8_t* outputPtr, 
+              AliHLTUInt32_t& size,
+              AliHLTComponentBlockDataList& outputBlocks );
+
+  using AliHLTProcessor::DoEvent;
+
+
+ private:
+  /** copy constructor prohibited */
+  AliHLTGlobalFlatEsdConverterComponent(const AliHLTGlobalFlatEsdConverterComponent&);
+  /** assignment operator prohibited */
+  AliHLTGlobalFlatEsdConverterComponent& operator=(const AliHLTGlobalFlatEsdConverterComponent&);
+
+  /**
+   * (Re)Configure from the CDB
+   * Loads the following objects:
+   * - HLT/ConfigHLT/SolenoidBz
+   */
+  int Reconfigure(const char* cdbEntry, const char* chainId);
+
+  /**
+   * Configure the component.
+   * Parse a string for the configuration arguments and set the component
+   * properties.
+   */
+  int Configure(const char* arguments);
+
+  int fWriteClusters; //!transient
+
+  /// verbosity level
+  int fVerbosity; //!transient
+
+protected:
+
+  /// solenoid b field
+  Double_t fSolenoidBz; //! transient
+  AliHLTComponentBenchmark fBenchmark; // benchmark
+
+  ClassDef(AliHLTGlobalFlatEsdConverterComponent, 0)
+};
+#endif
diff --git a/HLT/global/AliHLTGlobalFlatEsdTestComponent.cxx b/HLT/global/AliHLTGlobalFlatEsdTestComponent.cxx
new file mode 100644 (file)
index 0000000..981f7d5
--- /dev/null
@@ -0,0 +1,301 @@
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  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   AliHLTGlobalFlatEsdTestComponent.cxx
+//  @author Matthias Richter
+//  @date   
+//  @brief  Global ESD converter component.
+// 
+
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include <cassert>
+#include "AliHLTGlobalFlatEsdTestComponent.h"
+#include "AliFlatESDEvent.h"
+#include "AliFlatESDTrack.h"
+#include "AliFlatExternalTrackParam.h"
+#include "AliExternalTrackParam.h"
+
+#include "AliHLTGlobalBarrelTrack.h"
+#include "AliHLTExternalTrackParam.h"
+#include "AliHLTTrackMCLabel.h"
+#include "AliHLTCTPData.h"
+#include "AliHLTErrorGuard.h"
+#include "AliESDEvent.h"
+#include "AliESDfriend.h"
+#include "AliESDtrack.h"
+#include "AliESDMuonTrack.h"
+#include "AliESDMuonCluster.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliPID.h"
+#include "TTree.h"
+#include "TList.h"
+#include "TClonesArray.h"
+//#include "AliHLTESDCaloClusterMaker.h"
+//#include "AliHLTCaloClusterDataStruct.h"
+//#include "AliHLTCaloClusterReader.h"
+//#include "AliESDCaloCluster.h"
+//#include "AliESDVZERO.h"
+#include "AliHLTGlobalVertexerComponent.h"
+#include "AliHLTVertexFinderBase.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCClusterMCData.h"
+#include "AliHLTTPCTransform.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTGlobalFlatEsdTestComponent)
+
+AliHLTGlobalFlatEsdTestComponent::AliHLTGlobalFlatEsdTestComponent()
+  : AliHLTProcessor()
+  , fWriteClusters(0)
+  , fVerbosity(0)  
+  , fSolenoidBz(-5.00668)
+  , fBenchmark("FlatEsdTest")
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTGlobalFlatEsdTestComponent::~AliHLTGlobalFlatEsdTestComponent()
+{
+  // see header file for class documentation
+}
+
+int AliHLTGlobalFlatEsdTestComponent::Configure(const char* arguments)
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!arguments) return iResult;
+
+  TString allArgs=arguments;
+  TString argument;
+  int bMissingParam=0;
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;      
+      HLTError("unknown argument %s", argument.Data());
+      iResult=-EINVAL;
+      break;
+    }  
+    delete pTokens;
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+  return iResult;
+}
+
+int AliHLTGlobalFlatEsdTestComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // see header file for class documentation
+  int iResult=0;
+  const char* path=NULL;
+  const char* defaultNotify="";
+  if (cdbEntry) {
+    path=cdbEntry;
+    defaultNotify=" (default)";
+  }
+  if (path) {
+    HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+    if (pEntry) {
+      TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+      if (pString) {
+       HLTInfo("received configuration object string: \'%s\'", pString->String().Data());
+       iResult=Configure(pString->String().Data());
+      } else {
+       HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+      }
+    } else {
+      HLTError("can not fetch object \"%s\" from CDB", path);
+    }
+  }
+  
+  return iResult;
+}
+
+void AliHLTGlobalFlatEsdTestComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
+{
+  // see header file for class documentation
+  list.push_back(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
+  list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
+  list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut);
+}
+
+AliHLTComponentDataType AliHLTGlobalFlatEsdTestComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+}
+
+void AliHLTGlobalFlatEsdTestComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
+{
+  // see header file for class documentation
+  constBase=2000000;
+  inputMultiplier=10.0;
+}
+
+int AliHLTGlobalFlatEsdTestComponent::DoInit(int argc, const char** argv)
+{
+  // see header file for class documentation
+  int iResult=0;
+  TString argument="";
+  int bMissingParam=0;
+
+  // default list of skiped ESD objects
+  TString skipObjects=
+    // "AliESDRun,"
+    // "AliESDHeader,"
+    // "AliESDZDC,"
+    "AliESDFMD,"
+    // "AliESDVZERO,"
+    // "AliESDTZERO,"
+    // "TPCVertex,"
+    // "SPDVertex,"
+    // "PrimaryVertex,"
+    // "AliMultiplicity,"
+    // "PHOSTrigger,"
+    // "EMCALTrigger,"
+    // "SPDPileupVertices,"
+    // "TrkPileupVertices,"
+    "Cascades,"
+    "Kinks,"
+    "AliRawDataErrorLogs,"
+    "AliESDACORDE";
+
+  iResult=Reconfigure(NULL, NULL);
+  TString allArgs = "";
+  for ( int i = 0; i < argc; i++ ) {
+    if ( !allArgs.IsNull() ) allArgs += " ";
+    allArgs += argv[i];
+  }
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->String();        
+      if (argument.IsNull()) continue;
+
+      // -noclusters
+      if (argument.CompareTo("-noclusters")==0) {
+       fWriteClusters=0;       
+       // -clusters
+      } else if (argument.CompareTo("-clusters")==0) {
+       fWriteClusters=1;
+      } else if (argument.Contains("-skipobject=")) {
+       argument.ReplaceAll("-skipobject=", "");
+       skipObjects=argument;
+      } else {
+       HLTError("unknown argument %s", argument.Data());
+       iResult=-EINVAL;
+       break;
+      }
+    }
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+
+  fSolenoidBz=GetBz();
+
+  if (iResult>=0) {
+    SetupCTPData();
+  }
+
+  fBenchmark.SetTimer(0,"total");
+
+  return iResult;
+}
+
+int AliHLTGlobalFlatEsdTestComponent::DoDeinit()
+{
+  // see header file for class documentation
+
+  return 0;
+}
+
+int AliHLTGlobalFlatEsdTestComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
+                                                   const AliHLTComponentBlockData* /*blocks*/, 
+                                                   AliHLTComponentTriggerData& /*trigData*/,
+                                                   AliHLTUInt8_t* /*outputPtr*/, 
+                                                   AliHLTUInt32_t& size,
+                                                   AliHLTComponentBlockDataList& /*outputBlocks*/ )
+{
+  // see header file for class documentation
+  int iResult=0;
+
+  if (!IsDataEvent()) return iResult;
+
+  fBenchmark.StartNewEvent();
+  fBenchmark.Start(0);
+
+  size = 0;
+
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
+    //fBenchmark.AddInput(pBlock->fSize);
+    cout<<"Found ESD in esd test component !!!"<<endl;
+    AliESDEvent *esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));//dynamic_cast<const AliESDEvent*>(iter);
+    if( esd ){
+      esd->GetStdContent();
+      cout<<"N ESD tracks: "<<esd->GetNumberOfTracks()<<endl;
+    } else {
+      cout<<"ESD pointer is NULL "<<endl;
+    }
+  }
+
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {     
+    //fBenchmark.AddInput(pBlock->fSize);
+    cout<<"Found ESD friend in esd test component !!!"<<endl;
+    const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
+    if( esdFriend ){
+      cout<<"N friend tracks: "<<esdFriend->GetNumberOfTracks()<<endl;
+    } else {
+      cout<<"ESD friend pointer is NULL "<<endl;
+    }
+  }
+
+  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
+       pBlock!=NULL; pBlock=NULL/*GetNextInputBlock() there is only one block*/) {
+    fBenchmark.AddInput(pBlock->fSize);
+    AliFlatESDEvent *flatEvent = reinterpret_cast<AliFlatESDEvent*>( pBlock->fPtr );
+    cout<<"N flat tracks: "<<flatEvent->GetNumberOfTracks()<<endl;
+  }
+
+  
+  fBenchmark.Stop(0);
+  HLTWarning( fBenchmark.GetStatistics() );
+
+  return iResult;
+}
+
diff --git a/HLT/global/AliHLTGlobalFlatEsdTestComponent.h b/HLT/global/AliHLTGlobalFlatEsdTestComponent.h
new file mode 100644 (file)
index 0000000..bbe65c3
--- /dev/null
@@ -0,0 +1,102 @@
+//-*- Mode: C++ -*-
+// $Id$
+#ifndef ALIHLTGLOBALFLATESDTESTCOMPONENT_H
+#define ALIHLTGLOBALFLATESDTESTCOMPONENT_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   AliHLTGlobalFlatEsdTestComponent.h
+//  @author Matthias Richter
+//  @date   
+//  @brief  Global ESD converter component.
+//  @note
+
+#include "AliHLTProcessor.h"
+#include "AliHLTComponentBenchmark.h"
+#include <vector>
+
+
+/**
+ * @class AliHLTGlobalFlatEsdTestComponent
+ * Global collector for information designated for the HLT ESD.
+ *
+ * componentid: \b GlobalEsdConverter <br>
+ * componentlibrary: \b libAliHLTGlobal.so <br>
+ * Arguments: <br>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -notree                                                          <br>
+ *      write ESD directly to output (::kAliHLTDataTypeESDObject)
+ *      this has been made the default behavior in Sep 2008.
+ * \li -tree                                                            <br>
+ *      write ESD directly to TTree and to output (::kAliHLTDataTypeESDTree)
+ * \li -skipobject=name1,name2,...                                   <br>
+ *      comma separated list of ESD object names to be skipped, default is
+ *      AliESDZDC,AliESDFMD,Cascades,Kinks,AliRawDataErrorLogs,AliESDACORDE
+ *      leave blank to disable the option
+ *
+ * @ingroup alihlt_tpc_components
+ */
+class AliHLTGlobalFlatEsdTestComponent : public AliHLTProcessor
+{
+ public:
+  /** standard constructor */
+  AliHLTGlobalFlatEsdTestComponent();
+  /** destructor */
+  virtual ~AliHLTGlobalFlatEsdTestComponent();
+
+  // interface methods of base class
+  const char* GetComponentID() {return "GlobalFlatEsdTest";};
+  void GetInputDataTypes(AliHLTComponentDataTypeList& list);
+  AliHLTComponentDataType GetOutputDataType();
+  void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
+  AliHLTComponent* Spawn() {return new AliHLTGlobalFlatEsdTestComponent;}
+
+ protected:
+  // interface methods of base class
+  int DoInit(int argc, const char** argv);
+  int DoDeinit();
+  int DoEvent( const AliHLTComponentEventData& evtData,
+              const AliHLTComponentBlockData* blocks, 
+              AliHLTComponentTriggerData& trigData,
+              AliHLTUInt8_t* outputPtr, 
+              AliHLTUInt32_t& size,
+              AliHLTComponentBlockDataList& outputBlocks );
+
+  using AliHLTProcessor::DoEvent;
+
+
+ private:
+  /** copy constructor prohibited */
+  AliHLTGlobalFlatEsdTestComponent(const AliHLTGlobalFlatEsdTestComponent&);
+  /** assignment operator prohibited */
+  AliHLTGlobalFlatEsdTestComponent& operator=(const AliHLTGlobalFlatEsdTestComponent&);
+
+  /**
+   * (Re)Configure from the CDB
+   * Loads the following objects:
+   * - HLT/ConfigHLT/SolenoidBz
+   */
+  int Reconfigure(const char* cdbEntry, const char* chainId);
+
+  /**
+   * Configure the component.
+   * Parse a string for the configuration arguments and set the component
+   * properties.
+   */
+  int Configure(const char* arguments);
+
+  int fWriteClusters; //!transient
+
+  /// verbosity level
+  int fVerbosity; //!transient
+
+protected:
+
+  /// solenoid b field
+  Double_t fSolenoidBz; //! transient
+  AliHLTComponentBenchmark fBenchmark; // benchmark
+
+  ClassDef(AliHLTGlobalFlatEsdTestComponent, 0)
+};
+#endif
index bca2ded7c1bf83c81d40e796acd2d8bebfef4931..933e6c5f2ce534c6f8f35848524f49429669da8a 100644 (file)
@@ -148,7 +148,7 @@ int AliHLTGlobalTrackMergerComponent::DoEvent(const AliHLTComponentEventData& /*
   fESD->SetMagneticField(fSolenoidBz);
   //fESD->SetMagneticField(AliTracker::GetBz());
 
-  if ((iResult=ProcessBlocks(NULL, fESD))<0) return iResult;
+  if ((iResult=ProcessBlocks(NULL, fESD, NULL))<0) return iResult;
   if(!fESD->GetNumberOfTracks()>0) return iResult;
 
    // merge tracks
diff --git a/HLT/global/AliVVVZEROfriend.h b/HLT/global/AliVVVZEROfriend.h
new file mode 100644 (file)
index 0000000..fbc0cb3
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef ALIVVVZEROFRIEND_H
+#define ALIVVVZEROFRIEND_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+///////////////////////////////////////////////////////////////////////////////
+///
+/// This is a class with access methods for VZERO DDL raw data
+/// It is written to the ESD-friend file
+///
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+
+class AliVVVZEROfriend {
+  public :
+    AliVVVZEROfriend();
+    virtual ~AliVVVZEROfriend();
+
+    AliVVVZEROfriend(const AliVVVZEROfriend& vzerofriend);
+    AliVVVZEROfriend& operator = (const AliVVVZEROfriend& vzerofriend);
+
+    virtual void Reset();
+
+// Getters of various scalers and Minimum Bias flags :
+
+   virtual ULong64_t          GetBBScalers(Int_t channel) const  
+      { return        fBBScalers[channel]; }
+   virtual ULong64_t          GetBGScalers(Int_t channel) const  
+      { return        fBGScalers[channel]; }
+   virtual UInt_t             GetTriggerScalers(Int_t num_scaler) const 
+      { return        fScalers[num_scaler]; }
+   virtual UInt_t             GetBunchNumbersMB(Int_t num_bunch) const 
+      { return        fBunchNumbers[num_bunch]; }
+   virtual UShort_t           GetChargeMB(Int_t channel, Int_t num_bunch) const  
+      { return        fChargeMB[channel][num_bunch]; } 
+   virtual Bool_t             GetIntMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsIntMB[channel][num_bunch]; } 
+   virtual Bool_t             GetBBMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsBBMB[channel][num_bunch]; }  
+   virtual Bool_t             GetBGMBFlag(Int_t channel, Int_t num_bunch) const   
+      { return        fIsBGMB[channel][num_bunch]; }      
+       
+// Getters of ADC signals, ADC pedestals, time information and corresponding flags :
+
+    virtual Float_t           GetADC(Int_t channel) const
+      { return fADC[channel][kNEvOfInt/2]; }
+    virtual Float_t           GetPedestal(Int_t channel, Int_t event) const
+      { return fADC[channel][event]; }
+    virtual Bool_t            GetIntegratorFlag(Int_t channel, Int_t event) const
+      { return fIsInt[channel][event]; }
+    virtual Bool_t            GetBBFlag(Int_t channel, Int_t event) const
+      { return fIsBB[channel][event]; } 
+    virtual Bool_t            GetBGFlag(Int_t channel, Int_t event) const
+      { return fIsBG[channel][event]; }   
+    virtual Float_t            GetTime(Int_t channel) const
+      { return fTime[channel]; }
+    virtual Float_t            GetWidth(Int_t channel) const
+      { return fWidth[channel]; }
+
+    // Setters
+    virtual void              SetBBScalers(Int_t channel, ULong64_t scalers)
+      { fBBScalers[channel] = scalers; }
+    virtual void              SetBGScalers(Int_t channel, ULong64_t scalers)
+      { fBGScalers[channel] = scalers; }
+    virtual void              SetTriggerScalers(Int_t num_scaler, UInt_t scaler)
+      { fScalers[num_scaler] = scaler; }
+    virtual void              SetBunchNumbersMB(Int_t num_bunch, UInt_t bunch)
+      { fBunchNumbers[num_bunch] = bunch; }
+    virtual void              SetChargeMB(Int_t channel,Int_t num_bunch, UShort_t charge)
+      { fChargeMB[channel][num_bunch] = charge; }
+    virtual void              SetIntMBFlag(Int_t channel,Int_t num_bunch, Bool_t flag)
+      { fIsIntMB[channel][num_bunch] = flag; }
+    virtual void              SetBBMBFlag(Int_t channel,Int_t num_bunch, Bool_t flag)
+      { fIsBBMB[channel][num_bunch] = flag; }
+    virtual void              SetBGMBFlag(Int_t channel,Int_t num_bunch, Bool_t flag)
+      { fIsBGMB[channel][num_bunch] = flag; }
+
+    virtual void              SetPedestal(Int_t channel, Int_t event, Float_t adc)
+      { fADC[channel][event] = adc; }
+    virtual void              SetIntegratorFlag(Int_t channel, Int_t event, Bool_t flag)
+      { fIsInt[channel][event] = flag; }
+    virtual void              SetBBFlag(Int_t channel, Int_t event, Bool_t flag)
+      { fIsBB[channel][event] = flag; }
+    virtual void              SetBGFlag(Int_t channel, Int_t event, Bool_t flag)
+      { fIsBG[channel][event] = flag; }
+    virtual void              SetTime(Int_t channel, Float_t time)
+      { fTime[channel] = time; }
+    virtual void              SetWidth(Int_t channel, Float_t width)
+      { fWidth[channel] = width; }
+
+    virtual UShort_t          GetTriggerInputs() const
+      { return fTrigger; }
+    virtual UShort_t          GetTriggerInputsMask() const
+      { return fTriggerMask; }
+    virtual void              SetTriggerInputs(UShort_t inputs)
+      { fTrigger = inputs; }
+    virtual void              SetTriggerInputsMask(UShort_t mask)
+      { fTriggerMask = mask; }
+
+    enum EESDVZEROfriendParams {
+      kNChannels = 64, // number of electronic channels in V0 (FEE numbering)
+      kNEvOfInt  = 21, // number of events of interest
+      kNScalers  = 16, // number of scalers
+      kNBunches  = 10  // number of bunches used in Minimum Bias information 
+    };
+};
+
+#endif
diff --git a/HLT/global/CompareFlatESDs.C b/HLT/global/CompareFlatESDs.C
new file mode 100644 (file)
index 0000000..8d6e8a6
--- /dev/null
@@ -0,0 +1,315 @@
+/**
+ * >> Testing Macro to compare FlatESDEvents from output files <<
+ **
+ * Primary Authors : Steffen Weber
+ *
+ * Usage:
+ *  aliroot -b -l -q LoadLibs.C CompareFlatESDs.C++
+ *
+ **************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliESDfriend.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TSystem.h>
+#include "./AliFlatESDEvent.h"
+#include "./AliFlatESDTrack.h"
+#include "./AliFlatTPCCluster.h"
+#include "./AliFlatExternalTrackParam.h"
+#include "Riostream.h"
+#include "THnSparse.h"
+#endif   
+Double_t printDiff(string name, double val1, double val2);
+Double_t printDiff(string name, TString val1, TString val2);
+void CompareFlatESDs(const char* filename1="outFlatESD1.dat",const char* filename2="outFlatESD2.dat", Bool_t verbose=kFALSE) {
+  // Create output histograms
+  
+  
+  TString outputFilename = "$PWD/compare.root";
+  
+       cout<< "creating histograms"<<endl;
+       THnSparse * hDiff;
+       const   Int_t nDim = 12;
+       
+               Int_t bins[nDim] = {2};
+               Double_t mins[nDim] = {0};
+               Double_t maxs[nDim] = {1};
+               hDiff = new THnSparseD("Differences","Differences",nDim,bins,mins,maxs);
+       
+  
+
+  ifstream is1(filename1, std::ifstream::binary | std::ifstream::in);
+  ifstream is2(filename2, std::ifstream::binary | std::ifstream::in);
+  if (is1 && is2 ){
+    is1.seekg (0, is1.end);
+    int length1 = is1.tellg();
+    is1.seekg (0, is1.beg);
+    char * buffer1 = new char [length1];
+    
+    std::cout << "Reading " << length1 << " characters... ";
+    
+    is1.read (buffer1,length1);
+    if (is1)
+      std::cout << "all characters read successfully." << endl;
+    else
+      std::cout << "error: only " << is1.gcount() << " could be read";
+    is1.close();
+       
+       
+    is2.seekg (0, is2.end);
+    int length2 = is2.tellg();
+    is2.seekg (0, is2.beg);
+    char * buffer2 = new char [length2];
+    
+    std::cout << "Reading " << length2 << " characters... ";
+    
+    is2.read (buffer2,length2);
+    if (is2)
+      std::cout << "all characters read successfully." << endl;
+    else
+      std::cout << "error: only " << is2.gcount() << " could be read";
+    is2.close();
+    
+       
+       
+    // ...buffer contains the entire file...
+    
+    char *curr1 = buffer1;
+    char *endBuff1 = buffer1+length1;
+       
+    char *curr2 = buffer2;
+    char *endBuff2 = buffer2+length2;
+       
+    int iEvent = 0;
+       static const int nExt = 4;
+    
+       while( curr1 < endBuff1  && curr2 < endBuff2 ){
+//cout<<" curr1 endBuff1 curr2 endBuff2 "<< static_cast<void*> (curr1)<<" "<<static_cast<void*> (endBuff1)<<" "<<static_cast<void*> (curr2)<<" "<<static_cast<void*> (endBuff2)<<endl;
+
+      AliFlatESDEvent *flatEsd1 = reinterpret_cast<AliFlatESDEvent *>(curr1);
+      AliFlatESDEvent *flatEsd2 = reinterpret_cast<AliFlatESDEvent *>(curr2);
+         
+         flatEsd1->Reinitialize();
+         flatEsd2->Reinitialize();
+         
+      cout<<endl<<"________________________________________________________________________"<<endl;
+      cout<<endl<<"Reading event "<<iEvent<<":\t file1 | file 2\t|\t abs. diff\t|\t rel. diff"<<endl;
+               
+               Double_t diffs[nDim] ={
+                       printDiff("GetMagneticField",           flatEsd1->GetMagneticField(),           flatEsd2->GetMagneticField()),
+                       printDiff("GetPeriodNumber",            flatEsd1->GetPeriodNumber(),            flatEsd2->GetPeriodNumber()),
+                       printDiff("GetRunNumber",                               flatEsd1->GetRunNumber(),                               flatEsd2->GetRunNumber()),
+                       printDiff("GetOrbitNumber",                     flatEsd1->GetOrbitNumber(),                     flatEsd2->GetOrbitNumber()),
+                       printDiff("GetBunchCrossNumber",flatEsd1->GetBunchCrossNumber(),flatEsd2->GetBunchCrossNumber()),
+                       printDiff("GetTriggerMask",                     flatEsd1->GetTriggerMask(),                     flatEsd2->GetTriggerMask()),
+                       printDiff("GetTriggerMaskNext50",flatEsd1->GetTriggerMaskNext50(),                      flatEsd2->GetTriggerMaskNext50()),
+                       printDiff("GetFiredTriggerClasses",                     flatEsd1->GetFiredTriggerClasses(),                     flatEsd2->GetFiredTriggerClasses()),
+                       printDiff("GetNumberOfTracks",  flatEsd1->GetNumberOfTracks(),  flatEsd2->GetNumberOfTracks()),
+                       printDiff("GetNumberOfV0s",                     flatEsd1->GetNumberOfV0s(),                     flatEsd2->GetNumberOfV0s()),
+                       printDiff("GetTimeStamp",                       flatEsd1->GetTimeStamp(),                       flatEsd2->GetTimeStamp()),
+                       printDiff("GetEventSpecie",                     flatEsd1->GetEventSpecie(),                     flatEsd2->GetEventSpecie())
+       
+               };
+
+               hDiff->Fill(diffs);
+         
+         
+         /*
+         
+         if( (Bool_t) flatEsd1->GetFlatPrimaryVertexTracks() != (Bool_t) flatEsd2->GetFlatPrimaryVertexTracks()  ){
+               cout<<"\t\tDIFFERENCE!: "<<endl;
+               diff[2] =1;
+       }
+
+
+         cout<<"vtx tracks:\t"<<(Bool_t) flatEsd1->GetFlatPrimaryVertexTracks()<< " | " <<     (Bool_t) flatEsd2->GetFlatPrimaryVertexTracks()<<endl;    
+         //hVtxTr->Fill( (Bool_t) flatEsd1->GetFlatPrimaryVertexTracks(), (Bool_t) flatEsd2->GetFlatPrimaryVertexTracks());
+
+        
+         
+         if( (Bool_t) flatEsd1->GetFlatPrimaryVertexSPD() != (Bool_t) flatEsd2->GetFlatPrimaryVertexSPD()  ){
+               cout<<"\t\tDIFFERENCE!: "<<endl;
+               diff[3] =1;
+       }
+      cout<<"vtx SPD:\t"<<(Bool_t) flatEsd1->GetFlatPrimaryVertexSPD() << " | " << (Bool_t) flatEsd2->GetFlatPrimaryVertexSPD()<<endl;
+         //hVtxSPD->Fill( (Bool_t) flatEsd1->GetFlatPrimaryVertexSPD(), (Bool_t) flatEsd2->GetFlatPrimaryVertexSPD());
+
+         
+         
+  if((Bool_t)flatEsd1->GetFlatPrimaryVertexTracks() && (Bool_t)flatEsd2->GetFlatPrimaryVertexTracks()  ){
+               cout<<endl<<"vtx tracks -> X,Y,Z:\t"
+                       << flatEsd1->GetFlatPrimaryVertexTracks()->GetX()
+                       <<","<< flatEsd1->GetFlatPrimaryVertexTracks()->GetY()
+                       <<","<< flatEsd1->GetFlatPrimaryVertexTracks()->GetZ()
+                       <<" | " <<flatEsd2->GetFlatPrimaryVertexTracks()->GetX()
+                       <<","<< flatEsd2->GetFlatPrimaryVertexTracks()->GetY()
+                       <<","<< flatEsd2->GetFlatPrimaryVertexTracks()->GetZ()<<endl;     
+               }
+         */
+         
+         // compare tracks
+if(verbose){
+         AliFlatESDTrack *track1 = const_cast<AliFlatESDTrack*> (flatEsd1->GetTracks());
+         AliFlatESDTrack *track2 = const_cast<AliFlatESDTrack*> (flatEsd2->GetTracks());
+    for (Int_t idxTrack = 0; idxTrack < flatEsd1->GetNumberOfTracks() && track1 && track2; ++idxTrack) { 
+
+               //track2->Reinitialize();
+               const AliFlatExternalTrackParam* ext[2][nExt] ={
+                       {
+                               track1->GetFlatTrackParamRefitted(),
+                               track1->GetFlatTrackParamIp(),
+                               track1->GetFlatTrackParamTPCInner(),
+                               track1->GetFlatTrackParamOp(),
+               //              track1->GetFlatTrackParamCp(),
+               //              track1->GetFlatTrackParamITSOut()
+                       },
+                       {
+                               track2->GetFlatTrackParamRefitted(),
+                               track2->GetFlatTrackParamIp(),
+                               track2->GetFlatTrackParamTPCInner(),
+                               track2->GetFlatTrackParamOp(),
+                       //      track2->GetFlatTrackParamCp(),
+                       //      track2->GetFlatTrackParamITSOut()
+                       }
+               };
+       
+       //Printf("  TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
+       //Printf("  TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
+
+
+       for(int iExt=0; iExt<nExt; ++iExt){
+if(!ext[0][iExt] && !ext[1][iExt]) continue;   
+               if(!ext[0][iExt] && ext[1][iExt]){
+               //      cout<<"DIFFERENCE!: ";
+                       cout<<" ext"<<iExt<<" not set in "<<filename1<<endl;
+               }       
+               if(ext[0][iExt] && !ext[1][iExt]){
+               //      cout<<"DIFFERENCE!: ";
+                       cout<<" ext"<<iExt<<" not set in "<<filename2<<endl;
+               }
+
+
+               if( (!ext[0][iExt] || !ext[1][iExt])|| ext[0][iExt]->GetAlpha() != ext[1][iExt]->GetAlpha() ) {
+                       cout<<"\t\tDIFFERENCE!: "<<endl;
+                       //cout<<" alpha"<<iExt<<" :"  << (ext[0][iExt] ? ext[0][iExt]->GetAlpha() : -99.)  << "\t\t" << (ext[1][iExt] ?  ext[1][iExt]->GetAlpha(): -99.)<<endl;
+               }       cout<<" alpha"<<iExt<<" :\t"  << (ext[0][iExt] ? ext[0][iExt]->GetAlpha() : -99.)  << " | " << (ext[1][iExt] ?  ext[1][iExt]->GetAlpha(): -99.)<<endl;
+                       
+
+               if( (!ext[0][iExt] || !ext[1][iExt])||ext[0][iExt]->GetX() != ext[1][iExt]->GetX() ) {
+                       cout<<"\t\tDIFFERENCE!: "<<endl;
+                       //cout<<" GetX"<<iExt<<" :"  << (ext[0][iExt] ? ext[0][iExt]->GetX(): -99.)  << " | " << (ext[1][iExt] ?  ext[1][iExt]->GetX(): -99.)<<endl;
+               }       
+cout<<" GetX"<<iExt<<" :\t"  << (ext[0][iExt] ? ext[0][iExt]->GetX(): -99.)  << " | " << (ext[1][iExt] ?  ext[1][iExt]->GetX(): -99.)<<endl;
+
+
+               if( (!ext[0][iExt] || !ext[1][iExt])||ext[0][iExt]->GetSigned1Pt() !=  ext[0][iExt]->GetSigned1Pt() ) {
+                       cout<<"\t\tDIFFERENCE!: "<<endl;
+                       //cout<<" 1/pt"<<iExt<<" :"  <<  (ext[0][iExt] ? ext[0][iExt]->GetSigned1Pt(): -99.)  << " | " << (ext[1][iExt] ?  ext[1][iExt]->GetSigned1Pt(): -99.)<<endl;
+               }       
+       cout<<" 1/pt"<<iExt<<" :\t"  <<  (ext[0][iExt] ? ext[0][iExt]->GetSigned1Pt(): -99.)  << " | " << (ext[1][iExt] ?  ext[1][iExt]->GetSigned1Pt(): -99.)<<endl;
+                       
+
+}
+       
+         
+         /*
+       if( track1->GetNumberOfTPCClusters() != track2->GetNumberOfTPCClusters() ){
+               cout<<"DIFFERENCE!: ";
+               cout<<" nTPCclusters: "<<track1->GetNumberOfTPCClusters()<< " | " <<track2->GetNumberOfTPCClusters()<< endl;
+               diff[4]=1;
+       }  
+       if( track1->GetNumberOfITSClusters() != track2->GetNumberOfITSClusters() ){
+               cout<<"DIFFERENCE!: ";
+               cout<<" nITSclusters: "<<track1->GetNumberOfITSClusters()<< " | " <<track2->GetNumberOfITSClusters()<< endl;
+               diff[4]=1;
+       }
+*/
+         
+#if 0
+
+// compare clusters
+       if( verbose &&  track1->GetNumberOfTPCClusters() == track2->GetNumberOfTPCClusters()){
+               for (Int_t idxCluster = 0; idxCluster < track1->GetNumberOfTPCClusters(); ++idxCluster){
+                       AliFlatTPCCluster * cl1 = track1->GetTPCCluster(idxCluster);
+                       AliFlatTPCCluster * cl2 = track2->GetTPCCluster(idxCluster);
+/*
+                       if( cl1->GetX()&& cl2->GetX() && cl1->GetX() != cl2->GetX() ){
+                               cout<<"DIFFERENCE!: ";
+                               cout<<" cluster: "<<idxCluster<<" GetX :"<<cl1->GetX()<< " | " <<cl2->GetX()<< endl;
+                               diff=kTRUE;
+                       }
+                               cout<<" cluster: "<<idxCluster<<" GetX :"<<cl1->GetX()<< " | " <<cl2->GetX()<< endl;
+                               cout<<" cluster: "<<idxCluster<<" GetY :"<<cl1->GetY()<< " | " <<cl2->GetY()<< endl;
+
+                       if( cl1 && cl2 && cl1->GetY() != cl2->GetY() ){
+                               cout<<"DIFFERENCE!: ";
+                               cout<<" cluster: "<<idxCluster<<" GetY :"<<cl1->GetY()<< " | " <<cl2->GetY()<< endl;
+                               diff=kTRUE;
+                       }
+                       if( cl1->GetZ()&& cl2->GetZ() && cl1->GetZ() != cl2->GetZ() ){
+                               cout<<"DIFFERENCE!: ";
+                               cout<<" cluster: "<<idxCluster<<" GetZ :"<<cl1->GetZ()<< " | " <<cl2->GetZ()<< endl;
+                               diff=kTRUE;
+                       }
+*/
+                       if( cl1->GetPadRow()&& cl2->GetPadRow() && cl1->GetPadRow() != cl2->GetPadRow() ){
+                               cout<<"DIFFERENCE!: ";
+                               cout<<" cluster: "<<idxCluster<<" GetPadRow :"<<cl1->GetPadRow()<< " | " <<cl2->GetPadRow()<< endl;
+                               diff[5]=1;
+                       }
+
+               }
+         }
+         
+#endif
+      track1 = const_cast<AliFlatESDTrack*> (track1->GetNextTrack());
+      track2 = const_cast<AliFlatESDTrack*> (track2->GetNextTrack());
+         
+         
+         }
+}
+         
+         /*
+       //   hStat->Fill(0);      
+         Bool_t diffs=kFALSE;
+         for(int iDiff=0; iDiff<5;++iDiff){
+               if(diff[iDiff]){
+       //              hStat->Fill(iDiff+2);
+                       diffs = kTRUE;
+               }
+       }
+       if(!diffs) hStat->Fill(1);        
+*/
+
+      curr1=curr1+ flatEsd1->GetSize();
+      curr2=curr2+ flatEsd2->GetSize();
+      iEvent++;
+    }
+
+    delete[] buffer1;
+    delete[] buffer2;
+  }
+  else {
+    cout << "File could not be read" << endl;
+  }
+
+
+       TList histosList;
+       histosList.Add(hDiff);
+  histosList.SaveAs(outputFilename);
+
+  return;
+}
+
+Double_t printDiff(string name, double val1, double val2){
+       double relDiff = ( val1 != 0 || val2!=0 ) ? fabs(val1-val2)/(fabs(val1) + fabs(val2)): 0;
+       cout<<name<<":\t"<<val1<<" | " << val2 <<"\t|\t"<<(val1-val2)<<"\t|\t"<<relDiff<<endl;
+       return relDiff > 1e-6 ? 1:0;
+}
+Double_t printDiff(string name, TString val1, TString val2){
+       cout<<name<<":"<<endl<<"\t"<<val1<<endl<<"\t"<< val2 <<endl;
+       return val1.EqualTo(val2) ?0:1;
+}
diff --git a/HLT/global/FlatESDConverter.C b/HLT/global/FlatESDConverter.C
new file mode 100644 (file)
index 0000000..a0e085e
--- /dev/null
@@ -0,0 +1,195 @@
+/**
+ * >> Testing Macro to fill FlatESDEvent from ALiESDEvent <<
+ **
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ * Usage:
+ *  aliroot -b -l -q LoadLibs.C FlatESDConverter.C++
+ *
+ **************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliESDfriend.h"
+#include "AliESDfriendTrack.h"
+#include "../TPC/Rec/AliTPCseed.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TSystem.h>
+#include "./AliFlatESDEvent.h"
+#include "./AliFlatESDTrack.h"
+#include "./AliFlatESDTrigger.h"
+#include "./AliFlatTPCCluster.h"
+#include "./AliFlatExternalTrackParam.h"
+#include "Riostream.h"
+#include "AliSysInfo.h"
+#endif   
+
+void FlatESDConverter(const char* filename="AliESDs.root", const char* filenameFriends="AliESDfriends.root",const char* filenameOut="out.dat", Bool_t useESDFriends = kTRUE, Bool_t useHLTtree = kFALSE,Int_t verbose = 0) {
+
+       if(useESDFriends) Printf("using friends");
+       if(useHLTtree) Printf("using HLT tree");
+       
+       
+  // -- Convert AliESDEvent to AliFlatESDEvent
+/*
+  if ( access( filename, F_OK ) == -1 ){
+       Printf("input file not readable!");
+       return;
+  }
+*/
+
+  TFile *file    = new TFile(Form("%s", filename));
+       
+       
+  ofstream outFile(Form("%s",filenameOut), std::ifstream::binary | std::ifstream::out);
+  //ofstream outFile("outFlatESD.dat");
+
+  
+  TTree *esdTree = useHLTtree? dynamic_cast<TTree*>(file->Get("HLTesdTree")) : dynamic_cast<TTree*>(file->Get("esdTree"));
+  
+  // -- Connect ESD
+  AliESDEvent *esd = new AliESDEvent;
+  esd->ReadFromTree(esdTree);
+  
+  // -- Connect ESD friend
+  AliESDfriend *esdFriend = NULL; 
+  if (useESDFriends && !esdTree->FindBranch("ESDfriend.")) {
+    esdTree->AddFriend("esdFriendTree", Form("%s", filenameFriends));
+    esdTree->SetBranchStatus("ESDfriend.", 1);
+    esdFriend = (AliESDfriend*)esd->FindListObject("AliESDfriend");
+    if (esdFriend)
+      esdTree->SetBranchAddress("ESDfriend.", &esdFriend);
+  } // if (!esdTree->FindBranch("ESDfriend.")) {
+  ;
+  AliFlatESDEvent *flatEsd = NULL;
+
+  // -- Event Loop
+  for (Int_t idxEvent = 0; idxEvent < esdTree->GetEntries(); idxEvent++) {
+    Printf("Processing event nr %d", idxEvent);
+  //  esd->SaveAs("esdTemp.root");
+   // TFile  fTmp = TFile("esdTemp.root");
+    Int_t sizeIn = 1;//fTmp.GetSize();
+
+    AliSysInfo::AddStamp("getEntry",0,0,idxEvent);
+
+    esdTree->GetEntry(idxEvent);
+    // -- Book memory for AliFlatESDEvent
+    // -- TEST >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+       Int_t size = AliFlatESDEvent::EstimateSize(esd, kTRUE);
+    Byte_t *mem = new Byte_t[size];
+
+    flatEsd = reinterpret_cast<AliFlatESDEvent*>(mem);
+    new (flatEsd) AliFlatESDEvent;
+       
+       
+       
+    AliSysInfo::AddStamp("DoEvent.Start",0,0,idxEvent);
+    // -- Fill AliFlatESDEvent
+
+  Int_t err=  flatEsd->SetFromESD( size,  esd, kTRUE ); 
+  
+  if(err) Printf("!!! Error while filling flatESD event  %d!!!", err);
+  Printf("trigger classes: %d size: %d , = %d",flatEsd->GetNumberOfTriggerClasses(), sizeof(AliFlatESDTrigger) , flatEsd->GetNumberOfTriggerClasses() *sizeof(AliFlatESDTrigger) );      
+    AliSysInfo::AddStamp("DoEvent.Stop",sizeIn,flatEsd->GetSize(),idxEvent);
+
+               if(useESDFriends){
+      Printf("ESD : Event %d || V0s %d || Tracks %d | FRIEND Tracks %d || estimated size %llu", 
+            idxEvent, esd->GetNumberOfV0s(),esd->GetNumberOfTracks(), esdFriend->GetNumberOfTracks(), 
+            AliFlatESDEvent::EstimateSize(esd, useESDFriends));
+      Printf("FLAT: Event %d || V0s %d || Tracks %d | FRIEND Tracks %d || estimated size %llu", 
+            idxEvent, flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks(), esdFriend->GetNumberOfTracks(), flatEsd->GetSize());
+               }
+               else{
+      Printf("ESD : Event %d || V0s %d || Tracks %d || estimated size %llu ", 
+            idxEvent,esd->GetNumberOfV0s(), esd->GetNumberOfTracks(), 
+            AliFlatESDEvent::EstimateSize(esd, useESDFriends) );
+      Printf("FLAT: Event %d || V0s %d || Tracks %d || estimated size %llu ", 
+            idxEvent, flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks(),  flatEsd->GetSize());
+               }
+      AliFlatESDTrack *track = const_cast<AliFlatESDTrack*> (flatEsd->GetTracks());
+      for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks(); ++idxTrack) {      
+       AliESDtrack *esdTrack = esd->GetTrack(idxTrack);      
+       AliESDfriendTrack *friendTrack = useESDFriends ?  esdFriend->GetTrack(idxTrack) :NULL;
+               if (track && !esdTrack) {
+         Printf("ERROR THIS SHOULD NOT HAPPEN AT ALL !!! TRACK %d HAS NO ESD TRACK!!!", idxTrack);
+         return;
+       }
+    if (verbose) {
+       if (track) {
+         const AliFlatExternalTrackParam* exp1 = track->GetFlatTrackParamCp();
+          const AliFlatExternalTrackParam* exp2 = track->GetFlatTrackParamIp();
+          const AliFlatExternalTrackParam* exp3 = track->GetFlatTrackParamTPCInner();
+          const AliFlatExternalTrackParam* exp4 = track->GetFlatTrackParamOp();
+
+         Float_t alphaFLAT[4] = {0., 0., 0., 0.};
+         if (exp1) alphaFLAT[0] = exp1->GetAlpha();
+         if (exp2) alphaFLAT[1] = exp2->GetAlpha();
+         if (exp3) alphaFLAT[2] = exp3->GetAlpha();
+         if (exp4) alphaFLAT[3] = exp4->GetAlpha();
+
+         Float_t alphaOLD[4]  = {0., 0., 0., 0.};
+         if (esdTrack->GetConstrainedParam())  alphaOLD[0] = esdTrack->GetConstrainedParam()->GetAlpha();
+         if (esdTrack->GetInnerParam())        alphaOLD[1] = esdTrack->GetInnerParam()->GetAlpha();
+         if (esdTrack->GetTPCInnerParam())     alphaOLD[2] = esdTrack->GetTPCInnerParam()->GetAlpha();
+         if (esdTrack->GetOuterParam())        alphaOLD[3] = esdTrack->GetOuterParam()->GetAlpha();
+
+         Printf("TEST: FlatTrack %d > FlatExternalTrackParam > %p %p %p %p", idxTrack, exp1, exp2, exp3, exp4);
+         Printf("TEST: FlatTrack %d > Alpha %f %f %f %f", idxTrack, alphaFLAT[0], alphaFLAT[1], alphaFLAT[2], alphaFLAT[3]);
+         Printf("TEST: Old Track %d > Alpha %f %f %f %f", idxTrack, alphaOLD[0], alphaOLD[1], alphaOLD[2], alphaOLD[3]);
+         Printf("TEST: Diff      %d > Alpha %f %f %f %f", idxTrack, 
+                alphaFLAT[0]-alphaOLD[0], alphaFLAT[1]-alphaOLD[1], alphaFLAT[2]-alphaOLD[2], alphaFLAT[3]-alphaOLD[3]);
+
+         Int_t nCl = track->GetNumberOfTPCClusters();
+         Printf("TEST: FlatTrack %d has %d FlatClusters", idxTrack, nCl);
+         
+#if 0
+         if(nCl && useESDFriends && verbose > 1){
+           TObject* calibObject = NULL;
+           AliTPCseed* seed = NULL;
+           for (Int_t idx = 0; (calibObject = friendTrack->GetCalibObject(idx)); ++idx) {
+             if ((seed = dynamic_cast<AliTPCseed*>(calibObject))) break;
+           }
+           // -- Fill cluster
+           if (seed) {
+             Int_t idxRow2=0;
+             for (Int_t idxRow = 0; idxRow <  nCl; idxRow++){
+               AliFlatTPCCluster * cl = track->GetTPCCluster(idxRow);
+               cout << " idx fX fY fZ  fSigmaY2 fSigmaZ2 fCharge fQMax fPadRow" << endl;
+               if(cl){
+                 cout << idxRow << " " << cl->GetX() << " " << cl->GetY() << " " << cl->GetZ() << " " << cl->GetSigmaY2() << " " << cl->GetSigmaZ2() << " " << cl->GetCharge() << " " << cl->GetQMax() << " " << cl->GetPadRow() << endl;
+               }
+               else{
+                 cout << idxRow << "---------------------------------" << endl << endl;                
+               }
+               AliTPCclusterMI* cl2 = NULL; 
+               while(!cl2 && idxRow2<160){
+                 cl2 = seed->GetClusterPointer(idxRow2++);
+               }
+               if (cl2) {
+                 //cout<<" normalCl fX fY fZ fPadRow fSigmaY2 fSigmaZ2 fCharge fQMax" <<endl;
+                 cout << idxRow << " " << cl2->GetX() << " " << cl2->GetY() << " " << cl2->GetZ() << " " << cl2->GetSigmaY2() << " " << cl2->GetSigmaZ2() << " " << cl2->GetQ() << " " << cl2->GetMax() << " " << cl2->GetRow() << endl << endl;
+               }
+               else
+                 cout << idxRow << "---------------------------------" << endl << endl;        
+             }
+           }
+         }
+#endif
+
+       }
+       track = const_cast<AliFlatESDTrack*> (track->GetNextTrack() );
+      }
+    }
+
+    outFile.write(reinterpret_cast<char*>(mem), flatEsd->GetSize());
+    delete[] mem; 
+
+  } // for (Int_t idxEvent = 1; idxEvent < 2; idxEvent++) {
+
+  outFile.close();
+
+  return;
+}    
diff --git a/HLT/global/LoadLibs.C b/HLT/global/LoadLibs.C
new file mode 100644 (file)
index 0000000..c5ed538
--- /dev/null
@@ -0,0 +1,25 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliESDfriend.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TSystem.h>
+//#include "./AliFlatESDEvent.h"
+//#include "./AliFlatESDTrack.h"
+//#include "../BASE/AliHLTExternalTrackParam.h"
+#endif   
+
+
+void LoadLibs() {
+
+  gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS  -I$ALICE_ROOT/OADB -g"); 
+
+  gSystem->Load("libHLTbase.so");
+  gSystem->Load("libAliHLTUtil.so");
+  gSystem->Load("libAliHLTTPC.so");
+  gSystem->Load("libAliHLTITS.so");
+  gSystem->Load("libAliHLTGlobal.so");
+
+  return;
+}    
diff --git a/HLT/global/ReadFlatESD.C b/HLT/global/ReadFlatESD.C
new file mode 100644 (file)
index 0000000..defebb6
--- /dev/null
@@ -0,0 +1,160 @@
+/**
+ * >> Testing Macro to read FlatESDEvent from output file <<
+ **
+ * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
+ *
+ * Usage:
+ *  aliroot -b -l -q LoadLibs.C ReadFlatESD.C++
+ *
+ **************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliESDfriend.h"
+#include <TFile.h>
+#include <TTree.h>
+#include <TSystem.h>
+#include "./AliFlatESDEvent.h"
+#include "./AliFlatESDTrack.h"
+#include "./AliFlatTPCCluster.h"
+#include "./AliFlatExternalTrackParam.h"
+#include "./AliFlatESDTrigger.h"
+#include "./AliFlatESDV0.h"
+#include "Riostream.h"
+#endif   
+
+void ReadFlatESD(const char* filename="outFlatESD.dat", Int_t verbose=0) {
+
+  ifstream is(filename, std::ifstream::binary | std::ifstream::in);
+  if (is){
+    std::cout << "ifstream available"<<endl;
+    is.seekg (0, is.end);
+    int length = is.tellg();
+    is.seekg (0, is.beg);
+    std::cout << "length "<<length<<endl;
+    char * buffer = new char [length];
+    
+    std::cout << "Reading " << length << " characters... ";
+    
+    is.read (buffer,length);
+    if (is)
+      std::cout << "all characters read successfully." << endl;
+    else
+      std::cout << "error: only " << is.gcount() << " could be read";
+    is.close();
+    
+    // ...buffer contains the entire file...
+    
+    char *curr = buffer;
+    char *endBuff = buffer+length;
+    int iEvent = 0;
+    
+    while( curr < endBuff ){
+      cout<<endl<<"Reading event "<<iEvent<<":"<<endl;
+ //   Printf("curr: %p \t endBuff: %p \t diff %p ", curr, endBuff, endBuff-curr);
+      AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent *>(curr);
+                       flatEsd->Reinitialize();
+
+      
+cout<<"vtx SPD: "<<(Bool_t) flatEsd->GetFlatPrimaryVertexSPD()
+         <<" vtx tracks: "<<(Bool_t) flatEsd->GetFlatPrimaryVertexTracks()     
+         <<" ntracks: "<<flatEsd->GetNumberOfTracks()
+         <<" nV0's: "<<flatEsd->GetNumberOfV0s()
+         <<endl;
+
+// compare tracks
+if(verbose){/*
+       static const int nExt = 4;
+         AliFlatESDTrack *track = const_cast<AliFlatESDTrack*> ( flatEsd->GetTracks() );
+         //new (track)AliFlatESDTrack(1);
+    for (Int_t idxTrack = 0; idxTrack < flatEsd->GetNumberOfTracks() && track; ++idxTrack) { 
+
+       cout<<"track nr "<<idxTrack<<endl;
+
+               const AliFlatExternalTrackParam* ext[nExt] ={
+                       
+                               track->GetFlatTrackParamRefitted(),
+                               track->GetFlatTrackParamIp(),
+                               track->GetFlatTrackParamTPCInner(),
+                               track->GetFlatTrackParamOp(),
+               
+               };
+       
+       //Printf("  TEST: FlatTrack1 %d > FlatExternalTrackParam1 > %p %p %p %p", idxTrack, exp11, exp21, exp31, exp41);
+       //Printf("  TEST: FlatTrack2 %d > FlatExternalTrackParam2 > %p %p %p %p", idxTrack, exp12, exp22, exp32, exp42);
+
+
+       for(int iExt=0; iExt<nExt; ++iExt){
+cout<<endl<<iExt<<endl;                
+               if(!ext[iExt]){
+               //      cout<<"DIFFERENCE!: ";
+                       cout<<" ext"<<iExt<<" not set"<<endl;
+               }       
+
+
+               cout<<" alpha"<<iExt<<" :"  << (ext[iExt] ? ext[iExt]->GetAlpha() : -9999) <<endl;
+cout<<" GetX"<<iExt<<" :"  << (ext[iExt] ? ext[iExt]->GetX(): -9999) <<endl;
+       cout<<" 1/pt"<<iExt<<" :"  <<  (ext[iExt] ? ext[iExt]->GetSigned1Pt(): -9999)  <<endl;
+                       
+
+}      
+      track = const_cast<AliFlatESDTrack*> (track->GetNextTrack());
+         
+         
+         }
+         
+*/
+         
+         
+         // compare triggers
+         
+         /*
+               cout<<"------------------\ntriggers\n------------------\n";
+    AliFlatESDTrigger * trigger =const_cast<AliFlatESDTrigger*>(flatEsd->GetTriggerClasses() ) ;
+    for( Int_t i = 0; i < flatEsd->GetNumberOfTriggerClasses() ; i++ ){
+      cout<<"\nnew trigger\n";
+                       cout<<"AliFlatESDTrigger::GetSize"<<trigger->GetSize()<<endl;
+                       cout<<"AliFlatESDTrigger::GetTriggerIndex"<<trigger->GetTriggerIndex()<<endl;
+                       cout<< "AliFlatESDTrigger::GetTriggerClassName"<<trigger->GetTriggerClassName()<<endl;
+                       
+      trigger= trigger->GetNextTriggerNonConst();
+    }
+         **/
+         
+         // compare v0s
+
+         
+       if(flatEsd->GetNumberOfV0s()  ){
+               cout<<"------------------\nv0s\n------------------\n";
+               
+    AliFlatESDV0 * v0 = const_cast<AliFlatESDV0*>(flatEsd->GetV0s() ) ;
+    for( Int_t i = 0; i < flatEsd->GetNumberOfV0s(); i++ ){
+      cout<<"\nnew v0\n";
+                       cout<<"AliFlatESDV0::GetSize "<<v0->GetSize()<<endl; 
+                       cout<<"AliFlatESDV0::GetNegTrackID "<<v0->GetNegTrackID()<<endl ; 
+                       cout<<"AliFlatESDV0::GetPosTrackID "<<v0->GetPosTrackID()<<endl; 
+                       
+      v0 = v0->GetNextV0NonConst();
+    }
+       }
+         
+         
+         
+         
+         
+}
+
+  //  Printf("curr: %p \t + %d = %p , diff:%p", curr, flatEsd->GetSize() ,curr+ flatEsd->GetSize(), endBuff-(curr+ flatEsd->GetSize())   );
+      curr=curr+ flatEsd->GetSize();
+      iEvent++;
+    }
+
+
+    delete[] buffer;
+  }
+  else {
+    cout << "File "<<filename<<" could not be read" << endl;
+  }
+  return;
+}
diff --git a/HLT/global/fladevMacros/compare/command.sh b/HLT/global/fladevMacros/compare/command.sh
new file mode 100755 (executable)
index 0000000..0c24557
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/bash
+if [ $# -lt 1 ]
+    then
+       file1="flat.dat"
+    else
+       file1=$1
+    fi
+if [ $# -lt 2 ]
+    then
+       file2="normal.dat"
+    else
+       file2=$2
+    fi
+if [ $# -lt 3 ]
+    then
+       verbose="kFALSE"
+    else
+       verbose=$3
+    fi
+
+
+
+aliroot -b -l -q $ALICE_ROOT/HLT/global/LoadLibs.C $ALICE_ROOT/HLT/global/CompareFlatESDs.C++'("'${file1}'","'${file2}'",'${verbose}')' | tee compare.out
diff --git a/HLT/global/fladevMacros/esdToFlat/command_list.sh b/HLT/global/fladevMacros/esdToFlat/command_list.sh
new file mode 100755 (executable)
index 0000000..11039a3
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/bash
+if [ $# -lt 1 ]
+    then
+       fileList=$PWD
+    else
+       fileList=$1
+    fi
+if [ $# -lt 2 ]
+    then
+       useFriends=1
+    else
+       useFriends=$2
+    fi
+if [ $# -lt 3 ]
+    then
+       useHLTtree=0
+    else
+       useHLTtree=$3
+    fi
+if [ $# -lt 4 ]
+    then
+       verbose=0
+    else
+       verbose=$4
+    fi
+    
+    iFile=1
+for file in ${fileList}*/AliESDs.root
+do
+  mkdir ${iFile}
+  replace="AliESDfriends"
+  fileFriends="${file/AliESDs/$replace}"
+  aliroot -b -l -q $ALICE_ROOT/HLT/global/LoadLibs.C $ALICE_ROOT/HLT/global/FlatESDConverter.C++'("'${file}'", "'${fileFriends}'", "'${iFile}'/out.dat",'${useFriends}', '${useHLTtree}','${verbose}')' 2>&1| tee convert.log -a
+  cat ${iFile}/out.dat >> outFlatESD.dat
+  mv syswatch.log ${iFile}/syswatch.log
+       if [ $iFile -eq 1 ]
+               then
+                       cp 1/syswatch.log syswatch_merged.log
+               else
+                       sed 1d $iFile/syswatch.log >> syswatch_merged.log
+       fi
+  iFile=$((iFile+1))
+done
diff --git a/HLT/global/fladevMacros/plot/createHistos.C b/HLT/global/fladevMacros/plot/createHistos.C
new file mode 100644 (file)
index 0000000..199f5f0
--- /dev/null
@@ -0,0 +1,370 @@
+TCanvas * c;
+
+
+void createHistos(bool single=true, bool combined = true, bool merged=true, int fromType=0, int toType=2){
+
+
+       c = new TCanvas();
+// 0 = raw->esd
+// 1 = raw->flat
+// 2= esd -> flat
+
+
+       TTree * t[4];
+
+
+       char*sname[4]={"DoEvent.Stop","DoEvent.Stop","DoEvent.Stop","DoEvent.Stop"};
+       char*conversion[4]={"rawToEsd","rawToFlat","HltEsdToFlat","NormalEsdToFlat"};
+       char *infolder="rawToHltEsd";
+       char *subfolder="";
+       Int_t outMax = 80;
+       Int_t inMax = 150;
+       Int_t timeMax = 20;
+
+
+// create histograms for different types of conversion 
+
+for(int type=fromType; type<=toType; ++type){
+
+       if(type==1){
+               timeMax=6;
+               outMax = 700;
+               inMax = 2000;
+               infolder = "rawToFlat";
+       }
+       else if(type==2){
+               timeMax = 1;
+               inMax =200;
+               infolder = "HltEsdToFlat";
+       }
+       else if(type==3){
+               timeMax = 1;
+               inMax =200;
+               infolder = "NormalEsdToFlat";
+       }
+
+
+       if(merged){
+               t[type] = AliSysInfo::MakeTree(Form("%s/syswatch_merged.log" , infolder) );
+               subfolder = "/merged";
+       }
+       else{
+               t[type] = AliSysInfo::MakeTree(Form("%s/syswatch.log" , infolder) );
+               subfolder = "/single";
+
+       }
+
+
+
+if (single){
+
+       cout<<"Creating plots for "<< infolder<<endl;
+
+       // Draw cpu, sys, cpu+sys time distribution
+
+       t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser)>>h(100,0,15)", Form("sname==\"%s\"", sname[type]) );
+       saveHist("cpuTimeUserDistribution",conversion[type] , infolder, subfolder, "cpu time (user)/event (ms)", "\#events","",kTRUE);
+
+       t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys)>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeSysDistribution",conversion[type] , infolder, subfolder, "cpu time (sys)/event (ms)", "\#events","",kTRUE);
+
+       t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys)>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserSysDistribution",conversion[type] , infolder, subfolder, "cpu time (user+sys)/event (ms)", "\#events","",kTRUE);
+
+
+
+       // Draw cpu, sys, cpu+sys time vs input size
+
+       //t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+
+
+       int scale = type==0? 1000:1;
+       t[type]->Draw( Form("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1024/%d>>h(100,0,%d,100,0,%d)", scale,inMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserVsInputSize",conversion[type] , infolder, subfolder, "input size (kB)", "cpu time (user)/event (ms)", "");
+
+       //t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw( Form("1000*(pI.fCpuSys-pIOld.fCpuSys):id0/1024/%d>>h(100,0,%d,100,0,%d)",scale,inMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeSysVsInputSize",conversion[type] , infolder, subfolder, "input size (kB)", "cpu time (sys)/event (ms)","");
+
+       //t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw( Form("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):id0/1024/%d>>h(100,0,%d,100,0,%d)",scale, inMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserSysVsInputSize",conversion[type] , infolder, subfolder, "input size (kB)", "cpu time (user+sys)/event (ms)","");
+
+
+       // Draw cpu, sys, cpu+sys time vs output size
+
+       //t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw(Form("1000*(pI.fCpuUser-pIOld.fCpuUser):id1/1024>>h(1000,0,%d,1000,0,%d)",outMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserVsOutSize",conversion[type] , infolder, subfolder, "output size (kB)", "cpu time (user)/event (ms)");
+       //t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw(Form("1000*(pI.fCpuSys-pIOld.fCpuSys):id1/1024>>h(1000,0,%d,1000,0,%d)",outMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeSysVsOutSize",conversion[type] , infolder, subfolder, "output size (kB)", "cpu time (sys)/event (ms)");
+
+       //t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):id0/1000>>h(1000,0,120,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw(Form("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):id1/1024>>h(1000,0,%d,1000,0,%d)",outMax,timeMax) ,Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserSysVsOutSize",conversion[type] , infolder, subfolder, "output size (kB)", "cpu time (user+sys)/event (ms)");
+
+
+       // Draw cpu, sys, cpu+sys time vs timestamp
+
+       //t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):stampSec>>h(1000,1402524e3,1402534e3,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):stampSec>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserVsTimestamp",conversion[type] , infolder, subfolder, "timestamp (s)", "cpu time (user)/event (ms)");
+
+       //t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys):stampSec>>h(1000,1402524e3,1402534e3,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys):stampSec>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeSysVsTimestamp",conversion[type] , infolder, subfolder, "timestamp (s)", "cpu time (sys)/event (ms)");
+
+       //t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):stampSec>>h(1000,1402524e3,1402534e3,1000,0,15)",Form("sname==\"%s\"", sname[type]));
+       t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):stampSec>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserSysVsTimestamp",conversion[type] , infolder, subfolder, "timestamp (s)", "cpu time (user+sys)/event (ms)");
+
+
+       // Draw cpu, sys, cpu+sys time vs time in event
+
+       t[type]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):T>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserVsT",conversion[type] , infolder, subfolder, "time in file (s)", "cpu time (user)/event (ms)");
+
+       t[type]->Draw("1000*(pI.fCpuSys-pIOld.fCpuSys):T>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeSysVsT",conversion[type] , infolder, subfolder, "time in file (s)", "cpu time (sys)/event (ms)");
+
+       t[type]->Draw("1000*(pI.fCpuUser+pI.fCpuSys-pIOld.fCpuUser-pIOld.fCpuSys):T>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("cpuTimeUserSysVsT",conversion[type] , infolder, subfolder, "time in file (s)", "cpu time (user+sys)/event (ms)");
+
+       
+       // Draw input size distribution
+
+       t[type]->Draw("id0/1024>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("inputSize",conversion[type] , infolder, subfolder, "input size (kB)", "\#events","",kTRUE);
+
+
+       // Draw output size distribution
+
+       t[type]->Draw("id1/1024>>h()",Form("sname==\"%s\"", sname[type]));
+       saveHist("outputSize",conversion[type] , infolder, subfolder, "output size (kB)", "\#events","",kTRUE);
+
+
+       // Draw output vs input size
+
+       t[type]->Draw(Form("id1/1024/%d:id0/1024/%d>>h()",scale,scale),Form("sname==\"%s\"", sname[type]));
+       saveHist("OutVsIn",conversion[type] , infolder, subfolder, "input size (kB)", "output size (kB)","", kFALSE, kTRUE);
+
+}
+}
+
+
+// combined histo
+
+
+
+// draw time distribution for flat and esd in one histo
+if(combined){
+       cout<<"Creating combined plots"<<endl;
+
+       infolder = "combined";
+       subfolder = "";
+       char* legends[2] = {"ESD","flatESD"};
+       char* options[2] = {"",""};
+
+
+
+       t[0]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser)>>h1(100,0,15)", Form("sname==\"%s\"", sname[0]) );
+       t[1]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser)>>h2(100,0,15)", Form("sname==\"%s\"", sname[1]) );
+//     t[0]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser)>>h1()", Form("sname==\"%s\"", sname[0]) );
+//     t[1]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser)>>h2()", Form("sname==\"%s\"", sname[1]) );
+       save2Hists("cpuTimeUserDistribution","flatVsNormal" , infolder, subfolder, "cpu time (user)/event (ms)", "\#events",legends, options,kTRUE,1) ;
+
+       t[0]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1024/1000>>h1(1000,0,2000,1000,0,16)", Form("sname==\"%s\"", sname[0]) );
+       t[1]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1024>>h2(1000,0,2000,1000,0,16)", Form("sname==\"%s\"", sname[1]) );
+       //t[0]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1024/1000>>h1()", Form("sname==\"%s\"", sname[0]) );
+       //t[1]->Draw("1000*(pI.fCpuUser-pIOld.fCpuUser):id0/1024>>h2()", Form("sname==\"%s\"", sname[1]) );
+       save2Hists("cpuTimeUserVsInputSize","flatVsNormal" , infolder, subfolder, "input size (kB)", "cpu time (user)/event (ms)",legends, options,kFALSE,2);
+
+
+
+
+// loop over trees to get combined histos
+
+
+
+       TH2D*flatVsNormalCpuTime = new TH2D("flatVsNormalCpuTime", "cpu time: flat vs normal", 400,0,8,150,0,3);
+       TH2D*flatVsNormalInSize = new TH2D("flatVsNormalInSize", "input size: flat vs normal", 200,0,200,2000,0,2000);
+       TH2D*flatVsNormalOutSize = new TH2D("flatVsNormalOutSize", "output size: flat vs normal", 80,0,80,800,0,800);
+       Double_t cpuEsd , cpuOldEsd, cpuFlat, cpuOldFlat;
+       Int_t inputSizeEsd, inputSizeFlat,outputSizeEsd, outputSizeFlat;
+       char snameEsd[100]=".";
+       char snameFlat[100]=".";
+
+       t[0]->SetBranchAddress("pI.fCpuUser",&cpuEsd);
+       t[0]->SetBranchAddress("pIOld.fCpuUser",&cpuOldEsd);
+       t[0]->SetBranchAddress("sname",&snameEsd);
+       t[0]->SetBranchAddress("id0",&inputSizeEsd);
+       t[0]->SetBranchAddress("id1",&outputSizeEsd);
+
+       t[1]->SetBranchAddress("pI.fCpuUser",&cpuFlat);
+       t[1]->SetBranchAddress("pIOld.fCpuUser",&cpuOldFlat);
+       t[1]->SetBranchAddress("sname",&snameFlat);
+       t[1]->SetBranchAddress("id0",&inputSizeFlat);
+       t[1]->SetBranchAddress("id1",&outputSizeFlat);
+
+
+     t[0]->SetBranchStatus("*",0); //disable all branches
+     t[0]->SetBranchStatus("sname",1);
+     t[0]->SetBranchStatus("pI.fCpuUser",1);
+     t[0]->SetBranchStatus("pIOld.fCpuUser",1);
+     t[0]->SetBranchStatus("id0",1);
+     t[0]->SetBranchStatus("id1",1);
+
+     t[1]->SetBranchStatus("*",0); //disable all branches
+     t[1]->SetBranchStatus("sname",1);
+     t[1]->SetBranchStatus("pI.fCpuUser",1);
+     t[1]->SetBranchStatus("pIOld.fCpuUser",1);
+     t[1]->SetBranchStatus("id0",1);
+     t[1]->SetBranchStatus("id1",1);
+
+Int_t i2=0;
+
+// loop over timestamps in normalESD tree
+for (Int_t i1 = 0; i1 < t[0]->GetEntries()  ; i1++) {
+       
+       t[0]->GetEntry(i1);
+       if( strcmp(snameEsd,"DoEvent.Stop") == 0){
+               t[1]->GetEntry(i2++);
+               while(strcmp(snameFlat,"DoEvent.Stop") != 0 && i2 < t[1]->GetEntries()){
+                       t[1]->GetEntry(i2++);
+               }
+               if(i2 < t[1]->GetEntries()){
+//cout<<outputSizeEsd<<" "<<outputSizeFlat<<endl;
+                 flatVsNormalCpuTime->Fill( 1000*(cpuEsd-cpuOldEsd), 1000*(cpuFlat-cpuOldFlat) );
+                 flatVsNormalInSize->Fill( inputSizeEsd/1000/1024, inputSizeFlat/1024);
+                 flatVsNormalOutSize->Fill( outputSizeEsd/1000/1024, outputSizeFlat/1024);
+               }
+       }
+       
+}
+
+
+       saveHist(flatVsNormalCpuTime, infolder, subfolder, "cpu time ESD converter (ms)", "cpu time flatESD converter (ms)", "colz", kFALSE, kTRUE,kTRUE);
+       saveHist(flatVsNormalInSize, infolder, subfolder, "input size time ESD converter (kB)", "input size flatESD converter (kB)", "colz");
+       saveHist(flatVsNormalOutSize, infolder, subfolder, "output size ESD converter (kB)", "output size flatESD converter (kB)", "colz",kFALSE,kTRUE);
+delete flatVsNormalCpuTime;
+delete flatVsNormalInSize;
+delete flatVsNormalOutSize;
+
+}
+return;
+}
+
+void saveHist(TH1*h, char*infolder, char*subfolder, char*x="",char*y="",char*options="", Bool_t log=kFALSE, Bool_t fit = kFALSE, Bool_t xy=kFALSE){
+       TCanvas *c = new TCanvas();
+       if(log){
+               c->SetLogy();
+       }
+       h->GetXaxis()->SetTitle(x);
+       h->GetYaxis()->SetTitle(y);
+       h->SetStats(0);
+               h->SetMarkerStyle(6);
+       h->Draw(options);
+       //c->SaveAs( Form("%s%s/%s.png", infolder, subfolder, h->GetName()) );
+       //c->SaveAs( Form("%s%s/%s.root", infolder, subfolder, h->GetName()) );
+       if(fit){
+
+        TF1 *linear = new TF1("linear","pol2(0)", 0,2000);
+
+        linear->SetParameters(0.5,0.2);
+        linear->SetLineColor(kRed);
+        linear->SetLineWidth(2);
+               h->Fit(linear);
+
+       }
+       if(xy){
+
+        TF1 *linear = new TF1("lin","x",0,8);
+        linear->SetLineColor(kRed);
+        linear->SetLineWidth(2);
+               linear->Draw("same");
+
+       }
+       c->SaveAs( Form("%s%s/%s_fit.png", infolder, subfolder, h->GetName()) );
+       c->SaveAs( Form("%s%s/%s_fit.root", infolder, subfolder, h->GetName()) );
+}
+
+
+
+
+
+void saveHist(char* name, char* type, char*infolder, char*subfolder, char*x="",char*y="", char*options="", Bool_t log=kFALSE, Bool_t fit = kFALSE){
+       TCanvas *c = new TCanvas();
+       if(log){
+               c->SetLogy();
+       }
+       TH1* h = (TH1*)gDirectory->Get("h");
+       cout<<name<<" mean: "<< h->GetMean()<<endl;
+       h->SetTitle(Form("%s_%s", name, type) );
+       h->GetXaxis()->SetTitle(x);
+       h->GetYaxis()->SetTitle(y);
+       h->SetStats(0);
+       //h->SetMarkerStyle(6);
+       h->Draw(options);
+       if(fit){
+
+        TF1 *linear = new TF1("linear","pol2(0)", 0,2000);
+
+        linear->SetParameters(0.5,0.2);
+        linear->SetLineColor(kRed);
+        linear->SetLineWidth(2);
+               h->Fit(linear);
+
+       }
+
+
+       c->SaveAs( Form("%s%s/%s_%s.png", infolder, subfolder, name, type) );
+       c->SaveAs( Form("%s%s/%s_%s.root", infolder, subfolder, name, type) );
+       gDirectory->DeleteAll();
+}
+
+
+void save2Hists(char* name, char* infolder, char*subfolder, char*x="",char*y="", char**legends =0x0, char**options=0x0,  Bool_t log=kFALSE, Int_t dim=1){
+       TCanvas *c = new TCanvas();
+       if(log){
+               c->SetLogy();
+       }
+       TH1* h1 = (TH1*)gDirectory->Get("h1");
+       TH1* h2 = (TH1*)gDirectory->Get("h2");
+
+       if(dim==1){
+               h1->SetFillColor(kRed);
+               h2->SetFillColor(kBlue);
+       }
+       else if(dim==2){
+               h1->SetMarkerColor(kRed);
+               h2->SetMarkerColor(kBlue);
+               h1->SetMarkerStyle(6);
+               h2->SetMarkerStyle(6);
+       }
+
+       h1->SetTitle(Form("%s_%s", name, type) );
+       h1->GetXaxis()->SetTitle(x);
+       h1->GetYaxis()->SetTitle(y);
+       h1->SetStats(0);
+       h1->Draw();
+       h2->Draw("same");
+    TLegend* l=new TLegend(.58,0.68,.88,0.85);
+       l->SetFillColor(0);
+       l->SetBorderSize(0);
+
+       if(dim==1){
+               l->AddEntry(h1, legends[0], "f");
+               l->AddEntry(h2, legends[1],"f");
+       }
+       else if(dim==2){
+               l->AddEntry(h1, legends[0],"p");
+               l->AddEntry(h2, legends[1],"p");
+       }
+
+       l->Draw("same");
+       c->SaveAs( Form("%s%s/%s_%s.png", infolder, subfolder, name, type) );
+       c->SaveAs( Form("%s%s/%s_%s.root", infolder, subfolder, name,type) );
+       gDirectory->DeleteAll();
+       delete l;
+}
diff --git a/HLT/global/fladevMacros/rawToHltEsd/command_list.sh b/HLT/global/fladevMacros/rawToHltEsd/command_list.sh
new file mode 100755 (executable)
index 0000000..e02d81f
--- /dev/null
@@ -0,0 +1,69 @@
+#! /bin/bash
+if [ $# -lt 1 ]
+    then
+                       echo "please specify directory with input raw data"
+                       exit
+    else
+                               fileList=$1
+    fi
+if [ $# -lt 2 ]
+    then
+                       config="normal"
+    else
+                               config=$2
+    fi
+if [ $# -lt 3 ]
+    then
+        ocdb="local://$OCDB10"
+    else
+                               ocdb=$3
+    fi
+if [ $# -lt 4 ]
+    then
+        start=-1
+    else
+                               start=$4
+    fi
+if [ $# -lt 5 ]
+    then
+        end=-1
+    else
+                               end=$5
+    fi
+if [ $# -lt 6 ]
+    then
+                       ouputfileName="outFlatHLT.dat"
+    else
+                               ouputfileName=$6
+    fi
+        
+#aliroot ../createHistos.C -q
+iFile=1
+
+for file in ${fileList}*/raw.root
+do
+  #  dir=${dir%*/}
+  #  echo ${dir##*/}
+  echo "Now processing ${file}"
+  mkdir ${iFile}
+  
+  if [ $config = "flat" ]
+       then
+         echo "using flat ESD converter"
+         aliroot -q -b ../config_Flat.C'("'${iFile}'","'${ouputfileName}'")' $ALICE_ROOT/HLT/exa/recraw-local.C'("'${file}'","'${ocdb}'", '${start}', '${end}', "HLT", "chains=RootWriter  ignore-hltout")' 2>&1|tee recraw-local.log -a
+         cat ${iFile}/*.dat >> outFlatESD.dat
+       else
+         echo "using normal ESD converter"
+         aliroot -b -q -l $ALICE_ROOT/HLT/exa/recraw-local.C'("'${file}'","'${ocdb}'", '${start}', '${end}', "HLT","chains=GLOBAL-esd-converter ignore-hltout")' 2>&1|tee recraw-local.log -a
+         mv AliESD* ${iFile}/
+       fi
+       mv syswatch.log ${iFile}/syswatch.log 
+       if [ $iFile -eq 1 ]
+               then
+                       cp 1/syswatch.log syswatch_merged.log
+               else
+                       sed 1d $iFile/syswatch.log >> syswatch_merged.log
+               fi
+       mv *.root ${iFile}/
+  iFile=$((iFile+1))
+done
diff --git a/HLT/global/fladevMacros/rawToHltEsd/config_Flat.C b/HLT/global/fladevMacros/rawToHltEsd/config_Flat.C
new file mode 100644 (file)
index 0000000..cc49402
--- /dev/null
@@ -0,0 +1,36 @@
+void config_Flat( TString directory="outFlat", TString fileName="outFlatHLT.dat")
+{
+
+  cout<<"Now entering config_Flat"<<endl;
+  // set up HLT system to enable configuration registration
+  AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+
+  /*
+  pHLT->LoadComponentLibraries("libESD.so");  
+  pHLT->LoadComponentLibraries("libSTEER.so");  
+  pHLT->LoadComponentLibraries("libSTEERBase.so");  
+  pHLT->LoadComponentLibraries("libAOD.so");  
+  pHLT->LoadComponentLibraries("libANALYSIS.so");  
+  pHLT->LoadComponentLibraries("libANALYSISalice.so");  
+
+  pHLT->LoadComponentLibraries("libHLTbase.so");
+  pHLT->LoadComponentLibraries("libAliHLTUtil.so");
+  pHLT->LoadComponentLibraries("libAliHLTGlobal.so");  
+  */
+
+  /*
+    pHLT->LoadComponentLibraries("libAliHLTMUON.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTPC.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTRD.so");  
+  */
+
+
+  // writer configuration
+  
+
+  // -- The RootFileWriter 
+         AliHLTConfiguration RootWriter("RootWriter", "FileWriter", "GLOBAL-flat-esd-converter", "-directory " + directory + " -datafile " + fileName );
+
+  //pHLT->BuildTaskList("RootWriter");
+  //pHLT->PrintTaskList();
+}
diff --git a/HLT/global/fladevMacros/rawToNormalEsd/command_list.sh b/HLT/global/fladevMacros/rawToNormalEsd/command_list.sh
new file mode 100755 (executable)
index 0000000..abc3f3b
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/bash
+if [ $# -lt 1 ]
+    then
+                       echo "please specify directory with input raw data"
+                       exit
+    else
+                               fileList=$1
+    fi
+    if [ $# -lt 1 ]
+    then
+                       ocdb="local://$OCDB10"
+                       exit
+    else
+                               ocdb=$2
+    fi
+    
+    
+    
+    
+iFile=1
+
+for file in ${fileList}*/raw.root
+do
+  #  dir=${dir%*/}
+  #  echo ${dir##*/}
+  echo "Now processing ${file}"
+  mkdir ${iFile}
+
+        echo "using normal ESD converter"
+        aliroot -b -q ../rec.C'("'${file}'", "'${ocdb}'")' 2>&1|tee rec.log -a
+        mv *.root ${iFile}/
+
+
+       mv syswatch.log ${iFile}/syswatch.log 
+       if [ $iFile -eq 1 ]
+               then
+                       cp 1/syswatch.log syswatch_merged.log
+               else
+                       sed 1d $iFile/syswatch.log >> syswatch_merged.log
+               fi
+  iFile=$((iFile+1))
+done
diff --git a/HLT/global/fladevMacros/rawToNormalEsd/rec.C b/HLT/global/fladevMacros/rawToNormalEsd/rec.C
new file mode 100644 (file)
index 0000000..6beebe5
--- /dev/null
@@ -0,0 +1,97 @@
+void rec(char* input = "raw.root", char* ocdb="local://$OCDB10") {
+  AliReconstruction reco;
+
+       reco.SetInput(input);
+  reco.SetWriteESDfriend();
+  reco.SetWriteAlignmentData();
+  reco.SetFractionFriends(1.0);
+
+  reco.SetRunReconstruction("ITS TPC HLT");
+
+  
+//reco.SetDefaultStorage("local:///home/steffen/gsi/cvmfs/alice.gsi.de/alice/data/2010/OCDB");
+  reco.SetDefaultStorage(ocdb);
+
+  // -------------------------------------------------------
+
+  // ITS (2 objects)
+  reco.SetSpecificStorage("ITS/Align/Data",          "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("ITS/Calib/SPDSparseDead", "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");  
+
+  // MUON (1 object)
+  reco.SetSpecificStorage("MUON/Align/Data",         "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+
+  // TPC (24 objects)
+  reco.SetSpecificStorage("TPC/Align/Data",          "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/PadTime0",      "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/ClusterParam",  "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Pedestals",     "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Parameters",    "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/ExB",           "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Mapping",       "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/PadNoise",      "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/PadGainFactor", "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Temperature",   "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/RecoParam",     "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/TimeGain",      "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/AltroConfig",   "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/CE",            "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Pulser",        "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Distortion",    "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Ref",           "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Raw",           "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/QA",            "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/TimeDrift",     "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Goofie",        "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/HighVoltage",   "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/LaserTracks",   "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual");
+  reco.SetSpecificStorage("TPC/Calib/Correction",    "local:///cvmfs/alice-ocdb.cern.ch/calibration/MC/Residual"); 
+
+  /*
+  // TPC
+  //  reco.SetSpecificStorage("TPC/Calib/GainFactorDedx", "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/PadTime0",       "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Pedestals",      "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Mapping",        "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/PadNoise",       "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/PadGainFactor",  "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/CE",             "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Pulser",         "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Distortion",     "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Ref",            "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Raw",            "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/QA",             "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/Goofie",         "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/HighVoltage",    "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  //  reco.SetSpecificStorage("TPC/Calib/LaserTracks",    "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+
+  // maybe from RAW
+  reco.SetSpecificStorage("TPC/Calib/AltroConfig",    "local:///lustre/alice/alien/alice/simulation/2008/v4-15-Release/Ideal/");
+  */
+
+  // -------------------------------------------------------
+  
+  reco.SetRunPlaneEff(kTRUE);
+  //  reco.SetRecoParam("ZDC",AliZDCRecoParamPbPb::GetHighFluxParam(2760));
+
+  reco.SetRunQA(":") ;
+  
+  // -------------------------------------------------------
+
+Bool_t useHLT= kTRUE;
+
+  if (useHLT)  
+    reco.SetOption("TPC", "useHLT");
+  else
+    reco.SetOption("TPC", "useRAW");
+
+  // -------------------------------------------------------
+
+  TStopwatch timer;
+  timer.Start();
+
+  reco.Run();
+
+  timer.Stop();
+  timer.Print();
+}
diff --git a/HLT/global/fladevMacros/readFlat.sh b/HLT/global/fladevMacros/readFlat.sh
new file mode 100755 (executable)
index 0000000..6faa1dc
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/bash
+if [ $# -lt 1 ]
+    then
+                       verbose=0
+    else
+                               verbose=$1
+    fi
+if [ $# -lt 2 ]
+    then
+                       filename="outFlatESD.dat"
+    else
+                               filename=$2
+    fi
+aliroot -b -l -q $ALICE_ROOT/HLT/global/LoadLibs.C $ALICE_ROOT/HLT/global/ReadFlatESD.C++'("'${filename}'",'${verbose}')' 2>&1| tee readFlat.out
diff --git a/HLT/global/physics/AliHLTAnaManagerComponent.cxx b/HLT/global/physics/AliHLTAnaManagerComponent.cxx
new file mode 100644 (file)
index 0000000..00d6299
--- /dev/null
@@ -0,0 +1,272 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTAnaManagerComponent.cxx $
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: David Rohr, Jens Wiechula, C. Zampolli                *
+ *                                                                        *
+ * 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    AliHLTAnaManagerComponent.cxx
+    @author  David Rohr, Jens Wiechula, C. Zampolli
+    @brief   Component for Testing Analysis Manager inside HLT component
+*/
+
+#include "TMap.h"
+#include "TSystem.h"
+#include "TTimeStamp.h"
+#include "TObjString.h"
+#include "TH1F.h"
+#include "TList.h"
+#include "AliESDtrackCuts.h"
+#include "AliESDEvent.h"
+#include "AliHLTErrorGuard.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTAnaManagerComponent.h"
+#include "AliHLTITSClusterDataFormat.h"
+#include "AliAnalysisManager.h"
+#include "AliHLTTestInputHandler.h"
+#include "AliAnalysisTaskPt.h"
+#include "AliAnalysisDataContainer.h"
+#include "TTree.h"
+
+using namespace std;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTAnaManagerComponent)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+AliHLTAnaManagerComponent::AliHLTAnaManagerComponent() :
+  AliHLTProcessor(),
+  fUID(0),
+  fAnalysisManager(NULL),
+  fInputHandler(NULL){
+  // an example component which implements the ALICE HLT processor
+  // interface and does some analysis on the input raw data
+  //
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+// #################################################################################
+AliHLTAnaManagerComponent::~AliHLTAnaManagerComponent() {
+  // see header file for class documentation
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Public functions to implement AliHLTComponent's interface.
+ * These functions are required for the registration process
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+const Char_t* AliHLTAnaManagerComponent::GetComponentID() { 
+  // see header file for class documentation
+  return "AnaManagerComponent";
+}
+
+// #################################################################################
+void AliHLTAnaManagerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
+  // see header file for class documentation
+  list.push_back(kAliHLTDataTypeESDObject|kAliHLTDataOriginAny);
+  list.push_back(kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD);
+  list.push_back(kAliHLTDataTypeESDContent|kAliHLTDataOriginVZERO);
+  list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginAny);
+}
+
+// #################################################################################
+AliHLTComponentDataType AliHLTAnaManagerComponent::GetOutputDataType() {
+  // see header file for class documentation
+  return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT;
+}
+
+// #################################################################################
+void AliHLTAnaManagerComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
+  // see header file for class documentation
+  constBase = 100000;
+  inputMultiplier = 0.5;
+}
+
+// #################################################################################
+void AliHLTAnaManagerComponent::GetOCDBObjectDescription( TMap* const targetMap) {
+  // see header file for class documentation
+
+  if (!targetMap) return;
+  /*  targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"),
+                new TObjString("configuration object"));
+  targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelationsCentrality"),
+                new TObjString("centrality configuration object"));
+  */
+  return;
+}
+
+// #################################################################################
+AliHLTComponent* AliHLTAnaManagerComponent::Spawn() {
+  // see header file for class documentation
+  return new AliHLTAnaManagerComponent;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Protected functions to implement AliHLTComponent's interface.
+ * These functions provide initialization as well as the actual processing
+ * capabilities of the component. 
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+Int_t AliHLTAnaManagerComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) {
+  // see header file for class documentation
+  printf("AliHLTAnaManagerComponent::DoInit\n");
+
+  Int_t iResult=0;
+
+  Printf("----> AliHLTAnaManagerComponent::DoInit"); 
+  fAnalysisManager = new AliAnalysisManager;
+  fInputHandler    = new AliHLTTestInputHandler;
+  fAnalysisManager->SetInputEventHandler(fInputHandler);
+  fAnalysisManager->SetExternalLoop(kTRUE); 
+
+  AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt");
+  printf("-----> AliHLTAnaManagerComponent: here we set the usage of the friends to %d\n", (Int_t)task->GetUseFriends());
+  task->SetUseFriends(kTRUE);
+  fAnalysisManager->AddTask(task);
+  AliAnalysisDataContainer *cinput  = fAnalysisManager->GetCommonInputContainer();
+  Printf("Defining output file");
+  AliAnalysisDataContainer *coutput1 = fAnalysisManager->CreateContainer("pt", TList::Class(),
+      AliAnalysisManager::kOutputContainer, "Pt.ESD.root");
+
+  //           connect containers
+  Printf("---> Connecting input...");
+  fAnalysisManager->ConnectInput  (task,  0, cinput ); 
+  Printf("---> ...connected.");
+  Printf("---> Connecting output...");
+  fAnalysisManager->ConnectOutput (task,  0, coutput1);
+  Printf("---> ...connected.");
+
+  Printf("----> Calling InitAnalysis");
+  fAnalysisManager->InitAnalysis();
+  Printf("----> Done.");
+  Printf("----> Calling StartAnalysis");
+  fAnalysisManager->StartAnalysis("local", (TTree*)new TTree);
+  //fAnalysisManager->StartAnalysis("local", (TTree*)NULL);
+  Printf("----> Done.");
+
+  return iResult;
+}
+
+
+
+// #################################################################################
+Int_t AliHLTAnaManagerComponent::DoDeinit() {
+  // see header file for class documentation
+
+  fUID = 0;
+  fAnalysisManager->SetSkipTerminate(kTRUE);
+  fAnalysisManager->Terminate();
+
+  delete fAnalysisManager;
+
+  return 0;
+}
+
+// #################################################################################
+Int_t AliHLTAnaManagerComponent::DoEvent(const AliHLTComponentEventData& evtData,
+                                       AliHLTComponentTriggerData& /*trigData*/) {
+  // see header file for class documentation
+
+  printf("AliHLTAnaManagerComponent::DoEvent\n");
+  Int_t iResult=0;
+
+  // -- Only use data event
+  if (!IsDataEvent()) 
+    return 0;
+  
+  if( fUID == 0 ){
+    TTimeStamp t;
+    fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
+  }
+  
+  // -- Get ESD object
+  // -------------------
+  AliESDEvent *esdEvent = NULL;
+  AliESDfriend *esdFriend = NULL;
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
+    esdEvent = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
+    if( !esdEvent ){ 
+      HLTWarning("Wrong ESDEvent object received");
+      iResult = -1;
+      continue;
+    }
+    esdEvent->GetStdContent();
+  }
+  printf("----> ESDEvent %p has %d tracks: \n", esdEvent, esdEvent->GetNumberOfTracks());
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject); iter != NULL; iter = GetNextInputObject() ) {
+    esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>( iter ) );
+    if( !esdFriend ){ 
+      HLTWarning("Wrong ESDFriend object received");
+      iResult = -1;
+      continue;
+    }
+  }
+  printf("----> ESDFriend %p has %d tracks: \n", esdFriend, esdFriend->GetNumberOfTracks());
+
+  fAnalysisManager->InitInputData(esdEvent, esdFriend);
+  //  fInputHandler->BeginEvent(0);
+  fAnalysisManager->ExecAnalysis();
+  fInputHandler->FinishEvent();
+
+
+  // -- Send histlist
+//  PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()),
+//        kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,fUID);
+  return iResult;
+}
+
+// #################################################################################
+Int_t AliHLTAnaManagerComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
+  // see header file for class documentation
+
+  Int_t iResult=0;
+  TString cdbPath;
+  if (cdbEntry) {
+    cdbPath=cdbEntry;
+  } else {
+    cdbPath="HLT/ConfigGlobal/";
+    cdbPath+=GetComponentID();
+  }
+
+  AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
+  iResult=ConfigureFromCDBTObjString(cdbPath);
+
+  return iResult;
+}
+
+// #################################################################################
+Int_t AliHLTAnaManagerComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
+  // see header file for class documentation
+  ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
+  return 0;
+}
+
diff --git a/HLT/global/physics/AliHLTAnaManagerComponent.h b/HLT/global/physics/AliHLTAnaManagerComponent.h
new file mode 100644 (file)
index 0000000..1d7ab17
--- /dev/null
@@ -0,0 +1,230 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTAnaManagerComponent $
+
+#ifndef ALIHLTANAMANAGERCOMPONENT_H
+#define ALIHLTANAMANAGERCOMPONENT_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    AliHLTAnaManagerComponent.h
+    @author  Jochen Thaeder <jochen@thaeder.de>
+    @brief   Component for Multiplicty Correlations
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+
+class TH1F;
+class TList;
+
+class AliESDVZERO;
+class AliESDtrackCuts;
+class AliHLTCTPData;
+class AliHLTMultiplicityCorrelations;
+class AliHLTGlobalTriggerDecision;
+class AliAnalysisManager;
+class AliHLTTestInputHandler;
+
+/**
+ * @class AliHLTAnaManagerComponent
+ * Create Correlations for Multiplicities
+ * 
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b MultiplicityCorrelations <br>
+ * Library: \b libAliHLTGlobal.so     <br>
+ * Input Data Types:  @ref kAliHLTDataTypeESDObject <br>
+ * Output Data Types: @ref kAliHLTDataTypeTObject|kAliHLTDataOriginHLT <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> 
+ *
+ * <h2>Optional arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li -minpt    <i> pt  </i> <br>
+ *      minimum pt - pt range
+ * \li -maxpt    <i> pt  </i> <br>
+ *      maximum pt - pt range
+ * \li -min-ldca    <i> dca  </i> <br>
+ *      minimum longitudinal dca to reference point
+ * \li -max-ldca    <i> dca  </i> <br>
+ *      maximum longitudinal dca to reference point
+ * \li -min-tdca    <i> dca  </i> <br>
+ *      minimum transverse dca to reference point
+ * \li -max-tdca    <i> dca  </i> <br>
+ *      maximum transverse dca to reference point
+ * \li -etarange    <i> eta  </i> <br>
+ *      +/- eta range
+ *
+ * \li -binningVzero    <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningTpc      <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZdc      <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZnp     <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZem     <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningCalo    <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ *
+ * \li -addTrigger     <i> TriggerClass beginning (eg CPBI1)  </i> <br>
+
+ * <h2>Default CDB entries:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <tt>HLT/ConfigGlobal/MultiplicityCorrelations</tt>
+ * \li -TObjString object holding a string with the configuration parameters
+ *      currently empty 
+ *
+ * <h2>Performance:</h2>
+ *
+ * <h2>Memory consumption:</h2>
+ *
+ * <h2>Input size:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li pp: 
+ *
+ * <h2>Output size:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li pp: Average : 
+ *
+ * <h2>Macros Tests</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <tt>macros/makeConfigurationObjectMultiplicityCorrelations.C</tt>
+ * \li - Create configuration TObjString
+ *
+ * <tt>macros/HLTMultiplicityCorrelationsTest.C</tt>
+ * \li - Test macro for test in off-line environment
+ *
+ * <tt>macros/runMultiplicityCorrelationsTest.sh</tt>
+ * \li - Run Test macro HLTMultiplicityCorrelationsTest.C
+ *
+ * @ingroup alihlt_physics
+ */
+class AliHLTAnaManagerComponent : public AliHLTProcessor {
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** constructor */
+  AliHLTAnaManagerComponent();
+  
+  /** destructor */
+  virtual ~AliHLTAnaManagerComponent();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Public functions to implement AliHLTComponent's interface.
+   * These functions are required for the registration process
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** interface function, see @ref AliHLTComponent for description */
+  const Char_t* GetComponentID();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOCDBObjectDescription( TMap* const targetMap);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+ protected:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Protected functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  // AliHLTComponent interface functions
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoInit( Int_t /*argc*/, const Char_t** /*argv*/ );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoDeinit();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+
+  using AliHLTProcessor::DoEvent;
+
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t Reconfigure(const Char_t* cdbEntry, const Char_t* chainId);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t ReadPreprocessorValues(const Char_t* modules);
+  ///////////////////////////////////////////////////////////////////////////////////
+  
+private:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Private functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** copy constructor prohibited */
+  AliHLTAnaManagerComponent(const AliHLTAnaManagerComponent&);
+
+  /** assignment operator prohibited */
+  AliHLTAnaManagerComponent& operator=(const AliHLTAnaManagerComponent&);
+
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                              Helper
+   * ---------------------------------------------------------------------------------
+   */
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Members - private
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** UID for merging */
+  AliHLTUInt32_t fUID;                        // see above
+
+  AliAnalysisManager *fAnalysisManager;        // Manger
+
+  AliHLTTestInputHandler *fInputHandler;    // input handler
+
+  ClassDef(AliHLTAnaManagerComponent, 0)
+};
+#endif
diff --git a/HLT/global/physics/AliHLTFlatAnaManagerComponent.cxx b/HLT/global/physics/AliHLTFlatAnaManagerComponent.cxx
new file mode 100644 (file)
index 0000000..973d79e
--- /dev/null
@@ -0,0 +1,292 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTFlatAnaManagerComponent.cxx $
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: David Rohr, Jens Wiechula, C. Zampolli                *
+ *                                                                        *
+ * 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    AliHLTFlatAnaManagerComponent.cxx
+    @author  David Rohr, Jens Wiechula, C. Zampolli
+    @brief   Component for Testing Analysis Manager inside HLT component
+*/
+
+#include "TMap.h"
+#include "TSystem.h"
+#include "TTimeStamp.h"
+#include "TObjString.h"
+#include "TH1F.h"
+#include "TList.h"
+#include "AliESDtrackCuts.h"
+#include "AliFlatESDEvent.h"
+#include "AliESDfriend.h"
+#include "AliHLTErrorGuard.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTFlatAnaManagerComponent.h"
+#include "AliHLTITSClusterDataFormat.h"
+#include "AliAnalysisManager.h"
+#include "AliHLTTestInputHandler.h"
+#include "AliAnalysisTaskPt.h"
+#include "AliAnalysisDataContainer.h"
+#include "TTree.h"
+
+using namespace std;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTFlatAnaManagerComponent)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+AliHLTFlatAnaManagerComponent::AliHLTFlatAnaManagerComponent() :
+  AliHLTProcessor(),
+  fUID(0),
+  fAnalysisManager(NULL),
+  fInputHandler(NULL){
+  // an example component which implements the ALICE HLT processor
+  // interface and does some analysis on the input raw data
+  //
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  //
+  // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+// #################################################################################
+AliHLTFlatAnaManagerComponent::~AliHLTFlatAnaManagerComponent() {
+  // see header file for class documentation
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Public functions to implement AliHLTComponent's interface.
+ * These functions are required for the registration process
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+const Char_t* AliHLTFlatAnaManagerComponent::GetComponentID() { 
+  // see header file for class documentation
+  return "FlatAnaManagerComponent";
+}
+
+// #################################################################################
+void AliHLTFlatAnaManagerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
+  // see header file for class documentation
+  list.push_back(kAliHLTDataTypeFlatESD|kAliHLTDataOriginAny);
+  //  list.push_back(kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginAny);
+}
+
+// #################################################################################
+AliHLTComponentDataType AliHLTFlatAnaManagerComponent::GetOutputDataType() {
+  // see header file for class documentation
+  return kAliHLTDataTypeTObject|kAliHLTDataOriginHLT;
+}
+
+// #################################################################################
+void AliHLTFlatAnaManagerComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
+  // see header file for class documentation
+  constBase = 100000;
+  inputMultiplier = 0.5;
+}
+
+// #################################################################################
+void AliHLTFlatAnaManagerComponent::GetOCDBObjectDescription( TMap* const targetMap) {
+  // see header file for class documentation
+
+  if (!targetMap) return;
+  /*  targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelations"),
+                new TObjString("configuration object"));
+  targetMap->Add(new TObjString("HLT/ConfigGlobal/MultiplicityCorrelationsCentrality"),
+                new TObjString("centrality configuration object"));
+  */
+  return;
+}
+
+// #################################################################################
+AliHLTComponent* AliHLTFlatAnaManagerComponent::Spawn() {
+  // see header file for class documentation
+  return new AliHLTFlatAnaManagerComponent;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ * Protected functions to implement AliHLTComponent's interface.
+ * These functions provide initialization as well as the actual processing
+ * capabilities of the component. 
+ * ---------------------------------------------------------------------------------
+ */
+
+// #################################################################################
+Int_t AliHLTFlatAnaManagerComponent::DoInit( Int_t /*argc*/, const Char_t** /*argv*/ ) {
+  // see header file for class documentation
+  printf("AliHLTFlatAnaManagerComponent::DoInit\n");
+
+  Int_t iResult=0;
+
+  Printf("----> AliHLTFlatAnaManagerComponent::DoInit"); 
+  fAnalysisManager = new AliAnalysisManager;
+  fInputHandler    = new AliHLTTestInputHandler;
+  fAnalysisManager->SetInputEventHandler(fInputHandler);
+  fAnalysisManager->SetExternalLoop(kTRUE); 
+
+  AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt");
+  task->SetUseFriends(kFALSE);
+  fAnalysisManager->AddTask(task);
+  AliAnalysisDataContainer *cinput  = fAnalysisManager->GetCommonInputContainer();
+  Printf("Defining output file");
+  AliAnalysisDataContainer *coutput1 = fAnalysisManager->CreateContainer("pt", TList::Class(),
+      AliAnalysisManager::kOutputContainer, "Pt.ESD.root");
+
+  //           connect containers
+  Printf("---> Connecting input...");
+  fAnalysisManager->ConnectInput  (task,  0, cinput ); 
+  Printf("---> ...connected.");
+  Printf("---> Connecting output...");
+  fAnalysisManager->ConnectOutput (task,  0, coutput1);
+  Printf("---> ...connected.");
+
+  Printf("----> Calling InitAnalysis");
+  fAnalysisManager->InitAnalysis();
+  Printf("----> Done.");
+  Printf("----> Calling StartAnalysis");
+  fAnalysisManager->StartAnalysis("local", (TTree*)new TTree);
+  //fAnalysisManager->StartAnalysis("local", (TTree*)NULL);
+  Printf("----> Done.");
+
+  return iResult;
+}
+
+
+
+// #################################################################################
+Int_t AliHLTFlatAnaManagerComponent::DoDeinit() {
+  // see header file for class documentation
+
+  fUID = 0;
+  fAnalysisManager->SetSkipTerminate(kTRUE);
+  fAnalysisManager->Terminate();
+
+  delete fAnalysisManager;
+
+  return 0;
+}
+
+// #################################################################################
+Int_t AliHLTFlatAnaManagerComponent::DoEvent(const AliHLTComponentEventData& evtData,
+                                       AliHLTComponentTriggerData& /*trigData*/) {
+  // see header file for class documentation
+
+  printf("AliHLTFlatAnaManagerComponent::DoEvent\n");
+  Int_t iResult=0;
+
+  // -- Only use data event
+  if (!IsDataEvent()) {
+    Printf("-------> no data event");
+    return 0;
+  }
+  
+  if( fUID == 0 ){
+    TTimeStamp t;
+    fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
+  }
+  
+  Bool_t isESDfound = kFALSE;
+  // -- Get ESD object
+  // -------------------
+  AliFlatESDEvent *esdEvent = NULL;
+  AliESDfriend *esdFriend = NULL;
+  Int_t dataBlockIndex = 0;
+  for ( const AliHLTComponentBlockData *iter = GetFirstInputBlock(kAliHLTDataTypeFlatESD); iter != NULL; iter = GetNextInputBlock() ) {
+    if(iter->fDataType != kAliHLTDataTypeFlatESD) {
+      Printf("Data type of block is not flatESD");
+      continue;
+    }
+    dataBlockIndex++;
+    Printf("----> dataBlockIndex = %d", dataBlockIndex);
+    //iter->Print();
+    esdEvent = (AliFlatESDEvent*)(iter->fPtr);
+    if( !esdEvent ){ 
+      HLTWarning("Wrong ESDEvent object received");
+      Printf("Current object is not ESD event");
+      iResult = -1;
+      continue;
+    }
+    else isESDfound = kTRUE;
+    //    esdEvent->GetStdContent();
+  }
+  if (!isESDfound) {
+    Printf("-------> no ESD found!!");
+    return 0;
+  }
+  printf("----> ESDEvent %p has %d tracks: \n", esdEvent, esdEvent->GetNumberOfTracks());
+
+  /* // no friends for teh time being... 
+  for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject); iter != NULL; iter = GetNextInputObject() ) {
+    esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>( iter ) );
+    if( !esdFriend ){ 
+      HLTWarning("Wrong ESDFriend object received");
+      iResult = -1;
+      continue;
+    }
+  }
+  printf("----> ESDFriend %p has %d tracks: \n", esdFriend, esdFriend->GetNumberOfTracks());
+  */
+  fAnalysisManager->InitInputData(esdEvent, esdFriend);
+  //  fInputHandler->BeginEvent(0);
+  fAnalysisManager->ExecAnalysis();
+  fInputHandler->FinishEvent();
+
+
+  // -- Send histlist
+//  PushBack(dynamic_cast<TObject*>(fCorrObj->GetHistList()),
+//        kAliHLTDataTypeTObject|kAliHLTDataOriginHLT,fUID);
+  return iResult;
+}
+
+// #################################################################################
+Int_t AliHLTFlatAnaManagerComponent::Reconfigure(const Char_t* cdbEntry, const Char_t* chainId) {
+  // see header file for class documentation
+
+  Int_t iResult=0;
+  TString cdbPath;
+  if (cdbEntry) {
+    cdbPath=cdbEntry;
+  } else {
+    cdbPath="HLT/ConfigGlobal/";
+    cdbPath+=GetComponentID();
+  }
+
+  TString strcdb = "";
+  if (!cdbEntry) strcdb = "default";
+  Printf("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), strcdb.Data());
+  //AliInfoClass(Form("reconfigure '%s' from entry %s%s", chainId, cdbPath.Data(), cdbEntry?"":" (default)"));
+  iResult=ConfigureFromCDBTObjString(cdbPath);
+
+  return iResult;
+}
+
+// #################################################################################
+Int_t AliHLTFlatAnaManagerComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
+  // see header file for class documentation
+  ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
+  return 0;
+}
+
diff --git a/HLT/global/physics/AliHLTFlatAnaManagerComponent.h b/HLT/global/physics/AliHLTFlatAnaManagerComponent.h
new file mode 100644 (file)
index 0000000..faa18df
--- /dev/null
@@ -0,0 +1,230 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTFlatAnaManagerComponent $
+
+#ifndef ALIHLTFLATANAMANAGERCOMPONENT_H
+#define ALIHLTFLATANAMANAGERCOMPONENT_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    AliHLTFlatAnaManagerComponent.h
+    @author  Jochen Thaeder <jochen@thaeder.de>
+    @brief   Component for Multiplicty Correlations
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+
+class TH1F;
+class TList;
+
+class AliESDVZERO;
+class AliESDtrackCuts;
+class AliHLTCTPData;
+class AliHLTMultiplicityCorrelations;
+class AliHLTGlobalTriggerDecision;
+class AliAnalysisManager;
+class AliHLTTestInputHandler;
+
+/**
+ * @class AliHLTFlatAnaManagerComponent
+ * Create Correlations for Multiplicities
+ * 
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b MultiplicityCorrelations <br>
+ * Library: \b libAliHLTGlobal.so     <br>
+ * Input Data Types:  @ref kAliHLTDataTypeESDObject <br>
+ * Output Data Types: @ref kAliHLTDataTypeTObject|kAliHLTDataOriginHLT <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> 
+ *
+ * <h2>Optional arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li -minpt    <i> pt  </i> <br>
+ *      minimum pt - pt range
+ * \li -maxpt    <i> pt  </i> <br>
+ *      maximum pt - pt range
+ * \li -min-ldca    <i> dca  </i> <br>
+ *      minimum longitudinal dca to reference point
+ * \li -max-ldca    <i> dca  </i> <br>
+ *      maximum longitudinal dca to reference point
+ * \li -min-tdca    <i> dca  </i> <br>
+ *      minimum transverse dca to reference point
+ * \li -max-tdca    <i> dca  </i> <br>
+ *      maximum transverse dca to reference point
+ * \li -etarange    <i> eta  </i> <br>
+ *      +/- eta range
+ *
+ * \li -binningVzero    <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningTpc      <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZdc      <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZnp     <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningZem     <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ * \li -binningCalo    <i> bins min max  </i> <br>
+ *       bins (Int_t), minBin (Float_t), maxBin (Float_t)
+ *
+ * \li -addTrigger     <i> TriggerClass beginning (eg CPBI1)  </i> <br>
+
+ * <h2>Default CDB entries:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <tt>HLT/ConfigGlobal/MultiplicityCorrelations</tt>
+ * \li -TObjString object holding a string with the configuration parameters
+ *      currently empty 
+ *
+ * <h2>Performance:</h2>
+ *
+ * <h2>Memory consumption:</h2>
+ *
+ * <h2>Input size:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li pp: 
+ *
+ * <h2>Output size:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * \li pp: Average : 
+ *
+ * <h2>Macros Tests</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <tt>macros/makeConfigurationObjectMultiplicityCorrelations.C</tt>
+ * \li - Create configuration TObjString
+ *
+ * <tt>macros/HLTMultiplicityCorrelationsTest.C</tt>
+ * \li - Test macro for test in off-line environment
+ *
+ * <tt>macros/runMultiplicityCorrelationsTest.sh</tt>
+ * \li - Run Test macro HLTMultiplicityCorrelationsTest.C
+ *
+ * @ingroup alihlt_physics
+ */
+class AliHLTFlatAnaManagerComponent : public AliHLTProcessor {
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** constructor */
+  AliHLTFlatAnaManagerComponent();
+  
+  /** destructor */
+  virtual ~AliHLTFlatAnaManagerComponent();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Public functions to implement AliHLTComponent's interface.
+   * These functions are required for the registration process
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** interface function, see @ref AliHLTComponent for description */
+  const Char_t* GetComponentID();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  void GetOCDBObjectDescription( TMap* const targetMap);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+ protected:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Protected functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  // AliHLTComponent interface functions
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoInit( Int_t /*argc*/, const Char_t** /*argv*/ );
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoDeinit();
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+
+  using AliHLTProcessor::DoEvent;
+
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t Reconfigure(const Char_t* cdbEntry, const Char_t* chainId);
+
+  /** interface function, see @ref AliHLTComponent for description */
+  Int_t ReadPreprocessorValues(const Char_t* modules);
+  ///////////////////////////////////////////////////////////////////////////////////
+  
+private:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   * Private functions to implement AliHLTComponent's interface.
+   * These functions provide initialization as well as the actual processing
+   * capabilities of the component. 
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** copy constructor prohibited */
+  AliHLTFlatAnaManagerComponent(const AliHLTFlatAnaManagerComponent&);
+
+  /** assignment operator prohibited */
+  AliHLTFlatAnaManagerComponent& operator=(const AliHLTFlatAnaManagerComponent&);
+
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                              Helper
+   * ---------------------------------------------------------------------------------
+   */
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Members - private
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** UID for merging */
+  AliHLTUInt32_t fUID;                        // see above
+
+  AliAnalysisManager *fAnalysisManager;        // Manger
+
+  AliHLTTestInputHandler *fInputHandler;    // input handler
+
+  ClassDef(AliHLTFlatAnaManagerComponent, 0)
+};
+#endif
diff --git a/HLT/global/physics/macros/README_AliHLTAnaManagerComponent b/HLT/global/physics/macros/README_AliHLTAnaManagerComponent
new file mode 100644 (file)
index 0000000..383aa97
--- /dev/null
@@ -0,0 +1,22 @@
+To run an example using the AliHLTAnaManagerComponent, please, run:
+
+rm galice.root; aliroot -b -q -l testconfig.C'("GLOBAL-esd-converter")' $ALICE_ROOT/HLT/exa/recraw-local.C'("raw.root","local://$ALICE_ROOT/OCDB", 0, 10, "HLT", "chains=RootWriter ignore-hltout")' 2>&1| tee recHLT.log
+
+Note that you need to have a raw.root file in your folder.
+
+
+*******************************************************************************
+
+To run an example using the AliHLTFlatAnaManagerComponent, please, run:
+
+rm galice.root; aliroot -b -q -l testconfigFlat.C'("GLOBAL-flat-esd-converter")' $ALICE_ROOT/HLT/exa/recraw-local.C'("raw.root","local://$ALICE_ROOT/OCDB", 0, 10, "HLT", "chains=RootWriter ignore-hltout")' 2>&1| tee recHLT.log
+
+Note that you need to have a raw.root file in your folder.
+
+
+*******************************************************************************
+
+To run the same AliAnalysisPtTask but on Offline ESDs (that you need locally, optionally with the 
+friends) run:
+
+aliroot -b -q runTaskOffline.C
diff --git a/HLT/global/physics/macros/runTaskOffline.C b/HLT/global/physics/macros/runTaskOffline.C
new file mode 100644 (file)
index 0000000..a247a08
--- /dev/null
@@ -0,0 +1,54 @@
+void runTaskOffline()
+{
+  // load analysis framework
+  gSystem->Load("libANALYSISalice");
+
+  gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
+
+  // for includes use either global setting in $HOME/.rootrc
+  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
+  // or in each macro
+  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
+  gROOT->Macro("$ALICE_ROOT/PWGPP/CalibMacros/CPass0/LoadLibraries.C");
+
+  // Create the analysis manager
+  AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
+
+  // Add ESD input handler
+  AliESDInputHandler* esdH = new AliESDInputHandler();
+  esdH->SetReadFriends(kTRUE);
+  esdH->SetActiveBranches("ESDfriend");
+
+  // Register input handler to manager
+  mgr->SetInputEventHandler(esdH);
+
+  // Create task
+
+  //gROOT->LoadMacro("AliAnalysisTaskPt.cxx+g");
+  AliAnalysisTaskPt *task = new AliAnalysisTaskPt("TaskPt");
+  task->SetUseFriends(kTRUE);
+  
+  // Add task
+  mgr->AddTask(task);
+
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+  AliAnalysisDataContainer *coutput = mgr->CreateContainer("chist", TList::Class(),    AliAnalysisManager::kOutputContainer, "Pt.ESD.1.root");
+
+  // Connect input/output
+  mgr->ConnectInput(task, 0, cinput);
+  mgr->ConnectOutput(task, 0, coutput);
+
+  // Enable debug printouts
+  mgr->SetDebugLevel(2);
+
+  if (!mgr->InitAnalysis())
+    return;
+
+  mgr->PrintStatus();
+
+  TChain *chain1 = new TChain("esdTree");
+  chain1->Add("AliESDs.root");
+
+  mgr->StartAnalysis("local", chain1);
+}
diff --git a/HLT/global/physics/macros/testconfig.C b/HLT/global/physics/macros/testconfig.C
new file mode 100644 (file)
index 0000000..00e1a72
--- /dev/null
@@ -0,0 +1,38 @@
+void testconfig(const char* parent = "GLOBAL-esd-converter")
+{
+  // set up HLT system to enable configuration registration
+  AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+
+  //pHLT->LoadComponentLibraries("libANALYSIS.so");  
+  //pHLT->LoadComponentLibraries("libANALYSISalice.so");  
+  /*
+  pHLT->LoadComponentLibraries("libESD.so");  
+  pHLT->LoadComponentLibraries("libSTEER.so");  
+  pHLT->LoadComponentLibraries("libSTEERBase.so");  
+  pHLT->LoadComponentLibraries("libAOD.so");  
+  pHLT->LoadComponentLibraries("libANALYSIS.so");  
+  pHLT->LoadComponentLibraries("libANALYSISalice.so");  
+
+  pHLT->LoadComponentLibraries("libHLTbase.so");
+  pHLT->LoadComponentLibraries("libAliHLTUtil.so");
+  pHLT->LoadComponentLibraries("libAliHLTGlobal.so");  
+  */
+
+  /*
+    pHLT->LoadComponentLibraries("libAliHLTMUON.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTPC.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTRD.so");  
+  */
+
+
+  // writer configuration
+  AliHLTConfiguration calib("test" , "AnaManagerComponent" , parent , "");
+
+  TString writerArg(Form("-directory testDir -datafile test.root"));
+
+  // -- The RootFileWriter 
+  AliHLTConfiguration rootWriter("RootWriter", "ROOTFileWriter", "test", writerArg.Data() );
+
+  //pHLT->BuildTaskList("RootWriter");
+  //pHLT->PrintTaskList();
+}
diff --git a/HLT/global/physics/macros/testconfigFlat.C b/HLT/global/physics/macros/testconfigFlat.C
new file mode 100644 (file)
index 0000000..72057ff
--- /dev/null
@@ -0,0 +1,38 @@
+void testconfigFlat(const char* parent = "GLOBAL-esd-converter")
+{
+  // set up HLT system to enable configuration registration
+  AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+
+  //pHLT->LoadComponentLibraries("libANALYSIS.so");  
+  //pHLT->LoadComponentLibraries("libANALYSISalice.so");  
+  /*
+  pHLT->LoadComponentLibraries("libESD.so");  
+  pHLT->LoadComponentLibraries("libSTEER.so");  
+  pHLT->LoadComponentLibraries("libSTEERBase.so");  
+  pHLT->LoadComponentLibraries("libAOD.so");  
+  pHLT->LoadComponentLibraries("libANALYSIS.so");  
+  pHLT->LoadComponentLibraries("libANALYSISalice.so");  
+
+  pHLT->LoadComponentLibraries("libHLTbase.so");
+  pHLT->LoadComponentLibraries("libAliHLTUtil.so");
+  pHLT->LoadComponentLibraries("libAliHLTGlobal.so");  
+  */
+
+  /*
+    pHLT->LoadComponentLibraries("libAliHLTMUON.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTPC.so");  
+    pHLT->LoadComponentLibraries("libAliHLTTRD.so");  
+  */
+
+
+  // writer configuration
+  AliHLTConfiguration calib("test" , "FlatAnaManagerComponent" , parent , "");
+
+  TString writerArg(Form("-directory testDir -datafile test.root"));
+
+  // -- The RootFileWriter 
+  AliHLTConfiguration rootWriter("RootWriter", "ROOTFileWriter", "test", writerArg.Data() );
+
+  //pHLT->BuildTaskList("RootWriter");
+  //pHLT->PrintTaskList();
+}
index f3c8501269c1e61df6f9ecb72fda32c68130cee1..3cfd2cf2a0aa7026dd188647f741aed707b7cc9e 100644 (file)
@@ -72,6 +72,7 @@ public:
   Double_t GetD(Double_t x, Double_t y) const {
     return AliExternalTrackParam::GetD(x,y,GetBz());
   }
+  using AliExternalTrackParam::GetDZ;
   void GetDZ(Double_t xv, Double_t yv, Double_t zv, Float_t dz[2]) const {
     return AliExternalTrackParam::GetDZ(xv,yv,zv,GetBz(),dz);
   }
index 66f70879b0edcd73b7e9aa3a0838490775bb0415..131845d08ff25194b9f0b8efbfa1e697261c89f6 100644 (file)
@@ -143,7 +143,7 @@ public:
   //
   template <typename T> void GetP(T *p) const {
     p[0]=Pt(); p[1]=Phi(); p[2]=Theta();}
-
+  //using AliVVtrack::GetP;
   //  template <typename T> void GetPxPyPz(T *p) const {
   //    p[0] = Px(); p[1] = Py(); p[2] = Pz();}
   Bool_t GetPxPyPz(Double_t *p) const;
@@ -165,6 +165,7 @@ public:
   Bool_t GetXYZ(Double_t *p) const {
     return GetPosition(p); }
   
+  //using AliVVtrack::GetXYZ;
   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t *r) const;
   
   Bool_t GetCovarianceXYZPxPyPz(Double_t /*cv*/[21]) const {AliFatal("Not implemented"); return 0;}
index 1e304629a47b8e20c413100bd6585d49373efe5e..997ec3cb256ce603ee70c32c6c0b52e413836448 100644 (file)
@@ -622,7 +622,7 @@ void AliAnalysisTaskEMCALClusterizeFast::TrackClusterMatching(AliVCluster *c, TC
     AliVTrack *track = static_cast<AliVTrack*>(tarr->At(t));
     if (!track)
       continue;
-    const AliExternalTrackParam *outp = track->GetOuterParam();
+    const AliExternalTrackParam *outp = dynamic_cast<const AliExternalTrackParam*>(track->GetOuterParam());
     if (!outp)
       continue;
     Double_t trkPos[3] = {0.,0.,0.};
index 00dac4e759d0615c92190619cf50f10c4e550f49..93ff68da84dd65071362ac6b5998c912da4aa9b7 100644 (file)
@@ -21,6 +21,7 @@ class AliPicoTrack: public AliVTrack {
   Double_t        Pz()                        const { return fPt*TMath::SinH(fEta); }
   Double_t        Pt()                        const { return fPt;                   }
   Double_t        P()                         const { return fPt*TMath::CosH(fEta); }
+  
   Bool_t          PxPyPz(Double_t p[3])       const { p[0]=Px();p[1]=Py();p[2]=Pz(); return 1;         }
   Bool_t          GetPxPyPz(Double_t p[3])    const { p[0]=Px();p[1]=Py();p[2]=Pz(); return 1;         }
   Double_t        Xv()                        const { return 0.;      }
@@ -50,6 +51,7 @@ class AliPicoTrack: public AliVTrack {
   Bool_t          IsEMCAL()                   const { return fEmcal;  }
   ULong_t         GetStatus()                 const { return 0;       }
   Bool_t          GetXYZ(Double_t *v)         const { v[0]=0; v[1]=0; v[2]=0; return 0; }
+  using AliVTrack::GetXYZ;
   Double_t        GetBz()                     const { return 0;       }
   void            GetBxByBz(Double_t b[3])    const { b[0]=0;b[1]=0;b[2]=0; }
   Bool_t          GetCovarianceXYZPxPyPz(Double_t /*cv*/[21]) const { return 0; }
index f6c17cf3113f0a97e4014f3f4e7c304471cd059e..c035861fdecfd9014850b7760b25d621999921f9 100644 (file)
@@ -31,7 +31,6 @@ class AliVEvent;
 class AliMultiplicity; 
 class AliAODTracklets;  // XZhang 20120615
 class AliAODTrack;
-class AliESDtrack;
 class AliESDPmdTrack;
 class AliFlowBayesianPID;
 class AliESDkink;
index eddf240c0af4ef1cc6732458d407e22dc620b4f9..b00740ac4eaac2b542b336cc56cb3a3adf55daa0 100644 (file)
@@ -43,6 +43,7 @@ class AliAODVertex;
 class AliVertexerTracks;
 class AliESDv0; 
 class AliAODv0; 
+class AliExternalTrackParam;
 
 //-----------------------------------------------------------------------------
 class AliAnalysisVertexingHF : public TNamed {
index e0eddc8dca13ad0305bfa9d31da12fedf61e6570..d23bcf8de245c4ae49ca94e3d924899513165ddc 100644 (file)
@@ -68,7 +68,7 @@ class AliEmcalJet : public AliVParticle
   Short_t           ClusterAt(Int_t idx)         const { return fClusterIDs.At(idx);       }
   AliVCluster      *ClusterAt(Int_t idx, TClonesArray *ca)  const { if (!ca) return 0; return dynamic_cast<AliVCluster*>(ca->At(ClusterAt(idx))); }
   AliVCluster      *GetLeadingCluster(TClonesArray *clusters) const;
-  UShort_t          GetNumberOfClusters()        const { return fClusterIDs.GetSize();     }
+  Int_t          GetNumberOfClusters()        const { return fClusterIDs.GetSize();     }
   UShort_t          GetNumberOfTracks()          const { return fTrackIDs.GetSize();       }
   UShort_t          GetNumberOfConstituents()    const { return GetNumberOfClusters()+GetNumberOfTracks();       }
   Double_t          FracEmcalArea()              const { return fAreaEmc/fArea;            }
index 72099e929d5645b3445a6f5bc8ccebf49d89082b..ad1be63b1bcbbdb09fff1d37f3e72f846148d28f 100644 (file)
@@ -1074,3 +1074,5 @@ void AliAODEvent::ConnectTracks() {
   fTracksConnected = kTRUE;
 }
 
+AliVEvent::EDataLayoutType AliAODEvent::GetDataLayoutType() const {return AliVEvent::kAOD;}
+
index 1e078370893c7fe4f091f2349c4613fc8a508f5a..a4af17438cb20d15b3149240071fd5105e948f6e 100644 (file)
@@ -158,6 +158,8 @@ class AliAODEvent : public AliVEvent {
   {new((*fVertices)[fVertices->GetEntriesFast()]) AliAODVertex(*vtx); return fVertices->GetEntriesFast()-1;}
   
   // primary vertex
+  using AliVEvent::GetPrimaryVertex;
+  using AliVEvent::GetPrimaryVertexSPD;
   virtual AliAODVertex *GetPrimaryVertex() const { return GetVertex(0); }
   virtual AliAODVertex *GetPrimaryVertexSPD() const;
 
@@ -173,6 +175,7 @@ class AliAODEvent : public AliVEvent {
   // V0
   TClonesArray *GetV0s()                 const { return fV0s; }
   Int_t         GetNumberOfV0s()         const { return fV0s->GetEntriesFast(); }
+  using AliVEvent::GetV0;
   AliAODv0     *GetV0(Int_t nV0)         const { return (AliAODv0*)fV0s->UncheckedAt(nV0); }
   Int_t         AddV0(const AliAODv0* v0)
   {new((*fV0s)[fV0s->GetEntriesFast()]) AliAODv0(*v0); return fV0s->GetEntriesFast()-1;}
@@ -309,6 +312,7 @@ class AliAODEvent : public AliVEvent {
   //ZDC
   AliAODZDC   *GetZDCData() const { return fAODZDC; }
 
+  virtual AliVEvent::EDataLayoutType GetDataLayoutType() const;
 
   private :
 
index 8525e7ad35a151a81861fd364d5f719ed023a17e..8bd7db45252b05f1f9605cab551d9f4f8e73e28f 100644 (file)
@@ -78,6 +78,7 @@ class AliAODRecoDecay : public AliVTrack {
   virtual UChar_t  GetITSClusterMap() const;
   virtual ULong_t  GetStatus() const;
   virtual Bool_t   GetXYZ(Double_t *p) const { return XvYvZv(p); }
+  using AliVTrack::GetXYZ;
   virtual Bool_t   GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
   virtual Bool_t   PropagateToDCA(const AliVVertex* vtx,Double_t b,Double_t maxd,Double_t dz[2],Double_t covar[3]);
 
index 98c712bb9ae7b60029175c86059bf8b6621110b6..315399e3586d88e13dd5ea88071abd50650e57c1 100644 (file)
@@ -1150,3 +1150,13 @@ Double_t AliAODTrack::GetMassForTracking() const
 const AliTOFHeader* AliAODTrack::GetTOFHeader() const {
   return fAODEvent->GetTOFHeader();
 }
+  
+Int_t AliAODTrack::GetTrackParam         ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamRefitted ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamIp       ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamTPCInner ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamOp       ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamCp       ( AliExternalTrackParam & ) const {return 0;} 
+Int_t AliAODTrack::GetTrackParamITSOut   ( AliExternalTrackParam & ) const {return 0;} 
+
+
index d441b883d53937a8e24caa93984688757fd7d208..2a403b5f3c1987fcb7ff912e8146ef120c0b9276 100644 (file)
@@ -17,6 +17,7 @@
 #include "AliAODVertex.h"
 #include "AliAODRedCov.h"
 #include "AliAODPid.h"
+#include "AliExternalTrackParam.h"
  
 
 class AliVVertex;
@@ -200,6 +201,7 @@ class AliAODTrack : public AliVTrack {
   //
   Int_t   GetTOFBunchCrossing(Double_t b=0, Bool_t tpcPIDonly=kFALSE) const;
   //
+  using AliVTrack::GetP;
   template <typename T> void GetP(T *p) const {
     p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
 
@@ -220,7 +222,7 @@ class AliAODTrack : public AliVTrack {
     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
 
   Bool_t GetXYZ(Double_t *p) const {
-    return GetPosition(p); }
+    return GetPosition(p); }  
   
   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t *r) const;
   Bool_t GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz=0, Double_t* alpSect=0) const;  
@@ -276,6 +278,9 @@ class AliAODTrack : public AliVTrack {
   void    SetTPCFitMap(const TBits amap) {fTPCFitMap = amap;}
   void    SetTPCPointsF(UShort_t  findable){fTPCnclsF = findable;}
   void    SetTPCNCrossedRows(UInt_t n)     {fTPCNCrossedRows = n;}
+  
+  virtual const    AliExternalTrackParam * GetInnerParam() const { return NULL; }
+  virtual const    AliExternalTrackParam * GetOuterParam() const { return NULL; }
 
   UShort_t GetTPCNclsF() const { return fTPCnclsF;}
   UShort_t GetTPCNCrossedRows()  const { return fTPCNCrossedRows;}
@@ -485,6 +490,19 @@ class AliAODTrack : public AliVTrack {
 
   const AliAODEvent* fAODEvent;     //! pointer back to the event the track belongs to
 
+  //---------------------------------------------------------------------------
+  //--the calibration interface--
+  //--to be used in online calibration/QA
+  //--should also be implemented in ESD so it works offline as well
+  //-----------
+  virtual Int_t GetTrackParam         ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamIp       ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamOp       ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamCp       ( AliExternalTrackParam &p ) const;
+  virtual Int_t GetTrackParamITSOut   ( AliExternalTrackParam &p ) const;
+
   ClassDef(AliAODTrack, 24);
 };
 
index 82bad97a591a065e7f6cfd4b01b75d2d8d98831a..f2c942e6b39bd13b5ab6ccaa58904b15ad3d485e 100644 (file)
@@ -118,6 +118,7 @@ set ( SRCS
     STEER/AliTransportMonitor.cxx
     STEER/AliParamList.cxx
     STEER/AliMCGenHandler.cxx
+    STEER/AliHLTTestInputHandler.cxx
     )
 
 string(REPLACE ".cxx" ".h" HDRS  "${SRCS}")
index 3731a820ab071a978c1061ee72c5b6a5407a89e3..c4fb9a3de8afba1155520419e69c9e2dd782616a 100644 (file)
@@ -98,6 +98,9 @@ set ( SRCS
     STEERBase/AliVTOFcluster.cxx
     STEERBase/AliVMultiplicity.cxx
     STEERBase/AliGenHepMCEventHeader.cxx
+    STEERBase/AliVMisc.cxx
+    STEERBase/AliVfriendTrack.cxx
+    STEERBase/AliVfriendEvent.cxx
   )
 
 string(REPLACE ".cxx" ".h" HDRS  "${SRCS}")
index 8a1629748f75a21bf02e8a07e476950fb3364dd8..a1cdcf41789f55e0e80900407a1b49c5a2a3968b 100644 (file)
 #include "AliTriggerCluster.h"
 #include "AliEventplane.h"
 
-
 ClassImp(AliESDEvent)
 
-
-
 // here we define the names, some classes are no TNamed, therefore the classnames 
 // are the Names
   const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
@@ -1470,7 +1467,7 @@ void AliESDEvent::GetESDfriend(AliESDfriend *ev) const
 
   }
 
-  AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend"));
+  AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindFriend());
   if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend());
 }
 
@@ -2431,3 +2428,12 @@ void AliESDEvent::ConnectTracks() {
   fTracksConnected = kTRUE;
   //
 }
+
+//______________________________________________________________________________
+AliESDfriend* AliESDEvent::FindFriend() const 
+{ 
+  return static_cast<AliESDfriend*>(FindListObject("AliESDfriend")); 
+}
+
+AliVEvent::EDataLayoutType AliESDEvent::GetDataLayoutType() const {return AliVEvent::kESD;}
+
index 4f8d359903b18b2b00e6ab3e539154c17eb85e40..dc8e5e742fc6e31c9aba297f54247a50d541e75a 100644 (file)
 #include "AliESDTOFCluster.h"
 #include "AliESDTOFHit.h"
 #include "AliESDTOFMatch.h"
+#include "AliESDv0.h"
+#include "AliESDkink.h"
+#include "AliESDfriend.h"
 
-
-
-class AliESDfriend;
 class AliESDHLTtrack;
 class AliESDVertex;
 class AliESDPmdTrack;
 class AliESDFMD;
-class AliESDkink;
-class AliESDv0;
 class AliRawDataErrorLog;
 class AliESDRun;
 class AliESDTrdTrigger;
@@ -280,8 +278,7 @@ public:
 
   void SetESDfriend(const AliESDfriend *f) const;
   void GetESDfriend(AliESDfriend *f) const;
-
-
+  virtual AliESDfriend* FindFriend() const;
 
   void SetPrimaryVertexTPC(const AliESDVertex *vertex); 
   const AliESDVertex *GetPrimaryVertexTPC() const {return fTPCVertex;}
@@ -299,6 +296,30 @@ public:
 
   const AliESDVertex *GetPrimaryVertex() const;
 
+  //getters for calibration
+  Int_t GetPrimaryVertex (AliESDVertex &v) const {
+      if(!GetPrimaryVertex()) return -1;
+      v=*GetPrimaryVertex();
+      return 0;
+  }
+
+  Int_t GetPrimaryVertexTPC (AliESDVertex &v) const {
+      if(!GetPrimaryVertexTPC()) return -1;
+      v=*GetPrimaryVertexTPC();
+      return 0;
+  }
+
+  Int_t GetPrimaryVertexSPD (AliESDVertex &v) const {
+      if(!GetPrimaryVertexSPD()) return -1;
+      v=*GetPrimaryVertexSPD();
+      return 0;
+  }
+
+  Int_t GetPrimaryVertexTracks (AliESDVertex &v) const {
+      if(!GetPrimaryVertexTracks()) return -1;
+      v=*GetPrimaryVertexTracks();
+      return 0;
+  }
 
 
   void SetTOFHeader(const AliTOFHeader * tofEventTime);
@@ -418,6 +439,7 @@ public:
   void AddTrdTracklet(const AliESDTrdTracklet *trkl);
   void AddTrdTracklet(UInt_t trackletWord, Short_t hcid, Int_t label = -1);
 
+  using AliVEvent::GetV0;
   AliESDv0 *GetV0(Int_t i) const {
     return (AliESDv0*)(fV0s?fV0s->At(i):0x0);
   }
@@ -531,7 +553,9 @@ public:
   void SetDAQAttributes(UInt_t attributes) {fDAQAttributes = attributes;}
   UInt_t GetDAQDetectorPattern() const {return fDAQDetectorPattern;}
   UInt_t GetDAQAttributes() const {return fDAQAttributes;}
-  
+
+  virtual AliVEvent::EDataLayoutType GetDataLayoutType() const;
+
 protected:
   AliESDEvent(const AliESDEvent&);
   static Bool_t ResetWithPlacementNew(TObject *pObject);
index f97039940a261b2dac41114b367a2061a38f8d21..76ed08e5f216547a37ac4af50c6caffa6c3b93a5 100644 (file)
@@ -188,7 +188,7 @@ void AliESDInputHandler::ConnectFriends()
 
     cTree->AddFriend("esdFriendTree", esdFriendTreeFName.Data());
     cTree->SetBranchStatus("ESDfriend.", 1);
-    fFriend = (AliESDfriend*)(fEvent->FindListObject("AliESDfriend"));
+    fFriend = fEvent->FindFriend();
     if (fFriend) cTree->SetBranchAddress("ESDfriend.", &fFriend);
   }
 }
index 3b7706b15de11d8cf8dec5663832b6d8bc9352aa..5b2f648ca09d20fb3aed5ae4d890b0d403813923 100644 (file)
@@ -67,6 +67,9 @@ class AliESDInputHandler : public AliInputEventHandler {
     virtual void CreatePIDResponse(Bool_t isMC=kFALSE);
     AliESDpid           *GetESDpid()       const {return fESDpid;}
     void                 SetESDpid(AliESDpid* pid)     {Changed(); fESDpid = pid;}
+
+    //HLT
+    virtual AliVfriendEvent*   GetVfriendEvent() const {return fFriend;};
   
  private:
     AliESDInputHandler(const AliESDInputHandler& handler);             
index 32bf39b1ab64c406b88381d8eb2a0459594ad96d..c4e96b6cb3c0570c1f10572bcc52666d131f1a2f 100644 (file)
@@ -44,6 +44,7 @@ AliESDfriend::AliESDfriend(): TObject(), fTracks("AliESDfriendTrack",1),
 
 AliESDfriend::AliESDfriend(const AliESDfriend &f) :
   TObject(f),
+  AliVfriendEvent(),
   fTracks(f.fTracks),
   fESDVZEROfriend(f.fESDVZEROfriend ? new AliESDVZEROfriend(*f.fESDVZEROfriend) : NULL),
   fESDTZEROfriend(f.fESDTZEROfriend ? new AliESDTZEROfriend(*f.fESDTZEROfriend) : NULL),
index 530389ee4c35b618c2b5f779a1e588803d7b6fe3..cf5aa87fdba04fd458bcb21a26697992817782d6 100644 (file)
 #include <TClonesArray.h>
 
 #include "AliESDfriendTrack.h"
+#include "AliVfriendEvent.h"
 
 class AliESDVZEROfriend;
 class AliESDTZEROfriend;
 
 //_____________________________________________________________________________
-class AliESDfriend : public TObject {
+class AliESDfriend : public TObject, public AliVfriendEvent {
 public:
   AliESDfriend();
   AliESDfriend(const AliESDfriend &);
@@ -41,14 +42,14 @@ public:
   void SetTZEROfriend(AliESDTZEROfriend * obj);
   AliESDTZEROfriend *GetTZEROfriend(){ return fESDTZEROfriend; }
 
-  void Ls(){
+  void Ls() const {
          return fTracks.ls();
   }
 
   void Reset();
   // bit manipulation for filtering
   void SetSkipBit(Bool_t skip){SetBit(23,skip);}
-  Bool_t TestSkipBit() {return TestBit(23);}
+  Bool_t TestSkipBit() const { return TestBit(23); }
 
   //TPC cluster occupancy
   Int_t GetNclustersTPC(UInt_t sector) const {return (sector<72)?fNclustersTPC[sector]:0;}
index 5c7c934f21be6338db31a2416058d63b0a550d00..fc6a345a59626febd7a7095377f4c22518d531ba 100644 (file)
@@ -23,6 +23,7 @@
 #include "TObjArray.h"
 #include "TClonesArray.h"
 #include "AliKalmanTrack.h"
+#include "AliVTPCseed.h"
 
 ClassImp(AliESDfriendTrack)
 
@@ -60,6 +61,7 @@ fTRDIn(0)
 
 AliESDfriendTrack::AliESDfriendTrack(const AliESDfriendTrack &t): 
 TObject(t),
+AliVfriendTrack(),
 f1P(t.f1P),
 fnMaxITScluster(t.fnMaxITScluster),
 fnMaxTPCcluster(t.fnMaxTPCcluster),
@@ -139,7 +141,7 @@ void AliESDfriendTrack::AddCalibObject(TObject * calibObject){
   fCalibContainer->AddLast(calibObject);
 }
 
-TObject * AliESDfriendTrack::GetCalibObject(Int_t index){
+TObject * AliESDfriendTrack::GetCalibObject(Int_t index) const {
   //
   //
   //
@@ -148,6 +150,17 @@ TObject * AliESDfriendTrack::GetCalibObject(Int_t index){
   return fCalibContainer->At(index);
 }
 
+Int_t AliESDfriendTrack::GetTPCseed( AliTPCseed &seed) const {
+  TObject* calibObject = NULL;
+  AliVTPCseed* seedP = NULL;
+  for (Int_t idx = 0; (calibObject = GetCalibObject(idx)); ++idx) {
+    if ((seedP = dynamic_cast<AliVTPCseed*>(calibObject))) {
+      seedP->CopyToTPCseed( seed );
+      return 0;
+    }
+  }
+  return -1;
+}
 
 void AliESDfriendTrack::SetTPCOut(const AliExternalTrackParam &param) {
   // 
index b0f3033ec05b72ef73536c515d34b7da2ecdb589..f4d5cf492ca9d212975fc4ec49282e32643a445b 100644 (file)
 #include <TObject.h>
 #include <TClonesArray.h>
 #include <AliExternalTrackParam.h>
+#include "AliVfriendTrack.h"
+#include "AliTrackPointArray.h"
 
-class AliTrackPointArray;
 class AliKalmanTrack;
 class TObjArrray;
+class AliTPCseed;
+
+
 //_____________________________________________________________________________
-class AliESDfriendTrack : public TObject {
+class AliESDfriendTrack : public TObject, public AliVfriendTrack {
 public:
   enum {
     kMaxITScluster=12,
@@ -41,7 +45,8 @@ public:
   AliKalmanTrack *GetTRDtrack() {return fTRDtrack;}
   AliKalmanTrack *GetITStrack() {return fITStrack;}
   void AddCalibObject(TObject * calibObject); 
-  TObject * GetCalibObject(Int_t index);
+  TObject * GetCalibObject(Int_t index) const;
+
   //
   // parameters backup
   void SetTPCOut(const AliExternalTrackParam &param);
@@ -63,7 +68,11 @@ public:
   
   // bit manipulation for filtering
   void SetSkipBit(Bool_t skip){SetBit(23,skip);}
-  Bool_t TestSkipBit() {return TestBit(23);}
+  Bool_t TestSkipBit() const {return TestBit(23);}
+
+  // VfriendTrack interface
+
+  Int_t GetTPCseed( AliTPCseed &) const;
 
 protected:
   Float_t f1P;                     // 1/P (1/(GeV/c))
@@ -87,7 +96,7 @@ protected:
 private:
   AliESDfriendTrack &operator=(const AliESDfriendTrack & /* t */) {return *this;}
 
-  ClassDef(AliESDfriendTrack,6) //ESD friend track
+  ClassDef(AliESDfriendTrack,7) //ESD friend track
 };
 
 #endif
index 300210ac31b13ba9a92b2e99d62908d3614a82c9..92cc38720b1859c326d955b17184d15bc8c84569 100644 (file)
@@ -87,7 +87,7 @@ public:
   Char_t           fStatus[12];       //status of kink - first 4 mother (ITS,TPC,TRD,TOF)  other daughter
 
 
-  ClassDef(AliESDkink,4)      // ESD V0 vertex
+  ClassDef(AliESDkink, 5)      // ESD V0 vertex
 };
 
 #endif
index 0f558ea8fb12f9f9d2289da8da4c1936cebc6ffb..d6cd0cdc7ed366a13c84c5311f9420b509bf9cc3 100644 (file)
@@ -3440,3 +3440,4 @@ Double_t  AliESDtrack::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t qID, Int
   if (!fIp) return 0;
   return fTPCdEdxInfo->GetdEdxInfo(fIp, regionID, calibID, qID, valueID);
 }
+
index e7daf9b0311c1dc8af32e2a1b6d3e9a21fb7dffa..ea96a2a1d3f0086ec7b99c4f3d71e7f0cf5b6ae6 100644 (file)
@@ -97,7 +97,7 @@ public:
   Double_t M() const;
   Double_t E() const;
   Double_t Y() const;
-
   Bool_t GetConstrainedPxPyPz(Double_t *p) const {
     if (!fCp) return kFALSE;
     return fCp->GetPxPyPz(p);
@@ -421,7 +421,7 @@ public:
   Bool_t 
   RelateToVertexBxByBz(const AliESDVertex *vtx, Double_t b[3], Double_t maxd,
                         AliExternalTrackParam *cParam=0);
-  void GetImpactParameters(Float_t &xy,Float_t &z) const {xy=fD; z=fZ;}
+  virtual void GetImpactParameters(Float_t &xy,Float_t &z) const {xy=fD; z=fZ;}
   void GetImpactParameters(Float_t p[2], Float_t cov[3]) const {
     p[0]=fD; p[1]=fZ; cov[0]=fCdd; cov[1]=fCdz; cov[2]=fCzz;
   }
@@ -450,6 +450,20 @@ public:
   static bool OnlineMode() {return fgkOnlineMode;}
   static Double_t GetLengthInActiveZone(const AliExternalTrackParam  *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi =0 , TTreeSRedirector * pcstream =0 );
   Double_t GetLengthInActiveZone( Int_t mode, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi =0 , TTreeSRedirector * pcstream =0 ) const;
+
+  //---------------------------------------------------------------------------
+  //--the calibration interface--
+  //--to be used in online calibration/QA
+  //--should also be implemented in ESD so it works offline as well
+  //-----------
+  virtual Int_t GetTrackParam         ( AliExternalTrackParam &p ) const {p=*this; return 0;}
+  virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamIp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamOp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamCp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamITSOut   ( AliExternalTrackParam & ) const {return 0;}
+
 protected:
   
   AliExternalTrackParam *fCp; // Track parameters constrained to the primary vertex
index 615606c061d4e869c13eea2ef069a9d97023dfa2..55780c98c5a2b9d9a8d7481236c6fdeaf95063f7 100644 (file)
@@ -75,7 +75,7 @@ public:
   Double_t  GetChi2V0()  const {return fChi2V0;}
   void     GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const;
   void     GetNPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const;
-  void     GetPPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const;
+  void     GetPPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const;  
   void     GetXYZ(Double_t &x, Double_t &y, Double_t &z) const;
   Float_t  GetD(Double_t x0,Double_t y0) const;
   Float_t  GetD(Double_t x0,Double_t y0,Double_t z0) const;
@@ -113,7 +113,7 @@ public:
   void SetParamP(const AliExternalTrackParam & paramP) {fParamP = paramP;}
   void SetParamN(const AliExternalTrackParam & paramN) {fParamN = paramN;}
   void SetStatus(Int_t status){fStatus=status;}
-  Int_t GetStatus() const {return fStatus;}
+  ULong_t GetStatus() const {return ULong_t(fStatus);}
   Int_t GetIndex(Int_t i) const {return (i==0) ? fNidx : fPidx;}
   void SetIndex(Int_t i, Int_t ind);
   const Double_t *GetAnglep() const {return fAngle;}
index 98a879d231d737cf1402e89da8b86e890a159d23..8bdb434e3da863a0bdd8da29a91e72dd740e5447 100644 (file)
@@ -78,9 +78,9 @@ public:
   void SetFakeRatio(Float_t ratio) {fFakeRatio=ratio;}
   Float_t  GetFakeRatio()   const {return fFakeRatio;}
   void SetMass(Double_t mass) {fMass=mass;}
+  void SetChi2(Double_t chi2) {fChi2=chi2;} 
 
 protected:
-  void SetChi2(Double_t chi2) {fChi2=chi2;} 
 
   Double32_t fFakeRatio;  // fake ratio
   Double32_t fChi2;       // total chi2 value for this track
index 81856a31478733084fccf3b8afdd2944e4cc31fc..9025df0c162727d11a0670cc6d6abb7e0e29836a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <TObject.h>
 #include <TMatrixDSym.h>
+#include "Rtypes.h"
 
 class TGeoRotation;
 
diff --git a/STEER/STEER/AliHLTTestInputHandler.cxx b/STEER/STEER/AliHLTTestInputHandler.cxx
new file mode 100644 (file)
index 0000000..95263ba
--- /dev/null
@@ -0,0 +1,93 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+//     Event handler for reconstruction
+//     Author: Andrei Gheata, CERN
+//-------------------------------------------------------------------------
+
+#include "AliHLTTestInputHandler.h"
+#include "AliVCuts.h"
+#include "AliVEvent.h"
+#include "TObjArray.h"
+#include "AliAnalysisTask.h"
+
+ClassImp(AliHLTTestInputHandler)
+
+//______________________________________________________________________________
+AliHLTTestInputHandler::AliHLTTestInputHandler() 
+  : AliVEventHandler()
+  , fEvent(NULL)
+  , fFriendEvent(NULL)
+{
+// default constructor
+}
+
+//______________________________________________________________________________
+AliHLTTestInputHandler::AliHLTTestInputHandler(const char* name, const char* title) 
+  : AliVEventHandler(name,title)
+  , fEvent(NULL)
+  , fFriendEvent(NULL)
+{
+// Named constructor
+}
+
+//______________________________________________________________________________
+AliHLTTestInputHandler::AliHLTTestInputHandler(AliHLTTestInputHandler& that) 
+  : AliVEventHandler(that)
+  , fEvent(that.fEvent)
+  , fFriendEvent(that.fFriendEvent)
+{
+// dummy cpy constructor
+}
+
+//______________________________________________________________________________
+Bool_t AliHLTTestInputHandler::Init(TTree* /*tree*/,  Option_t* /*opt*/)
+{
+// Initialisation necessary for each new tree. In reco case this is once.
+  Printf("----> AliHLTTestInputHandler::Init"); 
+  Printf("<---- AliHLTTestInputHandler::Init"); 
+
+   return kTRUE;
+}  
+//______________________________________________________________________________
+Bool_t AliHLTTestInputHandler::BeginEvent(Long64_t)
+{
+// Called at the beginning of every event   
+
+  Printf("----> HLTTestInputHandler: BeginEvent: now fEvent is %p", fEvent);
+
+  Printf("----> HLTTestInputHandler: at the end of BeginEvent: now fEvent is %p", fEvent);
+  return kTRUE;
+}     
+
+//______________________________________________________________________________
+Bool_t AliHLTTestInputHandler::InitTaskInputData(AliVEvent* esdEvent, AliVfriendEvent* friendEvent, TObjArray* arrTasks) {
+
+// Method to propagte to all the connected tasks the HLT event.
+// The method gets the list of tasks from the manager
+
+  Printf("----> AliHLTTestInputHandler::InitTaskInpuData: Setting the event...");
+  SetEvent(esdEvent);
+  SetVFriendEvent(friendEvent);
+  // set transient pointer to event inside tracks
+  fEvent->ConnectTracks();
+  Printf("----> AliHLTTestInputHandler::InitTaskInpuData: ...Event set: fEvent = %p; friend = %p", fEvent, friendEvent);
+  for (Int_t i = 0; i < arrTasks->GetEntries(); i++){
+    AliAnalysisTask* t = (AliAnalysisTask*)(arrTasks->At(i));
+    t->ConnectInputData("");
+  }
+  return kTRUE;
+}
diff --git a/STEER/STEER/AliHLTTestInputHandler.h b/STEER/STEER/AliHLTTestInputHandler.h
new file mode 100644 (file)
index 0000000..3ce7a59
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALIHLTTESTINPUTHANDLER_H
+#define ALIHLTTESTINPUTHANDLER_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//-------------------------------------------------------------------------
+//     Reconstruction-specific input handler
+//     Author: Andrei Gheata, CERN
+//-------------------------------------------------------------------------
+
+#ifndef ALIVEVENTHANDLER_H
+#include "AliVEventHandler.h"
+#endif
+
+class TObjArray;
+class AliVfriendevent;
+class AliVEvent;
+
+class AliHLTTestInputHandler : public AliVEventHandler {
+
+ public:
+    AliHLTTestInputHandler();
+    AliHLTTestInputHandler(AliHLTTestInputHandler&);
+    AliHLTTestInputHandler(const char* name, const char* title);
+    virtual ~AliHLTTestInputHandler() {}
+    AliHLTTestInputHandler& operator=(const AliHLTTestInputHandler&) {return *this;}
+    virtual Bool_t Notify() { return kFALSE; }
+    virtual Bool_t Notify(const char *) {return kTRUE;}
+    virtual Bool_t Init(Option_t* /*opt*/) {return kTRUE;}
+    virtual Bool_t Init(TTree* /*tree*/, Option_t* /*opt*/);
+    virtual Bool_t BeginEvent(Long64_t entry);
+    virtual Bool_t FinishEvent() {return kTRUE;}
+    virtual void  SetOutputFileName(const char* /*fname*/) {};
+    virtual const char* GetOutputFileName() const {return NULL;}
+    // Input
+    virtual void SetInputTree(TTree* /*tree*/) {};
+    // Steering 
+    virtual Bool_t GetEntry() {return kTRUE;}
+    virtual Bool_t Terminate() {return kTRUE;}
+    virtual Bool_t TerminateIO() {return kTRUE;}
+
+    // Especially needed for HLT
+    virtual Bool_t InitTaskInputData(AliVEvent* /*esdEvent*/, AliVfriendEvent* /*friendEvent*/, TObjArray* /*arrTasks*/);
+
+    AliVEvent* GetEvent() const {return fEvent;}
+    //AliVEvent* GetEvent() const {return NULL;}
+    void  SetEvent(AliVEvent *event) {fEvent = event;}
+
+    AliVfriendEvent* GetVfriendEvent() const {return fFriendEvent;}
+    void  SetVFriendEvent(AliVfriendEvent *friendEvent) {fFriendEvent = friendEvent;}
+      
+ private:
+    AliHLTTestInputHandler(const AliVEventHandler& handler);             
+    AliHLTTestInputHandler& operator=(const AliVEventHandler& handler);  
+    
+    AliVEvent       *fEvent;          //! Pointer to the event
+    AliVfriendEvent *fFriendEvent;    //! Pointer to the friend event
+
+    ClassDef(AliHLTTestInputHandler, 1);
+};
+
+#endif
index 574fa2f2de9550cdede645dca97882028fc9f6f5..501b8cbeafa4b834a6b3b4540169cbb49f44927a 100644 (file)
@@ -21,7 +21,7 @@
 #include "TMath.h"
 
 #include "AliVTrack.h"
-
+#include "AliVMisc.h"
 const Double_t kVeryBig=1./kAlmost0;
 const Double_t kMostProbablePt=0.35;
 
@@ -43,6 +43,10 @@ class AliExternalTrackParam: public AliVTrack {
                        const Double_t param[5], const Double_t covar[15]);
   AliExternalTrackParam(Double_t xyz[3],Double_t pxpypz[3],
                        Double_t cv[21],Short_t sign);
+  // constructor for reinitialisation of vtable
+  AliExternalTrackParam( AliVConstructorReinitialisationFlag f) :AliVTrack(f), fX(), fAlpha(){}
+  void Reinitialize() { new (this) AliExternalTrackParam( AliVReinitialize ); }
+
   virtual ~AliExternalTrackParam(){}
   void CopyFromVTrack(const AliVTrack *vTrack);
   
@@ -85,7 +89,9 @@ class AliExternalTrackParam: public AliVTrack {
   Double_t GetY()    const {return fP[0];}
   Double_t GetZ()    const {return fP[1];}
   Double_t GetSnp()  const {return fP[2];}
-  Double_t GetTgl()  const {return fP[3];}
+  virtual Double_t GetTgl()  const {return fP[3];}
+  using AliVTrack::GetImpactParameters;
+  virtual void GetImpactParameters(Float_t& ,Float_t&) const {}
   Double_t GetSigned1Pt()  const {return fP[4];}
 
   Double_t GetSigmaY2() const {return fC[0];}
@@ -218,7 +224,7 @@ class AliExternalTrackParam: public AliVTrack {
   Bool_t ConstrainToVertex(const AliVVertex* vtx, Double_t b[3]);
   
   void GetDirection(Double_t d[3]) const;
-  Bool_t GetPxPyPz(Double_t *p) const;
+  Bool_t GetPxPyPz(Double_t *p) const;  
   Bool_t GetXYZ(Double_t *p) const;
   Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
   Bool_t GetPxPyPzAt(Double_t x, Double_t b, Double_t p[3]) const;
@@ -254,6 +260,19 @@ class AliExternalTrackParam: public AliVTrack {
   static Bool_t  GetUseLogTermMS()                {return fgUseLogTermMS;} 
   static void    SetUseLogTermMS(Bool_t v=kTRUE)  {fgUseLogTermMS = v;} 
 
+  //---------------------------------------------------------------------------
+  //--the calibration interface--
+  //--to be used in online calibration/QA
+  //--should also be implemented in ESD so it works offline as well
+  //-----------
+  virtual Int_t GetTrackParam         ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamIp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamOp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamCp       ( AliExternalTrackParam & ) const {return 0;}
+  virtual Int_t GetTrackParamITSOut   ( AliExternalTrackParam & ) const {return 0;}
+
  protected:
   AliExternalTrackParam(const AliVTrack *vTrack);
 
index c141030421bae530b717f9c609124577b98356d5..a2e260633a600d88c751869609bd819ecd1d3d31 100644 (file)
@@ -14,7 +14,6 @@
 #include <TTree.h>
 
 
-class AliVEvent;
 class AliVCuts;
 class AliRunTag;
 class AliEventTag;
index 44515d6a402d12db97c32f921e962f7f3113c15d..3d4bddba882cbcd92087ecc4aaab407e7b703589 100644 (file)
@@ -498,10 +498,7 @@ AliVParticle* AliMCEvent::GetTrack(Int_t i) const
     //
 
     if (fExternal) {
-       
-  
        return ((AliVParticle*) (fMCParticles->At(i)));
-  
     }
     
     //
@@ -965,7 +962,7 @@ void AliMCEvent::AssignGeneratorIndex(Int_t index, Int_t dmin, Int_t dmax) {
    }
    
    return 1;
-   }
+}
 
 void  AliMCEvent::SetParticleArray(TClonesArray* mcParticles) 
   {
@@ -993,5 +990,9 @@ void  AliMCEvent::SetParticleArray(TClonesArray* mcParticles)
     AssignGeneratorIndex();
   }
 
+AliVEvent::EDataLayoutType AliMCEvent::GetDataLayoutType() const
+{
+  return AliVEvent::kMC;
+}
 
 ClassImp(AliMCEvent)
index 6d1a0775d316133f87a09c3731da7d388dca1ac4..a25d7806fcf4bb1074b35f145e779e9c1488eee0 100644 (file)
@@ -99,6 +99,7 @@ public:
     virtual Int_t     GetNumberOfV0s()       const {return -1;}
     virtual Int_t     GetNumberOfCascades()  const {return -1;}
     // Vertex
+    using AliVEvent::GetPrimaryVertex;
     virtual const AliVVertex *GetPrimaryVertex() const;
     
     //
@@ -151,6 +152,7 @@ public:
   virtual AliVVZERO    *GetVZEROData() const {return 0;}
   virtual AliVZDC      *GetZDCData()   const {return 0;}
 
+  virtual AliVEvent::EDataLayoutType GetDataLayoutType() const;
 
 private:
     virtual void      ReorderAndExpandTreeTR();
@@ -180,6 +182,7 @@ private:
     static   Int_t        fgkBgLabelOffset;  // Standard branch name    
     mutable  AliVVertex*  fVertex;           // MC Vertex
     Int_t             fNBG;              //! Background particles in current event
+    
     ClassDef(AliMCEvent, 2)              // AliVEvent realisation for MC data
 };
 
index 39257885126095097eb2985439358e7c37042f74..db0eb63d4025951fbcb1e414f5df9eaf3d5433be 100644 (file)
@@ -355,3 +355,8 @@ Double_t AliMixedEvent::GetMagneticField() const
     AliVEvent* evt = (AliVEvent*) (fEventList.At(0));
     return evt->GetMagneticField();
 }
+
+AliVEvent::EDataLayoutType AliMixedEvent::GetDataLayoutType() const
+{
+  return AliVEvent::kMixed;
+}
index 2abee7c4b68ab94267e528660fbd0beecc69395f..1ed37e055290bcd381a59db45bce5fd99573f9b0 100644 (file)
@@ -114,11 +114,13 @@ public:
   virtual AliCentrality* GetCentrality() {return 0;}
   virtual AliEventplane* GetEventplane() {return 0;}
   // Primary vertex
+    using AliVEvent::GetPrimaryVertex;
     virtual const AliVVertex   *GetPrimaryVertex() const {return fMeanVertex;}
     virtual Bool_t ComputeVtx(const TObjArray *vertices, Double_t *pos,Double_t *sig,Int_t *nContributors);
   // VZERO
   virtual AliVVZERO *GetVZEROData() const {return 0;}
   virtual AliVZDC     *GetZDCData() const {return 0;}
+  virtual EDataLayoutType GetDataLayoutType() const;
 private:
   TList   fEventList;            //! List of Events
   Int_t   fNEvents;              //! Number of Events 
index 89915f9a228bd7f39da69933a235486428339342..68faa2f4203f3b19659ebd19f4d236e0c130ce3f 100644 (file)
@@ -1373,7 +1373,7 @@ AliTPCPIDResponse::EChamberStatus AliTPCPIDResponse::TrackStatus(const AliVTrack
   //if there is no inner param this could mean we're using the AOD track,
   //we still can extrapolate from the vertex - so use those params.
   const AliExternalTrackParam* ip = track->GetInnerParam();
-  if (ip) track=ip;
+  if (ip) track=dynamic_cast<const AliVTrack*>(ip);
 
   Bool_t trackAtInner = track->GetXYZAt(innerRadius, fMagField, trackPositionInner);
   Bool_t trackAtOuter = track->GetXYZAt(outerRadius, fMagField, trackPositionOuter);
index d9b85238139654c711c06b1daebafee381e9bdb3..948b55372f9bc98e2b00f7ffe90751de67e70e66 100644 (file)
@@ -24,7 +24,7 @@
 
 
 AliVEvent::AliVEvent(const AliVEvent& vEvnt) :
-  TObject(vEvnt) { } // Copy constructor
+  TObject(vEvnt)  { } // Copy constructor
 
 AliVEvent& AliVEvent::operator=(const AliVEvent& vEvnt)
 { if (this!=&vEvnt) { 
@@ -34,5 +34,23 @@ AliVEvent& AliVEvent::operator=(const AliVEvent& vEvnt)
   return *this; 
 }
 
+const char* AliVEvent::Whoami()
+{
+  switch (GetDataLayoutType())
+  {
+    case AliVEvent::kESD :
+      return "ESD";
+    case AliVEvent::kFlat :
+      return "Flat";
+    case AliVEvent::kAOD :
+      return "AOD";
+    case AliVEvent::kMC :
+      return "MC";
+    case AliVEvent::kMixed :
+      return "Mixed";
+    default:
+      return "unknown";
+  }
+}
 
 ClassImp(AliVEvent)
index be998dee9bf2d06a8b1620437d3cc383b40addad..a2784c2f8c5c586b3d25375a3afd31ee89639249 100644 (file)
 #include "AliTOFHeader.h"
 #include "AliVTrdTrack.h"
 #include "AliVMultiplicity.h"
+class AliVfriendEvent;
 class AliCentrality;
 class AliEventplane;
 class AliVVZERO;
 class AliVZDC;
 class AliVMFT;   // AU
+class AliESDkink;
+class AliESDv0;
+class AliESDVertex;
+class AliVTrack;
 
 class AliVEvent : public TObject {
 
 public:
+  enum EDataLayoutType { kESD, kMC, kAOD, kMixed, kFlat };
   enum EOfflineTriggerTypes { 
       kMB           = BIT(0), // Minimum bias trigger, i.e. interaction trigger, offline SPD or V0 selection
       kINT7         = BIT(1), // V0AND trigger, offline V0 selection
@@ -143,6 +149,8 @@ public:
  
   // Tracks
   virtual AliVParticle *GetTrack(Int_t i) const = 0;
+  virtual AliVTrack    *GetVTrack(Int_t /*i*/) const {return NULL;}
+  //virtual AliVTrack    *GetVTrack(Int_t /*i*/) {return NULL;}
   //virtual Int_t        AddTrack(const AliVParticle *t) = 0;
   virtual Int_t        GetNumberOfTracks() const = 0;
   virtual Int_t        GetNumberOfV0s() const = 0;
@@ -169,7 +177,6 @@ public:
 
        
   // Primary vertex
-  virtual const AliVVertex   *GetPrimaryVertex() const {return 0x0;}
   virtual Bool_t IsPileupFromSPD(Int_t /*minContributors*/, 
                                 Double_t /*minZdist*/, 
                                 Double_t /*nSigmaZdist*/, 
@@ -203,8 +210,32 @@ public:
   virtual AliVTrdTrack* GetTrdTrack(Int_t /* iTrack */) const { return 0x0; }
 
   virtual Int_t     GetNumberOfESDTracks()  const { return 0; }
+  virtual Int_t     GetEventNumberInFile() const {return 0;}
+
+  //used in calibration:
+  virtual Int_t            GetV0(AliESDv0&, Int_t /*iv0*/) const {return 0;}
+  virtual UInt_t           GetTimeStamp() const { return 0; }
+  virtual AliVfriendEvent* FindFriend() const { return 0; }
+  virtual UInt_t           GetEventSpecie() const { return 0; }
+  virtual AliESDkink*      GetKink(Int_t /*i*/) const { return NULL; }
+  virtual Int_t            GetNumberOfKinks() const { return 0; }
+
+  // Primary vertex
+  virtual const AliVVertex   *GetPrimaryVertex() const {return 0x0;}
+  //virtual const AliVVertex   *GetPrimaryVertexSPD() const {return 0x0;}
+  //virtual const AliVVertex   *GetPrimaryVertexTPC() const {return 0x0;}
+  //virtual const AliVVertex   *GetPrimaryVertexTracks() const {return 0x0;}
+
+  virtual Int_t GetPrimaryVertex( AliESDVertex & ) const {return 0;}
+  virtual Int_t GetPrimaryVertexTPC( AliESDVertex & ) const {return 0;}
+  virtual Int_t GetPrimaryVertexSPD( AliESDVertex & ) const {return 0;}
+  virtual Int_t GetPrimaryVertexTracks( AliESDVertex & ) const {return 0;}
+
+  virtual void ConnectTracks() {}
+  virtual EDataLayoutType GetDataLayoutType() const = 0;
+  const char* Whoami();
 
-  ClassDef(AliVEvent,2)  // base class for AliEvent data
+  ClassDef(AliVEvent, 3)  // base class for AliEvent data
 };
 #endif 
 
index bcd121d4c4e6552ef0a62a67ebfb7fb5e522f630..068e83f133102b525f0714c8148252bd9badedf7 100644 (file)
@@ -13,6 +13,9 @@
 #include <TNamed.h>
 
 class TTree;
+class TObjArray;
+class AliVEvent;
+class AliVfriendEvent;
 
 class AliVEventHandler : public TNamed {
 
@@ -58,6 +61,12 @@ enum EEventHandlerFlags {
     void                 Changed();
     virtual void         SetCacheSize(Long64_t) {}
     virtual TList        *GetUserInfo() const {return 0x0;};
+
+    // HLT
+    virtual Bool_t              InitTaskInputData(AliVEvent* /*event*/, AliVfriendEvent* /*esdFriend*/, TObjArray* /*arrTasks*/) {return kTRUE;};
+    virtual AliVEvent*          GetEvent() const {return 0x0;};
+    virtual AliVfriendEvent*   GetVfriendEvent() const {return 0x0;};
+
  private :
   ClassDef(AliVEventHandler, 1);
 };
diff --git a/STEER/STEERBase/AliVMisc.cxx b/STEER/STEERBase/AliVMisc.cxx
new file mode 100644 (file)
index 0000000..42d42f4
--- /dev/null
@@ -0,0 +1 @@
+//dummy implementation file
diff --git a/STEER/STEERBase/AliVMisc.h b/STEER/STEERBase/AliVMisc.h
new file mode 100644 (file)
index 0000000..aa8e12c
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef ALIVMISC_H
+#define ALIVMISC_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Authors : Steffen Weber     */
+
+
+
+enum AliVConstructorReinitialisationFlag{AliVReinitialize};
+
+typedef enum AliVConstructorReinitialisationFlag AliVConstructorReinitialisationFlag;
+
+
+#endif
index c5e34c83ddaa943f31b9dbafe0b8ec7579049883..52692f150d55abe9707cec133e4731d338e217c5 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <Rtypes.h>
 #include <TObject.h>
+#include "AliVMisc.h"
 
 #include <float.h>
 
@@ -29,6 +30,9 @@ public:
   AliVParticle(const AliVParticle& vPart); 
   AliVParticle& operator=(const AliVParticle& vPart);
 
+  // constructor for reinitialisation of vtable
+  AliVParticle( AliVConstructorReinitialisationFlag ) :TObject(){}
+
   // kinematics
   virtual Double_t Px() const = 0;
   virtual Double_t Py() const = 0;
diff --git a/STEER/STEERBase/AliVTPCseed.cxx b/STEER/STEERBase/AliVTPCseed.cxx
new file mode 100644 (file)
index 0000000..82200f8
--- /dev/null
@@ -0,0 +1 @@
+//implementation file
diff --git a/STEER/STEERBase/AliVTPCseed.h b/STEER/STEERBase/AliVTPCseed.h
new file mode 100644 (file)
index 0000000..1dc4999
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef ALIVTPCSEED_H
+#define ALIVTPCSEED_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ * Primary Author: Mikolaj Krzewicki, mkrzewic@cern.ch
+ */
+#include "Rtypes.h"
+class AliTPCseed;
+
+class AliVTPCseed {
+  public:
+  AliVTPCseed() {}
+  virtual ~AliVTPCseed() {}
+  virtual void CopyToTPCseed( AliTPCseed &) const = 0;
+};
+
+#endif
index ad5cd14646f72c62401be8e8d89f28b4ad02ddcc..abb5f80a2251e50d58a1272c2a9a70cff9a93745 100644 (file)
@@ -37,6 +37,9 @@ AliVTrack& AliVTrack::operator=(const AliVTrack& vTrack)
   return *this; 
 }
 
+Bool_t AliVTrack::GetXYZ(Double_t* /*p*/) const {return kFALSE;};
+Bool_t AliVTrack::GetXYZAt(Double_t /*x*/, Double_t /*b*/, Double_t* /*r*/ ) const {return kFALSE;}
+
 Double_t AliVTrack::GetBz() const 
 {
   // returns Bz component of the magnetic field (kG)
index 1f408dc9b1e04b64a52094532405b99564bf7360..de7817edb09cc8dae9ca3ccd5f0caa502c29a286 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "AliVParticle.h"
 #include "AliPID.h"
+#include "AliVMisc.h"
 
 class AliVEvent;
 class AliVVertex;
@@ -70,6 +71,8 @@ public:
   virtual ~AliVTrack() { }
   AliVTrack(const AliVTrack& vTrack); 
   AliVTrack& operator=(const AliVTrack& vTrack);
+  // constructor for reinitialisation of vtable
+  AliVTrack( AliVConstructorReinitialisationFlag f) :AliVParticle(f){}
 
   virtual const AliVEvent* GetEvent() const {return 0;}
   virtual Int_t    GetID() const = 0;
@@ -89,6 +92,13 @@ public:
   virtual void     SetDetectorPID(const AliDetectorPID */*pid*/) {;}
   virtual const    AliDetectorPID* GetDetectorPID() const { return 0x0; }
   virtual Double_t GetTRDchi2()          const { return -1;}
+  virtual Int_t    GetNumberOfClusters() const {return 0;}
+
+  virtual Float_t GetTPCCrossedRows() const {return 0;}
+  virtual void GetImpactParameters(Float_t [], Float_t []) const {;}
+  virtual void GetImpactParameters(Float_t &/*&xy*/,Float_t &/*&z*/) const {;}
+  virtual void GetImpactParametersTPC(Float_t &/*&xy*/,Float_t &/*&z*/) const {;}
+  virtual void GetImpactParametersTPC(Float_t [] /*p[2]*/, Float_t [] /*cov[3]*/) const {;}
   
   virtual Int_t GetEMCALcluster()     const {return kEMCALNoMatch;}
   virtual void SetEMCALcluster(Int_t)       {;}
@@ -117,6 +127,7 @@ public:
   virtual UShort_t  GetTPCsignalN()      const {return 0 ;}
   virtual Double_t  GetTPCmomentum()     const {return 0.;}
   virtual Double_t  GetTPCTgl()          const {return 0.;}
+  virtual Double_t  GetTgl()             const {return 0.;}
   virtual Double_t  GetTOFsignal()       const {return 0.;}
   virtual Double_t  GetTOFsignalTunedOnData() const {return 0.;}
   virtual Double_t  GetHMPIDsignal()     const {return 0.;}
@@ -132,27 +143,61 @@ public:
   virtual void GetHMPIDmip(Float_t &/*x*/, Float_t &/*y*/, Int_t &/*q*/,Int_t &/*nph*/) const {;}
   
   virtual Bool_t GetOuterHmpPxPyPz(Double_t */*p*/) const {return kFALSE;}
-  
-  virtual void      GetIntegratedTimes(Double_t */*times*/, Int_t nspec=AliPID::kSPECIES) const;
+
+  virtual const AliExternalTrackParam * GetInnerParam() const { return NULL;}
+  virtual const AliExternalTrackParam * GetOuterParam() const { return NULL;}
+  virtual const AliExternalTrackParam * GetTPCInnerParam() const { return NULL;}
+  virtual const AliExternalTrackParam * GetConstrainedParam() const {return NULL;}
+
+  virtual void      GetIntegratedTimes(Double_t */*times*/, Int_t nspec=AliPID::kSPECIESC) const;
   virtual Double_t  GetTRDmomentum(Int_t /*plane*/, Double_t */*sp*/=0x0) const {return 0.;}
   virtual void      GetHMPIDpid(Double_t */*p*/) const {;}
   virtual Double_t  GetIntegratedLength() const { return 0.;}
   
   virtual ULong_t  GetStatus() const = 0;
   virtual Bool_t   GetXYZ(Double_t *p) const = 0;
-  virtual Bool_t   GetXYZAt(Double_t /*x*/, Double_t /*b*/, Double_t* /*r*/ ) const {return kFALSE;}
+  virtual Bool_t   GetXYZAt(Double_t /*x*/, Double_t /*b*/, Double_t* /*r*/ ) const;
   virtual Double_t GetBz() const;
   virtual void     GetBxByBz(Double_t b[3]) const;
   virtual Bool_t   GetCovarianceXYZPxPyPz(Double_t cv[21]) const = 0;
   virtual Bool_t   PropagateToDCA(const AliVVertex *vtx,Double_t b,Double_t maxd,Double_t dz[2],Double_t covar[3]) = 0;
-  virtual const    AliExternalTrackParam * GetOuterParam() const { return NULL; }
-  virtual const    AliExternalTrackParam * GetInnerParam() const { return NULL; }
   virtual Int_t    GetNcls(Int_t /*idet*/) const { return 0; }
   virtual Bool_t   GetPxPyPz(Double_t */*p*/) const { return kFALSE; }
   virtual void     SetID(Short_t /*id*/) {;}
   virtual Int_t    GetTOFBunchCrossing(Double_t = 0, Bool_t = kFALSE) const { return kTOFBCNA;}
   virtual const AliTOFHeader *GetTOFHeader() const {return NULL;};
 
+  //---------------------------------------------------------------------------
+  //--the calibration interface--
+  //--to be used in online calibration/QA
+  //--should also be implemented in ESD so it works offline as well
+  //-----------
+  virtual Int_t GetTrackParam         ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamIp       ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamOp       ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamCp       ( AliExternalTrackParam& ) const {return 0;}
+  virtual Int_t GetTrackParamITSOut   ( AliExternalTrackParam& ) const {return 0;}
+
+  virtual Int_t             GetKinkIndex(Int_t /*i*/) const { return 0;}
+  virtual Double_t          GetSigned1Pt()         const { return 0;}
+  virtual Bool_t            IsOn(Int_t /*mask*/) const {return 0;}
+  virtual Double_t          GetX()    const {return 0;}
+  virtual Double_t          GetY()    const {return 0;}
+  virtual Double_t          GetZ()    const {return 0;}
+  virtual const Double_t   *GetParameter() const {return 0;}
+  virtual Double_t          GetAlpha() const {return 0;}
+  virtual UShort_t          GetTPCncls(Int_t /*row0*/=0, Int_t /*row1*/=159) const {return 0;}
+  virtual Double_t          GetTOFsignalDz() const {return 0;}
+  virtual Double_t          GetP() const {return 0;}
+  virtual void              GetDirection(Double_t []) const {;}
+  virtual Double_t          GetLinearD(Double_t /*xv*/, Double_t /*yv*/) const {return 0;}
+  virtual void              GetDZ(Double_t /*x*/,Double_t /*y*/,Double_t /*z*/,Double_t /*b*/,Float_t [] /*dz[2]*/) const {;}
+  virtual Char_t            GetITSclusters(Int_t */**idx*/) const {return 0;}
+  virtual UChar_t           GetTRDclusters(Int_t */**idx*/) const {return 0;}
+
+
   ClassDef(AliVTrack,1)  // base class for tracks
 };
 
index 710162832990d036f84de6470add48316f67517e..dd82a674cfdeacb42ea9443714521bad0346fa70 100644 (file)
@@ -40,7 +40,7 @@ public:
   virtual void Clear(Option_t* option) {TNamed::Clear(option);}
 
 
-  ClassDef(AliVVertex,1)  // base class for vertices
+  ClassDef(AliVVertex,2)  // base class for vertices
 };
 
 #endif
diff --git a/STEER/STEERBase/AliVfriendEvent.cxx b/STEER/STEERBase/AliVfriendEvent.cxx
new file mode 100644 (file)
index 0000000..82200f8
--- /dev/null
@@ -0,0 +1 @@
+//implementation file
diff --git a/STEER/STEERBase/AliVfriendEvent.h b/STEER/STEERBase/AliVfriendEvent.h
new file mode 100644 (file)
index 0000000..421ba28
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef ALIVFRIENDEVENT_H
+#define ALIVFRIENDEVENT_H
+
+#include "Rtypes.h"
+#include "AliVMisc.h"
+class AliVfriendTrack;
+
+//_____________________________________________________________________________
+class AliVfriendEvent {
+public:
+  AliVfriendEvent() {}
+  virtual ~AliVfriendEvent() {}
+
+  // constructor and method for reinitialisation of virtual table
+  AliVfriendEvent( AliVConstructorReinitialisationFlag );
+  void Reinitialize(){} // do nothing
+
+  virtual Int_t GetNumberOfTracks() const = 0;
+  virtual const AliVfriendTrack *GetTrack(Int_t /*i*/) const = 0;
+  virtual Int_t GetEntriesInTracks() const = 0;
+
+  // AliESDVZEROfriend *GetVZEROfriend();
+  // AliESDTZEROfriend *GetTZEROfriend();
+
+  virtual void Ls() const = 0;
+  virtual void Reset() = 0;
+
+  // bit manipulation for filtering
+  virtual void SetSkipBit(Bool_t skip) = 0;
+  virtual Bool_t TestSkipBit() const = 0;
+
+ //TPC cluster occupancy
+  virtual Int_t GetNclustersTPC(UInt_t /*sector*/) const = 0;
+  virtual Int_t GetNclustersTPCused(UInt_t /*sector*/) const = 0;
+
+private: 
+
+  AliVfriendEvent(const AliVfriendEvent &);
+  AliVfriendEvent& operator=(const AliVfriendEvent& esd);
+};
+
+#pragma GCC diagnostic ignored "-Weffc++" 
+inline AliVfriendEvent::AliVfriendEvent(AliVConstructorReinitialisationFlag ) {} // do nothing
+#pragma GCC diagnostic warning "-Weffc++" 
+
+#endif
+
diff --git a/STEER/STEERBase/AliVfriendTrack.cxx b/STEER/STEERBase/AliVfriendTrack.cxx
new file mode 100644 (file)
index 0000000..82200f8
--- /dev/null
@@ -0,0 +1 @@
+//implementation file
diff --git a/STEER/STEERBase/AliVfriendTrack.h b/STEER/STEERBase/AliVfriendTrack.h
new file mode 100644 (file)
index 0000000..08e6ec3
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef ALIVFRIENDTRACK_H
+#define ALIVFRIENDTRACK_H
+
+//_____________________________________________________________________________
+#include "AliVMisc.h"
+
+#include "Rtypes.h"
+class AliTPCseed;
+class AliVVtrackPointArray;
+class AliExternalTrackParam;
+class AliTrackPointArray;
+
+//_____________________________________________________________________________
+class AliVfriendTrack {
+public:
+
+  AliVfriendTrack(){}
+  // constructor for reinitialisation of vtable
+  AliVfriendTrack( AliVConstructorReinitialisationFlag ){}
+  virtual ~AliVfriendTrack(){}
+
+  //used in calibration
+  
+  virtual Int_t GetTPCseed( AliTPCseed &) const = 0;
+  virtual TObject* GetCalibObject(Int_t /*index*/) const = 0;
+
+  virtual const AliExternalTrackParam* GetTPCOut() const = 0;
+  virtual const AliExternalTrackParam * GetITSOut() const = 0;
+  
+  /*
+  Int_t GetTrackParamTPCOut( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x0  ); }
+  Int_t GetTrackParamITSOut( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x0  ); }
+  Int_t GetTrackParamTRDIn( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x0  ); }
+  */
+
+  virtual const AliTrackPointArray *GetTrackPointArray() const {return NULL ;}
+
+  // bit manipulation for filtering
+  virtual void SetSkipBit(Bool_t skip) = 0;
+  virtual Bool_t TestSkipBit() const = 0;
+
+private: 
+  AliVfriendTrack(const AliVfriendTrack &);
+  AliVfriendTrack& operator=(const AliVfriendTrack& esd);  
+
+};
+
+#endif
+
index d34148d8e092a94f84c8d1613256ca8ee77a55cc..69660544363b46c76f315b503d21fde8df498390 100644 (file)
 #pragma link C++ typedef AliLHCDipValC;
 
 #pragma link C++ class AliMCGenHandler+;
+#pragma link C++ class  AliHLTTestInputHandler+;
 
 #endif
index b5ece9b7edc0b26fb4f4a0077ab92d776c23699d..e508501e8c70459b2610351100c2ec07b0949eb6 100644 (file)
@@ -49,6 +49,7 @@ set ( SRCS
     Calib/AliTPCkalmanAlign.cxx 
     Calib/AliTPCcalibSummary.cxx 
     Calib/AliTPCcalibGainMult.cxx 
+    Calib/AliAnalysisTaskPt.cxx
     )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
diff --git a/TPC/Calib/AliAnalysisTaskPt.cxx b/TPC/Calib/AliAnalysisTaskPt.cxx
new file mode 100644 (file)
index 0000000..8e81dd8
--- /dev/null
@@ -0,0 +1,274 @@
+#include "TChain.h"
+#include "TTree.h"
+#include "TH1F.h"
+#include "TCanvas.h"
+#include "TObjArray.h"
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+
+#include "AliESDEvent.h"
+#include "AliESDtrackCuts.h"
+#include "AliVEventHandler.h"
+#include "AliTPCseed.h"
+#include "AliTPCclusterMI.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+#include "AliESDInputHandler.h"
+
+#include "AliAnalysisTaskPt.h"
+
+// example of an analysis task creating a p_t spectrum
+// Authors: Panos Cristakoglou, Jan Fiete Grosse-Oetringhaus, Christian Klein-Boesing
+
+ClassImp(AliAnalysisTaskPt)
+
+//________________________________________________________________________
+AliAnalysisTaskPt::AliAnalysisTaskPt(const char *name) 
+: AliAnalysisTask(name, ""), fESD(0), fESDfriend(0), fHistPt(0), fCuts(0), fEv(0), fHistQ(0), fListOut(0), fUseFriends(kFALSE), fHistNTPCCl(0), fHistNESDtracks(0),   fHistNESDfriendtracks(0)
+
+{
+  // Constructor
+
+  // Define input and output slots here
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TH1 container
+  DefineOutput(0, TList::Class());
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskPt::ConnectInputData(Option_t *) 
+{
+  // Connect ESD or AOD here
+  // Called once
+
+  printf("----> AliAnalysisTaskPt::ConnectInputData\n");
+  TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
+  if (!tree) {
+    Printf("ERROR: Could not read chain from input slot 0");
+  } 
+  else {
+    // Disable all branches and enable only the needed ones
+    // The next two lines are different when data produced as AliESDEvent is read
+    /*
+    tree->SetBranchStatus("*", kFALSE);
+    tree->SetBranchStatus("fTracks.*", kTRUE);
+    */
+
+    AliVEventHandler *esdH = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+    TString classInputHandler = esdH->ClassName();
+
+    Printf("----> AliAnalysisTaskPt: ClassName of handler = %s", classInputHandler.Data());
+
+    if (!esdH) {
+      Printf("ERROR: Could not get ESDInputHandler");
+    } 
+    else {
+      Printf("----> AliAnalysisTaskPt::ConnectInputData Getting the event from handler %p", esdH);
+      fESD = esdH->GetEvent();
+      if (fUseFriends){
+       Printf("...We have to use the friends...");
+       if (classInputHandler.Contains("HLT")) { // we are running in HLT
+         fESDfriend = esdH->GetVfriendEvent();
+       }
+       else { /// we are running offline
+         if (esdH && esdH->GetTree()) {
+           Printf("...We got the tree...");
+           if (esdH->GetTree()->GetBranch("ESDfriend.")){
+             Printf("Yu-huuuu!!! friend branch found");
+             fESDfriend = ((AliESDInputHandler*)esdH)->GetESDfriend();
+           }
+           else {
+             Printf("No friend branch found");
+           }
+         }
+       }       
+       Printf("and the result is: fESDfriend = %p", fESDfriend);
+      }
+      else {
+       Printf("The friends are not requested");
+      }
+    }
+    if (!fESD) {
+      Printf("ERROR, no ESD event");
+    }
+    if (fUseFriends && !fESDfriend) {
+      Printf("ERROR, no ESD friend");
+    }
+  }
+
+  Printf("fESD = %p, fESDfriend = %p", fESD, fESDfriend);
+  printf("<---- AliAnalysisTaskPt::ConnectInputData\n");
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskPt::CreateOutputObjects()
+{
+  // Create histograms
+  // Called once
+
+  fListOut = new TList();
+  fListOut->SetOwner();
+  fListOut->SetName("listHistos");
+
+  fHistPt = new TH1F("fHistPt", "P_{T} distribution", 15, 0.1, 3.1);
+  fHistPt->GetXaxis()->SetTitle("P_{T} (GeV/c)");
+  fHistPt->GetYaxis()->SetTitle("dN/dP_{T} (c/GeV)");
+  fHistPt->SetMarkerStyle(kFullCircle);
+
+  fHistQ = new TH1F("fHistQ", "TPC clusters: Q distribution", 1000, 0, 10000);
+  fHistQ->GetXaxis()->SetTitle("Q");
+  fHistQ->GetYaxis()->SetTitle("dN/dQ");
+  fHistQ->SetMarkerStyle(kFullCircle);
+
+  fHistNTPCCl = new TH1F("fHistNTPCCl", "Number of TPC clusters", 160, -0.5, 159.5);
+  fHistNTPCCl->GetXaxis()->SetTitle("n. TPC Cl.");
+  fHistNTPCCl->GetYaxis()->SetTitle("dN/d(n. TPC Cl)");
+  fHistNTPCCl->SetMarkerStyle(kFullCircle);
+
+  fHistNESDtracks = new TH1F("fHistNESDtracks", "Number of ESD friend tracks", 1000, -0.5, 999.5);
+  fHistNESDtracks->GetXaxis()->SetTitle("n. ESD friend tracks");
+  fHistNESDtracks->GetYaxis()->SetTitle("dN/d(n. ESD friend tracks)");
+  fHistNESDtracks->SetMarkerStyle(kFullCircle);
+
+  fHistNESDfriendtracks = new TH1F("fHistNESDfriendtracks", "Number of ESD tracks", 1000, -0.5, 999.5);
+  fHistNESDfriendtracks->GetXaxis()->SetTitle("n. ESD tracks");
+  fHistNESDfriendtracks->GetYaxis()->SetTitle("dN/d(n. ESD tracks)");
+  fHistNESDfriendtracks->SetMarkerStyle(kFullCircle);
+
+  fListOut->Add(fHistPt);
+  fListOut->Add(fHistQ);
+  fListOut->Add(fHistNTPCCl);
+  fListOut->Add(fHistNESDtracks);
+  fListOut->Add(fHistNESDfriendtracks);
+
+  PostData(0, fListOut);
+
+  fCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(1);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskPt::Exec(Option_t *) 
+{
+  // Main loop
+  // Called for each event
+
+  if (!fESD) {
+    Printf("ERROR: fESD not available");
+    return;
+  }
+
+  /*
+  if (fUseFriends){
+    Printf("In Exec: ...We have to use the friends...");
+    fESDfriend = fESD->FindFriend();
+    Printf("...and we got friends = %p", fESDfriend);
+    if (!fESDfriend) {
+      Printf("ERROR: fESDfriend not available");
+       return;
+    }
+  }
+  */
+
+  if (fUseFriends){
+    Printf("In Exec: ...We have to use the friends...");
+    Printf("...and we got friends = %p", fESDfriend);
+    if (!fESDfriend) {
+      Printf("ERROR: fESDfriend not available");
+       return;
+    }
+  }
+
+  Int_t nESDtracks = fESD->GetNumberOfTracks();
+  Int_t nESDfriendtracks = 0;
+  if (fUseFriends) nESDfriendtracks = fESDfriend->GetNumberOfTracks();
+  Printf("There are %d tracks in this event", nESDtracks);
+  Printf("... and there are %d friends in this event", nESDfriendtracks);
+
+  fHistNESDtracks->Fill(nESDtracks);
+  fHistNESDfriendtracks->Fill(nESDfriendtracks);
+
+  // Track loop to fill a pT spectrum
+  for (Int_t iTracks = 0; iTracks < nESDtracks; iTracks++) {
+    Printf("Checking track %d", iTracks);
+    const AliVTrack* track = dynamic_cast<AliVTrack*>(fESD->GetTrack(iTracks));
+    if (!track) {
+      Printf("ERROR: Could not receive track %d", iTracks);
+      continue;
+    }
+    Printf("track %d has pt = %f", iTracks, track->Pt());
+    fHistPt->Fill(track->Pt());
+    fHistNTPCCl->Fill(track->GetTPCNcls());
+  } //track loop 
+
+
+  if (fUseFriends){
+    Printf("In the loop over the friends");
+    // Friend Track loop
+    for (Int_t iFriend = 0; iFriend < nESDfriendtracks; iFriend++) {
+      Printf("Getting friend %d", iFriend);
+      const AliVfriendTrack* friendTrack = fESDfriend->GetTrack(iFriend);
+      if (!friendTrack) {
+       Printf("ERROR: Could not receive track %d", iFriend);
+       continue;
+      }
+      else {
+       Printf("friend track = %p", friendTrack);
+      }
+      
+      AliTPCseed seed;
+      Int_t err = friendTrack->GetTPCseed( seed );
+      Printf("err = %d", err);
+      if( err==0 ){
+       Printf("Found TPC seed" );
+       for (Int_t irow = 0; irow < 160; irow++){
+         AliTPCclusterMI* cluMI = seed.GetClusterPointer(irow);
+         if (cluMI){
+           Printf("Found cluster at row %d", irow);
+           Float_t q = cluMI->GetQ();
+           Printf("Q = %f", q);
+           fHistQ->Fill(q);
+         }
+         else {
+           Printf("Row %d does not contain clusters", irow);
+         }              
+       }
+      }            
+      else {
+       //Printf("Schade... seed is %p", seed);
+      }
+    }
+  }
+
+  // Post output data.
+  PostData(0, fListOut);
+  fEv++;
+}      
+
+//________________________________________________________________________
+void AliAnalysisTaskPt::Terminate(Option_t *) 
+{
+  // Draw result to the screen
+  // Called once at the end of the query
+
+  Printf("Terminate called: fESD = %p", fESD);
+
+  fListOut = dynamic_cast<TList*> (GetOutputData(0)); 
+
+  if (fListOut) {
+    fHistPt = dynamic_cast<TH1F*>(fListOut->FindObject("fHistPt")); 
+    if (!fHistPt) {
+      Printf("ERROR: fHistPt not available");
+      return;
+    }
+   
+    TCanvas *c1 = new TCanvas("AliAnalysisTaskPt","Pt",10,10,510,510);
+    c1->cd(1)->SetLogy();
+    fHistPt->DrawCopy("E");
+  }
+  else {
+    Printf("In Terminate: no TList found");
+  }
+
+}
diff --git a/TPC/Calib/AliAnalysisTaskPt.h b/TPC/Calib/AliAnalysisTaskPt.h
new file mode 100644 (file)
index 0000000..116a9f2
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef AliAnalysisTaskPt_cxx
+#define AliAnalysisTaskPt_cxx
+
+// example of an analysis task creating a p_t spectrum
+// Authors: Panos Cristakoglou, Jan Fiete Grosse-Oetringhaus, Christian Klein-Boesing
+
+class TH1F;
+class AliESDEvent;
+class AliVfriendEvent;
+class AliVEvent;
+class AliESDtrackCuts;
+class TList;
+
+#include "AliAnalysisTask.h"
+
+class AliAnalysisTaskPt : public AliAnalysisTask {
+ public:
+ AliAnalysisTaskPt() : AliAnalysisTask(), fESD(0), fESDfriend(0), fHistPt(0), fCuts(0), fEv(0), fHistQ(0), fListOut(0), fUseFriends(0), fHistNTPCCl(0), fHistNESDtracks(0), fHistNESDfriendtracks(0) 
+ {}
+  AliAnalysisTaskPt(const char *name);
+  virtual ~AliAnalysisTaskPt() {}
+  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  
+  Bool_t GetUseFriends() {return fUseFriends;}
+  void   SetUseFriends(Bool_t flag) {fUseFriends = flag;}
+
+ private:
+  AliVEvent*       fESD;                      // ESD object
+  AliVfriendEvent* fESDfriend;                // ESD friend object
+  TH1F*             fHistPt;                   // Pt spectrum
+  AliESDtrackCuts*  fCuts;                     // cuts
+  Int_t fEv;
+  TH1F*             fHistQ;                    // TPC clusters Q spectrum
+  TList*            fListOut;                  // output list
+  Bool_t            fUseFriends;               // flag to decide whether friends should be use
+  TH1F*             fHistNTPCCl;               // histo with the number of TPC clusters
+  TH1F*             fHistNESDtracks;           // histo with number of ESD tracks
+  TH1F*             fHistNESDfriendtracks;     // histo with number of ESD tracks
+
+  AliAnalysisTaskPt(const AliAnalysisTaskPt&); // not implemented
+  AliAnalysisTaskPt& operator=(const AliAnalysisTaskPt&); // not implemented
+  
+  ClassDef(AliAnalysisTaskPt, 1); // example of analysis
+};
+
+#endif
index 28b74cdd9663259360205f39a1e55cd1bb47e5eb..c543f08d9fd08bc6e0905c2ffced26c362fa74cf 100644 (file)
 #include "AliESDfriendTrack.h"
 #include "AliTPCseed.h"
 #include "AliESDInputHandler.h"
+
+#include "AliVEvent.h"
+#include "AliVfriendEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendTrack.h"
+#include "AliVEventHandler.h"
+
 #include "AliAnalysisManager.h"
 #include "TFile.h"
 #include "TSystem.h"
@@ -40,8 +47,8 @@ ClassImp(AliTPCAnalysisTaskcalib)
 AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib()
   :AliAnalysisTask(),
    fCalibJobs(0),
-   fESD(0),
-   fESDfriend(0),
+   fEvent(0),
+   fEventFriend(0),
    fDebugOutputPath("")
 {
   //
@@ -54,8 +61,8 @@ AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib()
 AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name) 
   :AliAnalysisTask(name,""),
    fCalibJobs(0),
-   fESD(0),
-   fESDfriend(0),
+   fEvent(0),
+   fEventFriend(0),
    fDebugOutputPath("")
 {
   //
@@ -84,23 +91,26 @@ void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
   //
   // Exec function
   // Loop over tracks and call  Process function
-  if (!fESD) {
-    //Printf("ERROR: fESD not available");
+    //Printf("AliTPCAnalysisTaskcalib::Exec()...");
+
+  if (!fEvent) {
+    Printf("ERROR AliTPCAnalysisTaskcalib::Exec(): fEvent not available");
     return;
   }
-  fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
-  Int_t n=fESD->GetNumberOfTracks();
-  Process(fESD);
-  if (!fESDfriend) {
-    //Printf("ERROR: fESDfriend not available");
+  fEventFriend=fEvent->FindFriend();
+  //fESDfriend=fESD->FindFriend();
+  Int_t n=fEvent->GetNumberOfTracks();
+  Process(fEvent);
+  if (!fEventFriend) {
+    //Printf("ERROR AliTPCAnalysisTaskcalib::Exec(): fEventFriend not available");
     return;
   }
-  if (fESDfriend->TestSkipBit()) return;
+  if (fEventFriend->TestSkipBit()) return;
   //
-  Int_t run = fESD->GetRunNumber();
+  Int_t run = fEvent->GetRunNumber();
   for (Int_t i=0;i<n;++i) {
-    AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
-    AliESDtrack *track=fESD->GetTrack(i);
+    const AliVfriendTrack *friendTrack=fEventFriend->GetTrack(i);
+    AliVTrack *track=fEvent->GetVTrack(i);
     TObject *calibObject=0;
     AliTPCseed *seed=0;
     if (!friendTrack) continue;
@@ -122,12 +132,13 @@ void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
     //Printf("ERROR: Could not read chain from input slot 0");
   } 
   else {
-    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+    //AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+    AliVEventHandler *esdH = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
     if (!esdH) {
-      //Printf("ERROR: Could not get ESDInputHandler");
+      Printf("ERROR: Could not get ESDInputHandler");
     } 
     else {
-      fESD = esdH->GetEvent();
+      fEvent = esdH->GetEvent();
       //Printf("*** CONNECTED NEW EVENT ****");
     }
   }
@@ -173,10 +184,11 @@ void AliTPCAnalysisTaskcalib::FinishTaskOutput()
 }
 
 
-void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
+void AliTPCAnalysisTaskcalib::Process(AliVEvent *event) {
   //
   // Process ESD event
   //
+    //Printf("AliTPCAnalysisTaskcalib::Process(event)...");
   AliTPCcalibBase *job=0;
   Int_t njobs = fCalibJobs->GetEntriesFast();
   for (Int_t i=0;i<njobs;i++){
@@ -193,6 +205,7 @@ void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
   //
   // Process TPC track
   //
+    //Printf("AliTPCAnalysisTaskcalib::Process(TPC track)...");
   AliTPCcalibBase *job=0;
   Int_t njobs = fCalibJobs->GetEntriesFast();
   for (Int_t i=0;i<njobs;i++){
@@ -203,10 +216,11 @@ void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
   }
 }
 
-void AliTPCAnalysisTaskcalib::Process(AliESDtrack *track, Int_t run) {
+void AliTPCAnalysisTaskcalib::Process(AliVTrack *track, Int_t run) {
   //
   // Process ESD track
   //
+    //Printf("AliTPCAnalysisTaskcalib::Process(ESD track)...");
   AliTPCcalibBase *job=0;
   Int_t njobs = fCalibJobs->GetEntriesFast();
   for (Int_t i=0;i<njobs;i++){
index 0d0f97319512044fdff3600a2e64e6d0347f3fb2..c14d232b2641770e8623fd17063c127003785fba 100644 (file)
 #include "AliAnalysisTask.h"
 #include "TObjArray.h"
 #include "AliTPCcalibBase.h"
-class AliESDEvent;
-class AliESDtrack;
-class AliESDfriend;
+//class AliESDEvent;
+//class AliESDtrack;
+//class AliESDfriend;
+class AliVEvent;
+class AliVTrack;
+class AliVfriendEvent;
+
 class AliTPCseed;
 
 class AliTPCAnalysisTaskcalib:public AliAnalysisTask {
@@ -31,16 +35,16 @@ public:
   virtual void FinishTaskOutput();
   void         SetDebugOuputhPath(const char * name){fDebugOutputPath=name;}
 protected:
-  virtual void     Process(AliESDEvent *event);
+  virtual void     Process(AliVEvent *event);
   virtual void     Process(AliTPCseed *track);
-  virtual void     Process(AliESDtrack *track, Int_t run);
+  virtual void     Process(AliVTrack *track, Int_t run);
   virtual Long64_t Merge(TCollection *li);
   virtual void     Analyze();
   void             RegisterDebugOutput();
 private:
   TObjArray *fCalibJobs;      // array of calibration objects - WE ARE NOT OWNER?
-  AliESDEvent *fESD;         //! current esd
-  AliESDfriend *fESDfriend;  //! current esd friend
+  AliVEvent *fEvent;         //! current event
+  AliVfriendEvent *fEventFriend;  //! current event friend
   TString      fDebugOutputPath; // debug output path   
   AliTPCAnalysisTaskcalib(const AliTPCAnalysisTaskcalib&);
   AliTPCAnalysisTaskcalib& operator=(const AliTPCAnalysisTaskcalib&);
index a130e06c2cdd72e46700163a55383298be1ce305..ac2fd31eb665a11165f5ad2cada36c410aa9b234 100644 (file)
 #include "AliTrackPointArray.h"
 
 #include "AliExternalTrackParam.h"
-#include "AliESDEvent.h"
-#include "AliESDfriend.h"
+//#include "AliESDEvent.h"
+//#include "AliESDfriend.h"
 #include "AliESDtrack.h"
 
+#include "AliVEvent.h"
+#include "AliVfriendEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendTrack.h"
+#include "AliESDVertex.h"
+
 #include "AliTPCTracklet.h"
 #include "TH1D.h"
 #include "TH2F.h"
@@ -449,7 +455,7 @@ AliTPCcalibAlign::~AliTPCcalibAlign() {
 
 }
 
-void AliTPCcalibAlign::Process(AliESDEvent *event) {
+void AliTPCcalibAlign::Process(AliVEvent *event) {
   //
   // Process pairs of cosmic tracks
   //
@@ -461,9 +467,10 @@ void AliTPCcalibAlign::Process(AliESDEvent *event) {
   ExportTrackPoints(event);  // export track points for external calibration 
   const Int_t kMaxTracks =6;
   const Int_t kminCl = 40;
-  AliESDfriend *eESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!eESDfriend) return;
-  if (eESDfriend->TestSkipBit()) return;
+  //AliESDfriend *eESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) return;
+  if (friendEvent->TestSkipBit()) return;
   Int_t ntracks=event->GetNumberOfTracks(); 
   Float_t dca0[2];
   Float_t dca1[2];
@@ -472,21 +479,22 @@ void AliTPCcalibAlign::Process(AliESDEvent *event) {
   // process seeds
   //
   for (Int_t i0=0;i0<ntracks;++i0) {
-    AliESDtrack *track0 = event->GetTrack(i0);
-    AliESDfriendTrack *friendTrack = 0;
+    AliVTrack *track0 = event->GetVTrack(i0);
+    //AliESDfriendTrack *friendTrack = 0;
     TObject *calibObject=0;
     AliTPCseed *seed0 = 0;
     //
-    friendTrack = (AliESDfriendTrack *)eESDfriend->GetTrack(i0);;
+    //friendTrack = (AliESDfriendTrack *)friendEvent->GetTrack(i0);;
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i0);;
     if (!friendTrack) continue;
     for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
       if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
     }
     if (!seed0) continue;
     fCurrentTrack=track0;
-    fCurrentFriendTrack=friendTrack;
+    fCurrentFriendTrack=const_cast<AliVfriendTrack*>(friendTrack);
     fCurrentSeed=seed0;
-    fCurrentEvent=event;
+    fCurrentEvent= event;
     Double_t scalept= TMath::Min(1./TMath::Abs(track0->GetParameter()[4]),2.);
     Bool_t   isSelected = (TMath::Exp(2*scalept)>kptDownscale*gRandom->Rndm());
     if (isSelected) ProcessSeed(seed0);
@@ -498,14 +506,14 @@ void AliTPCcalibAlign::Process(AliESDEvent *event) {
   //
   //select pairs - for alignment  
   for (Int_t i0=0;i0<ntracks;++i0) {
-    AliESDtrack *track0 = event->GetTrack(i0);
+      AliVTrack *track0 = event->GetVTrack(i0);
     //    if (track0->GetTPCNcls()<kminCl) continue;
     track0->GetImpactParameters(dca0[0],dca0[1]);
     //    if (TMath::Abs(dca0[0])>30) continue;
     //
     for (Int_t i1=0;i1<ntracks;++i1) {
       if (i0==i1) continue;
-      AliESDtrack *track1 = event->GetTrack(i1);
+      AliVTrack *track1 = event->GetVTrack(i1);
       //      if (track1->GetTPCNcls()<kminCl) continue;
       track1->GetImpactParameters(dca1[0],dca1[1]);
       // fast cuts on dca and theta
@@ -513,18 +521,18 @@ void AliTPCcalibAlign::Process(AliESDEvent *event) {
       //      if (TMath::Abs(dca1[1]-dca0[1])>15) continue;
       if (TMath::Abs(track0->GetParameter()[3]+track1->GetParameter()[3])>0.1) continue;
       //
-      AliESDfriendTrack *friendTrack = 0;
+      //AliESDfriendTrack *friendTrack = 0; ///!!! then it was used twice, cannot be const pointer
       TObject *calibObject=0;
       AliTPCseed *seed0 = 0,*seed1=0;
       //
-      friendTrack = (AliESDfriendTrack *)eESDfriend->GetTrack(i0);;
-      if (!friendTrack) continue;
-      for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
+      const AliVfriendTrack *friendTrack0 = friendEvent->GetTrack(i0);;
+      if (!friendTrack0) continue;
+      for (Int_t l=0;(calibObject=friendTrack0->GetCalibObject(l));++l) {
        if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
       }
-      friendTrack = (AliESDfriendTrack *)eESDfriend->GetTrack(i1);;
-      if (!friendTrack) continue;
-      for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
+      const AliVfriendTrack *friendTrack1 = friendEvent->GetTrack(i1);;
+      if (!friendTrack1) continue;
+      for (Int_t l=0;(calibObject=friendTrack1->GetCalibObject(l));++l) {
        if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
       }
       if (!seed0) continue;
@@ -608,13 +616,15 @@ void AliTPCcalibAlign::Process(AliESDEvent *event) {
   }
 }
 
-void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
+void  AliTPCcalibAlign::ExportTrackPoints(AliVEvent *event){
   //
   // Export track points for alignment - calibration
   // export space points for pairs of tracks if possible
   //
-  AliESDfriend *eESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!eESDfriend) return;
+  //AliESDfriend *eESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
+
+  if (!friendEvent) return;
   Int_t ntracks=event->GetNumberOfTracks();
   Int_t kMaxTracks=4;   // maximal number of tracks for cosmic pairs
   Int_t kMinVertexTracks=5;   // maximal number of tracks for vertex mesurement
@@ -629,10 +639,13 @@ void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
   const Double_t kDist1Pt = 0.1;
   const Double_t kMaxD0 =3;  // max distance to the primary vertex
   const Double_t kMaxD1 =5;  // max distance to the primary vertex
-  const AliESDVertex *tpcVertex = 0;
+  AliESDVertex *tpcVertex;
+  AliESDVertex tpcVtx;
   // get the primary vertex TPC
   if (ntracks>kMinVertexTracks) {
-    tpcVertex = event->GetPrimaryVertexSPD();
+    event->GetPrimaryVertexSPD(tpcVtx);
+    tpcVertex=&tpcVtx;
+    //event->GetPrimaryVertexSPD(tpcVertex);
     if (tpcVertex->GetNContributors()<kMinVertexTracks) tpcVertex=0;
   }
   //
@@ -641,15 +654,15 @@ void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
   Int_t index0=0,index1=0;
   //
   for (Int_t i0=0;i0<ntracks;++i0) {
-    AliESDtrack *track0 = event->GetTrack(i0);
+    AliVTrack *track0 = event->GetVTrack(i0);
     if (!track0) continue;
-    if ((track0->GetStatus() & AliESDtrack::kTPCrefit)==0) continue;
+    if ((track0->GetStatus() & AliVTrack::kTPCrefit)==0) continue;
     if (track0->GetOuterParam()==0) continue;
     if (track0->GetInnerParam()==0) continue;
     if (TMath::Abs(track0->GetInnerParam()->GetSigned1Pt()-track0->GetOuterParam()->GetSigned1Pt())>kDist1Pt) continue;
     if (TMath::Abs(track0->GetInnerParam()->GetSigned1Pt())>kDist1Pt) continue;
     if (TMath::Abs(track0->GetInnerParam()->GetTgl()-track0->GetOuterParam()->GetTgl())>kDistThS) continue;
-    AliESDtrack *track1P = 0;
+    AliVTrack *track1P = 0;
     if (track0->GetTPCNcls()<kminCl) continue;
     track0->GetImpactParameters(dca0[0],dca0[1]);
     index0=i0;
@@ -657,9 +670,9 @@ void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
     //
     if (ntracks<kMaxTracks) for (Int_t i1=i0+1;i1<ntracks;++i1) {
       if (i0==i1) continue;
-      AliESDtrack *track1 = event->GetTrack(i1);
+      AliVTrack *track1 = event->GetVTrack(i1);
       if (!track1) continue;
-      if ((track1->GetStatus() & AliESDtrack::kTPCrefit)==0) continue;
+      if ((track1->GetStatus() & AliVTrack::kTPCrefit)==0) continue;
       if (track1->GetOuterParam()==0) continue;
       if (track1->GetInnerParam()==0) continue;
       if (track1->GetTPCNcls()<kminCl) continue;
@@ -674,19 +687,20 @@ void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
       track1P = track1;
       index1=i1;
     }
-    AliESDfriendTrack *friendTrack = 0;
+    //AliESDfriendTrack *friendTrack = 0;
     TObject *calibObject=0;
     AliTPCseed *seed0 = 0,*seed1=0;
     //
-    friendTrack = (AliESDfriendTrack *)eESDfriend->GetTrack(index0);;
+    //friendTrack = (AliESDfriendTrack *)friendEvent->GetTrack(index0);;
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(index0);;
     if (!friendTrack) continue;
     for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
       if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
     }
     if (index1>0){
-      friendTrack = (AliESDfriendTrack *)eESDfriend->GetTrack(index1);;
-      if (!friendTrack) continue;
-      for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
+      const AliVfriendTrack *friendTrack1 = friendEvent->GetTrack(index1);;
+      if (!friendTrack1) continue;
+      for (Int_t l=0;(calibObject=friendTrack1->GetCalibObject(l));++l) {
        if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
       }
     }
@@ -745,19 +759,22 @@ void  AliTPCcalibAlign::ExportTrackPoints(AliESDEvent *event){
       Bool_t isVertex=(tpcVertex)? kTRUE:kFALSE;
       Double_t tof0=track0->GetTOFsignal();
       Double_t tof1=(track1P) ?  track1P->GetTOFsignal(): 0;
-      static AliExternalTrackParam dummy;
-      AliExternalTrackParam *p0In  = &dummy;
-      AliExternalTrackParam *p1In  = &dummy;
-      AliExternalTrackParam *p0Out = &dummy;
-      AliExternalTrackParam *p1Out = &dummy;
+      static AliExternalTrackParam param;
+      AliExternalTrackParam *p0In  = &param;
+      AliExternalTrackParam *p1In  = &param;
+      AliExternalTrackParam *p0Out = &param;
+      AliExternalTrackParam *p1Out = &param;
       AliESDVertex vdummy;
       AliESDVertex *pvertex= (tpcVertex)? (AliESDVertex *)tpcVertex: &vdummy;
       if (track0) {
-       p0In= new AliExternalTrackParam(*track0);
+    //p0In= new AliExternalTrackParam(*track0);
+    p0In->CopyFromVTrack(track0);
        p0Out=new AliExternalTrackParam(*(track0->GetOuterParam()));
       }
       if (track1P) {
-       p1In= new AliExternalTrackParam(*track1P);
+    //p1In= new AliExternalTrackParam(*track1P);
+    p1In->CopyFromVTrack(track1P);
+
        p1Out=new AliExternalTrackParam(*(track1P->GetOuterParam()));
       }
 
@@ -2873,7 +2890,10 @@ void  AliTPCcalibAlign::UpdateAlignSector(const AliTPCseed * track,Int_t isec){
   Double_t alpha =2.*TMath::Pi()*(isec%18+0.5)/18.;
   Double_t scos=TMath::Cos(alpha);
   Double_t ssin=TMath::Sin(alpha);
-  const AliESDVertex* vertex = fCurrentEvent->GetPrimaryVertexTracks();
+  AliESDVertex vtx;
+  fCurrentEvent->GetPrimaryVertexTracks(vtx);
+  const AliESDVertex* vertex=&vtx;
+
   vertex->GetXYZ(vPosG.GetMatrixArray());
   fCurrentTrack->GetImpactParameters(vImpact[0],vImpact[1]);  // track impact parameters
   //
index c48d1bf97bf9791478545119193b81b3ae6908ef..3134467ee752fa29c924fe8505a3900ad04b19f7 100644 (file)
@@ -23,6 +23,7 @@ class TTree;
 class AliExternalTrackParam;
 class AliTPCPointCorrection;
 class AliTPCseed;
+class AliVEvent;
 
 class AliTPCcalibAlign:public AliTPCcalibBase {
 public:
@@ -35,13 +36,13 @@ public:
   AliTPCcalibAlign(const AliTPCcalibAlign &align);
   //
   virtual ~AliTPCcalibAlign();
-  void     Process(AliESDEvent *event);
+  void     Process(AliVEvent *event);
   virtual void ProcessSeed(AliTPCseed *track);
   virtual void Process(AliTPCseed */*track*/){ return ;}
   virtual void Analyze();
   virtual void Terminate();  
   virtual Long64_t Merge(TCollection* const list);
-  void ExportTrackPoints(AliESDEvent *event);
+  void ExportTrackPoints(AliVEvent *event);
   //
   //
   void MakeReportDy(TFile *output); 
@@ -90,7 +91,8 @@ public:
 //   Bool_t GetTransformationCovar6(Int_t s1,Int_t s2,TMatrixD &a, Bool_t norm=kFALSE);
   void Add(AliTPCcalibAlign * align);
   const Int_t *GetPoints() const {return fPoints;}
-  void     Process(AliESDtrack *const track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *const track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *const track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   TLinearFitter* GetOrMakeFitter12(Int_t s1,Int_t s2);
   TLinearFitter* GetOrMakeFitter9(Int_t s1,Int_t s2);
   TLinearFitter* GetOrMakeFitter6(Int_t s1,Int_t s2);
index e4e004a0685d072345264e9cdd930e5cec30cf88..ba673f6f41e86ff5ead6b1ed8bcb821d97c5d9e6 100644 (file)
 #include "AliLog.h"
 #include "AliESDEvent.h"
 
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendTrack.h"
+
 
 ClassImp(AliTPCcalibBase)
 
@@ -185,7 +189,7 @@ TTreeSRedirector *AliTPCcalibBase::GetDebugStreamer(){
 }
 
 
-void    AliTPCcalibBase::UpdateEventInfo(AliESDEvent * event){
+void    AliTPCcalibBase::UpdateEventInfo(AliVEvent * event){
   //
   //
   //
@@ -200,7 +204,7 @@ void    AliTPCcalibBase::UpdateEventInfo(AliESDEvent * event){
 }
 
 
-Bool_t AliTPCcalibBase::HasLaser(AliESDEvent *event){
+Bool_t AliTPCcalibBase::HasLaser(AliVEvent *event){
   //
   //
   //
index f40241bcafb07d2313f292e6a881dddec0cd8fcc..2e6275f1285b853535a479d49ac6cae0dbc5b7e8 100644 (file)
 #include "TNamed.h"
 #include "TObjString.h"
 class AliTPCseed;
-class AliESDEvent;
-class AliESDtrack;
-class AliESDfriendTrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
+//class AliESDfriendTrack;
+class AliVfriendTrack;
 class TCollection;
 class TTreeSRedirector;
 class TGraph;
@@ -29,13 +32,19 @@ public:
   AliTPCcalibBase(const AliTPCcalibBase&calib);
   AliTPCcalibBase &operator=(const AliTPCcalibBase&calib);
   virtual ~AliTPCcalibBase();
-  virtual void     Process(AliESDEvent *event){ fCurrentEvent = event; return;}
-  virtual void     Process(AliTPCseed *track){fCurrentSeed = track; return;}
-  virtual void     Process(AliESDtrack *track, Int_t /*runNo=-1*/){fCurrentTrack=track; return;}
+  virtual void     Process(AliVEvent *event){
+      //Printf("AliTPCCalibBase::Process(ESD event)...");
+      fCurrentEvent = event; return;}
+  virtual void     Process(AliTPCseed *track){
+      //Printf("AliTPCCalibBase::Process(TPC track)...");
+      fCurrentSeed = track; return;}
+  virtual void     Process(AliVTrack *track, Int_t /*runNo=-1*/){
+      //Printf("AliTPCCalibBase::Process(ESD track)...");
+      fCurrentTrack=track; return;}
   virtual Long64_t Merge(TCollection */*li*/){return 0;}
   virtual void     Analyze(){return;}
   virtual void     Terminate();
-  virtual void     UpdateEventInfo(AliESDEvent * event);
+  virtual void     UpdateEventInfo(AliVEvent * event);
   virtual Bool_t   AcceptTrigger();
   virtual void     SetTriggerMask(Int_t accept, Int_t reject, Bool_t rejectLaser){fTriggerMaskAccept=accept;fTriggerMaskReject=reject; fRejectLaser = rejectLaser;}
  
@@ -47,7 +56,7 @@ public:
   Int_t      GetStreamLevel() const {return fStreamLevel;}
   Int_t      GetDebugLevel() const {return fDebugLevel;}
   virtual void RegisterDebugOutput(const char *path);
-  static     Bool_t HasLaser(AliESDEvent *event);
+  static     Bool_t HasLaser(AliVEvent *event);
   static TGraphErrors *        FitSlices(THnSparse *h, Int_t axisDim1, Int_t axisDim2, Int_t minEntries, Int_t nmaxBin, Float_t fracLow=0.1, Float_t fracUp=0.9, Bool_t useMedian=kFALSE, TTreeSRedirector *cstream=0, Int_t ival=1);
   static void            BinLogX(THnSparse *h, Int_t axisDim);
   static void            BinLogX(TH1 *h);
@@ -66,9 +75,9 @@ protected:
   Bool_t  fHasLaser;                    //flag the laser is overlayed with given event
   Bool_t  fRejectLaser;                 //flag- reject laser
   TObjString fTriggerClass;             // trigger class
-  AliESDEvent  *fCurrentEvent;          //! current event
-  AliESDtrack *fCurrentTrack;           //! current esd track
-  AliESDfriendTrack *fCurrentFriendTrack;     //! current friend track
+  AliVEvent  *fCurrentEvent;          //! current event
+  AliVTrack *fCurrentTrack;           //! current esd track
+  AliVfriendTrack *fCurrentFriendTrack;     //! current friend track
   AliTPCseed   *fCurrentSeed;           //! current seed
 private:
   Int_t  fDebugLevel;                   //  debug level
index f97c0cc62c6e4b4afc000ef6db073ed5ed1dce74..8a0350b831c3df00b345b6f9e52b101714756cc8 100644 (file)
 #include "TTreeStream.h"
 #include "AliLog.h"
 #include "TTimeStamp.h"
-#include "AliESDEvent.h"
-#include "AliESDfriend.h"
-#include "AliESDtrack.h"
+//#include "AliESDEvent.h"
+//#include "AliESDfriend.h"
+//#include "AliESDtrack.h"
+
+#include "AliVEvent.h"
+#include "AliVfriendEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendTrack.h"
+
 #include "AliTracker.h"
 #include "AliTPCClusterParam.h"
 #include "AliTPCParam.h"
@@ -128,20 +134,21 @@ AliTPCcalibCalib::~AliTPCcalibCalib() {
 }
 
 
-void     AliTPCcalibCalib::Process(AliESDEvent *event){
+void     AliTPCcalibCalib::Process(AliVEvent *event){
   //
   // 
   //
   if (!event) {
     return;
   }  
-  AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!ESDfriend) {
+  //AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
    return;
   }
-  if (ESDfriend->TestSkipBit()) return;
+  if (friendEvent->TestSkipBit()) return;
   if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
-  Int_t ntracks=ESDfriend->GetNumberOfTracks();   
+  Int_t ntracks=friendEvent->GetNumberOfTracks();
   //AliTPCcalibDB::Instance()->SetExBField(fMagF);
 
   //
@@ -149,14 +156,14 @@ void     AliTPCcalibCalib::Process(AliESDEvent *event){
   //
 
   for (Int_t i=0;i<ntracks;++i) {
-    AliESDtrack *track = event->GetTrack(i);     
-    AliESDfriendTrack *friendTrack = (AliESDfriendTrack*) ESDfriend->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
     if (!friendTrack) continue;
     //track->SetFriendTrack(friendTrack);
-    fCurrentFriendTrack=friendTrack;
+    fCurrentFriendTrack=(AliVfriendTrack*)(friendTrack);
     const AliExternalTrackParam * trackIn  = track->GetInnerParam();
     const AliExternalTrackParam * trackOut = track->GetOuterParam();
-    AliExternalTrackParam * tpcOut   = (AliExternalTrackParam *)friendTrack->GetTPCOut();
+    AliExternalTrackParam * tpcOut   = (AliExternalTrackParam *)(friendTrack->GetTPCOut());
     if (!trackIn) continue;
     if (!trackOut) continue;
     if (!tpcOut) continue;   
@@ -172,7 +179,7 @@ void     AliTPCcalibCalib::Process(AliESDEvent *event){
   return;
 }
 
-Bool_t  AliTPCcalibCalib::RefitTrack(AliESDtrack * track, AliTPCseed *seed, Float_t magesd){
+Bool_t  AliTPCcalibCalib::RefitTrack(AliVTrack *track, AliTPCseed *seed, Float_t magesd){
   //
   // Refit track
   // if magesd==0 forget the curvature
@@ -189,7 +196,7 @@ Bool_t  AliTPCcalibCalib::RefitTrack(AliESDtrack * track, AliTPCseed *seed, Floa
 
   static Int_t streamCounter=0;
   streamCounter++;
-  AliESDfriendTrack *friendTrack = fCurrentFriendTrack;
+  AliVfriendTrack *friendTrack = fCurrentFriendTrack;
 
   AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
   AliTPCParam     *param     = AliTPCcalibDB::Instance()->GetParameters();
index 25663ccd95ae65458ce2d1cc601f7c465b1bba1a..3dd666f0944ccd925785979f8ff9432a91325e49 100644 (file)
 
 #include "AliTPCcalibBase.h"
 class AliTPCseed;
-class AliESDEvent;
-class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
 class TCollection;
 class TTreeSRedirector;
 class AliExternalTrackParam;
@@ -24,12 +26,13 @@ public:
   AliTPCcalibCalib(const AliTPCcalibCalib&calib);
   AliTPCcalibCalib &operator=(const AliTPCcalibCalib&calib);
   virtual ~AliTPCcalibCalib();
-  virtual void     Process(AliESDEvent *event);
+  virtual void     Process(AliVEvent *event);
   virtual void     Analyze(){return;}
   
-  Bool_t  RefitTrack(AliESDtrack * track, AliTPCseed *seed, Float_t magesd);
+  Bool_t  RefitTrack(AliVTrack * track, AliTPCseed *seed, Float_t magesd);
   Bool_t  RejectCluster(AliTPCclusterMI* cl, AliExternalTrackParam * param);
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}
 
   void  SetApplyExBCorrection(Int_t flag){fApplyExBCorrection=flag;}
index c9e466575a68b5c655e3240f8a5010669d3ed5a9..aa220af7028ca2b07c8b36f15bfbe97e4a043f28 100644 (file)
 #include "AliTPCseed.h"
 #include "AliESDVertex.h"
 #include "AliESDEvent.h"
+#include "AliESDtrack.h"
 #include "AliESDfriend.h"
 #include "AliESDInputHandler.h"
 #include "AliAnalysisManager.h"
 
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+
 #include "AliTracker.h"
 #include "AliMagF.h"
 #include "AliTPCCalROC.h"
@@ -325,12 +331,12 @@ void AliTPCcalibCosmic::Add(const AliTPCcalibCosmic* cosmic){
 
 
 
-void AliTPCcalibCosmic::Process(AliESDEvent *event) {
+void AliTPCcalibCosmic::Process(AliVEvent *event) {
   //
   // Process of the ESD event  - fill calibration components
   //
   if (!event) {
-    Printf("ERROR: ESD not available");
+    Printf("ERROR: event not available");
     return;
   }  
    
@@ -460,7 +466,7 @@ void AliTPCcalibCosmic::FillHistoPerformance(const AliExternalTrackParam *par0,
   
 }
 
-void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
+void AliTPCcalibCosmic::FindPairs(const AliVEvent *event){
   //
   // Find cosmic pairs
   // 
@@ -468,7 +474,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
   // Track1 is choosen in lower TPC part
   //
   if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
   Int_t ntracks=event->GetNumberOfTracks(); 
   TObjArray  tpcSeeds(ntracks);
   if (ntracks==0) return;
@@ -479,7 +485,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
   //track loop
   //
   for (Int_t i=0;i<ntracks;++i) {
-   AliESDtrack *track = event->GetTrack(i);
+   AliVTrack *track = event->GetVTrack(i);
    fClusters->Fill(track->GetTPCNcls()); 
   
    const AliExternalTrackParam * trackIn = track->GetInnerParam();
@@ -489,7 +495,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
    if (ntracks>4 && TMath::Abs(trackIn->GetTgl())<0.0015) continue;  // filter laser 
 
 
-   AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
+   const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
    if (!friendTrack) continue;
    TObject *calibObject;
    AliTPCseed *seed = 0;   
@@ -519,7 +525,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
   // Find pairs
   //
   for (Int_t i=0;i<ntracks;++i) {
-    AliESDtrack *track0 = event->GetTrack(i);     
+      AliVTrack *track0 = event->GetVTrack(i);
     // track0 - choosen upper part
     if (!track0) continue;
     if (!track0->GetOuterParam()) continue;
@@ -528,7 +534,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
     track0->GetDirection(dir0);    
     for (Int_t j=0;j<ntracks;++j) {
       if (i==j) continue;
-      AliESDtrack *track1 = event->GetTrack(j);   
+      AliVTrack *track1 = event->GetVTrack(j);
       //track 1 lower part
       if (!track1) continue;
       if (!track1->GetOuterParam()) continue;
@@ -569,8 +575,11 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
       //
       //
       Float_t dmax = TMath::Max(TMath::Abs(d0),TMath::Abs(d1));
-      AliExternalTrackParam param0(*track0);
-      AliExternalTrackParam param1(*track1);
+      AliExternalTrackParam param0;
+      param0.CopyFromVTrack(track0);
+
+      AliExternalTrackParam param1;
+      param1.CopyFromVTrack(track1);
       //
       // Propagate using Magnetic field and correct fo material budget
       //
@@ -703,7 +712,7 @@ void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
 
 
 
-void  AliTPCcalibCosmic::FillAcordeHist(AliESDtrack *upperTrack) {
+void  AliTPCcalibCosmic::FillAcordeHist(AliVTrack *upperTrack) {
 
   // Pt cut to select straight tracks which can be easily propagated to ACORDE which is outside the magnetic field
   if (upperTrack->Pt() < 10 || upperTrack->GetTPCNcls() < 80) return;
@@ -984,14 +993,20 @@ void AliTPCcalibCosmic::UpdateTrack(AliExternalTrackParam &track1, const AliExte
 
 
 
-void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
+void AliTPCcalibCosmic::FindCosmicPairs(const AliVEvent *event) {
   //
   // find cosmic pairs trigger by random trigger
   //
   //
-  AliESDVertex *vertexSPD =  (AliESDVertex *)event->GetPrimaryVertexSPD();
-  AliESDVertex *vertexTPC =  (AliESDVertex *)event->GetPrimaryVertexTPC(); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliESDVertex vtxSPD;
+  event->GetPrimaryVertexSPD(vtxSPD);
+  AliESDVertex *vertexSPD=&vtxSPD;
+
+  AliESDVertex vtxTPC;
+  event->GetPrimaryVertexTPC(vtxTPC);
+  AliESDVertex *vertexTPC=&vtxTPC;
+
+  AliVfriendEvent *friendEvent=event->FindFriend();
   const Double_t kMinPt=1;
   const Double_t kMinPtMax=0.8;
   const Double_t kMinNcl=50;
@@ -1006,9 +1021,9 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
 
 
   for (Int_t itrack0=0;itrack0<ntracks;itrack0++) {
-    AliESDtrack *track0 = event->GetTrack(itrack0);
+    AliVTrack *track0 = event->GetVTrack(itrack0);
     if (!track0) continue;
-    if (!track0->IsOn(AliESDtrack::kTPCrefit)) continue;
+    if (!track0->IsOn(AliVTrack::kTPCrefit)) continue;
 
     if (TMath::Abs(AliTracker::GetBz())>1&&track0->Pt()<kMinPt) continue;
     if (track0->GetTPCncls()<kMinNcl) continue;
@@ -1022,9 +1037,9 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
     //if (TMath::Abs(dcaTPC[1])<kMaxDelta[0]*2) continue;
     //    const AliExternalTrackParam * trackIn0 = track0->GetInnerParam();
     for (Int_t itrack1=itrack0+1;itrack1<ntracks;itrack1++) {
-      AliESDtrack *track1 = event->GetTrack(itrack1);
+      AliVTrack *track1 = event->GetVTrack(itrack1);
       if (!track1) continue;  
-      if (!track1->IsOn(AliESDtrack::kTPCrefit)) continue;
+      if (!track1->IsOn(AliVTrack::kTPCrefit)) continue;
       if (track1->GetKinkIndex(0)>0) continue;
       if (TMath::Abs(AliTracker::GetBz())>1&&track1->Pt()<kMinPt) continue;
       if (track1->GetTPCncls()<kMinNcl) continue;
@@ -1055,7 +1070,7 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
       if (!isPair) continue;
       TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
       Int_t eventNumber = event->GetEventNumberInFile(); 
-      Bool_t hasFriend=(esdFriend) ? (esdFriend->GetTrack(itrack0)!=0):0; 
+      Bool_t hasFriend=(friendEvent) ? (friendEvent->GetTrack(itrack0)!=0):0;
       Bool_t hasITS=(track0->GetNcls(0)+track1->GetNcls(0)>4);
       printf("DUMPHPTCosmic:%s|%f|%d|%d|%d\n",filename.Data(),(TMath::Min(track0->Pt(),track1->Pt())), eventNumber,hasFriend,hasITS);
 
@@ -1067,9 +1082,9 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
       Int_t ntracksSPD = vertexSPD->GetNContributors();
       Int_t ntracksTPC = vertexTPC->GetNContributors();
       //
-      AliESDfriendTrack *friendTrack0 = esdFriend->GetTrack(itrack0);
+      const AliVfriendTrack *friendTrack0 = friendEvent->GetTrack(itrack0);
       if (!friendTrack0) continue;
-      AliESDfriendTrack *friendTrack1 = esdFriend->GetTrack(itrack1);
+      const AliVfriendTrack *friendTrack1 = friendEvent->GetTrack(itrack1);
       if (!friendTrack1) continue;
       TObject *calibObject;
       AliTPCseed *seed0 = 0;   
@@ -1081,6 +1096,7 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
       for (Int_t l=0;(calibObject=friendTrack1->GetCalibObject(l));++l) {
        if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
       }
+
       //
       if (pcstream){
        (*pcstream)<<"pairs"<<
@@ -1097,12 +1113,30 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
          "vTPC.="<<vertexTPC<<         //primary vertex -TPC
          "t0.="<<track0<<              //track0
          "t1.="<<track1<<              //track1
-         "ft0.="<<friendTrack0<<       //track0
-         "ft1.="<<friendTrack1<<       //track1
+      //"ft0.="<<dummyfriendTrack0<<       //track0
+      //"ft1.="<<dummyfriendTrack1<<       //track1
          "s0.="<<seed0<<               //track0
          "s1.="<<seed1<<               //track1
          "\n";      
       }
+
+      //**********************TEMPORARY!!*******************************************
+      // more investigation is needed with Tree ///!!!
+      //all dummy stuff here is just for code to compile and work with ESD
+
+      AliESDfriendTrack *dummyfriendTrack0 = (AliESDfriendTrack*)friendTrack0;
+      AliESDfriendTrack *dummyfriendTrack1 = (AliESDfriendTrack*)friendTrack1;
+
+      AliESDtrack *dummytrack0 = (AliESDtrack*)track0;
+      AliESDtrack *dummytrack1 = (AliESDtrack*)track1;
+
+      if ((pcstream)&&(dummyfriendTrack0)){
+          (*pcstream)<<"ft0.="<<dummyfriendTrack0<<"\n";
+      }
+      if ((pcstream)&&(dummyfriendTrack1)){
+          (*pcstream)<<"ft1.="<<dummyfriendTrack1<<"\n";
+      }
+
       if (!fCosmicTree) {
        fCosmicTree = new TTree("pairs","pairs");
        fCosmicTree->SetDirectory(0);
@@ -1110,15 +1144,15 @@ void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
       if (fCosmicTree->GetEntries()==0){
        //
        fCosmicTree->SetDirectory(0);
-       fCosmicTree->Branch("t0.",&track0);
-       fCosmicTree->Branch("t1.",&track1);
-       fCosmicTree->Branch("ft0.",&friendTrack0);
-       fCosmicTree->Branch("ft1.",&friendTrack1);
+    fCosmicTree->Branch("t0.",&dummytrack0);
+    fCosmicTree->Branch("t1.",&dummytrack1);
+    fCosmicTree->Branch("ft0.",&dummyfriendTrack0);
+    fCosmicTree->Branch("ft1.",&dummyfriendTrack1);
       }else{
-       fCosmicTree->SetBranchAddress("t0.",&track0);   
-       fCosmicTree->SetBranchAddress("t1.",&track1);
-       fCosmicTree->SetBranchAddress("ft0.",&friendTrack0);    
-       fCosmicTree->SetBranchAddress("ft1.",&friendTrack1);
+    fCosmicTree->SetBranchAddress("t0.",&dummytrack0);
+    fCosmicTree->SetBranchAddress("t1.",&dummytrack1);
+    fCosmicTree->SetBranchAddress("ft0.",&dummyfriendTrack0);
+    fCosmicTree->SetBranchAddress("ft1.",&dummyfriendTrack1);
       }
       fCosmicTree->Fill();
     }
@@ -1144,7 +1178,7 @@ void AliTPCcalibCosmic::AddTree(TTree* treeOutput, TTree * treeInput){
   //  
   return;
   //if (TMath::Abs(fMagF)<0.1) return; // work around - otherwise crashes 
-  AliESDtrack *track0=new AliESDtrack;
+  AliESDtrack *track0=new AliESDtrack;     ///!!!
   AliESDtrack *track1=new AliESDtrack;
   AliESDfriendTrack *ftrack0=new AliESDfriendTrack;
   AliESDfriendTrack *ftrack1=new AliESDfriendTrack;
index 9b9711262ce8b354b0ddfc15ecbc3e28776d501f..2ecbb46122b3f354e78e756154fd2256a0d27932 100644 (file)
@@ -8,8 +8,10 @@
 class TH2F;
 class TH1F;
 class TList;
-class AliESDEvent;
-class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
 class THnSparse;
 
 class AliTPCcalibCosmic:public AliTPCcalibBase {
@@ -18,14 +20,14 @@ public:
   AliTPCcalibCosmic(const Text_t *name, const Text_t *title);
   virtual ~AliTPCcalibCosmic();
   
-  virtual void      Process(AliESDEvent *event);
+  virtual void      Process(AliVEvent *event);
   virtual Long64_t  Merge(TCollection *const li);
   void              Add(const AliTPCcalibCosmic* cosmic);
   //
   //
   void              Init();
-  void              FindPairs(const AliESDEvent *event);
-  void              FindCosmicPairs(const AliESDEvent * event);
+  void              FindPairs(const AliVEvent *event);
+  void              FindCosmicPairs(const AliVEvent * event);
 
   Bool_t            IsPair(AliExternalTrackParam *tr0, AliExternalTrackParam *tr1) const;
   static void       CalculateBetheParams(TH2F *hist, Double_t * initialParam);
@@ -51,7 +53,8 @@ public:
   static void       BinLogX(TH1 *const h);   // method for correct histogram binning
   static void       BinLogX(THnSparse *const h, Int_t axisDim);   // method for correct histogram binning
 
-  void     Process(AliESDtrack *const track, Int_t runNo=-1) {AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *const track, Int_t runNo=-1) {AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *const track, Int_t runNo=-1) {AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *const track)  {return AliTPCcalibBase::Process(track);}
   virtual void  Terminate();
   static Double_t GetDeltaTime(Double_t rmin0, Double_t rmax0, Double_t rmin1, Double_t rmax1, Double_t tmin0, Double_t tmax0, Double_t tmin1, Double_t tmax1, Double_t dcaR, TVectorD& vectorDT);
@@ -66,7 +69,7 @@ public:
   static void AddTree(TTree* treeOutput, TTree * treeInput);
 private:
   
-  void              FillAcordeHist(AliESDtrack *upperTrack);
+  void              FillAcordeHist(AliVTrack *upperTrack);
 
   
 
index f7f590628d24ca942da2f6e52508c804d1daadbf..db44b143c78e0325b1f9d452c52a89c7b8a4e575 100644 (file)
@@ -44,12 +44,18 @@ Send comments etc. to: A.Kalweit@gsi.de, marian.ivanov@cern.ch
 #include "AliTPCClusterParam.h"
 #include "AliTPCseed.h"
 #include "AliESDVertex.h"
-#include "AliESDEvent.h"
-#include "AliESDfriend.h"
+//#include "AliESDEvent.h"
+//#include "AliESDfriend.h"
+#include "AliESDfriendTrack.h"
 #include "AliESDInputHandler.h"
 #include "AliAnalysisManager.h"
 #include "AliTPCParam.h"
 
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+
 #include "AliComplexCluster.h"
 #include "AliTPCclusterMI.h"
 
@@ -291,7 +297,7 @@ AliTPCcalibGainMult::~AliTPCcalibGainMult(){
 
 
 
-void AliTPCcalibGainMult::Process(AliESDEvent *event) {
+void AliTPCcalibGainMult::Process(AliVEvent *event) {
   //
   // Main function of the class
   // 1. Select Identified  particles - for identified particles the flag in the PID matrix is stored
@@ -314,25 +320,30 @@ void AliTPCcalibGainMult::Process(AliESDEvent *event) {
   //const Double_t kMaxDCAR=10; // maximal DCA R of the track
   //const Double_t kMaxDCAZ=5;  // maximal DCA Z of the track
   //  const Double_t kMIPPt=0.525; // MIP pt
+
+    //Printf("AliTPCcalibGainMult::Process()...");
+
+    //AliESDEvent *event=(AliESDEvent*)event;
   
   if (!event) {
-    Printf("ERROR: ESD not available");
+    Printf("ERROR AliTPCcalibGainMult::Process(): event not available");
     return;
   }  
-  fCurrentEvent=event  ;
+  fCurrentEvent=event;
   fMagF = event->GetMagneticField();
   Int_t ntracks=event->GetNumberOfTracks();  
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
-    //Printf("ERROR: esdFriend not available");
+  //AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindFriend());
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
+    Printf("ERROR: esdFriend not available");
     delete fPIDMatrix;
     return;
   }
-  if (!(esdFriend->TestSkipBit())) fPIDMatrix= new TMatrixD(ntracks,5);
+  if (!(friendEvent->TestSkipBit())) fPIDMatrix= new TMatrixD(ntracks,5);
   fHistNTracks->Fill(ntracks);
   //  ProcessCosmic(event);  // usually not enogh statistic
 
-  if (esdFriend->TestSkipBit()) {
+  if (friendEvent->TestSkipBit()) {
     return;
    }
   //
@@ -347,7 +358,8 @@ void AliTPCcalibGainMult::Process(AliESDEvent *event) {
   //
   for (Int_t i=0;i<ntracks;++i) {
     //
-    AliESDtrack *track = event->GetTrack(i);
+    //AliESDtrack *track = (AliESDtrack*)(event->GetTrack(i));
+    AliVTrack *track = event->GetVTrack(i);
     if (!track) continue;
     //   
     AliExternalTrackParam * trackIn  = (AliExternalTrackParam *)track->GetInnerParam();
@@ -372,13 +384,19 @@ void AliTPCcalibGainMult::Process(AliESDEvent *event) {
     if (TMath::Abs(trackIn->Eta()) > fCutEtaWindow) continue;
 
     UInt_t status = track->GetStatus();
-    if ((status&AliESDtrack::kTPCrefit)==0) continue;
-    if ((status&AliESDtrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
+    //if ((status&AliESDtrack::kTPCrefit)==0) continue;
+    //if ((status&AliESDtrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
+
+    if ((status&AliVTrack::kTPCrefit)==0) continue;
+    if ((status&AliVTrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
+
     Float_t dca[2], cov[3];
     track->GetImpactParameters(dca,cov);
     Float_t primVtxDCA = TMath::Sqrt(dca[0]*dca[0]);
     if (TMath::Abs(dca[0]) > fCutMaxDcaXY || TMath::Abs(dca[0]) < 0.0000001) continue;  // cut in xy
-    if (((status&AliESDtrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
+    //if (((status&AliESDtrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
+    if (((status&AliVTrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
+
     //
     //  
     // fill Alexander QA histogram
@@ -386,7 +404,8 @@ void AliTPCcalibGainMult::Process(AliESDEvent *event) {
     if (primVtxDCA < 3 && track->GetNcls(0) > 3 && track->GetKinkIndex(0) == 0 && ncls > 100) fHistQA->Fill(meanP, track->GetTPCsignal(), 5);
 
     // Get seeds
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
+    //AliESDfriendTrack *friendTrack = friendEvent->GetTrack(i);
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
     if (!friendTrack) continue;
     TObject *calibObject;
     AliTPCseed *seed = 0;
@@ -749,7 +768,7 @@ void AliTPCcalibGainMult::UpdateClusterParam() {
 }
 
 
-void AliTPCcalibGainMult::DumpTrack(AliESDtrack * track, AliESDfriendTrack *ftrack, AliTPCseed * seed, Int_t index){
+void AliTPCcalibGainMult::DumpTrack(AliVTrack * track, AliVfriendTrack *ftrack, AliTPCseed * seed, Int_t index){
   //
   // dump interesting tracks
   // 1. track at MIP region
@@ -803,7 +822,9 @@ void AliTPCcalibGainMult::DumpTrack(AliESDtrack * track, AliESDfriendTrack *ftra
   static Double_t radius1= roc->GetPadRowRadiiUp(30);
   static Double_t radius2= roc->GetPadRowRadiiUp(roc->GetNRows(36)-15);
 
-  AliESDVertex *vertex= (AliESDVertex *)fCurrentEvent->GetPrimaryVertex();
+  AliESDVertex vtx;
+  fCurrentEvent->GetPrimaryVertex(vtx);
+  AliESDVertex *vertex=&vtx;
   //
   // Estimate current MIP position - 
   //
@@ -1252,18 +1273,19 @@ void AliTPCcalibGainMult::DumpTrack(AliESDtrack * track, AliESDfriendTrack *ftra
 
 
 
-void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
+void AliTPCcalibGainMult::ProcessV0s(AliVEvent *event){
   //
   // Select the K0s and gamma  - and sign daughter products 
   //  
   TTreeSRedirector * pcstream =  GetDebugStreamer();
   AliKFParticle::SetField(event->GetMagneticField()); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
-    //Printf("ERROR: esdFriend not available");
+  //AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindFriend());
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
+    //Printf("ERROR: friendEvent not available");
    return;
   }
-  if (esdFriend->TestSkipBit()) return;
+  if (friendEvent->TestSkipBit()) return;
   //
   // 
   static const TDatabasePDG *pdg = TDatabasePDG::Instance();  
@@ -1274,11 +1296,23 @@ void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
   const Double_t kMaxREl=70;
   //
   Int_t nv0 = event->GetNumberOfV0s(); 
-  AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+
+
+  //AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+  AliESDVertex vtx;
+  event->GetPrimaryVertex(vtx);
+  AliESDVertex *vertex=&vtx;
+
   AliKFVertex kfvertex=*vertex;
+
+
   //
   for (Int_t iv0=0;iv0<nv0;iv0++){
-    AliESDv0 *v0 = event->GetV0(iv0);
+    //AliESDv0 *v0 = event->GetV0(iv0);
+    AliESDv0 v0dummy;
+    event->GetV0(v0dummy, iv0);
+    AliESDv0 *v0 = &v0dummy;
+
     if (!v0) continue;
     if (v0->GetOnFlyStatus()<0.5) continue;
     if (v0->GetPindex()<0) continue;
@@ -1331,8 +1365,10 @@ void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
     //
     Int_t pindex = (v0->GetParamP()->GetSign()>0) ? v0->GetPindex() : v0->GetNindex();
     Int_t nindex = (v0->GetParamP()->GetSign()>0) ? v0->GetNindex() : v0->GetPindex();
-    AliESDtrack * trackP = event->GetTrack(pindex);
-    AliESDtrack * trackN = event->GetTrack(nindex);
+    //AliESDtrack * trackP = (AliESDtrack*)event->GetTrack(pindex);
+    //AliESDtrack * trackN = (AliESDtrack*)event->GetTrack(nindex);
+    AliVTrack * trackP = event->GetVTrack(pindex);
+    AliVTrack * trackN = event->GetVTrack(nindex);
     if (!trackN) continue;
     if (!trackP) continue;
     Int_t nclP= (Int_t)trackP->GetTPCClusterInfo(2,1);
@@ -1342,8 +1378,10 @@ void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
     if (TMath::Abs(eta)>1) continue;
     //
     //
-    AliESDfriendTrack *friendTrackP = esdFriend->GetTrack(pindex);
-    AliESDfriendTrack *friendTrackN = esdFriend->GetTrack(nindex);
+    //AliESDfriendTrack *friendTrackP = friendEvent->GetTrack(pindex);
+    //AliESDfriendTrack *friendTrackN = friendEvent->GetTrack(nindex);
+    const AliVfriendTrack *friendTrackP = friendEvent->GetTrack(pindex);
+    const AliVfriendTrack *friendTrackN = friendEvent->GetTrack(nindex);
     if (!friendTrackP) continue;
     if (!friendTrackN) continue;
     TObject *calibObject;
@@ -1383,7 +1421,7 @@ void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
 
 
 
-void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
+void AliTPCcalibGainMult::ProcessCosmic(const AliVEvent *event) {
   //
   // Find cosmic pairs trigger by random trigger
   // 
@@ -1391,9 +1429,16 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
   AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
   AliTPCParam     *param     = AliTPCcalibDB::Instance()->GetParameters();
 
-  AliESDVertex *vertexSPD =  (AliESDVertex *)event->GetPrimaryVertexSPD();
-  AliESDVertex *vertexTPC =  (AliESDVertex *)event->GetPrimaryVertexTPC(); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliESDVertex vtxSPD;
+  event->GetPrimaryVertexSPD(vtxSPD);
+  AliESDVertex *vertexSPD=&vtxSPD;
+
+  AliESDVertex vtxTPC;
+  event->GetPrimaryVertexTPC(vtxTPC);
+  AliESDVertex *vertexTPC=&vtxTPC;
+
+  //AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
   const Double_t kMinPt=4;
   const Double_t kMinPtMax=0.8;
   const Double_t kMinNcl=159*0.5;
@@ -1408,9 +1453,9 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
   
 
   for (Int_t itrack0=0;itrack0<ntracks;itrack0++) {
-    AliESDtrack *track0 = event->GetTrack(itrack0);
+    AliVTrack *track0 = event->GetVTrack(itrack0);
     if (!track0) continue;
-    if (!track0->IsOn(AliESDtrack::kTPCrefit)) continue;
+    if (!track0->IsOn(AliVTrack::kTPCrefit)) continue;
 
     if (TMath::Abs(AliTracker::GetBz())>1&&track0->Pt()<kMinPt) continue;
     if (track0->GetTPCncls()<kMinNcl) continue;
@@ -1421,9 +1466,9 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
     //rm primaries
     //
     for (Int_t itrack1=itrack0+1;itrack1<ntracks;itrack1++) {
-      AliESDtrack *track1 = event->GetTrack(itrack1);
+      AliVTrack *track1 = event->GetVTrack(itrack1);
       if (!track1) continue;  
-      if (!track1->IsOn(AliESDtrack::kTPCrefit)) continue;
+      if (!track1->IsOn(AliVTrack::kTPCrefit)) continue;
       if (track1->GetKinkIndex(0)>0) continue;
       if (TMath::Abs(AliTracker::GetBz())>1&&track1->Pt()<kMinPt) continue;
       if (track1->GetTPCncls()<kMinNcl) continue;
@@ -1447,7 +1492,7 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
       if (!isPair) continue;
       TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
       Int_t eventNumber = event->GetEventNumberInFile(); 
-      Bool_t hasFriend=(esdFriend) ? (esdFriend->GetTrack(itrack0)!=0):0; 
+      Bool_t hasFriend=(friendEvent) ? (friendEvent->GetTrack(itrack0)!=0):0;
       Bool_t hasITS=(track0->GetNcls(0)+track1->GetNcls(0)>4);
       AliInfo(Form("DUMPHPTCosmic:%s|%f|%d|%d|%d\n",filename.Data(),(TMath::Min(track0->Pt(),track1->Pt())), eventNumber,hasFriend,hasITS));
       //
@@ -1474,9 +1519,9 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
          "\n";      
       }
       //
-      AliESDfriendTrack *friendTrack0 = esdFriend->GetTrack(itrack0);
+      const AliVfriendTrack *friendTrack0 = friendEvent->GetTrack(itrack0);
       if (!friendTrack0) continue;
-      AliESDfriendTrack *friendTrack1 = esdFriend->GetTrack(itrack1);
+      const AliVfriendTrack *friendTrack1 = friendEvent->GetTrack(itrack1);
       if (!friendTrack1) continue;
       TObject *calibObject;
       AliTPCseed *seed0 = 0;   
@@ -1504,12 +1549,21 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
          "vTPC.="<<vertexTPC<<         //primary vertex -TPC
          "t0.="<<track0<<              //track0
          "t1.="<<track1<<              //track1
-         "ft0.="<<friendTrack0<<       //track0
-         "ft1.="<<friendTrack1<<       //track1
+      //"ft0.="<<friendTrack0<<       //track0
+      //"ft1.="<<friendTrack1<<       //track1
          "s0.="<<seed0<<               //track0
          "s1.="<<seed1<<               //track1
          "\n";      
       }
+
+      if ((pcstream)&&((AliESDfriendTrack*)friendTrack0)){
+          (*pcstream)<<"ft0.="<<((AliESDfriendTrack*)friendTrack0)<<"\n";
+      }
+      if ((pcstream)&&((AliESDfriendTrack*)friendTrack1)){
+          (*pcstream)<<"ft1.="<<((AliESDfriendTrack*)friendTrack1)<<"\n";
+      }
+
+
       if (!seed0) continue;
       if (!seed1) continue;
       Int_t nclA0=0, nclC0=0;     // number of clusters
@@ -1571,13 +1625,13 @@ void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
 
 
 
-void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
+void AliTPCcalibGainMult::ProcessKinks(const AliVEvent *event){
   //
   //
   //
   AliKFParticle::SetField(event->GetMagneticField()); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
     //Printf("ERROR: esdFriend not available");
     return;
   }
@@ -1590,7 +1644,11 @@ void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
   const Int_t    kMinNcl=110;
   //
   Int_t nkinks = event->GetNumberOfKinks(); 
-  AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+  //AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+  AliESDVertex vtx;
+  event->GetPrimaryVertex(vtx);
+  AliESDVertex *vertex=&vtx;
+
   AliKFVertex kfvertex=*vertex;
   TTreeSRedirector * pcstream =  GetDebugStreamer();
   //
@@ -1610,8 +1668,8 @@ void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
     AliKFParticle *v0KF = new AliKFParticle(kfpm,kfpd); 
     v0KF->SetVtxGuess(kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]);
     Double_t chi2 = v0KF->GetChi2();
-    AliESDtrack * trackM = event->GetTrack(kink->GetIndex(0));
-    AliESDtrack * trackD = event->GetTrack(kink->GetIndex(1));
+    AliVTrack * trackM = event->GetVTrack(kink->GetIndex(0));
+    AliVTrack * trackD = event->GetVTrack(kink->GetIndex(1));
     if (!trackM) continue;
     if (!trackD) continue;
     Int_t nclM= (Int_t)trackM->GetTPCClusterInfo(2,1);
@@ -1662,8 +1720,8 @@ void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
     if (TMath::Abs(eta)>1) continue;
     //
     //
-    AliESDfriendTrack *friendTrackM = esdFriend->GetTrack(kink->GetIndex(0));
-    AliESDfriendTrack *friendTrackD = esdFriend->GetTrack(kink->GetIndex(1));
+    const AliVfriendTrack *friendTrackM = friendEvent->GetTrack(kink->GetIndex(0));
+    const AliVfriendTrack *friendTrackD = friendEvent->GetTrack(kink->GetIndex(1));
     if (!friendTrackM) continue;
     if (!friendTrackD) continue;
     TObject *calibObject;
@@ -1678,7 +1736,7 @@ void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
   }
 }
 
-void AliTPCcalibGainMult::DumpHPT(const AliESDEvent * event){
+void AliTPCcalibGainMult::DumpHPT(const AliVEvent *event){
   //
   // Function to select the HPT tracks and events
   // It is used to select event with HPT - list used later for the raw data downloading
@@ -1687,27 +1745,27 @@ void AliTPCcalibGainMult::DumpHPT(const AliESDEvent * event){
 
   TTreeSRedirector * pcstream =  GetDebugStreamer();
   AliKFParticle::SetField(event->GetMagneticField()); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
     //Printf("ERROR: esdFriend not available");
    return;
   }
-  if (esdFriend->TestSkipBit()) return;
+  if (friendEvent->TestSkipBit()) return;
 
   Int_t ntracks=event->GetNumberOfTracks(); 
   //
   for (Int_t i=0;i<ntracks;++i) {
     //
-    AliESDtrack *track = event->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
     if (!track) continue;
     if (track->Pt()<4) continue; 
     UInt_t status = track->GetStatus();
     //   
     AliExternalTrackParam * trackIn  = (AliExternalTrackParam *)track->GetInnerParam();
     if (!trackIn) continue;
-    if ((status&AliESDtrack::kTPCrefit)==0) continue;
-    if ((status&AliESDtrack::kITSrefit)==0) continue;
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
+    if ((status&AliVTrack::kTPCrefit)==0) continue;
+    if ((status&AliVTrack::kITSrefit)==0) continue;
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
     if (!friendTrack) continue;
     AliExternalTrackParam * itsOut = (AliExternalTrackParam *)(friendTrack->GetITSOut());
     if (!itsOut) continue;
@@ -1731,7 +1789,10 @@ void AliTPCcalibGainMult::DumpHPT(const AliESDEvent * event){
     tpcInnerC->Rotate(track->GetAlpha());
     tpcInnerC->PropagateTo(track->GetX(),event->GetMagneticField());
     Double_t dz[2],cov[3];
-    AliESDVertex *vtx= (AliESDVertex *)event->GetPrimaryVertex();
+    AliESDVertex dummyvtx;
+    event->GetPrimaryVertex(dummyvtx);
+    AliESDVertex *vtx=&dummyvtx;
+
   
     if (!tpcInnerC->PropagateToDCA(vtx, event->GetMagneticField(), 3, dz, cov)) continue;
     Double_t covar[6]; vtx->GetCovMatrix(covar);
@@ -1763,7 +1824,7 @@ void AliTPCcalibGainMult::DumpHPT(const AliESDEvent * event){
 
 
 
-void AliTPCcalibGainMult::ProcessTOF(const AliESDEvent * event){
+void AliTPCcalibGainMult::ProcessTOF(const AliVEvent *event){
   //
   // 1. Loop over tracks
   // 2. Fit T0
@@ -1774,12 +1835,14 @@ void AliTPCcalibGainMult::ProcessTOF(const AliESDEvent * event){
   const Double_t kMaxD=20;
   const Double_t kRMS0=200; 
   const Double_t kMaxDCAZ=10;
-  AliESDVertex *vtx= (AliESDVertex *)event->GetPrimaryVertex();
+  AliESDVertex dummyvtx;
+  event->GetPrimaryVertex(dummyvtx);
+  AliESDVertex *vtx=&dummyvtx;
   //
   TTreeSRedirector * pcstream =  GetDebugStreamer();
   AliKFParticle::SetField(event->GetMagneticField()); 
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
     //Printf("ERROR: esdFriend not available");
    return;
   }
@@ -1799,9 +1862,9 @@ void AliTPCcalibGainMult::ProcessTOF(const AliESDEvent * event){
     counter=0;
     for (Int_t i=0;i<ntracks;++i) {
       //
-      AliESDtrack *track = event->GetTrack(i);
+      AliVTrack *track = event->GetVTrack(i);
       if (!track) continue;
-      if (!track->IsOn(AliESDtrack::kTIME)) continue;
+      if (!track->IsOn(AliVTrack::kTIME)) continue;
       if (TMath::Abs(track->GetZ())>kMaxDCAZ) continue;         // remove overlaped events
       if (TMath::Abs(track->GetTOFsignalDz())>kMaxD) continue;
       Double_t times[1000];
@@ -1832,9 +1895,9 @@ void AliTPCcalibGainMult::ProcessTOF(const AliESDEvent * event){
   //
   for (Int_t i=0;i<ntracks;++i) {
     //
-    AliESDtrack *track = event->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
     if (!track) continue;
-    if (!track->IsOn(AliESDtrack::kTIME)) continue;
+    if (!track->IsOn(AliVTrack::kTIME)) continue;
     if (TMath::Abs(track->GetZ())>kMaxDCAZ) continue;          //remove overlapped events
     if (TMath::Abs(track->GetTOFsignalDz())>kMaxD) continue;
     Double_t times[1000];
index 7896be8fe11747b8be50d42be4cd33f4c33aa6bf..4dfb4e983852e774717e236e6326789ce13b7ef1 100644 (file)
 #include "TVectorD.h"
 class TH1F;
 class TList;
-class AliESDEvent;
-class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
+class AliVfriendTrack;
 class AliTPCseed;
 
 #include "TTreeStream.h"
@@ -29,15 +32,24 @@ public:
   void SetBBParam(TVectorD * param) {fBBParam=param;}
   //  virtual void Terminate();  
   //
-  virtual void           Process(AliESDEvent *event);
-  virtual void           ProcessV0s(AliESDEvent *event);
-  virtual void           ProcessCosmic(const AliESDEvent *event);
-  virtual void           ProcessKinks(const AliESDEvent *event);
-  virtual void           ProcessTOF(const AliESDEvent *event);  
-  virtual void           DumpHPT(const AliESDEvent *event);
+  //virtual void           Process(AliESDEvent *event);
+  virtual void           Process(AliVEvent *event);
+
+  //virtual void           ProcessV0s(AliESDEvent *event);
+  //virtual void           ProcessCosmic(const AliESDEvent *event);
+  //virtual void           ProcessKinks(const AliESDEvent *event);
+  //virtual void           ProcessTOF(const AliESDEvent *event);
+  //virtual void           DumpHPT(const AliESDEvent *event);
+
+  virtual void           ProcessV0s(AliVEvent *event);
+  virtual void           ProcessCosmic(const AliVEvent *event);
+  virtual void           ProcessKinks(const AliVEvent *event);
+  virtual void           ProcessTOF(const AliVEvent *event);
+  virtual void           DumpHPT(const AliVEvent *event);
+
   virtual Long64_t       Merge(TCollection *li);
   virtual void           Analyze();
-  void                   DumpTrack(AliESDtrack * track, AliESDfriendTrack *ftrack, AliTPCseed * seed, Int_t index);
+  void                   DumpTrack(AliVTrack * track, AliVfriendTrack *ftrack, AliTPCseed * seed, Int_t index);
   //
   TH1F   *          GetHistNTracks() const {return fHistNTracks;};
   TH1F   *          GetHistClusterShape() const {return fHistClusterShape;};
@@ -72,7 +84,8 @@ public:
   void SetAlephParameters(Float_t * parameters){for(Int_t j=0;j<5;j++) fAlephParameters[j] = parameters[j];};
   //
   //
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}
   //
   void     MakeLookup(THnSparse * hist, Char_t * outputFile);
index cac5c4a668fec2f877ae658f9f0bddca4b9374af..77b0e89a1b70fd5b8315a292aaa55fe8838e3266 100644 (file)
 #include "TLinearFitter.h"
 #include "AliTPCcalibLaser.h"
 #include "AliExternalTrackParam.h"
-#include "AliESDEvent.h"
-#include "AliESDfriend.h"
-#include "AliESDtrack.h"
+//#include "AliESDEvent.h"
+//#include "AliESDfriend.h"
+//#include "AliESDtrack.h"
+
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+
 #include "AliTPCTracklet.h"
 #include "TH1D.h"
 #include "TH1F.h"
@@ -136,11 +142,11 @@ ClassImp(AliTPCcalibLaser)
 
 AliTPCcalibLaser::AliTPCcalibLaser():
   AliTPCcalibBase(),
-  fESD(0),
-  fESDfriend(0),
+  fEvent(0),
+  fEventFriend(0),
   fNtracks(0),
   fTracksMirror(336),
-  fTracksEsd(336),
+  fTracks(336),
   fTracksEsdParam(336),
   fTracksTPC(336),
   fFullCalib(kTRUE),
@@ -245,11 +251,11 @@ AliTPCcalibLaser::AliTPCcalibLaser():
 
 AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title, Bool_t full):
   AliTPCcalibBase(),
-  fESD(0),
-  fESDfriend(0),
+  fEvent(0),
+  fEventFriend(0),
   fNtracks(0),
   fTracksMirror(336),
-  fTracksEsd(336),
+  fTracks(336),
   fTracksEsdParam(336),
   fTracksTPC(336),
   fFullCalib(full),
@@ -361,11 +367,11 @@ AliTPCcalibLaser::AliTPCcalibLaser(const Text_t *name, const Text_t *title, Bool
 
 AliTPCcalibLaser::AliTPCcalibLaser(const AliTPCcalibLaser& calibLaser):
   AliTPCcalibBase(calibLaser), 
-  fESD(0),
-  fESDfriend(0),
+  fEvent(0),
+  fEventFriend(0),
   fNtracks(0),
   fTracksMirror(336),
-  fTracksEsd(336),
+  fTracks(336),
   fTracksEsdParam(336),
   fTracksTPC(336),
   fFullCalib(calibLaser.fFullCalib),
@@ -575,7 +581,7 @@ AliTPCcalibLaser::~AliTPCcalibLaser() {
 
 
 
-void AliTPCcalibLaser::Process(AliESDEvent * event) {
+void AliTPCcalibLaser::Process(AliVEvent *event) {
   //
   //
   // Loop over tracks and call  Process function
@@ -583,24 +589,25 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
   const Int_t  kMinTracks=20;
   const Int_t  kMinClusters=40;
 
-  fESD = event;
-  if (!fESD) {
+  fEvent = event;
+  if (!fEvent) {
+      Printf("****ERROR AliTPCcalibLaser::Process(): Event not available!!********");
     return;
   }
-  fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
-  if (!fESDfriend) {
+  fEventFriend=fEvent->FindFriend();
+  if (!fEventFriend) {
     return;
   }
-  if (fESDfriend->TestSkipBit()) return;
-  if (fESD->GetNumberOfTracks()<kMinTracks) return; //not enough tracks
+  if (fEventFriend->TestSkipBit()) return;
+  if (fEvent->GetNumberOfTracks()<kMinTracks) return; //not enough tracks
   AliDebug(4,Form("Event number in current file: %d",event->GetEventNumberInFile()));
   //
   // find CE background if present
   //
   if (AliTPCLaserTrack::GetTracks()==0) AliTPCLaserTrack::LoadTracks();
   TH1D hisCE("hhisCE","hhisCE",100,-100,100);  
-  for (Int_t i=0;i<fESD->GetNumberOfTracks();++i) {
-    AliESDtrack *track=fESD->GetTrack(i);
+  for (Int_t i=0;i<fEvent->GetNumberOfTracks();++i) {
+    AliVTrack *track=fEvent->GetVTrack(i);
     if (!track) continue;
     hisCE.Fill(track->GetZ());
     hisCE.Fill(track->GetZ()+2);
@@ -611,7 +618,7 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
 
 
   fTracksTPC.Clear();
-  fTracksEsd.Clear();
+  fTracks.Clear();
   fTracksEsdParam.Delete();
   for (Int_t id=0; id<336;id++) {
     fCounter[id]=0;
@@ -619,12 +626,12 @@ void AliTPCcalibLaser::Process(AliESDEvent * event) {
     fClusterSatur[id]=0;
   }
   //
-  Int_t n=fESD->GetNumberOfTracks();
+  Int_t n=fEvent->GetNumberOfTracks();
   Int_t counter=0;
   for (Int_t i=0;i<n;++i) {
-    AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
+    const AliVfriendTrack *friendTrack=fEventFriend->GetTrack(i);
     if (!friendTrack) continue;
-    AliESDtrack *track=fESD->GetTrack(i);
+    AliVTrack *track= fEvent->GetVTrack(i);
     if (!track) continue;
     Double_t binC = hisCE.GetBinContent(hisCE.FindBin(track->GetZ()));
     if (binC>336) continue; //remove CE background
@@ -689,7 +696,7 @@ void AliTPCcalibLaser::MakeDistHisto(Int_t id){
 
     AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
     AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
-    AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
+    AliVTrack   *track    = (AliVTrack*)fTracks.At(id);
     if (!param) return;
     if (!ltrp) return;
     if (!track) return;
@@ -796,7 +803,7 @@ void AliTPCcalibLaser::FitDriftV(){
       if (!AcceptLaser(id)) continue;
       if ( fClusterSatur[id]>kSaturCut)  continue;
       if ( fClusterCounter[id]<kMinClusters)  continue;
-      AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
+      AliVTrack   *track    = (AliVTrack*)fTracks.At(id);
       if (track->GetTPCsignal()<kMinSignal) continue;
       AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
       AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
@@ -1099,7 +1106,7 @@ Bool_t  AliTPCcalibLaser::FitDriftV(Float_t minFraction){
       if (!AcceptLaser(id)) continue;
       if ( fClusterSatur[id]>kSaturCut)  continue;
       if ( fClusterCounter[id]<kMinClusters)  continue;
-      AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
+      AliVTrack   *track    = (AliVTrack*)fTracks.At(id);
       if (track->GetTPCsignal()<kMinSignal) continue;
       AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
       AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
@@ -1356,7 +1363,7 @@ Bool_t  AliTPCcalibLaser::AcceptLaser(Int_t id){
   return kTRUE;
 }
 
-Int_t  AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
+Int_t  AliTPCcalibLaser::FindMirror(AliVTrack *track, AliTPCseed *seed){
   //
   // Find corresponding mirror
   // add the corresponding tracks
@@ -1436,7 +1443,7 @@ Int_t  AliTPCcalibLaser::FindMirror(AliESDtrack *track, AliTPCseed *seed){
   if (accept){
     fClusterCounter[id]=countercl;
     fTracksEsdParam.AddAt(param.Clone(),id);
-    fTracksEsd.AddAt(track,id);
+    fTracks.AddAt(track,id);
     fTracksTPC.AddAt(seed,id);
   }
   return id;
@@ -1448,7 +1455,7 @@ void AliTPCcalibLaser::DumpLaser(Int_t id) {
   //
   //  Dump Laser info to the tree
   //
-  AliESDtrack   *track    = (AliESDtrack*)fTracksEsd.At(id);
+  AliVTrack   *track    = (AliVTrack*)fTracks.At(id);
   AliExternalTrackParam *param=(AliExternalTrackParam*)fTracksEsdParam.At(id);
   AliTPCLaserTrack *ltrp = ( AliTPCLaserTrack*)fTracksMirror.At(id);
   //
@@ -1469,7 +1476,7 @@ void AliTPCcalibLaser::DumpLaser(Int_t id) {
   
   if (fStreamLevel>0){
     TTreeSRedirector *cstream = GetDebugStreamer();
-    Int_t time = fESD->GetTimeStamp();
+    Int_t time = fEvent->GetTimeStamp();
     Bool_t accept = AcceptLaser(id);
     if (cstream){
       (*cstream)<<"Track"<<
index 9a764a72ebb61e0175d6277046e05acd814ad850..900f998d5c887576d86ef0ac1820412553bca809 100644 (file)
 
 
 class AliExternalTrackParam;
-class AliESDtrack;
-class AliESDEvent;
-class AliESDfriend;
+//class AliESDtrack;
+//class AliESDEvent;
+//class AliESDfriend;
+class AliVEvent;
+class AliVTrack;
+class AliVfriendEvent;
 class TGraphErrors;
 class TTree;
 class TH2F;
@@ -34,7 +37,7 @@ public:
   AliTPCcalibLaser(const AliTPCcalibLaser& laser);
   AliTPCcalibLaser & operator=(const AliTPCcalibLaser& calibLaser);
   virtual ~AliTPCcalibLaser();
-  virtual void     Process(AliESDEvent *event);
+  virtual void     Process(AliVEvent *event);
   Int_t   GetNtracks(){return fNtracks;}
   virtual void Analyze();
   static void        DumpLaser(const char *finput, Int_t run);
@@ -54,13 +57,14 @@ public:
   void         MakeDistHisto(Int_t id);
   void         AddCut(Double_t xcut, Double_t ycut, Double_t ncl){fEdgeXcuts[fNcuts]=xcut; fEdgeYcuts[fNcuts]=ycut; fNClCuts[fNcuts]=ncl; fNcuts++;}
 
-  Int_t  FindMirror(AliESDtrack *track, AliTPCseed *seed);
+  Int_t  FindMirror(AliVTrack *track, AliTPCseed *seed);
   Bool_t AcceptLaser(Int_t id);
   Float_t GetDistance(AliExternalTrackParam *track, AliTPCLaserTrack *ltrp);
   void   MakeFitHistos();
   void   UpdateFitHistos();
   void   MergeFitHistos(AliTPCcalibLaser * add);
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}
   //
   void SetBeamParameters(TVectorD& meanOffset, TVectorD& meanSlope,
@@ -70,12 +74,12 @@ public:
     {fUseFixedDriftV = 1; fFixedFitAside0=aside0; fFixedFitAside1=aside1;
     fFixedFitCside0=cside0; fFixedFitCside1=cside1;}
 
-  AliESDEvent  * fESD;             //! ESD event  - not OWNER
-  AliESDfriend * fESDfriend;       //! ESD event  - not OWNER
+  AliVEvent  * fEvent;             //! ESD event  - not OWNER
+  AliVfriendEvent * fEventFriend;       //! ESD event  - not OWNER
   Int_t          fNtracks;         //! counter of associated laser tracks
   //
   TObjArray      fTracksMirror;    //! tracks with mirror information
-  TObjArray      fTracksEsd;       //! tracks with reconstructed information - 
+  TObjArray      fTracks;       //! tracks with reconstructed information -
   //                               not owner ESD
   TObjArray      fTracksEsdParam;  //! tracks with reconstructed information - 
   //                               is owner ESD at mirror
index 6df9bf499df75734e32e97488f08263dc4755877..e844d0b8d6c76e209d108d4fa5b9a04e75357eb4 100644 (file)
@@ -39,10 +39,16 @@ Comments to be written here:
 
 #include "AliDCSSensor.h"
 #include "AliDCSSensorArray.h"
-#include "AliESDEvent.h"
+//#include "AliESDEvent.h"
 #include "AliESDInputHandler.h"
 #include "AliESDVertex.h"
-#include "AliESDfriend.h"
+//#include "AliESDfriend.h"
+
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+
 #include "AliLog.h"
 #include "AliRelAlignerKalman.h"
 #include "AliTPCCalROC.h"
@@ -366,19 +372,31 @@ void AliTPCcalibTime::ResetCurrent(){
 
 
 
-void AliTPCcalibTime::Process(AliESDEvent *event){
+void AliTPCcalibTime::Process(AliVEvent *event){
   //
   // main function to make calibration
   //
-  if(!event) return;
-  if (event->GetNumberOfTracks()<2) return; 
-  AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!ESDfriend) {
+
+    //Printf("*******************AliTPCcalibTime::Process()*******************");
+  if(!event) {
+      Printf("ERROR AliTPCcalibTime::Process(): NO EVENT AVAILABLE!");
+      return;
+  }
+  if (event->GetNumberOfTracks()<2) {
+      //Printf("ACHTUNG AliTPCcalibTime::Process(): not enough tracks!");
+      return;
+  }
+  //AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
+    Printf("ERROR AliTPCcalibTime::Process(): NO FRIEND AVAILABLE!");
     return;
   }
-  if (ESDfriend->TestSkipBit()) return;
+  if (friendEvent->TestSkipBit()) return;
   
   ResetCurrent();
+
+  //AliESDEvent *ev=(AliESDEvent*)event;
   //if(IsLaser  (event)) 
   ProcessLaser (event);
   //if(IsCosmics(event)) 
@@ -387,7 +405,7 @@ void AliTPCcalibTime::Process(AliESDEvent *event){
   ProcessBeam  (event);
 }
 
-void AliTPCcalibTime::ProcessLaser(AliESDEvent *event){
+void AliTPCcalibTime::ProcessLaser(AliVEvent *event){
   //
   // Fit drift velocity using laser 
   // 
@@ -516,12 +534,12 @@ void AliTPCcalibTime::ProcessLaser(AliESDEvent *event){
   }
 }
 
-void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
+void AliTPCcalibTime::ProcessCosmic(const AliVEvent *const event){
   //
   // process Cosmic event - track matching A side C side
   //
   if (!event) {
-    Printf("ERROR: ESD not available");
+    Printf("ERROR: event not available");
     return;
   }  
   if (event->GetTimeStamp() == 0 ) {
@@ -542,8 +560,8 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
   if (ntracks > fCutTracks) return;
   
   if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
-  AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
-  
+  //AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
   TObjArray  tpcSeeds(ntracks);
   Double_t vtxx[3]={0,0,0};
   Double_t svtxx[3]={0.000001,0.000001,100.};
@@ -556,17 +574,17 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
   for (Int_t i=0;i<ntracks;++i) {
     clusterSideA[i]=0;
     clusterSideC[i]=0;
-    AliESDtrack *track = event->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
     
     const AliExternalTrackParam * trackIn = track->GetInnerParam();
     const AliExternalTrackParam * trackOut = track->GetOuterParam();
     if (!trackIn) continue;
     if (!trackOut) continue;
     
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
     if (!friendTrack) continue;
     if (friendTrack) ProcessSame(track,friendTrack,event);
-    if (friendTrack) ProcessAlignITS(track,friendTrack,event,esdFriend);
+    if (friendTrack) ProcessAlignITS(track,friendTrack,event,friendEvent);
     if (friendTrack) ProcessAlignTRD(track,friendTrack);
     if (friendTrack) ProcessAlignTOF(track,friendTrack);
     TObject *calibObject;
@@ -591,7 +609,7 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
   //
 
   for (Int_t i=0;i<ntracks;++i) {
-    AliESDtrack *track0 = event->GetTrack(i);
+    AliVTrack *track0 = event->GetVTrack(i);
     // track0 - choosen upper part
     if (!track0) continue;
     if (!track0->GetOuterParam()) continue;
@@ -600,7 +618,7 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
     track0->GetDirection(d1);    
     for (Int_t j=0;j<ntracks;++j) {
       if (i==j) continue;
-      AliESDtrack *track1 = event->GetTrack(j);   
+      AliVTrack *track1 = event->GetVTrack(j);
       //track 1 lower part
       if (!track1) continue;
       if (!track1->GetOuterParam()) continue;
@@ -640,8 +658,10 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
       //
       //
       Float_t dmax = TMath::Max(TMath::Abs(dist0),TMath::Abs(dist1));
-      AliExternalTrackParam param0(*track0);
-      AliExternalTrackParam param1(*track1);
+      AliExternalTrackParam param0;
+      param0.CopyFromVTrack(track0);
+      AliExternalTrackParam param1;
+      param1.CopyFromVTrack(track1);
       //
       // Propagate using Magnetic field and correct fo material budget
       //
@@ -759,7 +779,7 @@ void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
   if (GetDebugLevel()>20) printf("Trigger: %s\n",event->GetFiredTriggerClasses().Data());
 }
 
-void AliTPCcalibTime::ProcessBeam(const AliESDEvent *const event){
+void AliTPCcalibTime::ProcessBeam(const AliVEvent *const event){
   //
   // Process beam data - calculates vartex
   //                     from A side and C side
@@ -792,23 +812,38 @@ void AliTPCcalibTime::ProcessBeam(const AliESDEvent *const event){
   if (ntracks==0) return;
   if (ntracks > fCutTracks) return;
   //
-  AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
+  //AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
   //
   // Divide tracks to A and C side tracks - using the cluster indexes
   TObjArray tracksA(ntracks);  
   TObjArray tracksC(ntracks);  
   //
-  AliESDVertex *vertexSPD =  (AliESDVertex *)event->GetPrimaryVertexSPD();
-  AliESDVertex *vertex    =  (AliESDVertex *)event->GetPrimaryVertex();
-  AliESDVertex *vertexTracks =  (AliESDVertex *)event->GetPrimaryVertexTracks();
+  //AliESDVertex *vertexSPD =  (AliESDVertex *)event->GetPrimaryVertexSPD();
+  //AliESDVertex *vertex    =  (AliESDVertex *)event->GetPrimaryVertex();
+  //AliESDVertex *vertexTracks =  (AliESDVertex *)event->GetPrimaryVertexTracks();
+
+  AliESDVertex vtxSPD;
+  event->GetPrimaryVertexSPD(vtxSPD);
+  AliESDVertex *vertexSPD=&vtxSPD;
+
+  AliESDVertex vtx;
+  event->GetPrimaryVertex(vtx);
+  AliESDVertex *vertex=&vtx;
+
+  AliESDVertex vtxTracks;
+  event->GetPrimaryVertexTracks(vtxTracks);
+  AliESDVertex *vertexTracks=&vtxTracks;
+
+
   Double_t vertexZA[10000], vertexZC[10000];
   //
   Int_t ntracksA= 0;
   Int_t ntracksC= 0;
   //
   for (Int_t itrack=0;itrack<ntracks;itrack++) {
-    AliESDtrack *track = event->GetTrack(itrack);
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(itrack);
+    AliVTrack *track = event->GetVTrack(itrack);
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(itrack);
     if (!friendTrack) continue;
     if (TMath::Abs(track->GetTgl())>kMaxTgl) continue;
     if (TMath::Abs(track->Pt())<kMinPt) continue;
@@ -1257,7 +1292,7 @@ Bool_t  AliTPCcalibTime::IsPair(const AliExternalTrackParam *tr0, const AliExter
 
   return kTRUE;  
 }
-Bool_t AliTPCcalibTime::IsCross(const AliESDtrack *const tr0, const AliESDtrack *const tr1){
+Bool_t AliTPCcalibTime::IsCross(const AliVTrack *const tr0, const AliVTrack *const tr1){
   //
   // check if the cosmic pair of tracks crossed A/C side
   // 
@@ -1267,7 +1302,7 @@ Bool_t AliTPCcalibTime::IsCross(const AliESDtrack *const tr0, const AliESDtrack
   return result;
 }
 
-Bool_t AliTPCcalibTime::IsSame(const AliESDtrack *const tr0, const AliESDtrack *const tr1){
+Bool_t AliTPCcalibTime::IsSame(const AliVTrack *const tr0, const AliVTrack *const tr1){
   // 
   // track crossing the CE
   // 0. minimal number of clusters 
@@ -1320,7 +1355,7 @@ Bool_t AliTPCcalibTime::IsSame(const AliESDtrack *const tr0, const AliESDtrack *
 }
 
 
-void  AliTPCcalibTime::ProcessSame(const AliESDtrack *const track, AliESDfriendTrack *const friendTrack, const AliESDEvent *const event){
+void  AliTPCcalibTime::ProcessSame(const AliVTrack *const track, const AliVfriendTrack *const friendTrack, const AliVEvent *const event){
   //
   // Process  TPC tracks crossing CE
   //
@@ -1483,7 +1518,7 @@ void  AliTPCcalibTime::ProcessSame(const AliESDtrack *const track, AliESDfriendT
 
 }
 
-void  AliTPCcalibTime::ProcessAlignITS(AliESDtrack *const track, const AliESDfriendTrack *const friendTrack, const AliESDEvent *const event, AliESDfriend *const esdFriend){
+void  AliTPCcalibTime::ProcessAlignITS(AliVTrack *const track, const AliVfriendTrack *const friendTrack, const AliVEvent *const event, AliVfriendEvent *const friendEvent){
   //
   // Process track - Update TPC-ITS alignment
   // Updates: 
@@ -1512,7 +1547,7 @@ void  AliTPCcalibTime::ProcessAlignITS(AliESDtrack *const track, const AliESDfri
   // 
   Int_t dummycl[1000];
   if (track->GetTPCNcls()<kMinTPC) return;  // minimal amount of clusters cut
-  if (!track->IsOn(AliESDtrack::kTPCrefit)) return;
+  if (!track->IsOn(AliVTrack::kTPCrefit)) return;
   if (!track->GetInnerParam())   return;
   if (!track->GetOuterParam())   return;
   if (track->GetInnerParam()->Pt()<kMinPt)  return;
@@ -1531,17 +1566,17 @@ void  AliTPCcalibTime::ProcessAlignITS(AliESDtrack *const track, const AliESDfri
     AliTracker::PropagateTrackToBxByBz(&pITS2,pTPC.GetX(),0.1,0.1,kFALSE);
   }
 
-  AliESDfriendTrack *itsfriendTrack=0;
+  //AliESDfriendTrack *itsfriendTrack=0;
   //
   // try to find standalone ITS track corresponing to the TPC if possible
   //
   Bool_t hasAlone=kFALSE;
   Int_t ntracks=event->GetNumberOfTracks();
   for (Int_t i=0; i<ntracks; i++){
-    AliESDtrack * trackITS = event->GetTrack(i); 
+    AliVTrack * trackITS = event->GetVTrack(i);
     if (!trackITS) continue;
     if (trackITS->GetITSclusters(dummycl)<kMinITS) continue;  // minimal amount of clusters
-    itsfriendTrack = esdFriend->GetTrack(i);
+    const AliVfriendTrack *itsfriendTrack = friendEvent->GetTrack(i);
     if (!itsfriendTrack) continue;
     if (!itsfriendTrack->GetITSOut()) continue;
      
@@ -1672,7 +1707,7 @@ void  AliTPCcalibTime::ProcessAlignITS(AliESDtrack *const track, const AliESDfri
 
 
 
-void  AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, const AliESDfriendTrack *const friendTrack){
+void  AliTPCcalibTime::ProcessAlignTRD(AliVTrack *const track, const AliVfriendTrack *const friendTrack){
   //
   // Process track - Update TPC-TRD alignment
   // Updates: 
@@ -1703,7 +1738,7 @@ void  AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, const AliESDfri
   if (track->GetTPCNcls()<kMinTPC) return;  // minimal amount of clusters cut
   //  if (!friendTrack->GetTRDIn()) return;  
   //  if (!track->IsOn(AliESDtrack::kTRDrefit)) return;   
-  if (!track->IsOn(AliESDtrack::kTRDout)) return;  
+  if (!track->IsOn(AliVTrack::kTRDout)) return;
   if (!track->GetInnerParam())   return;
   if (!friendTrack->GetTPCOut())   return;
   // exclude crossing track
@@ -1713,7 +1748,7 @@ void  AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, const AliESDfri
   AliTracker::PropagateTrackToBxByBz(&pTPC,kRefX,0.1,0.1,kFALSE);
   AliExternalTrackParam *pTRDtrack = 0; 
   TObject *calibObject=0;
-  for (Int_t l=0;(calibObject=((AliESDfriendTrack*)friendTrack)->GetCalibObject(l));++l) {
+  for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
     if ((dynamic_cast< AliTPCseed*>(calibObject))) continue;
     if ((pTRDtrack=dynamic_cast< AliExternalTrackParam*>(calibObject))) break;
   }
@@ -1840,7 +1875,7 @@ void  AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, const AliESDfri
 }
 
 
-void  AliTPCcalibTime::ProcessAlignTOF(AliESDtrack *const track, const AliESDfriendTrack *const friendTrack){
+void  AliTPCcalibTime::ProcessAlignTOF(AliVTrack *const track, const AliVfriendTrack *const friendTrack){
   //
   //
   // Process track - Update TPC-TOF alignment
@@ -2193,7 +2228,7 @@ void        AliTPCcalibTime::FillResHistoTPCITS(const AliExternalTrackParam * pT
 }  
 
      
-void        AliTPCcalibTime::FillResHistoTPC(const AliESDtrack * pTrack){
+void        AliTPCcalibTime::FillResHistoTPC(const AliVTrack *pTrack){
   //
   // fill residual histograms pTPC - vertex
   // Histogram is filled only for primary tracks
index ea629f77f8ca42bfda7516a8411537f59d432ba7..265f5f4739ecabd60e3d066b6808f38d3211720d 100644 (file)
@@ -20,12 +20,17 @@ class TH3F;
 class TH2F;
 class TH1D;
 class TList;
-class AliESDEvent;
-class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
+class AliExternalTrackParam;
 class AliTPCcalibLaser;
 class TGraphErrors;
 class AliSplineFit;
-class AliESDfriendTrack;
+//class AliESDfriendTrack;
+class AliVfriendTrack;
+class AliVfriendEvent;
 
 class AliTPCcalibTime:public AliTPCcalibBase {
 public:
@@ -33,22 +38,26 @@ public:
   AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeVdrift, Int_t memoryMode=2);
   virtual ~AliTPCcalibTime();
   
-  virtual void           Process(AliESDEvent *event);
+  virtual void           Process(AliVEvent *event);
   virtual Long64_t       Merge(TCollection *const li);
   virtual void           Analyze();
   //static Bool_t          IsLaser      (const AliESDEvent *const event) const;
   //static Bool_t          IsCosmics    (const AliESDEvent *const event) const;
   //static Bool_t          IsBeam       (const AliESDEvent *const event) const;
-  void                   ProcessLaser (AliESDEvent *event);
-  void                   ProcessCosmic(const AliESDEvent *const event);
-  void                   ProcessBeam  (const AliESDEvent *const event);
+  //void                   ProcessLaser (AliESDEvent *event);
+  //void                   ProcessCosmic(const AliESDEvent *const event);
+  //void                   ProcessBeam  (const AliESDEvent *const event);
+  void                   ProcessLaser (AliVEvent *event);
+  void                   ProcessCosmic(const AliVEvent *const event);
+  void                   ProcessBeam  (const AliVEvent *const event);
+
   Bool_t                 IsPair(const AliExternalTrackParam *tr0, const AliExternalTrackParam *tr1);
-  Bool_t                 IsCross(const AliESDtrack *const tr0, const AliESDtrack *const tr1);
-  Bool_t                 IsSame (const AliESDtrack *const tr0, const AliESDtrack *const tr1);
-  void                   ProcessSame(const AliESDtrack *const track, AliESDfriendTrack *const friendTrack, const AliESDEvent *const event);
-  void                   ProcessAlignITS(AliESDtrack *const track, const AliESDfriendTrack *const friendTrack, const AliESDEvent *const event, AliESDfriend *const ESDfriend);
-  void                   ProcessAlignTRD(AliESDtrack* const track, const AliESDfriendTrack *const friendTrack);
-  void                   ProcessAlignTOF(AliESDtrack* const track, const AliESDfriendTrack *const friendTrack);
+  Bool_t                 IsCross(const AliVTrack *const tr0, const AliVTrack *const tr1);
+  Bool_t                 IsSame (const AliVTrack *const tr0, const AliVTrack *const tr1);
+  void                   ProcessSame(const AliVTrack *const track, const AliVfriendTrack *const friendTrack, const AliVEvent *const event);
+  void                   ProcessAlignITS(AliVTrack *const track, const AliVfriendTrack *const friendTrack, const AliVEvent *const event, AliVfriendEvent *const friendEvent);
+  void                   ProcessAlignTRD(AliVTrack* const track, const AliVfriendTrack *const friendTrack);
+  void                   ProcessAlignTOF(AliVTrack* const track, const AliVfriendTrack *const friendTrack);
 
   THnSparse*    GetHistVdriftLaserA(Int_t index=1) const {return fHistVdriftLaserA[index];};
   THnSparse*    GetHistVdriftLaserC(Int_t index=1) const {return fHistVdriftLaserC[index];};
@@ -59,7 +68,8 @@ public:
   AliSplineFit* GetFitDrift(const char* name);
 //  TObjArray*    GetFitDrift();
   TH1F*         GetCosmiMatchingHisto(Int_t index=0) const {return fCosmiMatchingHisto[index];};
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}
   TObjArray* GetAlignITSTPC() const {return fAlignITSTPC;}              // alignemnt array ITS TPC match
   TObjArray* GetAlignTRDTPC() const {return fAlignTRDTPC;}              // alignemnt array TRD TPC match
@@ -77,7 +87,7 @@ public:
   void        BookDistortionMaps();      // book histograms
   void        FillResHistoTPCCE(const AliExternalTrackParam * pTPCIn, const AliExternalTrackParam * pTPCOut );       // fill residual histo
   void        FillResHistoTPCITS(const AliExternalTrackParam * pTPCIn, const AliExternalTrackParam * pITSOut );       // fill residual histo
-  void        FillResHistoTPC(const AliESDtrack * pTrack);
+  void        FillResHistoTPC(const AliVTrack * pTrack);
   void        FillResHistoTPCTRD(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTRDIn );
   void        FillResHistoTPCTOF(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTOFIn );
 
index 2245496133895395e24ba20c4aba4cf578aa83d4..8f4017501bd0bd91ff1027ce63f974d898cdd735 100644 (file)
@@ -156,11 +156,16 @@ TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
 #include "AliTPCclusterMI.h"
 #include "AliTPCseed.h"
 #include "AliESDVertex.h"
-#include "AliESDEvent.h"
+//#include "AliESDEvent.h"
 #include "AliESDfriend.h"
-#include "AliESDInputHandler.h"
+//#include "AliESDInputHandler.h"
 #include "AliAnalysisManager.h"
 
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendEvent.h"
+#include "AliVfriendTrack.h"
+
 #include "AliTracker.h"
 #include "AliMagF.h"
 #include "AliTPCCalROC.h"
@@ -308,19 +313,27 @@ AliTPCcalibTimeGain::~AliTPCcalibTimeGain(){
 }
 
 
-void AliTPCcalibTimeGain::Process(AliESDEvent *event) {
+void AliTPCcalibTimeGain::Process(AliVEvent *event) {
   //
   // main track loop
   //
+    //Printf("AliTPCcalibTimeGain::Process(event)...");
+
   if (!event) {
-    Printf("ERROR: ESD not available");
+    Printf("ERROR AliTPCcalibTimeGain::Process(): event not available");
     return;
   }
-  AliESDfriend *ESDfriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!ESDfriend) {
+
+  AliVfriendEvent *friendEvent=event->FindFriend();
+
+  if (!friendEvent) {
+      Printf("ERROR AliTPCcalibTimeGain::Process(): friendEvent not available");
    return;
   }
-  if (ESDfriend->TestSkipBit()) return;
+  //Printf("friendEvent->TestSkipBit() = %d",friendEvent->TestSkipBit() );
+  if (friendEvent->TestSkipBit()) {
+      return;
+  }
 
   if (fIsCosmic) { // this should be removed at some point based on trigger mask !?
     ProcessCosmicEvent(event);
@@ -328,34 +341,33 @@ void AliTPCcalibTimeGain::Process(AliESDEvent *event) {
     ProcessBeamEvent(event);
   }
   
-
-  
-  
 }
 
 
-void AliTPCcalibTimeGain::ProcessCosmicEvent(AliESDEvent *event) {
+void AliTPCcalibTimeGain::ProcessCosmicEvent(AliVEvent *event) {
   //
   // Process in case of cosmic event
   //
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
-   Printf("ERROR: ESDfriend not available");
+    //Printf("AliTPCcalibTimeGain::ProcessCosmicEvent(event)...");
+
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
+   Printf("ERROR AliTPCcalibTimeGain::ProcessCosmicEvent(): ESDfriend not available");
    return;
   }
   //
   UInt_t time = event->GetTimeStamp();
-  Int_t nFriendTracks = esdFriend->GetNumberOfTracks();
+  Int_t nFriendTracks = friendEvent->GetNumberOfTracks();
   Int_t runNumber = event->GetRunNumber();
   //
   // track loop
   //
   for (Int_t i=0;i<nFriendTracks;++i) {
 
-    AliESDtrack *track = event->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
     if (!track) continue;
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
-    if (!friendTrack) continue;        
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
+    if (!friendTrack) continue;
     const AliExternalTrackParam * trackIn = track->GetInnerParam();
     const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
     if (!trackIn) continue;
@@ -397,28 +409,34 @@ void AliTPCcalibTimeGain::ProcessCosmicEvent(AliESDEvent *event) {
 
 
 
-void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
+void AliTPCcalibTimeGain::ProcessBeamEvent(AliVEvent *event) {
   //
   // Process in case of beam event
   //
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
-  if (!esdFriend) {
-   Printf("ERROR: ESDfriend not available");
+    //Printf("AliTPCcalibTimeGain::ProcessBeamEvent(event)...");
+
+  AliVfriendEvent *friendEvent=event->FindFriend();
+  if (!friendEvent) {
+   Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDfriend not available");
    return;
   }
   //
   UInt_t time = event->GetTimeStamp();
-  Int_t nFriendTracks = esdFriend->GetNumberOfTracks();
+  if (!time) Printf("ERROR: no time stamp available!");
+  Int_t nFriendTracks = friendEvent->GetNumberOfTracks();
   Int_t runNumber = event->GetRunNumber();
   //
   // track loop
   //
   for (Int_t i=0;i<nFriendTracks;++i) { // begin track loop
 
-    AliESDtrack *track = event->GetTrack(i);
-    if (!track) continue;
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
-    if (!friendTrack) continue;
+    AliVTrack *track = event->GetVTrack(i);
+    if (!track) {Printf("***ERROR*** : track not available");  continue;}
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
+    if (!friendTrack) {
+        Printf("ERROR ProcessBeamEvent(): friendTrack is not available!");
+        continue;
+    }
         
     const AliExternalTrackParam * trackIn = track->GetInnerParam();
     const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
@@ -438,13 +456,13 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
     if (TMath::Abs(trackIn->Eta()) > fCutEtaWindow) continue;
     //
     UInt_t status = track->GetStatus();
-    if ((status&AliESDtrack::kTPCrefit)==0) continue;
-    if ((status&AliESDtrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
+    if ((status&AliVTrack::kTPCrefit)==0) continue;
+    if ((status&AliVTrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
     //
     Float_t dca[2], cov[3];
     track->GetImpactParameters(dca,cov);
     if (TMath::Abs(dca[0]) > fCutMaxDcaXY || TMath::Abs(dca[0]) < 0.0000001) continue;  // cut in xy
-    if (((status&AliESDtrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
+    if (((status&AliVTrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
     //
     Double_t eta = trackIn->Eta();
     
@@ -476,10 +494,12 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
                                                                    fAlephParameters[4]);
        tpcSignal /= corrFactor; 
       }        
+      //Printf("Fill DeDx histo..");
       fHistDeDxTotal->Fill(meanP, tpcSignal);
       //
       //dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 protons), momenta, runNumner, eta
       Double_t vec[7] = {tpcSignal,static_cast<Double_t>(time),static_cast<Double_t>(particleCase),meanDrift,meanP,static_cast<Double_t>(runNumber), eta};
+      //Printf("Fill Gain histo in track loop...");
       fHistGainTime->Fill(vec);
     }
     
@@ -488,7 +508,13 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
   // V0 loop -- in beam events the cosmic part of the histogram is filled with GammaConversions
   //
   for(Int_t iv0 = 0; iv0 < event->GetNumberOfV0s(); iv0++) {
-    AliESDv0 * v0 = event->GetV0(iv0);
+    //AliESDv0 * v0 = event->GetV0(iv0);
+     AliESDv0 v0dummy;
+     event->GetV0(v0dummy, iv0);
+     AliESDv0 *v0 = &v0dummy;
+
+     if (!v0) Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDv0 not available! ");
+
     if (!v0->GetOnFlyStatus()) continue;
     if (v0->GetEffMass(0,0) > 0.02) continue; // select low inv. mass
     Double_t xyz[3];
@@ -499,8 +525,9 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
     //
     for(Int_t idaughter = 0; idaughter < 2; idaughter++) { // daughter loop
       Int_t index = idaughter == 0 ? v0->GetPindex() : v0->GetNindex();
-      AliESDtrack * trackP = event->GetTrack(index);
-      AliESDfriendTrack *friendTrackP = esdFriend->GetTrack(index);
+      AliVTrack * trackP = event->GetVTrack(index);
+      if (!trackP) Printf("***ERROR*** trackP not available!");
+      const AliVfriendTrack *friendTrackP = friendEvent->GetTrack(index);
       if (!friendTrackP) continue;
       const AliExternalTrackParam * trackPIn = trackP->GetInnerParam();
       const AliExternalTrackParam * trackPOut = friendTrackP->GetTPCOut();
@@ -527,7 +554,8 @@ void AliTPCcalibTimeGain::ProcessBeamEvent(AliESDEvent *event) {
        Double_t tpcSignal = GetTPCdEdx(seed);
        //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
        Double_t vec[6] = {tpcSignal,static_cast<Double_t>(time),1,meanDrift,meanP,static_cast<Double_t>(runNumber)};
-       fHistGainTime->Fill(vec);
+    //Printf("Fill Gain histo in v0 loop...");
+    fHistGainTime->Fill(vec);
       }
     }
     
index 385417b51ad61e9f172b63e70bf065d84f199bf0..ff6becd8f9b8cf912a64bfd50132e52c7468936f 100644 (file)
@@ -17,8 +17,10 @@ class TH3F;
 class TH2F;
 class TList;
 class TGraphErrors;
-class AliESDEvent;
-class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+//class AliESDtrack;
+class AliVTrack;
 class AliTPCcalibLaser;
 class AliTPCseed;
 
@@ -31,12 +33,16 @@ public:
   AliTPCcalibTimeGain(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeGain);
   virtual ~AliTPCcalibTimeGain();
   //
-  virtual void           Process(AliESDEvent *event);
+  //virtual void           Process(AliESDEvent *event);
+  virtual void           Process(AliVEvent *event);
   virtual Long64_t       Merge(TCollection *li);
   virtual void           AnalyzeRun(Int_t minEntries);
   //
-  void                   ProcessCosmicEvent(AliESDEvent *event);
-  void                   ProcessBeamEvent(AliESDEvent *event);
+  //void                   ProcessCosmicEvent(AliESDEvent *event);
+  //void                   ProcessBeamEvent(AliESDEvent *event);
+
+  void                   ProcessCosmicEvent(AliVEvent *event);
+  void                   ProcessBeamEvent(AliVEvent *event);
   //
   void                   CalculateBetheAlephParams(TH2F *hist, Double_t * ini);
   static void            BinLogX(THnSparse *h, Int_t axisDim);
@@ -115,7 +121,7 @@ private:
   //
   AliTPCcalibTimeGain(const AliTPCcalibTimeGain&); 
   AliTPCcalibTimeGain& operator=(const AliTPCcalibTimeGain&); 
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}
 
   ClassDef(AliTPCcalibTimeGain, 2);
index 17fb28a83a7b67d48dcca20d59b06dc515b8f095..b143214c8346f39f2c6f89b14e0a5e4a4a1ac935 100644 (file)
@@ -133,9 +133,9 @@ using namespace std;
 #include "AliMagF.h"
 #include "AliTracker.h"
 #include "AliESD.h"
-#include "AliESDtrack.h"
-#include "AliESDfriend.h"
-#include "AliESDfriendTrack.h" 
+//#include "AliESDtrack.h"
+//#include "AliESDfriend.h"
+//#include "AliESDfriendTrack.h"
 #include "AliTPCseed.h"
 #include "AliTPCclusterMI.h"
 #include "AliTPCROC.h"
index e486a1c4a31e343198081dcf1b8a4c75ee1ad83d..5e25f2bad3289ed315f9712bf9be8115d7efd401 100644 (file)
@@ -35,14 +35,16 @@ class AliTPCClusterParam;
 class TTreeSRedirector;
 class AliTPCROC;
 class AliTPCseed;
-class AliESDtrack;
+//class AliESDtrack;
 class AliTPCclusterMI;
 class AliTPCcalibTracksCuts;
 class AliTPCCalPad;
 class TChain;
 class TTree;
 class TMutex;
-class AliESDEvent;
+//class AliESDEvent;
+class AliVEvent;
+class AliVTrack;
 
 using namespace std;
 
@@ -56,8 +58,10 @@ public :
   virtual ~AliTPCcalibTracks();                // destructor
   
   virtual void            Process(AliTPCseed *track);  // to be called by the Selector
-  void     Process(AliESDEvent *event) {AliTPCcalibBase::Process(event);};
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDEvent *event) {AliTPCcalibBase::Process(event);}
+  void     Process(AliVEvent *event) {AliTPCcalibBase::Process(event);}
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   virtual Long64_t Merge(TCollection *li);
   void    AddHistos(AliTPCcalibTracks* calib);
   void     MakeResPlotsQTree(Int_t minEntries = 100, const char* pathName = "plots");
index e39032aeb597b8cbaafe7209eabd2f3cdc2188a4..381d20171992b104b5fd5cff48cccd48d48f9c6c 100644 (file)
@@ -143,7 +143,7 @@ Int_t AliTPCcalibTracksCuts::AcceptTrack(const AliTPCseed * track) const {
   return 0;
 }
 
-Int_t AliTPCcalibTracksCuts::AcceptTrack(const AliESDtrack * track) const {
+Int_t AliTPCcalibTracksCuts::AcceptTrack(const AliVTrack * track) const {
   //
   // Function, that decides wheather a given track is accepted for 
   // the analysis or not. 
index 519b92eacc7df35dcb20a7639f92a5c89057a476..97a3ea87e9dfd045f84cb33fdbac043f01b19fef 100644 (file)
@@ -18,7 +18,7 @@
 
 class TChain;
 class AliTPCseed;
-class AliESDtrack;
+class AliVTrack;
 
 using namespace std;
 
@@ -33,7 +33,7 @@ public:
    static  AliTPCcalibTracksCuts  *CreateCuts(char* ctype);
 
    Int_t AcceptTrack(const AliTPCseed * track) const;
-   Int_t AcceptTrack(const AliESDtrack * track) const;
+   Int_t AcceptTrack(const AliVTrack * track) const;
 
    void SetMinClusters(Int_t minClusters){fMinClusters = minClusters;}
    void SetMinRatio(Float_t minRatio){fMinRatio = minRatio;}
index 545ad0da62bc4353f46f045f60957e8c99dfddd3..242ad9828f6bcd9915f73d6ec9809ef52a3c688a 100644 (file)
@@ -98,8 +98,10 @@ public:
 
 
   TLinearFitter*  GetFitter(UInt_t segment, UInt_t padType, UInt_t fitType);  
-  void     Process(AliESDEvent *event) {AliTPCcalibBase::Process(event);};
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDEvent *event) {AliTPCcalibBase::Process(event);}
+  void     Process(AliVEvent *event) {AliTPCcalibBase::Process(event);}
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   
 public:
   //
index 2cfad025feb3e76e37d3b73706cf7c968d09988f..c67275c069d22252491d7e3e05d7ebb86f99432f 100644 (file)
 
 #include "AliMagF.h"
 #include "AliTracker.h"
-#include "AliESDEvent.h"
+//#include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliESDfriend.h"
-#include "AliESDfriendTrack.h" 
+#include "AliESDfriendTrack.h"
+#include "AliESDVertex.h"
+
+#include "AliVEvent.h"
+#include "AliVTrack.h"
+#include "AliVfriendTrack.h"
+#include "AliVfriendEvent.h"
+
 #include "AliMathBase.h" 
 #include "AliTPCseed.h"
 #include "AliTPCclusterMI.h"
@@ -55,7 +62,7 @@ AliTPCcalibV0::AliTPCcalibV0() :
    fV0Tree(0),
    fHPTTree(0),
    fStack(0),
-   fESD(0),
+   fEvent(0),
    fPdg(0),
    fParticles(0),
    fV0s(0),
@@ -68,7 +75,7 @@ AliTPCcalibV0::AliTPCcalibV0(const Text_t *name, const Text_t *title):
    fV0Tree(0),
    fHPTTree(0),
    fStack(0),
-   fESD(0),
+   fEvent(0),
    fPdg(0),
    fParticles(0),
    fV0s(0),
@@ -92,43 +99,43 @@ AliTPCcalibV0::~AliTPCcalibV0(){
 
 
 
-void  AliTPCcalibV0::ProcessESD(AliESDEvent *esd){
+void  AliTPCcalibV0::ProcessESD(AliVEvent *event){
   //
   //
   //
-  fESD = esd;
-  AliKFParticle::SetField(esd->GetMagneticField());
+  fEvent = event;
+  AliKFParticle::SetField(event->GetMagneticField());
   if (TMath::Abs(AliTracker::GetBz())<1) return;  
-  DumpToTree(esd);
-  DumpToTreeHPT(esd);
+  DumpToTree(event);
+  DumpToTreeHPT(event);
 }
 
-void  AliTPCcalibV0::DumpToTreeHPT(AliESDEvent *esd){
+void  AliTPCcalibV0::DumpToTreeHPT(AliVEvent *event){
   //
   // Dump V0s fith full firend information to the 
   // 
   if (TMath::Abs(AliTracker::GetBz())<1) return;
   const Int_t kMinCluster=110;
   const Float_t kMinPt   =4.;
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(esd->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
 //   if (!esdFriend) {
 //     Printf("ERROR: esdFriend not available");
 //     return;
 //   }
   //
-  Int_t ntracks=esd->GetNumberOfTracks();
+  Int_t ntracks=event->GetNumberOfTracks();
   for (Int_t i=0;i<ntracks;++i) {
     Bool_t isOK=kFALSE;
-    AliESDtrack *track = esd->GetTrack(i);
+    AliVTrack *track = event->GetVTrack(i);
     if (track->GetTPCncls()<kMinCluster) continue;
     if (TMath::Abs(AliTracker::GetBz())>1){ // cut on momenta if measured
       if (track->Pt()>kMinPt) isOK=kTRUE;
     }
     if (TMath::Abs(AliTracker::GetBz())<1){  // require primary track for the B field OFF data
       Bool_t isAccepted=kTRUE;
-      if (!track->IsOn(AliESDtrack::kITSrefit)) isAccepted=kFALSE;
-      if (!track->IsOn(AliESDtrack::kTPCrefit)) isAccepted=kFALSE;
-      if (!track->IsOn(AliESDtrack::kTOFout))   isAccepted=kFALSE;
+      if (!track->IsOn(AliVTrack::kITSrefit)) isAccepted=kFALSE;
+      if (!track->IsOn(AliVTrack::kTPCrefit)) isAccepted=kFALSE;
+      if (!track->IsOn(AliVTrack::kTOFout))   isAccepted=kFALSE;
       Float_t dvertex[2],cvertex[3]; 
       track->GetImpactParametersTPC(dvertex,cvertex);
       if (TMath::Abs(dvertex[0]/TMath::Sqrt(cvertex[0]+0.01))>20) isAccepted=kFALSE;
@@ -139,25 +146,25 @@ void  AliTPCcalibV0::DumpToTreeHPT(AliESDEvent *esd){
       if (!isAccepted) isOK=kFALSE;
     } 
     if ( track->GetTPCsignal()>100 && track->GetInnerParam()->Pt()>1 ){
-      if (track->IsOn(AliESDtrack::kITSin)||track->IsOn(AliESDtrack::kTRDout)||track->IsOn(AliESDtrack::kTOFin))
+      if (track->IsOn(AliVTrack::kITSin)||track->IsOn(AliVTrack::kTRDout)||track->IsOn(AliVTrack::kTOFin))
        isOK=kTRUE;
       if (isOK){
        TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
-       Int_t eventNumber = esd->GetEventNumberInFile();
-       Bool_t hasFriend=(esdFriend) ? (esdFriend->GetTrack(i)!=0):0; 
+    Int_t eventNumber = event->GetEventNumberInFile();
+    Bool_t hasFriend=(friendEvent) ? (friendEvent->GetTrack(i)!=0):0;
        Bool_t hasITS=(track->GetNcls(0)>2);
        printf("DUMPIONTrack:%s|%f|%d|%d|%d\n",filename.Data(),track->GetInnerParam()->Pt()*track->GetTPCsignal()/50., eventNumber,hasFriend,hasITS);
       }
     }
     if (!isOK) continue;
     TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
-    Int_t eventNumber = esd->GetEventNumberInFile();   
-    Bool_t hasFriend=(esdFriend) ? (esdFriend->GetTrack(i)!=0):0;
+    Int_t eventNumber = event->GetEventNumberInFile();
+    Bool_t hasFriend=(friendEvent) ? (friendEvent->GetTrack(i)!=0):0;
     Bool_t hasITS=(track->GetNcls(0)>2);    
     printf("DUMPHPTTrack:%s|%f|%d|%d|%d\n",filename.Data(),track->Pt(), eventNumber,hasFriend,hasITS);
     //
-    if (!esdFriend) continue;
-    AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
+    if (!friendEvent) continue;
+    const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
     if (!friendTrack) continue;
 
     if (!isOK) continue;
@@ -173,15 +180,24 @@ void  AliTPCcalibV0::DumpToTreeHPT(AliESDEvent *esd){
       fHPTTree = new TTree("HPT","HPT");
       fHPTTree->SetDirectory(0);
     }
+
+      //**********************TEMPORARY!!*******************************************
+      // more investigation is needed with Tree ///!!!
+      //all dummy stuff here is just for code to compile and work with ESD
+
+      AliESDfriendTrack *dummyfriendTrack=(AliESDfriendTrack*)friendTrack;
+      AliESDtrack *dummytrack=(AliESDtrack*)track;
+
+
     if (fHPTTree->GetEntries()==0){
       //
       fHPTTree->SetDirectory(0);
-      fHPTTree->Branch("t.",&track);
-      fHPTTree->Branch("ft.",&friendTrack);
+      fHPTTree->Branch("t.",&dummytrack);
+      fHPTTree->Branch("ft.",&dummyfriendTrack);
       fHPTTree->Branch("s.",&seed);
     }else{
-      fHPTTree->SetBranchAddress("t.",&track);
-      fHPTTree->SetBranchAddress("ft.",&friendTrack);
+      fHPTTree->SetBranchAddress("t.",&dummytrack);
+      fHPTTree->SetBranchAddress("ft.",&dummyfriendTrack);
       fHPTTree->SetBranchAddress("s.",&seed);
     }
     fHPTTree->Fill();
@@ -191,23 +207,26 @@ void  AliTPCcalibV0::DumpToTreeHPT(AliESDEvent *esd){
 
 
 
-void  AliTPCcalibV0::DumpToTree(AliESDEvent *esd){
+void  AliTPCcalibV0::DumpToTree(AliVEvent *event){
   //
   // Dump V0s fith full firend information to the 
   // 
-  Int_t nV0s  = fESD->GetNumberOfV0s();
+  Int_t nV0s  = fEvent->GetNumberOfV0s();
   const Int_t kMinCluster=110;
   const Double_t kDownscale=0.01;
   const Float_t kMinPt   =1.0;
   const Float_t kMinMinPt   =0.7;
-  AliESDfriend *esdFriend=static_cast<AliESDfriend*>(esd->FindListObject("AliESDfriend"));
+  AliVfriendEvent *friendEvent=event->FindFriend();
   //
   
   for (Int_t ivertex=0; ivertex<nV0s; ivertex++){
     Bool_t isOK=kFALSE;
-    AliESDv0 * v0 = (AliESDv0*) esd->GetV0(ivertex);
-    AliESDtrack * track0 = fESD->GetTrack(v0->GetIndex(0)); // negative track
-    AliESDtrack * track1 = fESD->GetTrack(v0->GetIndex(1)); // positive track 
+    AliESDv0 dummyv0;
+    event->GetV0(dummyv0,ivertex);
+    AliESDv0 *v0=&dummyv0;
+
+    AliVTrack * track0 = fEvent->GetVTrack(v0->GetIndex(0)); // negative track
+    AliVTrack * track1 = fEvent->GetVTrack(v0->GetIndex(1)); // positive track
     if (track0->GetTPCNcls()<kMinCluster) continue;
     if (track0->GetKinkIndex(0)>0) continue;    
     if (track1->GetTPCNcls()<kMinCluster) continue;
@@ -222,17 +241,17 @@ void  AliTPCcalibV0::DumpToTree(AliESDEvent *esd){
     if (!isOK) continue;
     //
     TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
-    Int_t eventNumber = esd->GetEventNumberInFile();
+    Int_t eventNumber = event->GetEventNumberInFile();
     Bool_t hasITS=(track0->GetNcls(0)+ track1->GetNcls(0)>4);
-    printf("DUMPHPTV0:%s|%f|%d|%d|%d\n",filename.Data(), (TMath::Min(track0->Pt(),track1->Pt())), eventNumber,(esdFriend!=0), hasITS);
+    printf("DUMPHPTV0:%s|%f|%d|%d|%d\n",filename.Data(), (TMath::Min(track0->Pt(),track1->Pt())), eventNumber,(friendEvent!=0), hasITS);
     //
-    if (!esdFriend) continue;
+    if (!friendEvent) continue;
     //
     
     //
-    AliESDfriendTrack *ftrack0 = esdFriend->GetTrack(v0->GetIndex(0));
+    const AliVfriendTrack *ftrack0 = friendEvent->GetTrack(v0->GetIndex(0));
     if (!ftrack0) continue;
-    AliESDfriendTrack *ftrack1 = esdFriend->GetTrack(v0->GetIndex(1));
+    const AliVfriendTrack *ftrack1 = friendEvent->GetTrack(v0->GetIndex(1));
     if (!ftrack1) continue;
     //
     TObject *calibObject;
@@ -256,22 +275,32 @@ void  AliTPCcalibV0::DumpToTree(AliESDEvent *esd){
       fV0Tree = new TTree("V0s","V0s");
       fV0Tree->SetDirectory(0);
     }
+
+    //**********************TEMPORARY!!*******************************************
+    // more investigation is needed with Tree ///!!!
+    //all dummy stuff here is just for code to compile and work with ESD
+
+    AliESDfriendTrack *dummyftrack0=(AliESDfriendTrack*)ftrack0;
+    AliESDfriendTrack *dummyftrack1=(AliESDfriendTrack*)ftrack1;
+    AliESDtrack *dummytrack0=(AliESDtrack*)track0;
+    AliESDtrack *dummytrack1=(AliESDtrack*)track1;
+
     if (fV0Tree->GetEntries()==0){
       //
       fV0Tree->SetDirectory(0);
       fV0Tree->Branch("v0.",&v0);
-      fV0Tree->Branch("t0.",&track0);
-      fV0Tree->Branch("t1.",&track1);
-      fV0Tree->Branch("ft0.",&ftrack0);
-      fV0Tree->Branch("ft1.",&ftrack1);
+      fV0Tree->Branch("t0.",&dummytrack0);
+      fV0Tree->Branch("t1.",&dummytrack1);
+      fV0Tree->Branch("ft0.",&dummyftrack0);
+      fV0Tree->Branch("ft1.",&dummyftrack1);
       fV0Tree->Branch("s0.",&seed0);
       fV0Tree->Branch("s1.",&seed1);
     }else{
       fV0Tree->SetBranchAddress("v0.",&v0);
-      fV0Tree->SetBranchAddress("t0.",&track0);
-      fV0Tree->SetBranchAddress("t1.",&track1);
-      fV0Tree->SetBranchAddress("ft0.",&ftrack0);
-      fV0Tree->SetBranchAddress("ft1.",&ftrack1);
+      fV0Tree->SetBranchAddress("t0.",&dummytrack0);
+      fV0Tree->SetBranchAddress("t1.",&dummytrack1);
+      fV0Tree->SetBranchAddress("ft0.",&dummyftrack0);
+      fV0Tree->SetBranchAddress("ft1.",&dummyftrack1);
       fV0Tree->SetBranchAddress("s0.",&seed0);
       fV0Tree->SetBranchAddress("s1.",&seed1);
     }
@@ -885,7 +914,7 @@ void AliTPCcalibV0::BinLogX(TH2F *h) {
 
 
 
-void AliTPCcalibV0::FilterV0s(AliESDEvent* event){
+void AliTPCcalibV0::FilterV0s(AliVEvent *event){
   //
   // 
   TDatabasePDG pdg;  
@@ -894,12 +923,26 @@ void AliTPCcalibV0::FilterV0s(AliESDEvent* event){
   const Double_t ptCut=0.2;
   const Int_t kMinNcl=110;
   //
-  Int_t nv0 = event->GetNumberOfV0s(); 
-  AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+  Int_t nv0 = event->GetNumberOfV0s();
+  //AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
+  //AliKFVertex kfvertex=*vertex;
+
+  //AliESDVertex vtx;
+  //event->GetPrimaryVertex(vtx);
+  //AliESDVertex *vertex=&vtx;
+  //AliKFVertex *kfvertex=(AliKFVertex*)vertex;
+
+  AliESDVertex vtx;
+  event->GetPrimaryVertex(vtx);
+  AliESDVertex *vertex=&vtx;
   AliKFVertex kfvertex=*vertex;
+
   //
   for (Int_t iv0=0;iv0<nv0;iv0++){
-    AliESDv0 *v0 = event->GetV0(iv0);
+    AliESDv0 dummyv0;
+    event->GetV0(dummyv0,iv0);
+    AliESDv0 *v0=&dummyv0;
+
     if (!v0) continue;
     if (v0->GetPindex()<0) continue;
     if (v0->GetNindex()<0) continue;
@@ -933,8 +976,8 @@ void AliTPCcalibV0::FilterV0s(AliESDEvent* event){
 
     Double_t sign= v0->GetParamP()->GetSign()* v0->GetParamN()->GetSign();
     if (sign<0&&v0->GetOnFlyStatus()>0.5&&maxPt>ptCut&&isV0){
-      AliESDtrack * trackP = event->GetTrack(v0->GetPindex());
-      AliESDtrack * trackN = event->GetTrack(v0->GetNindex());
+      AliVTrack * trackP = event->GetVTrack(v0->GetPindex());
+      AliVTrack * trackN = event->GetVTrack(v0->GetNindex());
       if (!trackN) continue;
       if (!trackP) continue;
       Int_t nclP= (Int_t)trackP->GetTPCClusterInfo(2,1);
@@ -949,7 +992,7 @@ void AliTPCcalibV0::FilterV0s(AliESDEvent* event){
          "tp.="<<trackP<<
          "tm.="<<trackN<<
          //
-         "v.="<<vertex<<
+      //"v.="<<vertex<<
          "ncls="<<ncls<<
          "maxPt="<<maxPt<<
          "\n";        
index df7a7c2f96645f03193419c67b6f51bb35d70347..92cdefdee6fc741f590df421f02e5430a9c01396 100644 (file)
@@ -8,8 +8,10 @@
 class TTreeSRedirector;
 class AliTPCROC;
 class AliTPCseed;
-class AliESDtrack;
-class AliESDEvent;
+//class AliESDtrack;
+//class AliESDEvent;
+class AliVEvent;
+class AliVTrack;
 class TH3F;
 class TH1F;
 class TH2F;
@@ -32,8 +34,8 @@ public :
   AliTPCcalibV0();
   AliTPCcalibV0(const Text_t *name, const Text_t *title);
   virtual ~AliTPCcalibV0();
-  virtual void     Process(AliESDEvent *event) {return ProcessESD(event);}
-  void FilterV0s(AliESDEvent* event);
+  virtual void     Process(AliVEvent *event) {return ProcessESD(event);}
+  void FilterV0s(AliVEvent* event);
   Long64_t Merge(TCollection *const li);
   void AddTree(TTree * treeInput);
   void AddTreeHPT(TTree * treeInput);
@@ -43,9 +45,9 @@ public :
   //
   //
   //
-  void ProcessESD(AliESDEvent *esd);
-  void DumpToTree(AliESDEvent *esd);
-  void DumpToTreeHPT(AliESDEvent *esd);
+  void ProcessESD(AliVEvent *event);
+  void DumpToTree(AliVEvent *event);
+  void DumpToTreeHPT(AliVEvent *event);
   TTree * GetV0Tree(){return fV0Tree;}
   TTree * GetHPTTree(){return fHPTTree;}
   //  
@@ -68,13 +70,14 @@ private:
   TTree          *fHPTTree;      // tree with high mometa tracks - full calib info
   //
   AliStack       *fStack;        // pointer to kinematic tree        
-  AliESDEvent    *fESD;              //! current ED to proccess - NOT OWNER
+  AliVEvent      *fEvent;              //! current ED to proccess - NOT OWNER
   TDatabasePDG   *fPdg;              //! particle database
   TObjArray      *fParticles;         // array of selected MC particles
   TObjArray      *fV0s;               // array of V0s
   TObjArray      *fGammas;           // gamma conversion candidates
   //
-  void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);};
+  //void     Process(AliESDtrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
+  void     Process(AliVTrack *track, Int_t runNo=-1){AliTPCcalibBase::Process(track,runNo);}
   void     Process(AliTPCseed *track){return AliTPCcalibBase::Process(track);}  
   //       
   ClassDef(AliTPCcalibV0,3);
index 0c87dd04753dbb13c6e514b16be0c087681ccc64..94526874f702e16d27a517cfed103d49afa7be39 100644 (file)
@@ -274,7 +274,12 @@ AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
     if (!fClusterOwner) for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i];
     else                for(Int_t i = 0;i<160;++i) {
        delete fClusterPointer[i];
-       fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
+       if (param.fClusterPointer[i]) { 
+         fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
+       }
+       else {
+         fClusterPointer[i] = 0x0;
+       }
       }
     // leave out fPoint, they are also not copied in the copy ctor...
     // but deleted in the dtor... strange...
index 6ded28396df10829f11911ceb295faac5d1ea8fa..4fabb13a93c6928576242c5d162a4fda45833175 100644 (file)
@@ -20,6 +20,7 @@
 #include "AliTPCtrack.h"
 #include "AliComplexCluster.h"
 #include "AliPID.h"
+#include "AliVTPCseed.h"
 
 class TFile;
 class AliTPCParam;
@@ -30,7 +31,7 @@ class AliESD;
 class AliTPCCalPad;
 class TClonesArray;
 
-class AliTPCseed : public AliTPCtrack {
+class AliTPCseed : public AliTPCtrack, public AliVTPCseed {
   public:  
      AliTPCseed();
      virtual ~AliTPCseed();
@@ -152,6 +153,11 @@ class AliTPCseed : public AliTPCtrack {
   void    SetPoolID(Int_t id) {fPoolID = id;}
   Int_t   GetPoolID()  const {return fPoolID;}
   Int_t   GetNumberOfClustersIndices();  // Should be in AliTPCtrack
+
+  // AliVVTPCseed interface
+
+  void CopyToTPCseed( AliTPCseed &s) const { s = *this; }
+
  private:
      //     AliTPCseed & operator = (const AliTPCseed &)
      //  {::Fatal("= operator","Not Implemented\n");return *this;}
index afe28e452b4f0de01389ba37adc8b0773b360752..62cc33eb0382965f652446bd0abd3e51c557a374 100644 (file)
@@ -49,6 +49,7 @@
                                                    // --- move functionality to AliTPCCorrectionFit
 
 #pragma link C++ class AliTPCcalibSummary;         // Tree creation of calibration parameters
+#pragma link C++ class  AliAnalysisTaskPt+;
 
 #endif