ROOT logo
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

// $Id$

/// \class AliMUONLegacyClusterServer
///
/// Special implementation of AliMUONVClusterServer, which will only return 
/// clusters from a pre-defined cluster store.
///
/// Made to recover the old (i.e. before introduction of VClusterServer) behavior
/// of the MUON recontruction where rec points were always written to TreeR, 
/// and then the tracking picked them from that tree, in order to have the
/// possibility to save full rec points (for debugging the spectro, mainly, should
/// not be an option used during final production).
///
/// \author Laurent Aphecetche, Subatech
///

#include "AliMUONLegacyClusterServer.h"

#include "AliCodeTimer.h"
#include "AliLog.h"
#include "AliMUONGeometryTransformer.h"
#include "AliMUONTriggerTrackToTrackerClusters.h"
#include "AliMUONVCluster.h"
#include "AliMUONVClusterStore.h"
#include "AliMUONRecoParam.h"
#include "AliMpArea.h"
#include <TCollection.h>

/// \cond CLASSIMP
ClassImp(AliMUONLegacyClusterServer)
/// \endcond

//_____________________________________________________________________________
AliMUONLegacyClusterServer::AliMUONLegacyClusterServer(const AliMUONGeometryTransformer& transformer, 
																											 AliMUONVClusterStore* store,
																											 Bool_t bypassSt4, Bool_t bypassSt5)
: AliMUONVClusterServer(), fkTransformer(transformer), fClusterStore(store), fTriggerTrackStore(0x0),
fBypass(0x0),
fBypassSt4(bypassSt4),
fBypassSt5(bypassSt5)
{
  /// ctor. Mode Read : we'll only server clusters from existing store
}

//_____________________________________________________________________________
AliMUONLegacyClusterServer::~AliMUONLegacyClusterServer()
{
  /// dtor
  delete fBypass;
}

//_____________________________________________________________________________
Int_t 
AliMUONLegacyClusterServer::Clusterize(Int_t chamberId, 
                                       AliMUONVClusterStore& clusterStore,
                                       const AliMpArea& /*area*/,
                                       const AliMUONRecoParam* /*recoParam*/)
{
  /// Fills clusterStore with clusters in given chamber
  ///
  /// Return the number of clusters added to clusterStore
  
  AliCodeTimerAuto(Form("Chamber %d",chamberId),0);

  if ( fBypassSt4 && ( chamberId == 6 || chamberId == 7 ) ) 
  {
    return fBypass->GenerateClusters(chamberId,clusterStore);
  }

	if ( fBypassSt5 && ( chamberId == 8 || chamberId == 9 ) ) 
  {
    return fBypass->GenerateClusters(chamberId,clusterStore);
  }
	
  AliDebug(1,Form("chamberId=%d fClusterStore(%p).GetSize()=%d clusterStore(%p).GetSize()=%d",
                  chamberId,
                  fClusterStore,fClusterStore->GetSize(),
                  &clusterStore,clusterStore.GetSize()));
  
  TIter next(fClusterStore->CreateChamberIterator(chamberId,chamberId));
  AliMUONVCluster* cluster;
  Int_t n(0);
  TObjArray a;
  
  while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
  {
    clusterStore.Add(*cluster);
    a.Add(cluster);
    ++n;
  }
  
  TIter remove(&a);
  while ( ( cluster = static_cast<AliMUONVCluster*>(remove()) ) )
  {
    fClusterStore->Remove(*cluster);
  }
  
  AliDebug(1,Form("n=%d remaining clusters=%d",n,fClusterStore->GetSize()));
  
  return n;
}

//_____________________________________________________________________________
Bool_t 
AliMUONLegacyClusterServer::UseTriggerTrackStore(AliMUONVTriggerTrackStore* trackStore)
{
  /// Tells us to use trigger track store, and thus to bypass St4 and/or 5 clusters
  fTriggerTrackStore = trackStore; // not owner
  delete fBypass;
  fBypass = new AliMUONTriggerTrackToTrackerClusters(fkTransformer,fTriggerTrackStore);
  return kTRUE;
}

