2 #include "CAFAna/Core/Binning.h" 5 #include "CAFAna/Core/Var.h" 59 const std::string filenameCosmicsData =
"prod_mrdifcaf_R19-11-18-prod5reco.i_fd_cosmic_rhc_full_v1_goodruns";
60 const std::string filenameCRYMC =
"prod_mrdifcaf_R19-11-18-prod5reco.m_fd_cry_rhc_full_v3";
61 const std::string filenameGENIEFluxswap =
"prod_caf_R19-11-18-prod5reco.f_fd_genie_N1810j0211a_fluxswap_rhc_nova_v08_full_v1";
65 TFile *
f1 = TFile::Open(
pnfs2xrootd(
"/pnfs/nova/scratch/users/amhall/DiF/RHC/MRDiF_FD_RHC_Step1.root").c_str());
69 auto sShwAnglePreselCosmicsData=*
Spectrum::LoadFrom(f1,
"sShwAngleCorePreselCosmicsData");
71 auto sShwAnglePreselGENIEFluxswap=*
Spectrum::LoadFrom(f1,
"sShwAngleCorePreselGENIEFluxswap");
74 double mylivetime=sShwAnglePreselCosmicsData.Livetime();
75 double myPOT=sShwAnglePreselGENIEFluxswap.POT();
80 TH1D* hPreselCRY=sShwAnglePreselCRYMC.ToTH1(mylivetime,
kLivetime);
81 TH1D* hPreselData=sShwAnglePreselCosmicsData.ToTH1(mylivetime,
kLivetime);
106 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
124 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
142 if(myweight>=0)
return myweight;
155 if(myweight>=0)
return myweight;
170 double startx = -99999;
176 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
195 double starty = -99999;
201 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
220 double startz = -99999;
226 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
250 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
264 const Var kShwLength(
276 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
302 if(maxe < sr->vtx.elastic.fuzzyk.png[
i].shwlid.shwE){
356 const std::vector<Plot>
plots = {
357 {
"Shower Angle (cos_theta_z)",
kShwAngle, ShwAnglebin},
358 {
"Number of Hits in Slice",
kNHit, NHitbin },
359 {
"Number of Hits in Shower",
kShwNHit, NHitbin},
360 {
"Energy in Shower (GeV)",
kShwE, ShwEbin },
361 {
"Energy per Hit (CaloE/NHit)",
kEPerHit, EPerHitbin},
363 {
"Shower Width",
kShwWidth, ShwWidthbin},
364 {
"Shower Length", kShwLength, ShwLengthbin},
368 {
"Vtx X",
kVtxX, ShwStartXbin},
369 {
"Vtx Y",
kVtxY, ShwStartYbin},
370 {
"Vtx Z",
kVtxZ, ShwStartZbin},
371 {
"Distance to Top",
kdistTop, distVerticalbin},
372 {
"Distance to Bottom",
kdistBottom, distVerticalbin},
373 {
"Distance to East",
kdistEast, distHorizontalbin},
374 {
"Distance to West",
kdistWest, distHorizontalbin},
375 {
"Distance to Front",
kdistFront, distLengthbin},
376 {
"Distance to Back",
kdistBack, distLengthbin}
385 std::vector<Spectrum*> sDataPresel, sCRYMCPresel, sGENIEPresel, sData, sCRYMC, sGENIE;
386 std::vector<Spectrum*> sDataPreselWtd, sCRYMCPreselWtd, sDataWtd, sCRYMCWtd;
388 for(
const Plot&
p: plots){
405 loaderCosmicsData.
Go();
412 TFile *
outFile =
new TFile(
"MRDiF_FD_RHC_Step2_v2_clean.root",
"recreate");
415 for (
unsigned int i=0;
i<sDataPresel.size();
i++){
416 sprintf(cname,
"sDataPresel_V%d",
i);
417 sDataPresel[
i]->SaveTo(outFile, cname);
418 sprintf(cname,
"sData_V%d",
i);
419 sData[
i]->SaveTo(outFile, cname);
420 sprintf(cname,
"sDataPreselWtd_V%d",
i);
421 sDataPreselWtd[
i]->SaveTo(outFile, cname);
422 sprintf(cname,
"sDataWtd_V%d",
i);
423 sDataWtd[
i]->SaveTo(outFile, cname);
425 sprintf(cname,
"sCRYMCPresel_V%d",
i);
426 sCRYMCPresel[
i]->SaveTo(outFile, cname);
427 sprintf(cname,
"sCRYMC_V%d",
i);
428 sCRYMC[
i]->SaveTo(outFile, cname);
429 sprintf(cname,
"sCRYMCPreselWtd_V%d",
i);
430 sCRYMCPreselWtd[
i]->SaveTo(outFile, cname);
431 sprintf(cname,
"sCRYMCWtd_V%d",
i);
432 sCRYMCWtd[
i]->SaveTo(outFile, cname);
434 sprintf(cname,
"sGENIEPresel_V%d",
i);
435 sGENIEPresel[
i]->SaveTo(outFile, cname);
436 sprintf(cname,
"sGENIE_V%d",
i);
437 sGENIE[
i]->SaveTo(outFile, cname);
const Var kShwE([](const caf::SRProxy *sr){double maxe=-99.0;if(!sr->vtx.elastic.IsValid) return-99999.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-99999.0;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.npng;i++){if(maxe< sr->vtx.elastic.fuzzyk.png[i].shwlid.shwE){maxe=sr->vtx.elastic.fuzzyk.png[i].shwlid.shwE;}}return maxe;})
caf::Proxy< caf::SRFuzzyK > fuzzyk
Represent the binning of a Spectrum's x-axis.
Cuts and Vars for the 2020 FD DiF Study.
Proxy for caf::StandardRecord.
const Var kdistEast([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float x_val=sr->vtx.elastic.vtx.x;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.x;if(tmp > x_val) x_val=tmp;}float dist_to_east=765-x_val;return dist_to_east;})
void SetSpillCut(const SpillCut &cut)
std::string pnfs2xrootd(std::string loc, bool unauth)
const Cut kDiFPreselectionCut
const Var kEPerHit([](const caf::SRProxy *sr){if(sr->slc.nhit >0) return 1000.0 *(sr->slc.calE/sr->slc.nhit);else return-5.;})
const Var kdistBottom([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float y_val=sr->vtx.elastic.vtx.y;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.y;if(tmp< y_val) y_val=tmp;}float dist_to_bot=y_val+749;return dist_to_bot;})
TH1D * hPreselGENIE_forCRY
caf::Proxy< caf::SRElastic > elastic
caf::Proxy< std::vector< caf::SRFuzzyKProng > > png
====================================================================== ///
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
const std::vector< Plot > plots
void MRDiFStudy_RHC_Step2()
const Var kdistFront([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float z_val=sr->vtx.elastic.vtx.z;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.z;if(tmp< z_val) z_val=tmp;}return z_val;})
const Cut kDiFSelectionCut
virtual void Go() override
Load all the registered spectra.
std::vector< float > Spectrum
const SystShifts kNoShift
caf::Proxy< bool > IsValid
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kdistBack([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float z_val=sr->vtx.elastic.vtx.z;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.z;if(tmp > z_val) z_val=tmp;}return 5962-z_val;})
caf::Proxy< caf::SRVector3D > vtx
TH1D * hPreselGENIE_forData
const Cut kInCosmicTimingWindow_FD_MR
const SpillCut kStandardSpillCuts
Apply this unless you're doing something special.
const Var kShwAngle([](const caf::SRProxy *sr){double maxe=-99.0;double cosz=-1.0;if(!sr->vtx.elastic.IsValid) return-99999.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-99999.0;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.npng;i++){if(maxe< sr->vtx.elastic.fuzzyk.png[i].shwlid.shwE){maxe=sr->vtx.elastic.fuzzyk.png[i].shwlid.shwE;cosz=sr->vtx.elastic.fuzzyk.png[i].shwlid.dir.z;}}return cosz;})
caf::Proxy< caf::SRVertexBranch > vtx
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
const Var kdistWest([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float x_val=sr->vtx.elastic.vtx.x;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.x;if(tmp< x_val) x_val=tmp;}float dist_to_west=x_val+758;return dist_to_west;})
const Var kdistTop([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid||!(sr->vtx.elastic.fuzzyk.png.size() >0)) return(float)-5;float y_val=sr->vtx.elastic.vtx.y;for(unsigned int pngID=0;pngID< sr->vtx.elastic.fuzzyk.png.size();pngID++){float tmp=sr->vtx.elastic.fuzzyk.png[pngID].shwlid.stop.y;if(tmp > y_val) y_val=tmp;}float dist_to_top=765-y_val;return dist_to_top;})