]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
flat friends update
authorsgorbuno <Sergey.Gorbunov@cern.ch>
Mon, 20 Oct 2014 14:58:14 +0000 (16:58 +0200)
committersgorbuno <Sergey.Gorbunov@cern.ch>
Mon, 20 Oct 2014 14:58:14 +0000 (16:58 +0200)
HLT/BASE/AliHLTDataTypes.cxx
HLT/BASE/AliHLTDataTypes.h
HLT/CMakelibAliHLTGlobal.pkg
HLT/global/AliFlatESDFriend.cxx
HLT/global/AliFlatESDFriendTrack.h
HLT/global/AliFlatTPCCluster.h
HLT/global/AliFlatTPCseed.cxx
HLT/global/AliFlatTPCseed.h
HLT/global/AliHLTGlobalFlatEsdConverterComponent.cxx
HLT/global/AliHLTGlobalFlatEsdConverterComponent.h
TPC/Rec/AliTPCseed.h

index 17bb1f7857f192b8de7a6eabca0f259b5d644181..3781baf9b3277fb735ad2e5ab945b729ba06e206 100644 (file)
@@ -126,6 +126,10 @@ const AliHLTComponentDataType kAliHLTDataTypeESDfriendObject = AliHLTComponentDa
 const char kAliHLTFlatESDDataTypeIDstring[8] = kAliHLTFlatESDDataTypeID;
 const AliHLTComponentDataType kAliHLTDataTypeFlatESD = AliHLTComponentDataTypeInitializer(kAliHLTFlatESDDataTypeIDstring, kAliHLTDataOriginAny);
 
+/** Flat ESD friend data specification */
+const char kAliHLTFlatESDFriendDataTypeIDstring[8] = kAliHLTFlatESDFriendDataTypeID;
+const AliHLTComponentDataType kAliHLTDataTypeFlatESDFriend = AliHLTComponentDataTypeInitializer(kAliHLTFlatESDFriendDataTypeIDstring, kAliHLTDataOriginAny);
+
 /** Flat ESD Vertex data specification */
 const char kAliHLTFlatESDVertexDataTypeIDstring[8] = kAliHLTFlatESDVertexDataTypeID;
 const AliHLTComponentDataType kAliHLTDataTypeFlatESDVertex = AliHLTComponentDataTypeInitializer(kAliHLTFlatESDVertexDataTypeIDstring, kAliHLTDataOriginAny);
index ba19d88ebe9ad45f7923a4b1d0550232e3f0167f..d5e7e32bac4e3066a319a911715292634b4559a7 100644 (file)
@@ -403,6 +403,12 @@ const int kAliHLTComponentDataTypefIDsize=8;
  */
 # define kAliHLTFlatESDDataTypeID    {'F','L','A','T','E','S','D','0'}
 
+/** Flat ESD data block
+ * an AliFlatESDFriend object of varying origin
+ * @ingroup alihlt_component_datatypes
+ */
+# define kAliHLTFlatESDFriendDataTypeID    {'F','L','A','T','F','R','N','D'}
+
 /** ESD 
  * data blocks designated for the ESD
  * @ingroup alihlt_component_datatypes
@@ -1124,6 +1130,11 @@ extern "C" {
    */
   extern const AliHLTComponentDataType kAliHLTDataTypeFlatESD;
 
+ /** flat ESD friend object data specification, origin is 'any' 
+   * @ingroup alihlt_component_datatypes
+   */
+  extern const AliHLTComponentDataType kAliHLTDataTypeFlatESDFriend;
+
   /** flat ESD vertex object data specification, origin is 'any' 
    * @ingroup alihlt_component_datatypes
    */
index c481b6601ca98650b0aa6d5054881356bdd004b7..4db2cf9ef42734fe652de317d511870433bc9ec9 100644 (file)
@@ -75,7 +75,7 @@ set ( MODULE_HDRS     ${CLASS_HDRS})
 
 set ( MODULE_DHDR )
 
