1 #include "MomentumResolVariation.hxx" 2 #include "ND280AnalysisUtils.hxx" 3 #include "EventBoxTracker.hxx" 4 #include "VersioningUtils.hxx" 5 #include "ConstituentsUtils.hxx" 6 #include "CutUtils.hxx" 28 std::cout <<
" MomentumResolVariation::ApplyVariation() - start " << std::endl;
38 std::cout <<
" MomentumResolVariation::ApplyVariation() p0, p0_true = " << p <<
" " << p0_true << std::endl;
44 Float_t pt0_inv_flip = anaUtils::ComputeInversePTFlip(*track);
46 if (pt0_inv < 0)
return;
52 std::cout <<
" MomentumResolVariation::ApplyVariation() 1/pt0, 1/pt0_true = " << pt0_inv <<
" " << pt0_inv_true << std::endl;
53 std::cout <<
" MomentumResolVariation::ApplyVariation() 1/pt0_flip = " << pt0_inv_flip << std::endl;
54 std::cout <<
" MomentumResolVariation::ApplyVariation() var = " << variation << std::endl;
58 Float_t pt_inv = (1 + variation) * (pt0_inv - pt0_inv_true) + pt0_inv_true;
61 Float_t pt_inv_flip = (1 + variation) * (pt0_inv_flip - pt0_inv_true) + pt0_inv_true;
84 Float_t smearingFact = (p - p0_true)/(p0 - p0_true);
85 Float_t smearingFactMom = p / p0;
91 Float_t tpcmom = tpcTrackOrig->
Momentum;
94 tpcTrack->
Momentum = tpcmom * smearingFactMom;
98 std::cout <<
" MomentumResolVariation::ApplyVariation() p0 new = " << track->
Momentum << std::endl;
99 std::cout <<
" MomentumResolVariation::ApplyVariation() p0flip new = " << track->
MomentumFlip << std::endl;
110 std::cout <<
" MomentumResolVariation::ApplyVariationTPCBased() - start " << std::endl;
123 std::cout <<
" MomentumResolVariation::ApplyVariationTPCBased() p0, p0_true = " << track->
Momentum <<
" " << p0_true << std::endl;
124 std::cout <<
" MomentumResolVariation::ApplyVariationTPCBased() p0flip, p0_true = " << track->
MomentumFlip <<
" " << p0_true << std::endl;
157 std::cout <<
" MomentumResolVariation::ApplyVariationTPCBased() p0 new = " << track->
Momentum << std::endl;
158 std::cout <<
" MomentumResolVariation::ApplyVariationTPCBased() p0flip new = " << track->
MomentumFlip << std::endl;
190 if (!trueTrack)
return;
201 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() p0, p0_true = " << p <<
" " << p0_true << std::endl;
208 if (pt0_inv < 0)
return;
214 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() 1/pt0, 1/pt0_true = " << pt0_inv <<
" " << pt0_inv_true << std::endl;
215 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() var = " << variation << std::endl;
219 Float_t pt_inv = (1 + variation) * (pt0_inv - pt0_inv_true) + pt0_inv_true;
231 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() p_err = " << track->
MomentumError <<
" " << std::endl;
236 if (p0 - p0_true != 0)
240 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() p = " << p <<
" " << std::endl;
241 std::cout <<
" MomentumResolVariation::ApplyVariationTPC() p_err = " << track->
MomentumError <<
" " << std::endl;
260 if (!track)
return false;
265 Float_t x_zmin = -10000;
266 Float_t x_zmax = -10000;
267 Float_t zmin = 10000;
268 Float_t zmax = -10000;
275 for (
int k = 0; k < nTPCSegments; k++) {
291 std::cout <<
" MomentumResolVariation::GetXBinnedValues() mode " << mode
292 <<
" bin: " << x_zmin <<
" " << x_zmax <<
" " << zmin <<
" " << zmax
296 return GetXBinnedValues(x_zmin, x_zmax, value1, value2, index1, index2, mode);
311 if (!tpcTrack)
return false;
327 Float_t dist = 9999999.;
334 if (!tpc_track_tmp)
continue;
336 if (!cutUtils::TPCTrackQualityCut(*tpc_track_tmp))
continue;
338 Float_t dist_tmp = std::min(
343 if (dist_tmp < dist){
345 tpcTrack = tpc_track_tmp;
355 Float_t& value1, Float_t& value2,
356 Int_t& index1, Int_t& index2,
361 if (xmin < -1000 || xmax < -1000)
return false;
364 Float_t val1_tmp, val2_tmp;
376 std::cout <<
" MomentumResolVariation::GetXBinnedValues() " << mode
377 <<
" bin: " << xmin <<
" " << xmax
378 <<
" " << value1 <<
" " << value2 << std::endl;
384 else if (ok1 && !ok2){
389 else if (!ok1 && ok2){
virtual void ApplyVariation(AnaTrackB *track, const ToyExperiment &exp)
const AnaTrackB * GetOriginalTrack() const
Return a casted version of the original AnaParticleB associated.
Float_t PositionStart[4]
The reconstructed start position of the particle.
virtual bool GetVariationTPC(AnaTPCParticleB *track, Float_t &variation, const ToyExperiment &exp)
Abstract class to get the variation given a TPC object.
/// Extension to AnaParticleB containing momentum and charge info
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
Float_t ComputeMomentumFromInversePT(const AnaParticleB &part, Float_t PTinv)
compute the total momentum given the part and the inverse transverse momentum
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
Float_t Momentum
The initial momentum of the true particle.
float GetSeparationSquared(const Float_t *pos1, const Float_t *pos2)
Calculate the distance between two points.
static AnaParticleB * GetClosestTPCSegmentWithGoodDQ(const AnaTrackB &track, const Float_t *pos)
Get TPC segment that satisfies DQ and is closest.
bool GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
Float_t MomentumError
Error of the momentum at the start of the segment.
Float_t MomentumFlip
Momentum for the main PID hypothesis and reverse sense.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
virtual void ApplyVariationTPCBased(AnaTrackB *track, const ToyExperiment &exp)
Float_t GetEntranceMomentum(const AnaDetCrossingB &cross)
Get the momentum value from AnaDetCrossing.
Float_t ComputeInversePT(const AnaDetCrossingB &cross, bool entrance=true)
Compute inverse PT given an AnaDetCrossing.
const AnaParticleB * Original
static bool IsTPCDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a TPC or not.
Float_t ComputeMomentumFromInversePTFlip(const AnaParticleB &part, Float_t PTinv)
Compute the total momentum (flip) given the part and the inverse transverse momentum.
Representation of a detector crossing info for a true particle (G4 trajectory).
SubDetEnum
Enumeration of all detector systems and subdetectors.
Representation of a global track.
AnaDetCrossingB * GetAnaDetCrossing(const AnaTrueParticleB *track, SubDetId::SubDetEnum det)
virtual void ApplyVariationTPC(AnaTPCParticleB *track, const ToyExperiment &exp)
Smear TPC track based on the corresponding true track.
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Representation of a TPC segment of a global track.
bool GetXBinnedValues(AnaTrackB *track, Float_t &value1, Float_t &value2, Int_t &index1, Int_t &index2, ModeEnum mode)
Get parameters for this global track assumed one uses X bins.
virtual bool GetVariation(AnaTrackB *track, Float_t &variation, const ToyExperiment &exp)=0
Abstract class to get the variation given a track.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Representation of a reconstructed particle (track or shower).
Float_t PositionEnd[4]
The reconstructed end position of the particle.
BinnedParams * _params
Binned data to read the parameters.