]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/data/station345/SlatTranslatorToBusPatches.C
Changed default values of cuts
[u/mrichter/AliRoot.git] / MUON / mapping / data / station345 / SlatTranslatorToBusPatches.C
CommitLineData
1c4729e8 1/// $Id$
2///
3/// Generate, for a given slat type, the list of translators and their buspatch
4///
5/// It's the equivalent of the St#_Nappes-crocus-v#.#.pdf files found in
6/// https://twiki.cern.ch/twiki/bin/view/ALICE/St345CrocusFlatCables
7/// but sorted by slat type, and not by crocus.
8///
9/// \author Laurent Aphecetche, Subatech
10///
11
12#include "TString.h"
13#include <map>
14#include <string>
15#include <fstream>
16#include <iostream>
17#include "Riostream.h"
18#include "TSystem.h"
19#include <vector>
20#include <utility>
21#include "AliMpDetElement.h"
22#include "AliMpDDLStore.h"
23#include "AliMpCDB.h"
24#include "AliMpDataProcessor.h"
25#include "AliMpDataMap.h"
26#include "AliMpDataStreams.h"
27#include "AliMpDDLStore.h"
28#include "AliMpManuStore.h"
29#include "AliMpBusPatch.h"
30#include <algorithm>
31
32void LoadMapping(Bool_t fromFile)
33{
34 if ( fromFile )
35 {
36 AliMpDataProcessor mp;
37 {
38 AliMpDataMap* datamap = mp.CreateDataMap("data");
39 AliMpDataStreams dataStreams(datamap);
40 AliMpDDLStore::ReadData(dataStreams);
41 }
42 {
43 AliMpDataMap* datamap = mp.CreateDataMap("data_run");
44 AliMpDataStreams dataStreams(datamap);
45 AliMpManuStore::ReadData(dataStreams);
46 }
47 }
48 else
49 {
50 AliMpCDB::LoadAll2();
51 }
52}
53
54void SlatTranslatorToBusPatches(const char* whichSlat="112200NR2")
55{
56 LoadMapping(kTRUE);
57
58 TString file(gSystem->ExpandPathName("$ALICE_ROOT/MUON/mapping/data/station345/DetElemIdToSlatType.dat"));
59
60 ifstream in(file);
61 if (in.bad()) return;
62
63 int detElemId;
64 char s[80];
65 char slatType[80];
66 std::map<std::string,std::vector<int> > slats;
67
68 while ( in.getline(s,80,'\n') )
69 {
70 if ( s[0] != '#' && strlen(s) > 2 )
71 {
72 sscanf(s,"%d %s",&detElemId,slatType);
73
74 slats[slatType].push_back(detElemId);
75 }
76 }
77
78 std::map<std::string,std::vector<int> >::const_iterator it;
79
80 std::vector<int> v = slats[whichSlat];
81
82 cout << "----------------------" << endl;
83 cout << whichSlat << endl;
84 cout << "----------------------" << endl;
85 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(v[0]);
86 Int_t nofManus(0);
87 Int_t nofChannels(0);
88
89 for ( Int_t b = 0; b < de->GetNofBusPatches(); ++b )
90 {
91 Int_t busPatchId = de->GetBusPatchId(b);
92 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
93 nofManus += bp->GetNofManus();
94 cout << bp->GetTranslatorLabel() << " : " << bp->GetNofManus() << " manus" << endl;
95 for ( Int_t im = 0; im < bp->GetNofManus(); ++im )
96 {
97 Int_t manuId = bp->GetManuId(im);
98 nofChannels += de->NofChannelsInManu(manuId);
99 }
100 }
101
102 cout << "Number of bus patches = " << de->GetNofBusPatches() << endl;
103 cout << "Number of manus = " << nofManus << endl;
104 cout << "Number of channels = " << nofChannels << endl;
105 cout << "----------------------" << endl;
106
107 std::sort(v.begin(),v.end());
108
109 for ( size_t i = 0; i < v.size(); ++i )
110 {
111 Int_t detElemId = v[i];
112
113 cout << Form("%04d ",detElemId) << endl;
114
115 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
116 for ( Int_t b = 0; b < de->GetNofBusPatches(); ++b )
117 {
118 Int_t busPatchId = de->GetBusPatchId(b);
119 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
120 bp->Print();
121 }
122 }
123 cout << endl;
124
125 in.close();
126}
127
128
129