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