Blinding.cxx
Go to the documentation of this file.
1 #include "CAFMaker/Blinding.h"
2 #include <iostream>
3 
4 // This helper handles the blinding of CAF records. It defines the (currently simple)
5 // cuts deciding if a record needs to be blinded. When required, it goes through
6 // the record punching holes in it.
7 //
8 // Energy, PID, and tracklength variables are reset. Other variables too closely
9 // related to energy, PID, and tracklength are also reset.
10 
11 namespace caf
12 {
13 
14  // Using standard dummy value (-5), except for unsigned vals (0).
15  // Let casting take care of the type cconversions.
16  static const int blind_val = -5;
17  static const unsigned int blind_val_unsigned = 0;
18 
19  //......................................................................
21  // Small numbers of ncontplanes are useful for cosmic rejection, large
22  // numbers can leak the event length (~ energy).
23  slc.ncontplanes = std::max(10u, slc.ncontplanes);
25  slc.calE = blind_val;
26  slc.boxmax. SetZ( blind_val );
27  slc.meanpos.SetZ( blind_val );
28  }
29 
30  //......................................................................
37  trk.calE = blind_val;
38  trk.len = blind_val;
39  trk.lenE = blind_val;
40  trk.stop. SetZ( blind_val );
41  }
42 
43  //......................................................................
50  jm.calE = blind_val;
51  jm.len = blind_val;
52  jm.shwE = blind_val;
53  jm.vtxE = blind_val;
54  jm.stop. SetZ( blind_val );
55  }
56 
57  //......................................................................
59  for (unsigned int i=0; i<vtx.fuzzyk.png.size(); i++) {
60  vtx.fuzzyk.png[i].nhit = blind_val_unsigned;
61  vtx.fuzzyk.png[i].nhitx = blind_val_unsigned;
62  vtx.fuzzyk.png[i].nhity = blind_val_unsigned;
63  vtx.fuzzyk.png[i].nplane = blind_val_unsigned;
64  vtx.fuzzyk.png[i].maxplanecont = blind_val_unsigned;
65  vtx.fuzzyk.png[i].calE = blind_val;
66  vtx.fuzzyk.png[i].weightedCalE = blind_val;
67  vtx.fuzzyk.png[i].len = blind_val;
68 
69  vtx.fuzzyk.png[i].shwlid.nhit = blind_val_unsigned;
70  vtx.fuzzyk.png[i].shwlid.nhitx = blind_val_unsigned;
71  vtx.fuzzyk.png[i].shwlid.nhity = blind_val_unsigned;
72  vtx.fuzzyk.png[i].shwlid.nplane = blind_val_unsigned;
73  vtx.fuzzyk.png[i].shwlid.maxplanecont = blind_val_unsigned;
74  vtx.fuzzyk.png[i].shwlid.calE = blind_val;
75  vtx.fuzzyk.png[i].shwlid.len = blind_val;
76  vtx.fuzzyk.png[i].shwlid.stop.SetZ (blind_val);
77  vtx.fuzzyk.png[i].shwlid.lid.setDefault();
78  vtx.fuzzyk.png[i].shwlid.lidE.setDefault();
79  vtx.fuzzyk.png[i].cvnpart.setDefault();
80  vtx.fuzzyk.png[i].regcvn.setDefault();
81 
82  vtx.fuzzyk.png[i].bpf.muon.nhit = blind_val_unsigned;
83  vtx.fuzzyk.png[i].bpf.muon.nhitx = blind_val_unsigned;
84  vtx.fuzzyk.png[i].bpf.muon.nhity = blind_val_unsigned;
85  vtx.fuzzyk.png[i].bpf.muon.nplane = blind_val_unsigned;
86  vtx.fuzzyk.png[i].bpf.muon.maxplanecont = blind_val_unsigned;
87  vtx.fuzzyk.png[i].bpf.muon.calE = blind_val;
88  vtx.fuzzyk.png[i].bpf.muon.len = blind_val;
89  vtx.fuzzyk.png[i].bpf.muon.lenE = blind_val;
90  vtx.fuzzyk.png[i].bpf.muon.stop. SetZ( blind_val );
91  vtx.fuzzyk.png[i].bpf.muon.pid = blind_val;
92  vtx.fuzzyk.png[i].bpf.muon.chi2T = blind_val;
93  vtx.fuzzyk.png[i].bpf.muon.dEdXLL = blind_val;
94  vtx.fuzzyk.png[i].bpf.muon.hitRatio = blind_val;
95  vtx.fuzzyk.png[i].bpf.muon.energy = blind_val;
96  vtx.fuzzyk.png[i].bpf.muon.lenE = blind_val;
97  vtx.fuzzyk.png[i].bpf.muon.overlapE = blind_val;
98  vtx.fuzzyk.png[i].bpf.muon.momentum. SetX( blind_val );
99  vtx.fuzzyk.png[i].bpf.muon.momentum. SetY( blind_val );
100  vtx.fuzzyk.png[i].bpf.muon.momentum. SetZ( blind_val );
101 
102  vtx.fuzzyk.png[i].bpf.pion.nhit = blind_val_unsigned;
103  vtx.fuzzyk.png[i].bpf.pion.nhitx = blind_val_unsigned;
104  vtx.fuzzyk.png[i].bpf.pion.nhity = blind_val_unsigned;
105  vtx.fuzzyk.png[i].bpf.pion.nplane = blind_val_unsigned;
106  vtx.fuzzyk.png[i].bpf.pion.maxplanecont = blind_val_unsigned;
107  vtx.fuzzyk.png[i].bpf.pion.calE = blind_val;
108  vtx.fuzzyk.png[i].bpf.pion.len = blind_val;
109  vtx.fuzzyk.png[i].bpf.pion.lenE = blind_val;
110  vtx.fuzzyk.png[i].bpf.pion.stop. SetZ( blind_val );
111  vtx.fuzzyk.png[i].bpf.pion.pid = blind_val;
112  vtx.fuzzyk.png[i].bpf.pion.chi2T = blind_val;
113  vtx.fuzzyk.png[i].bpf.pion.dEdXLL = blind_val;
114  vtx.fuzzyk.png[i].bpf.pion.hitRatio = blind_val;
115  vtx.fuzzyk.png[i].bpf.pion.energy = blind_val;
116  vtx.fuzzyk.png[i].bpf.pion.lenE = blind_val;
117  vtx.fuzzyk.png[i].bpf.pion.overlapE = blind_val;
118  vtx.fuzzyk.png[i].bpf.pion.momentum. SetX( blind_val );
119  vtx.fuzzyk.png[i].bpf.pion.momentum. SetY( blind_val );
120  vtx.fuzzyk.png[i].bpf.pion.momentum. SetZ( blind_val );
121 
122  vtx.fuzzyk.png[i].bpf.proton.nhit = blind_val_unsigned;
123  vtx.fuzzyk.png[i].bpf.proton.nhitx = blind_val_unsigned;
124  vtx.fuzzyk.png[i].bpf.proton.nhity = blind_val_unsigned;
125  vtx.fuzzyk.png[i].bpf.proton.nplane = blind_val_unsigned;
126  vtx.fuzzyk.png[i].bpf.proton.maxplanecont = blind_val_unsigned;
127  vtx.fuzzyk.png[i].bpf.proton.calE = blind_val;
128  vtx.fuzzyk.png[i].bpf.proton.len = blind_val;
129  vtx.fuzzyk.png[i].bpf.proton.lenE = blind_val;
130  vtx.fuzzyk.png[i].bpf.proton.stop. SetZ( blind_val );
131  vtx.fuzzyk.png[i].bpf.proton.pid = blind_val;
132  vtx.fuzzyk.png[i].bpf.proton.chi2T = blind_val;
133  vtx.fuzzyk.png[i].bpf.proton.dEdXLL = blind_val;
134  vtx.fuzzyk.png[i].bpf.proton.hitRatio = blind_val;
135  vtx.fuzzyk.png[i].bpf.proton.energy = blind_val;
136  vtx.fuzzyk.png[i].bpf.proton.lenE = blind_val;
137  vtx.fuzzyk.png[i].bpf.proton.overlapE = blind_val;
138  vtx.fuzzyk.png[i].bpf.proton.momentum. SetX( blind_val );
139  vtx.fuzzyk.png[i].bpf.proton.momentum. SetY( blind_val );
140  vtx.fuzzyk.png[i].bpf.proton.momentum. SetZ( blind_val );
141 
142  }
143  for (unsigned int i=0; i<vtx.fuzzyk.png2d.size(); i++) {
144  vtx.fuzzyk.png2d[i].nhit = blind_val_unsigned;
145  vtx.fuzzyk.png2d[i].nhitx = blind_val_unsigned;
146  vtx.fuzzyk.png2d[i].nhity = blind_val_unsigned;
147  vtx.fuzzyk.png2d[i].nplane = blind_val_unsigned;
148  vtx.fuzzyk.png2d[i].maxplanecont = blind_val_unsigned;
149  vtx.fuzzyk.png2d[i].calE = blind_val;
150  vtx.fuzzyk.png2d[i].weightedCalE = blind_val;
151  vtx.fuzzyk.png2d[i].len = blind_val;
152  }
153  }
154 
155  //......................................................................
157  cosrej.eratio = blind_val;
158  cosrej.hadE = blind_val;
159  }
160 
161  //......................................................................
163  /// If required, scrub the record of any quantities that shouldn't be viewed
164 
165  if(rec->hdr.det != kFARDET){
166  std::cerr << "Should only apply blinding to the Far Detector, aborting."
167  << std::endl;
168  abort();
169  }
170 
171  if(rec->hdr.ismc){
172  std::cerr << "Shouldn't apply blinding to Monte Carlo, aborting."
173  << std::endl;
174  abort();
175  }
176 
177  // Is this record in the box?
178 
179  // Blinding 0.8 to 3 GeV events within 30 microsecond window
180  // around center of beam spill (t=222000 microseconds).
181  if (rec->slc.calE > 0.8 &&
182  rec->slc.calE < 3.0 &&
183  rec->slc.meantime > 207000 &&
184  rec->slc.meantime < 237000 ) {
185 
186  // Walk through each rec branch.
187 
188  // -- start of branches --
189 
190  // -- hdr
191  // Tag the record as blind
192  rec->hdr.blind = 1;
193 
194  // -- spill
195 
196  // -- slc
197  BlindThisSlice(rec->slc);
198 
199  // -- trk
200  for (unsigned int i=0; i<rec->trk.kalman.tracks.size(); i++) {
202  rec->trk.kalman.tracks[i].remavededx = blind_val;
203  rec->trk.kalman.tracks[i].rempid = blind_val;
204  rec->trk.kalman.tracks[i].scatllh = blind_val;
205  rec->trk.kalman.tracks[i].dedxllh = blind_val;
206  rec->trk.kalman.tracks[i].measfrac = blind_val;
207  rec->trk.kalman.tracks[i].remcont = blind_val;
208  rec->trk.kalman.tracks[i].lenE = blind_val;
209  rec->trk.kalman.tracks[i].overlapE = blind_val;
210  }
211  for (unsigned int i=0; i<rec->trk.discrete.tracks.size(); i++) {
213  }
214  for (unsigned int i=0; i<rec->trk.cosmic.tracks.size(); i++) {
216  }
217  for (unsigned int i=0; i<rec->trk.window.tracks.size(); i++) {
219  }
220 
221  // -- vtx
222  if (rec->vtx.elastic.IsValid == 1) {
224  }
225 
226  // -- energy
227  // for now, everything goes, so use setDefault() methods
228  rec->energy.numu.setDefault();
229  rec->energy.nue .setDefault();
230  rec->energy.nue.lid.setDefault();
231 
232  // for (unsigned int i=0; i<rec->energy.nue.lid.size(); i++) {
233  // rec->energy.nue.lid[i].setDefault();
234  // }
235 
236  // -- sel
237  // for now, everything goes, so use setDefault() methods
238  rec->sel.remid.setDefault();
239  rec->sel.bpfid.setDefault();
240  rec->sel.lid .setDefault();
241  // for (unsigned int i=0; i<rec->sel.lid.shwlid.size(); i++){
242  // rec->sel.lid.shwlid[i].setDefault();
243  //}
244  rec->sel.lem .setDefault();
245  rec->sel.rvp .setDefault();
247  rec->sel.cvnoldpresel .setDefault();
248  rec->sel.cvnnocosmics .setDefault();
249 
250  // some stuff survives here:
251  BlindThisCosRej (rec->sel.cosrej);
252 
253  // -- mc
254 
255  // -- parent
256 
257  // -- end of branches --
258 
259  } // end if (rec needs blinding)
260 
261  }
262 
263 } // namespace caf
Det_t det
Detector, ND = 1, FD = 2, NDOS = 3.
Definition: SRHeader.h:28
T max(const caf::Proxy< T > &a, T b)
float shwE
reconstructed shower energy [GeV]
Definition: SRJMShower.h:41
virtual void setDefault()
Definition: SRNueEnergy.cxx:23
virtual void setDefault()
Definition: SRBpfId.cxx:35
Far Detector at Ash River.
Definition: SREnums.h:11
SRCVNResult cvnnocosmics
Output from CVN - No cosmics ued in training (many-class PID)
Definition: SRIDBranch.h:56
bool blind
if true, record has been corrupted for blindness
Definition: SRHeader.h:29
SRHeader hdr
Header branch: run, subrun, etc.
std::vector< SRProng > png2d
Vector of 2D prong objects.
Definition: SRFuzzyK.h:20
unsigned int lastplane
last plane
Definition: SRSlice.h:27
SRCosRej cosrej
Output from CosRej (Cosmic Rejection)
Definition: SRIDBranch.h:47
unsigned short nplane
number of planes spanned
Definition: SRTrack.h:30
SRVector3D boxmax
Maximum coordinates box containing all the hits [cm].
Definition: SRSlice.h:47
std::vector< SRFuzzyKProng > png
Vector of 3D prong objects.
Definition: SRFuzzyK.h:19
static const int blind_val
Definition: Blinding.cxx:16
void BlindThisJMShower(SRJMShower &jm)
Definition: Blinding.cxx:44
unsigned short maxplanecont
maximum number of contiguous planes in prong
Definition: SRTrack.h:31
virtual void setDefault()
Definition: SRCVNResult.cxx:28
OStream cerr
Definition: OStream.cxx:7
SRTrackBase discrete
3D tracks produced by DiscreteTrack
Definition: SRTrackBranch.h:25
caf::StandardRecord * rec
Definition: tutCAFMacro.C:20
Output from Cosmic Rejection (CosRej) module.
Definition: SRCosRej.h:8
SRNueEnergy nue
Nue energy variables.
SRCVNResult cvnoldpresel
Output from CVN - Preselection used in Prod3/4 (many-class PID)
Definition: SRIDBranch.h:55
SRCVNResult cvnloosepreselptp
Output from CVN - Loose Presel plus PtP cut (many-class PID)
Definition: SRIDBranch.h:54
float calE
energy based on summed calibrated deposited charge [GeV]
Definition: SRTrack.h:34
bool ismc
data or MC? True if MC
Definition: SRHeader.h:27
void setDefault()
Definition: SRELid.cxx:27
SRRvp rvp
Output from RecoVariablePID (RVP)
Definition: SRIDBranch.h:46
virtual void setDefault()
Definition: SRRemid.cxx:29
float calE
energy based on summed calibrated deposited charge [GeV]
Definition: SRJMShower.h:29
unsigned short nhit
number of hits
Definition: SRTrack.h:25
float vtxE
calorimetric energy of [GeV]
Definition: SRJMShower.h:42
void BlindThisCosRej(SRCosRej &cosrej)
Definition: Blinding.cxx:156
void BlindThisTrack(SRTrack &trk)
Definition: Blinding.cxx:31
void SetZ(float _z)
Definition: SRVector3D.h:30
float hadE
GeV sum of non (Kalman best ReMId) track E.
Definition: SRCosRej.h:51
Track finder for cosmic rays.
virtual void setDefault()
SRKalman kalman
Tracks produced by KalmanTrack.
Definition: SRTrackBranch.h:24
SRRemid remid
Output from RecoMuonID (ReMId) package.
Definition: SRIDBranch.h:39
float calE
Calorimetric energy of the cluster [GeV].
Definition: SRSlice.h:38
void BlindThisSlice(SRSlice &slc)
Definition: Blinding.cxx:20
float lenE
energy based on track length and MIP assumption [GeV]
Definition: SRTrack.h:44
unsigned short nhity
number of hits in y-view
Definition: SRJMShower.h:25
virtual void setDefault()
unsigned short nplane
number of planes spanned
Definition: SRJMShower.h:26
float len
track length [cm]
Definition: SRJMShower.h:32
SRVector3D stop
shower stop point
Definition: SRJMShower.h:39
An SRSlice contains overarching information for a slice.
Definition: SRSlice.h:15
void BlindThisRecord(StandardRecord *rec)
Definition: Blinding.cxx:162
unsigned short nhitx
number of hits in x-view
Definition: SRTrack.h:28
SRBpfId bpfid
Output from the BreakPointFitter PID (BPFPIdMaker) package.
Definition: SRIDBranch.h:41
void BlindThisElasticVtx(SRElastic &vtx)
Definition: Blinding.cxx:58
SRVector3D stop
Track end point in detector coordinates. [cm].
Definition: SRTrack.h:46
static const unsigned int blind_val_unsigned
Definition: Blinding.cxx:17
Cosmic Rejection PIDs for Numu analysis.
Definition: FillParentInfo.h:9
The StandardRecord is the primary top-level object in the Common Analysis File trees.
float len
track length [cm]
Definition: SRTrack.h:41
SRNumuEnergy numu
Numu energy estimator.
unsigned short nhity
number of hits in y-view
Definition: SRTrack.h:29
SRTrackBase window
Tracks produced by WindowTrack.
Definition: SRTrackBranch.h:27
SRELid lid
Output from LIDBuilder (LID) package.
Definition: SRIDBranch.h:42
SRIDBranch sel
Selector (PID) branch.
float eratio
ratio of best kalman track GeV / slice GeV
Definition: SRCosRej.h:50
SRElastic elastic
Single vertex found by Elastic Arms.
unsigned short maxplanecont
maximum number of contiguous planes in prong
Definition: SRJMShower.h:27
SRSlice slc
Slice branch: nhit, extents, time, etc.
void setDefault()
Definition: SRLem.cxx:58
SRFuzzyK fuzzyk
Primary 3D prong object.
Definition: SRElastic.h:44
SRLem lem
Output from Library Event Matching (LEM)
Definition: SRIDBranch.h:43
This module creates Common Analysis Files.
Definition: FileReducer.h:10
SRVector3D meanpos
Mean position of hits in slice, weighted by charge [cm].
Definition: SRSlice.h:48
SRSLidEnergy lid
Energy estimate from lid for slice pid (most energetic shower for now)
Definition: SRNueEnergy.h:23
unsigned short nhitx
number of hits in x-view
Definition: SRJMShower.h:24
unsigned int ncontplanes
number of continuous planes
Definition: SRSlice.h:25
SRTrackBranch trk
Track branch: nhit, len, etc.
SREnergyBranch energy
Energy estimator branch.
SRTrackBase cosmic
Tracks produced by CosmicTrack.
Definition: SRTrackBranch.h:26
std::vector< SRTrack > tracks
Definition: SRTrackBase.h:15
A potential interaction point from the ElasticArms algorithm.
Definition: SRElastic.h:19
A reconstructed shower from the JMShower module.
Definition: SRJMShower.h:16
unsigned short nhit
number of hits
Definition: SRJMShower.h:23
std::vector< SRKalmanTrack > tracks
3D Tracks produced by KalmanTrack
Definition: SRKalman.h:16
float meantime
mean time, weighted by charge [ns]
Definition: SRSlice.h:41
void setDefault()
Definition: SRRvp.cxx:40
SRVertexBranch vtx
Vertex branch: location, time, etc.