]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONmapping/AliMpTriggerCrate.cxx
PMD module
[u/mrichter/AliRoot.git] / MUON / MUONmapping / AliMpTriggerCrate.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 // $MpId: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
18
19 //-----------------------------------------------------------------------------
20 // Class AliMpTriggerCrate
21 // --------------------
22 // The class defines the properties of trigger crate
23 // Author: Ch. Finck, Subatech Nantes
24 //-----------------------------------------------------------------------------
25
26 #include "AliMpTriggerCrate.h"
27
28 #include "AliLog.h"
29
30 #include <Riostream.h>
31
32 using std::endl;
33 /// \cond CLASSIMP
34 ClassImp(AliMpTriggerCrate)
35 /// \endcond
36
37
38 //______________________________________________________________________________
39 TString AliMpTriggerCrate::GenerateName(Int_t crateId, Int_t ddlId, Int_t nofDDLs)
40 {
41 /// Generate name
42
43   TString name;
44
45   if (crateId < 2)
46     name = Form("%d", crateId+1);
47   
48   if (crateId == 2)
49       name = "2-3";
50   
51   if (crateId > 2)
52       name = Form("%d", crateId);
53   
54   if (crateId > 7)
55     printf("crateId index too large\n");
56  
57   if (ddlId == nofDDLs)
58       name.Append("R");
59   else 
60       name.Append("L"); 
61
62   return name;
63 }  
64  
65 //______________________________________________________________________________
66 AliMpTriggerCrate::AliMpTriggerCrate(const Char_t* name, UShort_t id)
67   : TNamed(name, "mapping trigger crate"),
68     fId(id),
69     fDdlId(-1),
70     fLocalBoard(false)
71  
72 {
73 /// Standard constructor 
74 }
75
76 //______________________________________________________________________________
77 AliMpTriggerCrate::AliMpTriggerCrate(TRootIOCtor* /*ioCtor*/)
78   : TNamed(),
79     fId(),
80     fDdlId(),
81     fLocalBoard()
82 {
83 /// Root IO constructor
84 }
85
86 //______________________________________________________________________________
87 AliMpTriggerCrate::~AliMpTriggerCrate()
88 {
89 /// Destructor
90 }
91
92 //
93 // public methods
94 //
95
96 //______________________________________________________________________________
97 Bool_t AliMpTriggerCrate::AddLocalBoard(Int_t localBoardId)
98 {
99 /// Add local boards with given detElemId.
100 /// Return true if the local board was added
101
102   if ( HasLocalBoard(localBoardId) ) {
103     AliWarningStream() 
104       << "Local board with Id=" << localBoardId << " already present."
105       << endl;
106     return false;
107   }    
108
109   fLocalBoard.Add(localBoardId);
110   return true;
111 }   
112
113
114 //______________________________________________________________________________
115 Int_t AliMpTriggerCrate::GetNofLocalBoards() const
116 {  
117 /// Return the number of local board in this crate
118
119   return fLocalBoard.GetSize(); 
120 }
121
122 //______________________________________________________________________________
123 Int_t  AliMpTriggerCrate::GetLocalBoardId(Int_t index) const
124 {  
125 /// Return the local board by index (in loop)
126
127   if (index >= 0 && index < fLocalBoard.GetSize())
128       return fLocalBoard.GetValue(index); 
129   else 
130       return 0; // begin at 1
131 }
132
133 //______________________________________________________________________________
134 Bool_t  AliMpTriggerCrate::HasLocalBoard(Int_t localBoardId) const
135 {  
136 /// Return true if crate has local boardwith given localBoardId
137
138   return fLocalBoard.HasValue(localBoardId); 
139 }
140