1 #include "TPCFGDMatchEffSystematics.hxx" 2 #include "CutUtils.hxx" 3 #include "SystematicUtils.hxx" 4 #include "VersioningUtils.hxx" 6 #include "Parameters.hxx" 11 TPCFGDMatchEffSystematics::TPCFGDMatchEffSystematics(
bool comp):
BinnedParams(
"TPCFGDMatchEff",k1D_EFF_ASSYMMETRIC,
versionUtils::Extension()){
14 _computecounters=comp;
25 _apply_both_FGD1_FGD2 = (bool)ND::params().GetParameterI(
"psycheSystematics.TPCFGDMatchEffSystematics.ApplyBoth_FGD1_FGD2");
26 _prod6_nnodes_cut = ND::params().
GetParameterI(
"psycheSystematics.TPCFGDMatchEffSystematics.Prod6NNodesCut");
41 std::cout <<
" TPCFGDMatchEffSystematics::ComputeWeight() " << std::endl;
42 std::cout <<
" Event " <<
static_cast<const AnaEventB&
>(event).EventInfo.Event << std::endl;
47 if( !versionUtils::prod6_systematics){
53 bool tpc_rec_exists=
false;
57 if (recoTrack) p0 = recoTrack->
Momentum;
74 Float_t sigMCh = params1.sigmaMCh + (100-p0)/100.*params.sigmaMCh;
76 Float_t sigDATAh = params1.sigmaDATAh + (100-p0)/100.*params.sigmaDATAh;
81 params.sigmaMCh = sigMCh;
83 params.sigmaDATAh = sigDATAh;
88 if(recoTrack) found=
true;
90 else if(tpc_rec_exists) found=
false;
93 eventWeight *= systUtils::ComputeEffLikeWeight(found, toy,
GetIndex(), index, params);
120 std::cout <<
" Track " << itrk << std::endl;
123 if (!track)
continue;
135 if (!isInFGD1 && !isInFGD2)
return false;
137 if (isInFGD1 || _apply_both_FGD1_FGD2){
141 if (isInFGD2 || _apply_both_FGD1_FGD2){
145 if (!FGD1Segment && !FGD2Segment)
continue;
148 AnaParticleB* prim_cand = isInFGD1 ? FGD1Segment : FGD2Segment;
150 AnaParticleB* sec_cand = isInFGD1 ? FGD2Segment : FGD1Segment;
152 eventWeight *= GetWeight(static_cast<AnaFGDParticleB*>(prim_cand), toy);
155 Weight_h weight_tmp = GetWeight(static_cast<AnaFGDParticleB*>(prim_cand), toy);
156 std::cout <<
"weight prim corr " << weight_tmp.Correction <<
" syst " << weight_tmp.Systematic << std::endl;
158 if (_apply_both_FGD1_FGD2){
160 std::cout <<
" applying second weight " << std::endl;
165 std::cout <<
"does not exist " << std::endl;
167 eventWeight *= GetWeight(static_cast<AnaFGDParticleB*>(sec_cand), toy);
170 Weight_h weight_tmp = GetWeight(static_cast<AnaFGDParticleB*>(sec_cand), toy);
171 std::cout <<
"weight second corr " << weight_tmp.Correction <<
" syst " << weight_tmp.Systematic << std::endl;
180 std::cout <<
"weight final event corr " << eventWeight.Correction <<
" syst " << eventWeight.Systematic << std::endl;
190 if (!FGDSegment)
return weight;
192 Float_t nn = FGDSegment->
NNodes;
195 if (nn > _prod6_nnodes_cut)
return weight;
208 if (!
GetBinValues(fgdnum, params, index))
return weight;
210 Weight_h eff_w = systUtils::ComputeEffLikeWeight(
true, toy,
GetIndex(), 0, params);
216 weight *=
Weight_h(TMath::Power(eff_w.Correction,nn)*(1.+(nn+1)*(Pineff.Correction)*(((nn+2)/2.)*Pineff.Correction) )/ (1.+(nn+1)*(1-Pnom)*((nn+2)/2.*(1-Pnom))),
217 TMath::Power(eff_w.Systematic,nn)*(1.+(nn+1)*(Pineff.Systematic)*(((nn+2)/2.)*Pineff.Systematic) )/ (1.+(nn+1)*(1-Pnom)*((nn+2)/2.*(1-Pnom))));
241 if( versionUtils::prod6_systematics){
249 if (!isInFGD1 && !isInFGD2)
return false;
251 if (isInFGD1 || _apply_both_FGD1_FGD2){
254 if (isInFGD2 || _apply_both_FGD1_FGD2){
258 if (!FGD1Segment && !FGD2Segment)
return false;
261 AnaParticleB* prim_cand = isInFGD1 ? FGD1Segment : FGD2Segment;
263 AnaParticleB* sec_cand = isInFGD1 ? FGD2Segment : FGD1Segment;
265 if (!prim_cand)
return false;
267 Int_t nnodes = prim_cand->
NNodes;
269 if (_apply_both_FGD1_FGD2 && sec_cand)
270 nnodes = std::min(nnodes, sec_cand->
NNodes);
276 if (nnodes > _prod6_nnodes_cut)
return false;
280 if (track.
Momentum < 30)
return false;
301 if((tinFGD1 && (tinTPC1 || tinTPC2)) || (tinFGD2 && (tinTPC2 || tinTPC3)))
return true;
312 if( versionUtils::prod6_systematics){
313 if (det == SubDetId::kFGD1){
314 IDs[0] = EventBoxTracker::kTracksWithTPCInFGD1FV;
317 else if (det == SubDetId::kFGD2){
318 IDs[0] = EventBoxTracker::kTracksWithTPCInFGD2FV;
321 else if (det == SubDetId::kFGD){
322 IDs[0] = EventBoxTracker::kTracksWithTPCInFGD1FV;
323 IDs[1] = EventBoxTracker::kTracksWithTPCInFGD2FV;
328 if (det == SubDetId::kFGD1){
329 IDs[0] = EventBoxTracker::kTracksWithTPCorFGD1;
332 else if (det == SubDetId::kFGD2){
333 IDs[0] = EventBoxTracker::kTracksWithTPCorFGD2;
336 else if (det == SubDetId::kFGD){
337 IDs[0] = EventBoxTracker::kTracksWithTPCorFGD1;
338 IDs[1] = EventBoxTracker::kTracksWithTPCorFGD2;
353 if (det == SubDetId::kFGD1){
354 IDs[0] = EventBoxTracker::kTrueParticlesChargedInTPCorFGDInBunch;
357 else if (det == SubDetId::kFGD2){
358 IDs[0] = EventBoxTracker::kTrueParticlesChargedInTPCorFGDInBunch;
361 else if (det == SubDetId::kFGD){
362 IDs[0] = EventBoxTracker::kTrueParticlesChargedInTPCorFGDInBunch;
Float_t PositionStart[4]
The reconstructed start position of the particle.
Int_t GetIndex() const
Return the index of this systematic.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
Weight_h ComputeWeight(const ToyExperiment &, const AnaEventC &, const ToyBoxB &)
Apply the systematic.
Int_t SelectionEnabledIndex
The enabled index of this selection this ToyBox belongs to.
Int_t NNodes
The number of nodes in the reconstructed object.
SystBoxB * GetSystBox(const AnaEventC &event, Int_t isel=0, Int_t ibranch=0) const
Get the SystBox corresponding to a selection, branch and event.
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Weight_h GetWeight(const AnaFGDParticleB *FGDSegment, const ToyExperiment &toy)
Float_t Momentum
The initial momentum of the true particle.
bool CheckTrueRecoAssociation(const AnaTrueObjectC &trueTrack, const AnaRecObjectC &track) const
Check the true-reco association.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
bool GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
Int_t GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.
Float_t meanDATA
The mean value for each of the systematic parameters of the control sample.
bool UpdateEfficiencyCounter(Int_t index, bool correct)
Update the efficiency variables _ncorrect and _nwrong.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo trajectory/particle.
virtual bool IsRelevantRecObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaRecObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this track relevant for a given systematic (after selection, called for each toy) ...
Int_t SuccessfulBranch
The branch that is successful for this toy in the selection this ToyBox belongs to.
Float_t meanMC
The mean value for each of the systematic parameters of the control sample.
Representation of a global track.
Int_t nRelevantTrueObjects
Array of Relevant True RecObjects for each systematic.
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Representation of a FGD segment of a global track.
AnaRecObjectC ** RelevantTrueObjectsReco
Float_t meanMCANA
The mean value for each of the systematic parameters of the analysis sample.
int nFGDSegments
How many FGD tracks are associated with this track.
bool IsRelevantRecObject(const AnaEventC &event, const AnaRecObjectC &track) const
Is this track relevant for this systematic ?
Float_t sigmaDATAl
The sigma value for each of the systematic parameters of the control sample /// with possibility of a...
Int_t nRelevantRecObjects
----—— Relevant rec objects and true objects for each systematic ------------—— ...
void InitializeEfficiencyCounter()
Initialize counters.
bool GetParametersForBin(Int_t index, Float_t &mean, Float_t &sigma)
Gets the bin values for a source provided the bin index.
Int_t GetRelevantTrueObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrueTrackGroup IDs array for this systematic.
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
AnaParticleB * GetSegmentWithMostNodesInDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Method to get the subtrack with most nodes in a given detector.
Representation of a reconstructed particle (track or shower).
Int_t GetNBins()
Get the number of bins.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.