Functions | Variables
APDHVSetting Namespace Reference

Functions

def settings (apddict, filesuffix)
 

Variables

 pswdloc = os.environ['NOVADBPWDFILE']
 
 pswdfile = open(pswdloc, "r")
 
 pswd = pswdfile.read()
 
string SQL = "dbname=nova_hardware host=ifdbprod.fnal.gov user=nova_reader password={} port=5432"
 
 parser = argparse.ArgumentParser()
 
 help
 
 action
 
 default
 
 args = parser.parse_args()
 
 useSafeMode = args.safe
 
 dcm = args.dcm
 
 connFL = psycopg2.connect(SQL)
 
 connAR = psycopg2.connect(SQL)
 
 curFL = connFL.cursor()
 
 curAR = connAR.cursor()
 
string debugName = "debuginfo.txt"
 
 debugFile = open(debugName, "w")
 
string dummy = 'dummyhw'
 
 nonFDHW = dict(dummy = (dummy, dummy))
 
 rows = curFL.fetchall()
 
 hw_type = str(row[1])
 
 chars = len(row[0])
 
 sn = row[0][chars-7:]
 
 feb = str(row[0])
 
 febsn1 = feb.replace('_', '.')
 
 febinfo = dict(dummy = (-999., -999.))
 
 febsn = febsn1.replace('-', '.')
 
 apdStatsLowT = dict(dummy = (-999, -999, 999.) )
 
 apdStatsHighT = dict(dummy = (-999, 999, 999.) )
 
 apd = row[0][chars-7:]
 
 batch = row[1]
 
 temp = row[2]
 
 vr = row[3]
 
tuple stats = (batch, temp, vr)
 
 prevStats = apdStatsHighT.get(apd)
 
 prevBatch = prevStats[0]
 
 now = time.localtime()
 
 apdToFEBLowT = dict(dummy = ((-999, -999, 999., -999, now), ('stupidfeb', -999, now, -999., -999), -999))
 
 apdToFEBHighT = dict(dummy = ((-999, -999, 999., -999, now), ('stupidfeb', -999, now, -999., -999), -999))
 
 bcid = row[0]
 
 apdadded = row[2]
 
 numrows = curAR.rowcount
 
 apdcon = curAR.fetchone()
 
 mod = apdcon[0]
 
 modcon = apdcon[1]
 
 macrows = curAR.fetchall()
 
 febcon = curAR.fetchone()
 
 added = febcon[3]
 
 febrows = curAR.fetchall()
 
 prevDate = added
 
 removed = febrow[6]
 
 febmb = febinfo.get(febsn)
 
tuple febdata = (febsn, febcon[1], added, febmb[0], febmb[1])
 
 apdstats = apdStatsLowT.get(apd)
 
tuple apdinfo = (apdstats[0], apdstats[1], apdstats[2], bcid, apdadded)
 

Function Documentation

def APDHVSetting.settings (   apddict,
  filesuffix 
)

Definition at line 13 of file APDHVSetting.py.

References novadaq::HexUtils.format(), if(), open(), and stan::math.round().

Referenced by MCGIDI_quantitiesLookupModes.getGroupIndex().

