hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
Loading...
Searching...
No Matches
MCAnaProcessor.cxx
Go to the documentation of this file.
1
6#include "MCAnaProcessor.h"
7#include <iostream>
8
10//TODO CHECK THIS DESTRUCTOR
12
13
14void MCAnaProcessor::configure(const ParameterSet& parameters) {
15 std::cout << "Configuring MCAnaProcessor" << std::endl;
16 try
17 {
18 debug_ = parameters.getInteger("debug");
19 anaName_ = parameters.getString("anaName");
20 partColl_ = parameters.getString("partColl");
21 trkrHitColl_ = parameters.getString("trkrHitColl");
22 ecalHitColl_ = parameters.getString("ecalHitColl");
23 histCfgFilename_ = parameters.getString("histCfg");
24 analysis_ = parameters.getString("analysis");
25 }
26 catch (std::runtime_error& error)
27 {
28 std::cout << error.what() << std::endl;
29 }
30}
31
32void MCAnaProcessor::initialize(TTree* tree) {
33 tree_= tree;
34 // init histos
36 histos->loadHistoConfig(histCfgFilename_);
37 histos->DefineHistos();
38 histos->Define2DHistos();
39
40 // init TTree
41 tree_->SetBranchAddress(partColl_.c_str(), &mcParts_, &bmcParts_);
42 if (tree_->FindBranch(trkrHitColl_.c_str()))
43 tree_->SetBranchAddress(trkrHitColl_.c_str(), &mcTrkrHits_, &bmcTrkrHits_);
44 else
45 std::cout<<"WARNING: No tracker hit collection, will skip FillMCTrackerHits! "<<std::endl;
46
47 if ( tree_->FindBranch(ecalHitColl_.c_str()))
48 tree_->SetBranchAddress(ecalHitColl_.c_str(), &mcEcalHits_, &bmcEcalHits_);
49 else
50 std::cout<<"WARNING: No Ecal hit collection, will skip FillMCEcalHits"<<std::endl;
51
52}
53
55
56 histos->FillMCParticles(mcParts_, analysis_);
57 if(mcTrkrHits_)
58 histos->FillMCTrackerHits(mcTrkrHits_);
59 if(mcEcalHits_)
60 histos->FillMCEcalHits(mcEcalHits_);
61
62 return true;
63}
64
66
67 histos->saveHistos(outF_, anaName_);
68 delete histos;
69 histos = nullptr;
70}
71
#define DECLARE_PROCESSOR(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Definition Processor.h:139
Definition IEvent.h:7
description
Definition MCAnaHistos.h:20
Insert description here. more details.
std::vector< MCTrackerHit * > * mcTrkrHits_
description
MCAnaHistos * histos
virtual bool process(IEvent *ievent)
description
std::string trkrHitColl_
description
std::string ecalHitColl_
description
int debug_
Debug Level.
MCAnaProcessor(const std::string &name, Process &process)
Constructor.
TBranch * bmcTrkrHits_
description
std::string anaName_
description
virtual void configure(const ParameterSet &parameters)
description
virtual void finalize()
description
TBranch * bmcEcalHits_
description
virtual void initialize(TTree *tree)
description
std::string analysis_
description
std::string partColl_
description
std::vector< MCEcalHit * > * mcEcalHits_
description
TBranch * bmcParts_
description
std::string histCfgFilename_
description
std::vector< MCParticle * > * mcParts_
description
description
TFile * outF_
Definition Processor.h:125
Processor(const std::string &name, Process &process)
Class constructor.
Definition Processor.cxx:10
virtual bool process()
Process the histograms and generate analysis output.
Definition Processor.h:95