2424#include " CCDB/CcdbApi.h"
2525#include " DetectorsCalibration/Utils.h"
2626
27+ #include " TPCQC/Clusters.h"
2728#include " TPCBase/Mapper.h"
2829#include " TPCCalibration/DigitDump.h"
2930#include " TPCReconstruction/RawReaderCRU.h"
@@ -43,6 +44,15 @@ class TPCDigitDumpDevice : public o2::framework::Task
4344
4445 void init (o2::framework::InitContext& ic) final
4546 {
47+ // parse command line arguments
48+ mMaxEvents = static_cast <uint32_t >(ic.options ().get <int >(" max-events" ));
49+ mUseOldSubspec = ic.options ().get <bool >(" use-old-subspec" );
50+ const bool createOccupancyMaps = ic.options ().get <bool >(" create-occupancy-maps" );
51+ mForceQuit = ic.options ().get <bool >(" force-quit" );
52+ if (mUseOldSubspec ) {
53+ LOGP (info, " Using old subspecification (CruId << 16) | ((LinkId + 1) << (CruEndPoint == 1 ? 8 : 0))" );
54+ }
55+
4656 // set up ADC value filling
4757 mRawReader .createReader (" " );
4858 mDigitDump .init ();
@@ -53,6 +63,11 @@ class TPCDigitDumpDevice : public o2::framework::Task
5363 mDigitDump .setPedestalAndNoiseFile (pedestalFile);
5464 }
5565
66+ // set up cluster qc if requested
67+ if (createOccupancyMaps) {
68+ mClusterQC = std::make_unique<qc::Clusters>();
69+ }
70+
5671 mRawReader .setADCDataCallback ([this ](const PadROCPos& padROCPos, const CRU& cru, const gsl::span<const uint32_t > data) -> int {
5772 const int timeBins = mDigitDump .update (padROCPos, cru, data);
5873 mDigitDump .setNumberOfProcessedTimeBins (std::max (mDigitDump .getNumberOfProcessedTimeBins (), size_t (timeBins)));
@@ -63,15 +78,11 @@ class TPCDigitDumpDevice : public o2::framework::Task
6378 CRU cruID (cru);
6479 const PadRegionInfo& regionInfo = Mapper::instance ().getPadRegionInfo (cruID.region ());
6580 mDigitDump .updateCRU (cruID, rowInSector - regionInfo.getGlobalRowOffset (), padInRow, timeBin, adcValue);
81+ if (mClusterQC ) {
82+ mClusterQC ->fillADCValue (cru, rowInSector, padInRow, timeBin, adcValue);
83+ }
6684 return true ;
6785 });
68-
69- mMaxEvents = static_cast <uint32_t >(ic.options ().get <int >(" max-events" ));
70- mUseOldSubspec = ic.options ().get <bool >(" use-old-subspec" );
71- mForceQuit = ic.options ().get <bool >(" force-quit" );
72- if (mUseOldSubspec ) {
73- LOGP (info, " Using old subspecification (CruId << 16) | ((LinkId + 1) << (CruEndPoint == 1 ? 8 : 0))" );
74- }
7586 }
7687
7788 void run (o2::framework::ProcessingContext& pc) final
@@ -89,7 +100,7 @@ class TPCDigitDumpDevice : public o2::framework::Task
89100
90101 snapshotDigits (pc.outputs ());
91102
92- if ((mDigitDump .getNumberOfProcessedEvents () >= mMaxEvents )) {
103+ if (mMaxEvents && (mDigitDump .getNumberOfProcessedEvents () >= mMaxEvents )) {
93104 LOGP (info, " Maximm number of events reached ({}), no more processing will be done" , mMaxEvents );
94105 mReadyToQuit = true ;
95106 if (mForceQuit ) {
@@ -108,12 +119,17 @@ class TPCDigitDumpDevice : public o2::framework::Task
108119 snapshotDigits (ec.outputs ());
109120 }
110121 ec.services ().get <ControlService>().readyToQuit (QuitRequest::Me);
122+
123+ if (mClusterQC ) {
124+ dumpClusterQC ();
125+ }
111126 }
112127
113128 private:
114129 DigitDump mDigitDump ;
130+ std::unique_ptr<qc::Clusters> mClusterQC ;
115131 rawreader::RawReaderCRUManager mRawReader ;
116- uint32_t mMaxEvents {100 };
132+ uint32_t mMaxEvents {0 };
117133 bool mReadyToQuit {false };
118134 bool mCalibDumped {false };
119135 bool mUseOldSubspec {false };
@@ -135,6 +151,13 @@ class TPCDigitDumpDevice : public o2::framework::Task
135151 mDigitDump .clearDigits ();
136152 mActiveSectors = 0 ;
137153 }
154+
155+ // ____________________________________________________________________________
156+ void dumpClusterQC ()
157+ {
158+ mClusterQC ->analyse ();
159+ mClusterQC ->dumpToFile (" ClusterQC.root" );
160+ }
138161};
139162
140163DataProcessorSpec getRawToDigitsSpec (int channel, const std::string inputSpec, std::vector<int > const & tpcSectors)
@@ -152,10 +175,11 @@ DataProcessorSpec getRawToDigitsSpec(int channel, const std::string inputSpec, s
152175 outputs,
153176 AlgorithmSpec{adaptFromTask<device>(tpcSectors)},
154177 Options{
155- {" max-events" , VariantType::Int, 100 , {" maximum number of events to process" }},
178+ {" max-events" , VariantType::Int, 0 , {" maximum number of events to process" }},
156179 {" use-old-subspec" , VariantType::Bool, false , {" use old subsecifiation definition" }},
157180 {" force-quit" , VariantType::Bool, false , {" force quit after max-events have been reached" }},
158181 {" pedestal-file" , VariantType::String, " " , {" file with pedestals and noise for zero suppression" }},
182+ {" create-occupancy-maps" , VariantType::Bool, false , {" create occupancy maps and store them to local root file for debugging" }},
159183 } // end Options
160184 }; // end DataProcessorSpec
161185}
0 commit comments