13 def settings(apddict, filesuffix) :
14 
15  fileName = "hv_"+filesuffix+".csv"
16  if(useSafeMode) :
17  fileName = "hv_Safe"+filesuffix+".csv"
18  settingFile = open(fileName, "w")
19  fileName = "apd_installation.txt"
20  locFile = open(fileName, "w")
21 
22  default = '1,default,-1,cold,1000.0,0,1,2,3,4\n'
23  scaleFactor = 1.
24 
25  # according to Leon M, warm voltages should be 0.976 the value recorded because we
26  # operate at 15C, not the warm test value of 25C
27  if(filesuffix == "HighT") :
28  default = '1,default,-1,warm,2000.0,0,1,2,3,4\n'
29  scaleFactor = 0.976
30 
31  # put in the default line
32  settingFile.write(default)
33 
34  # make a dictionary of apd to location on the detector
35  # additional information is diblock, dcm, febport, then voltage
36  keyval = 'dcm-2-999-999-999'
37  locationToAPD = dict( keyval = ( 'stupidapd', (-999, -999, 999., -999, now), ('stupidfeb', -999, now, -999., -999), -999, (-999, -999, -999), -999.))
38 
39  # loop over the apds
40  for apd in apddict.iterkeys():
41  data = apddict.get(apd)
42  apdinfo = data[0]
43  febdata = data[1]
44  mod = data[2]
45 
46  if(apdinfo[0] == -999) : continue
47 
48  # grab the location information for the apd from block/plane/module to diblock/dcm/feb port
49  SQL = "select CAST(btrim(fcom.location1, 'DIBLK:') AS INT) diblk, CAST(btrim(fcom.position1, 'DCM:') AS INT) dcm , CAST(btrim(fcom.port1,'PRT:') AS INT) feb, mod.block, mod.layer, mod.position_in_layer from fnalprod_public.feb_comm_cables fcom, module mod, barcoded_item bi where mod.barcoded_item_id={} and (mod.block=CAST(btrim(fcom.location2,'BLK:') AS INT) and mod.layer=CAST(btrim(fcom.position2,'PLN:') AS INT) and mod.position_in_layer=CAST(btrim(fcom.port2,'POS:') AS INT)) and bi.barcoded_item_id={} ORDER BY diblk ASC, dcm ASC, feb ASC".format(mod,apdinfo[3])
50  curAR.execute(SQL)
51  loc = curAR.fetchone()
52  location = (loc[0], loc[1], loc[2])
53  keyval = "dcm-2-{}-{}-{}".format(loc[0], loc[1], loc[2])
54 
55  # have all the pieces we need now
56  # - apd voltage and location in apdinfo
57  # - feb to apd connection in febtoapd
58  # - feb voltage slope and intercept, remember abscisa is 4095 steps
59  # find nearest integer to (apdinfo[2] - febdata[3])/febdata[4]
60  # 1,<dcmName>,<febId>,<coolingState>,<voltage>,2,0,0,0,0
61  intercept = febdata[3]
62  slope = febdata[4]
63  if slope == 0. :
64  slope = 0.02586
65 
66  voltage = (scaleFactor*apdinfo[2] - intercept)/slope
67  if(useSafeMode) :
68  voltage = (apdinfo[2] - 30 - intercept)/slope
69 
70  #voltage = (350 - intercept)/slope
71 
72  # test the voltage setting
73  if apdinfo[1] > 0 and (voltage < 2500 or voltage > 4094) :
74  #print "Setting for loc: {} with APD: {} at temp {} is out of range {}".format(keyval, apd, apdinfo[1], voltage)
75  if voltage > 4094: voltage = 4094
76  elif voltage < 2500: voltage = 2500
77  elif apdinfo[1] < 0 and (voltage < 1000 or voltage > 4000) :
78  #print "Setting for loc: {} with APD: {} at temp {} is out of range {}".format(keyval, apd, apdinfo[1], voltage)
79  if voltage > 4000: voltage = 4000
80  elif voltage < 1000: voltage = 1000
81 
82  # check to see if the electronics location has already been used. If not, then
83  # insert it into the dictionary. If it has been used, then make sure the most
84  # recent entry is in the dictionary
85  if keyval not in locationToAPD :
86  locationToAPD[keyval] = (apd, apdinfo, febdata, mod, location, voltage)
87  else :
88  data = locationToAPD.get(keyval)
89  prevAPD = data[0]
90  prevAPDInfo = data[1]
91  prevFEB = data[2]
92  debugFile.write("dcm-2-{}-{} port {} assigned twice: \n".format(location[0], location[1], location[2]))
93  debugFile.write("\t Currently assigned APD: {} {} {}\n".format(prevAPD, prevAPDInfo, prevFEB))
94  debugFile.write("\t Alternate assigned APD: {} {} {}\n".format(apd, apdinfo, febdata))
95  if apdinfo[4] > prevAPDInfo[4] :
96  locationToAPD[keyval] = (apd, apdinfo, febdata, mod, location, voltage)
97  debugFile.write("\t\t Using APD: {} {} {}\n".format(apd, apdinfo, febdata))
98  else :
99  debugFile.write("\t\t Using APD: {} {} {}\n".format(prevAPD, prevAPDInfo, prevFEB))
100 
101  # loop over all electronics locations in the dictionary and
102  # and write them out to the file. Also write out the location used
103  # and the relevant information about the APD installed there
104  for keyval in locationToAPD :
105 
106  data = locationToAPD.get(keyval)
107  apd = data[0]
108  apdinfo = data[1]
109  febdata = data[2]
110  mod = data[3]
111  location = data[4]
112  voltage = data[5]
113 
114  if location[0] == -999 : continue
115 
116  diblock = '{}'.format(location[0])
117  if location[0] < 10 : diblock = '0{}'.format(location[0])
118  dcmposition = '{}'.format(location[1])
119  if location[1] < 10 : dcmposition = '0{}'.format(location[1])
120  temp = "warm"
121  if apdinfo[1] < 0 : temp = "cold"
122 
123  dcmloc = 'dcm-2-{}-{}'.format(diblock, dcmposition)
124 
125  if dcm in dcmloc :
126  settingInfo = '1,{},{},{},{},2,0,0,0,0\n'.format(dcmloc, location[2], temp, round(voltage) )
127  locInfo = '{},{},{},{}\n'.format(dcmloc, location[2], apd, apdinfo[4])
128  settingFile.write(settingInfo)
129  locFile.write(locInfo)
130 
131  # close the files.
132  settingFile.close()
133  locFile.close()
134 
135 
136 #read in the password for the db
fvar< T > round(const fvar< T > &x)
Definition: round.hpp:23
if(dump)
def settings(apddict, filesuffix)
Definition: APDHVSetting.py:13
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
procfile open("FD_BRL_v0.txt")

