Skip to content

Commit

Permalink
MCLabels in clusters; Fix to read full raw payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitri Peresunko authored and shahor02 committed Mar 16, 2021
1 parent 91c0186 commit 45ba3a5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 254 deletions.
6 changes: 1 addition & 5 deletions DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,10 @@ class Cluster

float getTime() const { return mTime; }

int getLabel() const { return mLabel; } //Index in MCContainer entry
void setLabel(int l) { mLabel = l; }

protected:
char mMulDigit = 0; ///< Digit nultiplicity
char mModule = 0; ///< Module number
char mNExMax = -1; ///< number of (Ex-)maxima before unfolding
int mLabel = -1; ///< Ref to entry in MCTruthContainer with list of labels
float mLocalPosX = 0.; ///< Center of gravity position in local module coordunates (phi direction)
float mLocalPosZ = 0.; ///< Center of gravity position in local module coordunates (z direction)
float mFullEnergy = 0.; ///< full energy of a shower
Expand All @@ -82,7 +78,7 @@ class Cluster
float mTime = 0.; ///< Time of the digit with maximal energy deposition
float mDistToBadChannel = 999; ///< Distance to nearest bad crystal

ClassDefNV(Cluster, 1);
ClassDefNV(Cluster, 2);
};
} // namespace phos
} // namespace o2
Expand Down
7 changes: 4 additions & 3 deletions Detectors/PHOS/reconstruction/src/AltroDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ void AltroDecoder::readChannels()
int currentpos = 0;
auto& buffer = mRawReader.getPayload().getPayloadWords();

