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

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 BetheBlochFit (const fhicl::ParameterSet &pset)
 
virtual ~BetheBlochFit ()
 
void analyze (const art::Event &evt) override
 
void beginJob () override
 
void endJob () override
 
void beginRun (const art::Run &run) override
 
void endRun (const art::Run &run) 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

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

Protected Attributes

double fWindowStart
 
double fWindowLength
 
TH2 * fdEdx
 
TH2 * fdEdx_true
 

Detailed Description

Definition at line 35 of file BetheBlochFit_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::BetheBlochFit::BetheBlochFit ( const fhicl::ParameterSet pset)
explicit

Definition at line 59 of file BetheBlochFit_module.cc.

References fWindowLength, and fWindowStart.

60  : EDAnalyzer(pset)
61  {
62  // TODO: get these from pset
63  fWindowStart = 100.;
64  fWindowLength = 100.;
65  }
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
calib::BetheBlochFit::~BetheBlochFit ( )
virtual

Definition at line 68 of file BetheBlochFit_module.cc.

69  {
70  }

Member Function Documentation

void calib::BetheBlochFit::analyze ( const art::Event evt)
override

Definition at line 73 of file BetheBlochFit_module.cc.

74  {
75  }
void calib::BetheBlochFit::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 78 of file BetheBlochFit_module.cc.

References fdEdx, fdEdx_true, and art::TFileDirectory::make().

79  {
81  fdEdx = tfs->make<TH2D>("dEdx", ";Distance to track end (cm);PECorr / cm",
82  50, 0, 500, 100, 0, 200);
83  fdEdx_true = tfs->make<TH2D>("dEdx_true",";Distance to track end (cm);True MeV / cm",
84  50, 0, 500, 100, 0, 5);
85  }
T * make(ARGS...args) const
void calib::BetheBlochFit::beginRun ( const art::Run run)
override

Definition at line 88 of file BetheBlochFit_module.cc.

89  {
90  }
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::BetheBlochFit::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 131 of file BetheBlochFit_module.cc.

References elec2geo::block, geo::PlaneGeo::Cell(), om::cout, DEFINE_ART_MODULE(), allTimeWatchdog::endl, fdEdx, art::TFileService::file(), geom(), calib::IBetheBloch::GetdEdxGraph(), calib::EnergyLossVsDistance::GetEnergyLossGraph(), calib::IBetheBloch::GetMPVGraph(), calib::EnergyLossVsDistance::GetTF1(), geo::CellGeo::HalfD(), calib::kPolyethylene, calib::IBetheBloch::MIP(), geo::GeometryBase::Plane(), ProfileMPV(), and geo::GeometryBase::ROOTGeoManager().

