Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ValBase Class Reference

base class for the XxxValsTools More...

#include <ValBase.h>

Inheritance diagram for ValBase:

Inheritance graph
[legend]
Collaboration diagram for ValBase:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::pair< std::string,
TypedPointer * > 
valPair
typedef std::vector< valPair * > valMap
typedef valMap::iterator mapIter
typedef valMap::const_iterator constMapIter

Public Member Functions

 ValBase (const std::string &type, const std::string &name, const IInterface *parent)
 ~ValBase ()
virtual void zeroVals ()
 clear map values

virtual void addItem (std::string varName, double *pValue)
 add an item to the map

virtual void addItem (std::string varName, float *pValue)
virtual void addItem (std::string varName, int *pValue)
virtual void addItem (std::string varName, unsigned int *pValue)
virtual void addItem (std::string varName, unsigned long long *pValue)
virtual void addItem (std::string varName, char *pValue)
virtual StatusCode doCalcIfNotDone ()
 let the user trigger her own calculation

virtual StatusCode getVal (std::string varName, double &value, int check=CALC)
 get a particular value, using ntuple name default forces calculation

virtual StatusCode getVal (std::string varName, float &value, int check=CALC)
virtual StatusCode getVal (std::string varName, int &value, int check=CALC)
virtual StatusCode getVal (std::string varName, unsigned int &value, int check=CALC)
virtual StatusCode getVal (std::string varName, unsigned long long &value, int check=CALC)
virtual StatusCode getVal (std::string varName, std::string &value, int check=CALC)
 return a string containing the value, as above

virtual StatusCode getValCheck (std::string varName, double &value)
 get a particular value, using ntuple name, with calc checking (called by AnaTup)

virtual StatusCode getValCheck (std::string varName, float &value)
virtual StatusCode getValCheck (std::string varName, int &value)
virtual StatusCode getValCheck (std::string varName, unsigned int &value)
virtual StatusCode getValCheck (std::string varName, unsigned long long &value)
virtual StatusCode getValCheck (std::string varName, std::string &value)
virtual bool getArrayArg (std::string varName, std::string &baseName, int &dim)
virtual std::string getFullName (std::string varName, int dim)
virtual void announceBadName (std::string varName)
 output the list of names

virtual StatusCode browse (MsgStream log, const std::string varName="")
 output the names and values, either all (default) or just one;

virtual void handle (const Incident &inc)
 this is called by the incident service at the beginning of an event

virtual IValsTool::Visitor::eVisitorRet traverse (IValsTool::Visitor *v, const bool checkCalc)
 callback for visitor

virtual int getCalcCount ()
 number of times a tool did its calculation for this event

virtual StatusCode calculate ()
 calculate all values; implemented by each XxxValsTool

virtual StatusCode initialize ()
virtual void setLoadOrder (int index)
 AnaTup loaded this object.

virtual bool isLoaded ()
virtual int getLoadOrder ()

Protected Member Functions

StatusCode getTypedPointer (std::string varName, TypedPointer *&ptr, int check)
void printHeader (MsgStream &log)
void setAnaTupBit ()

Static Protected Member Functions

double sign (double x)
 some static methods sign of a number

double globalToLocal (double x, double pitch, int n)
 turn a global coordinate (tower, ladder, wafer) roughly into a local one

double circleFraction (double r)
double circleFractionSimpson (double r, double angle_factor)

Protected Attributes

valMap m_ntupleMap
 map containing ntuple names, and pointers to the ntuple variables

IIncidentSvc * m_incSvc
 pointer to incident service

IDataProviderSvc * m_pEventSvc
 let ValBase handle the pointer to the data service, everyone uses it

bool m_newEvent
 flag to signal new event

int m_check
 flag to allow an always-calculate call if 0; if 1 checks and sets m_newEvent if -1 skips calculation

int m_calcCount
 count calls to tools

int m_loadOrder
 tells if this routine has been "loaded" by AnalysisNtupleAlg


Static Protected Attributes

const int s_badVal = -9999
 Obvious "bad" value if an exception occurs whild computing output variables.


Detailed Description

base class for the XxxValsTools

Author:
Leon Rochester

Definition at line 65 of file ValBase.h.


Member Typedef Documentation

typedef valMap::const_iterator ValBase::constMapIter
 

Definition at line 71 of file ValBase.h.

Referenced by browse(), getTypedPointer(), and traverse().

typedef valMap::iterator ValBase::mapIter
 

Definition at line 70 of file ValBase.h.

Referenced by CalValsTool::calculate(), zeroVals(), and ~ValBase().

typedef std::vector<valPair*> ValBase::valMap
 

Definition at line 69 of file ValBase.h.

typedef std::pair<std::string, TypedPointer*> ValBase::valPair
 

Definition at line 68 of file ValBase.h.

Referenced by addItem(), browse(), and traverse().


Constructor & Destructor Documentation

