@@ -31,7 +31,8 @@ void Digitizer::init()
31
31
mCalibParams .reset (new CalibParams (1 )); // test default calibration
32
32
LOG (INFO) << " [CPVDigitizer] No reading calibration from ccdb requested, set default" ;
33
33
} else {
34
- LOG (INFO) << " [CPVDigitizer] can not gey calibration object from ccdb yet" ;
34
+ LOG (INFO) << " [CPVDigitizer] can not get calibration object from ccdb yet. Using default" ;
35
+ mCalibParams .reset (new CalibParams (1 )); // test default calibration
35
36
// o2::ccdb::CcdbApi ccdb;
36
37
// std::map<std::string, std::string> metadata; // do we want to store any meta data?
37
38
// ccdb.init("http://ccdb-test.cern.ch:8080"); // or http://localhost:8080 for a local installation
@@ -41,6 +42,45 @@ void Digitizer::init()
41
42
// }
42
43
}
43
44
}
45
+ if (!mPedestals ) {
46
+ if (o2::cpv::CPVSimParams::Instance ().mCCDBPath .compare (" localtest" ) == 0 ) {
47
+ mPedestals .reset (new Pedestals (1 )); // test default calibration
48
+ LOG (INFO) << " [CPVDigitizer] No reading calibration from ccdb requested, set default" ;
49
+ } else {
50
+ LOG (INFO) << " [CPVDigitizer] can not get pedestal object from ccdb yet. Using default" ;
51
+ mPedestals .reset (new Pedestals (1 )); // test default calibration
52
+ // o2::ccdb::CcdbApi ccdb;
53
+ // std::map<std::string, std::string> metadata; // do we want to store any meta data?
54
+ // ccdb.init("http://ccdb-test.cern.ch:8080"); // or http://localhost:8080 for a local installation
55
+ // mPedestals = ccdb.retrieveFromTFileAny<o2::cpv::Pedestals>("CPV/Calib", metadata, mEventTime);
56
+ // if (!mPedestals) {
57
+ // LOG(FATAL) << "[CPVDigitizer] can not get calibration object from ccdb";
58
+ // }
59
+ }
60
+ }
61
+ if (!mBadMap ) {
62
+ if (o2::cpv::CPVSimParams::Instance ().mCCDBPath .compare (" localtest" ) == 0 ) {
63
+ mBadMap .reset (new BadChannelMap (1 )); // test default calibration
64
+ LOG (INFO) << " [CPVDigitizer] No reading calibration from ccdb requested, set default" ;
65
+ } else {
66
+ LOG (INFO) << " [CPVDigitizer] can not get bad channel map object from ccdb yet. Using default" ;
67
+ mBadMap .reset (new BadChannelMap (1 )); // test default calibration
68
+ // o2::ccdb::CcdbApi ccdb;
69
+ // std::map<std::string, std::string> metadata; // do we want to store any meta data?
70
+ // ccdb.init("http://ccdb-test.cern.ch:8080"); // or http://localhost:8080 for a local installation
71
+ // mBadMap = ccdb.retrieveFromTFileAny<o2::cpv::BadChannelMap>("CPV/Calib", metadata, mEventTime);
72
+ // if (!mBadMap) {
73
+ // LOG(FATAL) << "[CPVDigitizer] can not get calibration object from ccdb";
74
+ // }
75
+ }
76
+ }
77
+
78
+ // signal thresolds for digits
79
+ // note that digits are calibrated objects
80
+ for (int i = 0 ; i < NCHANNELS; i++) {
81
+ mDigitThresholds [i] = o2::cpv::CPVSimParams::Instance ().mZSnSigmas *
82
+ mPedestals ->getPedSigma (i) * mCalibParams ->getGain (i);
83
+ }
44
84
}
45
85
46
86
// _______________________________________________________________________
@@ -60,14 +100,11 @@ void Digitizer::processHits(const std::vector<Hit>* hits, const std::vector<Digi
60
100
mArrayD [i].reset ();
61
101
}
62
102
63
- if (digitsBg.size () == 0 ) { // no digits provided: try simulate noise
103
+ if (digitsBg.size () == 0 ) { // no digits provided: try simulate pedestal noise (do it only once)
64
104
for (int i = NCHANNELS; i--;) {
65
- float energy = simulateNoise ();
66
- energy = uncalibrate (energy, i);
67
- if (energy > o2::cpv::CPVSimParams::Instance ().mZSthreshold ) {
68
- mArrayD [i].setAmplitude (energy);
69
- mArrayD [i].setAbsId (i);
70
- }
105
+ float amplitude = simulatePedestalNoise (i);
106
+ mArrayD [i].setAmplitude (amplitude);
107
+ mArrayD [i].setAbsId (i);
71
108
}
72
109
} else { // if digits exist, no noise should be added
73
110
for (auto & dBg : digitsBg) { // digits are sorted and unique
@@ -79,12 +116,12 @@ void Digitizer::processHits(const std::vector<Hit>* hits, const std::vector<Digi
79
116
for (auto & h : *hits) {
80
117
int i = h.GetDetectorID ();
81
118
if (mArrayD [i].getAmplitude () > 0 ) {
82
- mArrayD [i].setAmplitude (mArrayD [i].getAmplitude () + uncalibrate ( h.GetEnergyLoss (), i ));
119
+ mArrayD [i].setAmplitude (mArrayD [i].getAmplitude () + h.GetEnergyLoss ());
83
120
} else {
84
- mArrayD [i].setAmplitude (uncalibrate ( h.GetEnergyLoss (), i ));
121
+ mArrayD [i].setAmplitude (h.GetEnergyLoss ());
85
122
mArrayD [i].setAbsId (i);
86
123
}
87
- if (mArrayD [i].getAmplitude () > o2::cpv::CPVSimParams::Instance (). mZSthreshold ) {
124
+ if (mArrayD [i].getAmplitude () > mDigitThresholds [i] ) {
88
125
int labelIndex = mArrayD [i].getLabel ();
89
126
if (labelIndex == -1 ) { // no digit or noisy
90
127
labelIndex = labels.getIndexedSize ();
@@ -109,23 +146,22 @@ void Digitizer::processHits(const std::vector<Hit>* hits, const std::vector<Digi
109
146
}
110
147
}
111
148
149
+ // finalize output digits
112
150
for (int i = 0 ; i < NCHANNELS; i++) {
113
- if (mArrayD [i].getAmplitude () > o2::cpv::CPVSimParams::Instance ().mZSthreshold ) {
151
+ if (!mBadMap ->isChannelGood (i)) {
152
+ continue ; // bad channel -> skip this digit
153
+ }
154
+ if (mArrayD [i].getAmplitude () > mDigitThresholds [i]) {
114
155
digitsOut.push_back (mArrayD [i]);
115
156
}
116
157
}
117
158
}
118
159
119
- float Digitizer::simulateNoise () { return gRandom ->Gaus (0 ., o2::cpv::CPVSimParams::Instance ().mNoise ); }
120
-
121
- // _______________________________________________________________________
122
- float Digitizer::uncalibrate (const float e, const int absId)
160
+ float Digitizer::simulatePedestalNoise (int absId)
123
161
{
124
- // Decalibrate CPV digit, i.e. transform from amplitude to ADC counts a factor read from CDB
125
- float calib = mCalibParams ->getGain (absId);
126
- if (calib > 0 ) {
127
- return e / calib;
128
- } else {
129
- return 0 ; // TODO apply de-calibration from OCDB
162
+ // this function is to simulate pedestal and its noise (ADC counts)
163
+ if (absId < 0 || absId >= NCHANNELS) {
164
+ return 0 .;
130
165
}
166
+ return gRandom ->Gaus (0 , mPedestals ->getPedSigma (absId) * mCalibParams ->getGain (absId));
131
167
}
0 commit comments