-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Idea is to use psanaBase for handling 1 vs 2 differences, and move all shared vars and funcs into suiteBase
- Loading branch information
1 parent
1e8c412
commit b02e721
Showing
7 changed files
with
467 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from calibrationSuite.psanaBase import * | ||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
def setupPsana1(baseObj): | ||
|
||
if baseObj.runRange is None: | ||
baseObj.ds = baseObj.get_ds(baseObj.run) | ||
else: | ||
baseObj.run = baseObj.runRange[0] | ||
baseObj.ds = baseObj.get_ds() | ||
|
||
baseObj.det = Detector("%s.0:%s.%d" % (baseObj.location, baseObj.detType, baseObj.camera), baseObj.ds.env()) | ||
baseObj.evrs = None | ||
try: | ||
baseObj.wave8 = Detector(baseObj.fluxSource, baseObj.ds.env()) | ||
except: | ||
baseObj.wave8 = None | ||
baseObj.config = None | ||
try: | ||
baseObj.controlData = Detector("ControlData") | ||
except: | ||
baseObj.controlData = None | ||
|
||
def getFluxPsana1(baseObj, evt): | ||
try: | ||
fluxes = baseObj.wave8.get(evt).peakA() | ||
if fluxes is None: | ||
print("No flux found") ## if baseObj.verbose? | ||
logger.error("No flux found") | ||
return None | ||
f = fluxes[baseObj.fluxChannels].mean() * baseObj.fluxSign | ||
try: | ||
if f < baseObj.fluxCut: | ||
return None | ||
except: | ||
pass | ||
except: | ||
return None | ||
return f | ||
|
||
def isKickedPsana1(baseObj, evt): | ||
try: | ||
evr = evt.get(EvrData.DataV4, baseObj.evrs[0]) | ||
except: | ||
baseObj.get_evrs() | ||
evr = evt.get(EvrData.DataV4, baseObj.evrs[0]) | ||
|
||
## kicked = False | ||
## try: | ||
## for ec in evr.fifoEvents(): | ||
## if ec.eventCode() == 162: | ||
## return True | ||
kicked = True | ||
try: | ||
for ec in evr.fifoEvents(): | ||
if ec.eventCode() == 137: | ||
kicked = False | ||
except: | ||
pass | ||
return kicked | ||
|
||
def getEvtPsana1(baseObj, run=None): | ||
oldDs = baseObj.ds | ||
if run is not None: | ||
baseObj.ds = baseObj.get_ds(run) | ||
try: ## or just yield evt I think | ||
evt = next(baseObj.ds.events()) | ||
except StopIteration: | ||
baseObj.ds = oldDs | ||
return None | ||
baseObj.ds = oldDs | ||
return evt | ||
|
||
def getRawDataPsana1(baseObj, evt, gainBitsMasked=True): | ||
frames = baseObj.det.raw(evt) | ||
if frames is None: | ||
return None | ||
if gainBitsMasked: | ||
return frames & 0x3FFF | ||
return frames |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from calibrationSuite.psanaBase import * | ||
logger = logging.getLogger(__name__) | ||
|
||
def setupPsana2(baseObj): | ||
|
||
if baseObj.runRange is None: | ||
baseObj.ds = baseObj.get_ds(baseObj.run) | ||
else: | ||
baseObj.run = baseObj.runRange[0] | ||
baseObj.ds = baseObj.get_ds() | ||
|
||
baseObj.myrun = next(baseObj.ds.runs()) | ||
try: | ||
baseObj.step_value = baseObj.myrun.Detector("step_value") | ||
baseObj.step_docstring = baseObj.myrun.Detector("step_docstring") | ||
except: | ||
baseObj.step_value = baseObj.step_docstring = None | ||
|
||
## baseObj.det = Detector('%s.0:%s.%d' %(baseObj.location, baseObj.detType, baseObj.camera), baseObj.ds.env()) | ||
## make this less dumb to accomodate epixM etc. | ||
## use a dict etc. | ||
baseObj.det = baseObj.myrun.Detector(baseObj.experimentHash['detectorType']) | ||
if baseObj.det is None: | ||
print("no det object for epixhr, what? Pretend it's ok.") | ||
##raise Exception | ||
## could set to None and reset with first frame I guess, or does the det object know? | ||
|
||
baseObj.timing = baseObj.myrun.Detector("timing") | ||
baseObj.desiredCodes = {"120Hz": 272, "4kHz": 273, "5kHz": 274} | ||
|
||
try: | ||
baseObj.mfxDg1 = baseObj.myrun.Detector("MfxDg1BmMon") | ||
except: | ||
baseObj.mfxDg1 = None | ||
print("No flux source found") ## if baseObj.verbose? | ||
logger.exception("No flux source found") | ||
try: | ||
baseObj.mfxDg2 = baseObj.myrun.Detector("MfxDg2BmMon") | ||
except: | ||
baseObj.mfxDg2 = None | ||
## fix hardcoding in the fullness of time | ||
baseObj.detEvts = 0 | ||
baseObj.flux = None | ||
|
||
baseObj.evrs = None | ||
try: | ||
baseObj.wave8 = Detector(baseObj.fluxSource, baseObj.ds.env()) | ||
except: | ||
baseObj.wave8 = None | ||
baseObj.config = None | ||
try: | ||
baseObj.controlData = Detector("ControlData") | ||
except: | ||
baseObj.controlData = None | ||
|
||
def getEvtPsana2(baseObj): | ||
try: | ||
evt = next(baseObj.myrun.events()) | ||
## dumb to do the below everywhere, should best not call this method | ||
##try: | ||
## baseObj.flux = baseObj._getFlux(evt) | ||
##except: | ||
## pass | ||
|
||
except StopIteration: | ||
return None | ||
return evt | ||
|
||
def getRawDataPsana2(baseObj, evt, gainBitsMasked=True): | ||
frames = baseObj.det.raw.raw(evt) | ||
if frames is None: | ||
return None | ||
if baseObj.special: | ||
if 'thirteenBits' in baseObj.special: | ||
frames = (frames & 0xfffe) | ||
##print("13bits") | ||
elif 'twelveBits' in baseObj.special: | ||
frames = (frames & 0xfffc) | ||
##print("12bits") | ||
elif 'elevenBits' in baseObj.special: | ||
frames = (frames & 0xfff8) | ||
##print("11bits") | ||
elif 'tenBits' in baseObj.special: | ||
frames = (frames & 0xfff0) | ||
##print("10bits") | ||
if gainBitsMasked: | ||
return frames & baseObj.gainBitsMask | ||
return frames | ||
|
Oops, something went wrong.