ValBase::ValBase const std::string &  type,
const std::string &  name,
const IInterface *  parent
 

Definition at line 23 of file ValBase.cxx.

00026                          : AlgTool( type, name, parent ), m_loadOrder(-1) { }

ValBase::~ValBase  ) 
 

Definition at line 68 of file ValBase.cxx.

References m_ntupleMap, and mapIter.

00069 {
00070     mapIter it = m_ntupleMap.begin();
00071     for ( ; it!=m_ntupleMap.end(); ++it) {
00072         delete (*it)->second;
00073         delete (*it);
00074     }
00075 }


Member Function Documentation

void ValBase::addItem std::string  varName,
char *  pValue
[virtual]
 

Definition at line 220 of file ValBase.cxx.

References getArrayArg(), m_ntupleMap, STRING, and valPair.

00221 {
00222     std::string baseName;
00223     int dim;
00224     bool hasArg = getArrayArg(varName, baseName, dim);
00225     if(hasArg) {
00226         dim = 1;
00227         std::cout << std::endl << "AnalysisNtuple/varBase " << std::endl;
00228         std::cout << "     " << varName << ": arrays of strings not allowed" << std::endl;
00229         std::cout << "     first one will be used... " << std::endl << std::endl;
00230     }
00231 
00232     TypedPointer* ptr = new TypedPointer(STRING, (void*) pValue, dim);
00233     valPair* pair = new valPair(baseName, ptr);
00234 
00235     m_ntupleMap.push_back(pair);
00236 }

void ValBase::addItem std::string  varName,
unsigned long long *  pValue
[virtual]
 

Definition at line 209 of file ValBase.cxx.

References getArrayArg(), m_ntupleMap, ULONG64, and valPair.

00210 {
00211     std::string baseName;
00212     int dim;
00213     /*bool hasArg =*/ getArrayArg(varName, baseName, dim);
00214     TypedPointer* ptr = new TypedPointer(ULONG64, (void*) pValue, dim);
00215     valPair* pair = new valPair(baseName, ptr);
00216 
00217     m_ntupleMap.push_back(pair);
00218 }

void ValBase::addItem std::string  varName,
unsigned int *  pValue
[virtual]
 

Definition at line 198 of file ValBase.cxx.

References getArrayArg(), m_ntupleMap, UINT, and valPair.

00199 {
00200     std::string baseName;
00201     int dim;
00202     /*bool hasArg =*/ getArrayArg(varName, baseName, dim);
00203     TypedPointer* ptr = new TypedPointer(UINT, (void*) pValue, dim);
00204     valPair* pair = new valPair(baseName, ptr);
00205 
00206     m_ntupleMap.push_back(pair);
00207 }

void ValBase::addItem std::string  varName,
int *  pValue
[virtual]
 

Definition at line 187 of file ValBase.cxx.

References getArrayArg(), INT, m_ntupleMap, and valPair.

00188 {
00189     std::string baseName;
00190     int dim;
00191     /*bool hasArg =*/ getArrayArg(varName, baseName, dim);
00192     TypedPointer* ptr = new TypedPointer(INT, (void*) pValue, dim);
00193     valPair* pair = new valPair(baseName, ptr);
00194 
00195     m_ntupleMap.push_back(pair);
00196 }

void ValBase::addItem std::string  varName,
float *  pValue
[virtual]
 

Definition at line 177 of file ValBase.cxx.

References FLOAT, getArrayArg(), m_ntupleMap, and valPair.

00178 {
00179     std::string baseName;
00180     int dim;
00181     /*bool hasArg =*/ getArrayArg(varName, baseName, dim);
00182     TypedPointer* ptr = new TypedPointer(FLOAT, (void*) pValue, dim);
00183     valPair* pair = new valPair(baseName, ptr);
00184 
00185     m_ntupleMap.push_back(pair);
00186 }

void ValBase::addItem std::string  varName,
double *  pValue
[virtual]
 

add an item to the map

Definition at line 166 of file ValBase.cxx.

References DOUBLE, getArrayArg(), m_ntupleMap, and valPair.

Referenced by VtxValsTool::initialize(), TkrValsTool::initialize(), TkrHitValsTool::initialize(), ObfValsTool::initialize(), McValsTool::initialize(), McTkrHitValsTool::initialize(), McKludgeValsTool::initialize(), McAnalValsTool::initialize(), GltValsTool::initialize(), GcrSelectValsTool::initialize(), GcrReconValsTool::initialize(), EvtValsTool::initialize(), CalValsTool::initialize(), CalMipValsTool::initialize(), and AcdValsTool::initialize().

00167 {
00168     std::string baseName;
00169     int dim;
00170     /*bool hasArg =*/ getArrayArg(varName, baseName, dim);
00171     TypedPointer* ptr = new TypedPointer(DOUBLE, (void*) pValue, dim);
00172     valPair* pair = new valPair(baseName, ptr);
00173 
00174     m_ntupleMap.push_back(pair);
00175 }

