@@ -32,7 +32,9 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic)
3232{
3333
3434 mStatistics = ic.options ().get <int >(" statistics" ); // desired number of events
35-
35+ LOG (info) << " PHOS pedestal init: will collect " << mStatistics << " events" ;
36+ LOG (info) << " mUseCCDB (try to get current object) = " << mUseCCDB ;
37+ LOG (info) << " mForceUpdate (update CCDB anyway) =" << mForceUpdate ;
3638 // Create histograms for mean and RMS
3739 short n = o2::phos::Mapping::NCHANNELS - 1792 ;
3840 mMeanHG .reset (new TH2F (" MeanHighGain" , " MeanHighGain" , n, 1792.5 , n + 1792.5 , 100 , 0 ., 100 .));
@@ -43,14 +45,19 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic)
4345
4446void PHOSPedestalCalibDevice::run (o2::framework::ProcessingContext& ctx)
4547{
46- // scan Cells stream, collect mean and RMS then calculateaverage and post
48+ // scan Cells stream, collect mean and RMS then calculate average and post
49+
4750 if (mRunStartTime == 0 ) {
48- mRunStartTime = o2::header::get<o2::framework::DataProcessingHeader*>(ctx.inputs ().get (" cellTriggerRecords" ).header )->startTime ;
51+ const auto ref = ctx.inputs ().getFirstValid (true );
52+ mRunStartTime = DataRefUtils::getHeader<DataProcessingHeader*>(ref)->creation ; // approximate time in ms
4953 }
5054
5155 if (mStatistics <= 0 ) { // skip the rest of the run
5256 return ;
5357 }
58+ if (mStatistics % 100 == 0 ) {
59+ LOG (info) << mStatistics << " left to produce calibration" ;
60+ }
5461 auto cells = ctx.inputs ().get <gsl::span<o2::phos::Cell>>(" cells" );
5562 LOG (debug) << " [PHOSPedestalCalibDevice - run] Received " << cells.size () << " cells, running calibration ..." ;
5663 auto cellsTR = ctx.inputs ().get <gsl::span<o2::phos::TriggerRecord>>(" cellTriggerRecords" );
@@ -70,6 +77,7 @@ void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx)
7077 --mStatistics ;
7178 }
7279 if (mStatistics <= 0 ) {
80+ LOG (info) << " Start calculating pedestals" ;
7381 calculatePedestals ();
7482 checkPedestals ();
7583 sendOutput (ctx.outputs ());
@@ -107,6 +115,19 @@ void PHOSPedestalCalibDevice::sendOutput(DataAllocator& output)
107115 header::DataHeader::SubSpecificationType subSpec{(header::DataHeader::SubSpecificationType)0 };
108116 output.snapshot (Output{o2::calibration::Utils::gDataOriginCDBPayload , " PHOS_Pedestal" , subSpec}, *image.get ());
109117 output.snapshot (Output{o2::calibration::Utils::gDataOriginCDBWrapper , " PHOS_Pedestal" , subSpec}, info);
118+ // Now same for DCS as vector
119+ std::vector<short > dcsPedestals (2 * (o2::phos::Mapping::NCHANNELS - 1792 ));
120+ // copy HG then LG pedestals
121+ for (short absId = 1793 ; absId <= o2::phos::Mapping::NCHANNELS; absId++) {
122+ dcsPedestals.emplace_back (mPedestals ->getHGPedestal (absId));
123+ }
124+ for (short absId = 1793 ; absId <= o2::phos::Mapping::NCHANNELS; absId++) {
125+ dcsPedestals.emplace_back (mPedestals ->getLGPedestal (absId));
126+ }
127+ auto imageDCS = o2::ccdb::CcdbApi::createObjectImage (&dcsPedestals, &info);
128+ header::DataHeader::SubSpecificationType subSpec1{(header::DataHeader::SubSpecificationType)1 };
129+ output.snapshot (Output{o2::calibration::Utils::gDataOriginCDBPayload , " PHOS_Pedestal" , subSpec1}, *imageDCS.get ());
130+ output.snapshot (Output{o2::calibration::Utils::gDataOriginCDBWrapper , " PHOS_Pedestal" , subSpec1}, info);
110131 }
111132 // Anyway send change to QC
112133 LOG (info) << " [PHOSPedestalCalibDevice - run] Sending QC " ;
@@ -137,6 +158,7 @@ void PHOSPedestalCalibDevice::calculatePedestals()
137158 mPedestals ->setLGRMS (cellId, a);
138159 pr->Delete ();
139160 }
161+ LOG (info) << " Pedestals calculated" ;
140162}
141163
142164void PHOSPedestalCalibDevice::checkPedestals ()
0 commit comments