Coding conventions (A.Szostak)
[u/mrichter/AliRoot.git] / HLT / MUON / src / AliRoot / ClusterSource.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Author: Artur Szostak
4 // Email:  artur@alice.phy.uct.ac.za | artursz@iafrica.com
5 //
6 ////////////////////////////////////////////////////////////////////////////////
7
8 #include "AliRoot/ClusterSource.hpp"
9 #include "AliRoot/Base.hpp"
10 #include "AliMUONConstants.h"
11 #include "AliMUONHit.h"
12 #include "AliMUONRawCluster.h"
13 #include "AliMUONDataInterface.h"
14 #ifndef __alpha
15 #include <math.h>
16 #else
17 #include <float.h>
18 #endif
19
20 ClassImp(AliHLTMUONClusterSource)
21 ClassImp(AliHLTMUONClusterSource::BlockData)
22 ClassImp(AliHLTMUONClusterSource::EventData)
23
24
25 AliHLTMUONClusterSource::AliHLTMUONClusterSource()
26         : TObject(), fEventList(AliHLTMUONClusterSource::EventData::Class())
27 {
28         fAreaToUse = FromWholePlane;
29         fDataToUse = FromRawClusters;
30         fMaxBlockSize = 0xFFFFFFFF;
31         fFilename = "";
32         fFoldername = "";
33         ResetAllPointers();
34 }
35
36
37 AliHLTMUONClusterSource::AliHLTMUONClusterSource(AliMUONDataInterface* data)
38         : TObject(), fEventList(AliHLTMUONClusterSource::EventData::Class())
39 {
40         fAreaToUse = FromWholePlane;
41         fDataToUse = FromRawClusters;
42         fMaxBlockSize = 0xFFFFFFFF;
43         fFilename = "";
44         fFoldername = "";
45         ResetAllPointers();
46         FillFrom(data);
47 }
48
49
50 AliHLTMUONClusterSource::~AliHLTMUONClusterSource()
51 {
52         fEventList.Clear("C");
53 }
54
55
56 void AliHLTMUONClusterSource::FillFrom(AliMUONDataInterface* data)
57 {
58         DebugMsg(1, "FillFrom(AliMUONDataInterface*)");
59         
60         if (FileAndFolderOk(data))
61         {
62                 for (Int_t i = 0; i < data->NumberOfEvents(); i++)
63                 {
64                         AddEventFrom(data, i);
65                 }
66         }
67 }
68
69
70 void AliHLTMUONClusterSource::FillFrom(AliMUONDataInterface* data, Int_t event)
71 {
72         DebugMsg(1, "FillFrom(AliMUONDataInterface*, Int_t)");
73         
74         if (FileAndFolderOk(data))
75                 AddEventFrom(data, event);
76 }
77
78
79 void AliHLTMUONClusterSource::FillFrom(AliMUONDataInterface* data, Int_t event, Int_t chamber)
80 {
81         DebugMsg(1, "FillFrom(AliMUONDataInterface*, Int_t)");
82         
83         if (FileAndFolderOk(data))
84         {
85                 if ( data->GetEvent(event) )
86                 {
87                         AddEvent(event);
88                         AddChamberFrom(data, chamber);
89                 }
90         }
91 }
92
93
94 void AliHLTMUONClusterSource::FillFrom(
95                 AliMUONDataInterface* data,
96                 Int_t event, Int_t chamber, Int_t cluster,
97                 Bool_t newblock
98         )
99 {
100         DebugMsg(1, "FillFrom(AliMUONDataInterface*, Int_t, Int_t, Int_t, Bool_t)");
101         
102         if (FileAndFolderOk(data))
103         {
104                 data->GetEvent(event);
105
106                 // Check if the current event corresponds to the event number we are
107                 // attempting to add to. If they do not or no event is selected then
108                 // try find the event or create a new one.
109                 if ( fCurrentEvent == NULL )
110                 {
111                         Bool_t found = GetEvent(event);
112                         if ( ! found) AddEvent(event);
113                 }
114                 else
115                 {
116                         if (fCurrentEvent->fEventNumber != event)
117                         {
118                                 Bool_t found = GetEvent(event);
119                                 if ( ! found) AddEvent(event);
120                         }
121                 }
122                 
123                 if ( fCurrentBlock != 0)
124                 {
125                         Assert( fCurrentEvent != NULL );
126                         
127                         if ( fCurrentBlock->fChamber != chamber)
128                         {
129                                 // Create a new block if the current blocks chamber number does
130                                 // not correspond to the specified chamber.
131                                 AddBlock(chamber);
132                         }
133                         else
134                         {
135                                 // If the newblock flag is set then force a new block.
136                                 if (newblock) AddBlock(chamber);
137                         }
138                 }
139                 else
140                         AddBlock(chamber);  // No block selected so we need to create a new block.
141
142                 AddClusterFrom(data, chamber, cluster);
143         }
144 }
145
146
147 void AliHLTMUONClusterSource::Clear(Option_t* /*option*/)
148 {
149         fFilename = "";
150         fFoldername = "";
151         ResetAllPointers();
152         fEventList.Delete();
153 }
154
155
156 Bool_t AliHLTMUONClusterSource::GetEvent(Int_t eventnumber) const
157 {
158         DebugMsg(1, "AliHLTMUONClusterSource::GetEvent(" << eventnumber << ")" );
159         
160         // Try find the corresponding event in the list of events.
161         for (Int_t i = 0; i < fEventList.GetEntriesFast(); i++)
162         {
163                 EventData* current = (EventData*) fEventList[i];
164                 if (current->fEventNumber == eventnumber)
165                 {
166                         fEventIndex = i;
167                         fCurrentEvent = current;
168                         GetFirstBlock();
169                         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
170                                 << " , fClusterIndex = " << fClusterIndex
171                         );
172                         return kTRUE;
173                 }
174         }
175         return kFALSE;
176 }
177
178
179 Bool_t AliHLTMUONClusterSource::GetFirstEvent() const
180 {
181         DebugMsg(1, "AliHLTMUONClusterSource::GetFirstEvent()");
182         if (fEventList.GetEntriesFast() > 0)
183         {
184                 fEventIndex = 0;
185                 fCurrentEvent = (EventData*) fEventList[0];
186                 GetFirstBlock();
187                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
188                         << " , fClusterIndex = " << fClusterIndex
189                 );
190                 return kTRUE;
191         }
192         else
193         {
194                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
195                         << " , fClusterIndex = " << fClusterIndex
196                 );
197                 return kFALSE;
198         }
199 }
200
201
202 Bool_t AliHLTMUONClusterSource::MoreEvents() const
203 {
204         return 0 <= fEventIndex && fEventIndex < fEventList.GetEntriesFast();
205 }
206
207
208 Bool_t AliHLTMUONClusterSource::GetNextEvent() const
209 {
210         DebugMsg(1, "AliHLTMUONClusterSource::GetNextEvent()");
211         if (fEventIndex < fEventList.GetEntriesFast() - 1)
212         {
213                 fCurrentEvent = (EventData*) fEventList[ ++fEventIndex ];
214                 GetFirstBlock();
215                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
216                         << " , fClusterIndex = " << fClusterIndex
217                 );
218                 return kTRUE;
219         }
220         else
221         {
222                 ResetAllPointers();
223                 return kFALSE;
224         }
225 }
226
227
228 Int_t AliHLTMUONClusterSource::CurrentEvent() const
229 {
230         if (fCurrentEvent != NULL)
231                 return fCurrentEvent->fEventNumber;
232         else
233                 return -1;
234 }
235
236
237 Int_t AliHLTMUONClusterSource::NumberOfBlocks() const
238 {
239         DebugMsg(1, "AliHLTMUONClusterSource::NumberOfBlocks()");
240         if (fCurrentEvent == NULL)
241         {
242                 Error("NumberOfBlocks", "No event selected.");
243                 return -1;
244         }
245         else
246                 return fCurrentEvent->fBlocks.GetEntriesFast();
247 }
248
249
250 Bool_t AliHLTMUONClusterSource::GetBlock(Int_t index) const
251 {
252         DebugMsg(1, "AliHLTMUONClusterSource::GetBlock(" << index << ")");
253         
254         // Note NumberOfBlocks() also checks if the event was selected.
255         Int_t numberofblocks = NumberOfBlocks();
256         if (numberofblocks < 0) return kFALSE;
257
258         if ( 0 <= index && index < numberofblocks )
259         {
260                 fBlockIndex = index;
261                 fCurrentBlock = (BlockData*) fCurrentEvent->fBlocks[index];
262                 GetFirstCluster();
263                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
264                         << " , fClusterIndex = " << fClusterIndex
265                 );
266                 return kTRUE;
267         }
268         else
269         {
270                 // The index is out of bounds so inform the user.
271                 if (numberofblocks > 0)
272                         Error(  "GetBlock",
273                                 "The block index (%d) is out of bounds. Valid range is [0, %d]",
274                                 index, numberofblocks - 1
275                         );
276                 else
277                         Error(  "GetBlock",
278                                 "The block index (%d) is out of bounds. No blocks found.",
279                                 index
280                         );
281                 return kFALSE;
282         }
283 }
284
285
286 Bool_t AliHLTMUONClusterSource::GetFirstBlock() const
287 {
288         DebugMsg(1, "AliHLTMUONClusterSource::GetFirstBlock()");
289         // Note: NumberOfBlocks() also checks if fCurrentEvent != NULL.
290         if (NumberOfBlocks() > 0)
291         {
292                 fBlockIndex = 0;
293                 fCurrentBlock = (BlockData*) fCurrentEvent->fBlocks[fBlockIndex];
294                 GetFirstCluster();
295                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
296                         << " , fClusterIndex = " << fClusterIndex
297                 );
298                 return kTRUE;
299         }
300         else
301                 return kFALSE;
302 }
303
304
305 Bool_t AliHLTMUONClusterSource::MoreBlocks() const
306 {
307         return 0 <= fBlockIndex && fBlockIndex < NumberOfBlocks();
308 }
309
310
311 Bool_t AliHLTMUONClusterSource::GetNextBlock() const
312 {
313         DebugMsg(1, "AliHLTMUONClusterSource::GetNextBlock()");
314
315         // Note: NumberOfBlocks() checks if fCurrentEvent != NULL. If it is then it returns -1
316         // and since fBlockIndex is always >= -1 the if statement must go to the else part.
317         if (fBlockIndex < NumberOfBlocks() - 1)
318         {
319                 fCurrentBlock = (BlockData*) fCurrentEvent->fBlocks[ ++fBlockIndex ];
320                 GetFirstCluster();
321                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
322                         << " , fClusterIndex = " << fClusterIndex
323                 );
324                 return kTRUE;
325         }
326         else
327         {
328                 ResetBlockPointers();
329                 return kFALSE;
330         }
331 }
332
333
334 Int_t AliHLTMUONClusterSource::Chamber() const
335 {
336         if (fCurrentBlock == NULL)
337         {
338                 Error("Chamber", "No block selected.");
339                 return -1;
340         }
341         else
342                 return fCurrentBlock->fChamber;
343 }
344
345
346 Int_t AliHLTMUONClusterSource::NumberOfClusters() const
347 {
348         DebugMsg(1, "AliHLTMUONClusterSource::NumberOfClusters()");
349         if (fCurrentBlock == NULL)
350         {
351                 Error("NumberOfClusters", "No block selected.");
352                 return -1;
353         }
354         else
355                 return fCurrentBlock->fClusters.GetEntriesFast();
356 }
357
358
359 const AliHLTMUONPoint* AliHLTMUONClusterSource::GetCluster(Int_t index) const
360 {
361         DebugMsg(1, "AliHLTMUONClusterSource::GetCluster(" << index << ")");
362
363         // Note NumberOfClusters() also checks if the event and block was selected.
364         Int_t numberofclusters = NumberOfClusters();
365         if (numberofclusters < 0) return NULL;
366         
367         if ( 0 <= index && index < numberofclusters )
368         {
369                 fClusterIndex = index;
370                 fCurrentCluster = (AliHLTMUONPoint*) fCurrentBlock->fClusters[index];
371                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
372                         << " , fClusterIndex = " << fClusterIndex
373                 );
374                 return fCurrentCluster;
375         }
376         else
377         {
378                 // The index is out of bounds so inform the user.
379                 if (numberofclusters > 0)
380                         Error(  "GetCluster",
381                                 "The cluster index (%d) is out of bounds. Valid range is [0, %d]",
382                                 index, numberofclusters - 1
383                         );
384                 else
385                         Error(  "GetCluster",
386                                 "The cluster index (%d) is out of bounds. No clusters found.",
387                                 index
388                         );
389                 return NULL;
390         }
391 }
392
393
394 const AliHLTMUONPoint* AliHLTMUONClusterSource::GetFirstCluster() const
395 {
396         DebugMsg(1, "AliHLTMUONClusterSource::GetFirstCluster()");
397         // Note: NumberOfClusters() also checks if fCurrentBlock != NULL.
398         if (NumberOfClusters() > 0)
399         {
400                 fClusterIndex = 0;
401                 fCurrentCluster = (AliHLTMUONPoint*) fCurrentBlock->fClusters[0];
402                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
403                         << " , fClusterIndex = " << fClusterIndex
404                 );
405                 return fCurrentCluster;
406         }
407         else
408                 return NULL;
409 }
410
411
412 Bool_t AliHLTMUONClusterSource::MoreClusters() const
413 {
414         return 0 <= fClusterIndex && fClusterIndex < NumberOfClusters();
415 }
416
417
418 const AliHLTMUONPoint* AliHLTMUONClusterSource::GetNextCluster() const
419 {
420         DebugMsg(1, "AliHLTMUONClusterSource::GetNextCluster()");
421         
422         // Note: NumberOfClusters() checks if fCurrentBlock != NULL. If it is then it returns -1
423         // and since fClusterIndex is always >= -1 the if statement must go to the else part.
424         if (fClusterIndex < NumberOfClusters() - 1)
425         {
426                 fCurrentCluster = (AliHLTMUONPoint*) fCurrentBlock->fClusters[ ++fClusterIndex ];
427                 DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
428                         << " , fClusterIndex = " << fClusterIndex
429                 );
430                 return fCurrentCluster;
431         }
432         else
433         {
434                 ResetClusterPointers();
435                 return NULL;
436         }
437 }
438
439
440 Bool_t AliHLTMUONClusterSource::FetchCluster(Float_t& x, Float_t& y) const
441 {
442         if (fCurrentCluster != NULL)
443         {
444                 x = fCurrentCluster->fX;
445                 y = fCurrentCluster->fY;
446                 return kTRUE;
447         }
448         else
449         {
450                 Error("FetchCluster", "No cluster point selected.");
451                 return kFALSE;
452         }
453 }
454
455
456 void AliHLTMUONClusterSource::AddEvent(Int_t eventnumber)
457 {
458         DebugMsg(1, "AliHLTMUONClusterSource::AddEvent(" << eventnumber << ")");
459         Assert( eventnumber >= 0 );
460
461         // Assume the eventnumber does not already exist in the event list.
462         fEventIndex = fEventList.GetEntriesFast();
463         new ( fEventList[fEventIndex] ) EventData(eventnumber);
464         fCurrentEvent = (EventData*) fEventList[fEventIndex];
465         
466         // Remember to reset the other pointers because the new event is empty.
467         ResetBlockPointers();
468         
469         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
470                 << " , fClusterIndex = " << fClusterIndex
471         );
472 }
473
474
475 void AliHLTMUONClusterSource::AddBlock(Int_t chamber)
476 {
477         DebugMsg(1, "AliHLTMUONClusterSource::AddBlock()");
478         
479         if (fCurrentEvent == NULL)
480         {
481                 Error("AddBlock", "No event selected.");
482                 return;
483         }
484         
485         fBlockIndex = fCurrentEvent->fBlocks.GetEntriesFast();
486         new ( fCurrentEvent->fBlocks[fBlockIndex] ) BlockData(chamber);
487         fCurrentBlock = (BlockData*) fCurrentEvent->fBlocks[fBlockIndex];
488         
489         // Remember to reset the trigger pointer because the new block is empty.
490         ResetClusterPointers();
491
492         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
493                 << " , fClusterIndex = " << fClusterIndex
494         );
495 }
496
497
498 void AliHLTMUONClusterSource::AddPoint(Float_t x, Float_t y)
499 {
500         DebugMsg(1, "AliHLTMUONClusterSource::AddPoint(" << x << ", " << y << ")");
501
502         if (fCurrentBlock == NULL)
503         {
504                 Error("AddPoint", "No block selected.");
505                 return;
506         }
507         
508         fClusterIndex = fCurrentBlock->fClusters.GetEntriesFast();
509         new ( fCurrentBlock->fClusters[fClusterIndex] ) AliHLTMUONPoint(x, y);
510         fCurrentCluster = (AliHLTMUONPoint*) fCurrentBlock->fClusters[fClusterIndex];
511         
512         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
513                 << " , fClusterIndex = " << fClusterIndex
514         );
515 }
516
517
518 Bool_t AliHLTMUONClusterSource::FileAndFolderOk(AliMUONDataInterface* data)
519 {
520         if (fFilename == "")
521         {
522                 // Nothing filled yet so set the file and folder names.
523                 fFilename = data->CurrentFile();
524                 fFoldername = data->CurrentFolder();
525                 return kTRUE;
526         }
527
528         if ( fFilename != data->CurrentFile() )
529         {
530                 Error(  "FileAndFolderOk",
531                         "The cluster source already contains data from file '%s', cannot add data from file '%s'",
532                         fFilename.Data(), data->CurrentFile().Data()
533                 );
534                 return kFALSE;
535         }
536         
537         if ( fFoldername != data->CurrentFolder() )
538         {
539                 Error(  "FileAndFolderOk",
540                         "The cluster source already contains data from folder '%s', cannot add data from folder '%s'",
541                         fFoldername.Data(), data->CurrentFolder().Data()
542                 );
543                 return kFALSE;
544         }
545         
546         return kTRUE;
547 }
548
549
550 void AliHLTMUONClusterSource::AddEventFrom(AliMUONDataInterface* data, Int_t event)
551 {
552         if ( data->GetEvent(event) )
553         {
554                 AddEvent(event);
555                 for (Int_t chamber = 0; chamber < AliMUONConstants::NTrackingCh(); chamber++)
556                 {
557                         AddChamberFrom(data, chamber);
558                 }
559         }
560 }
561
562
563 void AliHLTMUONClusterSource::AddChamberFrom(AliMUONDataInterface* data, Int_t chamber)
564 {
565         DebugMsg(1, "Entering AddChamberFrom");
566         
567         AddBlock(chamber);
568         UInt_t currentblocksize = 0;
569 #ifndef __alpha
570 #ifndef __sun
571         Float_t x = nanf(""), y = nanf("");
572 #else
573         Float_t x = 0, y = 0;
574 #endif
575 #else
576         Float_t x = FLT_QNAN, y = FLT_QNAN;
577 #endif
578         
579         switch (fDataToUse)
580         {
581         case FromHits:
582                 for (Int_t track = 0; track < data->NumberOfTracks(); track++)
583                 {
584                         // Find the hit that corresponds to the current chamber number.
585                         Int_t i;
586                         for (i = 0; i < data->NumberOfHits(track); i++)
587                         {
588                                 AliMUONHit* h = data->Hit(track, i);
589                                 // Note AliMUONHit::Chamber() returns a value in the range 1..14
590                                 if (h->Chamber() == chamber + 1)
591                                 {
592                                         x = h->X();
593                                         y = h->Y();
594                                         break;
595                                 }
596                         }
597
598                         // Continue to the next track if we could not find a hit
599                         // on the current track and chamber.
600                         if (i >= data->NumberOfHits(track))
601                         {
602                                 Warning("AddChamberFrom", "Could not find hit on chamber: %d , track: %d , event: %d", 
603                                         chamber, track, data->CurrentEvent()
604                                 );
605                                 continue;
606                         }
607
608                         if (InFillRegion(x, y))
609                         {
610                                 AddPoint(x, y);
611
612                                 // Create a new block if we reached the maximum block size.
613                                 if ( ++currentblocksize == fMaxBlockSize )
614                                 {
615                                         AddBlock(chamber);
616                                         currentblocksize = 0;
617                                 }
618                         }
619                 }
620                 break;
621
622         case FromRawClusters:
623                 for (Int_t i = 0; i < data->NumberOfRawClusters(chamber); i++)
624                 {
625                         AliMUONRawCluster* rc = data->RawCluster(chamber, i);
626                         x = rc->GetX(0);
627                         y = rc->GetY(0);
628
629                         if (InFillRegion(x, y))
630                         {
631                                 AddPoint(x, y);
632
633                                 // Create a new block if we reached the maximum block size.
634                                 if ( ++currentblocksize == fMaxBlockSize )
635                                 {
636                                         AddBlock(chamber);
637                                         currentblocksize = 0;
638                                 }
639                         }
640                 }
641                 break;
642
643         default:
644                 Error("AddChamberFrom", "fDataToUse is not set to a valid value.");
645         }
646         
647         DebugMsg(1, "Leaving AddChamberFrom");
648 }
649
650
651 void AliHLTMUONClusterSource::AddClusterFrom(
652                 AliMUONDataInterface* data, Int_t chamber, Int_t cluster
653         )
654 {
655         DebugMsg(1, "Entering AddClusterFrom");
656 #ifndef __alpha
657 #ifndef __sun   
658         Float_t x = nanf(""), y = nanf("");
659 #else
660         Float_t x = 0, y = 0;
661 #endif
662 #else
663         Float_t x = FLT_QNAN, y = FLT_QNAN;
664 #endif
665
666         switch (fDataToUse)
667         {
668         case FromHits:
669                 {
670                 Int_t i;
671                 // Note: cluster is now treated as the track number.
672                 for (i = 0; i < data->NumberOfHits(cluster); i++)
673                 {
674                         AliMUONHit* h = data->Hit(cluster, i);
675                         // Note AliMUONHit::Chamber() returns a value in the range 1..14
676                         if (h->Chamber() == chamber + 1)
677                         {
678                                 x = h->X();
679                                 y = h->Y();
680                                 break;
681                         }
682                 }
683
684                 if (i >= data->NumberOfHits(cluster))
685                 {
686                         // Could not find a hit on the specified chamber so just return.
687                         Warning("AddClusterFrom", "Could not find hit on chamber: %d , track: %d , event: %d", 
688                                 chamber, cluster, data->CurrentEvent()
689                         );
690                         DebugMsg(1, "Leaving AddClusterFrom");
691                         return;
692                 }
693                 }
694                 break;
695
696         case FromRawClusters:
697                 {
698                 AliMUONRawCluster* rc = data->RawCluster(chamber, cluster);
699                 x = rc->GetX(0);
700                 y = rc->GetY(0);
701                 }
702                 break;
703
704         default:
705                 Error("AddClusterFrom", "fDataToUse is not set to a valid value.");
706                 return;
707         }
708         
709         AddPoint(x, y);
710         
711         DebugMsg(1, "Leaving AddClusterFrom");
712 }
713
714
715 Bool_t AliHLTMUONClusterSource::InFillRegion(Float_t x, Float_t /*y*/)
716 {
717         switch (fAreaToUse)
718         {
719         case FromWholePlane:     return kTRUE;
720         case FromLeftHalfPlane:  return x <= 0;
721         case FromRightHalfPlane: return x > 0;
722
723         default:
724                 Error("InFillRegion", "fAreaToUse is not set to a valid value.");
725                 return kFALSE;
726         }
727 }
728
729
730 void AliHLTMUONClusterSource::ResetAllPointers() const
731 {
732         fEventIndex = -1;
733         fCurrentEvent = NULL;
734         fBlockIndex = -1;
735         fCurrentBlock = NULL;
736         fClusterIndex = -1;
737         fCurrentCluster = NULL;
738         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
739                 << " , fClusterIndex = " << fClusterIndex
740         );
741 }
742
743
744 void AliHLTMUONClusterSource::ResetBlockPointers() const
745 {
746         fBlockIndex = -1;
747         fCurrentBlock = NULL;
748         fClusterIndex = -1;
749         fCurrentCluster = NULL;
750         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
751                 << " , fClusterIndex = " << fClusterIndex
752         );
753 }
754
755
756 void AliHLTMUONClusterSource::ResetClusterPointers() const
757 {
758         fClusterIndex = -1;
759         fCurrentCluster = NULL;
760         DebugMsg(2, "\tfEventIndex = " << fEventIndex << " , fBlockIndex = " << fBlockIndex
761                 << " , fClusterIndex = " << fClusterIndex
762         );
763 }
764
765
766 AliHLTMUONClusterSource::BlockData::BlockData() : fClusters(AliHLTMUONPoint::Class())
767 {
768         fChamber = -1;
769 }
770
771 AliHLTMUONClusterSource::BlockData::BlockData(Int_t chamber) : fClusters(AliHLTMUONPoint::Class())
772 {
773         fChamber = chamber;
774 }
775
776 AliHLTMUONClusterSource::BlockData::~BlockData()
777 {
778         fClusters.Clear("C");
779 }
780
781 AliHLTMUONClusterSource::EventData::EventData() : fBlocks(AliHLTMUONClusterSource::BlockData::Class())
782 {
783         fEventNumber = -1;
784 }
785
786 AliHLTMUONClusterSource::EventData::EventData(Int_t eventnumber)
787         : fBlocks(AliHLTMUONClusterSource::BlockData::Class())
788 {
789         fEventNumber = eventnumber;
790
791         // If the following is not set then we do not write the fBlocks properly.
792         fBlocks.BypassStreamer(kFALSE);
793 }
794
795 AliHLTMUONClusterSource::EventData::~EventData()
796 {
797         fBlocks.Clear("C");
798 }
799