void ValBase::announceBadName std::string  varName  )  [virtual]
 

output the list of names

Definition at line 596 of file ValBase.cxx.

Referenced by getTypedPointer().

00597 {
00598     MsgStream log(msgSvc(), name());
00599 
00600     std::string delim     = ""; //"\"";
00601     std::string separator = " ";
00602     std::string indent    = "    ";
00603     
00604     std::cout << " ValsTool called with unknown name: " << delim << varName << delim << std::endl;
00605     /*
00606     std::cout << " Known names are: " ;
00607 
00608     int length = indent.size();
00609     int count;
00610 
00611     constMapIter it = m_ntupleMap.begin();
00612     for (count=0; it!=m_ntupleMap.end(); ++it, ++count) {
00613         valPair* pair = *it;
00614         std::string thisName = pair->first;
00615         int dim = (pair->second)->getDim();
00616         char result[80];
00617         sprintf(result, "%i",dim);
00618         if (dim>1) thisName = thisName+"["+result+"]";
00619         length += (thisName.size() + 2*delim.size() + separator.size());
00620         if(length>78) {
00621             std::cout << std::endl << indent ;
00622             length = indent.size();
00623         }
00624         std::cout << delim << thisName << delim << " ";
00625     }
00626     std::cout << std::endl;
00627     */
00628 }

StatusCode ValBase::browse MsgStream  log,
const std::string  varName = ""
[virtual]
 

output the names and values, either all (default) or just one;

Implements IValsTool.

Definition at line 238 of file ValBase.cxx.

References CALC, CHECK, constMapIter, doCalcIfNotDone(), DOUBLE, FLOAT, getArrayArg(), INT, m_check, m_ntupleMap, UINT, ULONG64, valPair, and valType.

00239 {
00240     // browse always triggers a calculation, which doesn't reset the m_newEvent flag
00241 
00242     m_check = CALC;
00243 
00244     //log << MSG::INFO << "ValBase::browse called" << endreq;
00245 
00246     std::string delim     = ""; //"\"";
00247     std::string separator = " ";
00248     std::string indent    = "    ";
00249     
00250     if(doCalcIfNotDone().isFailure()) {
00251         m_check = CHECK;
00252         return StatusCode::FAILURE;
00253     }
00254     m_check = CHECK;
00255 
00256     std::string varName;
00257     int element;
00258     bool hasArg = getArrayArg(varName0, varName, element);
00259     if (!hasArg) element = 0;
00260     bool doAll = !hasArg;
00261 
00262     
00263     if (varName!="") {
00264         log << MSG::INFO << " Variable " ;
00265     } else {
00266         log   << MSG::INFO << " Values of the variables:" << endreq << indent;
00267     }
00268     int length = indent.size();
00269     constMapIter it = m_ntupleMap.begin();
00270     
00271     for ( ; it!=m_ntupleMap.end(); ++it) {
00272         valPair* pair = *it;
00273         if (varName!="" && varName!=pair->first) continue;
00274         int valLen = 13;
00275         int deltaL= (pair->first).size() + 2*delim.size() + separator.size() + valLen + 2;
00276         length += deltaL;
00277         if(length>78) {
00278             log << MSG::INFO << endreq << indent ;
00279             length = indent.size() + deltaL;
00280         }
00281         log << delim << pair->first << delim << ": " ;
00282 
00283         TypedPointer* ptr = (*it)->second;
00284         valType type = ptr->getType();
00285         int dim = ptr->getDim();
00286         if(element>=dim || element<0) {
00287             log << MSG::ERROR << "Browse: error in arg: " << element << endreq;
00288             assert(element>=dim || element<0);
00289         }
00290 
00291         int start = (doAll ? 0 : element);
00292         int end   = (doAll ? dim-1 : element);
00293         void* vPtr = ptr->getPointer();
00294 
00295         int i;
00296         if (doAll && dim>1) log << "(";
00297 
00298 // LSR 14-Jul-08 code for ntuple types  
00299       
00300         for (i=start; i<=end; ++i) {
00301 
00302             switch (type) {
00303             case FLOAT: 
00304                 log << *(reinterpret_cast<float*>(vPtr)+i);
00305                 break;
00306             case DOUBLE:
00307                 log << *(reinterpret_cast<double*>(vPtr)+i);
00308                 break;
00309             case INT:
00310                 log << *(reinterpret_cast<int*>(vPtr)+i);
00311                 break;
00312             case UINT: 
00313                 log << *(reinterpret_cast<unsigned int*>(vPtr)+i);
00314                 break;
00315             case ULONG64: 
00316                 log << *(reinterpret_cast<unsigned long long*>(vPtr)+i);
00317                 break;
00318             default:
00319                 break;
00320             }
00321 
00322             if(doAll && dim>1) {
00323                 log << (i==dim-1 ? ")" : ",");
00324             }
00325             log << separator;
00326         }
00327         
00328     }
00329     log << endreq;
00330     return StatusCode::SUCCESS;
00331 }