-set ( EINCLUDE  HLT/global HLT/global/physics HLT/BASE HLT/BASE/util HLT/TPCLib TPC RAW TRD PHOS STEER/ESD STEER/STEERBase ANALYSIS)
+set ( EINCLUDE  HLT/global HLT/global/physics HLT/BASE HLT/BASE/util HLT/TPCLib TPC TPC/Rec RAW TRD PHOS STEER/ESD STEER/STEERBase ANALYSIS)
 
 set ( ELIBS  "HLTbase AliHLTUtil CDB ESD STEER STEERBase TPCrec TPCcalib TPCbase RAWDatarec RAWDatabase TRDbase -lEG")
 
index 5e3bd93ae4421fbdc04c4e71fed16b80d309e94b..992875520c7ede11404d766295523293335c5d32 100644 (file)
@@ -95,7 +95,8 @@ Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, cons
        table[idxTrack] = trackSize;
        if( freeSpace<flatTrack->EstimateSize() ) return -1;
        new (flatTrack) AliFlatESDFriendTrack;       
-       //flatTrack->SetFromESDTrack( esdTrack );
+       if( flatTrack->SetFromESDfriendTrack( esdTrack, freeSpace ) ) return -1;
+
        trackSize += flatTrack->GetSize();
        freeSpace -= flatTrack->GetSize();
        nTrackEntries++;
index 569a39bf3f056db41264bdc53b3537e1315a8c35..0fd57f4d3b73e4d9e2e2d53e4c1ee63af8de222b 100644 (file)
@@ -69,6 +69,10 @@ class AliFlatESDFriendTrack :public AliVfriendTrack
   void SetTPCseed         ( const AliTPCseed *p );
 
   // -- 
+
+  AliFlatTPCseed* SetTPCseedStart();
+  void SetTPCseedEnd( size_t tpcSeedSize );
+
   
   const AliFlatESDFriendTrack *GetNextTrack() const { return reinterpret_cast<const AliFlatESDFriendTrack*>(fContent+fContentSize); }
   AliFlatESDFriendTrack *GetNextTrackNonConst() { return reinterpret_cast<AliFlatESDFriendTrack*>(fContent+fContentSize); }
@@ -143,4 +147,14 @@ inline Int_t AliFlatESDFriendTrack::GetTPCseed( AliTPCseed &s ) const
   return 0;
 }
 
+inline AliFlatTPCseed* AliFlatESDFriendTrack::SetTPCseedStart()
+{
+  fTPCseedPointer = fContentSize;
+  return  reinterpret_cast< AliFlatTPCseed* >( fContent + fTPCseedPointer );
+}
+
+inline void AliFlatESDFriendTrack::SetTPCseedEnd( size_t tpcSeedSize ){
+  fContentSize += tpcSeedSize;
+}
+
 #endif
index c5b9c57babf6300160a49ad21ea5a59efafed5c6..684cdc2ed048a096d1ecc132ae029cb39216240b 100644 (file)
 #include "Rtypes.h"
 #include "AliVMisc.h"
 #include "AliTPCclusterMI.h"
+#include "AliComplexCluster.h"
 
 class AliFlatTPCCluster
 {
   public:
 
 AliFlatTPCCluster() : fX(0.), fY(0.), fZ(0.), fSector(0), fPadRow(0), fSigmaY2(0.), fSigmaZ2(0.), fCharge(0), fQMax(0) {}
AliFlatTPCCluster() : fX(0.), fY(0.), fZ(0.), fSector(0), fPadRow(0), fSigmaY2(0.), fSigmaZ2(0.), fCharge(0), fQMax(0), fTrackAngleY(0), fTrackAngleZ(0) {}
 
   AliFlatTPCCluster(AliVConstructorReinitialisationFlag ); // do nothing
  
@@ -34,7 +35,8 @@ class AliFlatTPCCluster
   void SetSigmaZ2(Float_t sigmaZ2) {fSigmaZ2 = sigmaZ2;}
   void SetCharge(UShort_t charge)  {fCharge = charge;}
   void SetQMax(UShort_t qmax)      {fQMax = qmax;}
-  
+  void SetTrackAngleY( Float_t angY ) {fTrackAngleY = angY;}  
+  void SetTrackAngleZ( Float_t angZ ) {fTrackAngleZ = angZ;}
  
   Float_t  GetX()       const      {return fX;}
   Float_t  GetY()       const      {return fY;}
@@ -45,9 +47,12 @@ class AliFlatTPCCluster
   Float_t  GetSigmaZ2() const      {return fSigmaZ2;}
   UShort_t GetCharge()  const      {return fCharge;}
   UShort_t GetQMax()    const      {return fQMax;}
+  
+  Float_t GetTrackAngleY() const {return fTrackAngleY;}
+  Float_t GetTrackAngleZ() const {return fTrackAngleZ;}
 
-  void SetTPCCluster( const AliTPCclusterMI *c );
-  void GetTPCCluster( AliTPCclusterMI *c ) const;
+  void SetTPCCluster( const AliTPCclusterMI *c, const AliTPCTrackerPoint *p );
+  void GetTPCCluster( AliTPCclusterMI *c, AliTPCTrackerPoint *p  ) const;
 
   private:
 
@@ -60,15 +65,17 @@ class AliFlatTPCCluster
   Float_t fSigmaZ2; // error (former width) of the clusters
   UInt_t  fCharge;  // total charge of cluster
   UInt_t  fQMax;    // QMax of cluster
-  
+  Float_t fTrackAngleY; // tracker point angle Y
+  Float_t fTrackAngleZ; // tracker point angle Z
 };
 
 #pragma GCC diagnostic ignored "-Weffc++" 
 inline AliFlatTPCCluster::AliFlatTPCCluster(AliVConstructorReinitialisationFlag ){}
 #pragma GCC diagnostic warning "-Weffc++" 
 
