Commit ab83f1a7 authored by Whitney Armstrong's avatar Whitney Armstrong

Fix up other digi algos.

- Some were making the same casting mistake. That should be fixed now.
See !62 for
details.
- Missing headers.
- SOIPIXTrackerDigi same as UFSDTrackerDigi except with poor time
resolution

	modified:   ExampleCaloDigi.cpp
parent 2acda3c5
Pipeline #5292 passed with stages
in 9 minutes and 7 seconds
#include <algorithm>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/Producer.h"
......@@ -35,7 +36,7 @@ namespace Jug {
StatusCode initialize() override
{
IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
StatusCode sc = m_gaussDist.initialize(randSvc, Rndm::Gauss(0.0, m_energyResolution.value() ));
StatusCode sc = m_gaussDist.initialize(randSvc, Rndm::Gauss(0.0, m_energyResolution.value()));
if (!sc.isSuccess()) {
return StatusCode::FAILURE;
}
......@@ -55,7 +56,7 @@ namespace Jug {
double sqrtE = std::sqrt(ahit.energyDeposit()) ;
double aterm = m_gaussDist()*sqrtE;
eic::RawCalorimeterHit rawhit((long long)ahit.cellID(),
(long long)((ahit.energyDeposit() + aterm) * 1e6),
std::llround((ahit.energyDeposit() + aterm) * 1e6),
ahit.truth().time * 1e6);
rawhits->push_back(rawhit);
}
......
#include <algorithm>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/Producer.h"
......@@ -111,8 +112,7 @@ namespace Jug {
eic::RawCalorimeterHitCollection* rawHitCollection = new eic::RawCalorimeterHitCollection();
for(const auto& ahit : *simhits) {
//std::cout << ahit << "\n";
eic::RawCalorimeterHit rawhit((long long)ahit.cellID(),
(long long)ahit.energyDeposit() * 100, 0);
eic::RawCalorimeterHit rawhit((long long)ahit.cellID(), std::llround(ahit.energyDeposit() * 100), 0);
rawhits->push_back(rawhit);
}
return StatusCode::SUCCESS;
......
#include <algorithm>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/Producer.h"
......@@ -75,7 +76,7 @@ namespace Jug {
double bterm = ahit.energyDeposit()*m_gaussDist_b();
// here 1000 is arbitrary scale factor
eic::RawCalorimeterHit rawhit((long long)ahit.cellID(),
(long long)(ahit.energyDeposit() +aterm + bterm) * 1000, 0);
std::llround(ahit.energyDeposit() +aterm + bterm * 1000), 0);
rawhits->push_back(rawhit);
}
return StatusCode::SUCCESS;
......
......@@ -10,6 +10,7 @@
#include <iterator>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/GaudiTool.h"
......
#include <algorithm>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/RndmGenerators.h"
#include "GaudiKernel/Property.h"
// FCCSW
#include "JugBase/DataHandle.h"
......@@ -19,6 +22,12 @@ namespace Jug {
*
*/
class SOIPIXTrackerDigi : public GaudiAlgorithm {
public:
Gaudi::Property<double> m_timeResolution{this, "timeResolution", 1e3}; // ns -- todo add units
Rndm::Numbers m_gaussDist;
DataHandle<dd4pod::TrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this};
DataHandle<eic::RawTrackerHitCollection> m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this};
public:
// ill-formed: using GaudiAlgorithm::GaudiAlgorithm;
SOIPIXTrackerDigi(const std::string& name, ISvcLocator* svcLoc)
......@@ -27,7 +36,13 @@ namespace Jug {
declareProperty("outputHitCollection", m_outputHitCollection, "");
}
StatusCode initialize() override {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
if (GaudiAlgorithm::initialize().isFailure())
return StatusCode::FAILURE;
IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
StatusCode sc = m_gaussDist.initialize(randSvc, Rndm::Gauss(0.0, m_timeResolution.value()));
if (!sc.isSuccess()) {
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
StatusCode execute() override {
......@@ -35,18 +50,24 @@ namespace Jug {
const dd4pod::TrackerHitCollection* simhits = m_inputHitCollection.get();
// Create output collections
auto rawhits = m_outputHitCollection.createAndPut();
eic::RawTrackerHitCollection* rawHitCollection = new eic::RawTrackerHitCollection();
for(const auto& ahit : *simhits) {
//std::cout << ahit << "\n";
//eic::RawTrackerHit rawhit((long long)ahit.cellID(), (long long)ahit.cellID(),
// (long long)ahit.energyDeposit() * 100, 0);
//rawhits->push_back(rawhit);
std::map<long long, int> cell_hit_map;
for (const auto& ahit : *simhits) {
// std::cout << ahit << "\n";
if (cell_hit_map.count(ahit.cellID()) == 0) {
cell_hit_map[ahit.cellID()] = rawhits->size();
eic::RawTrackerHit rawhit((long long)ahit.cellID(),
ahit.truth().time * 1e6 + m_gaussDist() * 1e6, // ns->fs
std::llround(ahit.energyDeposit() * 1e6));
rawhits->push_back(rawhit);
} else {
auto hit = (*rawhits)[cell_hit_map[ahit.cellID()]];
hit.time(ahit.truth().time * 1e6 + m_gaussDist() * 1e3);
auto ch = hit.charge();
hit.charge(ch + std::llround(ahit.energyDeposit() * 1e6));
}
}
return StatusCode::SUCCESS;
}
DataHandle<dd4pod::TrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this};
DataHandle<eic::RawTrackerHitCollection> m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this};
};
DECLARE_COMPONENT(SOIPIXTrackerDigi)
......
#include <algorithm>
#include <cmath>
#include "GaudiAlg/Transformer.h"
#include "GaudiAlg/GaudiTool.h"
......@@ -24,7 +25,7 @@ namespace Jug::Digi {
*/
class UFSDTrackerDigi : public GaudiAlgorithm {
public:
Gaudi::Property<double> m_timeResolution{this, "timeResolution", 10};
Gaudi::Property<double> m_timeResolution{this, "timeResolution", 10}; // todo : add units
Rndm::Numbers m_gaussDist;
DataHandle<dd4pod::TrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader,
this};
......@@ -63,13 +64,13 @@ namespace Jug::Digi {
cell_hit_map[ahit.cellID()] = rawhits->size();
eic::RawTrackerHit rawhit((long long)ahit.cellID(),
ahit.truth().time * 1e6 + m_gaussDist() * 1e3, // ns->fs
int(ahit.energyDeposit() * 1e6));
std::llround(ahit.energyDeposit() * 1e6));
rawhits->push_back(rawhit);
} else {
auto hit = (*rawhits)[cell_hit_map[ahit.cellID()]];
hit.time(ahit.truth().time * 1e6 + m_gaussDist() * 1e3);
auto ch = hit.charge();
hit.charge(ch + int(ahit.energyDeposit() * 1e6));
hit.charge(ch + std::llround(ahit.energyDeposit() * 1e6));
}
}
return StatusCode::SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment