Functions | Variables
getGoodRuns4SAM Namespace Reference

Functions

def countAnaBlocks (diblock_mask_binary)
 
def consolidate (run_rows)
 
def processFarDetData (data, detname, tag)
 
def processNearDetData (data, detname, tag)
 

Variables

string Usage
 
string data_type = 'data'
 
 tag = None
 
list dbcon = []
 
 t0 = text2datetime("0")
 
 t1 = text2datetime("100000000")
 
 channel_range = None
 
string username = "nova_reader"
 
 opts
 
 args
 
string tname = "fardet.dq_subrun_info"
 
list columns = ["dbmask","flag"]
 
 db = ConDB(dbcon)
 
 table = db.table(tname, columns)
 
 sampwd = None
 
 sampwdFile = None
 
 conn
 
 cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
 
 data
 
int n = 0
 
int nwrote = 0
 
string detname = 'fardet'
 
 fout = open("/tmp/goodRuns4SAM.csv","w")
 
int prev_diblock_mask = -1
 
bool prev_isGood = True
 
int run = int(epoch(tv))/100
 
int subrun = int(epoch(tv))%100
 
bool isGood = True
 
 diblock_mask = int(values[0])
 
string line = '{0},{1},{2},{3},{4},{5}\n'
 
 csvFile = open("/tmp/goodRuns4SAM.csv","r")
 
 sep
 
 DB_PWD = open(os.environ['NOVADBPWDFILE'], 'r').readlines()[0].strip()
 
 det = None
 
bool test = False
 
 run_rows = processFarDetData(data, det, tag)
 
 thisrun = row[0]
 
 nextrun = run_rows[ (idx+1)][0]
 
 run_range = psycopg2.extras.NumericRange(thisrun, nextrun, '[)')
 

Function Documentation

def getGoodRuns4SAM.consolidate (   run_rows)

Definition at line 35 of file getGoodRuns4SAM.py.

References novadaq::HexUtils.format(), and PandAna.Demos.demo1.range.

Referenced by processFarDetData(), and processNearDetData().

35 def consolidate(run_rows):
36  run_rows.sort()
37 
38  n = len(run_rows)
39  print "Read {} rows from the NOvA good runs database".format(n)
40  i=0
41 
42  prev_isGood = not(run_rows[0][3])
43  prev_diblock_mask = -1
44 
45  ret_rows = []
46 
47  for i in range(n):
48 
49  isGood = run_rows[i][3]
50  diblock_mask = run_rows[i][4]
51 
52  if ((prev_diblock_mask != diblock_mask) or (prev_isGood != isGood) or
53  (i == n-1)) :
54  ret_rows.append(run_rows[i])
55  prev_isGood = isGood
56  prev_diblock_mask = diblock_mask
57 
58 
59  print "Consisting of {} validity ranges.".format(len(ret_rows))
60  return ret_rows
61 
def consolidate(run_rows)
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def getGoodRuns4SAM.countAnaBlocks (   diblock_mask_binary)

Definition at line 17 of file getGoodRuns4SAM.py.

Referenced by processFarDetData().

17 def countAnaBlocks(diblock_mask_binary):
18  anadb = 0
19  counter = 0
20  # first get rid of the '0b' that binary strings start with
21  bit_mask = diblock_mask_binary[2:]
22  # split into substrings at every 0
23  bit_mask_burst = bit_mask.split('0')
24  # should be left with substrings containing only 1's
25  # add up if substring length is 4 or more
26  for s in bit_mask_burst:
27  if len(s) > 3:
28  anadb += len(s)
29  return anadb
30 
31 
def countAnaBlocks(diblock_mask_binary)
def getGoodRuns4SAM.processFarDetData (   data,
  detname,
  tag 
)

Definition at line 66 of file getGoodRuns4SAM.py.

References bin, consolidate(), countAnaBlocks(), exit(), makeTrainCVSamples.int, and parse_dependency_file_t.list.

