FairRoot/PandaRoot
PndGemDigitize.cxx
Go to the documentation of this file.
1 //* $Id: */
2 
3 // -------------------------------------------------------------------------
4 // ----- PndGemDigitize source file -----
5 // ----- Created 12/02/2009 by R. Karabowicz -----
6 // -------------------------------------------------------------------------
7 
8 // Includes from GEM
9 #include "PndGemDigitize.h"
10 
11 // Includes from base
12 #include "FairRootManager.h"
13 #include "FairRunAna.h"
14 #include "FairRuntimeDb.h"
15 #include "FairLink.h"
16 
17 // Includes from ROOT
18 #include "TClonesArray.h"
19 #include "TObjArray.h"
20 #include "TMath.h"
21 #include "TGeoManager.h"
22 #include "TGeoNode.h"
23 
24 #include "PndDetectorList.h"
25 #include "PndGemHit.h"
26 #include "PndGemMCPoint.h"
27 #include "PndGemDigiPar.h"
28 #include "PndGemSensor.h"
29 #include "PndGemDigi.h"
31 
32 #include <iostream>
33 #include <iomanip>
34 #include <map>
35 
36 using std::cout;
37 using std::cerr;
38 using std::endl;
39 using std::pair;
40 using std::setw;
41 using std::left;
42 using std::right;
43 using std::fixed;
44 using std::setprecision;
45 using std::map;
46 
47 
48 
49 // ----- Default constructor ------------------------------------------
51  : PndPersistencyTask("GEM Digitizer", 0),
52  fDigiPar(NULL),
53  fPoints(NULL),
54  fDigis(NULL),
55  fDigiMatches(NULL),
56  fSSigma(0.03),
57  fSaveOutsideHits(kFALSE),
58  fHitOutsideArray(NULL),
59  fRealisticResponse(kFALSE),
60  fTNofEvents(0),
61  fTNofPoints(0),
62  fTNofDigis(0),
63  fRand(new TRandom2()),
64  fDataBuffer(0),
65  fTimeOrderedDigi(kFALSE)
66 {
67  SetPersistency(kTRUE);
68  Reset();
69 }
70 // -------------------------------------------------------------------------
71 
72 
73 
74 // ----- Standard constructor ------------------------------------------
76  : PndPersistencyTask("GEM Digitizer", iVerbose),
77  fDigiPar(NULL),
78  fPoints(NULL),
79  fDigis(NULL),
80  fDigiMatches(NULL),
81  fSSigma(0.03),
82  fSaveOutsideHits(kFALSE),
83  fHitOutsideArray(NULL),
84  fRealisticResponse(kFALSE),
85  fTNofEvents(0),
86  fTNofPoints(0),
87  fTNofDigis(0),
88  fRand(new TRandom2()),
89  fDataBuffer(0),
90  fTimeOrderedDigi(kFALSE)
91 {
92  SetPersistency(kTRUE);
93  Reset();
94 }
95 // -------------------------------------------------------------------------
96 
97 
98 
99 // ----- Constructor with name -----------------------------------------
101  : PndPersistencyTask(name, iVerbose),
102  fDigiPar(NULL),
103  fPoints(NULL),
104  fDigis(NULL),
105  fDigiMatches(NULL),
106  fSSigma(0.03),
107  fSaveOutsideHits(kFALSE),
108  fHitOutsideArray(NULL),
109  fRealisticResponse(kFALSE),
110  fTNofEvents(0),
111  fTNofPoints(0),
112  fTNofDigis(0),
113  fRand(new TRandom2()),
114  fDataBuffer(0),
115  fTimeOrderedDigi(kFALSE)
116 {
117  SetPersistency(kTRUE);
118  Reset();
119 }
120 // -------------------------------------------------------------------------
121 
122 
123 
124 // ----- Destructor ----------------------------------------------------
126  Reset();
127  if ( fDigiPar) delete fDigiPar;
128  if ( fDigis ) {
129  fDigis->Delete();
130  delete fDigis;
131  }
132  if ( fDigiMatches ) {
133  fDigiMatches->Delete();
134  delete fDigiMatches;
135  }
136 
137 }
138 // -------------------------------------------------------------------------
139 
140 // ----- Public method Exec --------------------------------------------
141 void PndGemDigitize::Exec(Option_t*) {
142 
143  if ( fSaveOutsideHits ) {
144  if ( ! fHitOutsideArray ) Fatal("Exec", "No fHitOutsideArray");
145  fHitOutsideArray->Delete();
146  }
147 
148  Reset();
149 
150  if ( fVerbose )
151  cout << "EVENT " << fTNofEvents << endl;
152 
153  fTNofEvents++;
154 
155  if ( fRealisticResponse )
157  else
158  DigitizeEvent();
159 
160  PndGemDigi* adigi;
161  Double_t EventTime = FairRootManager::Instance()->GetEventTime();
162  // cout << "---------------> Event " << fTNofEvents << endl;
163  // cout << "--- at " << EventTime << " ns" << endl;
164  // cout << "--- has " << fDigis->GetEntriesFast() << " digis made from " << fPoints->GetEntriesFast() << " points" << endl;
165  // cout << "---------------> Put them in output buffer" << endl;
166  if ( fVerbose ) {
167  cout << "---PndGemDigitize---> Event " << fTNofEvents
168  << " at " << EventTime << " ns"
169  << " has " << fDigis->GetEntriesFast() << " digis made from " << fPoints->GetEntriesFast() << " points" << endl;
170  }
171  // this loop should be done after each point, and not at the end of the event not to miss any late digis...
172  for ( Int_t idigi = 0 ; idigi < fDigis->GetEntriesFast() ; idigi++ ) {
173  adigi = dynamic_cast<PndGemDigi*>(fDigis->At(idigi));
174  adigi->SetTimeStamp(adigi->GetTimeStamp()+EventTime);
175  fDataBuffer->FillNewData(adigi,
176  adigi->GetTimeStamp(),
177  adigi->GetTimeStamp()+100.); // 100 ns dead time
178  // adigi->GetTimeStamp()+EventTime,
179  // adigi->GetTimeStamp()+EventTime+100.); // 100 ns dead time
180  }
181  // cout << "------------------------------------------" << endl;
182 }
183 // -------------------------------------------------------------------------
184 
185 // ----- Private method DigitizeEvent --------------------------------------------
187  if ( fVerbose > 0 ) cout << "-I- PndGemDigitize::DigitizeEvent()" << endl;
188 
190 
191  Int_t nofHitsOutside = 0;
192  Int_t nofPoints = fPoints->GetEntriesFast();
193 
194 // cout << "GEM digitize points:" << endl;
195 // for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
196 // PndGemMCPoint* currentPndGemMCPoint = (PndGemMCPoint*)fPoints->At(iPoint);
197 // cout << iPoint << " : "
198 // << currentPndGemMCPoint->GetX() << " "
199 // << currentPndGemMCPoint->GetY() << " "
200 // << currentPndGemMCPoint->GetZ() << endl;
201 // }
202 // cout << "GEM digis: " << endl;
203 
204  for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
205  PndGemMCPoint* currentPndGemMCPoint = (PndGemMCPoint*)fPoints->At(iPoint);
206 
207  Double_t posIn[3] = {0.5*(currentPndGemMCPoint->GetX()+currentPndGemMCPoint->GetXOut()),
208  0.5*(currentPndGemMCPoint->GetY()+currentPndGemMCPoint->GetYOut()),
209  currentPndGemMCPoint->GetZ()};
210 
211  Int_t sensorId = currentPndGemMCPoint->GetSensorId();
212 
213  TString nodeName = fDigiPar->GetNodeName(sensorId);
214 
215  gGeoManager->cd(nodeName.Data());
216  TGeoNode* curNode = gGeoManager->GetCurrentNode();
217 
218 // cout << "id " << sensorId << " -> "
219 // << fDigiPar->GetStationNr(sensorId) << "."
220 // << fDigiPar->GetSensorNr(sensorId) << "."
221 // << fDigiPar->GetSegmentNr(sensorId) << " > "
222 // << nodeName.Data() << endl;
223 
224  sensor = (PndGemSensor*)fDigiPar->GetSensor(sensorId);
225  if ( !sensor ) {
226  cout << " -E- " << GetName() << ":Exec() There is no sensor: \""
227  << nodeName.Data() << "\"." << endl;
228  continue;
229  }
230  Double_t locPosIn[4];
231 
232  fTNofPoints++;
233 
234  curNode->MasterToLocal(posIn,locPosIn);
235 
236  // cout << "position: " << posIn[0] << " " << posIn[1] << " " << posIn[2] << endl;
237  // << " transf to " << locPosIn[0] << " " << locPosIn[1] << " " << locPosIn[2] << endl;
238 
239  // if ( sensor->GetType()!=1 ) { locPosIn[3] = locPosIn[2]; locPosIn[2] = locPosIn[1]; locPosIn[1] = locPosIn[3]; locPosIn[0] = -locPosIn[0]; }
240 
241  Int_t sensorDetId = sensor->GetDetectorId();
242 
243  Int_t channelNumber = sensor->GetChannel(locPosIn[0],locPosIn[1],0);
244  if ( fDigiPar->GetStationNr(sensorId) == 1 ) {
245  // cout << sensor->GetType() << ": for point " << locPosIn[0] << " " << locPosIn[1] << " ---> channel " << channelNumber << endl;
246  }
247  if ( channelNumber == -1 ) {
248  if ( fSaveOutsideHits ) {
249  TVector3 pos;
250  currentPndGemMCPoint->Position(pos);
251  TVector3 dposLocal(0.,0.,0.);
252 
253 
254  //Int_t hitDetId = sensorDetId | kGemHit << 21; //[R.K. 01/2017] unused variable?
255 
256  new ((*fHitOutsideArray)[nofHitsOutside]) PndGemHit(sensorDetId,
257  pos,dposLocal,iPoint,currentPndGemMCPoint->GetEnergyLoss(),1);
258  }
259  nofHitsOutside++;
260  }
261  else {
262  ActivateChannel(sensorDetId,0,channelNumber,1,0.,iPoint);
263  }
264 
265  channelNumber = sensor->GetChannel(locPosIn[0],locPosIn[1],1);
266  if ( channelNumber == -1 ) continue;
267 
268  ActivateChannel(sensorDetId,1,channelNumber,1.,0.,iPoint);
269 
270  }
271 }
272 // -------------------------------------------------------------------------
273 
274 // ----- Private method DigitizeRealisticEvent --------------------------------------------
276  if ( fVerbose > 0 ) cout << "-I- PndGemDigitize::DigitizeRealisticEvent()" << endl;
277  // cout << "DRE " << fTNofEvents << endl;
278 
279  //Double_t showerSigma = 0.1; // radius of smearing, in cm
280  Double_t showerSigma = 0.03; // radius of smearing, in cm (based on Andrii's sim)
281  showerSigma = fSSigma;
282  //Double_t totalSignal = 100.; // total signal strength //[R.K. 01/2017] unused variable?
283  Double_t sigMult = 1.e6;
284 
285  if ( fVerbose > 1 ) {
286  cout << " showerSigma=" << showerSigma
287  << " sigMult=" << sigMult
288  << endl;
289  }
290 
292 
293  //Int_t nofHitsOutside = 0; //[R.K. 01/2017] unused variable?
294  Int_t nofPoints = fPoints->GetEntriesFast();
295 
296  // if ( fVerbose > 0 ) {
297  // cout << "GEM digitize points:" << endl;
298  // for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
299  // PndGemMCPoint* currentPndGemMCPoint = (PndGemMCPoint*)fPoints->At(iPoint); }
300  // cout << "GEM digis: " << endl;
301  // }
302 
303  if ( fVerbose ) {
304  cout << "GemDigiPar has "
305  << fDigiPar->GetNStations() << " stations, "
306  << fDigiPar->GetNSensors() << " sensors, "
307  << fDigiPar->GetNChannels() << " channels. "
308  << endl;
309  }
310 
311  for ( Int_t iPoint = 0 ; iPoint < nofPoints ; iPoint++ ) {
312  PndGemMCPoint* currentPndGemMCPoint = (PndGemMCPoint*)fPoints->At(iPoint);
313 
314  Double_t posIn[3] = {currentPndGemMCPoint->GetX(),
315  currentPndGemMCPoint->GetY(),
316  currentPndGemMCPoint->GetZ()};
317 
318  Int_t sensorId = currentPndGemMCPoint->GetSensorId();
319 
320  if ( fVerbose > 0 ) {
321  cout << iPoint << " : "
322  << currentPndGemMCPoint->GetX() << " "
323  << currentPndGemMCPoint->GetY() << " "
324  << currentPndGemMCPoint->GetZ() << " in sensor "
325  << sensorId << endl;
326  }
327 
328  //Double_t stripWidth; //[R.K. 01/2017] unused variable?
329 
330  TString nodeName = fDigiPar->GetNodeName(sensorId);
331 
332  if ( fVerbose > 0 ) {
333  cout << "got nodeName = \"" << nodeName.Data() << "\"" << endl;
334  }
335 
336  gGeoManager->cd(nodeName.Data());
337  TGeoNode* curNode = gGeoManager->GetCurrentNode();
338 
339 // cout << "id " << sensorId << " -> "
340 // << fDigiPar->GetStationNr(sensorId) << "."
341 // << fDigiPar->GetSensorNr(sensorId) << "."
342 // << fDigiPar->GetSegmentNr(sensorId) << " > "
343 // << nodeName.Data() << endl;
344  sensor = (PndGemSensor*)fDigiPar->GetSensor(sensorId);
345 
346  if ( !sensor ) {
347  cout << " -E- " << GetName() << ":Exec() There is no sensor: \""
348  << nodeName.Data() << "\"." << endl;
349  continue;
350  }
351  Double_t locPosIn[4];
352 
353  fTNofPoints++;
354 
355  curNode->MasterToLocal(posIn,locPosIn);
356 
357  if ( fVerbose ) {
358  cout << "position: " << posIn[0] << " " << posIn[1] << " " << posIn[2] << endl;
359  cout << " transf to " << locPosIn[0] << " " << locPosIn[1] << " " << locPosIn[2] << endl;
360  }
361 
362  // if ( sensor->GetType()!=1 ) { locPosIn[3] = locPosIn[2]; locPosIn[2] = locPosIn[1]; locPosIn[1] = locPosIn[3]; locPosIn[0] = -locPosIn[0]; }
363 
364  //Int_t sensorDetId = sensor->GetDetectorId(); //[R.K. 01/2017] unused variable?
365  //Double_t rectSig = 100.; //[R.K. 01/2017] unused variable?
366 
367  //Double_t channelInd = sensor->GetChannel(locPosIn[0],locPosIn[1],0,stripWidth);
368  //Int_t channelNumber = (Int_t)channelInd;
369 
370  // cout << "channelNumber = " << channelNumber << " / channelInd = " << channelInd << " / stripWidth = " << stripWidth << endl;
371 
372  // SimulateRectangularResponse(sensorDetId,0,channelInd,stripWidth,showerSigma,rectSig,iPoint);
373  // SimulateGaussianResponse(sensor,0,currentPndGemMCPoint,showerSigma,rectSig,iPoint);
374  SimulateGaussianResponse(sensor,0,currentPndGemMCPoint,showerSigma,sigMult*currentPndGemMCPoint->GetEnergyLoss(),iPoint);
375 
376  //channelInd = sensor->GetChannel(locPosIn[0],locPosIn[1],1,stripWidth);
377  //channelNumber = (Int_t)channelInd;
378 
379  // cout << "channelNumber = " << channelNumber << " / channelInd = " << channelInd << " / stripWidth = " << stripWidth << endl;
380 
381  // SimulateRectangularResponse(sensorDetId,1,channelInd,stripWidth,showerSigma,rectSig,iPoint);
382  //SimulateGaussianResponse(sensor,1,currentPndGemMCPoint,showerSigma,rectSig,iPoint);
383  SimulateGaussianResponse(sensor,1,currentPndGemMCPoint,showerSigma,sigMult*currentPndGemMCPoint->GetEnergyLoss(),iPoint);
384 
385  }
386 }
387 // -------------------------------------------------------------------------
388 
389 // ----- Private method SimulateGaussianResponse --------------------------------------------
390 void PndGemDigitize::SimulateGaussianResponse(PndGemSensor* sensor, Int_t side, PndGemMCPoint* gemPoint, Double_t showerSigma, Double_t showerStrength, Int_t iPoint) {
391  Double_t posIn [3] = {gemPoint->GetX(),
392  gemPoint->GetY(),
393  gemPoint->GetZ()};
394  Double_t posOut[3] = {gemPoint->GetXOut(),
395  gemPoint->GetYOut(),
396  gemPoint->GetZOut()};
397 
398  Int_t sensorDetId = sensor->GetDetectorId();
399 
400  Int_t sensorId = gemPoint->GetSensorId();
401  TString nodeName = fDigiPar->GetNodeName(sensorId);
402  gGeoManager->cd(nodeName.Data());
403  TGeoNode* curNode = gGeoManager->GetCurrentNode();
404 
405  Double_t locPosIn [4];
406  Double_t locPosOut[4];
407 
408  curNode->MasterToLocal(posIn ,locPosIn );
409  curNode->MasterToLocal(posOut,locPosOut);
410 
411  Double_t scanOrient = sensor->GetStripOrientation(locPosIn[0],locPosIn[1],side) + TMath::Pi()/2.;
412 
413  Double_t feeDist;
414  Int_t minChan = sensor->GetChannel2(locPosIn[0],
415  locPosIn[1],
416  side,feeDist);
417  Int_t maxChan = sensor->GetChannel2(locPosOut[0],
418  locPosOut[1],
419  side,feeDist);
420 
421  Int_t nofBBB = 1000+10*sensor->GetDistance(side,minChan,maxChan);
422 
423  Double_t unitSig = showerStrength/((Double_t)nofBBB);
424 
425  Double_t deltaPos[4];
426  for ( Int_t ico = 0 ; ico < 4 ; ico++ ) deltaPos[ico] = (locPosOut[ico] - locPosIn[ico])/((Double_t)(nofBBB));
427 
428  Int_t chanNr = sensor->GetChannel(locPosIn[0],locPosIn[1],side);
429 
430  Double_t time = gemPoint->GetTime();
431 
432  if ( scanOrient > TMath::TwoPi() )
433  scanOrient -= TMath::TwoPi();
434 
435  for ( Int_t ibbb = 0 ; ibbb < nofBBB ; ibbb++ ) {
436  Double_t dist = fRand->Gaus(0.,showerSigma);
437 
438  Double_t xloc = locPosIn[0]+ibbb*deltaPos[0]-dist*TMath::Sin(scanOrient);
439  Double_t yloc = locPosIn[1]+ibbb*deltaPos[1]+dist*TMath::Cos(scanOrient);
440  chanNr = sensor->GetChannel2(xloc,yloc,side,feeDist);
441  time = gemPoint->GetTime()+fRand->Gaus(5,0.5)+fRand->Gaus(feeDist/30.,0.5);
442  //time = fTNofEvents;
443  if ( chanNr == -1 ) continue;
444  ActivateChannel(sensorDetId,side,chanNr,unitSig,time,iPoint);
445  }
446 
447 }
448 // -------------------------------------------------------------------------
449 
450 // ----- Private method SimulateRectangularResponse --------------------------------------------
451 void PndGemDigitize::SimulateRectangularResponse(Int_t sensorDetId, Int_t side, Double_t channelInd, Double_t stripWidth, Double_t showerSigma, Double_t showerStrength, Int_t iPoint) {
452  Int_t channelNumber = (Int_t)channelInd;
453 
454  Double_t thisASig = 0.;
455 
456  Double_t leftSide = showerSigma;
457  Double_t leftTBin = (channelInd-(Double_t)channelNumber)*stripWidth;
458  Int_t leftChan = channelNumber;
459 
460  for ( Int_t ibin = 0 ; ibin < 50 ; ibin++ ) {
461  Double_t leftASig = leftTBin*showerStrength/showerSigma;
462  if ( leftTBin > leftSide ) {
463  leftASig = leftSide*showerStrength/showerSigma;
464  ibin = 100; // to finish the loop
465  }
466 
467  //cout << "Lwill activate channel " << leftChan << " with " << leftASig << endl;
468  if ( ibin == 0 )
469  thisASig += leftASig;
470  else
471  ActivateChannel(sensorDetId,side,leftChan,leftASig,0.,iPoint);
472 
473  leftSide = leftSide - leftTBin;
474  leftTBin = stripWidth;
475  leftChan -= 1;
476  }
477 
478  Double_t rightSide = showerSigma;
479  Double_t rightTBin = (1.+(Double_t)channelNumber-channelInd)*stripWidth;
480  Int_t rightChan = channelNumber;
481 
482  for ( Int_t ibin = 0 ; ibin < 50 ; ibin++ ) {
483  Double_t rightASig = rightTBin*showerStrength/showerSigma;
484  if ( rightTBin > rightSide ) {
485  rightASig = rightSide*showerStrength/showerSigma;
486  ibin = 100; // to finish the loop
487  }
488 
489  //cout << "Rwill activate channel " << rightChan << " with " << rightASig << endl;
490  if ( ibin == 0 )
491  thisASig += rightASig;
492  else
493  ActivateChannel(sensorDetId,side,rightChan,rightASig,0.,iPoint);
494 
495  rightSide = rightSide - rightTBin;
496  rightTBin = stripWidth;
497  rightChan += 1;
498  }
499  ActivateChannel(sensorDetId,side,channelNumber,thisASig,0.,iPoint);
500 }
501 // ------------------------------------------------------------------------
502 
503 // ----- Private method ActivateChannel -------------------------------
504 void PndGemDigitize::ActivateChannel(Int_t sensorDetId, Int_t sensorSide, Int_t channelNumber, Double_t signalHeight, Double_t signalTime, Int_t iPoint) {
505  Int_t digiDetId = sensorDetId | kGemDigi << 21 | sensorSide << 5;
506 
507  pair<Int_t, Int_t> a (digiDetId, channelNumber);
508  if ( fChannelMap.find(a) == fChannelMap.end() ) {
509  // Channel not yet active, create new digi
510 
511  // cout << fNDigis << " : " << sensorDetId << " " << channelNumber << endl;
512 
513  new ((*fDigis)[fNDigis]) PndGemDigi(digiDetId, channelNumber, iPoint, signalHeight, signalTime);
514 
515  fChannelMap[a] = fNDigis;
516  fNDigis++;
517  fTNofDigis++;
518  }
519  else {
520  Int_t iDigi = fChannelMap[a];
521  PndGemDigi* ddigi = dynamic_cast<PndGemDigi*>(fDigis->At(iDigi));
522 
523  ddigi->AddCharge(signalHeight);
524 
525  // cout << "another mc point to this digi, last one " << ddigi->GetIndex(ddigi->GetNIndices()-1) << ", now adding " << iPoint << endl;
526  ddigi->AddIndex(iPoint);
527  }
528 }
529 // -------------------------------------------------------------------------
530 
531 
532 // ----- Private method PrintDigis -------------------------------
534  Int_t nofDigis = fDigis->GetEntriesFast();
535  for ( Int_t idigi = 0 ; idigi < nofDigis ; idigi++ ) {
536  PndGemDigi* digiToDraw = (PndGemDigi*)fDigis->At(idigi);
537  Int_t digiStationNr = digiToDraw->GetStationNr();
538  Int_t digiSensorNr = digiToDraw->GetSensorNr();
539  Int_t digiSide = digiToDraw->GetSide();
540  Double_t channelNumber = digiToDraw->GetChannelNr();
541 
542  cout << "HAVE digi " << idigi << " at " << digiStationNr << "." << digiSensorNr << "." << digiSide << "." << channelNumber << " ( " << digiToDraw->GetDetectorId() << " ) with signal = " << digiToDraw->GetCharge() << endl;
543 
544  }
545 }
546 // -------------------------------------------------------------------------
547 
548 // ----- Private method SetParContainers -------------------------------
550 
551  // Get run and runtime database
552  FairRun* run = FairRun::Instance();
553  if ( ! run ) Fatal("SetParContainers", "No analysis run");
554 
555  FairRuntimeDb* db = run->GetRuntimeDb();
556  if ( ! db ) Fatal("SetParContainers", "No runtime database");
557 
558  // Get GEM digitisation parameter container
559  fDigiPar = (PndGemDigiPar*)(db->getContainer("PndGemDetectors"));
560 }
561 // -------------------------------------------------------------------------
562 
563 
564 
565 // ----- Private method Init -------------------------------------------
566 InitStatus PndGemDigitize::Init() {
567 
568  // Get input array
569  FairRootManager* ioman = FairRootManager::Instance();
570 
571  if ( ! ioman ) Fatal("Init", "No FairRootManager");
572  fPoints = (TClonesArray*) ioman->GetObject("GEMPoint");
573 
574  if ( fSaveOutsideHits ) {
575  fHitOutsideArray = new TClonesArray("PndGemHit");
576  ioman->Register("GEMOutsideHit", "PndGem Hits in inactive region",
578  }
579 
580  // Register output array StsDigi
581  fDigis = new TClonesArray("PndGemDigi",10000);
582  ioman->Register("GEMDigiNormal", "Digital response in GEM", fDigis, kFALSE);
583 
584  // Register output buffer
585  fDataBuffer = new PndGemDigiWriteoutBuffer("GEMDigi", "GEM", GetPersistency());
586  fDataBuffer = (PndGemDigiWriteoutBuffer*)ioman->RegisterWriteoutBuffer("GEMDigi", fDataBuffer);
587  fDataBuffer->ActivateBuffering(fTimeOrderedDigi);
588 
589  cout << "-I- " << fName.Data() << "::Init(). There are " << fDigiPar->GetNStations() << " GEM stations." << endl;
590  cout << "-I- " << fName.Data() << "::Init(). Initialization succesfull." << endl;
591  return kSUCCESS;
592 
593 }
594 // -------------------------------------------------------------------------
595 
596 
597 
598 // ----- Private method ReInit -----------------------------------------
600 
601  // Clear digitisation scheme
602  // fDigiScheme->Clear();
603 
604  // Build new digitisation scheme
605  // if ( fDigiScheme->Init(fGeoPar, fDigiPar) ) return kSUCCESS;
606 
607  return kSUCCESS;
608 
609 }
610 // -------------------------------------------------------------------------
611 
612 
613 
614 // ----- Private method Reset ------------------------------------------
617  fChannelMap.clear();
618  if ( fDigis ) fDigis->Delete();
619  if ( fDigiMatches ) fDigiMatches->Clear();
620 }
621 // -------------------------------------------------------------------------
622 
623 // ----- Public method Finish ------------------------------------------
625  if ( fDigis ) fDigis->Delete();
626 
627  cout << "-------------------- " << fName.Data() << " : Summary ------------------------" << endl;
628  cout << " Events: " << setw(10) << fTNofEvents << endl;
629  cout << " MC Points: " << setw(10) << fTNofPoints << " ( " << (Double_t)fTNofPoints/((Double_t)fTNofEvents) << " per event )" << endl;
630  cout << " Digis: " << setw(10) << fTNofDigis << " ( " << (Double_t)fTNofDigis /((Double_t)fTNofEvents) << " per event )" << endl;
631  cout << " --> ( " << (Double_t)fTNofDigis /((Double_t)fTNofEvents)/((Double_t)fDigiPar->GetNSensors()) << " per sensor )" << endl;
632  cout << " --> ( " << (Double_t)fTNofDigis /((Double_t)fTNofEvents)/((Double_t)fDigiPar->GetNChannels())*100. << "% occupancy )" << endl;
633  cout << " --> ( 2 x " << (Double_t)fTNofDigis /((Double_t)fTNofPoints)/2. << " per point )" << endl;
634  cout << "---------------------------------------------------------------------" << endl;
635 }
636 // -------------------------------------------------------------------------
637 
638 
639 
641 
TVector3 pos
virtual InitStatus Init()
Bool_t fSaveOutsideHits
int fVerbose
Definition: poormantracks.C:24
Int_t run
Definition: autocutx.C:47
TRandom2 * fRand
void SimulateGaussianResponse(PndGemSensor *sensor, Int_t side, PndGemMCPoint *gemPoint, Double_t showerSigma, Double_t showerStrength, Int_t iPoint)
void ActivateChannel(Int_t sensorDetId, Int_t sensorSide, Int_t channelNumber, Double_t signalHeight, Double_t signalTime, Int_t iPoint)
Int_t GetStationNr() const
Definition: PndGemDigi.h:84
PndTransMap * map
Definition: sim_emc_apd.C:99
TRandom3 fRand
Definition: full_core_ntp.C:28
static T Sin(const T &x)
Definition: PndCAMath.h:42
Double_t GetZOut() const
Definition: PndGemMCPoint.h:85
void SetPersistency(Bool_t val=kTRUE)
TGeoVolume * sensor
Digitization Parameter Class for GEM part.
Definition: PndGemDigiPar.h:31
Int_t GetDetectorId() const
Definition: PndGemDigi.h:79
TGeoManager * gGeoManager
static T Cos(const T &x)
Definition: PndCAMath.h:43
Double_t GetStripOrientation(Double_t x, Double_t y, Int_t iSide)
Int_t GetNChannels()
Definition: PndGemDigiPar.h:47
Int_t GetSensorNr() const
Definition: PndGemDigi.h:86
virtual void Exec(Option_t *opt)
virtual InitStatus ReInit()
Int_t a
Definition: anaLmdDigi.C:126
PndGemSensor * GetSensor(Int_t stationNr, Int_t sensorNr)
void AddCharge(Double_t iCharge)
Definition: PndGemDigi.h:76
Int_t GetSensorId() const
Definition: PndGemMCPoint.h:90
virtual void Finish()
Int_t GetChannel(Double_t x, Double_t y, Int_t iSide)
Double_t
void AddIndex(int index)
Definition: PndGemDigi.h:105
TString GetNodeName(Int_t sensorId)
Double_t GetDistance(Int_t iSide, Double_t chan1, Double_t chan2)
Int_t GetChannel2(Double_t x, Double_t y, Int_t iSide, Double_t &feeDist)
Double_t GetChannelNr() const
Definition: PndGemDigi.h:80
PndGemDigiWriteoutBuffer * fDataBuffer
PndGemDigiPar * fDigiPar
Double_t fSSigma
Int_t GetNStations()
Definition: PndGemDigiPar.h:45
TString name
Int_t GetNSensors()
Definition: PndGemDigiPar.h:46
TClonesArray * fDigis
Int_t GetStationNr(Int_t sensorId)
Definition: PndGemDigiPar.h:54
static float TwoPi()
Definition: PndCAMath.h:61
virtual void SetParContainers()
TClonesArray * fHitOutsideArray
virtual ~PndGemDigitize()
ClassImp(PndAnaContFact)
Int_t iVerbose
Double_t GetCharge() const
Definition: PndGemDigi.h:91
Int_t GetDetectorId() const
Definition: PndGemSensor.h:89
TClonesArray * fDigiMatches
void DigitizeRealisticEvent()
TClonesArray * fPoints
Double_t Pi
Double_t GetYOut() const
Definition: PndGemMCPoint.h:84
Double_t GetXOut() const
Definition: PndGemMCPoint.h:83
Int_t GetSide() const
Definition: PndGemDigi.h:88
std::map< std::pair< Int_t, Int_t >, Int_t > fChannelMap
void SimulateRectangularResponse(Int_t sensorDetId, Int_t side, Double_t channelInd, Double_t stripWidth, Double_t showerSigma, Double_t showerStrength, Int_t iPoint)
Bool_t fRealisticResponse
Bool_t fTimeOrderedDigi