added friends to compare component
authorsgweber <steffen.georg.weber@cern.ch>
Mon, 27 Oct 2014 09:28:24 +0000 (10:28 +0100)
committersgweber <steffen.georg.weber@cern.ch>
Mon, 27 Oct 2014 09:28:24 +0000 (10:28 +0100)
HLT/global/AliFlatESDEvent.cxx
HLT/global/AliFlatESDFriend.cxx
HLT/global/AliFlatESDFriend.h
HLT/global/AliFlatESDFriendTrack.h
HLT/global/AliHLTGlobalCompareFlatComponent.cxx
HLT/global/AliHLTGlobalCompareFlatComponent.h
HLT/global/AliHLTGlobalEsdToFlatConverterComponent.cxx
HLT/global/AliHLTGlobalEsdToFlatConverterComponent.h

index 174dd90..42e1481 100644 (file)
@@ -197,7 +197,7 @@ void AliFlatESDEvent::Reset()
   
   ULong64_t size = sizeof(AliFlatESDEvent);
   size += 2 * sizeof( AliFlatESDVertex );
-  size += esd->GetNumberOfTracks() * ( AliFlatESDTrack::EstimateSize() + sizeof(Long64_t) );
+  size += esd->GetNumberOfTracks() * AliFlatESDTrack::EstimateSize();
   size += AliESDRun::kNTriggerClasses * sizeof(AliFlatESDTrigger) ;
   if( fillV0s ) size += esd->GetNumberOfV0s()*sizeof(AliFlatESDV0);
   return size;
index 9928755..c24e23b 100644 (file)
@@ -53,6 +53,20 @@ void AliFlatESDFriend::Ls() const
 }
 
 
+
+// _______________________________________________________________________________________________________
+  ULong64_t AliFlatESDFriend::EstimateSize(AliESDfriend* esdFriend) 
+{
+  // Estimate upper limit of the object size
+  // -> Added objects have to be added here as well
+  
+  ULong64_t size = sizeof(AliFlatESDFriend);
+  size += esdFriend->GetNumberOfTracks() *  AliFlatESDFriendTrack::EstimateSize();
+  return size;
+}
+
+
+
 // _______________________________________________________________________________________________________
 
 Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, const AliESDfriend *esdFriend )
index 48b6fd7..cec1246 100644 (file)
@@ -79,6 +79,7 @@ public:
 
   ULong64_t  GetSize()  const { return fContent - reinterpret_cast<const Byte_t*>(this) + fContentSize; }
 
+  static ULong64_t EstimateSize(AliESDfriend* esdFriend );
 
 private: 
 
index 0fd57f4..9254db7 100644 (file)
@@ -107,7 +107,7 @@ class AliFlatESDFriendTrack :public AliVfriendTrack
   
   Byte_t fContent[1];                  // Variale size object, which contains all data
 
-  //ClassDef(AliFlatESDFriendTrack, 0)
+ // ClassDef(AliFlatESDFriendTrack, 0)
 
 };
 
@@ -116,6 +116,7 @@ inline Int_t AliFlatESDFriendTrack::GetTrackParam( Long64_t ptr, AliExternalTrac
   if( ptr<0 ) return -1;
   const AliFlatExternalTrackParam *fp = reinterpret_cast< const AliFlatExternalTrackParam* >( fContent + ptr );
   fp->GetExternalTrackParam( param );
+       return 0;
 }
 
 inline void AliFlatESDFriendTrack::SetTrackParam( Long64_t &ptr, const AliExternalTrackParam *p )
index 5040762..8806d3f 100644 (file)
@@ -28,6 +28,7 @@
 #include "THnSparse.h"
 #include "AliESDEvent.h"
 #include "AliFlatESDEvent.h"
+#include "AliFlatESDFriend.h"
 #include "AliFlatESDTrigger.h"
 #include "AliFlatESDV0.h"
 #include "AliFlatESDVertex.h"
@@ -36,6 +37,8 @@
 #include "AliHLTGlobalCompareFlatComponent.h"
 #include "AliHLTITSClusterDataFormat.h"
 #include "AliHLTTPCDefinitions.h"
+#include "AliTPCseed.h"
+#include "AliExternalTrackParam.h"
 #include "TTree.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
@@ -52,6 +55,33 @@ void AliHLTGlobalCompareFlatComponent::printDiff( string name, double val1, doub
        else if(relDiff < -1e-6) diff = -1;
        outFile<<name<<"\t" << val1 << "\t" << val2 <<"\t" << diff << "\n";
 }