StatusCode ValBase::calculate  )  [virtual]
 

calculate all values; implemented by each XxxValsTool

Reimplemented in AcdValsTool, CalMipValsTool, CalValsTool, EvtValsTool, GcrReconValsTool, GcrSelectValsTool, GltValsTool, McAnalValsTool, McKludgeValsTool, McTkrHitValsTool, McValsTool, ObfValsTool, TkrHitValsTool, TkrValsTool, and VtxValsTool.

Definition at line 630 of file ValBase.cxx.

Referenced by doCalcIfNotDone().

00630                               {
00631 
00632     MsgStream log(msgSvc(), name());
00633 
00634     std::cout << "No specific calc routine defined!" << std::endl;
00635     return StatusCode::SUCCESS;
00636 }

double ValBase::circleFraction double  r  )  [inline, static, protected]
 

Definition at line 148 of file ValBase.h.

Referenced by circleFractionSimpson().

00148                                            {
00149         double rl = (fabs(r) < 1.) ? fabs(r):1.; 
00150         double a_slice = 2.*(M_PI/4. - rl*sqrt(std::max(0.0,1.-rl*rl))/2. - asin(rl)/2.);
00151         double in_frac = 1.-a_slice/M_PI;
00152         if(r < 0.) in_frac = a_slice/M_PI;
00153         return in_frac;
00154     }

double ValBase::circleFractionSimpson double  r,
double  angle_factor
[inline, static, protected]
 

Definition at line 156 of file ValBase.h.

References circleFraction().

00156                                                                        {
00157         double slice_0 = circleFraction(r);
00158         double slice_p = circleFraction(r+angle_factor);
00159         double slice_m = circleFraction(r-angle_factor);
00160         return (slice_p + 4.*slice_0 + slice_m)/6.;
00161     }

StatusCode ValBase::doCalcIfNotDone  )  [virtual]
 

let the user trigger her own calculation

Implements IValsTool.

Definition at line 333 of file ValBase.cxx.

References CALC, calculate(), CHECK, m_calcCount, m_check, m_newEvent, m_pEventSvc, NOCALC, and zeroVals().

Referenced by browse(), getTypedPointer(), and traverse().

00334 {
00335     StatusCode sc = StatusCode::SUCCESS; 
00336 
00337     MsgStream log(msgSvc(), name());
00338 
00339     // if NOCALC means don't do the calculation
00340     // if CALC   means always do the calculation
00341     // if CHECK  means do the calculation if not already done, and reset m_newEvent
00342 
00343     if(m_check!=NOCALC) {
00344         if(m_newEvent || m_check==CALC) {
00345             if (!m_pEventSvc)  return StatusCode::FAILURE;
00346             zeroVals();
00347             ++m_calcCount;
00348             sc = calculate();
00349             //std::cout  << m_calcCount << " calculations so far" << std::endl;
00350             // only reset the newEvent flag if we're called with the check flag on.
00351             if(m_check==CHECK) m_newEvent = false;
00352         }
00353     }
00354     return sc;
00355 }       

bool ValBase::getArrayArg std::string  varName,
std::string &  baseName,
int &  dim
[virtual]
 

Definition at line 127 of file ValBase.cxx.

Referenced by addItem(), browse(), and getVal().

00128 {
00129     MsgStream log(msgSvc(), name());
00130     
00131     arg = -1;
00132     baseName = varName;
00133     bool hasArg = false;
00134 
00135     int pos1, pos2;
00136     pos1 = varName.find("[");
00137     if (pos1!=-1) {
00138         pos2 = varName.find("]");
00139         if (pos2<pos1+2) {
00140             log << MSG::ERROR << "variable " << varName << " out of range or malformed" << endreq;
00141             log << MSG::ERROR << "Character positions " << pos1 << " " << pos2 << endreq;
00142             assert(pos2<pos1+2);
00143             return hasArg;
00144         } else {
00145             std::string strDim = varName.substr(pos1+1, pos2-pos1-1);
00146             arg = atoi(strDim.c_str());
00147             if(arg<0) {
00148                 log << MSG::ERROR << "variable " << varName << " out of range or malformed" << endreq;
00149                 log << MSG::ERROR << "argString = " << strDim << ", arg = " << arg << endreq;
00150                 assert(arg<0);
00151                 return hasArg;
00152             }
00153             baseName = varName.substr(0,pos1);
00154             hasArg = true;
00155             return hasArg;
00156         }
00157     } else {
00158         arg = 1;
00159         return hasArg;
00160     }
00161 }

virtual int ValBase::getCalcCount  )  [inline, virtual]
 

number of times a tool did its calculation for this event

Implements IValsTool.