-inline void AliFlatTPCCluster::SetTPCCluster( const AliTPCclusterMI *c )
+inline void AliFlatTPCCluster::SetTPCCluster( const AliTPCclusterMI *c, const AliTPCTrackerPoint *p  )
 {
+  if( !c ) return;
   SetX( c->GetX() );
   SetY( c->GetY() );
   SetZ( c->GetZ() );
@@ -78,20 +85,32 @@ inline void AliFlatTPCCluster::SetTPCCluster( const AliTPCclusterMI *c )
   SetSigmaZ2( c->GetSigmaZ2() );
   SetCharge( c->GetQ() );
   SetQMax( c->GetMax() );
+  if( p ){
+    SetTrackAngleY( p->GetAngleY() );  
+    SetTrackAngleZ( p->GetAngleZ() );  
+  } else {
+    SetTrackAngleY( 0. );  
+    SetTrackAngleZ( 0. );  
+  }
 }
-inline void AliFlatTPCCluster::GetTPCCluster( AliTPCclusterMI *c ) const
+
+inline void AliFlatTPCCluster::GetTPCCluster( AliTPCclusterMI *c, AliTPCTrackerPoint *p ) 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() );
+  if( c ){
+    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() );
+  }
+  if( p ){
+    p->SetAngleY( GetTrackAngleY() );
+    p->SetAngleZ( GetTrackAngleZ() );
+  }
 }
 
 #endif
index b42e8b37b9512ff331fc3d78b3bed22eeec3a449..0cbc11b29b7f69490c42323a04bef81b7d8c8aa8 100644 (file)
@@ -37,16 +37,10 @@ void AliFlatTPCseed::SetFromTPCseed( const AliTPCseed *p )
 
   Reset();
   if( !p ) return;
-
   fParam.SetExternalTrackParam(  p );
-  fLabel = p->GetLabel();
-  AliFlatTPCCluster *clusters = reinterpret_cast< AliFlatTPCCluster* >( fContent );  
+  fLabel = p->GetLabel();  
   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++;
+    AddCluster( p->GetClusterPointer(irow), p->GetTrackPointConst(irow) );
   }
 }
 
@@ -67,12 +61,14 @@ void AliFlatTPCseed::GetTPCseed( AliTPCseed *p ) const
   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]) );
+    const AliFlatTPCCluster &flatCluster = flatClusters[ic];
     int sec = flatCluster.GetSector();
     int row = flatCluster.GetPadRow();
     if(sec >= 36) row = row + AliHLTTPCTransform::GetNRowLow();
-    if( row<160 ) seed.SetClusterPointer( row , &(clusters[ic]) );
+    if( row<160 ){
+      flatCluster.GetTPCCluster( &(clusters[ic]), seed.GetTrackPoint(row) );
+      seed.SetClusterPointer( row , &(clusters[ic]) );
+    }
   }
   new (p) AliTPCseed( seed, kTRUE ); // true means that p creates its own cluster objects
 }
