Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sbndcode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ add_subdirectory(ChannelMaps)
add_subdirectory(SBNDCVN)

add_subdirectory(TPCPMTBarycenterMatching)

add_subdirectory(LightPropagationCorrection)
51 changes: 51 additions & 0 deletions sbndcode/LightPropagationCorrection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

set (
MODULE_LIBRARIES
art::Framework_Principal
art::Framework_Services_Registry
art_root_io::tfile_support
art_root_io::TFileService_service
art::Persistency_Common
art::Persistency_Provenance
art::Utilities

ROOT::Tree
ROOT::Core

larsim::Utils
larsim::MCCheater_BackTrackerService_service
larsim::MCCheater_ParticleInventoryService_service
lardata::DetectorInfoServices_DetectorClocksServiceStandard_service
larcore::Geometry_Geometry_service
larcorealg::Geometry
lardataobj::RawData
lardataobj::RecoBase
lardataobj::MCBase
lardataobj::Simulation
nusimdata::SimulationBase
nug4::ParticleNavigation

sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_SBND
sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays
sbndaq_artdaq_core::sbndaq-artdaq-core_Overlays_Common

sbndcode_OpDetReco_OpFlash_FlashFinder

sbnobj::Common_Reco
sbnobj::SBND_CRT
sbnobj::SBND_Timing
sbnobj::SBND_OpFlashTiming
sbndcode_OpDetSim
)

cet_build_plugin(LightPropagationCorrection art::module SOURCE LightPropagationCorrection_module.cc LIBRARIES ${MODULE_LIBRARIES})
cet_build_plugin(LightPropagationCorrectionAna art::module SOURCE LightPropagationCorrectionAna_module.cc LIBRARIES ${MODULE_LIBRARIES})

build_dictionary(DICTIONARY_LIBRARIES
lardataobj::RecoBase
canvas::canvas
)
add_subdirectory(job)
install_fhicl()
install_source()
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
////////////////////////////////////////////////////////////////////////
// Class: SBNDOpT0FinderAna
// Plugin Type: analyzer (art v3_05_01)
// File: SBNDOpT0FinderAna_module.cc
//
// Generated at Mon Oct 12 13:52:37 2020 by Marco Del Tutto using cetskelgen
// from cetlib version v3_10_00.
////////////////////////////////////////////////////////////////////////

#include "art/Framework/Core/EDAnalyzer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "canvas/Persistency/Common/FindManyP.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/OpFlash.h"
#include "sbnobj/SBND/OpFlashTiming/CorrectedOpFlashTiming.h"

#include "art_root_io/TFileService.h"

#include "TTree.h"

#include <numeric>

class LightPropagationCorrectionAna;


class LightPropagationCorrectionAna : public art::EDAnalyzer {
public:
explicit LightPropagationCorrectionAna(fhicl::ParameterSet const& p);
// The compiler-generated destructor is fine for non-base
// classes without bare pointers or other resource use.

// Plugins should not be copied or assigned.
LightPropagationCorrectionAna(LightPropagationCorrectionAna const&) = delete;
LightPropagationCorrectionAna(LightPropagationCorrectionAna&&) = delete;
LightPropagationCorrectionAna& operator=(LightPropagationCorrectionAna const&) = delete;
LightPropagationCorrectionAna& operator=(LightPropagationCorrectionAna&&) = delete;

// Required functions.
void analyze(art::Event const& e) override;
void beginJob() override;
private:

std::string fLightPropCorrectionLabel; ///< The light propagation correction label producer

TTree* fTree; ///< The TTree for storing event information

double fOpFlashT0;
double fUpstreamTime_lightonly;
double fUpstreamTime_tpczcorr;
double fUpstreamTime_propcorr_tpczcorr;

unsigned int _eventID;
unsigned int _runID;
unsigned int _subrunID;

};


LightPropagationCorrectionAna::LightPropagationCorrectionAna(fhicl::ParameterSet const& p)
: EDAnalyzer{p}
{
fLightPropCorrectionLabel = p.get<std::string>("LightPropCorrectionLabel");
}