Definition at line 122 of file ValBase.h.

References m_calcCount.

00122 { return m_calcCount;}

std::string ValBase::getFullName std::string  varName,
int  dim
[virtual]
 

Definition at line 119 of file ValBase.cxx.

Referenced by traverse().

00120 {
00121     char buffer[6];
00122     sprintf(buffer, "[%i]", dim);
00123     std::string fullName = varName+buffer;
00124     return fullName;
00125 }

virtual int ValBase::getLoadOrder  )  [inline, virtual]
 

Implements IValsTool.

Definition at line 133 of file ValBase.h.

References m_loadOrder.

00133 { return m_loadOrder; }

StatusCode ValBase::getTypedPointer std::string  varName,
TypedPointer *&  ptr,
int  check
[protected]
 

Definition at line 392 of file ValBase.cxx.

References announceBadName(), CHECK, check, constMapIter, doCalcIfNotDone(), m_check, and m_ntupleMap.

Referenced by getVal().

00393 {
00394     // optional check flag
00395 
00396     StatusCode sc = StatusCode::SUCCESS;
00397 
00398     m_check = check;
00399     
00400     constMapIter it = m_ntupleMap.begin();
00401     for ( ; it!=m_ntupleMap.end(); ++it) {
00402         if ((*it)->first == varName) break;
00403     }
00404     
00405     if (it==m_ntupleMap.end()) { 
00406         announceBadName(varName); 
00407         m_check = CHECK;
00408         return StatusCode::FAILURE;
00409     } else {
00410         if(doCalcIfNotDone().isFailure()) {
00411             m_check = CHECK;
00412             return StatusCode::FAILURE;
00413         }
00414         ptr = (*it)->second;
00415     }
00416     m_check = CHECK;
00417     return sc;
00418 }

StatusCode ValBase::getVal std::string  varName,
std::string &  value,
int  check = CALC
[virtual]
 

return a string containing the value, as above

Implements IValsTool.

Definition at line 420 of file ValBase.cxx.

References check, DOUBLE, FLOAT, getArrayArg(), getTypedPointer(), INT, UINT, ULONG64, and valType.

00421 {
00422     MsgStream log(msgSvc(), name());
00423 
00424     char buffer[80];
00425     TypedPointer* ptr = 0;
00426     value = "";
00427 
00428     std::string baseName;
00429     int element;
00430     bool hasArg = getArrayArg(varName, baseName, element);
00431     if(!hasArg) element = 0;
00432     StatusCode sc = getTypedPointer(baseName, ptr, check);
00433     if(sc.isFailure()) return sc;
00434 
00435     void* vPtr = ptr->getPointer();
00436 
00437     int dim = ptr->getDim();
00438     if (element>=dim || element<0) 
00439     {
00440         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00441             assert(element<dim && element>-1);
00442     }
00443 
00444     valType type = ptr->getType();
00445  
00446 // LSR 14-Jul-08 code for ntuple types
00447     
00448     if(sc.isSuccess()) {
00449         if (type==FLOAT) { sprintf(buffer, "%g", 
00450             *(reinterpret_cast<float*>(vPtr)+element));}
00451         else if (type==DOUBLE)  { sprintf(buffer, "%g", 
00452             *(reinterpret_cast<double*>(vPtr)+element));}
00453         else if (type==INT)     { sprintf(buffer, "%i", 
00454             *(reinterpret_cast<int*>(vPtr)+element));}
00455         else if (type==UINT)    { sprintf(buffer, "%u", 
00456             *(reinterpret_cast<unsigned int*>(vPtr)+element));}
00457         else if (type==ULONG64)    { sprintf(buffer, "%u", 
00458             *(reinterpret_cast<unsigned long long*>(vPtr)+element));}
00459     }
00460     value = std::string(buffer);
00461     return sc;
00462 }

StatusCode ValBase::getVal std::string  varName,
unsigned long long &  value,
int  check = CALC
[virtual]
 

Implements IValsTool.

Definition at line 518 of file ValBase.cxx.

References check, getArrayArg(), and getTypedPointer().

00519 {
00520     MsgStream log(msgSvc(), name());
00521     TypedPointer* ptr = 0;
00522     value = 0;
00523 
00524     std::string baseName;
00525     int element;
00526     bool hasArg = getArrayArg(varName, baseName, element);
00527 
00528     StatusCode sc = getTypedPointer(baseName, ptr, check);
00529     if(sc.isFailure()) return sc;
00530 
00531     if(!hasArg) element = 0;
00532     int dim = ptr->getDim();
00533     if (element>=dim || element<0) 
00534     {
00535         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00536             assert(element<dim && element>-1);
00537     }
00538 
00539     value = *(reinterpret_cast<unsigned long long*>(ptr->getPointer())+element);
00540    
00541     return sc;
00542 }

StatusCode ValBase::getVal std::string  varName,
unsigned int &  value,
int  check = CALC
[virtual]
 

