/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes
DybDbi::mapr::Mapr Class Reference

List of all members.

Public Member Functions

def scan
def __init__
def feeChannelId
def __call__
def toDict
def validity_scan

Public Attributes

 svcMode
 cableSvc

Properties

 vrec = property(_get_vrec, _set_vrec, doc=_set_vrec.__doc__)
 all validities

Private Member Functions

def _set_vrec
def _get_vrec
def _cableSvc
def _insertDateSvcMode
def _sensorId

Private Attributes

 _vrec

Detailed Description

Definition at line 11 of file mapr.py.


Constructor & Destructor Documentation

def DybDbi::mapr::Mapr::__init__ (   self)
Provide ``DetectorSensor`` to ``feeChannelId`` mappings at context and task 
corresponding to the validity record (obtainable from any DBI table eg using ``rpt.vrec`` )

The validity record specifies both ``Context`` and task.  
The timestamp used corresponds to the ``INSERTDATE`` of the validity record.

Definition at line 18 of file mapr.py.

00019                       :
00020         """ 
00021         Provide ``DetectorSensor`` to ``feeChannelId`` mappings at context and task 
00022         corresponding to the validity record (obtainable from any DBI table eg using ``rpt.vrec`` )
00023 
00024         The validity record specifies both ``Context`` and task.  
00025         The timestamp used corresponds to the ``INSERTDATE`` of the validity record.
00026 
00027         """ 
00028         self._vrec = None 
00029         self.svcMode = None
00030         self.cableSvc = self._cableSvc()       


Member Function Documentation

def DybDbi::mapr::Mapr::scan (   cls,
  kls 
)

Definition at line 14 of file mapr.py.

00015                       :
00016         mpr = cls()
00017         return mpr.validity_scan(kls)

def DybDbi::mapr::Mapr::_set_vrec (   self,
  vrec 
) [private]
:param vrec: validity record 

Setting `vrec` attribute updates the ``svcMode`` used to make cablesvc calls

Definition at line 31 of file mapr.py.

00032                              :
00033         """
00034         :param vrec: validity record 
00035 
00036         Setting `vrec` attribute updates the ``svcMode`` used to make cablesvc calls
00037         """
00038         self._vrec = vrec
        self.svcMode = self._insertDateSvcMode(vrec)        
def DybDbi::mapr::Mapr::_get_vrec (   self) [private]

Definition at line 39 of file mapr.py.

00040                        :
        return self._vrec 
def DybDbi::mapr::Mapr::_cableSvc (   self) [private]
:return: cableSvc

Definition at line 43 of file mapr.py.

00044                        :
00045         """
00046         :return: cableSvc
00047         """
00048         from Gaudi.Configuration import ApplicationMgr
00049         theApp = ApplicationMgr()
00050         theApp.ExtSvc.append('DybCableSvc/DybCableSvc')
00051         from GaudiPython import AppMgr
00052         global appMgr
00053         appMgr = AppMgr()
00054         appMgr.initialize()
00055         global cableSvc
00056         cableSvc = appMgr.service('DybCableSvc','ICableSvc')
00057         assert cableSvc, 'Failed to lookup DybCableSvc'
00058         return cableSvc

def DybDbi::mapr::Mapr::_insertDateSvcMode (   self,
  vrec 
) [private]
:param vrec: validity record
:return: ``SvcMode`` instance corresponding to the insertdate of the record

Definition at line 59 of file mapr.py.

00060                                       :
00061         """
00062         :param vrec: validity record
00063         :return: ``SvcMode`` instance corresponding to the insertdate of the record
00064         """ 
00065         from GaudiPython import gbl
00066         ServiceMode = gbl.ServiceMode
00067         Context = gbl.Context
00068         ictx = Context(vrec.contextrange.sitemask,vrec.contextrange.simmask,vrec.insertdate,vrec.subsite)
00069         svcMode = ServiceMode(ictx,vrec.task)
00070         return svcMode         

def DybDbi::mapr::Mapr::_sensorId (   self,
  sensorData 
) [private]
:param sensorData: fullPackedData integer of a ``DetectorSensor`` 
:return: instance of appropriate ``DetectorSensor`` subclass 

See :dybgaudi:`DataModel/Conventions/Conventions/Detectors.h`

Definition at line 71 of file mapr.py.

00072                                     :
00073         """
00074         :param sensorData: fullPackedData integer of a ``DetectorSensor`` 
00075         :return: instance of appropriate ``DetectorSensor`` subclass 
00076 
00077         See :dybgaudi:`DataModel/Conventions/Conventions/Detectors.h`
00078         """
00079         from GaudiPython import gbl
00080         DetectorSensor = gbl.DayaBay.DetectorSensor
00081         AdPmtSensor = gbl.DayaBay.AdPmtSensor
00082         PoolPmtSensor = gbl.DayaBay.PoolPmtSensor
00083         RpcSensor = gbl.DayaBay.RpcSensor
00084 
00085         if type(sensorData) != int:
00086             sensorData = sensorData.fullPackedData()
00087 
00088         sensor = None
00089         ds = DetectorSensor(sensorData)
00090         if ds.isAD():
00091             sensor=AdPmtSensor(sensorData)
00092         elif ds.isWaterShield():
00093             sensor=PoolPmtSensor(sensorData)
00094         elif ds.isRPC():
00095             sensor=RpcSensor(sensorData)
00096         else:
00097             raise Exception("_sensorId: sensorData %s is unrecognized" % sensorData)
00098         return sensor 
00099 