Variable Documentation

APDHVSetting.action

Definition at line 145 of file APDHVSetting.py.

APDHVSetting.added = febcon[3]
APDHVSetting.apd = row[0][chars-7:]

Definition at line 233 of file APDHVSetting.py.

APDHVSetting.apdadded = row[2]

Definition at line 274 of file APDHVSetting.py.

APDHVSetting.apdcon = curAR.fetchone()

Definition at line 289 of file APDHVSetting.py.

tuple APDHVSetting.apdinfo = (apdstats[0], apdstats[1], apdstats[2], bcid, apdadded)

Definition at line 345 of file APDHVSetting.py.

APDHVSetting.apdstats = apdStatsLowT.get(apd)

Definition at line 344 of file APDHVSetting.py.

APDHVSetting.apdStatsHighT = dict(dummy = (-999, 999, 999.) )

Definition at line 227 of file APDHVSetting.py.

APDHVSetting.apdStatsLowT = dict(dummy = (-999, -999, 999.) )

Definition at line 226 of file APDHVSetting.py.

APDHVSetting.apdToFEBHighT = dict(dummy = ((-999, -999, 999., -999, now), ('stupidfeb', -999, now, -999., -999), -999))

Definition at line 267 of file APDHVSetting.py.

APDHVSetting.apdToFEBLowT = dict(dummy = ((-999, -999, 999., -999, now), ('stupidfeb', -999, now, -999., -999), -999))

Definition at line 266 of file APDHVSetting.py.

APDHVSetting.args = parser.parse_args()

Definition at line 147 of file APDHVSetting.py.

APDHVSetting.batch = row[1]
APDHVSetting.bcid = row[0]

Definition at line 273 of file APDHVSetting.py.

APDHVSetting.chars = len(row[0])

Definition at line 191 of file APDHVSetting.py.

APDHVSetting.connAR = psycopg2.connect(SQL)

Definition at line 164 of file APDHVSetting.py.

APDHVSetting.connFL = psycopg2.connect(SQL)

Definition at line 158 of file APDHVSetting.py.

APDHVSetting.curAR = connAR.cursor()

Definition at line 170 of file APDHVSetting.py.