int payloadend = mRCUTrailer.getPayloadSize();
int payloadend = buffer.size() - mRCUTrailer.getTrailerSize(); //mRCUTrailer.getPayloadSize() was not updated in case of merged pages.
while (currentpos < payloadend) {
auto currentword = buffer[currentpos++];
ChannelHeader header = {currentword};

if (header.mMark != 1) {
LOG(ERROR) << "Channel header mark not found";
if (currentword != 0) {
LOG(ERROR) << "Channel header mark not found, header word " << currentword;
}
continue;
}
// starting a new channel
Expand Down
14 changes: 2 additions & 12 deletions Detectors/PHOS/reconstruction/src/Clusterer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void Clusterer::process(gsl::span<const Digit> digits, gsl::span<const TriggerRe
clusters->clear(); //final out list of clusters
trigRec->clear();
cluMC->clear();
mProcessMC = (dmc != nullptr);

for (const auto& tr : dtr) {
mFirstDigitInEvent = tr.getFirstEntry();
Expand Down Expand Up @@ -104,9 +105,7 @@ void Clusterer::processCells(gsl::span<const Cell> cells, gsl::span<const Trigge
cluMC->clear();
mProcessMC = (dmc != nullptr);
miCellLabel = 0;
printf("start clustering \n");
for (const auto& tr : ctr) {
printf(" tf=%d, %d \n", tr.getFirstEntry(), tr.getNumberOfObjects());
int firstCellInEvent = tr.getFirstEntry();
int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects();
int indexStart = clusters->size();
Expand All @@ -116,10 +115,8 @@ void Clusterer::processCells(gsl::span<const Cell> cells, gsl::span<const Trigge

if (mBadMap.get() == nullptr) {
if (o2::phos::PHOSSimParams::Instance().mCCDBPath.compare("localtest") == 0) {
mBadMap.reset(new BadChannelMap(1)); // test default map
printf("SetBadMap \n");
mBadMap.reset(new BadChannelMap(1)); // test default map
mCalibParams.reset(new CalibParams(1)); //test calibration map
printf("SetCalib \n");
LOG(INFO) << "No reading BadMap/Calibration from ccdb requested, set default";
} else {
// LOG(INFO) << "Getting BadMap object from ccdb";
Expand All @@ -137,22 +134,17 @@ void Clusterer::processCells(gsl::span<const Cell> cells, gsl::span<const Trigge
// // }
}
}
printf("converteing: %d, %d \n", firstCellInEvent, lastCellInEvent);
LOG(INFO) << "Converting ";
convertCellsToDigits(cells, firstCellInEvent, lastCellInEvent);
// Collect digits to clusters
printf("makeClu \n");
makeClusters(mDigits);
// Unfold overlapped clusters
// Split clusters with several local maxima if necessary
if (o2::phos::PHOSSimParams::Instance().mUnfoldClusters) {
makeUnfoldings(mDigits);
}
printf("cluprop \n");

// Calculate properties of collected clusters (Local position, energy, disp etc.)
evalCluProperties(mDigits, clusters, dmc, cluMC);
printf("cdone \n");

LOG(DEBUG) << "Found clusters from " << indexStart << " to " << clusters->size();

Expand Down Expand Up @@ -440,7 +432,6 @@ void Clusterer::evalCluProperties(gsl::span<const Digit> digits, std::vector<Clu
auto clu = mClusters.begin();

while (clu != mClusters.end()) {

if (clu->getEnergy() < 1.e-4) { //Marked earlier for removal
++clu;
continue;
Expand Down Expand Up @@ -498,7 +489,6 @@ void Clusterer::evalCluProperties(gsl::span<const Digit> digits, std::vector<Clu
}
++ll;
}
clusters->back().setLabel(labelIndex);
labelIndex++;
} // Work with MC
}
Expand Down
1 change: 0 additions & 1 deletion Detectors/PHOS/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

o2_add_library(PHOSWorkflow
SOURCES src/RecoWorkflow.cxx
src/PublisherSpec.cxx
src/ReaderSpec.cxx
src/CellConverterSpec.cxx
src/RawToCellConverterSpec.cxx
Expand Down
46 changes: 0 additions & 46 deletions Detectors/PHOS/workflow/include/PHOSWorkflow/PublisherSpec.h

This file was deleted.

6 changes: 0 additions & 6 deletions Detectors/PHOS/workflow/src/ClusterizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,16 @@ void ClusterizerSpec::run(framework::ProcessingContext& ctx)

LOG(DEBUG) << "PHOSClusterizer - run run on cells called";

printf("Getting cells \n");
auto cells = ctx.inputs().get<std::vector<o2::phos::Cell>>("cells");
// auto cells = ctx.inputs().get<gsl::span<o2::phos::Cell>>("cells");
LOG(DEBUG) << "[PHOSClusterizer - run] Received " << cells.size() << " cells, running clusterizer ...";
printf("Getting TR \n");
// auto cellsTR = ctx.inputs().get<gsl::span<o2::phos::TriggerRecord>>("cellTriggerRecords");
auto cellsTR = ctx.inputs().get<std::vector<o2::phos::TriggerRecord>>("cellTriggerRecords");
if (mPropagateMC) {
printf("Getting MC \n");
std::unique_ptr<const o2::dataformats::MCTruthContainer<o2::phos::MCLabel>> truthcont(ctx.inputs().get<o2::dataformats::MCTruthContainer<o2::phos::MCLabel>*>("cellsmctr"));
// truthmap = ctx.inputs().get<gsl::span<uint>>("cellssmcmap");
printf("Clustering \n");
mClusterizer.processCells(cells, cellsTR, truthcont.get(), &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont); // Find clusters on digits (pass by ref)
} else {
printf("Clustering2 \n");
mClusterizer.processCells(cells, cellsTR, nullptr, &mOutputClusters, &mOutputClusterTrigRecs, &mOutputTruthCont); // Find clusters on digits (pass by ref)
}
}
Expand All @@ -82,7 +77,6 @@ void ClusterizerSpec::run(framework::ProcessingContext& ctx)
if (mPropagateMC) {
ctx.outputs().snapshot(o2::framework::Output{"PHS", "CLUSTERTRUEMC", 0, o2::framework::Lifetime::Timeframe}, mOutputTruthCont);
}
LOG(INFO) << "Finished ";
ctx.services().get<o2::framework::ControlService>().readyToQuit(framework::QuitRequest::Me);
}

Expand Down
179 changes: 0 additions & 179 deletions Detectors/PHOS/workflow/src/PublisherSpec.cxx

This file was deleted.

4 changes: 2 additions & 2 deletions Detectors/PHOS/workflow/src/RecoWorkflow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ o2::framework::WorkflowSpec getWorkflow(bool disableRootInp,
}
if (isEnabled(OutputType::Clusters)) {
specs.emplace_back(o2::phos::reco_workflow::getRawToCellConverterSpec());
specs.emplace_back(o2::phos::reco_workflow::getClusterizerSpec(false)); //no MC propagation
specs.emplace_back(o2::phos::reco_workflow::getCellClusterizerSpec(false)); //no MC propagation
if (!disableRootOut) {
specs.emplace_back(o2::phos::getClusterWriterSpec(propagateMC));
specs.emplace_back(o2::phos::getClusterWriterSpec(false));
}
}
}
Expand Down

0 comments on commit 45ba3a5

Please sign in to comment.