66 def processFarDetData(data, detname, tag):
67 
68  li = list(data)
69 
70  prev_diblock_mask = -1
71  if li == []:
72  print "\nNOvA database returned no information.\n"
73  exit(1)
74 
75  # set the variable that keep account of what the previous subrun's
76  # isgood flag was to the compliment of the flag for the first subrun
77  prev_isGood = ( li[0][2][0] > 1 )
78 
79  run_rows = []
80  n=0
81 
82  # parse information from the good runs database and put it
83  # into a list of ntuples that can later be sorted by run
84  for c, tv, values in li:
85 
86  run = int(epoch(tv))
87  isGood=True
88  if (values[1] > 0):
89  isGood = False
90 
91  diblock_mask = int(values[0])
92  ngood_cont_diblock = values[2]
93 
94  #convert to binary
95  diblock_mask_binary = bin( diblock_mask)
96  #count the number of 1's in the binary diblock mask
97  ngood_tot_diblock = diblock_mask_binary.count('1')
98 
99  ngood_ana_diblock = countAnaBlocks(diblock_mask_binary)
100 
101  tup = (run,
102  detname,tag,isGood,
103  diblock_mask,
104  ngood_cont_diblock,
105  ngood_ana_diblock,
106  ngood_tot_diblock)
107  run_rows.append(tup)
108 
109  return consolidate(run_rows)
110 
def consolidate(run_rows)
float bin[41]
Definition: plottest35.C:14
def processFarDetData(data, detname, tag)
exit(0)
def countAnaBlocks(diblock_mask_binary)
def getGoodRuns4SAM.processNearDetData (   data,
  detname,
  tag 
)

Definition at line 114 of file getGoodRuns4SAM.py.

References consolidate(), exit(), makeTrainCVSamples.int, and parse_dependency_file_t.list.

114 def processNearDetData(data, detname, tag):
115  li = list(data)
116  if li == []:
117  print "\nNOvA database returned no information.\n"
118  exit(1)
119  # set the variable that keep account of what the previous subrun's
120  # isgood flag was to the compliment of the flag for the first subrun
121 
122  run_rows = []
123 
124  for c, tv, values in li:
125 
126  run = int(epoch(tv))
127  isGood=(values[0] < 1)
128 
129  # set FD specific metrics to 0
130  diblock_mask = 0
131  ngood_cont_diblock = 0
132  ngood_tot_diblock = 0
133  ngood_ana_diblock = 0
134 
135  tup = (run,
136  detname,tag,isGood,
137  diblock_mask,
138  ngood_cont_diblock,
139  ngood_ana_diblock,
140  ngood_tot_diblock)
141  run_rows.append(tup)
142 
143  return consolidate(run_rows)
144 
145 
146 
def consolidate(run_rows)
exit(0)
def processNearDetData(data, detname, tag)

Variable Documentation

getGoodRuns4SAM.args

Definition at line 24 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.channel_range = None

Definition at line 21 of file getGoodRuns4SAM.py.

list getGoodRuns4SAM.columns = ["dbmask","flag"]

Definition at line 48 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.conn
Initial value:
1 = psycopg2.connect("dbname=samdev host=cspgsdev.fnal.gov "\
2  "user=jpaley "\
3  "port=5433")

Definition at line 67 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.csvFile = open("/tmp/goodRuns4SAM.csv","r")

Definition at line 110 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)

Definition at line 70 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.data
Initial value:
1 = table.getDataIntervalIter(t0, t1, data_type=data_type, tag=tag,
2  channel_range = channel_range)

Definition at line 76 of file getGoodRuns4SAM.py.

string getGoodRuns4SAM.data_type = 'data'
getGoodRuns4SAM.db = ConDB(dbcon)

Definition at line 49 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.DB_PWD = open(os.environ['NOVADBPWDFILE'], 'r').readlines()[0].strip()

Definition at line 161 of file getGoodRuns4SAM.py.

string getGoodRuns4SAM.dbcon = []

Definition at line 17 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.det = None

Definition at line 164 of file getGoodRuns4SAM.py.

string getGoodRuns4SAM.detname = 'fardet'
getGoodRuns4SAM.diblock_mask = int(values[0])

Definition at line 94 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.fout = open("/tmp/goodRuns4SAM.csv","w")

