FairRoot/PandaRoot
PndGemDigiPar.cxx
Go to the documentation of this file.
1 //* $Id: */
2 
3 // -------------------------------------------------------------------------
4 // ----- PndGemDigiPar source file -----
5 // ----- Created 12/02/2009 by R. Karabowicz -----
6 // -------------------------------------------------------------------------
7 
17 #include <iostream>
18 #include "PndGemDigiPar.h"
19 #include "PndDetectorList.h"
20 
21 using std::cout;
22 using std::endl;
23 using std::flush;
24 using std::map;
25 using std::pair;
26 
27 PndGemDigiPar::PndGemDigiPar(const char* name, const char* title, const char* context)
28  : FairParGenericSet(name,title,context),
29  fGemParameters(TArrayD()),
30  fStations(new TObjArray(10)),
31  fNSensors(0),
32  fNChannels(0),
33  fTrackFinderOnHits_ParThetaA(0.),
34  fTrackFinderOnHits_ParThetaB(0.),
35  fTrackFinderOnHits_ParTheta0(0.),
36  fTrackFinderOnHits_ParTheta1(0.),
37  fTrackFinderOnHits_ParTheta2(0.),
38  fTrackFinderOnHits_ParTheta3(0.),
39  fTrackFinderOnHits_ParRadPhi0(0.),
40  fTrackFinderOnHits_ParRadPhi2(0.),
41  fTrackFinderOnHits_ParMat0(TArrayD()),
42  fTrackFinderOnHits_ParMat1(TArrayD())
43 
44 {
45 
46 }
47 // -------------------------------------------------------------------------
48 
49 
50 // ----- Destructor ----------------------------------------------------
52  if ( fStations) {
53  fStations->Delete();
54  delete fStations;
55  }
56 }
57 // -------------------------------------------------------------------------
58 
59 
60 void PndGemDigiPar::putParams(FairParamList* list)
61 {
62  if(!list) return;
63  list->add("parameters", fGemParameters);
64 
65  list->add("TrackFinderOnHits_ParThetaA",fTrackFinderOnHits_ParThetaA);
66  list->add("TrackFinderOnHits_ParThetaB",fTrackFinderOnHits_ParThetaB);
67 
68  list->add("TrackFinderOnHits_ParTheta0",fTrackFinderOnHits_ParTheta0);
69  list->add("TrackFinderOnHits_ParTheta1",fTrackFinderOnHits_ParTheta1);
70  list->add("TrackFinderOnHits_ParTheta2",fTrackFinderOnHits_ParTheta2);
71  list->add("TrackFinderOnHits_ParTheta3",fTrackFinderOnHits_ParTheta3);
72 
73  list->add("TrackFinderOnHits_ParRadPhi0",fTrackFinderOnHits_ParRadPhi0);
74  list->add("TrackFinderOnHits_ParRadPhi2",fTrackFinderOnHits_ParRadPhi2);
75 
76  list->add("TrackFinderOnHits_ParMat0",fTrackFinderOnHits_ParMat0);
77  list->add("TrackFinderOnHits_ParMat1",fTrackFinderOnHits_ParMat1);
78 
79 }
80 
81 Bool_t PndGemDigiPar::getParams(FairParamList* list)
82 {
83  if (!list) {std::cout<<"list not found"<<std::endl; return kFALSE;}
84  if(!list->fill("parameters",&fGemParameters))
85  {std::cout<<"par: fGemParameters not found"<<std::endl; return kFALSE;}
86  if(!list->fill("TrackFinderOnHits_ParThetaA",&fTrackFinderOnHits_ParThetaA))
87  {std::cout<<"par: fTrackFinderOnHits_ParThetaA not found"<<std::endl; return kFALSE;}
88  if(!list->fill("TrackFinderOnHits_ParThetaB",&fTrackFinderOnHits_ParThetaB))
89  {std::cout<<"par: fTrackFinderOnHits_ParThetaB not found"<<std::endl; return kFALSE;}
90 
91  if(!list->fill("TrackFinderOnHits_ParTheta0",&fTrackFinderOnHits_ParTheta0))
92  {std::cout<<"par: fTrackFinderOnHits_ParTheta0 not found"<<std::endl; return kFALSE;}
93  if(!list->fill("TrackFinderOnHits_ParTheta1",&fTrackFinderOnHits_ParTheta1))
94  {std::cout<<"par: fTrackFinderOnHits_ParTheta1 not found"<<std::endl; return kFALSE;}
95  if(!list->fill("TrackFinderOnHits_ParTheta2",&fTrackFinderOnHits_ParTheta2))
96  {std::cout<<"par: fTrackFinderOnHits_ParTheta2 not found"<<std::endl; return kFALSE;}
97  if(!list->fill("TrackFinderOnHits_ParTheta3",&fTrackFinderOnHits_ParTheta3))
98  {std::cout<<"par: fTrackFinderOnHits_ParTheta3 not found"<<std::endl; return kFALSE;}
99 
100  if(!list->fill("TrackFinderOnHits_ParRadPhi0",&fTrackFinderOnHits_ParRadPhi0))
101  {std::cout<<"par: fTrackFinderOnHits_ParRadPhi0 not found"<<std::endl; return kFALSE;}
102  if(!list->fill("TrackFinderOnHits_ParRadPhi2",&fTrackFinderOnHits_ParRadPhi2))
103  {std::cout<<"par: fTrackFinderOnHits_ParRadPhi2 not found"<<std::endl; return kFALSE;}
104 
105  if(!list->fill("TrackFinderOnHits_ParMat0",&fTrackFinderOnHits_ParMat0))
106  {std::cout<<"par: fTrackFinderOnHits_ParMat0 not found"<<std::endl; return kFALSE;}
107  if(!list->fill("TrackFinderOnHits_ParMat1",&fTrackFinderOnHits_ParMat1))
108  {std::cout<<"par: fTrackFinderOnHits_ParMat1 not found"<<std::endl; return kFALSE;}
109 
110  CreateStations();
111 
112  return kTRUE;
113 }
114 
116 {
117  if ( GetNStations() > 0 ) return;
118  Int_t arrayIndex = 0;
119 
120  fNSensors = 0;
121  fNChannels = 0;
122 
123  Int_t stationNr = 0;
124  TString stationName = "";
125  Int_t nofSensors = 0;
126  Int_t sensorNr = 0;
127  TString sensorName = "";
128  PndGemStation* station = NULL;
129  PndGemSensor* sensor = NULL;
130 
131  while ( arrayIndex < fGemParameters.GetSize() ) {
132  stationNr = (Int_t)fGemParameters[arrayIndex+0];
133  stationName = Form("Gem_Station_%d",stationNr);
134 
135  station = new PndGemStation(stationName.Data(), stationNr, fGemParameters[arrayIndex+1], TMath::Pi()*fGemParameters[arrayIndex+2]/180. );
136 
137  fStations->Add(station);
138  fStationMap[stationNr] = station;
139 
140  arrayIndex += 4;
141 
142  nofSensors = (Int_t)fGemParameters[arrayIndex-1];
143 
144  for ( Int_t isec = 0 ; isec < nofSensors ; isec++ ) {
145  sensorNr = (Int_t)fGemParameters[arrayIndex+0];
146  // sensorName = Form("Gem_Disk%d_Gem%s_Sensor_kapton",stationNr,(sensorNr==1?"1":"6"));
147  sensorName = Form("Gem_Disk%d_Gem%s_Sensor_GEMmixture",stationNr,(sensorNr==1?"1":"6"));
148 
149  sensor = new PndGemSensor(sensorName.Data(), stationNr, sensorNr, (Int_t)fGemParameters[arrayIndex+1],
150  fGemParameters[arrayIndex+ 2], fGemParameters[arrayIndex+ 3], fGemParameters[arrayIndex+ 4],
151  -TMath::Pi()*fGemParameters[arrayIndex+ 5]/180.,
152  fGemParameters[arrayIndex+ 6], fGemParameters[arrayIndex+ 7],
153  fGemParameters[arrayIndex+ 8],
154  fGemParameters[arrayIndex+ 9], fGemParameters[arrayIndex+10],
155  fGemParameters[arrayIndex+11], fGemParameters[arrayIndex+12]);
156 
157  station->AddSensor(sensor);
158 
159  fNSensors ++;
160  fNChannels += sensor->GetNChannels();
161 
162  // put sensor into name/sensor map
163  map < TString, PndGemSensor*>::iterator p;
164  p=fSensorByName.find(sensorName.Data());
165  if(p!=fSensorByName.end()){
166  cout << " -E- Sensor \"" << sensorName.Data() << "\" is already inserted " << endl;
167  }else{
168  fSensorByName.insert(pair<TString, PndGemSensor*> (sensorName.Data(), sensor));
169  }
170  arrayIndex+=13;
171  }
172  }
173 }
174 
175 // ----- Public method GetStation --------------------------------------
177  return (PndGemStation*) fStations->At(iStation);
178 }
179 // -------------------------------------------------------------------------
180 
181 // ----- Public method GetNodeName -------------------------------------
183 //TString detN = Form("/cave_1/Gem_Disks_0/Gem_Disk%d_Volume_0/Gem_Disk%d_Seg%d_Gem%c_Sensor_kapton_0",
184  TString detN = Form("/cave_1/Gem_Disks_0/Gem_Disk%d_Volume_0/Gem_Disk%d_Seg%d_Gem%c_Sensor_GEMmixture_0",
185  GetStationNr(sensorId),
186  GetStationNr(sensorId),
187  GetSegmentNr(sensorId),
188  (GetSensorNr(sensorId)==1?'1':'6'));
189  return detN;
190 }
191 // -------------------------------------------------------------------------
192 
193 
194 // ------- Public method GetStationById --------------------------------
196  PndGemStation* station = (PndGemStation*) fStationMap[stationNr];
197  if ( ! station ) {
198  cout << "-W- PndGemDigiPar::GetStationByNr: "
199  << "No parameters found for station " << stationNr << endl;
200  return NULL;
201  }
202  return station;
203 }
204 // -------------------------------------------------------------------------
205 
206 
207 // ----- Public method GetDetectorIdByName ------------------------------
209 {
210  map < TString, Int_t>::iterator p;
211  p=fDetIdByName.find(sensorName);
212 
213  if(p!=fDetIdByName.end()){
214  return p->second;
215  }else{
216  cout << " -E- PndGemDigiPar::GetDetectorIdByName \"" << sensorName.Data() << "\" not found " << endl;
217  return -1;
218  }
219 }
220 // -------------------------------------------------------------------------
221 
222 // ----- Public method GetSensor ---------------------------------------
223 PndGemSensor* PndGemDigiPar::GetSensor(Int_t stationNr, Int_t sensorNr) {
224  PndGemStation* stat = (PndGemStation*)this->GetStation(stationNr-1);
225  return stat->GetSensor(sensorNr-1);
226  // return ( GetStationByNr(stationNr)->GetSensorByNr(sensorNr) );
227 }
228 // -------------------------------------------------------------------------
229 
230 // ----- Public method GetSensorIdByName --------------------------------
232 {
233  map < TString, PndGemSensor*>::iterator p;
234  p=fSensorByName.find(sensorName);
235 
236  if(p!=fSensorByName.end()){
237  return p->second;
238  }else{
239  cout << " -E- PndGemDigiPar::GetSensorByName \"" << sensorName.Data() << "\" not found " << endl;
240  return 0;
241  }
242 }
243 // -------------------------------------------------------------------------
244 
246 
248 {
249  cout << "-------------------------------------------------" << endl;
250  cout<<"GEM Digitization Parameters (" << fGemParameters.GetSize() << "):"<<endl;
251 
252  for ( Int_t iind = 0 ; iind < fGemParameters.GetSize() ; iind++ ) {
253  cout << fGemParameters[iind] << " " << flush;
254  if ( iind%30 == 3 ) cout << endl << " " << flush;
255  if ( iind%30 == 16 ) cout << endl << " " << flush;
256  if ( iind%30 == 29 ) cout << endl;
257  }
258  cout << "-------------------------------------------------" << endl;
259 }
Double_t fTrackFinderOnHits_ParThetaA
Definition: PndGemDigiPar.h:87
Double_t fTrackFinderOnHits_ParTheta0
Definition: PndGemDigiPar.h:90
std::map< TString, Int_t > fDetIdByName
Map from number to station.
PndTransMap * map
Definition: sim_emc_apd.C:99
std::map< Int_t, PndGemStation * > fStationMap
std::map< TString, PndGemSensor * > fSensorByName
TGeoVolume * sensor
void AddSensor(PndGemSensor *sensor)
Digitization Parameter Class for GEM part.
Definition: PndGemDigiPar.h:31
Int_t GetSensorNr(Int_t sensorId)
Definition: PndGemDigiPar.h:56
Bool_t getParams(FairParamList *list)
TArrayD fTrackFinderOnHits_ParMat0
Definition: PndGemDigiPar.h:98
PndGemSensor * GetSensor(Int_t iSensor)
Definition: PndGemStation.h:63
Int_t GetSegmentNr(Int_t sensorId)
Definition: PndGemDigiPar.h:58
Double_t p
Definition: anasim.C:58
PndGemDigiPar(const char *name="PndGemParTest", const char *title="PndGem digi parameter", const char *context="TestDefaultContext")
void putParams(FairParamList *list)
int isec
Definition: f_Init.h:19
Int_t GetDetectorIdByName(TString sensorName)
PndGemSensor * GetSensor(Int_t stationNr, Int_t sensorNr)
PndGemSensor * GetSensorByName(TString sensorName)
Double_t fTrackFinderOnHits_ParRadPhi0
Definition: PndGemDigiPar.h:95
TArrayD fTrackFinderOnHits_ParMat1
Definition: PndGemDigiPar.h:99
TArrayD fGemParameters
Definition: PndGemDigiPar.h:81
TString GetNodeName(Int_t sensorId)
ClassImp(PndGemDigiPar)
Double_t fTrackFinderOnHits_ParTheta1
Definition: PndGemDigiPar.h:91
Int_t GetNStations()
Definition: PndGemDigiPar.h:45
TString name
TObjArray * fStations
Definition: PndGemDigiPar.h:83
Int_t GetStationNr(Int_t sensorId)
Definition: PndGemDigiPar.h:54
Double_t fTrackFinderOnHits_ParThetaB
Definition: PndGemDigiPar.h:88
Double_t fTrackFinderOnHits_ParRadPhi2
Definition: PndGemDigiPar.h:96
Int_t GetNChannels() const
Definition: PndGemSensor.h:110
Double_t Pi
Double_t fTrackFinderOnHits_ParTheta3
Definition: PndGemDigiPar.h:93
Double_t fTrackFinderOnHits_ParTheta2
Definition: PndGemDigiPar.h:92
PndGemStation * GetStation(Int_t iStation)
PndGemStation * GetStationByNr(Int_t stationNr)