#include <CalSignalTool.h>
Inheritance diagram for CalSignalTool:


Public Member Functions | |
| CalSignalTool (const std::string &type, const std::string &name, const IInterface *parent) | |
| default ctor, declares jobOptions | |
| StatusCode | initialize () |
| StatusCode | finalize () |
| StatusCode | getDiodeSignal (CalUtil::DiodeIdx diodeIdx, float &signal) |
| get signal level for given cal diode. | |
| const CalRelationMap * | getCalRelationMap () |
| get map bewteen McIntegrating hits and crystals | |
| void | handle (const Incident &inc) |
| hook the BeginEvent so that we can check our validity once per event. | |
Private Types | |
| typedef CalUtil::CalVec< CalUtil::DiodeIdx, float > | CalSignalMap |
| map diodes to electronic signal levels | |
Private Member Functions | |
| void | newEvent () |
| clear internal tables | |
| StatusCode | syncData () |
| ensure that internal data is either sync'd with current event or empty | |
| StatusCode | loadSignalMaps () |
| load internal maps with MC data from TDS | |
| StatusCode | calcNoise () |
| apply electronic noise calcuation to entire cal | |
| StatusCode | calcPoissonicNoiseXtal (const CalUtil::XtalIdx xtalIdx) |
| apply poissonic noise (based on electron count) calculation to single crystal | |
| StatusCode | calcElectronicNoiseXtal (const CalUtil::XtalIdx xtalIdx) |
| apply electronic noise (pedestal width) calculation to single crystal | |
| StatusCode | registerHitRel (Event::McIntegratingHit &hit) |
| register McHit <> Xtal relation | |
| StatusCode | retrieveConstants () |
| retrieve constants from db | |
| StatusCode | sumHit (const Event::McIntegratingHit &hit) |
| sum hit signal to all applicable diodes in private store | |
Private Attributes | |
| CalSignalMap | m_calSignalMap |
| map diodes to electronic signal levels | |
| CalRelationMap | m_calRelMap |
| map crystals to MCIntegratingHits | |
| bool | m_isValid |
| if current private data store is valid | |
| IDataProviderSvc * | m_evtSvc |
| ptr to event svc | |
| int | m_eTowerCAL |
| volume ID enumeration | |
| int | m_eLATTowers |
| volume ID enumeration | |
| int | m_eMeasureX |
| volume ID enum | |
| int | m_eXtal |
| volume ID enum | |
| int | m_ePerMeV [2] |
| gain - electrons/MeV 1=Sm, 0=Large | |
| StringProperty | m_xtalSignalToolName |
| name of Tool for calculating single xtal signal response. | |
| IXtalSignalTool * | m_xtalSignalTool |
| pointer to xtal signal tool | |
| BooleanProperty | m_enableNoise |
| enable noise simulation | |
| StringProperty | m_precalcCalibName |
| name of precalc calib tool | |
| IPrecalcCalibTool * | m_precalcCalib |
| pointer to precalcCalibTool | |
| StringProperty | m_calCalibSvcName |
| name of CalCalibSvc to use for calib constants. | |
| ICalCalibSvc * | m_calCalibSvc |
| pointer to CalCalibSvc object. | |
| IGlastDetSvc * | m_detSvc |
| used for constants & conversion routines. | |
| std::vector< CalUtil::TwrNum > | m_twrList |
| list of active tower bays, populated at run time | |
jobOptions
Definition at line 51 of file CalSignalTool.h.
|
|
map diodes to electronic signal levels
Definition at line 108 of file CalSignalTool.h. |
|
||||||||||||||||
|
default ctor, declares jobOptions
Definition at line 39 of file CalSignalTool.cxx. References m_calCalibSvcName, m_enableNoise, m_precalcCalibName, and m_xtalSignalToolName.
00042 : AlgTool(type,name,parent), 00043 m_isValid(false), 00044 m_evtSvc(0), 00045 m_eTowerCAL(0), 00046 m_eLATTowers(0), 00047 m_eMeasureX(0), 00048 m_eXtal(0), 00049 m_xtalSignalTool(0), 00050 m_precalcCalib(0), 00051 m_calCalibSvc(0), 00052 m_detSvc(0) 00053 { 00054 declareInterface<ICalSignalTool>(this); 00055 00056 declareProperty("CalCalibSvc", m_calCalibSvcName = "CalCalibSvc"); 00057 declareProperty("XtalSignalToolName", m_xtalSignalToolName = "XtalSignalTool"); 00058 declareProperty("enableNoise", m_enableNoise = true); 00059 declareProperty("PrecalcCalibTool", m_precalcCalibName = "PrecalcCalibTool"); 00060 00061 } |
|
|
apply electronic noise (pedestal width) calculation to single crystal
Definition at line 330 of file CalSignalTool.cxx. References IPrecalcCalibTool::getPedSigCIDAC(), m_calSignalMap, and m_precalcCalib. Referenced by calcNoise().
00330 {
00331 using namespace CalUtil;
00332
00333 for (XtalDiode xtalDiode;
00334 xtalDiode.isValid();
00335 xtalDiode++) {
00336
00337 const XtalRng xRng(xtalDiode.getFace(),
00338 xtalDiode.getDiode().getX8Rng());
00339 const RngIdx rngIdx(xtalIdx, xRng);
00340
00341 // get pedestal sigma
00342 float pedSig;
00343 StatusCode sc = m_precalcCalib->getPedSigCIDAC(rngIdx, pedSig);
00344 if (sc.isFailure()) return sc;
00345
00346 // use same rand for both ranges
00347 // since the X1 & X8 noise
00348 const float rnd = CLHEP::RandGauss::shoot();
00349
00350 m_calSignalMap[DiodeIdx(xtalIdx,xtalDiode)] += pedSig*rnd;
00351 } // for (XtalDiode)
00352
00353 return StatusCode::SUCCESS;
00354 }
|
|
|
apply electronic noise calcuation to entire cal Loop through (installed) towers and crystals; Definition at line 299 of file CalSignalTool.cxx. References calcElectronicNoiseXtal(), calcPoissonicNoiseXtal(), and m_twrList. Referenced by syncData().
00299 {
00300 using namespace CalUtil;
00301
00303 for (unsigned twrSeq = 0; twrSeq < m_twrList.size(); twrSeq++) {
00304 // get bay id of nth live tower
00305 const TwrNum twr(m_twrList[twrSeq]);
00306 for (LyrNum lyr; lyr.isValid(); lyr++)
00307 for (ColNum col; col.isValid(); col++) {
00308
00309 // assemble current calXtalId
00310 const XtalIdx xtalIdx(twr,
00311 lyr,
00312 col);
00313
00314 StatusCode sc = calcPoissonicNoiseXtal(xtalIdx);
00315 if (sc.isFailure())
00316 return sc;
00317
00318 sc = calcElectronicNoiseXtal(xtalIdx);
00319 if (sc.isFailure())
00320 return sc;
00321
00322
00323 } // xtal loop
00324 } // twr loop
00325
00326 return StatusCode::SUCCESS;
00327 }
|
|
|
apply poissonic noise (based on electron count) calculation to single crystal
Definition at line 357 of file CalSignalTool.cxx. References ICalCalibSvc::getMPD(), m_calCalibSvc, m_calSignalMap, and m_ePerMeV. Referenced by calcNoise().
00357 {
00358 using namespace CalUtil;
00359
00360 // retrieve mevPerDAC calibration object
00361 CalibData::CalMevPerDac const * const calibMPD = m_calCalibSvc->getMPD(xtalIdx);
00362 if (!calibMPD) return StatusCode::FAILURE;
00363
00364 // store actual mevPerDAC values in usable array.
00365 CalVec<DiodeNum, float> mpd;
00366 mpd[CalUtil::LRG_DIODE] = calibMPD->getBig()->getVal();
00367 mpd[CalUtil::SM_DIODE] = calibMPD->getSmall()->getVal();
00368
00369
00370 for (XtalDiode xDiode; xDiode.isValid(); xDiode++) {
00371 const DiodeNum diode = xDiode.getDiode();
00372 const DiodeIdx diodeIdx(xtalIdx, xDiode);
00373
00374 // convert cidac in diode to MeV in xtal
00375 float meVXtal = m_calSignalMap[diodeIdx]*mpd[diode];
00376
00377 // MeV in xtal -> electrons in diode
00378 float eDiode = meVXtal * m_ePerMeV[diode.val()];
00379
00380 // apply poissonic fluctuation to # of electrons.
00381 float noise = CLHEP::RandGauss::shoot();
00382 noise *= sqrt(eDiode);
00383
00384 // add noise
00385 eDiode += noise;
00386
00387 // convert back to cidac in diode
00388 meVXtal = eDiode/m_ePerMeV[diode.val()];
00389 m_calSignalMap[diodeIdx] =
00390 meVXtal/mpd[diode];
00391
00392 }
00393 return StatusCode::SUCCESS;
00394 }
|
|
|
Definition at line 63 of file CalSignalTool.h.
00063 {return StatusCode::SUCCESS;}
|
|
|
get map bewteen McIntegrating hits and crystals check that all internal data is up2date Implements ICalSignalTool. Definition at line 178 of file CalSignalTool.cxx. References ICalSignalTool::CalRelationMap, m_calRelMap, and syncData().
00178 {
00180 StatusCode sc = syncData();
00181 if (sc.isFailure())
00182 return 0;
00183
00184 return &m_calRelMap;
00185 }
|
|
||||||||||||
|
get signal level for given cal diode. check that all internal data is up2date Implements ICalSignalTool. Definition at line 397 of file CalSignalTool.cxx. References m_calSignalMap, and syncData().
00398 {
00400 if (syncData().isFailure())
00401 return StatusCode::FAILURE;
00402
00403 signal = m_calSignalMap[diodeIdx];
00404
00405 return StatusCode::SUCCESS;
00406 }
|
|
|
hook the BeginEvent so that we can check our validity once per event.
Definition at line 409 of file CalSignalTool.cxx. References newEvent().
00409 {
00410 if ((inc.type() == "BeginEvent"))
00411 newEvent();
00412
00413 return;
00414 }
|
|
|
Definition at line 63 of file CalSignalTool.cxx. References m_calCalibSvc, m_calCalibSvcName, m_detSvc, m_evtSvc, m_precalcCalib, m_precalcCalibName, m_twrList, m_xtalSignalTool, m_xtalSignalToolName, and retrieveConstants().
00063 {
00064 MsgStream msglog(msgSvc(), name());
00065 msglog << MSG::INFO << "initializing" << endreq;
00066
00067 //-- jobOptions --//
00068 StatusCode sc;
00069 if ((sc = setProperties()).isFailure()) {
00070 msglog << MSG::ERROR << "Failed to set properties" << endreq;
00071 return sc;
00072 }
00073
00074 //-- Retreive EventDataSvc
00075 sc = serviceLocator()->service( "EventDataSvc", m_evtSvc, true );
00076 if(sc.isFailure()){
00077 msglog << MSG::ERROR << "Could not find EventDataSvc" << endreq;
00078 return sc;
00079 }
00080
00081 // now try to find the GlastDetSvc service
00082 sc = service("GlastDetSvc", m_detSvc);
00083 if (sc.isFailure() ) {
00084 MsgStream msglog(msgSvc(), name());
00085 msglog << MSG::ERROR << " Unable to get GlastDetSvc " << endreq;
00086 return sc;
00087 }
00088
00089 //-- Retrieve constants from GlastDetSVc
00090 sc = retrieveConstants();
00091 if (sc.isFailure())
00092 return sc;
00093
00094 //-- find out which tems are installed.
00095 m_twrList = CalUtil::findActiveTowers(*m_detSvc);
00096
00097 //-- Retrieve xtalSignalTool
00098 sc = toolSvc()->retrieveTool("XtalSignalTool",
00099 m_xtalSignalToolName,
00100 m_xtalSignalTool,
00101 this );
00102 if (sc.isFailure() ) {
00103 msglog << MSG::ERROR << " Unable to create " << m_xtalSignalToolName << endreq;
00104 return sc;
00105 }
00106
00107 // Get ready to listen for BeginEvent
00108 IIncidentSvc* incSvc;
00109 sc = service("IncidentSvc", incSvc, true);
00110 if (sc.isSuccess() ) {
00111 incSvc->addListener(this, "BeginEvent"); // priority not important
00112 } else {
00113 msglog << MSG::ERROR << "can't find IncidentSvc" << endreq;
00114 return sc;
00115 }
00116
00117 // this tool may also be shared by CalTrigTool, global ownership
00118 sc = toolSvc()->retrieveTool("PrecalcCalibTool",
00119 m_precalcCalibName,
00120 m_precalcCalib,
00121 0); // shared by other code
00122 if (sc.isFailure() ) {
00123 msglog << MSG::ERROR << " Unable to create " << m_precalcCalibName << endreq;
00124 return sc;
00125 }
00126
00127 // obtain CalCalibSvc
00128 sc = service(m_calCalibSvcName.value(), m_calCalibSvc);
00129 if (sc.isFailure()) {
00130 msglog << MSG::ERROR << "can't get " << m_calCalibSvcName << endreq;
00131 return sc;
00132 }
00133
00134 return StatusCode::SUCCESS;
00135 }
|
|
|
load internal maps with MC data from TDS
Definition at line 214 of file CalSignalTool.cxx. References m_eLATTowers, m_eTowerCAL, m_evtSvc, registerHitRel(), and sumHit(). Referenced by syncData().
00214 {
00215 // get McIntegratingHit collection. Abort if empty.
00216 SmartDataPtr<Event::McIntegratingHitVector>
00217 McCalHits(m_evtSvc, EventModel::MC::McIntegratingHitCol );
00218
00219 if (McCalHits == 0) {
00220 // create msglog only when needed for speed.
00221 MsgStream msglog(msgSvc(), name());
00222 msglog << MSG::DEBUG;
00223 if (msglog.isActive()){
00224 msglog.stream() << "no cal hits found" ;}
00225 msglog << endreq;
00226 return StatusCode::SUCCESS;
00227 }
00228
00229 // loop over hits - pick out CAL hits
00230 for (Event::McIntegratingHitVector::const_iterator it = McCalHits->begin();
00231 it != McCalHits->end();
00232 it++) {
00233
00234 // get volumeId from hit
00235 const idents::VolumeIdentifier volId =
00236 ((idents::VolumeIdentifier)(*it)->volumeID());
00237
00238 // extracting parameters from volume Id identifying as in CAL
00239 if ((int)volId[CalUtil::fLATObjects] == m_eLATTowers &&
00240 (int)volId[CalUtil::fTowerObjects] == m_eTowerCAL) {
00241
00242 // apply hit signal to relavant diodes
00243 StatusCode sc = sumHit(**it);
00244 if (sc.isFailure())
00245 return sc;
00246
00247 // store MCHit <> xtal relation
00248 sc = registerHitRel(**it);
00249 if (sc.isFailure())
00250 return sc;
00251
00252 }
00253 }
00254
00255
00256 return StatusCode::SUCCESS;
00257 }
|
|
|
clear internal tables
Definition at line 166 of file CalSignalTool.cxx. References m_calRelMap, m_calSignalMap, and m_isValid. Referenced by handle().
00166 {
00167
00168 fill(m_calSignalMap.begin(),
00169 m_calSignalMap.end(),
00170 0);
00171
00172 m_calRelMap.clear();
00173
00174 m_isValid = false;
00175 }
|
|
|
register McHit <> Xtal relation retrieve crystal id from hit Definition at line 289 of file CalSignalTool.cxx. References ICalSignalTool::CalRelation, and m_calRelMap. Referenced by loadSignalMaps().
00289 {
00291 const CalUtil::XtalIdx xtalIdx(idents::CalXtalId(hit.volumeID()));
00292
00293 m_calRelMap.insert(CalRelation(xtalIdx, &hit));
00294
00295 return StatusCode::SUCCESS;
00296 }
|
|
|
retrieve constants from db
Definition at line 138 of file CalSignalTool.cxx. References m_detSvc, m_eLATTowers, m_eMeasureX, m_ePerMeV, m_eTowerCAL, and m_eXtal. Referenced by initialize().
00138 {
00139 double value;
00140 typedef map<int*,string> PARAMAP;
00141
00142
00143 PARAMAP param;
00144 param[&m_eTowerCAL] = string("eTowerCAL");
00145 param[&m_eLATTowers] = string("eLATTowers");
00146 param[&m_eXtal] = string("eXtal");
00147 param[&m_eMeasureX] = string("eMeasureX");
00148 param[m_ePerMeV+1] = string("cal.ePerMeVSmall");
00149 param[m_ePerMeV] = string("cal.ePerMevLarge");
00150
00151
00152
00153 for(PARAMAP::iterator it=param.begin(); it!=param.end();it++){
00154 if(!m_detSvc->getNumericConstByName((*it).second, &value)) {
00155 MsgStream msglog(msgSvc(), name());
00156 msglog << MSG::ERROR << " constant " <<(*it).second
00157 <<" not defined" << endreq;
00158 return StatusCode::FAILURE;
00159 } else *((*it).first)=(int)value;
00160 }
00161
00162 return StatusCode::SUCCESS;
00163 }
|
|
|
sum hit signal to all applicable diodes in private store
Definition at line 260 of file CalSignalTool.cxx. References IXtalSignalTool::calculate(), m_calSignalMap, and m_xtalSignalTool. Referenced by loadSignalMaps().
00260 {
00261 // retrieve crystal id from hit
00262 using namespace idents;
00263 using namespace CalUtil;
00264
00265 const XtalIdx xtalIdx(CalXtalId(hit.volumeID()));
00266
00267 // destination for signal data from this hit
00268 CalUtil::CalVec<CalUtil::XtalDiode, float> hitSignal;
00269
00270 // convert the hit into signal level
00271 StatusCode sc = m_xtalSignalTool->calculate(hit,
00272 hitSignal);
00273 if (sc.isFailure())
00274 return sc;
00275
00276 // sum xtal signals into full arry
00277 for (XtalDiode xtalDiode;
00278 xtalDiode.isValid();
00279 xtalDiode++) {
00280 const DiodeIdx diodeIdx(xtalIdx, xtalDiode);
00281
00282 m_calSignalMap[diodeIdx] += hitSignal[xtalDiode];
00283 }
00284
00285 return StatusCode::SUCCESS;
00286 }
|
|
|
ensure that internal data is either sync'd with current event or empty sum individual mc hits calc electronic noise (independent of hits) indicate that event data is up-to-date for now return early if we've already calcuated everything for this event Definition at line 189 of file CalSignalTool.cxx. References calcNoise(), loadSignalMaps(), m_enableNoise, and m_isValid. Referenced by getCalRelationMap(), and getDiodeSignal().
00189 {
00192 if (m_isValid)
00193 return StatusCode::SUCCESS;
00194
00196 StatusCode sc = loadSignalMaps();
00197 if (sc.isFailure())
00198 return sc;
00199
00201 if (m_enableNoise) {
00202 sc = calcNoise();
00203 if (sc.isFailure())
00204 return sc;
00205 }
00206
00208 m_isValid = true;
00209
00210 return StatusCode::SUCCESS;
00211 }
|
|
|
pointer to CalCalibSvc object.
Definition at line 157 of file CalSignalTool.h. Referenced by calcPoissonicNoiseXtal(), and initialize(). |
|
|
name of CalCalibSvc to use for calib constants.
Definition at line 154 of file CalSignalTool.h. Referenced by CalSignalTool(), and initialize(). |
|
|
map crystals to MCIntegratingHits
Definition at line 114 of file CalSignalTool.h. Referenced by getCalRelationMap(), newEvent(), and registerHitRel(). |
|
|
map diodes to electronic signal levels
Definition at line 111 of file CalSignalTool.h. Referenced by calcElectronicNoiseXtal(), calcPoissonicNoiseXtal(), getDiodeSignal(), newEvent(), and sumHit(). |
|
|
used for constants & conversion routines.
Definition at line 160 of file CalSignalTool.h. Referenced by initialize(), and retrieveConstants(). |
|
|
volume ID enumeration
Definition at line 126 of file CalSignalTool.h. Referenced by loadSignalMaps(), and retrieveConstants(). |
|
|
volume ID enum
Definition at line 129 of file CalSignalTool.h. Referenced by retrieveConstants(). |
|
|
enable noise simulation
Definition at line 144 of file CalSignalTool.h. Referenced by CalSignalTool(), and syncData(). |
|
|
gain - electrons/MeV 1=Sm, 0=Large
Definition at line 135 of file CalSignalTool.h. Referenced by calcPoissonicNoiseXtal(), and retrieveConstants(). |
|
|
volume ID enumeration
Definition at line 123 of file CalSignalTool.h. Referenced by loadSignalMaps(), and retrieveConstants(). |
|
|
ptr to event svc
Definition at line 120 of file CalSignalTool.h. Referenced by initialize(), and loadSignalMaps(). |
|
|
volume ID enum
Definition at line 132 of file CalSignalTool.h. Referenced by retrieveConstants(). |
|
|
if current private data store is valid
Definition at line 117 of file CalSignalTool.h. Referenced by newEvent(), and syncData(). |
|
|
pointer to precalcCalibTool
Definition at line 150 of file CalSignalTool.h. Referenced by calcElectronicNoiseXtal(), and initialize(). |
|
|
name of precalc calib tool
Definition at line 147 of file CalSignalTool.h. Referenced by CalSignalTool(), and initialize(). |
|
|
list of active tower bays, populated at run time
Definition at line 164 of file CalSignalTool.h. Referenced by calcNoise(), and initialize(). |
|
|
pointer to xtal signal tool
Definition at line 141 of file CalSignalTool.h. Referenced by initialize(), and sumHit(). |
|
|
name of Tool for calculating single xtal signal response.
Definition at line 138 of file CalSignalTool.h. Referenced by CalSignalTool(), and initialize(). |
1.3.3