CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloSamples.cc
Go to the documentation of this file.
2 #include <math.h>
3 
4 CaloSamples::CaloSamples() : id_(), size_(0), presamples_(0) { setBlank() ; }
5 
7  id_ ( id ) ,
8  size_ ( size ) ,
9  presamples_ ( 0 )
10 {
11  setBlank() ;
12 }
13 
14 void
16 {
17  presamples_ = pre ;
18 }
19 
22 {
23  for (int i=0; i<MAXSAMPLES; i++) data_[i]*=value;
24  return (*this);
25 }
26 
29 {
30  for (int i=0; i<MAXSAMPLES; i++) data_[i]+=value;
31  return (*this);
32 }
33 
36 {
37  double data[MAXSAMPLES];
38  for( int i ( 0 ) ; i != MAXSAMPLES ; ++i )
39  {
40  double t = i*25. - offset;
41  int firstbin = floor(t/25.);
42  double f = t/25. - firstbin;
43  int nextbin = firstbin + 1;
44  double v1 = (firstbin < 0 || firstbin >= MAXSAMPLES) ? 0. : data_[firstbin];
45  double v2 = (nextbin < 0 || nextbin >= MAXSAMPLES) ? 0. : data_[nextbin];
46  data[i] = (v1*(1.-f)+v2*f);
47  }
48  for( int i ( 0 ) ; i != MAXSAMPLES ; ++i )
49  {
50  data_[i] = data[i];
51  }
52  return (*this);
53 }
54 
55 bool
56 CaloSamples::isBlank() const // are the samples blank (zero?)
57 {
58  for( int i ( 0 ) ; i != MAXSAMPLES ; ++i )
59  {
60  if( 1.e-6 < fabs( data_[i] ) ) return false ;
61  }
62  return true ;
63 }
64 
65 void
66 CaloSamples::setBlank() // keep id, presamples, size but zero out data
67 {
68  std::fill( data_ , data_ + MAXSAMPLES, (double)0.0 ) ;
69 }
70 
71 std::ostream& operator<<(std::ostream& s, const CaloSamples& samples) {
72  s << "DetId=" << samples.id().rawId();
73  s << ", "<< samples.size() << "samples" << std::endl;
74  for (int i=0; i<samples.size(); i++)
75  s << i << ":" << samples[i] << std::endl;
76  return s;
77 }
int i
Definition: DBlmapReader.cc:9
string fill
Definition: lumiContext.py:319
CaloSamples & scale(double value)
multiply each item by this value
Definition: CaloSamples.cc:21
static const int MAXSAMPLES
Definition: CaloSamples.h:55
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
bool isBlank() const
Definition: CaloSamples.cc:56
void setBlank()
Definition: CaloSamples.cc:66
double f[11][100]
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:15
unsigned int offset(bool)
Definition: DetId.h:20
int size() const
get the size
Definition: CaloSamples.h:24
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:35
string const
Definition: compareJSON.py:14
int presamples_
Definition: CaloSamples.h:59
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
size_(0)
Definition: OwnArray.h:181
CaloSamples & operator+=(double value)
add a value to all samples
Definition: CaloSamples.cc:28
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
double data_[MAXSAMPLES]
Definition: CaloSamples.h:58
tuple size
Write out results.