]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpManuList.cxx
Corrected GetNeighbours() (Laurent)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpManuList.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
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 **************************************************************************/
15
16 // $Id$
17
18 #include "AliMpManuList.h"
19
20 #include "AliMpDEIterator.h"
21 #include "AliMpDEManager.h"
22 #include "AliMpSegmentation.h"
23 #include "AliMpStationType.h"
24 #include "AliMpCathodType.h"
25 #include "AliMpVSegmentation.h"
26 #include "TArrayI.h"
27 #include "TList.h"
28
29 ///
30 /// \class AliMpManuList
31 ///
32 /// A sort of cache for mapping information we use often (or that are
33 /// time consuming to recompute).
34 ///
35 /// \author Laurent Aphecetche
36
37 /// \cond CLASSIMP
38 ClassImp(AliMpManuList)
39 /// \endcond
40
41 //_____________________________________________________________________________
42 AliMpManuList::AliMpManuList()
43 {
44   /// ctor
45 }
46
47 //_____________________________________________________________________________
48 AliMpManuList::~AliMpManuList()
49 {
50   /// dtor
51 }
52
53 //_____________________________________________________________________________
54 Bool_t 
55 AliMpManuList::DoesChannelExist(Int_t detElemId, Int_t manuID, Int_t manuChannel)
56 {
57   /// Whether a given (detElemId,manuID,manuChannel) combination is a valid one
58   
59   const AliMpVSegmentation* seg = 
60     AliMpSegmentation::Instance()
61       ->GetMpSegmentationByElectronics(detElemId,manuID);
62   if (!seg) return kFALSE;
63   
64   if ( seg->PadByLocation(AliMpIntPair(manuID,manuChannel),kFALSE).IsValid() )
65   {
66     return kTRUE;
67   }
68   else
69   {
70     return kFALSE;
71   }
72 }
73
74 //_____________________________________________________________________________
75 TList*
76 AliMpManuList::ManuList()
77 {
78   /// Create a TList of AliMpIntPair<detElemId,manuID> of all MUON TRK manus
79   /// The returned list must be deleted by the client
80   
81   TList* manuList = new TList;
82   
83   manuList->SetOwner(kTRUE);
84   
85   AliMpDEIterator it;
86   
87   it.First();
88   
89   while ( !it.IsDone() )
90   {
91     Int_t detElemId = it.CurrentDEId();
92     AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
93     if ( stationType != AliMp::kStationTrigger ) 
94     {
95       for ( Int_t cath = AliMp::kCath0; cath <=AliMp::kCath1 ; ++cath )
96       {
97         const AliMpVSegmentation* seg 
98           = AliMpSegmentation::Instance()
99             ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
100         
101         TArrayI manus;
102         
103         seg->GetAllElectronicCardIDs(manus);
104         
105         for ( Int_t im = 0; im < manus.GetSize(); ++im )
106         {
107           manuList->Add(new AliMpIntPair(detElemId,manus[im]));
108         }        
109       }
110     }
111     it.Next();
112   }
113   return manuList;
114 }
115
116 //_____________________________________________________________________________
117 Int_t 
118 AliMpManuList::NumberOfChannels(Int_t detElemId, Int_t manuId)
119 {
120   /// Returns the number of channels in that manuID. Answer should be <=64
121   /// whatever happens.
122   
123   const AliMpVSegmentation* seg = 
124     AliMpSegmentation::Instance()
125       ->GetMpSegmentationByElectronics(detElemId,manuId);
126   Int_t n(0);
127   for ( Int_t i = 0; i < 64; ++i )
128   {
129     AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE);
130     if (pad.IsValid()) ++n;
131   }
132   return n;
133 }
134
135 //_____________________________________________________________________________
136 Int_t 
137 AliMpManuList::NumberOfManus(Int_t detElemId)
138 {
139   /// Returns the number of manus contained in the given detection element.
140   Int_t n(0);
141   for ( Int_t i = AliMp::kCath0; i <= AliMp::kCath1; ++i )
142   {
143     const AliMpVSegmentation* seg 
144       = AliMpSegmentation::Instance()
145         ->GetMpSegmentation(detElemId,AliMp::GetCathodType(i));
146         
147     TArrayI manus;
148     seg->GetAllElectronicCardIDs(manus);
149     n += manus.GetSize();
150   }
151   return n;
152 }
153