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 AliMUONGeometryModule
// -----------------------------
// Class for definition of the detector module parameters
// (the transformations of detection elements, mapping between
//  sensitive volumes and detection elements).
//
// Author: Ivana Hrivnacova, IPN Orsay
//-----------------------------------------------------------------------------

#include "AliMUONGeometryModule.h"
#include "AliMUONGeometryModuleTransformer.h"
#include "AliMUONGeometryEnvelope.h"
#include "AliMUONGeometryEnvelopeStore.h"
#include "AliMUONGeometryDetElement.h"	
#include "AliMUONStringIntMap.h"	

#include "AliLog.h"	

#include <TVirtualMC.h>
#include <TGeoMatrix.h>
#include <TObjArray.h>
#include <TArrayI.h>
#include <Riostream.h>

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

//______________________________________________________________________________
AliMUONGeometryModule::AliMUONGeometryModule(Int_t moduleId)
 : TObject(),
   fIsVirtual(true),
   fNofSVs(0),
   fSVVolumeIds(0),
   fEnvelopes(0),
   fSVMap(0),
   fTransformer(0)
{
/// Standard constructor

  // Arrays of volumes Ids
  fSVVolumeIds = new TArrayI(20);

  // Sensitive volumes map
  fSVMap = new AliMUONStringIntMap();

  // Geometry parametrisation
  fTransformer = new AliMUONGeometryModuleTransformer(moduleId);
    
  // Envelope store
  fEnvelopes = new AliMUONGeometryEnvelopeStore(
                             fTransformer->GetDetElementStore());  
}


//______________________________________________________________________________
AliMUONGeometryModule::AliMUONGeometryModule()
 : TObject(),
   fIsVirtual(true),
   fNofSVs(0),
   fSVVolumeIds(0),
   fEnvelopes(0),
   fSVMap(0),
   fTransformer(0)
{
/// Default constructor
}

//______________________________________________________________________________
AliMUONGeometryModule::~AliMUONGeometryModule() 
{
/// Destructor

  delete fSVVolumeIds;
  delete fEnvelopes;
  delete fSVMap;
  delete fTransformer;
}

//
// private methods
//

//______________________________________________________________________________
Int_t AliMUONGeometryModule::GetSVIndex(Int_t svVolId) const
{
/// Return the index of the volume specified by volId
/// if it is present in the list of sensitive volumes 
/// (or -1 if not present).
 
  for (Int_t i=0; i<fNofSVs; i++) {
      if (fSVVolumeIds->At(i) == svVolId) return i;
  }
  return -1;
}

//
// public methods
//

//______________________________________________________________________________
void  AliMUONGeometryModule::SetTransformation(const TGeoCombiTrans& transform)
{
/// Set the module position wrt world.

  fTransformer->SetTransformation(transform);
}  

//______________________________________________________________________________
void AliMUONGeometryModule::SetVolumePath(const TString& volumePath)
{ 
/// Set the volume path to transformer

  fTransformer->SetVolumePath(volumePath);
}

//______________________________________________________________________________
void  AliMUONGeometryModule::SetSensitiveVolume(Int_t svVolId)
{
/// Add the volume specified by volId to the list of sensitive
/// volumes
  
  // Resize TArrayI if needed
  if (fSVVolumeIds->GetSize() == fNofSVs) fSVVolumeIds->Set(2*fNofSVs);

  fSVVolumeIds->AddAt(svVolId, fNofSVs++);
}      

//______________________________________________________________________________
void  AliMUONGeometryModule::SetSensitiveVolume(const TString& volName)
{
/// Add the volume specified by volName to the list of sensitive
/// volumes

  SetSensitiveVolume(TVirtualMC::GetMC()->VolId(volName));
}      

//______________________________________________________________________________
void  AliMUONGeometryModule::SetAlign(Bool_t align)
{
/// Set alignement option to envelope store.
  
  fEnvelopes->SetAlign(align);
}  

//______________________________________________________________________________
AliMUONGeometryDetElement* 
AliMUONGeometryModule::FindBySensitiveVolume(const TString& sensVolume) const
{
/// Find detection element which the sensitive volume specified by name belongs to

  Int_t detElemId = fSVMap->Get(sensVolume);

  if (!detElemId) return 0; 
        // The specified sensitive volume is not in the map   
  
  return fTransformer->GetDetElement(detElemId);
}  

//______________________________________________________________________________
Bool_t AliMUONGeometryModule::IsSensitiveVolume(Int_t volId) const
{
/// Check if the volume specified by volId is present in the list
/// of sensitive volumes.

  for (Int_t i=0; i<fNofSVs; i++) {
      if (fSVVolumeIds->At(i) == volId) return kTRUE;
  }
  return kFALSE;
}