index 58897360d6f5ad93cd776c5a24b12bdcec757759..a2dd1f7a5b9debdb5a75354771da1d94938e6b8c 100644 (file)
 #include "AliVfriendTrack.h"
 #include "AliVMisc.h"
 #include "AliFlatExternalTrackParam.h"
+#include "AliTPCseed.h"
 
 class AliESDtrack;
 class AliESDfriendTrack;
 class AliExternalTrackParam;
-class AliTrackPointArray;
-class AliTPCseed;
 
 class AliFlatTPCseed  
 {
@@ -36,15 +35,28 @@ class AliFlatTPCseed
   AliFlatTPCseed( AliVConstructorReinitialisationFlag );
   void Reinitialize() { new (this) AliFlatTPCseed( AliVReinitialize ); }
 
+  // -- Getters 
+
+  void GetTPCseed( AliTPCseed *p ) const;
+
+  Int_t GetLabel() const { return fLabel; }
+  Int_t GetNClusters() const { return fNTPCClusters; }
+
+  const AliFlatTPCCluster *GetClusters() const { return reinterpret_cast< const AliFlatTPCCluster* >( fContent ); }
+  AliFlatTPCCluster *GetClustersNonConst(){ return reinterpret_cast< AliFlatTPCCluster* >( fContent ); }
+
   // -- 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; }
+  void SetExternalTrackParam( const AliExternalTrackParam* p ){ fParam.SetExternalTrackParam(  p ); }
+
+  void SetLabel( Int_t lab ){ fLabel=lab; }
+
+  void AddCluster( const AliTPCclusterMI *cl, const AliTPCTrackerPoint *p ){ if(cl) GetClustersNonConst()[fNTPCClusters++].SetTPCCluster( cl, p );  }
+
 
   // --------------------------------------------------------------------------------
   // -- Size methods
index d02ca4aa72bfcd348efe67b15c004ef4c51a8468..775068db4ec806db7792fb7f9cbae1fff9f5f089 100644 (file)
@@ -71,10 +71,9 @@ ClassImp(AliHLTGlobalFlatEsdConverterComponent)
 
 AliHLTGlobalFlatEsdConverterComponent::AliHLTGlobalFlatEsdConverterComponent()
   : AliHLTProcessor()
-  , fWriteClusters(0)
-  , fVerbosity(0)  
-  , fSolenoidBz(-5.00668)
+  , fVerbosity(0)    
   , fBenchmark("FlatEsdConverter")
+  , fProduceFriend(1)
 {
   // see header file for class documentation
   // or
@@ -185,27 +184,6 @@ int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
   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++ ) {
@@ -220,14 +198,11 @@ int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
       if (argument.IsNull()) continue;
 
       // -noclusters
-      if (argument.CompareTo("-noclusters")==0) {
-       fWriteClusters=0;       
+      if (argument.CompareTo("-nofriend")==0) {
+       fProduceFriend=0;       
        // -clusters
-      } else if (argument.CompareTo("-clusters")==0) {
-       fWriteClusters=1;
-      } else if (argument.Contains("-skipobject=")) {
-       argument.ReplaceAll("-skipobject=", "");
-       skipObjects=argument;
+      } else if (argument.CompareTo("-friend")==0) {
+       fProduceFriend=1;
       } else {
        HLTError("unknown argument %s", argument.Data());
        iResult=-EINVAL;
@@ -240,8 +215,6 @@ int AliHLTGlobalFlatEsdConverterComponent::DoInit(int argc, const char** argv)
     iResult=-EINVAL;
   }
 
-  fSolenoidBz=GetBz();
-
   if (iResult>=0) {
     SetupCTPData();
   }
@@ -282,7 +255,6 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
   // 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()) {
@@ -300,22 +272,6 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
     }
   }
  
-  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; 
@@ -330,17 +286,17 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
   // 3) read  TPC tracks, ITS refitted tracks, ITS OUT tracks
 
   vector<AliHLTGlobalBarrelTrack> tracksTPC;
+  vector<AliHLTGlobalBarrelTrack> tracksTPCOut;
   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 ){
@@ -348,22 +304,41 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
        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);  