+
+
+
+void AliHLTGlobalCompareFlatComponent::printDiff( string name, int n , double* vals1, double* vals2 ){
+       double relDiff = 0;
+       int diff = 0;
+       
+       for(int i=0; i<n && diff == 0; i++){
+               relDiff = ( vals1[i] != 0 || vals2[i] !=0 ) ? (vals1[i]-vals2[i])/(fabs(vals1[i]) + fabs(vals2[i])): 0;
+               if (relDiff > 1e-6) diff = 1;
+               else if(relDiff < -1e-6) diff = -1;
+       }
+               
+       outFile<<name<<"\t";
+       for(int i=0; i<n;i++){
+                       outFile<<vals1[i]<<" ";
+       }
+       outFile<<"\t";
+       for(int i=0; i<n;i++){
+                       outFile<<vals2[i]<<" ";
+       }
+       outFile<<"\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";
 }
@@ -214,6 +244,7 @@ Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData&
    return 0;
 
  AliFlatESDEvent *flatEsd[2] ;
+ AliFlatESDFriend *flatFriend[2] ;
        
   printf("search for input onbjects\n");
        {
@@ -222,13 +253,18 @@ Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData&
     pBlock!=NULL && i<2; pBlock = GetNextInputBlock(),i++ ) {
                        flatEsd[i] = reinterpret_cast<AliFlatESDEvent*>( pBlock->fPtr );
   }