def DybDbi::mapr::Mapr::feeChannelId (   self,
  sensorData 
)
:param sensorData: integer fullPackedData of a DetectorSensor (typically these are the raw numbers persisted in SENSORID columns of DB)

Hmm there us potential to get stale answers depending on cableSvc cache interaction with rollback ?

Definition at line 100 of file mapr.py.

00101                                        :
00102         """
00103         :param sensorData: integer fullPackedData of a DetectorSensor (typically these are the raw numbers persisted in SENSORID columns of DB)
00104 
00105         Hmm there us potential to get stale answers depending on cableSvc cache interaction with rollback ?
00106         """ 
00107         if not self.svcMode:
00108             raise Exception("must establish svcMode (context,task) by assigning .vrec before calling ")
00109         sensorId = self._sensorId(sensorData)
00110         channelId = self.cableSvc.feeChannelId(sensorId,self.svcMode);
00111         return channelId
00112 

def DybDbi::mapr::Mapr::__call__ (   self,
  sensorData 
)

Definition at line 113 of file mapr.py.

00114                                    :
00115         return self.feeChannelId( sensorData )
00116 

def DybDbi::mapr::Mapr::toDict (   self,
  rpt,
  mapkey = True,
  smry = False 
)
:param rpt: DybDbi `Rpt` instance
:param mapkey: when `True` the keying id is mapped
:param smry: when `True` provide just the fullPackedData as the value, rather than the row instance
:return: dict containing DbiTableRow instances keyed my mapped or direct `.sensorid`

Assumptions:

#. rows obtained from the `rpt` have `sensorid` attribute which can mapped to the id used for keying 

Definition at line 117 of file mapr.py.

00118                                                    :
00119         """
00120         :param rpt: DybDbi `Rpt` instance
00121         :param mapkey: when `True` the keying id is mapped
00122         :param smry: when `True` provide just the fullPackedData as the value, rather than the row instance
00123         :return: dict containing DbiTableRow instances keyed my mapped or direct `.sensorid`
00124 
00125         Assumptions:
00126 
00127         #. rows obtained from the `rpt` have `sensorid` attribute which can mapped to the id used for keying 
00128 
00129         """
00130         d = {}
00131         for r in rpt:
00132             sid = r.sensorid
00133             if mapkey:
00134                 cid = self(sid)
00135                 k = cid.fullPackedData()
00136                 assert k not in d, "key already present %s " % k
00137                 v = sid.fullPackedData()   
00138             else:
00139                 k = sid.fullPackedData() 
00140                 v = None                # smry without mapkey not yet implemented
00141             d[k] = v if smry else r  
00142         return d

def DybDbi::mapr::Mapr::validity_scan (   self,
  kls,
  skips = () 
)
:param kls: `DybDbi` class
:param skips: list of SEQNO to skip

:return: (`SEQNO` keyed dict containing mappings, running time in seconds)

Check cableMap-ings at all validities of the kls, using Rollback to 
apply the approriate vintage of CableMap

Definition at line 143 of file mapr.py.

00144                                              :
00145         """
00146         :param kls: `DybDbi` class
00147         :param skips: list of SEQNO to skip
00148 
00149         :return: (`SEQNO` keyed dict containing mappings, running time in seconds)
00150 
00151         Check cableMap-ings at all validities of the kls, using Rollback to 
00152         apply the approriate vintage of CableMap
00153 
00154         """
00155         from DybDbi import Rollback
00156         t0 = time.time()
00157         sqlcontext, task, subsite = "1=1", -1, -1     ## all validities
00158         vrb = kls.GetTableProxy().MakeValidityRecBuilder( sqlcontext, subsite, task )
00159         seqno_ = lambda _:int(_.seqno)
00160         seq = map(seqno_,vrb)
00161         seqnos = filter(lambda _:_ not in skips, seq )
00162         log.info("skipping %s " % repr(skips) )
00163         amap = {}
00164         for seqno in sorted(seqnos): 
00165             vrec = vrb.GetValidityRecFromSeqNo(seqno)  
00166             rpt = kls.Rpt().Clone()
00167             rpt.ctx(validityrec=vrec )
00168             log.info("seqno %s" % seqno)
00169             self.vrec = vrec   # adjusts svcMode to use the appropriate CableMap and Rollback ensures the correct vintage
00170             with Rollback(self.vrec.insertdate):
00171                 amap[seqno] = self.toDict( rpt, mapkey=True, smry=True ) 
00172             pass
00173         t1 = time.time()
00174         log.warn("from total of %s seqno skipped %s namely %s " % ( len(seq), len(skips), repr(skips)))
00175         return amap, t1 - t0
00176 


Member Data Documentation

Definition at line 25 of file mapr.py.

Definition at line 25 of file mapr.py.

Definition at line 25 of file mapr.py.


Property Documentation

DybDbi::mapr::Mapr::vrec = property(_get_vrec, _set_vrec, doc=_set_vrec.__doc__) [static]

all validities

Definition at line 41 of file mapr.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:57:24 for DybDbi by doxygen 1.7.4