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 // _______________________________________________________________________________________________________
42 AliFlatESDFriend::AliFlatESDFriend() :
47 fTrackTablePointer(0),
50 // Default constructor
54 void AliFlatESDFriend::Reset()
59 fTrackTablePointer = 0;
61 for( int i=0; i<72; i++ ){
63 fNclustersTPCused[i]=0;
65 // We set size of the fContent array such, that it reaches the end of the AliFlatESDFriend structure.
66 // To be sure that actual GetSize() is always >= size of the structure.
67 // First, it makes the memory alignment better. Second, just for a case..
68 fContentSize = sizeof(AliFlatESDFriend) - (fContent - reinterpret_cast<const Byte_t*>(this));
69 for( UInt_t i=0; i<fContentSize; i++ ) fContent[i]=0;
72 // _______________________________________________________________________________________________________
73 AliFlatESDFriend::AliFlatESDFriend(AliVConstructorReinitialisationFlag f)
80 // fTrackTablePointer(),
83 //special constructor, used to restore the vtable pointer
84 //uses the special dummy constructors of contained objects
86 // the vtable pointer for this AliFlatESDFriend object is already reset when this constructor is called
87 // we should only initialise vtable pointers for all contained objects
89 if(f == AliVReinitialize){
90 for( int i=0; i<fNTracks; i++ ){
91 AliFlatESDFriendTrack *tr = GetFlatTrackNonConst(i);
92 if( tr ) tr->Reinitialize();
100 void AliFlatESDFriend::Ls() const
102 cout<<"Flat ESD friend: "<<endl;
103 cout<<" N tracks: "<<fNTracks<<endl;
104 cout<<" N track entries: "<<fNTrackEntries<<endl;
108 // _______________________________________________________________________________________________________
109 Int_t AliFlatESDFriend::SetFromESDfriend( const size_t allocatedMemorySize, const AliESDfriend *esdFriend )
111 // Fill flat ESD friend from ALiESDfriend
113 if( allocatedMemorySize < sizeof(AliFlatESDFriend ) ) return -1;
117 if( !esdFriend ) return 0;
120 size_t freeSpace = allocatedMemorySize - GetSize();
124 SetSkipBit( esdFriend->TestSkipBit() );
125 for( int iSector=0; iSector<72; iSector++ ){
126 SetNclustersTPC( iSector, esdFriend->GetNclustersTPC(iSector) );
127 SetNclustersTPCused( iSector, esdFriend->GetNclustersTPCused(iSector) );
131 // fill track friends
133 size_t trackSize = 0;
135 int nTrackEntries = 0;
136 Long64_t *table = NULL;
137 AliFlatESDFriendTrack *flatTrack = NULL;
138 err = SetTracksStart( flatTrack, table, esdFriend->GetNumberOfTracks(), freeSpace );
139 if( err!=0 ) return err;
140 freeSpace = allocatedMemorySize - GetSize();
142 for (Int_t idxTrack = 0; idxTrack < esdFriend->GetNumberOfTracks(); ++idxTrack) {
143 const AliESDfriendTrack *esdTrack = esdFriend->GetTrack(idxTrack);
144 table[idxTrack] = -1;
146 table[idxTrack] = trackSize;
147 if( freeSpace<flatTrack->EstimateSize() ) return -1;
148 new (flatTrack) AliFlatESDFriendTrack;
149 //flatTrack->SetFromESDTrack( esdTrack );
150 trackSize += flatTrack->GetSize();
151 freeSpace -= flatTrack->GetSize();
153 flatTrack = flatTrack->GetNextTrackNonConst();
158 SetTracksEnd( nTracks, nTrackEntries, trackSize );