Public Member Functions | Private Attributes | List of all members
sim::ProtoDUNEBeamTPCMatching Class Reference
Inheritance diagram for sim::ProtoDUNEBeamTPCMatching:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 ProtoDUNEBeamTPCMatching (fhicl::ParameterSet const &p)
 
 ProtoDUNEBeamTPCMatching (ProtoDUNEBeamTPCMatching const &)=delete
 
 ProtoDUNEBeamTPCMatching (ProtoDUNEBeamTPCMatching &&)=delete
 
ProtoDUNEBeamTPCMatchingoperator= (ProtoDUNEBeamTPCMatching const &)=delete
 
ProtoDUNEBeamTPCMatchingoperator= (ProtoDUNEBeamTPCMatching &&)=delete
 
virtual void beginJob () override
 
virtual void endJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void analyze (art::Event const &e) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

float fBeamTPC_theta
 
float fBeamTPC_phi
 
float beam_true_bprof4_pos [4]
 
float beam_true_tof
 
float beam_true_dir [3]
 
float beam_smeared_bprof4_pos [4]
 
float beam_smeared_tof
 
float beam_smeared_dir [3]
 
float tpc_true_startpos [4]
 
float tpc_true_dir [3]
 
float tpc_reco_startpos [4]
 
float tpc_reco_dir [3]
 
TVector3 tpc_pos
 
TVector3 tpc_dir
 
std::string fpandoraTrack
 
TTree * beamtpc
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 56 of file ProtoDUNEBeamTPCMatching_module.cc.

Constructor & Destructor Documentation

sim::ProtoDUNEBeamTPCMatching::ProtoDUNEBeamTPCMatching ( fhicl::ParameterSet const &  p)
explicit

Definition at line 114 of file ProtoDUNEBeamTPCMatching_module.cc.

