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 // _______________________________________________________________________________________________________
48 void AliFlatESDFriend::Ls() const
50 cout<<"Flat ESD friend: "<<endl;
51 cout<<" N tracks: "<<fNTracks<<endl;
52 cout<<" N track entries: "<<fNTrackEntries<<endl;
56 // _______________________________________________________________________________________________________
58 Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, const AliESDfriend *esdFriend )
60 // Fill flat ESD friend from ALiESDfriend
62 if( allocatedMemorySize < sizeof(AliFlatESDFriend ) ) return -1;
66 if( !esdFriend ) return 0;
69 size_t freeSpace = allocatedMemorySize - GetSize();
73 SetSkipBit( esdFriend->TestSkipBit() );
74 for( int iSector=0; iSector<72; iSector++ ){
75 SetNclustersTPC( iSector, esdFriend->GetNclustersTPC(iSector) );
76 SetNclustersTPCused( iSector, esdFriend->GetNclustersTPCused(iSector) );
84 int nTrackEntries = 0;
85 Long64_t *table = NULL;
86 AliFlatESDFriendTrack *flatTrack = NULL;
87 err = SetTracksStart( flatTrack, table, esdFriend->GetNumberOfTracks(), freeSpace );
88 if( err!=0 ) return err;
89 freeSpace = allocatedMemorySize - GetSize();
91 for (Int_t idxTrack = 0; idxTrack < esdFriend->GetNumberOfTracks(); ++idxTrack) {
92 const AliESDfriendTrack *esdTrack = esdFriend->GetTrack(idxTrack);
95 table[idxTrack] = trackSize;
96 if( freeSpace<flatTrack->EstimateSize() ) return -1;
97 new (flatTrack) AliFlatESDFriendTrack;
98 //flatTrack->SetFromESDTrack( esdTrack );
99 trackSize += flatTrack->GetSize();
100 freeSpace -= flatTrack->GetSize();
102 flatTrack = flatTrack->GetNextTrackNonConst();
107 SetTracksEnd( nTracks, nTrackEntries, trackSize );