APDHVSetting.curFL = connFL.cursor()

Definition at line 169 of file APDHVSetting.py.

APDHVSetting.dcm = args.dcm

Definition at line 149 of file APDHVSetting.py.

APDHVSetting.debugFile = open(debugName, "w")

Definition at line 179 of file APDHVSetting.py.

string APDHVSetting.debugName = "debuginfo.txt"

Definition at line 178 of file APDHVSetting.py.

APDHVSetting.default

Definition at line 146 of file APDHVSetting.py.

string APDHVSetting.dummy = 'dummyhw'
APDHVSetting.feb = str(row[0])

Definition at line 194 of file APDHVSetting.py.

Referenced by cmap::dataprov::CMap.AddException(), comi::DataCheck.analyze(), tbana::DetectorRateShutOff.analyze(), comi::FEBFlash.analyze(), tbana::DetectorRateShutOff.beginJob(), chaninfo::FindSwappedChannels.beginSubRun(), BuildMetricsTree_OnMon(), daqchannelmap::NearDetDAQChannelMap.computeFEB(), daqchannelmap::TestBeamDAQChannelMap.computeFEB(), daqchannelmap::FarDetDAQChannelMap.computeFEB(), rsim::ReadoutSim.CreateRawDigits(), nova::dbi::RunHistory::DCM.DCM(), daqchannelmap::NearDetDAQChannelMap.encodeDChan(), daqchannelmap::TestBeamDAQChannelMap.encodeDChan(), daqchannelmap::FarDetDAQChannelMap.encodeDChan(), daqchannelmap::NearDetDAQChannelMap.encodeLChan(), daqchannelmap::TestBeamDAQChannelMap.encodeLChan(), daqchannelmap::FarDetDAQChannelMap.encodeLChan(), tbana::DetectorRateShutOff.EndSpill(), febrates(), febshutoff(), om::PlotClickHandler.FEButcInfo(), chaninfo::FindSwappedChannels.fill_hist_and_tree(), mcdatadaq::DCMSimulator.generateNanoSlice(), cmap::dataprov::CMap.getFEB(), nova::dbi::RunHistory.GetFEB(), mcdatadaq::DCMSimulator.getFEBSimulator(), nova::dbi::RunHistory.GetGain(), GetHist(), mcdatadaq::DAQSimulator.getNanoSliceOrder(), nova::dbi::RunHistory.GetPedestal(), nova::dbi::RunHistory.GetPixelGain(), nova::dbi::RunHistory.GetPixelGains(), om::PlotClickHandler.HwDCMHistogramInfo(), om::PlotClickHandler.HwDetHistogramInfo(), om::PlotClickHandler.HwPCHistogramInfoX(), om::PlotClickHandler.HwPCHistogramInfoY(), chaninfo::BadChanList.IsBadUncached(), nova::dbi::RunHistory.IsCooled(), nova::dbi::RunHistory.LoadHardwareInfo(), chaninfo::BadChanList.LoadNewData(), mcdatadaq::NanoSliceOrder.print(), mcdatadaq::DAQSimulator.print(), evd::RawDataDrawer.RawDigitHardware(), om::IPC.RequestAddToWatchList(), om::IPC.RequestRemoveFromWatchList(), calib::DriftCorrection.respondToCloseOutputFiles(), om::WatchListBox.UpdateCurrentList(), and dq::FlasherFinder.Veto().

APDHVSetting.febcon = curAR.fetchone()

Definition at line 312 of file APDHVSetting.py.

tuple APDHVSetting.febdata = (febsn, febcon[1], added, febmb[0], febmb[1])

Definition at line 335 of file APDHVSetting.py.

APDHVSetting.febinfo = dict(dummy = (-999., -999.))

Definition at line 203 of file APDHVSetting.py.

APDHVSetting.febmb = febinfo.get(febsn)

Definition at line 334 of file APDHVSetting.py.

APDHVSetting.febrows = curAR.fetchall()

Definition at line 319 of file APDHVSetting.py.

APDHVSetting.febsn = febsn1.replace('-', '.')