115  : EDAnalyzer(p)
116 {
117 
118 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
sim::ProtoDUNEBeamTPCMatching::ProtoDUNEBeamTPCMatching ( ProtoDUNEBeamTPCMatching const &  )
delete
sim::ProtoDUNEBeamTPCMatching::ProtoDUNEBeamTPCMatching ( ProtoDUNEBeamTPCMatching &&  )
delete

Member Function Documentation

void sim::ProtoDUNEBeamTPCMatching::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 166 of file ProtoDUNEBeamTPCMatching_module.cc.

167 {
168  fBeamTPC_theta=0.27361019;
169  fBeamTPC_phi=3.9651559;
170 //========Start of Beam part==========
171  // Get the reconstructed tracks
172  auto beamsim = evt.getValidHandle<std::vector<sim::ProtoDUNEbeamsim> >("generator");
173  const sim::ProtoDUNEbeamsim temp = (*beamsim)[0];
174 // unsigned short nInst = temp.NInstruments();
175 // Computing true and smeared TOF (between TOF1 and TRIG2)
176  sim::ProtoDUNEBeamInstrument tof1 = temp.GetInstrument("TOF1");
177  sim::ProtoDUNEBeamInstrument trig2 = temp.GetInstrument("TRIG2");
178  beam_true_tof = trig2.GetT() - tof1.GetT();
180 // std::cout << "TOF " << tof << std::endl;
181 // std::cout << "TOFS " << tof_smeared << std::endl;
182 
183  sim::ProtoDUNEBeamInstrument bprofext = temp.GetInstrument("BPROFEXT");
184  sim::ProtoDUNEBeamInstrument bprof4 = temp.GetInstrument("BPROF4");
185 
186  beam_true_bprof4_pos[0] = bprof4.GetX() - 0.0;//?
187  beam_true_bprof4_pos[1] = bprof4.GetY() - 0.0;//?
188  beam_true_bprof4_pos[2] = bprof4.GetZ() - 717242.5;
189  beam_true_bprof4_pos[3] = bprof4.GetT();
190  beam_smeared_bprof4_pos[0] = bprof4.GetSmearedVar1() - 0.0;//?
191  beam_smeared_bprof4_pos[1] = bprof4.GetSmearedVar2() - 0.0;//?
192  beam_smeared_bprof4_pos[2] = bprof4.GetZ() - 717242.5;
193  beam_smeared_bprof4_pos[3] = bprof4.GetT();
194 
195  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(evt);
196 
197  double dummy;
198  dummy = pow(pow(bprofext.GetX() -bprof4.GetX(),2)+pow(bprofext.GetY() -bprof4.GetY(),2)+pow(bprofext.GetZ() -bprof4.GetZ(),2),0.5);
199  beam_true_dir[0] = (bprofext.GetX() -bprof4.GetX())/dummy;
200  beam_true_dir[1] = (bprofext.GetY() -bprof4.GetY())/dummy;
201  beam_true_dir[2] = (bprofext.GetZ() -bprof4.GetZ())/dummy;
203  beam_true_dir[1] = -sin(fBeamTPC_phi)*beam_true_dir[0] + cos(fBeamTPC_phi)*cos(fBeamTPC_theta)*beam_true_dir[1] + sin(fBeamTPC_theta)*cos(fBeamTPC_phi)*beam_true_dir[2];
204  beam_true_dir[2] = -sin(fBeamTPC_theta)*beam_true_dir[1] + cos(fBeamTPC_theta)*beam_true_dir[2];
205 // std::cout << dir[2] << " " << sin(fBeamTPC_phi)*sin(fBeamTPC_theta)*dir[0] << " + " << - cos(fBeamTPC_phi)*sin(fBeamTPC_theta)*dir[1] << "+ " << cos(fBeamTPC_theta)*dir[2] << std::endl;
206  dummy = pow(pow(bprofext.GetSmearedVar1() -bprof4.GetSmearedVar1(),2)+pow(bprofext.GetSmearedVar2() -bprof4.GetSmearedVar2(),2)+pow(bprofext.GetZ() -bprof4.GetZ(),2),0.5);
207  beam_smeared_dir[0] = (bprofext.GetSmearedVar1() -bprof4.GetSmearedVar1())/dummy;
208  beam_smeared_dir[1] = (bprofext.GetSmearedVar2() -bprof4.GetSmearedVar2())/dummy;
209  beam_smeared_dir[2] = (bprofext.GetZ() -bprof4.GetZ())/dummy;
210  beam_smeared_dir[0] = cos(fBeamTPC_phi)*beam_true_dir[0] + sin(fBeamTPC_phi)*cos(fBeamTPC_theta)*beam_true_dir[1] - sin(fBeamTPC_phi)*sin(fBeamTPC_theta)*beam_true_dir[2];
211  beam_smeared_dir[1] = -sin(fBeamTPC_phi)*beam_true_dir[0] + cos(fBeamTPC_phi)*cos(fBeamTPC_theta)*beam_true_dir[1] + sin(fBeamTPC_theta)*cos(fBeamTPC_phi)*beam_true_dir[2];
212  beam_smeared_dir[2] = -sin(fBeamTPC_theta)*beam_true_dir[1] + cos(fBeamTPC_theta)*beam_true_dir[2];
213 // std::cout << fBeamTPC_phi << " " << fBeamTPC_theta << std::endl;
214 
215 // std::cout << "cos" << dir[0]*dir_smeared[0]+dir[1]*dir_smeared[1]+dir[2]*dir_smeared[2] << std::endl;
216 // std::cout << bprofext.GetX() << "," << bprofext.GetSmearedVar1() << std::endl;
217 // std::cout << dir[0] << "," << dir_smeared[0] << std::endl;
218 
219 //Filling hisotgrams
220 /* fT0FHist_zoom->Fill(beam_true_tof);
221  fT0FsHist_zoom->Fill(beam_smeared_tof);
222  fUxHist_zoom->Fill(beam_true_dir[0]);
223  fUxsHist_zoom->Fill(beam_smeared_dir[0]);
224  fUyHist_zoom->Fill(beam_true_dir[1]);
225  fUysHist_zoom->Fill(beam_smeared_dir[1]);
226  fUzHist_zoom->Fill(beam_true_dir[2]);
227  fUzsHist_zoom->Fill(beam_smeared_dir[2]);
228  fT0FHist->Fill(beam_true_tof);
229  fT0FsHist->Fill(beam_smeared_tof);
230  fUxHist->Fill(beam_true_dir[0]);
231  fUxsHist->Fill(beam_smeared_dir[0]);
232  fUyHist->Fill(beam_true_dir[1]);
233  fUysHist->Fill(beam_smeared_dir[1]);
234  fUzHist->Fill(beam_true_dir[2]);
235  fUzsHist->Fill(beam_smeared_dir[2]);*/
236 //========End of Beam part==========
237 //
238 //========Start of TPC part==========
239 //Get tracks
240 /* art::Handle< std::vector<simb::MCTruth> > mctruthhandle;
241  std::vector< art::Ptr<simb::MCTruth> > mclist;
242  art::Ptr<simb::MCTruth> mctruth;
243  mctruth = mclist[0];
244 */
245  auto recoTracks = evt.getValidHandle<std::vector<recob::Track> >(fpandoraTrack);
248  dummy = 999999.;
249  TVector3 pos, dir_start, dir_end;
250  for(unsigned int t = 0; t < recoTracks->size(); ++t){
251  const recob::Track thisTrack = (*recoTracks)[t];
252  tpc_pos = thisTrack.Vertex<TVector3>();
253  tpc_dir = thisTrack.VertexDirection<TVector3>();
254  std::vector<anab::T0> trackT0 = trackUtil.GetRecoTrackT0(thisTrack,evt,fpandoraTrack);
255  tpc_reco_startpos[3] = trackT0[0].fTime;
256  tpc_reco_startpos[0] = tpc_pos.X();
257  tpc_reco_startpos[1] = tpc_pos.Y();
258  tpc_reco_startpos[2] = tpc_pos.Z();
259 // tpc_true_startpos = thisTrack->StartMomentumVector();
260  if (dummy >= tpc_reco_startpos[3]){
261  dummy = tpc_reco_startpos[3];
262  const simb::MCParticle *trueMatch = truthUtil.GetMCParticleFromRecoTrack(clockData, thisTrack,evt,fpandoraTrack);
263  bool hasTruth = (trueMatch != 0x0);
264  if (hasTruth == true) {
265 // std::cout << "hey" << std::endl;
266  tpc_true_startpos[0] = trueMatch->Vx();
267  tpc_true_startpos[1] = trueMatch->Vy();
268  tpc_true_startpos[2] = trueMatch->Vz();
269  tpc_true_startpos[3] = trueMatch->T();
270  tpc_true_dir[0] = trueMatch->Px() / trueMatch->P();
271  tpc_true_dir[1] = trueMatch->Py() / trueMatch->P();
272  tpc_true_dir[2] = trueMatch->Pz() / trueMatch->P();
273  }
274  }
275  }
276 
277 
278 
279 
280 /*// Find the associations between tracks and T0
281  const art::FindManyP<anab::T0> findTrackT0(trackHandle,evt,fpandoraTrack);
282 
283 // Also look for cosmic tags so we can make a T0 plot for cosmic tagged events only
284  const art::FindManyP<anab::CosmicTag> findCosmicTag(trackHandle,evt,fpandoraTrack);
285 */
286 beamtpc->Fill();
287 }
double Py(const int i=0) const
Definition: MCParticle.h:231
constexpr T pow(T x)
Definition: pow.h:72
double Px(const int i=0) const
Definition: MCParticle.h:230
Vector_t VertexDirection() const
Definition: Track.h:132
std::vector< anab::T0 > GetRecoTrackT0(const recob::Track &track, art::Event const &evt, std::string trackModule) const
Get the T0(s) from a given reco track.
double P(const int i=0) const
Definition: MCParticle.h:234
Point_t const & Vertex() const
Definition: Track.h:124
double T(const int i=0) const
Definition: MCParticle.h:224
double Vx(const int i=0) const
Definition: MCParticle.h:221
double Pz(const int i=0) const
Definition: MCParticle.h:232
double Vz(const int i=0) const
Definition: MCParticle.h:223
cet::LibraryManager dummy("noplugin")
TCEvent evt
Definition: DataStructs.cxx:7
double Vy(const int i=0) const
Definition: MCParticle.h:222
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
void sim::ProtoDUNEBeamTPCMatching::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 120 of file ProtoDUNEBeamTPCMatching_module.cc.

121 {
122 // Declaring histograms
124 /* fT0FHist_zoom = tfs->make<TH1F>("TOF_TRUE_zoom","T0F (ns)",100,95,96);
125  fT0FsHist_zoom = tfs->make<TH1F>("TOF_SMEARED_zoom","T0F (ns)",100,95,96);
126  fUxHist_zoom = tfs->make<TH1F>("X_DIRECTION_TRUE_zoom","Ux",100,-0.05,0.05);
127  fUyHist_zoom = tfs->make<TH1F>("Y_DIRECTION_TRUE_zoom","Uy",100,-0.05,0.05);
128  fUzHist_zoom = tfs->make<TH1F>("Z_DIRECTION_TRUE_zoom","Uz",100,-1,-0.95);
129  fUxsHist_zoom = tfs->make<TH1F>("X_DIRECTION_SMEARED_zoom","Ux",100,-0.05,0.05);
130  fUysHist_zoom = tfs->make<TH1F>("Y_DIRECTION_SMEARED_zoom","Uy",100,-0.05,0.05);
131  fUzsHist_zoom = tfs->make<TH1F>("Z_DIRECTION_SMEARED_zoom","Uz",100,-1,-0.95);
132  fT0FHist = tfs->make<TH1F>("TOF_TRUE","T0F (ns)",100,90,100);
133  fT0FsHist = tfs->make<TH1F>("TOF_SMEARED","T0F (ns)",100,90,100);
134  fUxHist = tfs->make<TH1F>("X_DIRECTION_TRUE","Ux",100,-1,1);
135  fUyHist = tfs->make<TH1F>("Y_DIRECTION_TRUE","Uy",100,-1,1);
136  fUzHist = tfs->make<TH1F>("Z_DIRECTION_TRUE","Uz",100,-1,1);
137  fUxsHist = tfs->make<TH1F>("X_DIRECTION_SMEARED","Ux",100,-1,1);
138  fUysHist = tfs->make<TH1F>("Y_DIRECTION_SMEARED","Uy",100,-1,1);
139  fUzsHist = tfs->make<TH1F>("Z_DIRECTION_SMEARED","Uz",100,-1,1);
140 */
141  beamtpc = tfs->make<TTree>("beam-tpc", "Beam + TPC matiching Tree");
142  beamtpc->Branch("beam_true_tof", &beam_true_tof, "beam_true_tof/F");
143  beamtpc->Branch("beam_true_dir", &beam_true_dir, "beam_true_dir[3]/F");
144  beamtpc->Branch("beam_true_bprof4_pos",&beam_true_bprof4_pos, "beam_true_bprof4_pos[4]/F");
145  beamtpc->Branch("beam_smeared_tof", &beam_smeared_tof, "beam_smeared_tof/F");
146  beamtpc->Branch("beam_smeared_dir", &beam_smeared_dir, "beam_smeared_dir[3]/F");
147  beamtpc->Branch("beam_smeared_bprof4_pos",&beam_smeared_bprof4_pos, "beam_true_bprof4_pos[4]/F");
148 
149  beamtpc->Branch("tpc_true_startpos", &tpc_true_startpos, "tpc_true_startpos[4]/F");
150  beamtpc->Branch("tpc_true_dir", &tpc_true_dir, "tpc_true_dir[3]/F");
151  beamtpc->Branch("tpc_reco_startpos", &tpc_reco_startpos, "tpc_reco_startpos[4]/F");
152  beamtpc->Branch("tpc_reco_dir", &tpc_reco_dir, "tpc_reco_dir[3]/F");
153 }
void sim::ProtoDUNEBeamTPCMatching::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 292 of file ProtoDUNEBeamTPCMatching_module.cc.

293 {
294 
295 }
ProtoDUNEBeamTPCMatching& sim::ProtoDUNEBeamTPCMatching::operator= ( ProtoDUNEBeamTPCMatching const &  )
delete
ProtoDUNEBeamTPCMatching& sim::ProtoDUNEBeamTPCMatching::operator= ( ProtoDUNEBeamTPCMatching &&  )
delete
void sim::ProtoDUNEBeamTPCMatching::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 156 of file ProtoDUNEBeamTPCMatching_module.cc.

157 {
158  // Rotation angles from last beam section to TPC cordinates
159 // fBeamTPC_theta = pset.get<float>("BeamTPC_theta");
160 // fBeamTPC_phi = pset.get<float>("BeamTPC_phi");
161  // The name of the module that produced the tracks
162  fpandoraTrack = pset.get<std::string>("TrackLabel");
163  } // reconfigure
std::string string
Definition: nybbler.cc:12

Member Data Documentation

float sim::ProtoDUNEBeamTPCMatching::beam_smeared_bprof4_pos[4]
private

Definition at line 84 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::beam_smeared_dir[3]
private

Definition at line 84 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::beam_smeared_tof
private

Definition at line 84 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::beam_true_bprof4_pos[4]
private

Definition at line 83 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::beam_true_dir[3]
private

Definition at line 83 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::beam_true_tof
private

Definition at line 83 of file ProtoDUNEBeamTPCMatching_module.cc.

TTree* sim::ProtoDUNEBeamTPCMatching::beamtpc
private

Definition at line 94 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::fBeamTPC_phi
private

Definition at line 82 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::fBeamTPC_theta
private

Definition at line 81 of file ProtoDUNEBeamTPCMatching_module.cc.

std::string sim::ProtoDUNEBeamTPCMatching::fpandoraTrack
private

Definition at line 92 of file ProtoDUNEBeamTPCMatching_module.cc.

TVector3 sim::ProtoDUNEBeamTPCMatching::tpc_dir
private

Definition at line 89 of file ProtoDUNEBeamTPCMatching_module.cc.

TVector3 sim::ProtoDUNEBeamTPCMatching::tpc_pos
private

Definition at line 89 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::tpc_reco_dir[3]
private

Definition at line 88 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::tpc_reco_startpos[4]
private

Definition at line 88 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::tpc_true_dir[3]
private

Definition at line 86 of file ProtoDUNEBeamTPCMatching_module.cc.

float sim::ProtoDUNEBeamTPCMatching::tpc_true_startpos[4]
private

Definition at line 86 of file ProtoDUNEBeamTPCMatching_module.cc.


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