3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
19 * >> Flat structure representing an ESD friend <<
21 * To be used in the online and offline calibration schema.
23 * Class provides interface methods for
24 * - Filling from AliESDfriend, but also from HLT
27 * In the online case, the structure can be directly written into a shared
28 * memory, in the offline case, the size has to be estimated first.
31 * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli
33 * ************************************************************************
36 #include "AliFlatESDFriend.h"
37 #include "AliFlatESDFriendTrack.h"
38 #include "Riostream.h"
39 #include "AliESDfriend.h"
41 // _______________________________________________________________________________________________________
49 void AliFlatESDFriend::Ls() const
51 cout<<"Flat ESD friend: "<<endl;
52 cout<<" N tracks: "<<fNTracks<<endl;
53 cout<<" N track entries: "<<fNTrackEntries<<endl;
58 // _______________________________________________________________________________________________________
59 ULong64_t AliFlatESDFriend::EstimateSize(AliESDfriend* esdFriend)
61 // Estimate upper limit of the object size
62 // -> Added objects have to be added here as well
63 if(esdFriend == NULL) return 0;
64 ULong64_t size = sizeof(AliFlatESDFriend);
65 // one Long64_t per track for tracks table
66 size += esdFriend->GetNumberOfTracks() * (AliFlatESDFriendTrack::EstimateSize() + sizeof(Long64_t) );
72 // _______________________________________________________________________________________________________
74 Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, const AliESDfriend *esdFriend )
76 // Fill flat ESD friend from ALiESDfriend
78 if( allocatedMemorySize < sizeof(AliFlatESDFriend ) ) return -1;
82 if( !esdFriend ) return 0;
85 size_t freeSpace = allocatedMemorySize - GetSize();
89 SetSkipBit( esdFriend->TestSkipBit() );
90 for( int iSector=0; iSector<72; iSector++ ){
91 SetNclustersTPC( iSector, esdFriend->GetNclustersTPC(iSector) );
92 SetNclustersTPCused( iSector, esdFriend->GetNclustersTPCused(iSector) );
100 int nTrackEntries = 0;
101 Long64_t *table = NULL;
102 AliFlatESDFriendTrack *flatTrack = NULL;
103 err = SetTracksStart( flatTrack, table, esdFriend->GetNumberOfTracks(), freeSpace );
104 if( err!=0 ) return err;
105 freeSpace = allocatedMemorySize - GetSize();
107 for (Int_t idxTrack = 0; idxTrack < esdFriend->GetNumberOfTracks(); ++idxTrack) {
108 const AliESDfriendTrack *esdTrack = esdFriend->GetTrack(idxTrack);
109 table[idxTrack] = -1;
111 table[idxTrack] = trackSize;
112 if( freeSpace<flatTrack->EstimateSize() ) return -1;
113 new (flatTrack) AliFlatESDFriendTrack;
114 if( flatTrack->SetFromESDfriendTrack( esdTrack, freeSpace ) ) return -1;
116 trackSize += flatTrack->GetSize();
117 freeSpace -= flatTrack->GetSize();
119 flatTrack = flatTrack->GetNextTrackNonConst();
124 SetTracksEnd( nTracks, nTrackEntries, trackSize );