AliPhysics  v5-06-11-01 (156c7f3)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerBinningComponent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 /*
16  * Global binning definition for the charged particle pt analysis
17  *
18  * Author: Markus Fasel
19  */
20 #include <iostream>
21 
22 #include <TObjArray.h>
24 
26 ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerBinningComponent)
27 
28 namespace EMCalTriggerPtAnalysis {
29 
30 //______________________________________________________________________________
31 AliEMCalTriggerBinningComponent::AliEMCalTriggerBinningComponent() :
32  TObject(),
33  fDimensions(NULL)
34 {
35  /*
36  * Main constructor
37  */
38  fDimensions = new TObjArray;
39  fDimensions->SetOwner();
40 }
41 
42 //______________________________________________________________________________
43 AliEMCalTriggerBinningComponent::AliEMCalTriggerBinningComponent(const AliEMCalTriggerBinningComponent& ref) :
44  TObject(ref),
45  fDimensions(NULL)
46 {
47  /*
48  * Copy constructor, creating a deep copy
49  */
50  fDimensions = new TObjArray;
51  fDimensions->SetOwner();
52  TIter dimIter(ref.fDimensions);
54  while((dim = dynamic_cast<AliEMCalTriggerBinningDimension *>(dimIter())))
56 }
57 
58 //______________________________________________________________________________
60  /*
61  * Assignment operator, doing a deep copy
62  */
63  TObject::operator=(ref);
64  if(&ref != this){
66 
67  fDimensions = new TObjArray;
68  fDimensions->SetOwner();
69  TIter dimIter(ref.fDimensions);
71  while((dim = dynamic_cast<AliEMCalTriggerBinningDimension *>(dimIter())))
73  }
74  return *this;
75 }
76 
77 //______________________________________________________________________________
79  /*
80  * Destructor
81  */
82  delete fDimensions;
83 }
84 
85 //______________________________________________________________________________
87  /*
88  * Get binning information for a given axis. Return nullpointer if axis is not yet defined
89  *
90  * @param name: axis name
91  * @return: the axis information
92  */
93  return dynamic_cast<AliEMCalTriggerBinningDimension *>(fDimensions->FindObject(name));
94 }
95 
96 //______________________________________________________________________________
97 void AliEMCalTriggerBinningComponent::SetBinning(const char* dimname, int nbins, double* binning) {
98  /*
99  * Set binning for dimension. If not yet existing, create it
100  *
101  * @param dimname: axis name
102  * @param nbins: Number of bins
103  * @param binning: array of bin limits (size nbins+1)
104  */
106  if(dim) dim->Set(nbins, binning);
107  else {
108  dim = new AliEMCalTriggerBinningDimension(dimname, nbins, binning);
109  fDimensions->Add(dim);
110  }
111 }
112 
113 //______________________________________________________________________________
114 void AliEMCalTriggerBinningComponent::SetBinning(const char* dimname, const TArrayD& binning) {
115  /*
116  * Set binning for dimension. If not yet existing, create it
117  *
118  * @param dimname: axis name
119  * @param nbins: Number of bins
120  * @param binning: array of bin limits (size nbins+1)
121  */
123  if(dim) dim->Set(binning);
124  else {
125  dim = new AliEMCalTriggerBinningDimension(dimname, binning);
126  fDimensions->Add(dim);
127  }
128 }
129 
130 //______________________________________________________________________________
131 void AliEMCalTriggerBinningDimension::Print(Option_t * /*option*/) const {
132  /*
133  * Print the bin limits for a given dimension
134  */
135  std::cout << "Binning for variable " << GetName() << ":" << std::endl;
136  std::cout << "================================================" << std::endl;
137  for(int ilim = 0; ilim < fBinning.GetSize(); ilim++){
138  std::cout << fBinning[ilim];
139  if(ilim < fBinning.GetSize() -1) std::cout << ", ";
140  }
141  std::cout << std::endl;
142 }
143 
144 
145 } /* namespace EMCalTriggerPtAnalysis */
146 
void SetBinning(const char *dimname, int nbins, double *binning)
AliEMCalTriggerBinningComponent & operator=(const AliEMCalTriggerBinningComponent &ref)
ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerBinningDimension) ClassImp(EMCalTriggerPtAnalysis
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const