FairRoot/PandaRoot
PndMvdBoxMap.cxx
Go to the documentation of this file.
1 // Class PndMvdBoxMap
2 
3 // Simone Bianco
4 
5 #include "PndMvdBoxMap.h"
6 #include <fstream>
7 #include <iostream>
8 
9 using namespace std;
10 
11 // ----------------------------------------------------------
13 {
14  Info("Print","Filename = %s",fFileName.Data());
15  return;
16 }
17 
18 // ----------------------------------------------------------
20 {
21  ifstream mapfile(fFileName.Data(),ifstream::in);
22 
23  Int_t fbox=-1, fchanMin=-1, fchanMax=-1;
24  nLines = 0;
25  TString detPathName;
26 
27  if (!mapfile.is_open()){
28  // abort on wrong file
29  Error("Init","Could not open file %s",fFileName.Data());
30  return kFALSE;
31  }
32 
33  /*box = new Int_t();
34  fCh = new Int_t();
35  lCh = new Int_t();*/
36  while(mapfile.good())
37  {
38  mapfile >> fbox >> fchanMin >> fchanMax >> detPathName;
39  if(mapfile.eof()) break;
40  cout << "Position: " << mapfile.tellg() << endl;
41  Info("Init","Read line: %i %i %i %s",fbox,fchanMin,fchanMax,detPathName.Data());
42  box[nLines] = fbox;
43  fCh[nLines] = fchanMin;
44  lCh[nLines] = fchanMax;
45 
46  fMap[nLines] = detPathName;
47 
48  // TString *name = new TString(detPathName);
49 // name.push_back(detPathName.Data());
50  //*name[nLines] = detPathName.Data();
51 
52  nLines++;
53  }
54 
55  cout << nLines << " entries" << endl;
56 
57 /* mapfile.clear();
58  mapfile.seekg(ios::beg);
59 
60 
61  Int_t buffNum;
62  TString buffName;
63 
64  for (Int_t zz = 0 ; zz < nLines ; zz++)
65  {
66 
67  mapfile >> buffNum;
68  box[zz] = buffNum;
69  mapfile >> buffNum;
70  fCh[zz] = buffNum;
71  mapfile >> buffNum;
72  lCh[zz] = buffNum;
73  mapfile >> buffName;
74  name[zz] = buffName;
75 
76  if(mapfile.eof()) break;
77  }
78 */
79 
80 //std::pair<Int_t,TString> apair(sw,detPathName);
81 //fApvNumberMap[rw] = apair;
82 
83  mapfile.close();
84  return kTRUE;
85 }
86 
88 {
89 
90  for (Int_t jj = 0 ; jj < nLines ; jj++)
91  {
92  cout << box[jj] << " " << fCh[jj] << " " << lCh[jj] << " " << fMap[jj] << endl;
93  }
94 }
95 
96 
97 // ----------------------------------------------------------
98 void PndMvdBoxMap::DoMapping(Int_t nbox, Int_t chan, TString &detpath)
99 {
100 
101  //Int_t sat = -1; //[R.K.02/2017] Unused variable?
102 
103  for (Int_t jj = 0 ; jj < nLines ; jj++)
104  {
105  if (nbox == box[jj])
106  {
107  if ( chan >= fCh[jj] && chan <= lCh[jj] )
108  {
109  detpath = fMap[jj];
110  //sat = jj; //[R.K.02/2017] Unused variable?
111  }
112  }
113  }
114 
115  // for debug...
116  // cout << "Box: " << nbox << ", ch: " << chan << " --> line: " << sat << ", name: " << detpath.Data() << endl;
117 
118  return;
119 }
120 
121 
122 
123 
void DoMapping(Int_t nbox, Int_t chan, TString &detpath)
Bool_t Init()
ClassImp(PndAnaContFact)