//______________________________________________________________________________
Bool_t AliMUONGeometryModule::IsSensitiveVolume(const TString& volName) const
{
/// Check if the volume specified by volName  is present in the list
/// of sensitive volumes.

  return IsSensitiveVolume(TVirtualMC::GetMC()->VolId(volName));
}
 AliMUONGeometryModule.cxx:1
 AliMUONGeometryModule.cxx:2
 AliMUONGeometryModule.cxx:3
 AliMUONGeometryModule.cxx:4
 AliMUONGeometryModule.cxx:5
 AliMUONGeometryModule.cxx:6
 AliMUONGeometryModule.cxx:7
 AliMUONGeometryModule.cxx:8
 AliMUONGeometryModule.cxx:9
 AliMUONGeometryModule.cxx:10
 AliMUONGeometryModule.cxx:11
 AliMUONGeometryModule.cxx:12
 AliMUONGeometryModule.cxx:13
 AliMUONGeometryModule.cxx:14
 AliMUONGeometryModule.cxx:15
 AliMUONGeometryModule.cxx:16
 AliMUONGeometryModule.cxx:17
 AliMUONGeometryModule.cxx:18
 AliMUONGeometryModule.cxx:19
 AliMUONGeometryModule.cxx:20
 AliMUONGeometryModule.cxx:21
 AliMUONGeometryModule.cxx:22
 AliMUONGeometryModule.cxx:23
 AliMUONGeometryModule.cxx:24
 AliMUONGeometryModule.cxx:25
 AliMUONGeometryModule.cxx:26
 AliMUONGeometryModule.cxx:27
 AliMUONGeometryModule.cxx:28
 AliMUONGeometryModule.cxx:29
 AliMUONGeometryModule.cxx:30
 AliMUONGeometryModule.cxx:31
 AliMUONGeometryModule.cxx:32
 AliMUONGeometryModule.cxx:33
 AliMUONGeometryModule.cxx:34
 AliMUONGeometryModule.cxx:35
 AliMUONGeometryModule.cxx:36
 AliMUONGeometryModule.cxx:37
 AliMUONGeometryModule.cxx:38
 AliMUONGeometryModule.cxx:39
 AliMUONGeometryModule.cxx:40
 AliMUONGeometryModule.cxx:41
 AliMUONGeometryModule.cxx:42
 AliMUONGeometryModule.cxx:43
 AliMUONGeometryModule.cxx:44
 AliMUONGeometryModule.cxx:45
 AliMUONGeometryModule.cxx:46
 AliMUONGeometryModule.cxx:47
 AliMUONGeometryModule.cxx:48
 AliMUONGeometryModule.cxx:49
 AliMUONGeometryModule.cxx:50
 AliMUONGeometryModule.cxx:51
 AliMUONGeometryModule.cxx:52
 AliMUONGeometryModule.cxx:53
 AliMUONGeometryModule.cxx:54
 AliMUONGeometryModule.cxx:55
 AliMUONGeometryModule.cxx:56
 AliMUONGeometryModule.cxx:57
 AliMUONGeometryModule.cxx:58
 AliMUONGeometryModule.cxx:59
 AliMUONGeometryModule.cxx:60
 AliMUONGeometryModule.cxx:61
 AliMUONGeometryModule.cxx:62
 AliMUONGeometryModule.cxx:63
 AliMUONGeometryModule.cxx:64
 AliMUONGeometryModule.cxx:65
 AliMUONGeometryModule.cxx:66
 AliMUONGeometryModule.cxx:67
 AliMUONGeometryModule.cxx:68
 AliMUONGeometryModule.cxx:69
 AliMUONGeometryModule.cxx:70
 AliMUONGeometryModule.cxx:71
 AliMUONGeometryModule.cxx:72
 AliMUONGeometryModule.cxx:73
 AliMUONGeometryModule.cxx:74
 AliMUONGeometryModule.cxx:75
 AliMUONGeometryModule.cxx:76
 AliMUONGeometryModule.cxx:77
 AliMUONGeometryModule.cxx:78
 AliMUONGeometryModule.cxx:79
 AliMUONGeometryModule.cxx:80
 AliMUONGeometryModule.cxx:81
 AliMUONGeometryModule.cxx:82
 AliMUONGeometryModule.cxx:83
 AliMUONGeometryModule.cxx:84
 AliMUONGeometryModule.cxx:85
 AliMUONGeometryModule.cxx:86
 AliMUONGeometryModule.cxx:87
 AliMUONGeometryModule.cxx:88
 AliMUONGeometryModule.cxx:89
 AliMUONGeometryModule.cxx:90
 AliMUONGeometryModule.cxx:91
 AliMUONGeometryModule.cxx:92
 AliMUONGeometryModule.cxx:93
 AliMUONGeometryModule.cxx:94
 AliMUONGeometryModule.cxx:95
 AliMUONGeometryModule.cxx:96
 AliMUONGeometryModule.cxx:97
 AliMUONGeometryModule.cxx:98
 AliMUONGeometryModule.cxx:99
 AliMUONGeometryModule.cxx:100
 AliMUONGeometryModule.cxx:101
 AliMUONGeometryModule.cxx:102
 AliMUONGeometryModule.cxx:103
 AliMUONGeometryModule.cxx:104
 AliMUONGeometryModule.cxx:105
 AliMUONGeometryModule.cxx:106
 AliMUONGeometryModule.cxx:107
 AliMUONGeometryModule.cxx:108
 AliMUONGeometryModule.cxx:109
 AliMUONGeometryModule.cxx:110
 AliMUONGeometryModule.cxx:111
 AliMUONGeometryModule.cxx:112
 AliMUONGeometryModule.cxx:113
 AliMUONGeometryModule.cxx:114
 AliMUONGeometryModule.cxx:115
 AliMUONGeometryModule.cxx:116
 AliMUONGeometryModule.cxx:117
 AliMUONGeometryModule.cxx:118
 AliMUONGeometryModule.cxx:119
 AliMUONGeometryModule.cxx:120
 AliMUONGeometryModule.cxx:121
 AliMUONGeometryModule.cxx:122
 AliMUONGeometryModule.cxx:123
 AliMUONGeometryModule.cxx:124
 AliMUONGeometryModule.cxx:125
 AliMUONGeometryModule.cxx:126
 AliMUONGeometryModule.cxx:127
 AliMUONGeometryModule.cxx:128
 AliMUONGeometryModule.cxx:129
 AliMUONGeometryModule.cxx:130
 AliMUONGeometryModule.cxx:131
 AliMUONGeometryModule.cxx:132
 AliMUONGeometryModule.cxx:133
 AliMUONGeometryModule.cxx:134
 AliMUONGeometryModule.cxx:135
 AliMUONGeometryModule.cxx:136
 AliMUONGeometryModule.cxx:137
 AliMUONGeometryModule.cxx:138
 AliMUONGeometryModule.cxx:139
 AliMUONGeometryModule.cxx:140
 AliMUONGeometryModule.cxx:141
 AliMUONGeometryModule.cxx:142
 AliMUONGeometryModule.cxx:143
 AliMUONGeometryModule.cxx:144
 AliMUONGeometryModule.cxx:145
 AliMUONGeometryModule.cxx:146
 AliMUONGeometryModule.cxx:147
 AliMUONGeometryModule.cxx:148
 AliMUONGeometryModule.cxx:149
 AliMUONGeometryModule.cxx:150
 AliMUONGeometryModule.cxx:151
 AliMUONGeometryModule.cxx:152
 AliMUONGeometryModule.cxx:153
 AliMUONGeometryModule.cxx:154
 AliMUONGeometryModule.cxx:155
 AliMUONGeometryModule.cxx:156
 AliMUONGeometryModule.cxx:157
 AliMUONGeometryModule.cxx:158
 AliMUONGeometryModule.cxx:159
 AliMUONGeometryModule.cxx:160
 AliMUONGeometryModule.cxx:161
 AliMUONGeometryModule.cxx:162
 AliMUONGeometryModule.cxx:163
 AliMUONGeometryModule.cxx:164
 AliMUONGeometryModule.cxx:165
 AliMUONGeometryModule.cxx:166
 AliMUONGeometryModule.cxx:167
 AliMUONGeometryModule.cxx:168
 AliMUONGeometryModule.cxx:169
 AliMUONGeometryModule.cxx:170
 AliMUONGeometryModule.cxx:171
 AliMUONGeometryModule.cxx:172
 AliMUONGeometryModule.cxx:173
 AliMUONGeometryModule.cxx:174
 AliMUONGeometryModule.cxx:175
 AliMUONGeometryModule.cxx:176
 AliMUONGeometryModule.cxx:177
 AliMUONGeometryModule.cxx:178
 AliMUONGeometryModule.cxx:179
 AliMUONGeometryModule.cxx:180
 AliMUONGeometryModule.cxx:181
 AliMUONGeometryModule.cxx:182
 AliMUONGeometryModule.cxx:183
 AliMUONGeometryModule.cxx:184
 AliMUONGeometryModule.cxx:185
 AliMUONGeometryModule.cxx:186
 AliMUONGeometryModule.cxx:187
 AliMUONGeometryModule.cxx:188
 AliMUONGeometryModule.cxx:189
 AliMUONGeometryModule.cxx:190
 AliMUONGeometryModule.cxx:191
 AliMUONGeometryModule.cxx:192
 AliMUONGeometryModule.cxx:193
 AliMUONGeometryModule.cxx:194
 AliMUONGeometryModule.cxx:195
 AliMUONGeometryModule.cxx:196
 AliMUONGeometryModule.cxx:197