Skip to content
Draft
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
54 changes: 54 additions & 0 deletions duneopdet/OpticalDetector/PhotonCalibratorDUNE.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// dunetpc includes
#include "duneopdet/OpticalDetector/PhotonCalibratorDUNE.h"

// LArSoft Includes
#include "larreco/Calibrator/IPhotonCalibrator.h"
#include "larcore/Geometry/Geometry.h"
#include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom()
#include "larcore/Geometry/WireReadout.h"

// ART includes
#include "fhiclcpp/ParameterSet.h"
#include "art/Framework/Services/Registry/ActivityRegistry.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Registry/ServiceMacros.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

#include <vector>
#include <algorithm>
#include <map>

namespace calib {

PhotonCalibratorDUNE::PhotonCalibratorDUNE(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg)
{

fBadChannels = pset.get<std::vector<int> >("BadChannels");
fHdwChannels = pset.get<std::vector<int> >("HdwChannels");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fHdwChannels a good name? I know there are different channel definitions and I think what is passed to the calibrator is the "offline channel" number/ID. I don't know if this is the standard naming, but the Hdw prefix makes me thing about the numbering defined by the hardware people.

fSPEAreas = pset.get<std::vector<float> >("SPEAreas");
fSPEShifts = pset.get<std::vector<float> >("SPEShifts");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these fSPEShifts can be empty by default? They would only be applied if they were specified. Thus lines 47 and 48 would be conditional. It would prevent the "expensive" look up in the map if not necessary.


//Map for associating each hardware channel with its correspondent SPE area
for(size_t i=0; i<fHdwChannels.size();i++){
fAreaMap.emplace(fHdwChannels[i], fSPEAreas[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two maps could be defined as a single map of pairs. This would remove extra lookup.

fShiftMap.emplace(fHdwChannels[i], fSPEShifts[i]);
}

}

double PhotonCalibratorDUNE::PE(double adcs, int opchannel) const
{
if (std::find(fBadChannels.begin(), fBadChannels.end(), opchannel) != fBadChannels.end()) {
mf::LogDebug("PhotonCalibratorDUNE") << "Skipping bad channel " << opchannel;
return 0;
}
auto entry = fAreaMap.find(opchannel);
float area = entry->second;
auto entry2 = fShiftMap.find(opchannel);
float shift = entry2->second;
return adcs/area + shift;
}

}

//DEFINE_ART_SERVICE_INTERFACE_IMPL(calib::PhotonCalibratorDUNE, calib::IPhotonCalibrator)
31 changes: 31 additions & 0 deletions duneopdet/OpticalDetector/PhotonCalibratorDUNE.fcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BEGIN_PROLOG

#
# Applies channel-by-channel PE calibrations
#
#Data taken between ???
protodunevd_photoncalibrator_config_beam_v100:
{
service_provider: PhotonCalibratorServiceDUNE
BadChannels: [ ]
HdwChannels: [ 1010, 1011, 1020, 1021, 1030, 1031, 1040, 1041, 1050, 1051, 1060, 1061, 1070, 1071, 1080, 1081, 2010, 2011, 2020, 2021, 2030, 2031, 2040, 2041, 2050, 2051, 2060, 2061, 2070, 2071, 2080, 2081, 3010, 3020, 3030, 3040, 3050, 3060, 3070, 3080, 3090, 3100, 3110, 3120, 3130, 3140, 3150, 3160, 3170, 3180, 3190, 3200, 3210, 3220, 3230, 3240 ] #hardware channels as in the PDVD_PDS_Mapping (in dunecore/ChannelMap)
SPEShifts: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SPEAreas: [ 3482.9, 1893.97, 2148.87, 4332.16, 2063.53, 2000, 2257.92, 2530.51, 5225.09, 5185.5, 2426.86, 2685.4, 3831.38, 3567.7, 1526.98, 1258.39, 2000, 2000, 2000, 2000, 3147.79, 3278.53, 1380.77, 2205.66, 4364.88, 4221.51, 3058.11, 3009.3, 2634.38, 2557.6, 3771.75, 3723.89, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] #channel correspondence can be found in the PDVD_PDS_Mapping found in dunecore/ChannelMap. Values from waffles/np02_data/calibration_data --> STILL TO BE OBTAINED. DO NOT USE

}

#Data taken between July 10th - 16th
protodunevd_photoncalibrator_config_beam_v200: @local::protodunevd_photoncalibrator_config_beam_v100
protodunevd_photoncalibrator_config_beam_v200.SPEAreas: [ 3450.06, 1950.04, 2138.67, 4251.92, 2063.53, 2000, 2336.25, 2197.08, 5225.09, 5185.5, 2426.86, 2685.4, 3831.38, 3567.7, 1526.98, 1258.39, 2000, 2000, 2000, 2000, 2794.99, 2732.12, 2073.26, 1948.84, 4302.94, 4255.39, 2900.88, 2826.3, 3238.6, 3074.78, 3669.16, 3723.37, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] #Values from waffles/np02_data/calibration_data/ --> STILL TO BE OBTAINED. DO NOT USE

#Data taken between August 2nd - 8th
protodunevd_photoncalibrator_config_beam_v300: @local::protodunevd_photoncalibrator_config_beam_v100
protodunevd_photoncalibrator_config_beam_v300.SPEAreas: [ 215.63, 121.88, 133.67, 265.75, 128.97, 125.00, 146.02, 137.32, 326.57, 324.09, 151.68, 167.84, 239.46, 222.98, 95.44, 78.65, 125.00, 125.00, 125.00, 125.00, 174.69, 170.76, 129.58, 121.80, 268.93, 265.96, 181.31, 176.64, 202.41, 192.17, 229.32, 232.71, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] #Values from waffles/np02_data/calibration_data/np02-config-v3.0.0.csv from finger plot (Henrique), values most likely underestimated by a factor 2-3

#Data taken from August 10th on
protodunevd_photoncalibrator_config_beam_v400: @local::protodunevd_photoncalibrator_config_beam_v100
#protodunevd_photoncalibrator_config_beam_v400.SPEAreas: [ 217.68, 118.37, 134.30, 270.76, 128.97, 125.00, 141.12, 158.16, 326.57, 324.09, 151.68, 167.84, 239.46, 222.98, 95.44, 78.65, 125.00, 125.00, 125.00, 125.00, 196.74, 204.91, 86.30, 137.85, 272.81, 263.84, 191.13, 188.08, 164.65, 159.85, 235.73, 232.74, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] #Values from waffles/np02_data/calibration_data/np02-config-v4.0.0.csv from finger plot (Henrique), values most likely underestimated by a factor 2-3
protodunevd_photoncalibrator_config_beam_v400.SPEAreas: [ 760.00, 501.00, 665.00, 794.00, 316.00, 290.00, 534.00, 551.00, 488.00, 584.00, 408.00, 370.00, 660.00, 515.00, 380.00, 313.00, 125.00, 125.00, 125.00, 125.00, 196.74, 204.91, 86.30, 137.85, 272.81, 263.84, 191.13, 188.08, 164.65, 159.85, 235.73, 232.74, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] #Values from waffles/np02_data/calibration_data/np02-config-v4.0.0.csv for membrane modules from finger plot (Henrique), values most likely underestimated by a factor 2-3. Cathode values obtained by Ajib (https://indico.fnal.gov/event/69308/contributions/333039/attachments/195016/270786/Preliminary_LowPE_background_Study.pdf)


END_PROLOG
51 changes: 51 additions & 0 deletions duneopdet/OpticalDetector/PhotonCalibratorDUNE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
////////////////////////////////////////////////////////////////////////
// \file PhotonCalibratorDUNE.h
//
// \brief DUNE service provider applying a channel based scale factor to optical hits.
//
// \author lpaulucc@fnal.gov based on PhotonCalibratorProtoduneSP by ahimmel
//
////////////////////////////////////////////////////////////////////////


#ifndef PHOTONCALIBRATORDUNE_H
#define PHOTONCALIBRATORDUNE_H

#include "larreco/Calibrator/IPhotonCalibrator.h"

// ART includes
#include "fhiclcpp/ParameterSet.h"
#include "art/Framework/Services/Registry/ActivityRegistry.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Registry/ServiceMacros.h"


namespace calib {

class PhotonCalibratorDUNE : public IPhotonCalibrator
{
public:
PhotonCalibratorDUNE(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg);

// Override base class functions
double PE(double adcs, int opchannel) const override;
bool UseArea() const override { return true; } // ProtoDUNE always uses area

/// Need a 3D position because result depends on position along length of
/// bar. This is going to be pretty imprecise even so.
// virtual double GeV(double PE, int opchannel, TVector3 pos) override;

private:
std::vector<int> fHdwChannels;
std::vector<float> fSPEAreas;
std::vector<float> fSPEShifts;
std::vector<int> fBadChannels;
std::map<int, float> fAreaMap;
std::map<int, float> fShiftMap;
}; // class PhotonCalibratorDUNE
}

//DECLARE_ART_SERVICE_INTERFACE_IMPL(calib::PhotonCalibratorDUNE, calib::IPhotonCalibrator, LEGACY)


#endif
68 changes: 68 additions & 0 deletions duneopdet/OpticalDetector/PhotonCalibratorServiceDUNE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
////////////////////////////////////////////////////////////////////////
// \file PhotonCalibratorServiceDUNE.h
//
// \brief Framework interface to PhotonCalibratorDUNE
//
// \author lpaulucc@fnal.gov based on PhotonCalibratorServiceProtuDUNESP by ahimmel@fnal.gov
//
////////////////////////////////////////////////////////////////////////


#ifndef PHOTONCALIBRATORSERVICEDUNE
#define PHOTONCALIBRATORSERVICEDUNE

// LArSoft Includes
#include "duneopdet/OpticalDetector/PhotonCalibratorDUNE.h"
#include "larreco/Calibrator/IPhotonCalibratorService.h"


// ART Includes
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/types/Atom.h"
#include "fhiclcpp/types/Sequence.h"
#include "art/Framework/Services/Registry/ActivityRegistry.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art/Framework/Services/Registry/ServiceMacros.h"
#include "art/Framework/Services/Registry/ServiceTable.h"
#include "art/Framework/Principal/Run.h"


#include <vector>

namespace calib {


class PhotonCalibratorServiceDUNE : public IPhotonCalibratorService
{
public:
using provider_type = PhotonCalibratorDUNE;

struct ServiceConfiguration_t
{
fhicl::Sequence<int> HdwChannels { fhicl::Name("HdwChannels") };
fhicl::Sequence<float> SPEAreas { fhicl::Name("SPEAreas") };
fhicl::Sequence<float> SPEShifts { fhicl::Name("SPEShifts") };
fhicl::Sequence<int> BadChannels { fhicl::Name("BadChannels"), fhicl::Comment("Channels to remove from reconstruction") };
};

using Parameters = art::ServiceTable<ServiceConfiguration_t>;

public:
PhotonCalibratorServiceDUNE(Parameters const & config,
art::ActivityRegistry& aReg)
: fProvider( new PhotonCalibratorDUNE(config.get_PSet(), aReg) )
{ }

provider_type const* provider() const override { return fProvider.get(); }

private:
std::unique_ptr<PhotonCalibratorDUNE> fProvider;
};

}

DECLARE_ART_SERVICE_INTERFACE_IMPL(calib::PhotonCalibratorServiceDUNE,
calib::IPhotonCalibratorService,
LEGACY)

#endif // PHOTONCALIBRATORSERVICEDUNE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Required minimal implementation file for calibrator service
* which only returns a provider.
*/
#include "duneopdet/OpticalDetector/PhotonCalibratorServiceDUNE.h"
#include "art/Framework/Services/Registry/ServiceDefinitionMacros.h"

DEFINE_ART_SERVICE_INTERFACE_IMPL(calib::PhotonCalibratorServiceDUNE,
calib::IPhotonCalibratorService)