//_____________________________________________________________________________
void
AliMUONLegacyClusterServer::UseDigits(TIter&, AliMUONVDigitStore*)
{
  /// Give the iterator to our delegate if we have one, of issue and error
  
  AliError("Not implemented for this class, as we're not writing clusters, but reading them instead !");
}

 AliMUONLegacyClusterServer.cxx:1
 AliMUONLegacyClusterServer.cxx:2
 AliMUONLegacyClusterServer.cxx:3
 AliMUONLegacyClusterServer.cxx:4
 AliMUONLegacyClusterServer.cxx:5
 AliMUONLegacyClusterServer.cxx:6
 AliMUONLegacyClusterServer.cxx:7
 AliMUONLegacyClusterServer.cxx:8
 AliMUONLegacyClusterServer.cxx:9
 AliMUONLegacyClusterServer.cxx:10
 AliMUONLegacyClusterServer.cxx:11
 AliMUONLegacyClusterServer.cxx:12
 AliMUONLegacyClusterServer.cxx:13
 AliMUONLegacyClusterServer.cxx:14
 AliMUONLegacyClusterServer.cxx:15
 AliMUONLegacyClusterServer.cxx:16
 AliMUONLegacyClusterServer.cxx:17
 AliMUONLegacyClusterServer.cxx:18
 AliMUONLegacyClusterServer.cxx:19
 AliMUONLegacyClusterServer.cxx:20
 AliMUONLegacyClusterServer.cxx:21
 AliMUONLegacyClusterServer.cxx:22
 AliMUONLegacyClusterServer.cxx:23
 AliMUONLegacyClusterServer.cxx:24
 AliMUONLegacyClusterServer.cxx:25
 AliMUONLegacyClusterServer.cxx:26
 AliMUONLegacyClusterServer.cxx:27
 AliMUONLegacyClusterServer.cxx:28
 AliMUONLegacyClusterServer.cxx:29
 AliMUONLegacyClusterServer.cxx:30
 AliMUONLegacyClusterServer.cxx:31
 AliMUONLegacyClusterServer.cxx:32
 AliMUONLegacyClusterServer.cxx:33
 AliMUONLegacyClusterServer.cxx:34
 AliMUONLegacyClusterServer.cxx:35
 AliMUONLegacyClusterServer.cxx:36
 AliMUONLegacyClusterServer.cxx:37
 AliMUONLegacyClusterServer.cxx:38
 AliMUONLegacyClusterServer.cxx:39
 AliMUONLegacyClusterServer.cxx:40
 AliMUONLegacyClusterServer.cxx:41
 AliMUONLegacyClusterServer.cxx:42
 AliMUONLegacyClusterServer.cxx:43
 AliMUONLegacyClusterServer.cxx:44
 AliMUONLegacyClusterServer.cxx:45
 AliMUONLegacyClusterServer.cxx:46
 AliMUONLegacyClusterServer.cxx:47
 AliMUONLegacyClusterServer.cxx:48
 AliMUONLegacyClusterServer.cxx:49
 AliMUONLegacyClusterServer.cxx:50
 AliMUONLegacyClusterServer.cxx:51
 AliMUONLegacyClusterServer.cxx:52
 AliMUONLegacyClusterServer.cxx:53
 AliMUONLegacyClusterServer.cxx:54
 AliMUONLegacyClusterServer.cxx:55
 AliMUONLegacyClusterServer.cxx:56
 AliMUONLegacyClusterServer.cxx:57
 AliMUONLegacyClusterServer.cxx:58
 AliMUONLegacyClusterServer.cxx:59
 AliMUONLegacyClusterServer.cxx:60
 AliMUONLegacyClusterServer.cxx:61
 AliMUONLegacyClusterServer.cxx:62
 AliMUONLegacyClusterServer.cxx:63
 AliMUONLegacyClusterServer.cxx:64
 AliMUONLegacyClusterServer.cxx:65
 AliMUONLegacyClusterServer.cxx:66
 AliMUONLegacyClusterServer.cxx:67
 AliMUONLegacyClusterServer.cxx:68
 AliMUONLegacyClusterServer.cxx:69
 AliMUONLegacyClusterServer.cxx:70
 AliMUONLegacyClusterServer.cxx:71
 AliMUONLegacyClusterServer.cxx:72
 AliMUONLegacyClusterServer.cxx:73
 AliMUONLegacyClusterServer.cxx:74
 AliMUONLegacyClusterServer.cxx:75
 AliMUONLegacyClusterServer.cxx:76
 AliMUONLegacyClusterServer.cxx:77
 AliMUONLegacyClusterServer.cxx:78
 AliMUONLegacyClusterServer.cxx:79
 AliMUONLegacyClusterServer.cxx:80
 AliMUONLegacyClusterServer.cxx:81
 AliMUONLegacyClusterServer.cxx:82
 AliMUONLegacyClusterServer.cxx:83
 AliMUONLegacyClusterServer.cxx:84
 AliMUONLegacyClusterServer.cxx:85
 AliMUONLegacyClusterServer.cxx:86
 AliMUONLegacyClusterServer.cxx:87
 AliMUONLegacyClusterServer.cxx:88
 AliMUONLegacyClusterServer.cxx:89
 AliMUONLegacyClusterServer.cxx:90
 AliMUONLegacyClusterServer.cxx:91
 AliMUONLegacyClusterServer.cxx:92
 AliMUONLegacyClusterServer.cxx:93
 AliMUONLegacyClusterServer.cxx:94
 AliMUONLegacyClusterServer.cxx:95
 AliMUONLegacyClusterServer.cxx:96
 AliMUONLegacyClusterServer.cxx:97
 AliMUONLegacyClusterServer.cxx:98
 AliMUONLegacyClusterServer.cxx:99
 AliMUONLegacyClusterServer.cxx:100
 AliMUONLegacyClusterServer.cxx:101
 AliMUONLegacyClusterServer.cxx:102
 AliMUONLegacyClusterServer.cxx:103
 AliMUONLegacyClusterServer.cxx:104
 AliMUONLegacyClusterServer.cxx:105
 AliMUONLegacyClusterServer.cxx:106
 AliMUONLegacyClusterServer.cxx:107
 AliMUONLegacyClusterServer.cxx:108
 AliMUONLegacyClusterServer.cxx:109
 AliMUONLegacyClusterServer.cxx:110
 AliMUONLegacyClusterServer.cxx:111
 AliMUONLegacyClusterServer.cxx:112
 AliMUONLegacyClusterServer.cxx:113
 AliMUONLegacyClusterServer.cxx:114
 AliMUONLegacyClusterServer.cxx:115
 AliMUONLegacyClusterServer.cxx:116
 AliMUONLegacyClusterServer.cxx:117
 AliMUONLegacyClusterServer.cxx:118
 AliMUONLegacyClusterServer.cxx:119
 AliMUONLegacyClusterServer.cxx:120
 AliMUONLegacyClusterServer.cxx:121
 AliMUONLegacyClusterServer.cxx:122
 AliMUONLegacyClusterServer.cxx:123
 AliMUONLegacyClusterServer.cxx:124
 AliMUONLegacyClusterServer.cxx:125
 AliMUONLegacyClusterServer.cxx:126
 AliMUONLegacyClusterServer.cxx:127
 AliMUONLegacyClusterServer.cxx:128
 AliMUONLegacyClusterServer.cxx:129
 AliMUONLegacyClusterServer.cxx:130
 AliMUONLegacyClusterServer.cxx:131
 AliMUONLegacyClusterServer.cxx:132
 AliMUONLegacyClusterServer.cxx:133
 AliMUONLegacyClusterServer.cxx:134
 AliMUONLegacyClusterServer.cxx:135
 AliMUONLegacyClusterServer.cxx:136
 AliMUONLegacyClusterServer.cxx:137