StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEmcTower.cxx
1 // Hey Emacs this is -*-c++-*-
2 // $Id: EEmcTower.cxx,v 1.7 2007/07/12 19:27:23 fisyak Exp $
3 
23 #include <iostream>
24 #include <ostream>
25 #include <cctype>
26 
27 #include "TList.h"
28 #include "EEmcTower.h"
29 
30 #if !defined(ST_NO_NAMESPACES)
31 using std::ostream;
32 #endif
33 
34 ClassImp(EEmcTower);
35 
36 
37 static const int kMaxLabelLen = 16;
38 
39 //
40 EEmcTower::EEmcTower(const char *label , float adc, float ene)
41 {
42  mSec = -1;
43  mSub = -1;
44  mEta = -1;
45  mADC = 0.0;
46  mEdep = 0.0;
47  if( ! ParseLabel(label) ) return;
48  mADC = adc;
49  mEdep = ene;
50 }
51 //
52 
53 //=============================================================================
54 bool
55 EEmcTower::ParseLabel(const char *label)
56 {
57  if(label==NULL) return false;
58  char const *p = label;
59  int s=0;
60  char ss=0;
61  char t=0;
62  int e=0;
63  while( *p != 0x00 && !islower(*p) && !isupper(*p) && !isdigit(*p) ) p++;
64  int r=sscanf(p,"%02d%1c%1c%02d",&s,&t,&ss,&e);
65  if(toupper(t)!='T') return false;
66  if(r!=4) return false;
67  // adjust indices
68  mSec = s - 1;
69  mSub = ss - 'A';
70  mEta = e - 1;
71  return true;
72 
73 }
74 
75 //=============================================================================
76 const char*
78 {
79  static char labelBuffer[kMaxLabelLen];
80  sprintf(labelBuffer,"%02dT%1c%02d",SecLabel(),SubSecLabel(),EtaLabel());
81  return labelBuffer;
82 }
83 
84 
85 //=============================================================================
86 ostream&
87 EEmcTower::Out(ostream &out ) const
88 {
89  out << "<EEmcTower";
90  out << " TOWER=\"" << TowerLabel() << "\"";
91  out << " ADC=\"" << mADC << "\"";
92  out << " EDEP=\"" << mEdep << "\"";
93  out << " />\n";
94  return out;
95 }
96 
97 
98 //=============================================================================
99 ostream& operator<<(ostream &out, const EEmcTower &t ) {
100  return t.Out(out);
101 }
102 
EEmcTower()
the default constructor
Definition: EEmcTower.h:20
const char * TowerLabel() const
returns tower label, e.g. &quot;05TB09&quot;
Definition: EEmcTower.cxx:77
int SubSecLabel() const
gets tower subsector label, human offset [A..E]
Definition: EEmcTower.h:78
ostream & Out(ostream &out) const
print tower hit info in xml-like style
Definition: EEmcTower.cxx:87
int SecLabel() const
gets tower sector label, human offset [1..12]
Definition: EEmcTower.h:73
int EtaLabel() const
gets tower eta label, human offset [1..12]
Definition: EEmcTower.h:83
EEmcTower holds information about an EEMC tower &#39;hit&#39;.
Definition: EEmcTower.h:17