void LightPropagationCorrectionAna::analyze(art::Event const& e)
{
fOpFlashT0=-99999.;
fUpstreamTime_lightonly=-99999.;
fUpstreamTime_tpczcorr=-99999.;
fUpstreamTime_propcorr_tpczcorr=-99999.;

_eventID = -1;
_runID = -1;
_subrunID = -1;

std::cout << "Run: " << e.id().run() << " Sub: " << e.id().subRun() << " Evt: " << e.id().event() << std::endl;

_eventID = e.id().event();
_runID = e.id().run();
_subrunID = e.id().subRun();

// Get all the T0 objects
::art::Handle<std::vector<sbnd::OpFlashTiming::CorrectedOpFlashTiming>> correctedopflash_h;
e.getByLabel(fLightPropCorrectionLabel, correctedopflash_h);
if(!correctedopflash_h.isValid() || correctedopflash_h->empty()) {
mf::LogWarning("fLightPropCorrectionLabel") << "No LightPropCorrectionLabel objects with label " << fLightPropCorrectionLabel << std::endl;
return;
}


std::vector<art::Ptr<sbnd::OpFlashTiming::CorrectedOpFlashTiming>> correctedopflash_v;
art::fill_ptr_vector(correctedopflash_v, correctedopflash_h);

// Get the T0->Slice association
art::FindManyP<recob::Slice> correctedflash_to_slices(correctedopflash_h, e, fLightPropCorrectionLabel);
art::FindManyP<recob::OpFlash> correctedflash_to_flashes(correctedopflash_h, e, fLightPropCorrectionLabel);

for (size_t i = 0; i < correctedopflash_v.size(); i++) {

// The T0 object
auto const correctedopflash = correctedopflash_v[i];

// The associations from T0 to both slices and flashes
std::vector<art::Ptr<recob::Slice>> slice_v = correctedflash_to_slices.at(correctedopflash.key());
std::vector<art::Ptr<recob::OpFlash>> flash_v = correctedflash_to_flashes.at(correctedopflash.key());

// One T0 object is always associated to one and only one Slice and Flash
assert(slice_v.size() == 1);
assert(flash_v.size() == 1);

std::cout << " Corrected flash time is " << correctedopflash->OpFlashT0 << std::endl;
std::cout << " Associated with slice id " << slice_v[0]->ID() << std::endl;
std::cout << "Corrected flash time light only " << correctedopflash->UpstreamTime_lightonly << std::endl;
std::cout << "Corrected flash time tpc z corr " << correctedopflash->UpstreamTime_tpczcorr << std::endl;
std::cout << "Corrected flash time prop corr tpc z corr " << correctedopflash->UpstreamTime_propcorr_tpczcorr << std::endl;

fOpFlashT0 = correctedopflash->OpFlashT0;
fUpstreamTime_lightonly = correctedopflash->UpstreamTime_lightonly;
fUpstreamTime_tpczcorr = correctedopflash->UpstreamTime_tpczcorr;
fUpstreamTime_propcorr_tpczcorr = correctedopflash->UpstreamTime_propcorr_tpczcorr;
fTree->Fill();
}
}

void LightPropagationCorrectionAna::beginJob()
{
// Implementation of optional member function here.
art::ServiceHandle<art::TFileService> tfs;
fTree = tfs->make<TTree>("LightPropagationCorrection", "Light Propagation Correction Tree");

fTree->Branch("eventID", &_eventID, "eventID/i");
fTree->Branch("runID", &_runID, "runID/i");
fTree->Branch("subrunID", &_subrunID, "subrunID/i");

fTree->Branch("fOpFlashT0", &fOpFlashT0, "OpFlashT0/d");
fTree->Branch("fUpstreamTime_lightonly", &fUpstreamTime_lightonly, "UpstreamTime_lightonly/d");
fTree->Branch("fUpstreamTime_tpczcorr", &fUpstreamTime_tpczcorr, "UpstreamTime_tpczcorr/d");
fTree->Branch("fUpstreamTime_propcorr_tpczcorr", &fUpstreamTime_propcorr_tpczcorr, "UpstreamTime_propcorr_tpczcorr/d");

}

DEFINE_ART_MODULE(LightPropagationCorrectionAna)
Loading