Definition at line 83 of file getGoodRuns4SAM.py.

bool getGoodRuns4SAM.isGood = True

Definition at line 91 of file getGoodRuns4SAM.py.

string getGoodRuns4SAM.line = '{0},{1},{2},{3},{4},{5}\n'

Definition at line 99 of file getGoodRuns4SAM.py.

int getGoodRuns4SAM.n = 0

Definition at line 79 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.nextrun = run_rows[ (idx+1)][0]

Definition at line 256 of file getGoodRuns4SAM.py.

Referenced by CondenseRunList().

int getGoodRuns4SAM.nwrote = 0

Definition at line 80 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.opts

Definition at line 24 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.prev_diblock_mask = -1

Definition at line 85 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.prev_isGood = True

Definition at line 86 of file getGoodRuns4SAM.py.

int getGoodRuns4SAM.run = int(epoch(tv))/100

Definition at line 89 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.run_range = psycopg2.extras.NumericRange(thisrun, nextrun, '[)')

Definition at line 261 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.run_rows = processFarDetData(data, det, tag)

Definition at line 238 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.sampwd = None

Definition at line 52 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.sampwdFile = None

Definition at line 53 of file getGoodRuns4SAM.py.

getGoodRuns4SAM.sep

Definition at line 112 of file getGoodRuns4SAM.py.

int getGoodRuns4SAM.subrun = int(epoch(tv))%100

Definition at line 90 of file getGoodRuns4SAM.py.

Referenced by comi::NearlineAna.analyze(), om::OnMonProd.analyze(), AnaPlotMaker(), BuildMetricsTree(), BuildMetricsTree_OnMon(), BuildOldTree(), caf::Proxy< caf::SRHeader >.CheckEquals(), caf::Proxy< caf::SRNeutrino >.CheckEquals(), caf::Proxy< caf::SRSpill >.CheckEquals(), CheckSubrun(), CheckTrueDate(), CleanupPrelim(), CleanupTree(), flat::Flat< caf::SRHeader >.Clear(), flat::Flat< caf::SRNeutrino >.Clear(), flat::Flat< caf::SRSpill >.Clear(), CondenseDetCfg(), CondenseRunList(), DCMOffsetCalculator(), DDTOnMonPlotMaker(), comi::ChanOcc.endSubRun(), FileNameToRunSubrun(), flat::Flat< caf::SRHeader >.Fill(), flat::Flat< caf::SRNeutrino >.Fill(), flat::Flat< caf::SRSpill >.Fill(), FillTree(), GetManualSubruns(), GetPartList(), GetPartList_4DB(), GetProcessed(), GetRunInfo(), nova::dbi::RunHistory.GoodDiBlockMask(), GoodRuns(), chaninfo::BadChanList.LoadNewData(), make_cosmic_eff_table(), MakeDetCfgCSV(), MakeDQValidityCSV(), MakeDQValidityCSVND(), MakeRunList(), Nearline_Watchdog_Plots(), NewNearlinePlots(), om::OnMonProd.NewRunNumber(), om::OnMonProd.NewSubrunNumber(), nova::dbi::RunHistory.NFEBs(), OnMonAnaHistosFEB_IssueRates(), OnMonAnaHistosPIX(), OnMonPlotMaker(), cmf::EventId.operator<(), caf::Proxy< caf::SRHeader >.operator=(), caf::Proxy< caf::SRNeutrino >.operator=(), caf::Proxy< caf::SRSpill >.operator=(), plot_cosmic_eff(), PlotDB_Web(), PlotOnMon(), plotTime(), om::IPC.PostResources(), caf::CAFMaker.produce(), util::TimeFilter.ReadEventFile(), util::EventFilterNoSlice.reconfigure(), util::RunEventFilter.reconfigure(), SamFileNameToRunSubrun(), nova::dbi::RunHistory.SetGoodDiBlockMask(), SetupOutTree(), om::FEBRateAnalysis.StoreContent(), novaddt::RunInfoStatic.Subrun(), TB_Nearline_Watchdog_Plots(), om::Ticker.Update(), and State.Write().

