Skip to content

Commit

Permalink
[MCH] merged new pre-clustering code from https://github.com/pillot/A…
Browse files Browse the repository at this point in the history
…liceO2

Merged commits:
- ffafe2c (use o2::mch::Digit instead of DigitStruct (removed))
- 84c2c981b3b116cb56970e8c7e894ee95dfc5346 (use O2 mapping instead of external one)

The changes in the pre-clustering currently break the existing workflows and tests for the clustering code.
  • Loading branch information
alice-mch committed Mar 24, 2020
1 parent 1bb8393 commit 6b1049e
Show file tree
Hide file tree
Showing 23 changed files with 272 additions and 801 deletions.
7 changes: 3 additions & 4 deletions Detectors/MUON/MCH/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ o2_add_library(MCHBase
SOURCES
src/ClusterBlock.cxx
src/Digit.cxx
src/Mapping.cxx
src/PreClusterBlock.cxx
src/TrackBlock.cxx
PUBLIC_LINK_LIBRARIES ROOT::Core FairRoot::Base FairMQ::FairMQ O2::CommonDataFormat O2::GPUCommon O2::MCHMappingInterface O2::MCHMappingImpl3)
src/PreClusterBlock.cxx
src/TrackBlock.cxx
PUBLIC_LINK_LIBRARIES ROOT::Core FairRoot::Base FairMQ::FairMQ)

o2_target_root_dictionary(MCHBase
HEADERS include/MCHBase/Digit.h)
6 changes: 3 additions & 3 deletions Detectors/MUON/MCH/Base/include/MCHBase/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class Digit

bool operator==(const Digit&) const;

void setTimeStamp(double t) { mTime = t; }
double getTimeStamp() const { return mTime; }
void setTimeStamp(double t) { mTime = t; }

void setDetID(int i) { mDetID = i; }
int getDetID() const { return mDetID; }
void setDetID(int i) { mDetID = i; }

void setPadID(int i) { mPadID = i; }
int getPadID() const { return mPadID; }
void setPadID(int padID) { mPadID = padID; }

unsigned long getADC() const { return mADC; }
void setADC(unsigned long adc) { mADC = adc; }
Expand Down
17 changes: 6 additions & 11 deletions Detectors/MUON/MCH/Base/include/MCHBase/PreClusterBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace mch
* hit reconstruction and correlated into a common cluster.
*/
struct PreClusterStruct {
uint16_t nDigits; // number of digits attached to this precluster
const Digit* digits; // pointer to the 1st element of the array of digits
uint16_t nDigits; // number of digits attached to this precluster
Digit* digits; // pointer to the 1st element of the array of digits
};

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ class PreClusterBlock
/**
* Return the vector of preclusters currently stored in the data block.
*/
//const std::vector<PreClusterStruct>& getPreClusters() const { return mPreClusters; }
const std::vector<PreClusterStruct>& getPreClusters() const { return mPreClusters; }

