AliRoot Core  3dc7879 (3dc7879)
AliMUONRegionalTriggerConfig.cxx
Go to the documentation of this file.
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 
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;
48 
49 
50 //______________________________________________________________________________
52  : TObject(),
53  fTriggerCrates()
54 {
56 
57  fTriggerCrates.SetOwner(true);
58  fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
59 }
60 
61 //______________________________________________________________________________
63  : TObject(rhs),
64  fTriggerCrates(rhs.fTriggerCrates)
65 {
67 }
68 
69 //______________________________________________________________________________
71 {
73 
74  // check assignment to self
75  if (this == &rhs) return *this;
76 
77  // base class assignment
78  TObject::operator=(rhs);
79 
80  // assignment operator
82 
83  return *this;
84 }
85 
86 //______________________________________________________________________________
88 {
90 }
91 
92 //
93 // public methods
94 //
95 
96 //______________________________________________________________________________
98 {
100 
101  // Read first data contained in mapping object
102  //
103  AliMpRegionalTrigger mpRegionalTrigger;
104  mpRegionalTrigger.SetTriggerCratesOwner(kFALSE);
105  if ( ! mpRegionalTrigger.ReadData(fileName) ) {
107  << "Reading mapping regional trigger from file " << fileName.Data() << " failed."
108  << endl;
109  return 0;
110  }
111 
112  // Fill calibration object from mapping object
113  //
114  TIterator* it = mpRegionalTrigger.CreateCrateIterator();
115  AliMpTriggerCrate* mpTriggerCrate;
116  while ( ( mpTriggerCrate = (AliMpTriggerCrate*)it->Next() ) ) {
118  mpTriggerCrate->GetName(), new AliMUONTriggerCrateConfig(mpTriggerCrate));
119  }
120  delete it;
121 
122  //
123 
124  // Read remaining calibration data from file
125  //
126  ifstream in(gSystem->ExpandPathName(fileName.Data()), ios::in);
127  if ( ! in.good() ) {
129  << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
130  return 0;
131  }
132 
133  UShort_t mask;
134  Int_t mode, coincidence;
135  Int_t nofBoards;
136  char line[80];
137 
138  // decode file and store in objects
139  while (!in.eof())
140  {
141  // Get name
142  in.getline(line,80);
143  if (!strlen(line)) break;
144  TString crateName(AliMpHelper::Normalize(line));
145 
146  in.getline(line,80);
147 
148  // read mode
149  in.getline(line,80);
150  sscanf(line,"%d",&mode);
151 
152  // read coincidence
153  in.getline(line,80);
154  sscanf(line,"%d",&coincidence);
155 
156  // read mask
157  in.getline(line,80);
158  sscanf(line,"%hx",&mask);
159 
160  // read # local board
161  in.getline(line,80);
162  sscanf(line,"%d",&nofBoards);
163 
164  AliMUONTriggerCrateConfig* crateConfig
165  = (AliMUONTriggerCrateConfig*)(fTriggerCrates.GetValue(crateName.Data()));
166 
167  // This should never happen, but let's test it anyway
168  if ( ! crateConfig ) {
170  << "Cannot find AliMUONTriggerCrateConfig " << crateName.Data() << endl;
171  return 0;
172  }
173 
174  crateConfig->SetMode(mode);
175  crateConfig->SetCoinc(coincidence);
176  crateConfig->SetMask(mask);
177 
178  // Skipp local board data
179  for ( Int_t i = 0; i < 3*nofBoards; ++i )
180  in.getline(line,80);
181  }
182 
183  return fTriggerCrates.GetSize();
184 }
185 
186 //______________________________________________________________________________
188  Bool_t warn) const
189 {
191 
194 
195  if ( ! crate && warn ) {
197  << "Trigger crate with name = " << name.Data() << " not defined." << endl;
198  }
199 
200  return crate;
201 }
202 
203 //______________________________________________________________________________
205 {
207 
208  return fTriggerCrates.GetSize();
209 }
210 
211 //______________________________________________________________________________
212 TIterator*
214 {
216  return fTriggerCrates.CreateIterator();
217 }
218 
219 
220 
221 
void SetMode(UShort_t mode)
Set mode operating for crate.
The class defines the configuration of trigger crate.
#define AliErrorStream()
Definition: AliLog.h:630
Bool_t ReadData(const TString &fileName)
The class defines the properties of trigger crate.
static TString Normalize(const char *line)
AliMUONRegionalTriggerConfig & operator=(const AliMUONRegionalTriggerConfig &rhs)
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
Int_t GetSize() const
Definition: AliMpExMap.cxx:340
AliMpExMap fTriggerCrates
map for trigger crates
AliMUONTriggerCrateConfig * FindTriggerCrate(TString crateName, Bool_t warn=true) const
void SetTriggerCratesOwner(Bool_t owner)
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
The class defines the properties of regional trigger crate.
static Int_t LocalBoardNofChannels()
Max number of channels per local board.
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
TIterator * CreateCrateIterator() const
Int_t ReadData(const TString &fileName="")
The class defines the properties of regional trigger crate.
void SetCoinc(UShort_t coinc)
Set coincidence mode for crate.
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
void SetMask(UShort_t mask)
Set regional mask.