]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
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 174dd906cd98b1ec0ca896980e5852ffa9062dea..42e1481c4c6fc014a2ac3f81c37c2aafd6424150 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 992875520c7ede11404d766295523293335c5d32..c24e23b070f54b64c4ed841e2187a95cc030b4be 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 48b6fd7f3aeaaa59aa1379b847722d8a407a3a55..cec1246158a584f48e93de3c0e99db20f5c86f31 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 0fd57f4d3b73e4d9e2e2d53e4c1ee63af8de222b..9254db72179a7493420b9bc8e5d485c0780ccdc7 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 50407621df1f955078e35bb9d363641d7f0c120b..8806d3fce1b003c42dad35db5f1da943d479bd39 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 77416b617b89c934c2f803b936064e9f41f9cc7c..b5613aafe5903196fee1ecd6f313e18d9fbd2cb4 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 59c0ef3a60e1f0dc9e087ce753b232cddeff08ae..d26f741c20bcad15d5d4c02516c1aa1592a067ca 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 63641a629b11b08d0d9d4fb7fd49ac227c5ce2ff..66a89aca43c5bc495a73c8dad8fef2455ee40916 100644 (file)
@@ -62,6 +62,9 @@ public:
   /** interface function, see @ref AliHLTComponent for description */
   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 );