Implements IValsTool.

Definition at line 492 of file ValBase.cxx.

References check, getArrayArg(), and getTypedPointer().

00493 {
00494     MsgStream log(msgSvc(), name());
00495     TypedPointer* ptr = 0;
00496     value = 0;
00497 
00498     std::string baseName;
00499     int element;
00500     bool hasArg = getArrayArg(varName, baseName, element);
00501 
00502     StatusCode sc = getTypedPointer(baseName, ptr, check);
00503     if(sc.isFailure()) return sc;
00504 
00505     if(!hasArg) element = 0;
00506     int dim = ptr->getDim();
00507     if (element>=dim || element<0) 
00508     {
00509         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00510             assert(element<dim && element>-1);
00511     }
00512 
00513     value = *(reinterpret_cast<unsigned int*>(ptr->getPointer())+element);
00514    
00515     return sc;
00516 }

StatusCode ValBase::getVal std::string  varName,
int &  value,
int  check = CALC
[virtual]
 

Implements IValsTool.

Definition at line 466 of file ValBase.cxx.

References check, getArrayArg(), and getTypedPointer().

00467 {
00468     MsgStream log(msgSvc(), name());
00469     TypedPointer* ptr = 0;
00470     value = 0;
00471 
00472     std::string baseName;
00473     int element;
00474     bool hasArg = getArrayArg(varName, baseName, element);
00475     if(!hasArg) element = 0;
00476 
00477     StatusCode sc = getTypedPointer(baseName, ptr, check);
00478     if(sc.isFailure()) return sc;
00479 
00480     int dim = ptr->getDim();
00481     if (element>=dim || element<0) 
00482     {
00483         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00484             assert(element<dim && element>-1);
00485     }
00486 
00487     value = *(reinterpret_cast<int*>(ptr->getPointer())+element);
00488 
00489     return sc;
00490 }

StatusCode ValBase::getVal std::string  varName,
float &  value,
int  check = CALC
[virtual]
 

Implements IValsTool.

Definition at line 570 of file ValBase.cxx.

References check, getArrayArg(), and getTypedPointer().

00571 {
00572     MsgStream log(msgSvc(), name());
00573     TypedPointer* ptr = 0;
00574     value = 0.0;
00575 
00576     std::string baseName;
00577     int element;
00578     bool hasArg = getArrayArg(varName, baseName, element);
00579 
00580     StatusCode sc = getTypedPointer(baseName, ptr, check);
00581     if(sc.isFailure()) return sc;
00582 
00583     int dim = ptr->getDim();
00584     if(!hasArg) element = 0;
00585     if (element>=dim || element<0) 
00586     {
00587         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00588             assert(element<dim && element>-1);
00589     }
00590 
00591     value = *(reinterpret_cast<float*>(ptr->getPointer())+element);
00592 
00593     return sc;
00594 }

StatusCode ValBase::getVal std::string  varName,
double &  value,
int  check = CALC
[virtual]
 

get a particular value, using ntuple name default forces calculation

Implements IValsTool.

Definition at line 545 of file ValBase.cxx.

References check, getArrayArg(), and getTypedPointer().

Referenced by getValCheck().

00546 {
00547     MsgStream log(msgSvc(), name());
00548     TypedPointer* ptr = 0;
00549     value = 0.0;
00550 
00551     std::string baseName;
00552     int element;
00553     bool hasArg = getArrayArg(varName, baseName, element);
00554     if(!hasArg) element = 0;
00555 
00556     StatusCode sc = getTypedPointer(baseName, ptr, check);
00557     if(sc.isFailure()) return sc;
00558     int dim = ptr->getDim();
00559     if (element>=dim || element<0) 
00560     {
00561         log << MSG::ERROR << "GetVal: element " << varName << " out of range" << endreq;
00562             assert(element<dim && element>-1);
00563     }
00564 
00565     value = *(reinterpret_cast<double*>(ptr->getPointer())+element);
00566 
00567     return sc;
00568 }

StatusCode ValBase::getValCheck std::string  varName,
std::string &  value
[virtual]
 

Implements IValsTool.

Definition at line 386 of file ValBase.cxx.

References CHECK, and getVal().

00387 {
00388     // a simple way to force the check
00389     return getVal(varName, value, CHECK);
00390 }

StatusCode ValBase::getValCheck std::string  varName,
unsigned long long &  value
[virtual]
 

Implements IValsTool.

Definition at line 381 of file ValBase.cxx.

References CHECK, and getVal().

00382 {
00383     // a simple way to force the check
00384     return getVal(varName, value, CHECK);
00385 }

StatusCode ValBase::getValCheck std::string  varName,
unsigned int &  value
[virtual]
 

Implements IValsTool.

Definition at line 375 of file ValBase.cxx.

References CHECK, and getVal().

00376 {
00377     // a simple way to force the check
00378     return getVal(varName, value, CHECK);
00379 }

