EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PndSensorNamePar.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PndSensorNamePar.h
1 //
2 // C++ Interface: PndSensorNamePar
3 //
4 #ifndef PNDSENSORNAMEPAR_H
5 #define PNDSENSORNAMEPAR_H
6 
7 
8 #include "FairParGenericSet.h"
9 #include "FairParamList.h"
10 #include "FairRun.h"
11 
12 #include "TObjArray.h"
13 #include "TObjString.h"
14 
15 #include <iostream>
16 #include <map>
17 
20 {
21  public :
22  PndSensorNamePar (const char* name="PndSensorNamePar",
23  const char* title="Match between GeoManager path and SensorId",
24  const char* context="TestDefaultContext");
26  if(fSensorNames) delete fSensorNames;
27  };
28  void clear(void){};
30  Bool_t getParams(FairParamList* list);
31 
32  void Print();
33 
34  Int_t AddSensorName(TObjString* name);
35 
36  Int_t SensorInList(TObjString* name){
37 // for (int i = 0; i < fSensorNames->GetEntries();i++){
38 // TObjString* SensName = (TObjString*)fSensorNames->At(i);
39 // if (SensName->GetString() == name->GetString())
40 // return i;
41 // }
42 // return -1;
43  std::map<TString, Int_t>::iterator iter;
44  iter = fMapOfSensorNames.find(name->GetString());
45  if (iter != fMapOfSensorNames.end())
46  return iter->second;
47  else
48  return -1;
49  }
50 
51  void FillMap(){
52  for (int i = 0; i < fSensorNames->GetEntries();i++){
53  TObjString* SensName = (TObjString*)fSensorNames->At(i);
54  fMapOfSensorNames[SensName->GetString()] = i;
55  fMapOfSensorIndizes[i] = SensName->GetString();
56  }
57  }
58 
59  TString GetSensorName(Int_t index){
60 // if (index < fSensorNames->GetEntries()){
61 // TObjString* myString = (TObjString*)fSensorNames->At(index);
62 // return myString->GetString();
63 // }
64 // else{
65 // std::cout << "-E- PndSensorNamePar::GetSensorName index " << index
66 // << " out of bounds: " << fSensorNames->GetEntries() << std::endl;
67 // return "";
68 // }
69  std::map<Int_t, TString>::const_iterator iter;
70  iter = fMapOfSensorIndizes.find(index);
71  if (iter != fMapOfSensorIndizes.end()) {
72  return iter->second;
73  } else {
74  std::cout << "-E- PndSensorNamePar::GetSensorName index " << index << " not in list!";
75  return "";
76  }
77 
78  }
79 
80  TObjArray* GetSensorNames() const{return fSensorNames;}
81 
84 
85  private:
86  TObjArray* fSensorNames;
87  std::map<TString, Int_t> fMapOfSensorNames;
88  std::map<Int_t, TString> fMapOfSensorIndizes;
89 
90 
91 
93 };
94 
95 #endif