Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
calib::AbsCalib Class Reference
Inheritance diagram for calib::AbsCalib:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 AbsCalib (fhicl::ParameterSet const &p)
 
virtual ~AbsCalib ()
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
void beginRun (art::Run const &r) override
 
void endRun (art::Run const &r) override
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

double fitMEU (TH1D *&proj, double &sigma, bool isTruth=false)
 

Private Attributes

double fWindowStart
 
double fWindowLength
 
double fMEU
 
double fMEU_minus
 
double fMEU_plus
 
double fMEU_true
 
double fMEU_error
 
double fMEU_error_minus
 
double fMEU_error_plus
 
double fMEU_error_true
 
TH2D * fdEdx
 
TH2D * fdEdx_minus
 
TH2D * fdEdx_plus
 
TH2D * fdEdx_true
 
TH1D * fWindow
 
TH1D * fWindow_minus
 
TH1D * fWindow_plus
 
TH1D * fWindow_true
 

Detailed Description

Definition at line 30 of file AbsCalib_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

calib::AbsCalib::AbsCalib ( fhicl::ParameterSet const &  p)
explicit

Definition at line 66 of file AbsCalib_module.cc.

References fWindowLength, and fWindowStart.

67  : EDAnalyzer(p)
68  {
69  fWindowStart = 100.;
70  fWindowLength = 100.;
71  }
const char * p
Definition: xmltok.h:285
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
calib::AbsCalib::~AbsCalib ( )
virtual

Definition at line 73 of file AbsCalib_module.cc.

74  {
75  }

Member Function Documentation

void calib::AbsCalib::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 77 of file AbsCalib_module.cc.

78  {
79  }
void calib::AbsCalib::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 81 of file AbsCalib_module.cc.

References fdEdx, fdEdx_minus, fdEdx_plus, fdEdx_true, fWindow, fWindow_minus, fWindow_plus, fWindow_true, and art::TFileDirectory::make().

82  {
84  fdEdx = tfs->make<TH2D>("dEdx","; ; ;",
85  50,0.,500.,200,0.,200.);
86  fdEdx_minus = tfs->make<TH2D>("dEdx_minus","; ; ;",
87  50,0.,500.,200,0.,200.);
88  fdEdx_plus = tfs->make<TH2D>("dEdx_plus","; ; ;",
89  50,0.,500.,200,0.,200.);
90  fdEdx_true = tfs->make<TH2D>("dEdx_true","; ; ;",
91  50,0.,500.,200,0.,5.);
92  fWindow = tfs->make<TH1D>("window","window",
93  200,0.,200.);
94  fWindow_minus = tfs->make<TH1D>("window_minus","window_minus",
95  200,0.,200.);
96  fWindow_plus = tfs->make<TH1D>("window_plus","window_plus",
97  200,0.,200.);
98  fWindow_true = tfs->make<TH1D>("window_true","window_true",
99  200,0.,5.);
100  }
T * make(ARGS...args) const
void calib::AbsCalib::beginRun ( art::Run const &  r)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 154 of file AbsCalib_module.cc.

155  {
156  }
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDAnalyzer::currentContext ( ) const
protectedinherited
void calib::AbsCalib::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 102 of file AbsCalib_module.cc.

References om::cout, allTimeWatchdog::endl, stan::math::fabs(), fitMEU(), fMEU, fMEU_error, fMEU_error_minus, fMEU_error_plus, fMEU_error_true, fMEU_minus, fMEU_plus, fMEU_true, fWindow, fWindow_minus, fWindow_plus, and fWindow_true.