132  {
134 
135  // This differs from soup by about 0.2%
136  // Representative of the whole detector
137  TGeoVolume* block = geom->ROOTGeoManager()->FindVolumeFast("vBlock");
138  const double avgDensity = 1e3*block->Weight()/block->Capacity();
139 
140  // const double avgDensity =
141  // geom->ROOTGeoManager()->GetMaterial("Soup")->GetDensity();
142 
143  const double scintDensity =
144  geom->ROOTGeoManager()->GetMaterial("Scintillator")->GetDensity();
145 
146  std::cout << "Detector average (soup) density is " << avgDensity << std::endl;
147  std::cout << "Scintillator density is " << scintDensity << std::endl;
148 
149  TProfile* prof = fdEdx->ProfileX();
150 
151  IBetheBloch* bb_ana = new BetheBlochAnalytic(kPolyethylene);
152  IBetheBloch* bb_tab = new BetheBlochTables(kPolyethylene);
153 
154  EnergyLossVsDistance el_ana(bb_ana, scintDensity, avgDensity);
155  EnergyLossVsDistance el_tab(bb_tab, scintDensity, avgDensity);
156 
157  TF1* f_ana = el_ana.GetTF1();
158  prof->Fit(f_ana, "", "", 50, 500);
159  TF1* f_tab = el_tab.GetTF1();
160  prof->Fit(f_tab, "", "", 50, 500);
161 
162  // Average seen by muon travelling along z-axis
163  const double Lz = (geom->Plane(0)->Cell(4)->HalfD()+geom->Plane(1)->Cell(4)->HalfD())/2;
164 
165  const double pePerMeV = f_ana->GetParameter(0);
166 
167  std::cout << "1 MeV = " << pePerMeV << " PE -> 1 PE = " << 1/pePerMeV << " MeV" << std::endl;
168 
169  const double MeVPerCmPerMIP = bb_ana->MIP()*scintDensity;
170 
171  std::cout << "1 MIP = " << MeVPerCmPerMIP*Lz << " MeV [MeVScale]" << std::endl;
172 
173  const double pePerMIPPerCm = pePerMeV*MeVPerCmPerMIP;
174 
175  std::cout << "1 MIP = " << pePerMIPPerCm*Lz << " PE -> 1 PE = " << 1/pePerMIPPerCm/Lz << " MIP [MIPScale]" << std::endl;
176 
177  // Subvert the file service
179  tfs->file().cd("bb");
180  f_ana->Draw("c");
181  f_ana->GetHistogram()->Write("fit_ana");
182  f_tab->Draw("c");
183  f_tab->GetHistogram()->Write("fit_tab");
184 
185  el_ana.GetEnergyLossGraph()->Write("el_ana");
186  el_tab.GetEnergyLossGraph()->Write("el_tab");
187 
188  bb_tab->GetdEdxGraph(scintDensity)->Write("dEdx_curve");
189  bb_ana->GetdEdxGraph(scintDensity)->Write("dEdx_curve_ana");
190  bb_ana->GetMPVGraph(scintDensity, Lz)->Write("mpv_curve_ana");
191  bb_ana->GetMPVGraph(scintDensity, Lz*2)->Write("mpv_curve_ana2");
192  bb_ana->GetMPVGraph(scintDensity, Lz/2)->Write("mpv_curve_ana3");
193 
194  ProfileMPV(fdEdx)->Write("prof_mpv");
195  }
double HalfD() const
Definition: CellGeo.cxx:205
const CellGeo * Cell(int icell) const
Definition: PlaneGeo.h:48
TGeoManager * ROOTGeoManager() const
TFile & file() const
Definition: TFileService.h:63
const PlaneGeo * Plane(unsigned int i) const
TH1 * ProfileMPV(TH2 *h) const
block
print "ROW IS " print row
Definition: elec2geo.py:31
OStream cout
Definition: OStream.cxx:6
void geom(int which=0)
Definition: geom.C:163
void calib::BetheBlochFit::endRun ( const art::Run run)
override

Definition at line 93 of file BetheBlochFit_module.cc.

References dE, fdEdx, fdEdx_true, and art::DataViewImpl::getByLabel().

94  {
95  art::Handle<TH2D> dE, dEtrue;
96  run.getByLabel("muondedx", "dEdx", dE);
97  run.getByLabel("muondedx", "dEdxTrue", dEtrue);
98 
99  fdEdx->Add(&*dE);
100  fdEdx_true->Add(&*dEtrue);
101  }
double dE
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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
TH1 * calib::BetheBlochFit::ProfileMPV ( TH2 *  h) const
protected

Definition at line 104 of file BetheBlochFit_module.cc.

References func(), maxy, proj, runNovaSAM::ret, febshutoff_auto::val, submit_syst::x, and submit_syst::y.

Referenced by endJob().

105  {
106  TH1* ret = new TH1F("", "", h->GetNbinsX(),
107  h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
108  for(int x = 0; x < h->GetNbinsX()+2; ++x){
109  double maxVal = -1e10;
110  double maxy = 0;
111  for(int y = 1; y < h->GetNbinsY()+1; ++y){
112  const double val = h->GetBinContent(x, y);
113  if(val > maxVal){
114  maxVal = val;
115  maxy = h->GetYaxis()->GetBinCenter(y);
116  }
117  }
118  TH1* proj = h->ProjectionY("", x, x);
119  proj->Fit("gaus", "0Q", "", maxy-0.2, maxy+0.2);
120  TF1* func = proj->GetFunction("gaus");
121  if(func){
122  ret->SetBinContent(x, func->GetParameter(1));
123  ret->SetBinError(x, func->GetParError(1));
124  }
125  }
126 
127  return ret;
128  }
double maxy
double func(double x, double y)
Float_t proj
Definition: plot.C:35
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

TH2* calib::BetheBlochFit::fdEdx
protected

Definition at line 54 of file BetheBlochFit_module.cc.

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

TH2* calib::BetheBlochFit::fdEdx_true
protected

Definition at line 55 of file BetheBlochFit_module.cc.

Referenced by beginJob(), and endRun().

double calib::BetheBlochFit::fWindowLength
protected

Definition at line 52 of file BetheBlochFit_module.cc.

Referenced by BetheBlochFit().

double calib::BetheBlochFit::fWindowStart
protected

Definition at line 51 of file BetheBlochFit_module.cc.

Referenced by BetheBlochFit().


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