Definition at line 213 of file APDHVSetting.py.

APDHVSetting.febsn1 = feb.replace('_', '.')

Definition at line 195 of file APDHVSetting.py.

APDHVSetting.help

Definition at line 145 of file APDHVSetting.py.

APDHVSetting.hw_type = str(row[1])

Definition at line 189 of file APDHVSetting.py.

APDHVSetting.macrows = curAR.fetchall()

Definition at line 295 of file APDHVSetting.py.

APDHVSetting.mod = apdcon[0]
APDHVSetting.modcon = apdcon[1]

Definition at line 291 of file APDHVSetting.py.

APDHVSetting.nonFDHW = dict(dummy = (dummy, dummy))

Definition at line 184 of file APDHVSetting.py.

APDHVSetting.now = time.localtime()

Definition at line 264 of file APDHVSetting.py.

APDHVSetting.numrows = curAR.rowcount

Definition at line 284 of file APDHVSetting.py.

APDHVSetting.parser = argparse.ArgumentParser()

Definition at line 144 of file APDHVSetting.py.

APDHVSetting.prevBatch = prevStats[0]

Definition at line 247 of file APDHVSetting.py.

APDHVSetting.prevDate = added

Definition at line 321 of file APDHVSetting.py.

APDHVSetting.prevStats = apdStatsHighT.get(apd)

Definition at line 246 of file APDHVSetting.py.

APDHVSetting.pswd = pswdfile.read()

Definition at line 139 of file APDHVSetting.py.

APDHVSetting.pswdfile = open(pswdloc, "r")

Definition at line 138 of file APDHVSetting.py.

APDHVSetting.pswdloc = os.environ['NOVADBPWDFILE']

Definition at line 137 of file APDHVSetting.py.

APDHVSetting.removed = febrow[6]

Definition at line 326 of file APDHVSetting.py.

Referenced by trk::WindowTrackingAlg.MakeTrack().

APDHVSetting.rows = curFL.fetchall()

Definition at line 187 of file APDHVSetting.py.

APDHVSetting.sn = row[0][chars-7:]

Definition at line 192 of file APDHVSetting.py.

Referenced by RawMilliBlock.set().

string APDHVSetting.SQL = "dbname=nova_hardware host=ifdbprod.fnal.gov user=nova_reader password={} port=5432"

Definition at line 141 of file APDHVSetting.py.

tuple APDHVSetting.stats = (batch, temp, vr)

Definition at line 237 of file APDHVSetting.py.

APDHVSetting.temp = row[2]

Definition at line 235 of file APDHVSetting.py.

Referenced by om::WatchListManager.Add(), ana.Add3FlavorAna2020XSecSysts(), ana.AddJointAna2017XSecSysts(), ana.AddJointAna2018XSecSysts(), ana.AddNusAna2020XSecSysts(), slicer::S4DParamCalc.analyze(), fuzz::FuzzyKValidate.analyze(), bpfit::BreakPointProtonAna.analyze(), boost::python::vector_indexing_suite< Container, NoProxy, final_vector_derived_policies< Container, NoProxy > >.base_extend(), boost::python::detail::slice_helper< Container, DerivedPolicies, ProxyHandler, Data, Index >.base_set_slice(), caf_numu_nd_cutflow(), caf_numu_nuenergy_vs_xy(), caf_numu_reco_minus_true(), caf_numu_validation(), caf_numu_vars(), Calculate2DChi2(), daqqc::QualityCheck.checkEvent(), daqqc::QualityCheck.checkRun(), novaddt::RemoveNoise.CleanSlice(), ana.ComparisonTableOne(), CLibSymbolInfo.ConvertBigEndian(), CylindricalSmoothing(), d3sigma_calc(), d4sigma_calc(), d4sigma_hist(), DCMOffsetCalculator(), util::HoughCalc.DeleteChain(), genie::flux::GJPARCNuFlux.DLocName2Id(), evd::TZProjPad.Draw(), calib::DCMTimingOffset.endJob(), calib::DCMTimingOffset.endRun(), genie::BaryonResonanceDecayer.EvolveDeltaBR(), stan::math.factor_U(), fd_plot(), novaddt::SpaceSlice.filter(), novaddt::TimeDCMSlice.filter(), genie::Algorithm.FindConfig(), util::HoughCalc.FindLineErrs(), FindMedianCLContours(), art::Hash< I >.fixup(), getContoursFromDeltaChiSqr(), cosrej::CosRejFxs.getCVVars(), getErrorBand(), GetFakeData(), evd::SimulationDrawer.GetFLSHits(), getFractionalErrorBand(), SystEntry.GetLimits(), GetLimits(), GetMockData(), ana.GetNumuData2020(), evd::SliceNavigator.GetProductsImplFull(), evd::RawDataDrawer.GetRawDigits(), evd::RawDataDrawer.GetRawDigitsMulti(), evd::RawDataDrawer.GetRawTrigger(), goodness_of_fit(), om::PlotClickHandler.HwDetDoubleClick(), joint_fit_2017_slices(), joint_fit_2018_contours(), joint_fit_2018_slices(), joint_fit_2019_bestfit(), joint_fit_2019_contours(), joint_fit_2019_slices(), joint_fit_future_bestfit_univ(), joint_fit_future_contour_univ(), genie::NievesQELCCPXSec.leviCivita(), dbutils::RunHistory.Load(), nova::dbi::RunHistory.LoadAPDSettings(), ana::NumuCCIncAnalysis.LoadFrom(), cmf::PlotUtilities.Make2DContours(), FormatFile.makeDataFile(), MakeFakeExperiment(), fnex.MakeGraphs(), MakeMePlot(), nerd::NERDProng.MakeProngs(), trk::CosmicTrackAlg.MakeTrack(), mre_blessed(), mre_comp_split(), util::HoughCalc.newNode(), util::HoughCalc.nodeUpdate(), numu_sig_nonmax(), numu_validation_numuvars(), NuSCalculateCorr(), stan::math.operator++(), stan::math.operator--(), art::TriggerResults.operator=(), art::HLTGlobalStatus.operator=(), stan::math.pareto_type_2_cdf(), stan::math.pareto_type_2_lccdf(), stan::math.pareto_type_2_lcdf(), ana::NumuCCIncAnalysis.PlotEfficiency(), ana::NDPredictionSterile.Predict(), ana::NDPredictionSterile.PredictComponent(), slicer::PointManager.PreparekDistInfo(), art::Hash< I >.print(), PrintErrorSurface(), FormatFile.process(), slid::Recluster.produce(), fuzz::FuzzyKVertex.produce(), nerd::NERDProng.produce(), ana::NumuCCIncAnalysis.Project(), osc::OscCalcPMNSOptEigen.PropMatter(), stan::math.quad_form_diag(), stan::math.read_corr_L(), genie::MECHadronTensor.ReadHadTensorqzq0File(), fnex::ReadFitResults.readResults(), reduce_the_predfile_nue_numu(), nerd::NERDEval.remove_overlap(), hdf5::HDF5Maker.respondToOpenInputFile(), caf::CAFMaker.respondToOpenInputFile(), ana::NumuCCIncAnalysis.ReturnHists(), run_joint_fit_2020_bestfit(), run_joint_fit_2020_contours(), run_joint_fit_2020_slices(), selection_story_plots(), sensitivity2018(), sensitivity2020(), osc::PMNS_Sterile.SetAngle(), osc::PMNS_Sterile.SetDelta(), red::MatterProbe.SetMap(), sha1_forRMS_process(), ana.sort_chisq_tot(), slicer::SlicerAna.sortEffPur(), SystsGENIEAna(), Tutorial2019Fit(), Tutorial2019FitContours(), Tutorial2019FitSlices(), om::WatchListBox.UpdateCurrentList(), util::HoughCalc.UpdateTree(), and validation_numu_nd().

APDHVSetting.useSafeMode = args.safe

Definition at line 148 of file APDHVSetting.py.

APDHVSetting.vr = row[3]

Definition at line 236 of file APDHVSetting.py.