103  {
104  // For now calculate MEU per job, maybe later move to run
105  fMEU = this->fitMEU(fWindow,fMEU_error);
109 
110 
111  double sys_err = fabs(fMEU_plus - fMEU);
112  sys_err = (fabs(fMEU - fMEU_minus) > sys_err ) ? fabs(fMEU - fMEU_minus) : sys_err;
113 
114  std::cout << "MEU = " << fMEU << " +/-" << fMEU_error << "(stat) PECorr/cm"
115  << " +/-" << sys_err << "(sys) PECorr/cm"
116  << std::endl;
117 
118 
119  std::cout << "True MEU = " << fMEU_true << " +/-" << fMEU_error_true << "(stat) MeV/cm"
120  << std::endl;
121 
122 
123  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double fitMEU(TH1D *&proj, double &sigma, bool isTruth=false)
OStream cout
Definition: OStream.cxx:6
void calib::AbsCalib::endRun ( art::Run const &  r)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 158 of file AbsCalib_module.cc.

References DEFINE_ART_MODULE(), fdEdx, fdEdx_minus, fdEdx_plus, fdEdx_true, fWindow, fWindow_minus, fWindow_plus, fWindow_true, fWindowLength, fWindowStart, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, calib::j, and tmp.

159  {
160  art::Handle<TH2D> tmp, tmpMinus, tmpPlus, tmpTrue;
161  r.getByLabel("muondedx","dEdx",tmp);
162  r.getByLabel("muondedx","dEdxMinus",tmpMinus);
163  r.getByLabel("muondedx","dEdxPlus",tmpPlus);
164  r.getByLabel("muondedx","dEdxTrue",tmpTrue);
165 
166  for( int i=0; i<fdEdx->GetNbinsX(); ++i ){
167  for( int j=0; j<fdEdx->GetNbinsY(); ++j ){
168  double thing = fdEdx->GetBinContent(i+1,j+1);
169  double thingMinus = fdEdx_minus->GetBinContent(i+1,j+1);
170  double thingPlus = fdEdx_plus->GetBinContent(i+1,j+1);
171  double thingTrue = fdEdx_true->GetBinContent(i+1,j+1);
172  thing += tmp->GetBinContent(i+1,j+1);
173  thingMinus += tmpMinus->GetBinContent(i+1,j+1);
174  thingPlus += tmpPlus->GetBinContent(i+1,j+1);
175  thingTrue += tmpTrue->GetBinContent(i+1,j+1);
176  fdEdx->SetBinContent(i+1,j+1,thing);
177  fdEdx_minus->SetBinContent(i+1,j+1,thingMinus);
178  fdEdx_plus->SetBinContent(i+1,j+1,thingPlus);
179  fdEdx_true->SetBinContent(i+1,j+1,thingTrue);
180  }
181  }
182 
183  // project into track window
184  int startBin = fdEdx->GetXaxis()->FindBin(fWindowStart);
185  int endBin = 1 + fdEdx->GetXaxis()->FindBin(fWindowStart+fWindowLength);
186  fWindow->Add((TH1D*)tmp->ProjectionY("window",startBin,endBin));
187  fWindow_minus->Add((TH1D*)tmpMinus->ProjectionY("window_minus",startBin,endBin));
188  fWindow_plus->Add((TH1D*)tmpPlus->ProjectionY("window_plus",startBin,endBin));
189  fWindow_true->Add((TH1D*)tmpTrue->ProjectionY("window_true",startBin,endBin));
190  }
Float_t tmp
Definition: plot.C:36
const double j
Definition: BetheBloch.cxx:29
TRandom3 r(0)
double calib::AbsCalib::fitMEU ( TH1D *&  proj,
double &  sigma,
bool  isTruth = false 
)
private

Definition at line 125 of file AbsCalib_module.cc.

References std::max().

Referenced by endJob().

125  {
126 
127  Double_t parameters[3];
128  parameters[0] = proj->GetBinContent(proj->GetMaximumBin());
129  parameters[1] = proj->GetBinCenter(proj->GetMaximumBin());
130  parameters[2] = proj->GetRMS();
131 
132 
133  // only care about finding peak position, use gaussian truncated about mode
134  Double_t bound_size = (isTruth) ? 0.2 : 0.5; // narrower for truth, *not* MC reco... don't mess this up.
135 
136  Double_t lowerBound = std::max(0.,parameters[1] - bound_size*proj->GetRMS());
137  Double_t upperBound = parameters[1] + bound_size*proj->GetRMS();
138 
139 
140  TF1* fitfunction = new TF1("fitfunction","[0]*TMath::Gaus(x,[1],[2])",lowerBound,upperBound);
141  fitfunction->SetParameters(parameters);
142 
143 
144  // fitting
145  proj->Fit(fitfunction,"RQ");
146 
147 
148  // retrieve values
149  sigma = fitfunction->GetParError(1);
150  return fitfunction->GetParameter(1);
151  }
T max(const caf::Proxy< T > &a, T b)
double sigma(TH1F *hist, double percentile)
Float_t proj
Definition: plot.C:35
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:35
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

Referenced by art::RootOutput::RootOutput().

47  {
48  return wantAllEvents_;
49  }
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited

Definition at line 51 of file EventObserverBase.h.

References art::EventObserverBase::selectors_, and art::detail::CachedProducts::wantEvent().

52  {
53  return selectors_.wantEvent(e);
54  }
detail::CachedProducts selectors_
Float_t e
Definition: plot.C:35
bool wantEvent(Event const &)
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

TH2D* calib::AbsCalib::fdEdx
private

Definition at line 55 of file AbsCalib_module.cc.

Referenced by beginJob(), and endRun().

TH2D* calib::AbsCalib::fdEdx_minus
private

Definition at line 56 of file AbsCalib_module.cc.

Referenced by beginJob(), and endRun().

TH2D* calib::AbsCalib::fdEdx_plus
private

Definition at line 57 of file AbsCalib_module.cc.

Referenced by beginJob(), and endRun().

TH2D* calib::AbsCalib::fdEdx_true
private

Definition at line 58 of file AbsCalib_module.cc.

Referenced by beginJob(), and endRun().

double calib::AbsCalib::fMEU
private

Definition at line 52 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_error
private

Definition at line 53 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_error_minus
private

Definition at line 53 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_error_plus
private

Definition at line 53 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_error_true
private

Definition at line 53 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_minus
private

Definition at line 52 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_plus
private

Definition at line 52 of file AbsCalib_module.cc.

Referenced by endJob().

double calib::AbsCalib::fMEU_true
private

Definition at line 52 of file AbsCalib_module.cc.

Referenced by endJob().

TH1D* calib::AbsCalib::fWindow
private

Definition at line 59 of file AbsCalib_module.cc.

Referenced by beginJob(), endJob(), and endRun().

TH1D* calib::AbsCalib::fWindow_minus
private

Definition at line 60 of file AbsCalib_module.cc.

Referenced by beginJob(), endJob(), and endRun().

TH1D* calib::AbsCalib::fWindow_plus
private

Definition at line 61 of file AbsCalib_module.cc.

Referenced by beginJob(), endJob(), and endRun().

TH1D* calib::AbsCalib::fWindow_true
private

Definition at line 62 of file AbsCalib_module.cc.

Referenced by beginJob(), endJob(), and endRun().

double calib::AbsCalib::fWindowLength
private

Definition at line 50 of file AbsCalib_module.cc.

Referenced by AbsCalib(), and endRun().

double calib::AbsCalib::fWindowStart
private

Definition at line 49 of file AbsCalib_module.cc.

Referenced by AbsCalib(), and endRun().


The documentation for this class was generated from the following file: