Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
new raw decoding processor using ecal detector map
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Nov 30, 2021
1 parent 71c1c29 commit 2b13c9e
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/Ecal/EcalDetectorMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "DetDescr/EcalID.h"
#include "DetDescr/EcalElectronicsID.h"
#include "Tools/ElectronicsMap.h"

#include "Framework/ConditionsObject.h"
#include "Conditions/GeneralCSVLoader.h"
#include <vector>
Expand Down
47 changes: 47 additions & 0 deletions include/Ecal/EcalRawDecoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef ECAL_ECALRAWDECODER_H_
#define ECAL_ECALRAWDECODER_H_

//----------//
// LDMX //
//----------//
#include "Framework/EventProcessor.h"

namespace ecal {

/**
* @class EcalRawDecoder
*/
class EcalRawDecoder : public framework::Producer {
public:
/**
* Constructor
*/
EcalRawDecoder(const std::string& name, framework::Process& process);

/**
* Destructor
*/
virtual ~EcalRawDecoder();

/**
*/
virtual void configure(framework::config::Parameters&);

/**
*/
virtual void produce(framework::Event& event);

private:
/// input object of encoded data
std::string input_name_;
/// input pass of creating encoded data
std::string input_pass_;
/// output object to put onto event bus
std::string output_name_;
/// version of HGC ROC we are decoding
int roc_version_;

};
} // namespace ecal

#endif
71 changes: 71 additions & 0 deletions src/Ecal/EcalRawDecoder.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* @file EcalRawDecoder.cxx
* @brief Class that performs basic ECal digitization
* @author Cameron Bravo, SLAC National Accelerator Laboratory
* @author Tom Eichlersmith, University of Minnesota
*/

#include "Ecal/EcalRawDecoder.h"
#include "Recon/Event/HgcrocDigiCollection.h"
#include "Tools/HgcrocDecoder.h"
#include "DetDescr/EcalElectronicsID.h"
#include "DetDescr/EcalID.h"
#include "Ecal/EcalDetectorMap.h"

namespace ecal {

EcalRawDecoder::EcalRawDecoder(const std::string& name,
framework::Process& process)
: Producer(name, process) {
}

EcalRawDecoder::~EcalRawDecoder() {}

void EcalRawDecoder::configure(framework::config::Parameters& ps) {
input_name_ = ps.getParameter<std::string>("input_name");
input_pass_ = ps.getParameter<std::string>("input_pass");
output_name_ = ps.getParameter<std::string>("output_name");
roc_version_ = ps.getParameter<int>("roc_version");
}

void EcalRawDecoder::produce(framework::Event& event) {
/**
* Decoding of raw data
*
* First we unpack the encoded data into a map
* of electronic IDs to sets of timesamples.
* This is done by another utility class
*/
tools::HgcrocDecoder decoder{roc_version_};
auto eid_to_samples{
decoder.decode(event.getCollection<uint32_t>(input_name_, input_pass_))};

/**
* Translation
*
* Now the HgcrocDigiCollection::Sample class handles the
* unpacking of individual samples; however, we still need
* to translate electronic IDs into detector IDs.
*/
auto detmap{getCondition<EcalDetectorMap>(EcalDetectorMap::CONDITIONS_OBJECT_NAME).emap()};
ldmx::HgcrocDigiCollection digis;
for (auto const& [eid_raw, digi] : eid_to_samples) {
// TODO: This checking of existence should be temporary,
// the electronic ID mapping should be complete.
uint32_t did_raw{eid_raw};
ldmx::EcalElectronicsID eid{eid_raw};
if (detmap.exists(eid)) {
did_raw = detmap.get(eid).raw();
}

digis.addDigi(did_raw, digi);
}

event.add(output_name_, digis);

return;
} // produce

} // namespace ecal

DECLARE_PRODUCER_NS(ecal, EcalRawDecoder);

0 comments on commit 2b13c9e

Please sign in to comment.