BmnRoot
Loading...
Searching...
No Matches
BmnSsdDigitize.cxx
Go to the documentation of this file.
1
6// Include class header
7#include "BmnSsdDigitize.h"
8
9// Includes from C++
10#include <cassert>
11#include <cstring>
12#include <fstream>
13#include <sstream>
14#include <sstream>
15#include <iomanip>
16#include <iostream>
17
18// Includes from ROOT
19#include "TClonesArray.h"
20#include "TGeoBBox.h"
21#include "TGeoMatrix.h"
22#include "TGeoPhysicalNode.h"
23#include "TGeoVolume.h"
24
25// Includes from FairRoot
26#include "FairEventHeader.h"
27#include "FairField.h"
28#include "FairLink.h"
29#include "FairLogger.h"
30#include "FairMCEventHeader.h"
31#include "FairMCPoint.h"
32#include "FairRunAna.h"
33#include "FairRunSim.h"
34#include "FairRuntimeDb.h"
35
36//#include "BmnDaqBuffer.h"
37#include "BmnDaqBuffer.h"
38// Includes from BmnRoot
39#include "CbmMCTrack.h"
40#include "BmnSsdDigi.h"
41#include "BmnSsdPoint.h"
42
43// Includes from SSD
44#include "setup/BmnSsdModule.h"
45#include "setup/BmnSsdSensor.h"
47#include "setup/BmnSsdSetup.h"
50
51using std::fixed;
52using std::right;
53using std::setprecision;
54using std::setw;
55using std::string;
56
58
64
66
67// ----- Standard constructor ------------------------------------------
69: BmnDigitize("SsdDigitize"),
70 fIsInitialised(kFALSE),
72 fUseLorentzShift(kTRUE),
73 fUseDiffusion(kTRUE),
74 fUseCrossTalk(kTRUE),
75 fGenerateNoise(kFALSE),
76 fDigiPar(NULL),
77 fSetup(NULL),
78 fPoints(NULL),
79 fTracks(NULL),
80 fDigis(NULL),
81 fMatches(NULL),
82 fTimer(),
83 fSensorDinact(0.12),
84 fSensorPitch(0.0058),
85 fSensorStereoF(0.),
86 fSensorStereoB(7.5),
87 fSensorVdep(70.),
88 fSensorVbias(140.),
89 fSensorTemperature(268.),
90 fSensorCcoupling(17.5),
91 fSensorCinterstrip(1.),
92 fModuleDynRange(75000.),
93 fModuleThreshold(3000.),
94 fModuleNofAdc(32),
95 fModuleTresol(5.),
96 fModuleTdead(800.),
97 fModuleNoise(1000.),
98 fModuleZeroNoiseRate(3.9789e-3),
99 fModuleFracDeadChan(0.),
100 fSensorParameterFile(),
101 fSensorConditionFile(),
102 fModuleParameterFile(),
103 fTimePointLast(-1.),
104 fTimeDigiFirst(-1.),
105 fTimeDigiLast(-1.),
106 fNofPoints(0),
107 fNofSignalsF(0),
108 fNofSignalsB(0),
109 fNofDigis(0),
110 fNofEvents(0),
111 fNofPointsTot(0.),
112 fNofSignalsFTot(0.),
113 fNofSignalsBTot(0.),
114 fNofDigisTot(0.),
115 fNofNoiseTot(0.),
116 fTimeTot()
117{
118 ResetCounters();
119}
120// -------------------------------------------------------------------------
121
122
123
124// ----- Destructor ----------------------------------------------------
126 LOG(debug) << "Destructing " << fName;
127 ResetArrays();
128 delete fDigis;
129 delete fMatches;
130}
131// -------------------------------------------------------------------------
132
133
134
135// ----- Content of analogue buffers -----------------------------------
136Int_t BmnSsdDigitize::BufferSize() const {
137 Int_t nSignals = 0;
138 Int_t nSigModule;
139 Double_t t1Module;
140 Double_t t2Module;
141
142 for (Int_t iModule = 0; iModule < fSetup->GetNofModules(); iModule++) {
143 fSetup->GetModule(iModule)->BufferStatus(nSigModule, t1Module, t2Module);
144 nSignals += nSigModule;
145 } //# modules in setup
146
147 return nSignals;
148}
149// -------------------------------------------------------------------------
150
151
152
153// ----- Print the status of the analogue buffers ----------------------
154string BmnSsdDigitize::BufferStatus() const {
155
156 Int_t nSignals = 0;
157 Double_t t1 = -1;
158 Double_t t2 = -1.;
159
160 Int_t nSigModule;
161 Double_t t1Module;
162 Double_t t2Module;
163
164 for (Int_t iModule = 0; iModule < fSetup->GetNofModules(); iModule++) {
165 fSetup->GetModule(iModule)->BufferStatus(nSigModule, t1Module, t2Module);
166 if ( nSigModule ) {
167 nSignals += nSigModule;
168 t1 = t1 < 0. ? t1Module : TMath::Min(t1, t1Module);
169 t2 = TMath::Max(t2, t2Module);
170 } //? signals in module buffer?
171 } //# modules in setup
172
173 std::stringstream ss;
174 ss << nSignals << ( nSignals == 1 ? " signal " : " signals " )
175 << "in analogue buffers";
176 if ( nSignals ) ss << " ( from " << fixed << setprecision(3)
177 << t1 << " ns to " << t2 << " ns )";
178 return ss.str();
179}
180// -------------------------------------------------------------------------
181
182
183
184// ----- Create a digi object ------------------------------------------
185void BmnSsdDigitize::CreateDigi(Int_t address, UShort_t channel,
186 Long64_t time,
187 UShort_t adc,
188 const BmnMatch& match) {
189
190 // Copy match object. Will be deleted in the digi destructor.
191 BmnMatch* digiMatch = new BmnMatch(match);
192
193 // Update times of first and last digi
194 fTimeDigiFirst = fNofDigis ?
195 TMath::Min(fTimeDigiFirst, Double_t(time)) : time;
196 fTimeDigiLast = TMath::Max(fTimeDigiLast, Double_t(time));
197
198 // Create digi
199 BmnSsdDigi* digi = new BmnSsdDigi(address, channel, time, adc);
200 digi->SetMatch(digiMatch);
201
202 // Send the digi to DAQ
203 SendDigi(digi);
204
205 fNofDigis++;
206 LOG(debug3) << GetName() << ": created digi at " << time
207 << " ns with ADC " << adc << " at address " << address
208 << " (module "
209 << fSetup->GetElement(address, kSsdModule)->GetName()
210 << ", channel " << channel
211 << ")";
212
213}
214// -------------------------------------------------------------------------
215
216
217
218// ----- Task execution ------------------------------------------------
219void BmnSsdDigitize::Exec(Option_t* /*opt*/) {
220
221 // --- Start timer and reset counters
222 fTimer.Start();
223 ResetCounters();
224
225 // --- For debug: status of analogue buffers
226 if ( gLogger->IsLogNeeded(DEBUG)) {
227 std::cout << std::endl;
228 LOG(debug) << GetName() << ": " << BufferStatus();
229 }
230
231 // --- Store previous event time. Get current event time.
232 Double_t eventTimePrevious = fCurrentEventTime;
233 GetEventInfo();
234
235 // --- Generate noise from previous to current event time
236 if ( fDigiPar->GetGenerateNoise() ) {
237 Int_t nNoise = 0;
238 Double_t tNoiseStart = fNofEvents ? eventTimePrevious : 0.;
239 Double_t tNoiseEnd = fCurrentEventTime;
240 for (Int_t iModule = 0; iModule < fSetup->GetNofModules(); iModule++)
241 nNoise += fSetup->GetModule(iModule)->GenerateNoise(tNoiseStart,
242 tNoiseEnd);
243 fNofNoiseTot += Double_t(nNoise);
244 LOG(info) << "+ " << setw(20) << GetName() << ": Generated " << nNoise
245 << " noise signals from t = " << tNoiseStart << " ns to "
246 << tNoiseEnd << " ns";
247 }
248
249 // --- Analogue response: Process the input array of SsdPoints
250 ProcessMCEvent();
251 LOG(debug) << GetName() << ": " << fNofSignalsF + fNofSignalsB
252 << " signals generated ( "
253 << fNofSignalsF << " / " << fNofSignalsB << " )"
254 ;
255 // --- For debug: status of analogue buffers
256 if ( gLogger->IsLogNeeded(DEBUG)) {
257 LOG(debug) << GetName() << ": " << BufferStatus();
258 }
259
260 // --- Readout time: in stream mode the time of the current event.
261 // --- Analogue buffers will be digitised for signals at times smaller than
262 // --- that time minus a safety margin depending on the module properties
263 // --- (dead time and time resolution). In event mode, the readout time
264 // --- is set to -1., meaning to digitise everything in the readout buffers.
265 Double_t readoutTime = fEventMode ? -1. : fCurrentEventTime;
266
267 // --- Digital response: Process buffers of all modules
268 ProcessAnalogBuffers(readoutTime);
269
270 // --- Check status of analogue module buffers
271 if ( gLogger->IsLogNeeded(DEBUG)) {
272 LOG(debug) << GetName() << ": " << BufferStatus();
273 }
274
275 // --- Event log
276 LOG(info) << "+ " << setw(15) << GetName() << ": Event " << setw(6)
277 << right << fCurrentEvent << " at " << fixed << setprecision(3)
278 << fCurrentEventTime << " ns, points: " << fNofPoints
279 << ", signals: " << fNofSignalsF << " / " << fNofSignalsB
280 << ", digis: " << fNofDigis << ". Exec time " << setprecision(6)
281 << fTimer.RealTime() << " s.";
282
283 // --- Counters
284 fTimer.Stop();
285 fNofEvents++;
286 fNofPointsTot += fNofPoints;
287 fNofSignalsFTot += fNofSignalsF;
288 fNofSignalsBTot += fNofSignalsB;
289 fNofDigisTot += fNofDigis;
290 fTimeTot += fTimer.RealTime();
291
292}
293// -------------------------------------------------------------------------
294
295
296
297// ----- Finish run ---------------------------------------------------
298void BmnSsdDigitize::Finish() {
299
300 // --- Start timer and reset counters
301 fTimer.Start();
302 ResetCounters();
303 Int_t nSignals;
304 Double_t t1;
305 Double_t t2;
306
307 // --- In event-by-event mode, the analogue buffers should be empty.
308 if ( fEventMode ) {
309 if ( BufferSize() ) {
310 LOG(info) << fName << BufferStatus();
311 LOG(fatal) << fName << ": Non-empty analogue buffers at end of event "
312 << " in event-by-event mode!";
313 } //? buffers not empty
314 } //? event-by-event mode
315
316 // --- In time-based mode: process the remaining signals in the buffers
317 else {
318 std::cout << std::endl;
319 LOG(info) << GetName() << ": Finish run";
320 LOG(info) << GetName() << ": " << BufferStatus()
321 ;
322 LOG(info) << GetName() << ": Processing analogue buffers"
323 ;
324
325 // --- Loop over all modules in the setup and process their buffers
326 for (Int_t iModule = 0; iModule < fSetup->GetNofModules(); iModule++)
327 fSetup->GetModule(iModule)->ProcessAnalogBuffer(-1.);
328
329 // --- Screen output
330 LOG(info) << GetName() << ": " << fNofDigis
331 << ( fNofDigis == 1 ? " digi " : " digis " )
332 << "created and sent to DAQ ";
333 if ( fNofDigis ) LOG(debug) << "( from " << fixed
334 << setprecision(3) << fTimeDigiFirst << " ns to "
335 << fTimeDigiLast << " ns )";
336 LOG(info);
337 LOG(info) << GetName() << ": " << BufferStatus()
338 ;
339 }
340
341 fTimer.Stop();
342 fNofPointsTot += fNofPoints;
343 fNofSignalsFTot += fNofSignalsF;
344 fNofSignalsBTot += fNofSignalsB;
345 fNofDigisTot += fNofDigis;
346 fTimeTot += fTimer.RealTime();
347
348 std::cout << std::endl;
349 LOG(info) << "=====================================";
350 LOG(info) << GetName() << ": Run summary";
351 LOG(info) << "Events processed : " << fNofEvents;
352 LOG(info) << "SsdPoint / event : " << setprecision(1)
353 << fNofPointsTot / Double_t(fNofEvents)
354 ;
355 LOG(info) << "Signals / event : "
356 << fNofSignalsFTot / Double_t(fNofEvents)
357 << " / " << fNofSignalsBTot / Double_t(fNofEvents)
358 ;
359 LOG(info) << "SsdDigi / event : "
360 << fNofDigisTot / Double_t(fNofEvents);
361 LOG(info) << "Digis per point : " << setprecision(6)
362 << fNofDigisTot / fNofPointsTot;
363 LOG(info) << "Digis per signal : "
364 << fNofDigisTot / ( fNofSignalsFTot + fNofSignalsBTot )
365 ;
366 LOG(info) << "Noise digis / event : " << fNofNoiseTot / Double_t(fNofEvents)
367 ;
368 LOG(info) << "Noise fraction : " << fNofNoiseTot / fNofDigisTot
369 ;
370 LOG(info) << "Real time per event : " << fTimeTot / Double_t(fNofEvents)
371 << " s";
372 LOG(info) << "=====================================";
373}
374// -------------------------------------------------------------------------
375
376
407{
408 fDigiPar = static_cast<BmnSsdDigitizeParameters*>(FairRunAna::Instance()->GetRuntimeDb()->getContainer("BmnSsdDigitizeParameters"));
409}
410
411
412// ----- Initialisation -----------------------------------------------
413InitStatus BmnSsdDigitize::Init() {
414
415 // Get and initialise the SSD setup interface
416 InitSetup();
417
418 // Screen output
419 std::cout << std::endl;
420 LOG(info) << "==========================================================";
421 LOG(info) << GetName() << ": Initialisation";
422
423 // Deactivate noise in event-by-event mode
424 if ( fEventMode ) {
425 LOG(info) << GetName() << ": Using event mode.";
426 SetGenerateNoise(kFALSE);
427 }
428
429 // Instantiate SsdPhysics
431
432 // --- Write physics settings to the parameter container. The default values
433 // --- are defined in the constructor; they may have been changed from the
434 // --- macro level by SetProcesses().
435 fDigiPar->SetProcesses(fEnergyLossModel, fUseLorentzShift, fUseDiffusion,
436 fUseCrossTalk, fGenerateNoise);
437
438 // --- Screen output of settings
439 LOG(info) << GetName() << ": " << fDigiPar->ToString();
440
441 // --- Get FairRootManager instance
442 FairRootManager* ioman = FairRootManager::Instance();
443 assert ( ioman );
444
445 // --- Get input array (BmnSsdPoint)
446 fPoints = (TClonesArray*) ioman->GetObject("SsdPoint");
447 assert ( fPoints );
448
449 // --- Get input array (CbmMCTrack)
450 fTracks = (TClonesArray*) ioman->GetObject("MCTrack");
451 assert ( fTracks );
452
453 // Register output array (SsdDigi)
454 fDigis = new TClonesArray("BmnSsdDigi",1000);
455 ioman->Register("SsdDigi", "SSD", fDigis,
456 IsOutputBranchPersistent("SsdDigi"));
457
458 // Register output array (SsdDigiMatch)
459 // For backward compatibility only; the match object is already member
460 // of BmnSsdDigi.
461 fMatches = new TClonesArray("BmnMatch", 1000);
462 ioman->Register("SsdDigiMatch", "SSD", fMatches,
463 IsOutputBranchPersistent("SsdDigiMatch"));
464
465
466 // --- Screen output
467 LOG(info) << GetName() << ": Initialisation successful"
468 ;
469 LOG(info) << "=========================================================="
470 ;
471 std::cout << std::endl;
472
473 // Set static initialisation flag
474 fIsInitialised = kTRUE;
475
476 return kSUCCESS;
477}
478// -------------------------------------------------------------------------
479
480
481
482// ----- Initialisation of setup --------------------------------------
484
485 // Get the SSD setup interface
486 fSetup = BmnSsdSetup::Instance();
487
488 // Register this task and the parameter container to the setup
489 fSetup->SetDigitizer(this);
491
492 // Set or read sensor parameters
493 fSetup->SetDefaultSensorParameters(fSensorDinact, fSensorPitch,
494 fSensorStereoF, fSensorStereoB);
495 if ( fSensorParameterFile.IsNull() ) fSetup->Init();
496 else fSetup->Init(nullptr, fSensorParameterFile);
497
498 // Set sensor conditions, global or from file
499 if ( fSensorConditionFile.IsNull() )
500 fSetup->SetSensorConditions(fSensorVdep, fSensorVbias,
501 fSensorTemperature, fSensorCcoupling,
502 fSensorCinterstrip);
503 else
504 fSetup->SetSensorConditions(fSensorConditionFile);
505
506 // Set module parameters, global or from file
507 if ( fModuleParameterFile.IsNull() )
508 fSetup->SetModuleParameters(fModuleDynRange, fModuleThreshold,
509 fModuleNofAdc, fModuleTresol, fModuleTdead,
510 fModuleNoise, fModuleZeroNoiseRate,
511 fModuleFracDeadChan);
512 else
513 fSetup->SetModuleParameters(fModuleParameterFile);
514
515}
516// -------------------------------------------------------------------------
517
518
519
520// ----- Process the analog buffers of all modules ---------------------
521void BmnSsdDigitize::ProcessAnalogBuffers(Double_t readoutTime) {
522
523 // --- Debug
524 LOG(debug) << GetName() << ": Processing analog buffers with readout "
525 << "time " << readoutTime << " ns";
526
527 // --- Loop over all modules in the setup and process their buffers
528 for (Int_t iModule = 0; iModule < fSetup->GetNofModules(); iModule++)
529 fSetup->GetModule(iModule)->ProcessAnalogBuffer(readoutTime);
530
531 // --- Debug output
532 LOG(debug) << GetName() << ": " << fNofDigis
533 << ( fNofDigis == 1 ? " digi " : " digis " )
534 << "created and sent to DAQ ";
535 if ( fNofDigis ) LOG(debug) << "( from " << fixed
536 << setprecision(3) << fTimeDigiFirst << " ns to "
537 << fTimeDigiLast << " ns )";
538 LOG(debug);
539
540}
541// -------------------------------------------------------------------------
542
543
544
545// ----- Process points from MC event ---------------------------------
546void BmnSsdDigitize::ProcessMCEvent() {
547
548 // --- MC Event info (input file, entry number, start time)
549 LOG(debug) << GetName() << ": Processing event " << fCurrentEvent
550 << " from input " << fCurrentInput << " at t = " << fCurrentEventTime
551 << " ns with " << fPoints->GetEntriesFast() << " SsdPoints "
552 ;
553
554
555 // --- Loop over all SsdPoints and execute the ProcessPoint method
556 assert ( fPoints );
557 for (Int_t iPoint=0; iPoint<fPoints->GetEntriesFast(); iPoint++) {
558 const BmnSsdPoint* point = (const BmnSsdPoint*) fPoints->At(iPoint);
559 BmnLink* link = new BmnLink(1., iPoint, fCurrentEvent, fCurrentInput);
560
561 // --- Discard secondaries if the respective flag is set
563 Int_t iTrack = point->GetTrackID();
564 if ( iTrack >= 0 ) { // MC track is present
565 CbmMCTrack* track = (CbmMCTrack*) fTracks->At(iTrack);
566 assert ( track );
567 if ( track->GetMotherId() >= 0 ) continue;
568 } //? MC track present
569 } //? discard secondaries
570
571 ProcessPoint(point, fCurrentEventTime, link);
572 fNofPoints++;
573 delete link;
574 } //# SsdPoints
575
576}
577// -------------------------------------------------------------------------
578
579
580
581// ----- Process a SsdPoint ---------------------------------------------
582void BmnSsdDigitize::ProcessPoint(const BmnSsdPoint* point,
583 Double_t eventTime, BmnLink* link) {
584
585 // Debug
586 if ( FairLogger::GetLogger()->IsLogNeeded(DEBUG2) ) point->Print();
587 LOG(debug2) << GetName() << ": Point coordinates: in (" << point->GetXIn()
588 << ", " << point->GetYIn() << ", " << point->GetZIn() << ")"
589 << ", out (" << point->GetXOut() << ", " << point->GetYOut()
590 << ", " << point->GetZOut() << ")";
591
592
593 // --- Get the sensor the point is in
594 Int_t address = point->GetDetectorID();
595 BmnSsdSensor* sensor = dynamic_cast<BmnSsdSensor*>
596 (fSetup->GetElement(address, kSsdSensor));
597 if ( ! sensor ) {
598 LOG(info) << GetName() << ": No sensor for address " << address
599 ;
600 LOG(info) << "Unit " << BmnSsdAddress::GetElementId(address, kSsdUnit);
601 LOG(info) << " Ladder " << BmnSsdAddress::GetElementId(address, kSsdLadder);
602 LOG(info) << " Half-ladder " << BmnSsdAddress::GetElementId(address, kSsdHalfLadder);
603 LOG(info) << " Module " << BmnSsdAddress::GetElementId(address, kSsdModule);
604 LOG(info) << " Sensor " << BmnSsdAddress::GetElementId(address, kSsdSensor);
605 LOG(info);
606 }
607 if ( ! sensor ) LOG(error) << GetName() << ": Sensor of SsdPoint not found!"
608 ;
609 assert(sensor);
610 LOG(debug2) << GetName() << ": Sending point to sensor "
611 << sensor->GetName() << " ( " << sensor->GetAddress()
612 << " ) ";
613
614 // --- Process the point on the sensor
615 Int_t status = sensor->ProcessPoint(point, eventTime, link);
616
617 // --- Statistics
618 Int_t nSignalsF = status / 1000;
619 Int_t nSignalsB = status - 1000 * nSignalsF;
620 LOG(debug2) << GetName() << ": Produced signals: "
621 << nSignalsF + nSignalsB << " ( " << nSignalsF << " / "
622 << nSignalsB << " )";
623 fNofSignalsF += nSignalsF;
624 fNofSignalsB += nSignalsB;
625
626}
627// -------------------------------------------------------------------------
628
629
630
631// ----- Private method ReInit -----------------------------------------
633
634 fSetup = BmnSsdSetup::Instance();
635
636 return kERROR;
637
638}
639// -------------------------------------------------------------------------
640
641
642
643// ----- Clear the output data arrays ----------------------------------
645 if ( fDigis ) fDigis->Delete();
646 if ( fMatches ) fMatches->Delete();
647}
648// -------------------------------------------------------------------------
649
650
651
652// ----- Reset event counters ------------------------------------------
653void BmnSsdDigitize::ResetCounters() {
654 fTimeDigiFirst = fTimeDigiLast = -1.;
655 fNofPoints = fNofSignalsF = fNofSignalsB = fNofDigis = 0;
656}
657// -------------------------------------------------------------------------
658
659
660
661// ----- Set the default module parameters -----------------------------
663 Double_t threshold,
664 Int_t nAdc,
665 Double_t timeResolution,
666 Double_t deadTime,
667 Double_t noise,
668 Double_t zeroNoiseRate,
669 Double_t fracDeadChan) {
670 assert( ! fIsInitialised );
671 assert( nAdc > 0 );
672 assert( fracDeadChan >= 0. && fracDeadChan <= 1.);
673 fModuleDynRange = dynRange;
674 fModuleThreshold = threshold;
675 fModuleNofAdc = nAdc;
676 fModuleTresol = timeResolution;
677 fModuleTdead = deadTime;
678 fModuleNoise = noise;
679 fModuleZeroNoiseRate = zeroNoiseRate;
680 fModuleFracDeadChan = fracDeadChan;
681}
682// -------------------------------------------------------------------------
683
684
685
686// ----- Set the default sensor conditions -----------------------------
688 Double_t vBias,
689 Double_t temperature,
690 Double_t cCoupling,
691 Double_t cInterstrip) {
692 assert( ! fIsInitialised );
693 fSensorVdep = vDep;
694 fSensorVbias = vBias;
695 fSensorTemperature = temperature;
696 fSensorCcoupling = cCoupling;
697 fSensorCinterstrip = cInterstrip;
698}
699// -------------------------------------------------------------------------
700
701
702
703// ----- Set the default sensor parameters -----------------------------
705 Double_t pitch,
706 Double_t stereoF,
707 Double_t stereoB) {
708 assert( ! fIsInitialised );
709 assert( dInact >= 0.);
710 assert( pitch >= 0. );
711 fSensorDinact = dInact;
712 fSensorPitch = pitch;
713 fSensorStereoF = stereoF;
714 fSensorStereoB = stereoB;
715}
716// -------------------------------------------------------------------------
717
718
719
720// ----- Activate noise generation -------------------------------------
722
723 if ( fIsInitialised ) {
724 LOG(error) << GetName() << ": physics processes must be set before "
725 << "initialisation! Statement will have no effect."
726 ;
727 return;
728 }
729
730 fGenerateNoise = choice;
731}
732// -------------------------------------------------------------------------
733
734
735
736// ----- Set sensor parameter file -------------------------------------
737void BmnSsdDigitize::SetModuleParameterFile(const char* fileName) {
738
739 assert( ! fIsInitialised );
740 fModuleParameterFile = fileName;
741
742}
743// -------------------------------------------------------------------------
744
745
746
747// ----- Set the digitisation parameters -------------------------------
748void BmnSsdDigitize::SetParameters(Double_t dynRange, Double_t threshold,
749 Int_t nAdc, Double_t timeResolution,
750 Double_t deadTime, Double_t noise,
751 Double_t zeroNoiseRate,
752 Double_t deadChannelFrac) {
753
754 if ( fIsInitialised ) {
755 LOG(error) << GetName() << ": physics processes must be set before "
756 << "initialisation! Statement will have no effect."
757 ;
758 return;
759 }
760 assert(fDigiPar);
761 fDigiPar->SetModuleParameters(dynRange, threshold, nAdc, timeResolution,
762 deadTime, noise, zeroNoiseRate,
763 deadChannelFrac);
764}
765// -------------------------------------------------------------------------
766
767
768
769// ----- Set the switches for physical processes for the analogue response
770void BmnSsdDigitize::SetProcesses(Int_t eLossModel,
771 Bool_t useLorentzShift,
772 Bool_t useDiffusion,
773 Bool_t useCrossTalk,
774 Bool_t generateNoise) {
775 if ( fIsInitialised ) {
776 LOG(error) << GetName() << ": physics processes must be set before "
777 << "initialisation! Statement will have no effect."
778 ;
779 return;
780 }
781 fEnergyLossModel = eLossModel;
782 fUseLorentzShift = useLorentzShift;
783 fUseDiffusion = useDiffusion;
784 fUseCrossTalk = useCrossTalk;
785 fGenerateNoise = generateNoise;
786}
787// -------------------------------------------------------------------------
788
789
790
791// ----- Set sensor condition file -------------------------------------
792void BmnSsdDigitize::SetSensorConditionFile(const char* fileName) {
793
794 if ( fIsInitialised ) {
795 LOG(fatal) << GetName()
796 <<": sensor conditions must be set before initialisation!"
797 ;
798 return;
799 }
800 fSensorConditionFile = fileName;
801
802}
803// -------------------------------------------------------------------------
804
805
806
807// ----- Set sensor parameter file -------------------------------------
808void BmnSsdDigitize::SetSensorParameterFile(const char* fileName) {
809
810 if ( fIsInitialised ) {
811 LOG(fatal) << GetName()
812 <<": sensor parameters must be set before initialisation!"
813 ;
814 return;
815 }
816 fSensorParameterFile = fileName;
817
818}
819// -------------------------------------------------------------------------
820
821
822
823// ----- Write a digi to the output array ------------------------------
825
826 // --- Assert that it is a SsdDigi
827 BmnSsdDigi* ssdDigi = dynamic_cast<BmnSsdDigi*>(digi);
828 if ( ! ssdDigi ) LOG(fatal) << fName
829 << ": not a valid SsdDigi pointer!";
830
831 assert(fDigis);
832 assert(fMatches);
833 Int_t nDigis = fDigis->GetEntriesFast();
834 new( (*fDigis)[nDigis] ) BmnSsdDigi(*ssdDigi);
835 new( (*fMatches)[nDigis] ) BmnMatch(*(ssdDigi->GetMatch()));
836
837}
838// -------------------------------------------------------------------------
@ kSsdLadder
@ kSsdUnit
@ kSsdSensor
@ kSsdModule
@ kSsdHalfLadder
Bool_t fUseCrossTalk
Bool_t fGenerateNoise
Bool_t fIsInitialised
kTRUE if Init() was called
Int_t fEnergyLossModel
Energy loss model.
BmnSsdDigitizeParameters * fDigiPar
Digitisation parameters.
Bool_t fUseDiffusion
Bool_t fUseLorentzShift
Base class for persistent representation of digital information.
Definition BmnDigi.h:44
BmnMatch * GetMatch() const
Definition BmnDigi.h:76
void SetMatch(BmnMatch *match)
Definition BmnDigi.h:88
Abstract base class for BMN digitisation tasks.
Definition BmnDigitize.h:23
Int_t fCurrentInput
Int_t fCurrentEvent
void GetEventInfo()
Get event information.
Double_t fCurrentEventTime
void SendDigi(BmnDigi *digi)
Send a digi object to the DAQ.
Bool_t fEventMode
Data class for a single-channel message in the SSD.
Definition BmnSsdDigi.h:27
Parameters for SSD digitization.
void SetModuleParameters(Double_t dynRange, Double_t threshold, Int_t nAdc, Double_t timeResol, Double_t deadTime, Double_t noise, Double_t zeroNoiseRate, Double_t deadChannelFrac)
Set digital response parameters.
void SetProcesses(Int_t eLossModel, Bool_t useLorentzShift, Bool_t useDiffusion, Bool_t useCrossTalk, Bool_t generateNoise=kFALSE)
Switch analogue response processes on or off.
virtual std::string ToString() const
void SetModuleParameterFile(const char *fileName)
Set the file name with module parameters.
virtual void Exec(Option_t *opt)
void SetParameters(Double_t dynRange, Double_t threshold, Int_t nAdc, Double_t timeResolution, Double_t deadTime, Double_t noise, Double_t zeroNoiseRate, Double_t deadChannelFrac=0.)
void SetProcesses(Int_t eLossModel, Bool_t useLorentzShift=kTRUE, Bool_t useDiffusion=kTRUE, Bool_t useCrossTalk=kTRUE, Bool_t generateNoise=kFALSE)
void CreateDigi(Int_t address, UShort_t channel, Long64_t time, UShort_t adc, const BmnMatch &match)
void SetDefaultSensorConditions(Double_t vDep, Double_t vBias, Double_t temperature, Double_t cCoupling, Double_t cInterstrip)
Set the default sensor conditions.
virtual InitStatus ReInit()
virtual void ResetArrays()
Clear data arrays.
virtual ~BmnSsdDigitize()
void SetSensorParameterFile(const char *fileName)
Set the file name with sensor parameters.
void SetGenerateNoise(Bool_t choise=kTRUE)
Activate noise generation.
void SetDefaultModuleParameters(Double_t dynRange, Double_t threshold, Int_t nAdc, Double_t timeResolution, Double_t deadTime, Double_t noise, Double_t zeroNoiseRate, Double_t fracDeadChan)
Set the default module parameters.
void SetDefaultSensorParameters(Double_t dInact, Double_t pitch, Double_t stereoF, Double_t stereoB)
Set the default sensor parameters.
virtual void WriteDigi(BmnDigi *digi)
Write a digi to the output tree.
virtual void SetParContainers()
Inherited from FairTask.
void SetSensorConditionFile(const char *fileName)
Set the file name with sensor conditions.
Int_t GetAddress() const
Int_t ProcessAnalogBuffer(Double_t readoutTime)
Int_t GenerateNoise(Double_t t1, Double_t t2)
Generate noise.
void BufferStatus(Int_t &nofSignals, Double_t &timeFirst, Double_t &timeLast)
static BmnSsdPhysics * Instance()
Double_t GetXIn() const
Definition BmnSsdPoint.h:74
Double_t GetYIn() const
Definition BmnSsdPoint.h:75
Double_t GetXOut() const
Definition BmnSsdPoint.h:77
Double_t GetZOut() const
Definition BmnSsdPoint.h:79
Double_t GetYOut() const
Definition BmnSsdPoint.h:78
Double_t GetZIn() const
Definition BmnSsdPoint.h:76
Class representing an instance of a sensor in the BMN-SSD.
Int_t ProcessPoint(const BmnSsdPoint *point, Double_t eventTime=0., BmnLink *link=NULL)
void SetDefaultSensorParameters(Double_t dInact, Double_t pitch, Double_t stereoF, Double_t stereoB)
Set the default sensor parameters.
static BmnSsdSetup * Instance()
Int_t SetModuleParameters(Double_t dynRange, Double_t threshold, Int_t nAdc, Double_t timeResolution, Double_t deadTime, Double_t noise, Double_t zeroNoiseRate, Double_t fracDeadChannels)
Set parameters for all modules.
void SetDigitizer(BmnSsdDigitize *digitizer)
Set the digitiser task.
Int_t GetNofModules() const
BmnSsdModule * GetModule(Int_t index)
Get a module from the module array.
Definition BmnSsdSetup.h:99
Bool_t Init(const char *geometryFile=nullptr, const char *sensorParameterFile=nullptr)
Initialise the setup.
Int_t SetSensorConditions()
Set conditions for all sensors (same values for all)
BmnSsdElement * GetElement(Int_t address, Int_t level)
void SetDigiParameters(BmnSsdDigitizeParameters *settings)
Set the digitiser parameters.
Int_t GetMotherId() const
Definition CbmMCTrack.h:57
UInt_t GetElementId(Int_t address, Int_t level)
Get the index of an element.