/**
* Return the total size of the precluster blocks.
Expand All @@ -119,14 +119,9 @@ class PreClusterBlock
: 0;
}

uint32_t getPreClustersBufferSize(PreClusterFinder& finder);
void storePreClusters(PreClusterFinder& finder, char* buf);

/// read the buffer
int readBuffer(std::vector<PreClusterStruct>& preClusters);
void readPreClusters(std::vector<PreClusterStruct>& preClusters, char* buffer, uint32_t size);

private:
/// read the buffer
int readBuffer();

static constexpr uint32_t SSizeOfUShort = sizeof(uint16_t);
static constexpr uint32_t SSizeOfDigit = sizeof(Digit);
Expand All @@ -145,7 +140,7 @@ class PreClusterBlock
uint16_t* mNPreClusters = nullptr; ///< number of preclusters
uint16_t* mLastNDigits = nullptr; ///< number of digits in the last precluster (write mode)

//std::vector<PreClusterStruct> mPreClusters{}; ///< list of preclusters
std::vector<PreClusterStruct> mPreClusters{}; ///< list of preclusters
};

/// stream operator for printout
Expand Down
2 changes: 1 addition & 1 deletion Detectors/MUON/MCH/Clustering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

o2_add_library(MCHClustering
SOURCES src/ClusteringForTest.cxx src/MyObjectDigits.cxx src/MyObjectParametersMathieson.cxx src/MyObjectParametersGauss.cxx src/MyObjectParametersDoubleGauss.cxx
PUBLIC_LINK_LIBRARIES O2::MCHMappingInterface O2::SimulationDataFormat O2::MCHBase O2::Framework O2::MCHPreClustering)
PUBLIC_LINK_LIBRARIES O2::MCHMappingInterface O2::SimulationDataFormat O2::MCHBase O2::Framework O2::MCHPreClustering O2::MCHMappingInterface O2::MCHMappingFactory O2::MCHMappingImpl3)

o2_target_root_dictionary(MCHClustering
HEADERS include/MCHClustering/MyObjectDigits.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "MCHBase/Digit.h"
#include "MCHMappingInterface/Segmentation.h"
#include "MCHPreClustering/PreClusterBlock.h"
#include "MCHBase/PreClusterBlock.h"

namespace o2
{
Expand Down
4 changes: 2 additions & 2 deletions Detectors/MUON/MCH/Clustering/src/ClusteringForTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "MCHClustering/ClusteringForTest.h"
#include "MCHBase/Digit.h"
#include "MCHMappingInterface/Segmentation.h"
#include "MCHPreClustering/PreClusterFinder.h"
#include "MCHPreClustering/PreClusterBlock.h"
#//include "MCHPreClustering/PreClusterFinder.h"
#include "MCHBase/PreClusterBlock.h"
#include "TVirtualFitter.h"
#include "TObject.h"
#include "TObjArray.h"
Expand Down
8 changes: 5 additions & 3 deletions Detectors/MUON/MCH/PreClustering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
# submit itself to any jurisdiction.

o2_add_library(MCHPreClustering
SOURCES src/PreClusterFinderMapping.cxx src/PreClusterFinder.cxx src/PreClusterBlock.cxx
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat O2::MCHBase O2::Framework)
SOURCES src/PreClusterFinder.cxx
src/PreClusterFinderMapping.cxx
PUBLIC_LINK_LIBRARIES O2::MCHMappingFactory O2::MCHBase O2::Framework)

o2_add_executable(preclusterizer-workflow
COMPONENT_NAME mch
SOURCES src/PreClusterizerWorkflow.cxx
src/DigitSamplerSpec.cxx src/PreClusterFinderSpec.cxx
src/DigitSamplerSpec.cxx
src/PreClusterFinderSpec.cxx
src/PreClusterSinkSpec.cxx
PUBLIC_LINK_LIBRARIES O2::MCHPreClustering)
37 changes: 34 additions & 3 deletions Detectors/MUON/MCH/PreClustering/src/DigitSamplerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <iostream>
#include <fstream>

#include <string>
#include <stdexcept>

#include "Framework/CallbackService.h"
Expand All @@ -30,6 +31,8 @@

#include "MCHBase/Digit.h"

#include "MCHMappingFactory/CreateSegmentation.h"

namespace o2
{
namespace mch
Expand All @@ -53,6 +56,8 @@ class DigitSamplerTask
throw invalid_argument("Cannot open input file " + inputFileName);
}

mUseRun2DigitUID = ic.options().get<bool>("useRun2DigitUID");

auto stop = [this]() {
/// close the input file
LOG(INFO) << "stop digit sampler";
Expand Down Expand Up @@ -86,19 +91,44 @@ class DigitSamplerTask
memcpy(bufferPtr, &nDigits, SSizeOfInt);
bufferPtr += SSizeOfInt;

// fill digits if any
// fill digits in O2 format, if any
if (size > 0) {
mInputFile.read(bufferPtr, size);
if (mUseRun2DigitUID) {
convertDigitUID2PadID(reinterpret_cast<Digit*>(bufferPtr), nDigits);
}
} else {
LOG(INFO) << "event is empty";
}
}

private:
//_________________________________________________________________________________________________
void convertDigitUID2PadID(Digit* digits, int nDigits)
{
/// convert the digit UID in run2 format into a pad ID (i.e. index) in O2 mapping

for (int iDigit = 0; iDigit < nDigits; ++iDigit) {

int deID = digits[iDigit].getDetID();
int digitID = digits[iDigit].getPadID();
int manuID = (digitID & 0xFFF000) >> 12;
int manuCh = (digitID & 0x3F000000) >> 24;

int padID = mapping::segmentation(deID).findPadByFEE(manuID, manuCh);
if (padID < 0) {
throw runtime_error(std::string("digitID ") + digitID + " does not exist in the mapping");
}

digits[iDigit].setPadID(padID);
}
}

static constexpr uint32_t SSizeOfInt = sizeof(int);
static constexpr uint32_t SSizeOfDigit = sizeof(Digit);

std::ifstream mInputFile{}; ///< input file
std::ifstream mInputFile{}; ///< input file
bool mUseRun2DigitUID = false; ///< true if Digit.mPadID = digit UID in run2 format
};

//_________________________________________________________________________________________________
Expand All @@ -109,7 +139,8 @@ o2::framework::DataProcessorSpec getDigitSamplerSpec()
Inputs{},
Outputs{OutputSpec{"MCH", "DIGITS", 0, Lifetime::Timeframe}},
AlgorithmSpec{adaptFromTask<DigitSamplerTask>()},
Options{{"infile", VariantType::String, "", {"input file name"}}}};
Options{{"infile", VariantType::String, "", {"input file name"}},
{"useRun2DigitUID", VariantType::Bool, false, {"mPadID = digit UID in run2 format"}}}};
}

} // end namespace mch
Expand Down
Loading

0 comments on commit 6b1049e

Please sign in to comment.