+  i=0;
+       for ( const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESDFriend|kAliHLTDataOriginOut);
+    pBlock!=NULL && i<2; pBlock = GetNextInputBlock(),i++ ) {
+                       flatFriend[i] = reinterpret_cast<AliFlatESDFriend*>( 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;
+ cout<<"size event : "<<flatEsd[0]->GetSize() << " "<<flatEsd[1]->GetSize()<<endl;
+ cout<<"nTracks : "<<flatEsd[0]->GetNumberOfTracks()<<" "<<flatEsd[1]->GetNumberOfTracks()<<endl;
+ cout<<"size friend : "<<flatFriend[0]->GetSize() << " "<<flatFriend[1]->GetSize()<<endl;
+ cout<<"nFriendTracks : "<<flatFriend[0]->GetNumberOfTracks()<<" "<<flatFriend[1]->GetNumberOfTracks()<<endl;
  
  outFile.open("comparison.txt",ios::app);
  
@@ -268,6 +304,7 @@ Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData&
  
        if(vertexSPD[0] && vertexSPD[1]){
       outFile<<"\nnew AliFlatESDVertexSPD\n";
+                       outFile<<"AliFlatESDVertexSPD::memcmp "<<memcmp(vertexSPD[0], vertexSPD[1], max(vertexSPD[0]->GetSize(), vertexSPD[1]->GetSize()))<<"\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() ); 
@@ -347,10 +384,9 @@ Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData&
                                        printDiff( Form("AliFlatExternalTrackParam%s::GetTgl",pNames[i]),p[i][0]->GetTgl(),p[i][1]->GetTgl() ); 
                                        printDiff( Form("AliFlatExternalTrackParam%s::GetSigned1Pt",pNames[i]),p[i][0]->GetSigned1Pt(),p[i][1]->GetSigned1Pt() ); 
                                        
-                                       for(int j=0; j<15; j++){
-                                               printDiff( Form("AliFlatExternalTrackParam%s::GetCovEntry(%d)",pNames[i],j),p[i][0]->GetCovEntry(j),p[i][1]->GetCovEntry(j) ); 
-                                       }
-                               
+                                       
+                                       Double_t* cov[2] = {(Double_t* ) p[i][0]->GetCov() , (Double_t*) p[i][1]->GetCov() };
+                                       printDiff( Form("AliFlatExternalTrackParam%s::GetCov",pNames[i]) , 15, cov[0], cov[1]); 
                                }
                        }
                        
@@ -358,24 +394,101 @@ Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData&
                        
                        
       track[0] = track[0]->GetNextTrackNonConst();
-                       track[1] = track[1]->GetNextTrackNonConst();
+                       track[1] = track[1]->GetNextTrackNonConst();                    
                        
+    }
+       }
+       
+       
+ // Compare Friend variables
+       outFile<<"\n\n------------------\nnew AliFlatESDFriend\n------------------\n";
+       printDiff( "AliFlatESDFriend::GetSize" ,flatFriend[0]->GetSize(), flatFriend[1]->GetSize() ) ;
+       printDiff( "AliFlatESDFriend::GetNumberOfTracks" ,flatFriend[0]->GetNumberOfTracks(), flatFriend[1]->GetNumberOfTracks());
+       printDiff( "AliFlatESDFriend::GetEntriesInTracks" ,flatFriend[0]->GetEntriesInTracks(), flatFriend[1]->GetEntriesInTracks());
+       printDiff( "AliFlatESDFriend::TestSkipBit" ,flatFriend[0]->TestSkipBit(), flatFriend[1]->TestSkipBit() ) ;
+       Double_t clTpc[2][72];
+       Double_t clTpcU[2][72];
+       for(int i = 0 ; i<72; i++){
+               clTpc[0][i] = flatFriend[0]->GetNclustersTPC(i);
+               clTpc[1][i] = flatFriend[1]->GetNclustersTPC(i);
+               
+               clTpcU[0][i] = flatFriend[0]->GetNclustersTPCused(i);
+               clTpcU[1][i] = flatFriend[1]->GetNclustersTPCused(i);
+       }
+       
+       
+       printDiff( "AliFlatESDFriend::GetNclustersTPC" ,72, clTpc[0], clTpc[1] ) ;
+       printDiff( "AliFlatESDFriend::GetNclustersTPCused" ,72, clTpcU[0], clTpcU[1] ) ;
+       
+       
+       // compare friend tracks
+       
+       if(flatFriend[0]->GetEntriesInTracks()  && flatFriend[1]->GetEntriesInTracks() ){
+               outFile<<"------------------\nfriend tracks\n------------------\n";
+               
+    AliFlatESDFriendTrack * track[2] = { const_cast<AliFlatESDFriendTrack*>(flatFriend[0]->GetFlatTrackEntry(0) ) , const_cast<AliFlatESDFriendTrack*>(flatFriend[1]->GetFlatTrackEntry(0) ) };
+    for( Int_t t = 0; t < flatFriend[0]->GetEntriesInTracks()  && t < flatFriend[1]->GetEntriesInTracks()  ; t++ ){
+                       if(!track[0] || !track[1]) continue;
+      outFile<<"\nnew AliFlatESDFriendTrack\n";
+                       printDiff( "AliFlatESDFriendTrack::GetSize",track[0]->GetSize(),track[1]->GetSize() ); 
                        
+                       AliExternalTrackParam p[3][2]; 
+                       AliExternalTrackParam q =AliExternalTrackParam() ;
                        
+                       const char* pNames[3] = {"TPCOut", "ITSOut", "TRDIn"};
                        
+               //      track[0]->GetTrackParamTPCOut(q );
+               //      track[1]->GetTrackParamTPCOut(p[0][1] );
                        
+               //      track[0]->GetTrackParamITSOut(p[1][0] );
+                       //track[1]->GetTrackParamITSOut(p[1][1] );
                        
                        
+                       track[0]->GetTrackParamTRDIn(p[2][0] );
+                       track[1]->GetTrackParamTRDIn(p[2][1] );
                        
                        
-    }
-       }
+                                       for(int i = 0 ; i<7; i++){
+                                       outFile<<"\nnew AliExternalTrackParam" << pNames[i] << "\n";
+                                       printDiff( Form("AliExternalTrackParam%s::GetAlpha",pNames[i]),p[i][0].GetAlpha(),p[i][1].GetAlpha() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetX",pNames[i]),p[i][0].GetX(),p[i][1].GetX() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetY",pNames[i]),p[i][0].GetY(),p[i][1].GetY() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetZ",pNames[i]),p[i][0].GetZ(),p[i][1].GetZ() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetSnp",pNames[i]),p[i][0].GetSnp(),p[i][1].GetSnp() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetTgl",pNames[i]),p[i][0].GetTgl(),p[i][1].GetTgl() ); 
+                                       printDiff( Form("AliExternalTrackParam%s::GetSigned1Pt",pNames[i]),p[i][0].GetSigned1Pt(),p[i][1].GetSigned1Pt() ); 
+                                       
+                                       
+                                       Double_t* cov[2] = { const_cast<Double_t*>( p[i][0].GetCovariance()) , const_cast<Double_t*>( p[i][1].GetCovariance() ) };
+                                       printDiff( Form("AliExternalTrackParam%s::GetCovariance",pNames[i]) , 15, cov[0], cov[1]); 
+                       
+                       }
+                       
+                       
+                       
+                       
+                       
+                       AliTPCseed s[2];
+                       
+                       
+                       track[0]->GetTPCseed(s[0] );
+                       track[1]->GetTPCseed(s[1] );
+                       
+                       
+      track[0] = track[0]->GetNextTrackNonConst();
+                       track[1] = track[1]->GetNextTrackNonConst();    
+                       
+                       
+               }
        
+       }
        
- outFile.close();
+       outFile.close();
  
  
-  return iResult;
+       return iResult;
 }
 
 