StatusCode ValBase::getValCheck std::string  varName,
int &  value
[virtual]
 

Implements IValsTool.

Definition at line 369 of file ValBase.cxx.

References CHECK, and getVal().

00370 {
00371     // a simple way to force the check
00372     return getVal(varName, value, CHECK);
00373 }

StatusCode ValBase::getValCheck std::string  varName,
float &  value
[virtual]
 

Implements IValsTool.

Definition at line 364 of file ValBase.cxx.

References CHECK, and getVal().

00365 {
00366     // a simple way to force the check
00367     return getVal(varName, value, CHECK);
00368 }

StatusCode ValBase::getValCheck std::string  varName,
double &  value
[virtual]
 

get a particular value, using ntuple name, with calc checking (called by AnaTup)

Implements IValsTool.

Definition at line 359 of file ValBase.cxx.

References CHECK, and getVal().

00360 {
00361     // a simple way to force the check
00362     return getVal(varName, value, CHECK);
00363 }

double ValBase::globalToLocal double  x,
double  pitch,
int  n
[inline, static, protected]
 

turn a global coordinate (tower, ladder, wafer) roughly into a local one

Definition at line 143 of file ValBase.h.

References sign().

Referenced by CalValsTool::activeDist(), TkrValsTool::calculate(), and TkrValsTool::towerEdge().

00143                                                                {
00144         double xNorm = x/pitch + 0.5*n;
00145         return sign(x)*(fmod(fabs(xNorm),1.0) - 0.5)*pitch ;
00146     }

void ValBase::handle const Incident &  inc  )  [virtual]
 

this is called by the incident service at the beginning of an event

Definition at line 638 of file ValBase.cxx.

References m_calcCount, and m_newEvent.

00639 {    
00640     MsgStream log(msgSvc(), name());
00641 
00642     if(inc.type()=="BeginEvent") {
00643         //std::cout << "handle called at BeginEvent" << std::endl;
00644         m_newEvent = true;
00645         m_calcCount = 0;
00646     }
00647 }

StatusCode ValBase::initialize  )  [virtual]
 

Reimplemented in AcdValsTool, CalMipValsTool, CalValsTool, EvtValsTool, GcrReconValsTool, GcrSelectValsTool, GltValsTool, McAnalValsTool, McKludgeValsTool, McTkrHitValsTool, McValsTool, ObfValsTool, TkrHitValsTool, TkrValsTool, and VtxValsTool.

Definition at line 29 of file ValBase.cxx.

References CHECK, m_calcCount, m_check, m_incSvc, m_newEvent, m_ntupleMap, and m_pEventSvc.

Referenced by VtxValsTool::initialize(), TkrValsTool::initialize(), TkrHitValsTool::initialize(), ObfValsTool::initialize(), McValsTool::initialize(), McTkrHitValsTool::initialize(), McKludgeValsTool::initialize(), McAnalValsTool::initialize(), GltValsTool::initialize(), GcrSelectValsTool::initialize(), GcrReconValsTool::initialize(), EvtValsTool::initialize(), CalValsTool::initialize(), CalMipValsTool::initialize(), and AcdValsTool::initialize().

00030   {
00031       // use the incident service to register begin, end events
00032       IIncidentSvc* incsvc = 0;
00033       IDataProviderSvc* eventsvc = 0;
00034 
00035       m_newEvent = true;
00036       m_check = CHECK;
00037       m_calcCount = 0;
00038 
00039       m_ntupleMap.clear();
00040 
00041       MsgStream log(msgSvc(), name());
00042 
00043       StatusCode sc = StatusCode::FAILURE;
00044 
00045       log << MSG::INFO << "ValBase is initializing" << endreq;
00046 
00047       if (serviceLocator()) {
00048           sc = serviceLocator()->service( "IncidentSvc", incsvc, true );
00049           if(sc.isFailure()){
00050               log << MSG::ERROR << "Could not find IncidentSvc" << std::endl;
00051               return sc;
00052           }
00053           m_incSvc = incsvc;
00054 
00055           sc = serviceLocator()->service( "EventDataSvc", eventsvc, true );
00056           if(sc.isFailure()){
00057               log << MSG::ERROR << "Could not find EventDataSvc" << std::endl;
00058               return sc;
00059           }
00060           m_pEventSvc = eventsvc;
00061       } 
00062 
00063       //set up listener for IncidentSvc
00064       incsvc->addListener(this, "BeginEvent", 100);
00065       return sc;
00066   }

virtual bool ValBase::isLoaded  )  [inline, virtual]
 

Implements IValsTool.

Definition at line 132 of file ValBase.h.

References m_loadOrder.

00132 { return m_loadOrder>-1; }

void ValBase::printHeader MsgStream &  log  )  [protected]
 

Definition at line 705 of file ValBase.cxx.

References m_pEventSvc.

