1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 * @file AliHLTMUONMansoTrackerComponent.cxx
20 * @author Artur Szostak <artursz@iafrica.com>
22 * @brief Implementation of AliHLTMUONMansoTrackerComponent class.
25 #include "AliHLTMUONMansoTrackerComponent.h"
26 #include "Util/AliHLTMUONRecPoint.h"
32 // this is a global object used for automatic component registration, do not use this
33 AliHLTMUONMansoTrackerComponent gAliHLTMUONMansoTrackerComponent;
37 ClassImp(AliHLTMUONMansoTrackerComponent);
40 AliHLTMUONMansoTrackerComponent::AliHLTMUONMansoTrackerComponent()
42 fOutputPercentage(100) // By default we copy to the output exactly what we got as input
46 AliHLTMUONMansoTrackerComponent::~AliHLTMUONMansoTrackerComponent()
50 const char* AliHLTMUONMansoTrackerComponent::GetComponentID()
52 return "tracking"; // The ID of this component
55 void AliHLTMUONMansoTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
57 /* in order to be backward compatible we have to keep the old code, at
58 * least for a while. Remember to use the new const kAliHLTVoidDataType
59 * if you are using a more recent AliRoot version (from Jan 07)
60 list.push_back(kAliHLTAnyDataType); // We do not have any requirements for our input data type(s).
63 AliHLTComponentDataType dt =
64 { sizeof(AliHLTComponentDataType),
65 {'*','*','*','*','*','*','*','\0'},
70 AliHLTComponentDataType AliHLTMUONMansoTrackerComponent::GetOutputDataType()
72 /* in order to be backward compatible we have to keep the old code, at
73 * least for a while. Remember to use the new const kAliHLTVoidDataType
74 * if you are using a more recent AliRoot version (from Jan 07)
75 return kAliHLTVoidDataType;
77 AliHLTComponentDataType dt =
78 { sizeof(AliHLTComponentDataType),
79 {'\0','\0','\0','0','\0','\0','\0','\0'},
80 {'\0','\0','\0','\0'}};
84 void AliHLTMUONMansoTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
87 inputMultiplier = ((double)fOutputPercentage)/100.0;
92 // Spawn function, return new instance of this class
93 AliHLTComponent* AliHLTMUONMansoTrackerComponent::Spawn()
95 return new AliHLTMUONMansoTrackerComponent;
98 int AliHLTMUONMansoTrackerComponent::DoInit( int argc, const char** argv )
100 // perform initialization. We check whether our relative output size is specified in the arguments.
101 fOutputPercentage = 100;
103 fTracker = new AliHLTMUONMansoTracker();
105 Logging(kHLTLogInfo, "dHLT", "Tracking", "hitrec, DoInit");
106 if (argc==0 && argv==NULL) {
107 // this is just to get rid of the warning "unused parameter"
114 Logging( kHLTLogDebug, "AliHLTMUONMansoTrackerComponent::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
115 if ( !strcmp( argv[i], "output_percentage" ) )
119 Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Missing Argument", "Missing output_percentage parameter");
122 Logging( kHLTLogDebug, "AliHLTMUONMansoTrackerComponent::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
123 fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
126 Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
129 Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
133 Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
139 int AliHLTMUONMansoTrackerComponent::DoDeinit()
146 int AliHLTMUONMansoTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
147 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
148 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
150 Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
152 unsigned long totalSize = 0;
153 AliHLTUInt32_t maxTracksPerEvent = 1024;
156 fTracker->SetTrackOutputBuffer((AliHLTMUONTrackPoints*)outputPtr,maxTracksPerEvent);
158 // cout<<"BlockSize :"<<evtData.fBlockCnt<<" size :"<<outputBlocks.size()<<endl;
159 // Loop over all input blocks in the event
160 for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
162 // Align the beginning of this block to the required value.
163 // if ( totalSize % kAliHLTBlockAlignment )
164 // totalSize += kAliHLTBlockAlignment-(totalSize % kAliHLTBlockAlignment);
166 if ( totalSize > size )
168 // Determine the size we should use for the output for this block (the input block's size times the relative output size)
169 unsigned long mySize = (blocks[n].fSize * fOutputPercentage) / 100;
170 Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "mySize set (1)", "mySize == %lu B - blocks[%lu].fSize == %lu - fOutputPercentage == %lu - totalSize == %lu",
171 mySize, n, blocks[n].fSize, fOutputPercentage, totalSize );
173 Int_t noftrigData,nofhitData;
174 if(n== (evtData.fBlockCnt - 1)){// for trigger
176 memcpy(&trigDataSize,blocks[n].fPtr,sizeof(UInt_t));
177 // cout<<"trigDataSize :"<<trigDataSize<<endl;
179 memcpy(&trigOffSet,(UInt_t*)blocks[n].fPtr + 1,sizeof(UInt_t));
180 // cout<<"trigOffSet :"<<trigOffSet<<endl;
181 noftrigData = (trigDataSize - sizeof(UInt_t))*sizeof(AliHLTUInt32_t)/sizeof(AliHLTMUONCoreTriggerRecord) ;
182 fTrigData = new AliHLTMUONCoreTriggerRecord[noftrigData];
184 for(Int_t i=0;i<noftrigData;i++){
185 AliHLTMUONCoreTriggerRecord record;
186 memcpy(&record,(UInt_t*)blocks[n].fPtr + 2 + i*(sizeof(AliHLTMUONCoreTriggerRecord))/4,sizeof(AliHLTMUONCoreTriggerRecord));
187 fTrigData[i] = record;
189 // cout<<" Sign : "<<fTrigData[i].fSign
190 // <<" Pt : "<<fTrigData[i].fPt
191 // <<"\t X1:"<<fTrigData[i].fStation1impact.X()<<" Y1 :"<<fTrigData[i].fStation1impact.Y()
192 // <<"\t X2:"<<fTrigData[i].fStation2impact.X()<<" Y2 :"<<fTrigData[i].fStation2impact.Y()
196 fTracker->FindTracks(fTrigData,noftrigData);
197 // cout<<"Nof tracks found :"<<fTracker->TrackCount()<<endl;
198 // cout<<"Z7 : "<<AliHLTMUONCoreMansoTracker::GetZ7()<<endl;
202 memcpy(&hitDataSize,blocks[n].fPtr,sizeof(UInt_t));
203 // cout<<"hitDataSize :"<<hitDataSize<<endl;
204 nofhitData = hitDataSize*sizeof(AliHLTUInt32_t)/sizeof(AliHLTMUONCorePoint) ;
206 Int_t chamber = n + 6;
207 AliHLTMUONRecPoint *recHit = new AliHLTMUONRecPoint[nofhitData];
208 for(Int_t i=0;i<nofhitData;i++){
209 AliHLTMUONCorePoint point;
210 memcpy(&point,(UInt_t*)blocks[n].fPtr + 1 + i*(sizeof(AliHLTMUONCorePoint))/4,sizeof(AliHLTMUONCorePoint));
211 // cout <<"chamber :"<<chamber<<"\tX : "<<point.X()<<"\t Y : "<<point.Y()<< endl;
212 recHit[i].fX = point.X();
213 recHit[i].fY = point.Y();
216 fTracker->AddRecHits(chamber,recHit,nofhitData);
218 }// hit or trig condn
221 //for(Int_t itrig = 0 ; itrig < nofTrigData ; itrig++){
226 // Check how much space we have left and adapt this output block's size accordingly.
227 // if ( totalSize + mySize > size )
228 // mySize = size-totalSize;
229 // Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "mySize set (2)", "mySize == %lu B - totalSize == %lu - size == %lu",
230 // mySize, totalSize, size );
232 // continue; // No room left to write a further block.
233 // // Now copy the input block
234 // unsigned long copied = 0;
235 // // First copy all full multiples of the input block
236 // while ( copied+blocks[n].fSize <= mySize )
238 // Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B",
239 // blocks[n].fSize, copied, totalSize );
240 // memcpy( outputPtr+totalSize+copied, blocks[n].fPtr, blocks[n].fSize );
241 // copied += blocks[n].fSize;
243 // // And the copy the remaining fragment of the block
244 // Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B",
245 // mySize-copied, copied, totalSize );
246 // memcpy( outputPtr+totalSize+copied, blocks[n].fPtr, mySize-copied );
247 // Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "Copied", "Copied: %lu B - totalSize: %lu B",
248 // copied, totalSize );
249 // // Fill a block data structure for our output block.
250 // AliHLTComponentBlockData ob;
251 // // Let the structure be filled with the default values.
252 // // This takes care of setting the shared memory and data type values to default values,
253 // // so that they can be filled in by the calling code.
254 // FillBlockData( ob );
255 // // This block's start (offset) is after all other blocks written so far
256 // ob.fOffset = totalSize;
257 // // the size of this block's data.
258 // ob.fSize = mySize;
259 // // The specification of the data is copied from the input block.
260 // ob.fSpecification = blocks[n].fSpecification;
261 // // The data type is set automatically to the component's specified output data type.
262 // // Place this block into the list of output blocks
263 // outputBlocks.push_back( ob );
264 // // Increase the total amount of data written so far to our output memory
265 // totalSize += mySize;
267 // Finally we set the total size of output memory we consumed.