getGoodRuns4SAM.t0 = text2datetime("0")
getGoodRuns4SAM.t1 = text2datetime("100000000")

Definition at line 20 of file getGoodRuns4SAM.py.

Referenced by art::detail::CanBeAggregated< std::array< T, N > >.aggregate(), singlekaon_xsec.Amatrix_NN(), genie::AlamSimoAtharVacasSKPXSec2014.Amatrix_NN(), singlekaon_xsec.Amatrix_NP(), genie::AlamSimoAtharVacasSKPXSec2014.Amatrix_NP(), singlekaon_xsec.Amatrix_PP(), genie::AlamSimoAtharVacasSKPXSec2014.Amatrix_PP(), zcl::SMMTriggerAna.analyze(), beamlinereco::ToFPositionRecoAnalysis.analyze(), beamlinereco::LEHitFinder< T >.BackwardFindingOfHitStart(), beamlinereco::CFDHitFinder< T >.BackwardFindingOfHitStart(), novaddt::HoughPoint.calc(), distance(), ifdb::IFDBSpillInfo.extrapolate_position(), highe::HighEnergyFilt.filter(), novaddt::HighETrigger.filter(), novaddt::SlowMMTrigger.filter(), beamlinereco::CFDHitFinder< T >.FindHitWidth(), lem.get_http_response_internal(), novaddt::SupernovaTrigger.GetCandidates(), nutools::dbi::Table.GetConnection(), nova::dbi::Table.GetConnection(), nutools::dbi::Table.GetDataFromWebService(), nova::dbi::Table.GetDataFromWebService(), genie::HAIntranuke.Inelastic(), genie::HAIntranuke2018.Inelastic(), runh::BadDataFilter.LoadBadTimeRanges(), main(), evtsum::EventSummary.MakeOutput(), osc::OscCalc.P_internal_me(), osc::OscCalc.P_internal_mt(), osc::OscCalc.P_internal_te(), zcl::SPCluster.produce(), comi::Cana.produce(), nl::TimeSeriesData.RangeTime(), evd::GeometryDrawer.ShowCellAndPlaneNumbers(), mono::SlowMonopoleTrigger.SlowMonopoleTrigger(), osc::analytic.SolveCubic(), sn.SortTrackEndsByTime(), and tbrecoplots().

getGoodRuns4SAM.table = db.table(tname, columns)
getGoodRuns4SAM.tag = None

Definition at line 16 of file getGoodRuns4SAM.py.