Referenced by TkrValsTool::calculate(), CalValsTool::calculate(), and TkrValsTool::SSDEvaluation().

00706 {
00707       SmartDataPtr<Event::EventHeader> header(m_pEventSvc, EventModel::EventHeader);
00708       unsigned long evtId = (header) ? header->event() : 0;
00709       long runId = (header) ? header->run() : -1;
00710       log << MSG::WARNING << "Caught exception (run,event): ( " 
00711           << runId << ", " << evtId << " ) " << endreq;
00712 }

void ValBase::setAnaTupBit  )  [protected]
 

Definition at line 714 of file ValBase.cxx.

References m_pEventSvc.

Referenced by TkrValsTool::calculate(), CalValsTool::calculate(), and TkrValsTool::SSDEvaluation().

00715 {
00716       SmartDataPtr<Event::EventHeader> header(m_pEventSvc, EventModel::EventHeader);
00717       if(header) header->setAnalysisNtupleError();
00718 }

virtual void ValBase::setLoadOrder int  index  )  [inline, virtual]
 

AnaTup loaded this object.

Implements IValsTool.

Definition at line 131 of file ValBase.h.

References m_loadOrder.

00131 { m_loadOrder = index; }

double ValBase::sign double  x  )  [inline, static, protected]
 

some static methods sign of a number

Definition at line 141 of file ValBase.h.

Referenced by TkrValsTool::calculate(), and globalToLocal().

00141 { return x>0 ? 1.: -1. ;}

IValsTool::Visitor::eVisitorRet ValBase::traverse IValsTool::Visitor v,
const bool  checkCalc
[virtual]
 

callback for visitor

Implements IValsTool.

Definition at line 649 of file ValBase.cxx.

References IValsTool::Visitor::analysisValue(), constMapIter, IValsTool::Visitor::CONT, doCalcIfNotDone(), IValsTool::Visitor::DONE, DOUBLE, IValsTool::Visitor::ERROR, IValsTool::Visitor::eVisitorRet, FLOAT, getFullName(), INT, m_ntupleMap, STRING, UINT, ULONG64, valPair, and valType.

00651 {
00652     IValsTool::Visitor::eVisitorRet ret = IValsTool::Visitor::DONE;
00653 
00654     if (checkCalc) {
00655         if(doCalcIfNotDone().isFailure()) return IValsTool::Visitor::ERROR;
00656     }
00657 
00658     constMapIter it = m_ntupleMap.begin();
00659     for ( ; it!=m_ntupleMap.end(); ++it) {
00660         valPair* pair = *it;
00661         TypedPointer* ptr = pair->second;
00662         valType type = ptr->getType();
00663         void* vPtr = ptr->getPointer();
00664         std::string varName = pair->first;
00665 
00666         // here's where we need to construct the varName from the baseName and the dim
00667         std::string fullName = varName;
00668         int dim = ptr->getDim();
00669         if (dim>1) {
00670             fullName = getFullName(varName, dim);
00671         }
00672 
00673  
00674 // LSR 14-Jul-08 code for ntuple types
00675 
00676         switch (type) {
00677             case FLOAT:
00678                 ret = v->analysisValue(fullName, *(reinterpret_cast<float*>(vPtr)));
00679                 //std::cout << "analysisValue returns: " << *(reinterpret_cast<float*>(vPtr)) << std::endl;
00680                 break;
00681             case DOUBLE:
00682                 ret = v->analysisValue(fullName, *(reinterpret_cast<double*>(vPtr)));
00683                 break;
00684             case UINT:
00685                 ret = v->analysisValue(fullName, *(reinterpret_cast<unsigned int*>(vPtr)));
00686                 break;
00687             case ULONG64:
00688                 ret = v->analysisValue(fullName, *(reinterpret_cast<unsigned long long*>(vPtr)));
00689                 break;
00690             case INT:
00691                 ret = v->analysisValue(fullName, *(reinterpret_cast<int*>(vPtr)));
00692                 //std::cout << "analysisValue returns: " << *(reinterpret_cast<int*>(vPtr)) << std::endl;
00693                break;
00694             case STRING:
00695                 ret = v->analysisValue(fullName, (reinterpret_cast<char*>(vPtr)));
00696                 //std::cout << "analysisValue returns: " << reinterpret_cast<char*>(vPtr) << std::endl;
00697                 break;
00698         }
00699 
00700         if (ret!= IValsTool::Visitor::CONT) return ret;
00701     }
00702     return IValsTool::Visitor::DONE;
00703 }

void ValBase::zeroVals  )  [virtual]
 

clear map values

Implements IValsTool.

Reimplemented in CalValsTool, EvtValsTool, and GltValsTool.

Definition at line 77 of file ValBase.cxx.

References DOUBLE, FLOAT, INT, m_ntupleMap, mapIter, STRING, UINT, ULONG64, and valType.

Referenced by