Prod4DQFailCheck.cxx
Go to the documentation of this file.
2 
4 
6 
7 #include <iostream>
8 
9 namespace ana
10 {
12  {
13  int thisTrig = sp->trigger;
14  int thisDet = sp->det;
15  if(fFirstTrigger==-99) fFirstTrigger = thisTrig;
16  if(fFirstTrigger!=thisTrig){
17  std::cerr << "TRIGGER STREAM SWITCH, SPILL CUTS WILL NO LONGER BE APPLIED CORRECTLY!" << std::endl;
18  std::abort();
19  }
20  if(fFDId!=thisDet){
21  std::cerr << "NEAR DETECTOR LABEL! THIS CUT ONLY APPLIES TO FD!" << std::endl;
22  std::abort();
23  }
24 
25  if(fSet_Spills_RS.size()>0) return;
26 
27  std::cout << "\n\n\nAPPLYING SPILL CUTS MOTIVATED BY PROD4 SPILL INFO\n\n\n" << std::endl;
28 
29  std::string s_BaseDir = "/cvmfs/nova.osgstorage.org/analysis/3flavor/Cuts/";
30  std::string s_FName_RS = "";
31  std::string s_FName_RSE = "";
32  if(thisTrig==fCosmTrig){
33  s_FName_RS = "SpillTreeFile_kFailsStandardDQCuts_full_WithPatch_ForCosmics_Including_dbmask_RunSubrun_NonDegen.txt";
34  }
35  else if(thisTrig==fNumiTrig){
36  s_FName_RS = "dbmask_RunSubrun_NonDegen.txt";
37  s_FName_RSE = "SpillTreeFile_kFailsStandardDQCuts_full_WithPatch.txt";
38  }
39  else{
40  std::cerr << "TRIGGER TYPE NOT RECOGNISED!" << std::endl;
41  std::abort();
42  }
43 
44  std::ifstream f_SpillList;
45  f_SpillList.open(s_BaseDir+s_FName_RS);
46  std::size_t event, isgoodspill, run, subrun;
47  std::size_t count = 0;
48  while(f_SpillList >> run >> subrun){
49  std::vector<std::size_t> vec_Spill;
50  vec_Spill = {run, subrun};
51  fSet_Spills_RS.insert(vec_Spill);
52  count++;
53  }
54  f_SpillList.close();
55 
56  //std::cout << "COMPARING RS CONTAINER SIZES: " << fSet_Spills_RS.size() << " " << count << std::endl;
57  if(fSet_Spills_RS.size() < count) std::cout << "\n\n\nWARNING!!! SET HAS FEWER LINES THAN INPUT FILE\n\n\n";
58 
59  if(s_FName_RSE!=""){
60  count = 0;
61  f_SpillList.open(s_BaseDir+s_FName_RSE);
62  while(f_SpillList >> event >> isgoodspill >> run >> subrun){
63  std::vector<std::size_t> vec_Spill;
64  vec_Spill = {run, subrun, event};
65  fSet_Spills_RSE.insert(vec_Spill);
66  count++;
67  }
68  //std::cout << "COMPARING RSE CONTAINER SIZES: " << fSet_Spills_RSE.size() << " " << count << std::endl;
69  if(fSet_Spills_RSE.size() < count) std::cout << "\n\n\nWARNING!!! SET HAS FEWER LINES THAN INPUT FILE\n\n\n";
70  }
71 
72  return;
73  }
74 
76  {
77  InitialiseSets(sp);
78 
79  bool isBad_RS = (fSet_Spills_RS .find({sp->run, sp->subrun})!=fSet_Spills_RS .end());
80  if(fFirstTrigger==fCosmTrig) return !(isBad_RS);
81  else{
82  bool isBad_RSE = (fSet_Spills_RSE.find({sp->run, sp->subrun, sp->evt})!=fSet_Spills_RSE.end());
83  return !(isBad_RS || isBad_RSE);
84  }
85  }
86 
88  {
89  int thisIsMC = sp->ismc;
90  if(fFirstIsMC==-99) fFirstIsMC = thisIsMC;
91  if(fFirstIsMC!=thisIsMC){
92  std::cerr << "SWITCH BETWEEN DATA AND MC, SPILL CUTS WILL NO LONGER BE APPLIED CORRECTLY!" << std::endl;
93  std::abort();
94  }
95 
96  // IF RUNNING OVER MC, GO BACK TO THE STANDARD DQ CUTS.
97  if(thisIsMC==fIsMC) return kStandardDQCuts(sp);
98  return GetCutResult(sp);
99  }
100 
101 }
102 
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
OStream cerr
Definition: OStream.cxx:7
void InitialiseSets(const caf::SRSpillProxy *sp) const
bool operator()(const caf::SRSpillProxy *sp) const
bool GetCutResult(const caf::SRSpillProxy *sp) const
const SpillCut kStandardDQCuts([](const caf::SRSpillProxy *spill){if(spill->dcmedgematchfrac==0 &&spill->fracdcm3hits==0 &&spill->nmissingdcmslg==0) return bool(spill->isgoodspill); if(spill->det==caf::kNEARDET && (spill->fracdcm3hits > 0.45|| spill->nmissingdcms > 0)) return false; if(spill->eventincomplete) return false; if(spill->det==caf::kFARDET && spill->nmissingdcmslg > 0) return false; if(spill->det==caf::kFARDET && !spill->ismc && spill->dcmedgematchfrac<=0.2) return false;return true;})
Cut out events with a noisy detector or with parts missing.
Definition: SpillCuts.h:16
caf::Proxy< unsigned int > evt
Definition: SRProxy.h:1367
caf::Proxy< unsigned char > trigger
Definition: SRProxy.h:1411
std::unordered_set< std::vector< std::size_t >, VectorHash > fSet_Spills_RS
std::unordered_set< std::vector< std::size_t >, VectorHash > fSet_Spills_RSE
caf::Proxy< unsigned int > subrun
Definition: SRProxy.h:1410
Proxy for caf::SRSpill.
Definition: SRProxy.h:1346
OStream cout
Definition: OStream.cxx:6
int run
Definition: NusVarsTemp.cxx:51
caf::Proxy< unsigned int > run
Definition: SRProxy.h:1406
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:1361
caf::Proxy< bool > ismc
Definition: SRProxy.h:1378
int subrun
Definition: NusVarsTemp.cxx:52
enum BeamMode string