index 77416b6..b5613aa 100644 (file)
@@ -131,6 +131,7 @@ private:
   /** assignment operator prohibited */
   AliHLTGlobalCompareFlatComponent& operator=(const AliHLTGlobalCompareFlatComponent&);
 void printDiff( string name, double val1, double val2);
+void printDiff( string name, int n , double* vals1, double* vals2 );
 void printDiff( string name, TString val1, TString val2);
 
   /*
index 59c0ef3..d26f741 100644 (file)
@@ -90,10 +90,20 @@ void AliHLTGlobalEsdToFlatConverterComponent::GetInputDataTypes( vector<AliHLTCo
   list.push_back( kAliHLTDataTypeESDfriendObject|kAliHLTDataOriginOut );
 }
 
-// #################################################################################
-AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType() {
+
+AliHLTComponentDataType AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataType()
+{
   // see header file for class documentation
-  return kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut;
+  return kAliHLTMultipleDataType;
+}
+
+int AliHLTGlobalEsdToFlatConverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){ 
+// see header file for class documentation
+
+  tgtList.clear();
+  tgtList.push_back( kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut );
+  tgtList.push_back( kAliHLTDataTypeFlatESDFriend|kAliHLTDataOriginOut );
+  return tgtList.size();
 }
 
 // #################################################################################
@@ -208,6 +218,7 @@ Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEven
   AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Start");
   Int_t iResult=0;
 
+       Bool_t err = kFALSE;
        
        
   size_t maxOutputSize = size;
@@ -218,11 +229,13 @@ Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEven
     return 0;
   
    AliESDEvent *esd;
+       AliESDfriend *esdFriend;
        
        
   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {
     esd =dynamic_cast<AliESDEvent*>(const_cast<TObject*>(iter));
     if( esd ){
+                       cout <<"ESD object found in input"<<endl;
       esd->GetStdContent();
                        iResult=1;
     } else {
@@ -230,43 +243,64 @@ Int_t AliHLTGlobalEsdToFlatConverterComponent::DoEvent(const AliHLTComponentEven
   }
 
    for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDfriendObject | kAliHLTDataOriginOut); iter != NULL; iter = GetNextInputObject() ) {     
-     //fBenchmark.AddInput(pBlock->fSize);
-    const AliESDfriend *esdFriend = dynamic_cast<const AliESDfriend*>(iter);
+   esdFriend = dynamic_cast<AliESDfriend*>(const_cast<TObject*>(iter));
     if( esdFriend ){
+                       cout <<"ESD friend object found in input"<<endl;
     } else {
     }
   }
            
- AliFlatESDEvent *flatEsd ;
-
-    flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
-    new (flatEsd) AliFlatESDEvent;
-  flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE); 
-                
+       AliFlatESDEvent *flatEsd = reinterpret_cast<AliFlatESDEvent*>(outputPtr);
+       new (flatEsd) AliFlatESDEvent;
+       flatEsd->SetFromESD(AliFlatESDEvent::EstimateSize(esd),esd, kTRUE); 
+        
+       
+       
        
-       if( maxOutputSize > flatEsd->GetSize() ){
        
+       
+       
+       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;       
        }
-       
+ if(esdFriend){
+               AliFlatESDFriend *flatFriend = reinterpret_cast<AliFlatESDFriend*>(outputPtr + size); 
+               size_t freeSpaceTotal = maxOutputSize - size;
+    size_t freeSpace = freeSpaceTotal;
+
+    err = ( freeSpace < sizeof( AliFlatESDEvent ) );    
+    if( err ) return 0;
+
+    new (flatFriend) AliFlatESDFriend;
+    freeSpace = freeSpaceTotal - flatFriend->GetSize();
+               
+       flatFriend->SetFromESDfriend(AliFlatESDFriend::EstimateSize(esdFriend),esdFriend); 
+               
+                   { // 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 );
+      size += outBlock.fSize;
+    }
+               
+               
+ }
+               
   AliSysInfo::AddStamp("AliHLTGlobalEsdToFlatConverterComponent::DoEvent.Stop",0, flatEsd->GetSize(),flatEsd->GetNumberOfV0s(),flatEsd->GetNumberOfTracks());
  
  
index 63641a6..66a89ac 100644 (file)
@@ -63,6 +63,9 @@ public:
   AliHLTComponentDataType GetOutputDataType();
 
   /** interface function, see @ref AliHLTComponent for description */
+  int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+
+  /** interface function, see @ref AliHLTComponent for description */
   void GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier );
 
   /** interface function, see @ref AliHLTComponent for description */