Skip to content

Commit

Permalink
Fix the DDPlanarDigi algorithm to run like the processor (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell authored Jul 7, 2024
1 parent 114d5d8 commit 281b93b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
26 changes: 2 additions & 24 deletions k4Reco/DDPlanarDigi/components/DDPlanarDigi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,15 @@
#include "edm4hep/TrackerHitPlaneCollection.h"

#include "Gaudi/Accumulators/RootHistogram.h"
#include "Gaudi/Histograming/Sink/Utils.h"

#include "DD4hep/BitFieldCoder.h"
#include "DD4hep/DD4hepUnits.h"
#include "DD4hep/Detector.h"
#include "DDSegmentation/BitFieldCoder.h"

#include "TFile.h"
#include "TMath.h"

#include <fmt/format.h>
#include <cmath>
#include <random>

DDPlanarDigi::DDPlanarDigi(const std::string& name, ISvcLocator* svcLoc)
: MultiTransformer(name, svcLoc,
Expand Down Expand Up @@ -156,7 +153,7 @@ std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::MCRecoTrackerAssociation
// Smear time of the hit and apply the time window cut if needed
double hitT = hit.getTime();

if (m_resTLayer.size() and m_resTLayer[0] > 0) {
if (m_resTLayer.size() && m_resTLayer[0] > 0) {
float resT = m_resTLayer.size() > 1 ? m_resTLayer[layer] : m_resTLayer[0];

double tSmear = resT > 0 ? m_engine.Gaus(0, resT) : 0;
Expand Down Expand Up @@ -312,22 +309,3 @@ std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::MCRecoTrackerAssociation

return std::make_tuple(std::move(trkhitVec), std::move(thsthcol));
}

StatusCode DDPlanarDigi::finalize() {
auto file = TFile::Open(m_outputFileName.value().c_str(), "RECREATE");
std::vector<const char*> names = {"hu", "hv", "hT", "hitE", "hitsAccepted", "diffu", "diffv", "diffT", "hSize"};
auto it = names.begin();
for (auto& h : m_histograms) {
std::string name = "";
// Name that will appear in the stats table
std::string histName = *it;
nlohmann::json json = *h;
auto [histo, dir] =
Gaudi::Histograming::Sink::jsonToRootHistogram<Gaudi::Histograming::Sink::Traits<false, TH1D, 1>>(
name, histName, json);
histo.Write(*it);
++it;
}
file->Close();
return StatusCode::SUCCESS;
}
4 changes: 1 addition & 3 deletions k4Reco/DDPlanarDigi/components/DDPlanarDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

#include "TRandom2.h"

#include <random>
#include <string>
#include <vector>

Expand Down Expand Up @@ -78,7 +77,6 @@ struct DDPlanarDigi final
DDPlanarDigi(const std::string& name, ISvcLocator* svcLoc);

StatusCode initialize() override;
StatusCode finalize() override;

std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::MCRecoTrackerAssociationCollection> operator()(
const edm4hep::SimTrackerHitCollection& simTrackerHits,
Expand All @@ -94,7 +92,7 @@ struct DDPlanarDigi final
Gaudi::Property<std::vector<float>> m_resTLayer{
this,
"ResolutionT",
{0.004},
{-1},
"Resolution in the direction of t; either one per layer or one for all layers. If the single entry is negative, "
"disable time smearing. "};
Gaudi::Property<bool> m_forceHitsOntoSurface{this, "ForceHitsOntoSurface", false,
Expand Down
8 changes: 7 additions & 1 deletion k4Reco/DDPlanarDigi/options/runDDPlanarDigi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from Configurables import DDPlanarDigi
from Configurables import GeoSvc
from Configurables import UniqueIDGenSvc
from Configurables import RootHistSvc
from Configurables import Gaudi__Histograming__Sink__Root as RootHistoSink
import os

id_service = UniqueIDGenSvc("UniqueIDGenSvc")
Expand Down Expand Up @@ -50,9 +52,13 @@
# "EventHeader",
# ]

hps = RootHistSvc("HistogramPersistencySvc")
root_hist_svc = RootHistoSink("RootHistoSink")
root_hist_svc.FileName = "ddplanardigi_hist.root"

ApplicationMgr(TopAlg=[digi],
EvtSel="NONE",
EvtMax=-1,
ExtSvc=[EventDataSvc("EventDataSvc")],
ExtSvc=[EventDataSvc("EventDataSvc"), root_hist_svc],
OutputLevel=INFO,
)

0 comments on commit 281b93b

Please sign in to comment.