+              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() );
+  
+  // Set TPC MC labels to tracks
+  for( UInt_t itr=0; itr < tracksTPC.size(); itr++) {
+    AliHLTGlobalBarrelTrack &track = tracksTPC[itr];
+    std::map<int,int>::const_iterator lab = mcLabelsTPC.find( track.TrackID() );
+    if( lab!=mcLabelsTPC.end() ) track.SetLabel( lab->second );
+    else track.SetLabel( -1 );
+  }
+
+  // Create TPC Out tracks - just propagate to the outermost TPC cluster
+  for( UInt_t itr=0; itr < tracksTPC.size(); itr++) {
+    tracksTPCOut.push_back( tracksTPC[itr] );
+    AliHLTGlobalBarrelTrack &track = tracksTPCOut.back();
+    const Int_t N=10; // number of steps.
+    const Float_t xRange = track.GetLastPointX() - track.GetX();
+    const Float_t xStep = xRange / N ;
+    for(int i = 1; i <= N; ++i) {
+      if(!track.AliExternalTrackParam::PropagateTo(track.GetX() + xStep, GetBz() )) break;
+    }
+  }
+
 
   // ---------------------------------------------
   //
@@ -375,16 +350,18 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
 
   do{ // single loop for easy break in case of output buffer overflow
 
-    err = ( maxOutputSize < sizeof( AliFlatESDEvent ) );    
+    size_t freeSpace = maxOutputSize;
+
+    err = ( freeSpace < sizeof( AliFlatESDEvent ) );    
     if( err ) break;
 
     new (flatEsd) AliFlatESDEvent;    
  
-    size_t freeSpace = maxOutputSize - flatEsd->GetSize();
+    freeSpace -= flatEsd->GetSize();
   
     // fill run info
     {
-      flatEsd->SetMagneticField( fSolenoidBz );
+      flatEsd->SetMagneticField( GetBz() );
       flatEsd->SetPeriodNumber( GetPeriodNumber() );
       flatEsd->SetRunNumber( GetRunNo() );
       flatEsd->SetOrbitNumber( GetOrbitNumber() );
@@ -448,7 +425,6 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
     
     if( err ) break;
 
-
     { // Fill track information to the flat ESD structure
      
       size_t trackSize = 0;
@@ -460,110 +436,72 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
     
       if( err ) break;
 
-      for( UInt_t tpcIter=0, itsIter = 0, itsOutIter = 0; tpcIter < tracksTPC.size(); tpcIter++) {       
-       
+      for( UInt_t tpcIter=0, itsIter = 0, itsOutIter = 0; tpcIter < tracksTPC.size(); tpcIter++) {
+
+       // ----------------------------
+       // -- read track information
+
        // 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();  
+       AliHLTGlobalBarrelTrack *tpcOutTrack = &(tracksTPCOut[tpcIter]);
+
+       // ITS track parameters
        
-       {       
-         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());
+       AliHLTGlobalBarrelTrack *itsRefit=0;
+       AliHLTGlobalBarrelTrack *itsOut=0;
        
-         if( mcLabelsTPC.find(tpcTrack->TrackID())!=mcLabelsTPC.end() ) tpcLabel = mcLabelsTPC[tpcTrack->TrackID()];
+       // ITS Refit track
          
-         tpcTrack->SetLabel( tpcLabel );
+       for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
        
-         { // 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( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
+         itsRefit = &(tracksITS[itsIter]);
+         itsIter++;
+       }
+       
+       // ITS Out track
          
-         if( tpcTrack->TrackID()<ndEdxTPC ){
+       for(; itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID()<(int) tpcIter; itsOutIter++ );
+       
+       if( itsOutIter< tracksITSOut.size() && tracksITSOut[itsOutIter].TrackID() == (int) tpcIter ){
+         itsOut = &(tracksITSOut[itsOutIter]);
+         itsOutIter++;
+       }       
+       
+       // 
+
+       if (fVerbosity>0) tpcTrack->Print();  
+
+       Float_t tpcDeDx[3]={0,0,0};
+       
+       if( ndEdxTPC>0 ){       
+         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");
+           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;
-       
+       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();
-       }       
+         esdTrack.UpdateTrackParams(&(*tpcTrack),AliESDtrack::kTPCrefit);        
+         esdTrack.RelateToVertex( primaryVertex, GetBz(), 1000 );      
+         tpcConstrained = esdTrack.GetConstrainedParam();      
+       }
 
        UInt_t nClustersTPC = tpcTrack->GetNumberOfPoints();
        UInt_t nClustersITS = itsRefit ?itsRefit->GetNumberOfPoints() :0;
 
-       // fill flat track
+       
+       // ----------------------------
+       // -- fill flat track structure
 
        table[tpcIter] = trackSize;
        err = ( freeSpace < flatTrack->EstimateSize() );
@@ -571,7 +509,7 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
        
        new (flatTrack) AliFlatESDTrack;       
        
-       flatTrack->SetExternalTrackParam( itsRefit, itsRefit, tpcTrack, &tpcOutTrack, tpcConstrained, itsOut );
+       flatTrack->SetExternalTrackParam( itsRefit, itsRefit, tpcTrack, tpcOutTrack, tpcConstrained, itsOut );
        flatTrack->SetNumberOfTPCClusters( nClustersTPC );
        flatTrack->SetNumberOfITSClusters( nClustersITS );
        trackSize += flatTrack->GetSize();
@@ -617,30 +555,260 @@ int AliHLTGlobalFlatEsdConverterComponent::DoEvent( const AliHLTComponentEventDa
     if( err ) break;
 
   }while(0);
-  
+
+
   if( err ){
     HLTWarning( "Output buffer size %d exceeded, flat ESD event is not stored", maxOutputSize );
-    return -ENOSPC;
-  } 
+  } else {
 
-  { // set up the output block description
+    // 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;
+  }
 
-    fBenchmark.AddOutput(outBlock.fSize);      
+  
+  // ---------------------------------------------
+  //
+  // Fill the flat ESD friend structure
+  //
+  
+  while( !err && fProduceFriend ){ // single loop for easy break in case of output buffer overflow
 
-    size += outBlock.fSize;
+    // ---------- Access to clusters --------------------
+
+    const AliHLTTPCClusterData  *partitionClusters[fkNPartition];  //! arrays of cluster data for each TPC partition
+    Int_t                        partitionNClusters[fkNPartition]; //! number of clusters for each TPC partition
+
+    {
+      for(Int_t i=0; i<fkNPartition; i++){
+       partitionClusters[i]  = 0;
+       partitionNClusters[i] = 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;
+       }
+       const AliHLTTPCClusterData * clusterData = ( AliHLTTPCClusterData* )( iter->fPtr );
+       if( clusterData ) {
+         partitionClusters[slicepartition] = clusterData;
+         partitionNClusters[slicepartition] = clusterData->fSpacePointCnt;
+       }
+      } // end of loop over blocks of clusters    
+    }
+
+
+    AliFlatESDFriend *flatFriend = reinterpret_cast<AliFlatESDFriend*>(outputPtr + size);     
+
+    size_t freeSpaceTotal = maxOutputSize - size;
+    size_t freeSpace = freeSpaceTotal;
+
+    err = ( freeSpace < sizeof( AliFlatESDEvent ) );    
+    if( err ) break;
+
+    new (flatFriend) AliFlatESDFriend;
+      
+    freeSpace = freeSpaceTotal - flatFriend->GetSize();
+  
+    // fill event info
+    {
+      //flatFriend->SetSkipBit( 0 ); // SG!!
+      for( Int_t iSlice=0; iSlice<36; iSlice++ ){
+       int iSector = iSlice;
+       int nclu = 0;
+       for( Int_t iPartition=0; iPartition<3; iPartition++){       
+         int slicepartition = iSlice*6+iPartition;
+         nclu+= partitionNClusters[slicepartition];
+       }
+       flatFriend->SetNclustersTPC( iSector, nclu );
+       iSector = 36+iSlice;
+       nclu = 0;
+       for( Int_t iPartition=3; iPartition<6; iPartition++){       
+         int slicepartition = iSlice*6+iPartition;
+         nclu+= partitionNClusters[slicepartition];
+       }
+       flatFriend->SetNclustersTPC( iSector, nclu );
+       //SG!!!flatFriend->SetNclustersTPCused( iSector, esdFriend->GetNclustersTPCused(iSector) );
+      }
+    }
+      
+    { // Fill track friends information to the flat ESD friend structure
+     
+      size_t trackSize = 0;
+      int nTracks = 0;
+      int nTrackEntries = 0;
+      Long64_t *table = NULL;
+      AliFlatESDFriendTrack *flatTrack = NULL;
+      err = flatFriend->SetTracksStart( flatTrack, table, tracksTPC.size(), freeSpace );
+      if( err ) break;
+      freeSpace = freeSpaceTotal - flatFriend->GetSize();
+
+      for( UInt_t tpcIter=0, itsIter = 0, itsOutIter = 0; tpcIter < tracksTPC.size(); tpcIter++) {       
+       
+       // TPC track parameters
+       
+       AliHLTGlobalBarrelTrack *tpcTrack = &(tracksTPC[tpcIter]);
+       AliHLTGlobalBarrelTrack *tpcOutTrack = &(tracksTPCOut[tpcIter]);
+
+       // ITS track parameters
+       
+       AliHLTGlobalBarrelTrack *itsRefit=0;
+       AliHLTGlobalBarrelTrack *itsOut=0;
+       
+       // ITS Refit track
+         
+       for(; itsIter< tracksITS.size() && tracksITS[itsIter].TrackID()<(int) tpcIter; itsIter++ );
+       
+       if( itsIter< tracksITS.size() && tracksITS[itsIter].TrackID() == (int) tpcIter ){
+         itsRefit = &(tracksITS[itsIter]);
+         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++;
+       }
+       
+       // fill track parameters
+                 
+       table[tpcIter] = trackSize;
+       err = ( freeSpace < flatTrack->EstimateSize() );          
+       if( err ) break;
+       new (flatTrack) AliFlatESDFriendTrack;
+                 
+       freeSpace = freeSpaceTotal - flatFriend->GetSize();
+
+       flatTrack->SetSkipBit( 0 );
+       flatTrack->SetTrackParamTPCOut( tpcOutTrack );
+       flatTrack->SetTrackParamITSOut( itsOut );
+       // flatTrack->SetTrackParamTRDIn( track->GetTRDIn() );
+
+       // fill TPC seed
+
+       AliFlatTPCseed* seed = flatTrack->SetTPCseedStart();
+       new( seed ) AliFlatTPCseed;
+
+       seed->SetLabel( tpcTrack->GetLabel() );
+       seed->SetExternalTrackParam( tpcTrack );
+       
+       // clusters 
+
+       UInt_t nClusters = tpcTrack->GetNumberOfPoints();       
+       const UInt_t*clusterIDs = tpcTrack->GetPoints();
+       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;
+         }
+         
+         const AliHLTTPCClusterData * clusterData = partitionClusters[iSlice*6 + iPartition];
+         if(!clusterData ){
+           HLTError("Clusters are missed for slice %d, partition %d", iSlice, iPartition );
+           continue;
+         }
+           
+         if(iCluster >= partitionNClusters[iSlice*6 + iPartition]){
+           HLTError("TPC slice %d, partition %d: ClusterID==%d >= N Cluaters==%d ", iSlice, iPartition,iCluster, partitionNClusters[iSlice*6 + iPartition] );
+           continue;
+         }
+
+           
+         const AliHLTTPCSpacePointData *chlt = &( clusterData->fSpacePoints[iCluster] );
+         AliTPCclusterMI cl;
+         cl.SetX(chlt->fX);
+         cl.SetY(chlt->fY);
+         cl.SetZ(chlt->fZ);
+         cl.SetSigmaY2(chlt->fSigmaY2);
+         cl.SetSigmaYZ( 0 );
+         cl.SetSigmaZ2(chlt->fSigmaZ2);
+         cl.SetQ( chlt->fCharge );
+         cl.SetMax( chlt->fQMax );
+         Int_t sector, row;
+         AliHLTTPCTransform::Slice2Sector(iSlice,chlt->fPadRow, sector, row);
+         cl.SetDetector( sector );
+         cl.SetRow( row );
+         //Float_t padtime[3] = {0,chlt->fY,chlt->fZ};
+         //AliHLTTPCTransform::Local2Raw( padtime, sector, row);
+         //cl.SetPad( (Int_t) padtime[1] );
+         //cl.SetTimeBin( (Int_t) padtime[2] );
+         
+                 
+         tpcTrack->Propagate( TMath::DegToRad()*(sector%18*20.+10.), cl.GetX(), GetBz() );
+         Double_t angle2 = tpcTrack->GetSnp()*tpcTrack->GetSnp();
+         angle2 = (angle2<1) ?TMath::Sqrt(angle2/(1-angle2)) :10.; 
+         AliTPCTrackerPoint point;
+         point.SetAngleY( angle2 );
+         point.SetAngleZ( tpcTrack->GetTgl() );
+
+         seed->AddCluster(&cl, &point ); 
+       } // end of associated cluster loop
+               
+       
+       flatTrack->SetTPCseedEnd( seed->GetSize() );    
+         
+       trackSize += flatTrack->GetSize();
+       freeSpace -= flatTrack->GetSize();
+       nTrackEntries++;
+       nTracks++;
+       flatTrack = flatTrack->GetNextTrackNonConst();  
+       
+      } // fill tracks
+      
+
+      flatFriend->SetTracksEnd( nTracks, nTrackEntries, trackSize );
+      
+    }      
+
+    if( err ) break;
+
+    { // set up the output block description
+    
+      AliHLTComponentBlockData outBlock;
+      FillBlockData( outBlock );
+      outBlock.fOffset = size;
+      outBlock.fSize = flatFriend->GetSize();
+      outBlock.fDataType = kAliHLTDataTypeFlatESDFriend|kAliHLTDataOriginOut;
+      outputBlocks.push_back( outBlock );
+      fBenchmark.AddOutput(outBlock.fSize);      
+      size += outBlock.fSize;
+    }
+    
+    break;
   }
+
+  if( err ){
+    HLTWarning( "Output buffer size %d exceeded, flat ESD friend event is not stored", maxOutputSize );
+    return -ENOSPC;
+  } 
+  
+
   fBenchmark.Stop(0);
   HLTWarning( fBenchmark.GetStatistics() );
-
+  if( err ){
+    HLTWarning( "Output buffer size %d exceeded, flat ESD event is not stored", maxOutputSize );
+    return -ENOSPC;
+  } 
+  
   return 0;
 }
 
index 474e550672c0e7b694f5454f7f83bf7b6de7a81b..acb0ea8531175bd14782625b969b7734328aae95 100644 (file)
@@ -86,16 +86,16 @@ class AliHLTGlobalFlatEsdConverterComponent : public AliHLTProcessor
    */
   int Configure(const char* arguments);
 
-  int fWriteClusters; //!transient
-
   /// verbosity level
   int fVerbosity; //!transient
 
 protected:
 
-  /// solenoid b field
-  Double_t fSolenoidBz; //! transient
+  static const Int_t fkNPartition = 36*6;           // number of patches in TPC
+
   AliHLTComponentBenchmark fBenchmark; // benchmark
+  
+  Bool_t fProduceFriend; // should it produce the flat ESD friend
 
   ClassDef(AliHLTGlobalFlatEsdConverterComponent, 0)
 };
index 4fabb13a93c6928576242c5d162a4fda45833175..8322f9fb9533b90b8f723ec75980c454960fcd66 100644 (file)
@@ -51,6 +51,7 @@ class AliTPCseed : public AliTPCtrack, public AliVTPCseed {
      virtual Double_t GetPredictedChi2(const AliCluster *cluster2) const;
      virtual Bool_t Update(const AliCluster* c2, Double_t chi2, Int_t i);
      AliTPCTrackerPoint * GetTrackPoint(Int_t i);
+     const AliTPCTrackerPoint * GetTrackPointConst(Int_t i) const { return &fTrackPoints[i]; }
      AliTPCclusterMI * GetClusterFast(Int_t irow){ return fClusterPointer[irow];}
      AliTPCclusterMI * GetClusterFast(Int_t irow) const { return fClusterPointer[irow];}
      void SetClusterPointer(Int_t irow, AliTPCclusterMI* cl) {fClusterPointer[irow]=cl;}