--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+// $Id$
+// $MpId: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
+
+//-----------------------------------------------------------------------------
+// Class AliMpRegionalTrigger
+// --------------------
+// The class defines the properties of regional trigger crate
+// Author: Ch. Finck, Subatech Nantes
+//-----------------------------------------------------------------------------
+
+#include "AliMpRegionalTrigger.h"
+#include "AliMpTriggerCrate.h"
+#include "AliMpLocalBoard.h"
+#include "AliMpConstants.h"
+#include "AliMpFiles.h"
+#include "AliMpHelper.h"
+
+#include "AliLog.h"
+
+#include <TArrayI.h>
+#include <Riostream.h>
+#include <TClass.h>
+#include <TSystem.h>
+
+
+/// \cond CLASSIMP
+ClassImp(AliMpRegionalTrigger)
+/// \endcond
+
+
+//______________________________________________________________________________
+AliMpRegionalTrigger::AliMpRegionalTrigger()
+ : TObject(),
+ fTriggerCrates(true),
+ fLocalBoards(true)
+{
+/// Standard constructor
+
+ fTriggerCrates.SetOwner(true);
+ fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
+
+ fLocalBoards.SetOwner(true);
+ fLocalBoards.SetSize(AliMpConstants::TotalNofLocalBoards()); // included non-notified boards
+}
+
+//______________________________________________________________________________
+AliMpRegionalTrigger::AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs)
+ : TObject(rhs),
+ fTriggerCrates(rhs.fTriggerCrates),
+ fLocalBoards(rhs.fLocalBoards)
+{
+/// Copy constructor
+}
+
+//______________________________________________________________________________
+AliMpRegionalTrigger::AliMpRegionalTrigger(TRootIOCtor* /*ioCtor*/)
+ : TObject(),
+ fTriggerCrates(),
+ fLocalBoards()
+{
+/// Constructor for I0
+}
+
+//______________________________________________________________________________
+AliMpRegionalTrigger& AliMpRegionalTrigger::operator=(const AliMpRegionalTrigger& rhs)
+{
+/// Assignment operator
+
+ // check assignment to self
+ if (this == &rhs) return *this;
+
+ // base class assignment
+ TObject::operator=(rhs);
+
+ // assignment operator
+ fTriggerCrates = rhs.fTriggerCrates;
+ fLocalBoards = rhs.fLocalBoards;
+
+ return *this;
+}
+
+//______________________________________________________________________________
+AliMpRegionalTrigger::~AliMpRegionalTrigger()
+{
+/// Destructor
+}
+
+//
+// public methods
+//
+
+//______________________________________________________________________________
+Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName)
+{
+/// Load the Regional trigger from ASCII data files
+/// and return its instance
+
+ TString inFileName(fileName);
+ if ( inFileName == "" )
+ inFileName = AliMpFiles::LocalTriggerBoardMapping();
+
+ inFileName = gSystem->ExpandPathName(inFileName.Data());
+
+ ifstream in(inFileName.Data(), ios::in);
+
+ if (!in) {
+ AliErrorStream()
+ << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
+ return kFALSE;
+ }
+
+ AliMpLocalBoard* board = 0x0;
+ AliMpTriggerCrate* crate = 0x0;
+
+
+ Int_t localBoardId = 0;
+ TArrayI list;
+ UShort_t crateId, mask;
+ Int_t mode, coincidence;
+
+ char line[80];
+
+ while (!in.eof())
+ {
+ in.getline(line,80);
+ if (!strlen(line)) break;
+ TString crateName(AliMpHelper::Normalize(line));
+
+ in.getline(line,80);
+ sscanf(line,"%hx",&crateId);
+
+ in.getline(line,80);
+ sscanf(line,"%d",&mode);
+
+ in.getline(line,80);
+ sscanf(line,"%d",&coincidence);
+
+ in.getline(line,80);
+ sscanf(line,"%hx",&mask);
+
+ crate = (AliMpTriggerCrate*)(fTriggerCrates.GetValue(crateName.Data()));
+ if (!crate)
+ {
+ // cout << "Creating crate: " << crateName.Data() << endl;
+ crate = new AliMpTriggerCrate(crateName.Data(), crateId, mask, mode, coincidence);
+ fTriggerCrates.Add(crateName.Data(), crate);
+ }
+
+ Char_t localBoardName[20];
+ Int_t slot;
+ UInt_t switches;
+
+ for ( Int_t i = 0; i < AliMpConstants::LocalBoardNofChannels(); ++i )
+ {
+ if ( (mask >> i ) & 0x1 )
+ {
+ in.getline(line,80);
+ sscanf(line,"%02d %s %03d %03x",&slot,localBoardName,&localBoardId,&switches);
+ // cout << " Creating local board: " << localBoardId << endl;
+ board = new AliMpLocalBoard(localBoardId, localBoardName, slot);
+ board->SetSwitch(switches);
+ board->SetCrate(crateName);
+
+ if (localBoardId > AliMpConstants::NofLocalBoards())
+ board->SetNotified(false); // copy cards
+
+ crate->AddLocalBoard(localBoardId);
+
+ // add list of DEs for local board
+ list.Reset();
+ in.getline(line,80);
+ TString tmp(AliMpHelper::Normalize(line));
+ AliMpHelper::DecodeName(tmp,' ',list);
+ for (Int_t i = 0; i < list.GetSize(); ++i) {
+ if ( list[i] ) board->AddDE(list[i]);
+ }
+
+ // set copy number and transverse connector
+ in.getline(line,80);
+ tmp = AliMpHelper::Normalize(line);
+ AliMpHelper::DecodeName(tmp,' ',list);
+
+ board->SetInputXfrom(list[0]);
+ board->SetInputXto(list[1]);
+
+ board->SetInputYfrom(list[2]);
+ board->SetInputYto(list[3]);
+
+ board->SetTC(list[4]);
+
+ // add local board into map
+ fLocalBoards.Add(board->GetId(), board);
+ }
+ }
+ }
+ return kTRUE;
+}
+
+//______________________________________________________________________________
+AliMpLocalBoard* AliMpRegionalTrigger::FindLocalBoard(Int_t localBoardId,
+ Bool_t warn) const {
+ /// Return bus patch with given Id
+
+ AliMpLocalBoard* localBoard
+ = (AliMpLocalBoard*) fLocalBoards.GetValue(localBoardId);
+
+ if ( ! localBoard && warn ) {
+ AliErrorStream()
+ << "Local board with Id = " << localBoardId << " not defined." << endl;
+ }
+
+ return localBoard;
+}
+
+//______________________________________________________________________________
+AliMpTriggerCrate* AliMpRegionalTrigger::FindTriggerCrate(TString name,
+ Bool_t warn) const {
+ /// Return trigger crate with given name
+
+ AliMpTriggerCrate* crate
+ = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
+
+ if ( ! crate && warn ) {
+ AliErrorStream()
+ << "Trigger crate with name = " << name.Data() << " not defined." << endl;
+ }
+
+ return crate;
+}
+
+//______________________________________________________________________________
+Int_t AliMpRegionalTrigger::GetNofTriggerCrates() const
+{
+ /// Return number of trigger crates
+
+ return fTriggerCrates.GetSize();
+}
+
+//______________________________________________________________________________
+AliMpTriggerCrate* AliMpRegionalTrigger::GetTriggerCrate(Int_t index) const
+{
+ /// Return the trigger crates with given index;
+
+ return static_cast<AliMpTriggerCrate*>(fTriggerCrates.GetObject(index));
+}
+
+//______________________________________________________________________________
+AliMpTriggerCrate* AliMpRegionalTrigger::GetTriggerCrateFast(Int_t index) const
+{
+ /// Return the trigger crates with given index;
+ /// the index is not checked as we use the fast method in AliMpExMap.
+
+ return static_cast<AliMpTriggerCrate*>(fTriggerCrates.GetObjectFast(index));
+}
+
+//______________________________________________________________________________
+Int_t AliMpRegionalTrigger::GetNofLocalBoards() const
+{
+ /// Return number of local boards
+
+ return fLocalBoards.GetSize();
+}
+
+//______________________________________________________________________________
+AliMpLocalBoard* AliMpRegionalTrigger::GetLocalBoard(Int_t index) const
+{
+ /// Return local board with given index;
+
+ return static_cast<AliMpLocalBoard*>(fLocalBoards.GetObject(index));
+}
+
+//______________________________________________________________________________
+AliMpLocalBoard* AliMpRegionalTrigger::GetLocalBoardFast(Int_t index) const
+{
+ /// Return local board with given index;
+ /// the index is not checked as we use the fast method in AliMpExMap.
+
+ return static_cast<AliMpLocalBoard*>(fLocalBoards.GetObjectFast(index));
+}
+
+
+
+
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $MpId: $
+
+/// \ingroup mptrigger
+/// \class AliMpRegionalTrigger
+/// \brief The class defines the properties of regional trigger crate
+///
+/// \author Ch. Finck, Subatech Nantes; I. Hrivnacova, IPN Orsay
+
+#ifndef ALI_MP_REGIONAL_TRIGGER_H
+#define ALI_MP_REGIONAL_TRIGGER_H
+
+#include <TObject.h>
+
+#include "AliMpExMap.h"
+
+#include <TObjArray.h>
+
+class AliMpTriggerCrate;
+class AliMpLocalBoard;
+
+class AliMpRegionalTrigger : public TObject{
+
+ public:
+ AliMpRegionalTrigger();
+ AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs);
+ AliMpRegionalTrigger(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpRegionalTrigger();
+
+ // operators
+ AliMpRegionalTrigger& operator=(const AliMpRegionalTrigger& rhs);
+
+ // methods
+ Bool_t ReadData(const TString& fileName = "");
+
+ AliMpTriggerCrate* FindTriggerCrate(TString crateName, Bool_t warn = true) const;
+ AliMpLocalBoard* FindLocalBoard(Int_t localBoardId, Bool_t warn = true) const;
+
+ // method for looping
+
+ Int_t GetNofTriggerCrates() const;
+ AliMpTriggerCrate* GetTriggerCrate(Int_t index) const;
+ AliMpTriggerCrate* GetTriggerCrateFast(Int_t index) const;
+ TExMapIter GetTriggerCrateItr() const;
+
+ Int_t GetNofLocalBoards() const;
+ AliMpLocalBoard* GetLocalBoard(Int_t index) const;
+ AliMpLocalBoard* GetLocalBoardFast(Int_t index) const;
+ TExMapIter GetLocalBoardItr() const;
+
+ private:
+ // data members
+ AliMpExMap fTriggerCrates; ///< map for trigger crates
+ AliMpExMap fLocalBoards; ///< map for local boards
+
+ ClassDef(AliMpRegionalTrigger,1) // Regional trigger crate
+};
+
+/// Return trigger crates iterator
+inline TExMapIter AliMpRegionalTrigger::GetTriggerCrateItr() const {
+ return fTriggerCrates.GetIterator();
+}
+
+/// Return trigger local board iterator
+inline TExMapIter AliMpRegionalTrigger::GetLocalBoardItr() const {
+ return fLocalBoards.GetIterator();
+}
+
+
+#endif //ALI_MP_REGIONAL__CRATE_H
+
+
+
+
+
+
+
+
+
+
+
+
+
+