Referenced by daq2raw::SpillWrapper.add(), genie::XclsTag.AsString(), art::Wrapper< T >.Class_Version(), compareEvents(), compareSelectedSets(), art::ModuleBase.consumes(), art::ModuleBase.consumesView(), ConvertGeantToPdg(), om::HistoSet.CopyAndResetOne(), art::prevent_recursion< T >.create_empty_sampled_product(), DrawCovMx(), caf::CAFMaker.endJob(), calib::SumRunsCalib.endRun(), Expression.fetchAll(), Expression.fetchOne(), skim::SkimmerAna.FillNueHistograms(), skim::CosmicBeamComparison.FillNueHistograms(), skim::SkimmingUtils.FillSliceVector(), art::FindMany< ProdB, void >.FindMany(), art::FindMany< ProdB, Data >.FindMany(), art::FindManyP< ProdB, void >.FindManyP(), art::FindManyP< ProdB, Data >.FindManyP(), art::FindOne< ProdB, void >.FindOne(), art::FindOne< ProdB, Data >.FindOne(), art::FindOneP< ProdB, void >.FindOneP(), art::FindOneP< ProdB, Data >.FindOneP(), GenerateCovMx(), art::DataViewImpl.getProductTokens(), ana::covmx::Sample.GetTag(), muonid.HighestPIDTrack(), remid.HighestPIDTrack(), HTag(), art::EDProduct.insertIfSampledProduct(), joint_fit_2018_contours(), joint_fit_2018_slices(), joint_fit_2019_contours(), joint_fit_2019_slices(), ana::NumuSyst.LoadFrom(), ana::NCSyst.LoadFrom(), ana::ISignalEstimator.LoadFrom(), ana::ReactorExperiment.LoadFrom(), ana::SolarConstraints.LoadFrom(), ana::NueSyst.LoadFrom(), ana::PredictionSterile.LoadFrom(), ana::TrivialSignalEstimator.LoadFrom(), ana::Binning.LoadFrom(), ana::PredictionCombinePeriods.LoadFrom(), ana::CrossSectionSpectra.LoadFrom(), ana::PredictionSystJoint2018.LoadFrom(), ana::PredictionSystJointDemo.LoadFrom(), ana::NDPredictionNoOsc.LoadFrom(), ana::NDOscillatableSpectrum.LoadFrom(), ana::ReweightableSpectrum.LoadFrom(), ana::TrivialCrossSectionAnalysis.LoadFrom(), ana::PredictionInterp.LoadFrom(), ana::BayesianSurface.LoadFrom(), ana::FrequentistSurface.LoadFrom(), ana::SystShifts.LoadFrom(), ana::SystMakerShiftSigma.LoadFrom(), ana::covmx::CovarianceMatrix.LoadFrom(), ana::OscillatableSpectrum.LoadFrom(), ana::PredictionSystNue2017.LoadFrom(), ana::SystMakerShift.LoadFrom(), ana::PredictionSystNumu2017.LoadFrom(), ana::MCMCSamples.LoadFrom(), ana::SystMaker.LoadFrom(), ana::Spectrum.LoadFrom(), ana::SystematicsMaker.LoadFrom(), ana.LoadFrom< IBkgdEstimator >(), ana.LoadFrom< IDecomp >(), ana.LoadFrom< IExperiment >(), ana.LoadFrom< IExtrap >(), ana.LoadFrom< IPrediction >(), ana.LoadFrom< ModularExtrapComponent >(), ana.LoadFrom< osc::IOscCalc >(), ana.LoadFrom< osc::IOscCalcAdjustable >(), genie::Spline.LoadFromXmlFile(), make_pi0_xcheck(), MakeSurface(), art::ModuleBase.mayConsume(), art::ModuleBase.mayConsumeView(), evdb::ParameterSetEditRow.ParameterSetEditRow(), ana::NuePlotStyle.PIDTag(), PIDTag(), plot_pi0_xcheck(), PrettyTag(), lem::LEMWorkerOutput.produce(), calib::SumAttenuationProfiles.readResults(), calib::AttenuationFit.readResults(), ana::LoadFromRegistry< BaseClass >.Register(), run_joint_fit_2020_contours(), run_joint_fit_2020_slices(), art::Sampled< T >.Sampled(), sensitivity_plot(), calib::TimingCache.SetEpochTag(), calib::DriftCache.SetEpochTag(), calib::AbsCache.SetEpochTag(), calib::AttenCache.SetEpochTag(), nova::dbi::RunHistory.SetGainSettingTag(), calib::TimingCache.SetTag(), calib::AbsCache.SetTag(), calib::DriftCache.SetTag(), calib::AttenCache.SetTag(), daq2raw::SpillWrapper.SpillWrapper(), calib::SumAttenuationProfiles.SumAttenuationProfiles(), calib::SumRunsCalib.SumRunsCalib(), and om::PlotViewer.UpdateCompare().

getGoodRuns4SAM.test = False

Definition at line 165 of file getGoodRuns4SAM.py.

Referenced by lem::dec::Forest.TrainSingle().

getGoodRuns4SAM.thisrun = row[0]

Definition at line 254 of file getGoodRuns4SAM.py.

Referenced by CondenseDetCfg().

string getGoodRuns4SAM.tname = "fardet.dq_subrun_info"
string getGoodRuns4SAM.Usage
Initial value:
1 = """
2 python getGoodRuns4SAM.py [options]
3 options:
4  -U <user>
5  -w <password>
6  -T <tag> [REQUIRED]
7 """

Definition at line 7 of file getGoodRuns4SAM.py.

string getGoodRuns4SAM.username = "nova_reader"

Definition at line 22 of file getGoodRuns4SAM.py.