17 #include "canvas/Persistency/Common/FindManyP.h" 37 #include "TTimeStamp.h" 42 class CalibrationdEdXPDSP;
106 vDrift = detProp.DriftVelocity();
109 produces< std::vector<anab::Calorimetry> >();
110 produces< art::Assns<recob::Track, anab::Calorimetry> >();
143 uint64_t evttime = tts.AsDouble();
146 std::cout <<
"evttime: " << evttime <<
std::endl;
154 std::cout<<
"Plane\tReference dQ/dx\tGlobal median dQ/dx\tCalorimetry constant"<<
std::endl;
155 for (
int i = 0; i<3; ++i){
161 auto const*
sce = lar::providerFrom<spacecharge::SpaceChargeService>();
164 std::unique_ptr< std::vector<anab::Calorimetry> > calorimetrycol(
new std::vector<anab::Calorimetry>);
170 std::vector<art::Ptr<recob::Track> > tracklist;
178 std::vector<art::Ptr<recob::Hit> > hitlist;
181 if (!fmcal.isValid()){
183 <<
"Could not get assocated Calorimetry objects";
186 for (
size_t trkIter = 0; trkIter < tracklist.size(); ++trkIter){
187 for (
size_t i = 0; i<fmcal.at(trkIter).size(); ++i){
188 auto &
calo = fmcal.at(trkIter)[i];
192 calorimetrycol->push_back(*
calo);
200 std::vector<float> vdEdx =
calo->dEdx();
201 std::vector<float> vdQdx =
calo->dQdx();
202 std::vector<float> vresRange =
calo->ResidualRange();
203 std::vector<float> deadwire =
calo->DeadWireResRC();
204 float Trk_Length =
calo->Range();
205 std::vector<float> fpitch =
calo->TrkPitchVec();
206 const auto& fHitIndex =
calo->TpIndices();
207 const auto& vXYZ =
calo->XYZ();
211 if (vdEdx.size()!=vXYZ.size()||
212 vdQdx.size()!=vXYZ.size()||
213 vresRange.size()!=vXYZ.size()||
214 fpitch.size()!=vXYZ.size()){
216 <<
"Vector sizes mismatch for vdEdx, vdQdx, vresRange, fpitch, vXYZ";
222 <<
"planeID is invalid";
224 if (planeID.
Plane>2){
226 <<
"plane is invalid "<<planeID.
Plane;
231 for (
size_t j = 0; j<vdQdx.size(); ++j){
232 auto &
hit = hitlist[fHitIndex[j]];
233 if (
hit->WireID().Plane != planeID.
Plane){
235 <<
"Hit plane = "<<
hit->WireID().Plane<<
" calo plane = "<<planeID.
Plane;
237 double normcorrection = 1;
241 if (!normcorrection) normcorrection = 1.;
243 double xcorrection = 1;
245 xcorrection = xyzcalib->
GetXCorr(planeID.
Plane, vXYZ[j].X());
246 if (!xcorrection) xcorrection = 1.;
248 double yzcorrection = 1;
250 yzcorrection = xyzcalib->
GetYZCorr(planeID.
Plane, vXYZ[j].X()>0, vXYZ[j].Y(), vXYZ[j].Z());
251 if (!yzcorrection) yzcorrection = 1.;
258 vdQdx[j] = normcorrection*xcorrection*yzcorrection*vdQdx[j];
268 double rho = detProp.Density();
270 double E_field_nominal = detProp.Efield();
275 if(
sce->EnableCalEfieldSCE()&&
fSCE) E_field_offsets =
sce->GetCalEfieldOffsets(
geo::Point_t{vXYZ[j].X(), vXYZ[j].Y(), vXYZ[j].Z()},
hit->WireID().TPC);
277 TVector3 E_field_vector = {E_field_nominal*(1 + E_field_offsets.X()), E_field_nominal*E_field_offsets.Y(), E_field_nominal*E_field_offsets.Z()};
278 double E_field = E_field_vector.Mag();
281 double Beta =
fModBoxB / (rho * E_field);
284 vdEdx[j] = (exp(Beta * Wion * dQdx_e) - Alpha) / Beta;
296 if ( (vresRange[j] < 0) || (vresRange[j-1] < 0) )
continue;
297 EkinNew += fabs(vresRange[j]-vresRange[j-1]) * vdEdx[j];
300 if ( (vresRange[j] < 0) || (vresRange[j+1] < 0) )
continue;
301 EkinNew += fabs(vresRange[j]-vresRange[j+1]) * vdEdx[j];
std::vector< double > fReferencedQdx
CalibrationdEdXPDSP(fhicl::ParameterSet const &p)
constexpr std::uint32_t timeLow() const
Handle< PROD > getHandle(SelectorBase const &) const
virtual double GetNormCorr(int plane)=0
EDProducer(fhicl::ParameterSet const &pset)
constexpr std::uint32_t timeHigh() const
The data type to uniquely identify a Plane.
bool isValid
Whether this ID points to a valid element.
virtual double GetLifetime()=0
virtual calib::XYZCalib * provider() const =0
std::string fHitModuleLabel
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::string fTrackModuleLabel
virtual calib::LifetimeCalib * provider() const =0
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double ElectronsFromADCArea(double area, unsigned short plane) const
calo::CalorimetryAlg caloAlg
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
bool fUseLifetimeFromDatabase
#define DEFINE_ART_MODULE(klass)
void produce(art::Event &e) override
SubRunNumber_t subRun() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fCalorimetryModuleLabel
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
PlaneID_t Plane
Index of the plane within its TPC.
CalibrationdEdXPDSP & operator=(CalibrationdEdXPDSP const &)=delete
bool fApplyLifetimeCorrection
Detector simulation of raw signals on wires.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
virtual double GetXCorr(int plane, double x)=0
Provides recob::Track data product.
int trigger_offset(DetectorClocksData const &data)
EventNumber_t event() const
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
virtual double GetYZCorr(int plane, int side, double x, double y)=0
bool fApplyNormCorrection
QTextStream & endl(QTextStream &s)