Line data Source code
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 AliMUONRegionalTriggerConfig
21 : // --------------------
22 : // The class defines the configuration of regional trigger crate
23 : // Author: Ch. Finck, Subatech Nantes
24 : //-----------------------------------------------------------------------------
25 :
26 : #include "AliMUONRegionalTriggerConfig.h"
27 : #include "AliMUONTriggerCrateConfig.h"
28 : #include "AliMpConstants.h"
29 : #include "AliMpHelper.h"
30 : #include "AliMpExMapIterator.h"
31 : #include "AliMpRegionalTrigger.h"
32 : #include "AliLog.h"
33 :
34 : #include <TArrayI.h>
35 : #include <Riostream.h>
36 : #include <TClass.h>
37 : #include <TSystem.h>
38 : #include <TList.h>
39 :
40 :
41 : using std::cout;
42 : using std::endl;
43 : using std::ifstream;
44 : using std::ios;
45 : /// \cond CLASSIMP
46 18 : ClassImp(AliMUONRegionalTriggerConfig)
47 : /// \endcond
48 :
49 :
50 : //______________________________________________________________________________
51 : AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig()
52 3 : : TObject(),
53 3 : fTriggerCrates()
54 15 : {
55 : /// Standard constructor
56 :
57 3 : fTriggerCrates.SetOwner(true);
58 3 : fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
59 6 : }
60 :
61 : //______________________________________________________________________________
62 : AliMUONRegionalTriggerConfig::AliMUONRegionalTriggerConfig(const AliMUONRegionalTriggerConfig& rhs)
63 0 : : TObject(rhs),
64 0 : fTriggerCrates(rhs.fTriggerCrates)
65 0 : {
66 : /// Copy constructor
67 0 : }
68 :
69 : //______________________________________________________________________________
70 : AliMUONRegionalTriggerConfig& AliMUONRegionalTriggerConfig::operator=(const AliMUONRegionalTriggerConfig& rhs)
71 : {
72 : /// Assignment operator
73 :
74 : // check assignment to self
75 0 : if (this == &rhs) return *this;
76 :
77 : // base class assignment
78 0 : TObject::operator=(rhs);
79 :
80 : // assignment operator
81 0 : fTriggerCrates = rhs.fTriggerCrates;
82 :
83 0 : return *this;
84 0 : }
85 :
86 : //______________________________________________________________________________
87 : AliMUONRegionalTriggerConfig::~AliMUONRegionalTriggerConfig()
88 0 : {
89 : /// Destructor
90 0 : }
91 :
92 : //
93 : // public methods
94 : //
95 :
96 : //______________________________________________________________________________
97 : Int_t AliMUONRegionalTriggerConfig::ReadData(const TString& fileName)
98 : {
99 : /// Load the Regional trigger from ASCII data file
100 :
101 : // Read first data contained in mapping object
102 : //
103 0 : AliMpRegionalTrigger mpRegionalTrigger;
104 0 : mpRegionalTrigger.SetTriggerCratesOwner(kFALSE);
105 0 : if ( ! mpRegionalTrigger.ReadData(fileName) ) {
106 0 : AliErrorStream()
107 0 : << "Reading mapping regional trigger from file " << fileName.Data() << " failed."
108 0 : << endl;
109 0 : return 0;
110 : }
111 :
112 : // Fill calibration object from mapping object
113 : //
114 0 : TIterator* it = mpRegionalTrigger.CreateCrateIterator();
115 : AliMpTriggerCrate* mpTriggerCrate;
116 0 : while ( ( mpTriggerCrate = (AliMpTriggerCrate*)it->Next() ) ) {
117 0 : fTriggerCrates.Add(
118 0 : mpTriggerCrate->GetName(), new AliMUONTriggerCrateConfig(mpTriggerCrate));
119 : }
120 0 : delete it;
121 :
122 : //
123 :
124 : // Read remaining calibration data from file
125 : //
126 0 : ifstream in(gSystem->ExpandPathName(fileName.Data()), ios::in);
127 0 : if ( ! in.good() ) {
128 0 : AliErrorStream()
129 0 : << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
130 0 : return 0;
131 : }
132 :
133 0 : UShort_t mask;
134 0 : Int_t mode, coincidence;
135 0 : Int_t nofBoards;
136 0 : char line[80];
137 :
138 : // decode file and store in objects
139 0 : while (!in.eof())
140 : {
141 : // Get name
142 0 : in.getline(line,80);
143 0 : if (!strlen(line)) break;
144 0 : TString crateName(AliMpHelper::Normalize(line));
145 :
146 0 : in.getline(line,80);
147 :
148 : // read mode
149 0 : in.getline(line,80);
150 0 : sscanf(line,"%d",&mode);
151 :
152 : // read coincidence
153 0 : in.getline(line,80);
154 0 : sscanf(line,"%d",&coincidence);
155 :
156 : // read mask
157 0 : in.getline(line,80);
158 0 : sscanf(line,"%hx",&mask);
159 :
160 : // read # local board
161 0 : in.getline(line,80);
162 0 : sscanf(line,"%d",&nofBoards);
163 :
164 : AliMUONTriggerCrateConfig* crateConfig
165 0 : = (AliMUONTriggerCrateConfig*)(fTriggerCrates.GetValue(crateName.Data()));
166 :
167 : // This should never happen, but let's test it anyway
168 0 : if ( ! crateConfig ) {
169 0 : AliErrorStream()
170 0 : << "Cannot find AliMUONTriggerCrateConfig " << crateName.Data() << endl;
171 0 : return 0;
172 : }
173 :
174 0 : crateConfig->SetMode(mode);
175 0 : crateConfig->SetCoinc(coincidence);
176 0 : crateConfig->SetMask(mask);
177 :
178 : // Skipp local board data
179 0 : for ( Int_t i = 0; i < 3*nofBoards; ++i )
180 0 : in.getline(line,80);
181 0 : }
182 :
183 0 : return fTriggerCrates.GetSize();
184 0 : }
185 :
186 : //______________________________________________________________________________
187 : AliMUONTriggerCrateConfig* AliMUONRegionalTriggerConfig::FindTriggerCrate(TString name,
188 : Bool_t warn) const
189 : {
190 : /// Return trigger crate with given name
191 :
192 : AliMUONTriggerCrateConfig* crate
193 384 : = (AliMUONTriggerCrateConfig*) fTriggerCrates.GetValue(name.Data());
194 :
195 192 : if ( ! crate && warn ) {
196 0 : AliErrorStream()
197 0 : << "Trigger crate with name = " << name.Data() << " not defined." << endl;
198 0 : }
199 :
200 192 : return crate;
201 0 : }
202 :
203 : //______________________________________________________________________________
204 : Int_t AliMUONRegionalTriggerConfig::GetNofTriggerCrates() const
205 : {
206 : /// Return number of trigger crates
207 :
208 0 : return fTriggerCrates.GetSize();
209 : }
210 :
211 : //______________________________________________________________________________
212 : TIterator*
213 : AliMUONRegionalTriggerConfig::CreateCrateIterator() const
214 : {
215 : /// Return trigger crates iterator
216 0 : return fTriggerCrates.CreateIterator();
217 : }
218 :
219 :
220 :
221 :
|