]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRegionalTriggerReader.cxx
In mapping:
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRegionalTriggerReader.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 AliMpRegionalTriggerReader
21 // --------------------
22 // The class to read the  regional trigger crate files
23 // Author: Ch. Finck, Subatech Nantes
24 //-----------------------------------------------------------------------------
25
26 #include "AliMpRegionalTriggerReader.h"
27 #include "AliMpTriggerCrate.h"
28 #include "AliMpLocalBoard.h"
29 #include "AliMUONRegionalTriggerConfig.h"
30 #include "AliMUONTriggerCrateConfig.h"
31 #include "AliMpConstants.h"
32 #include "AliMpFiles.h"
33 #include "AliMpHelper.h"
34 #include "AliMpExMap.h"
35
36 #include "AliLog.h"
37
38 #include <TArrayI.h>
39 #include <TObjArray.h>
40 #include <Riostream.h>
41 #include <TClass.h>
42 #include <TSystem.h>
43
44
45 /// \cond CLASSIMP
46 ClassImp(AliMpRegionalTriggerReader)
47 /// \endcond
48
49
50 //______________________________________________________________________________
51 AliMpRegionalTriggerReader::AliMpRegionalTriggerReader()
52   : TObject()
53 {
54 /// constructor
55 }
56
57 //______________________________________________________________________________
58 AliMpRegionalTriggerReader::~AliMpRegionalTriggerReader()
59 {
60 /// Destructor
61 }
62
63 //
64 // public methods
65 //
66
67 //______________________________________________________________________________
68 Int_t AliMpRegionalTriggerReader::ReadData(TList& list, istream& in)
69 {
70 /// Load the Regional trigger from ASCII data files
71 /// and fill objects
72     
73     if (!in) {
74       return -1;
75     }
76      
77     AliMpExMap* triggerCrates = 0x0;
78     AliMpExMap* localBoardMap = 0x0;
79     TObjArray*  localBoardArray = 0x0;
80     
81     // common trigger crate map for mapping/config
82     triggerCrates = static_cast<AliMpExMap*> (list.At(0));
83
84     Bool_t mapping = false;
85     // only for mapping
86     if (list.GetSize() == 3) 
87     {
88       mapping = true;
89       localBoardMap   = static_cast<AliMpExMap*> (list.At(1));
90       localBoardArray = static_cast<TObjArray*>  (list.At(2));
91     }
92               
93     AliMpLocalBoard* board = 0x0;
94     AliMpTriggerCrate* crate = 0x0;
95     AliMUONTriggerCrateConfig* crateConfig = 0x0;
96
97     Int_t localBoardId = 0;
98     TArrayI listInt;
99     UShort_t crateId, mask;
100     Int_t mode, coincidence;
101     Int_t nofBoards;
102     char line[80];
103    
104     // decode file and store in objects
105     while (!in.eof())
106     {
107       in.getline(line,80);
108       if (!strlen(line)) break;
109       TString crateName(AliMpHelper::Normalize(line));
110       
111       in.getline(line,80);    
112       sscanf(line,"%hx",&crateId);
113   
114       // read mode
115       in.getline(line,80);
116       sscanf(line,"%d",&mode);
117
118       // read coincidence
119       in.getline(line,80);
120       sscanf(line,"%d",&coincidence);
121
122       // read mask
123       in.getline(line,80);
124       sscanf(line,"%hx",&mask);
125       
126       // read # local board
127       in.getline(line,80);
128       sscanf(line,"%d",&nofBoards);
129
130       if (mapping)
131       {
132         crate = (AliMpTriggerCrate*)(triggerCrates->GetValue(crateName.Data()));
133         if (!crate) 
134         {
135           crate = new AliMpTriggerCrate(crateName.Data(), crateId);
136           triggerCrates->Add(crateName.Data(), crate);
137         }
138       }
139       else
140       {
141         crateConfig = (AliMUONTriggerCrateConfig*)(triggerCrates->GetValue(crateName.Data()));
142         if (!crateConfig) 
143         {
144           crateConfig = new AliMUONTriggerCrateConfig(crateName.Data(), crateId, mask, mode, coincidence);
145           triggerCrates->Add(crateName.Data(), crateConfig);
146         }
147       }
148       
149       Char_t localBoardName[20];
150       Int_t slot;
151       UInt_t switches;
152       
153       for ( Int_t i = 0; i < nofBoards; ++i ) 
154       {
155           in.getline(line,80);
156           sscanf(line,"%02d %s %03d %03x",&slot,localBoardName,&localBoardId,&switches);
157           if (mapping)
158           {
159             board = new AliMpLocalBoard(localBoardId, localBoardName, slot); 
160             board->SetSwitch(switches);
161             board->SetCrate(crateName);
162             
163             if (localBoardId > AliMpConstants::NofLocalBoards())
164               board->SetNotified(false); // copy cards
165             
166             crate->AddLocalBoard(localBoardId);
167           }
168           else
169           {
170             crateConfig->AddLocalBoard(localBoardId);
171           }
172           
173           // add  list of DEs for local board
174           listInt.Reset();
175           in.getline(line,80);
176           if (mapping)
177           {
178             TString tmp(AliMpHelper::Normalize(line));
179             AliMpHelper::DecodeName(tmp,' ',listInt);
180             for (Int_t ii = 0; ii < listInt.GetSize(); ++ii) { 
181               if ( listInt[ii] ) board->AddDE(listInt[ii]);
182             }  
183           }
184           
185           // set copy number and transverse connector
186           in.getline(line,80);
187           if (mapping)
188           {
189             TString tmp1 = AliMpHelper::Normalize(line);
190             AliMpHelper::DecodeName(tmp1,' ',listInt);
191             
192             board->SetInputXfrom(listInt[0]);
193             board->SetInputXto(listInt[1]);
194             
195             board->SetInputYfrom(listInt[2]);
196             board->SetInputYto(listInt[3]);
197             
198             board->SetTC(listInt[4]);
199             
200             // add local board into array
201             localBoardArray->AddAt(board,board->GetId());
202             localBoardMap->Add(board->GetId(),board);
203           
204         }
205       }
206     }
207     
208     return triggerCrates->GetSize();
209   }