Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
94f7a7b
initial commit
sophieMu2e Feb 21, 2019
3670fc4
add straightfit
sophieMu2e Feb 21, 2019
b79c7e9
new parametric fit
sophieMu2e Feb 28, 2019
c8da7c8
para fit
sophieMu2e Feb 28, 2019
de29097
cosmics para
sophieMu2e Feb 28, 2019
ab4a5e8
adding
sophieMu2e Mar 6, 2019
4973294
updated master
sophieMu2e Mar 6, 2019
8239e78
Fixed conflicts caused by first merge- some issues still remain with …
sophieMu2e Mar 7, 2019
d425ebf
finally working with latest merge update
sophieMu2e Mar 7, 2019
3625e42
...
sophieMu2e Mar 7, 2019
4f0b3ac
added build matrix sums class to do sum algrbra for track parameter c…
sophieMu2e Mar 9, 2019
2109abb
Updated Fit routines -still not right but improved..
sophieMu2e Mar 14, 2019
13f7318
Updated Fitting routine- still not final but chi2 and pulls now more …
sophieMu2e Mar 15, 2019
eac3a60
iterative errors, double prime coord system- not finished yet, residu…
sophieMu2e Mar 19, 2019
6b61394
beginning to add drift information, currently under sonstruction in C…
sophieMu2e Mar 21, 2019
7f5e601
updated diagnostics (works), updated event display, iteration and con…
sophieMu2e Mar 26, 2019
3e9644d
fixed recon efficiency but chi 2 still bad in Y
sophieMu2e Apr 1, 2019
9ccf5e9
Added MC Digi information Extractor to CosmicTrack Fit
sophieMu2e Apr 4, 2019
934288b
alogrithim seems to work, event displays in colour, some labelling, r…
sophieMu2e Apr 10, 2019
5473425
Lots of updates - the entire alogrithim for fitting has been re-writ…
sophieMu2e May 31, 2019
a640c72
updated diagnostics for CM in Minnesota
sophieMu2e Jun 22, 2019
0bcddcb
updated diagnostics for minnesota
sophieMu2e Jun 28, 2019
c15ca36
a few tidy ups
sophieMu2e Jul 12, 2019
45840ea
deleted Straight stuff ...hopefully...
sophieMu2e Jul 22, 2019
7373f82
Added in liklihood functionality, PDF not quite there yet but no erro…
sophieMu2e Jul 31, 2019
980982c
Added a lot of functionality to allow for various forms of PDF fit, o…
sophieMu2e Aug 2, 2019
6ce6816
added way to access TrkStrawHit in CosmicTrackSeed but doesnt yet wor…
sophieMu2e Aug 6, 2019
4c9bd92
Updated CosmicTrack class structure, improved seed fit diagnostic sto…
sophieMu2e Aug 13, 2019
4be8ded
a few minor updates
sophieMu2e Aug 15, 2019
e858379
old files, saving incase needed later on
sophieMu2e Aug 15, 2019
6f8a23f
merged in master - some issues
sophieMu2e Aug 15, 2019
5dd4c57
latest master merged in- come changes to prologs to accompate
sophieMu2e Aug 15, 2019
45fda2c
added code to plot DOCA and time residuals before and after Minuit Dr…
sophieMu2e Aug 19, 2019
ef1db02
lots of changes - added in functions to transform local co-ordinates …
sophieMu2e Sep 17, 2019
408dbb3
initial drift fit with gaussina pdf for time residual converges and i…
sophieMu2e Sep 23, 2019
ecb954c
Full PDF and interpolate PDF (based on Richie's code) implemented. Ch…
sophieMu2e Sep 30, 2019
bb72d8c
Full fit working - not ran on high stats yet
sophieMu2e Oct 11, 2019
6bd59d8
added mom plot to analysis module
sophieMu2e Oct 11, 2019
350adfe
changed chi2 min
sophieMu2e Oct 11, 2019
9203762
cuts changed
sophieMu2e Oct 11, 2019
638994d
cuts changed
sophieMu2e Oct 11, 2019
e3f2f0d
changed cuts
sophieMu2e Oct 12, 2019
4f9ce96
working drift fit
sophieMu2e Oct 16, 2019
4aacb1f
removed trkdifgi.fcl
sophieMu2e Oct 16, 2019
90e112b
testing
sophieMu2e Oct 16, 2019
0111e30
updated trkpatrec prolog fcl
sophieMu2e Oct 16, 2019
eff71a8
removed straight stuff and read energy de
sophieMu2e Oct 16, 2019
0aac7f8
fcls changed
sophieMu2e Oct 16, 2019
c1b29b2
changed prolog.fcl in trkpatrec so cosmics tracking is its own producer
sophieMu2e Oct 17, 2019
1a533f4
removed clutter in TrkReco
sophieMu2e Oct 17, 2019
fd163c1
removed clutter from TrkPatRec
sophieMu2e Oct 17, 2019
53875e9
tidied up RecoDataProducts
sophieMu2e Oct 17, 2019
76cc81f
further deletes
sophieMu2e Oct 17, 2019
8ff761b
Created CosmicReco directory
sophieMu2e Oct 17, 2019
25eeaf3
transfer TrkReco cosmic code to cosmic reco directory, updated paths …
sophieMu2e Oct 17, 2019
bd08205
Further updates to mu2eutilities-deleted old straight fitting code
sophieMu2e Oct 17, 2019
f168379
added in more cosmic modules to src
sophieMu2e Oct 17, 2019
7ad1fb8
Removed from the TrkReco completely now
sophieMu2e Oct 17, 2019
f3cc667
deleted all cosmics from inc in trkreco
sophieMu2e Oct 17, 2019
7545ad1
first working build, fcl no ready yet though
sophieMu2e Oct 17, 2019
47dea5c
added fcl file to cosmic reco
sophieMu2e Oct 17, 2019
bb47566
added cosmic reco prolog to standard producers list
sophieMu2e Oct 17, 2019
c2d8c48
removed from standard producer...not a good idea, it turns out....
sophieMu2e Oct 17, 2019
13fc9ed
updated utils
sophieMu2e Oct 17, 2019
963ad8e
added trk fit flags for cosmics to the recodataproducts class defs
sophieMu2e Oct 17, 2019
e5ec2a3
added CosmicTrkFlag, works and ran on low sats reco eff now assymetri…
sophieMu2e Oct 17, 2019
57427d9
moved TrkDiag cosmic modules to cosmic reco and added in trk flag for…
sophieMu2e Oct 17, 2019
ad2a400
deleted old code
sophieMu2e Oct 18, 2019
b684613
TrkFitFlag editted
sophieMu2e Oct 18, 2019
ea028fa
changed SConscript to orign
sophieMu2e Oct 18, 2019
bfe4682
reverted TrackerConsditions
sophieMu2e Oct 18, 2019
479934b
TrkStrawHit reverted
sophieMu2e Oct 18, 2019
0956b7c
reverted standard producers
sophieMu2e Oct 18, 2019
e901bf3
lots of small 1 line none real conflicts resolved
sophieMu2e Oct 18, 2019
4e8fa75
very minor cinflicts resolved
sophieMu2e Oct 18, 2019
a7cea34
TrkReco conflicts begin resolving
sophieMu2e Oct 18, 2019
e4f732f
removed odd gedit file and started on TrkPatRec conflicts in helix
sophieMu2e Oct 18, 2019
f3a4fc8
more minor changes to resolve conflicts in TrkPatRec (nothing reallly…
sophieMu2e Oct 18, 2019
58f114d
resolved name conflict in helix diag in trkpatrec
sophieMu2e Oct 18, 2019
8b91db7
fixed conflit in helix diag (Same as above, forgot to add)
sophieMu2e Oct 18, 2019
a651e8e
conflicts removed
sophieMu2e Oct 18, 2019
c4dae1a
removed LineFit - empty file
sophieMu2e Oct 18, 2019
3ebf9f7
removed and moved file associated with cosmictrakc finder
sophieMu2e Oct 18, 2019
44b91fa
reverted tracker conditions added space and trkfitflag reverted to or…
sophieMu2e Oct 18, 2019
fd91694
prolog of tracker conditions reverted
sophieMu2e Oct 18, 2019
5ae4202
reverted prologs
sophieMu2e Oct 18, 2019
79bc58e
Produces also a TTree
Oct 19, 2019
ff70668
Added support for shower minimum energy:
Oct 19, 2019
cc85f8b
Fixed broken GeometryService
Oct 19, 2019
97069db
Implemented CORSIKA support
Oct 19, 2019
36c322d
Restore CRY default config
Oct 19, 2019
bbadc3e
Fixed minimum shower energy CRY:
Oct 19, 2019
15d956a
Added minimum shower energy support
Oct 19, 2019
a4bd31e
Added CORSIKA support
Oct 19, 2019
f8ea9f1
so slight changes to correct conflits
sophieMu2e Oct 20, 2019
d78a57e
Increased shower area extension, no buffer as in CRY
Oct 22, 2019
eb89293
Added standard geometry statement
Oct 22, 2019
a30d144
Appended new enum at the end
Oct 22, 2019
91487d5
For sequential event mixing, skip a random number of events in the se…
AndrewEdmonds11 Oct 22, 2019
1679ea5
Dropped SimpleConfig, now the parameters are in the fcl file. Various…
Oct 23, 2019
83bdf26
updated analysis module
sophieMu2e Oct 24, 2019
fedfcfc
Merge branch 'master' of https://github.com/brownd1978/Offline
brownd1978 Oct 24, 2019
7e79454
Merge branch 'tracker-step-point-compression-bug-check-fix' of https:…
brownd1978 Oct 24, 2019
110c90c
fixed memory leak by adding remove feature to pdf class
sophieMu2e Oct 25, 2019
fc75335
tried to correct small conflicts
sophieMu2e Oct 25, 2019
273b991
tried to remove conflict in trk flag
sophieMu2e Oct 25, 2019
71ffa53
removed conflict in the SConscript of Trkdiag
sophieMu2e Oct 25, 2019
c2a3480
reverted combohit.cc
sophieMu2e Oct 25, 2019
6858747
reverted combohit.cc fixed white space
sophieMu2e Oct 25, 2019
e719565
Adding a FIXME comment
AndrewEdmonds11 Oct 26, 2019
151d6cd
added function for evaluating the lambda and phi0 in RobustHelixFit u…
Oct 28, 2019
d3ad3f9
CORSIKA producer divided into source+producer modules
Oct 28, 2019
16a4f89
Added source model and fcl test
Oct 28, 2019
aa93603
lots of changes after Dave Browns corrections
sophieMu2e Oct 29, 2019
0782558
lots of change to MC omputation and comparrision to reco, this is all…
sophieMu2e Oct 29, 2019
7d3ba6b
fixed ambi type to int, updated reco class list
sophieMu2e Oct 29, 2019
569d4d9
moved some things arounf on cosmc anlayzer
sophieMu2e Oct 29, 2019
4fa8dde
first attempt at validated fhicl-builds but havnt ran yet
sophieMu2e Oct 29, 2019
ce2ecab
error in analyzer
sophieMu2e Oct 30, 2019
e85a6b6
fixed analyzer, now works with validation fcl
sophieMu2e Oct 30, 2019
f8bbca4
transltated fit module and helper to valiated fhicl
sophieMu2e Oct 30, 2019
87bd832
lots of tidying up, reoved types class and diag plug in as it was not…
sophieMu2e Oct 30, 2019
7515981
tidied up and changed class names in Liklihood fitter to better refle…
sophieMu2e Oct 31, 2019
a92342e
Merge pull request #39 from AndrewEdmonds11/sequential-mixing
brownd1978 Oct 31, 2019
177d800
Merge branch 'master' of https://github.com/mu2e/Offline
brownd1978 Oct 31, 2019
5b4bd21
Adjust sequential mixing parameters. Update validation mixing script…
brownd1978 Oct 31, 2019
026b2b8
revert file names, comment
brownd1978 Oct 31, 2019
2347ed2
Merge pull request #43 from brownd1978/valfix
brownd1978 Oct 31, 2019
6613046
changed Liklihood fitter name, moved DriftFitUtil
sophieMu2e Oct 31, 2019
2c4713c
condensed the PDFs so no longer a PDFFitter class needed
sophieMu2e Oct 31, 2019
daa2b3e
adding missing files
sophieMu2e Oct 31, 2019
7786166
Merge pull request #40 from sophiemiddleton/CosmicDriftUpdate
brownd1978 Oct 31, 2019
2f5d68a
ParticleDataTable outside loop; every shower starts at t=0
soleti Nov 1, 2019
f9fb316
Removed header file not needed anymore
soleti Nov 1, 2019
94e3942
code cleanup. Created sub-routines to simplify the code structure
Nov 1, 2019
fb2efcc
Fix bit overwrite
brownd1978 Nov 1, 2019
f65ce98
switched from simple vectors to std::vector in the function RobustHel…
Nov 1, 2019
aea8d58
Merge pull request #44 from brownd1978/bugfix
brownd1978 Nov 1, 2019
a32030e
New event if particle outside the box; refactored utility functions
soleti Nov 1, 2019
905c05b
Addition of scripts for cosmic and beam resampling
Nov 4, 2019
f65ac3e
Merge pull request #41 from gianipez/ahaslundBackup
brownd1978 Nov 4, 2019
6fb26f4
Merge pull request #45 from oksuzian/master
kutschke Nov 4, 2019
7f5f700
make bit positions permanent
rlcee Nov 5, 2019
2f5d55c
Merge pull request #47 from rlcee/val_bits
brownd1978 Nov 5, 2019
fc034b2
Added geometry utilities and tidied fcl files
soleti Nov 6, 2019
880d02f
Merge pull request #35 from soleti/master
kutschke Nov 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
264 changes: 264 additions & 0 deletions Analyses/src/CORSIKAGenPlots_module.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
////////////////////////////////////////////////////////////////////////
// Class: CORSIKAGenPlots
// Plugin Type: analyzer (art v2_10_04)
// File: CORSIKAGenPlots_module.cc
//
// Stefano Roberto Soleti (roberto@lbl.gov)
//
////////////////////////////////////////////////////////////////////////

#include "art/Framework/Core/EDAnalyzer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "art_root_io/TFileService.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"

#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

#include "GlobalConstantsService/inc/GlobalConstantsHandle.hh"
#include "GlobalConstantsService/inc/PhysicsParams.hh"
#include "GlobalConstantsService/inc/ParticleDataTable.hh"
#include "MCDataProducts/inc/GenParticleCollection.hh"

#include "TH1F.h"
#include "TH2F.h"
#include "TTree.h"
namespace mu2e {
class CORSIKAGenPlots;
}

using CLHEP::Hep3Vector;
using CLHEP::HepLorentzVector;


class mu2e::CORSIKAGenPlots : public art::EDAnalyzer {
public:
explicit CORSIKAGenPlots(fhicl::ParameterSet const & p);
// The compiler-generated destructor is fine for non-base
// classes without bare pointers or other resource use.

// Plugins should not be copied or assigned.
CORSIKAGenPlots(CORSIKAGenPlots const &) = delete;
CORSIKAGenPlots(CORSIKAGenPlots &&) = delete;
CORSIKAGenPlots & operator = (CORSIKAGenPlots const &) = delete;
CORSIKAGenPlots & operator = (CORSIKAGenPlots &&) = delete;

// Required functions.
void analyze(art::Event const & e) override;

// Selected optional functions.
void beginJob() override;
void endJob() override;

private:
std::string processName_;
std::string CORSIKAModuleLabel_;
std::string CORSIKAInstanceName_;
float _keMax = std::numeric_limits<float>::max();

// histograms
TH2F *_hXZ = nullptr;
TH1F *_hY = nullptr;
TH1F *_hKE = nullptr;
TH1F *_hTheta = nullptr;
TH1F *_hPhi = nullptr;
TH1F *_hPmag = nullptr;
TH1F *_hPyOverPmag = nullptr;
TH1F *_hTime = nullptr;
TH2F *_hPtypeKE = nullptr;
TH1F *_hNSecondaries = nullptr;

TTree *_cosmicTree = nullptr;

float _x = std::numeric_limits<float>::lowest();
float _y = std::numeric_limits<float>::lowest();
float _z = std::numeric_limits<float>::lowest();
float _px = std::numeric_limits<float>::lowest();
float _py = std::numeric_limits<float>::lowest();
float _pz = std::numeric_limits<float>::lowest();
float _theta = std::numeric_limits<float>::lowest();
float _phi = std::numeric_limits<float>::lowest();
float _KE = std::numeric_limits<float>::lowest();
float _p = std::numeric_limits<float>::lowest();
float _t = std::numeric_limits<float>::lowest();
PDGCode::type _pdgId;

void bookHists(art::ServiceHandle<art::TFileService> &);
GlobalConstantsHandle<ParticleDataTable> pdt;
};

mu2e::CORSIKAGenPlots::CORSIKAGenPlots(fhicl::ParameterSet const &p)
: EDAnalyzer(p),
processName_(p.get<std::string>("processName", "")),
CORSIKAModuleLabel_(p.get<std::string>("CORSIKAModuleLabel", "FromCorsikaBinary")),
CORSIKAInstanceName_(p.get<std::string>("CORSIKAInstanceName", "")),
_keMax(p.get<double>("keMax", 10E3))
{
art::ServiceHandle<art::TFileService> tfs;

bookHists(tfs);

_cosmicTree = tfs->make<TTree>("cosmicTree", "TTree with cosmic ray info");

_cosmicTree->Branch("x", &_x, "x/F");
_cosmicTree->Branch("y", &_y, "y/F");
_cosmicTree->Branch("z", &_z, "z/F");
_cosmicTree->Branch("px", &_px, "px/F");
_cosmicTree->Branch("py", &_py, "py/F");
_cosmicTree->Branch("pz", &_pz, "pz/F");
_cosmicTree->Branch("theta", &_theta, "theta/F");
_cosmicTree->Branch("phi", &_phi, "phi/F");
_cosmicTree->Branch("KE", &_KE, "KE/F");
_cosmicTree->Branch("p", &_p, "p/F");
_cosmicTree->Branch("t", &_t, "t/F");
_cosmicTree->Branch("pdgId", &_pdgId, "pdgId/I");

}


void mu2e::CORSIKAGenPlots::analyze(art::Event const & e)
{
art::Handle<GenParticleCollection> gpHandle;
bool success;

if (processName_.length() > 0)
success = e.getByLabel(CORSIKAModuleLabel_, CORSIKAInstanceName_, processName_,
gpHandle);
else
success = e.getByLabel(CORSIKAModuleLabel_, CORSIKAInstanceName_, gpHandle);

if (!success)
return;

const auto & particles = *gpHandle;


_hNSecondaries->Fill(particles.size());
for(const auto & p : particles)
{
_hXZ->Fill(p.position().x(), p.position().z());
_hY->Fill(p.position().y());

const HepPDT::ParticleData& p_data = pdt->particle(p.pdgId()).ref();
double mass = p_data.mass().value(); // in MeV

HepLorentzVector mom4 = p.momentum();
Hep3Vector mom3(mom4.px(), mom4.py(), mom4.pz());
Hep3Vector yMom3(mom4.pz(), mom4.px(), -mom4.py()); // for theta, phi

_hKE->Fill(mom4.e() - mass);
_hTheta->Fill(yMom3.theta());
_hPhi->Fill(yMom3.phi());

_hPmag->Fill(mom3.mag());
_hTime->Fill(p.time());
_hPyOverPmag->Fill(mom4.py() / mom3.mag());

_x = p.position().x();
_y = p.position().y();
_z = p.position().z();

_px = mom4.px();
_py = mom4.py();
_pz = mom4.pz();

_theta = yMom3.theta();
_phi = yMom3.phi();
_KE = mom4.e() - mass;
_p = mom3.mag();

_t = p.time();

_pdgId = p.pdgId();
_cosmicTree->Fill();

switch (p.pdgId()) {
case 13: // mu-
_hPtypeKE->Fill(mom4.e(), 0); break;
case -13: // mu+
_hPtypeKE->Fill(mom4.e(), 0); break;
case 22: // photon
_hPtypeKE->Fill(mom4.e(), 1); break;
case -11: // e+
_hPtypeKE->Fill(mom4.e(), 2); break;
case 11: // e-
_hPtypeKE->Fill(mom4.e(), 2); break;
case 2112: // neutron
_hPtypeKE->Fill(mom4.e(), 3); break;
case -2112: // neutron
_hPtypeKE->Fill(mom4.e(), 3); break;
case 2212: // proton
_hPtypeKE->Fill(mom4.e(), 4); break;
case -2212: // proton
_hPtypeKE->Fill(mom4.e(), 4); break;
case 111: // pi0
_hPtypeKE->Fill(mom4.e(), 5); break;
case 211: // pi+
_hPtypeKE->Fill(mom4.e(), 5); break;
case -211: // pi-
_hPtypeKE->Fill(mom4.e(), 5); break;
case 130: // k0 L
_hPtypeKE->Fill(mom4.e(), 6); break;
case 310: // k0 S
_hPtypeKE->Fill(mom4.e(), 6); break;
case 311: // k0
_hPtypeKE->Fill(mom4.e(), 6); break;
case 321: // k+
_hPtypeKE->Fill(mom4.e(), 6); break;
case -321: // k-
_hPtypeKE->Fill(mom4.e(), 6); break;
default: // others
_hPtypeKE->Fill(mom4.e(), 7); break;
}

}

}

void mu2e::CORSIKAGenPlots::beginJob()
{
// Implementation of optional member function here.
}

void mu2e::CORSIKAGenPlots::endJob()
{
// Implementation of optional member function here.
}

void mu2e::CORSIKAGenPlots::bookHists(art::ServiceHandle<art::TFileService> &tfs)
{

_hXZ = tfs->make<TH2F>("XZ", "XZ", 500, -2.0e5, 2.0e5, 500, -2.0e5, 2.0e5 );
_hY = tfs->make<TH1F>("Y", "Y", 500, -15.0e3, 21.0e3 );

_hKE = tfs->make<TH1F>("E", "E", 2000, 0, _keMax);
_hTheta = tfs->make<TH1F>("Theta", "Theta",
200, -M_PI - 0.5, M_PI + 0.5);
_hPhi = tfs->make<TH1F>("Phi", "Phi",
200, -M_PI - 0.5, M_PI + 0.5);

_hPmag = tfs->make<TH1F>("Pmag", "Momentum modulus", 500, 0., 2E6);
_hPyOverPmag = tfs->make<TH1F>("PyOverPmag", "Py/Pmag", 200, -20., 20.);
_hTime = tfs->make<TH1F>("Time", "Timing of secondary particles",
1000, -1.E-3, 1E0);

_hNSecondaries = tfs->make<TH1F>("nSecondaries", "Number of secondaries",
1000, 0, 1000);

_hPtypeKE = tfs->make<TH2F>("PtypeKE", "Particle type vs energy",
2000, 0., 2E6, 8, 0, 8);
_hPtypeKE->GetYaxis()->SetBinLabel(1, "mu");
_hPtypeKE->GetYaxis()->SetBinLabel(2, "gamma");
_hPtypeKE->GetYaxis()->SetBinLabel(3, "electron");
_hPtypeKE->GetYaxis()->SetBinLabel(4, "neutron");
_hPtypeKE->GetYaxis()->SetBinLabel(5, "proton");
_hPtypeKE->GetYaxis()->SetBinLabel(6, "pion");
_hPtypeKE->GetYaxis()->SetBinLabel(7, "kaon");
_hPtypeKE->GetYaxis()->SetBinLabel(8, "others");
}
DEFINE_ART_MODULE(mu2e::CORSIKAGenPlots)
70 changes: 64 additions & 6 deletions Analyses/src/CRYGenPlots_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,23 @@ class mu2e::CRYGenPlots : public art::EDAnalyzer {
TH2F *_hPtypeKE;
TH1F *_hNSecondaries;

void bookHists();
GlobalConstantsHandle<ParticleDataTable> pdt;
TTree *_cosmicTree;

float _x;
float _y;
float _z;
float _px;
float _py;
float _pz;
float _theta;
float _phi;
float _KE;
float _p;
float _t;
int _pdgId;

void bookHists(art::ServiceHandle<art::TFileService> &);
GlobalConstantsHandle<ParticleDataTable> pdt;
};


Expand All @@ -85,7 +100,24 @@ class mu2e::CRYGenPlots : public art::EDAnalyzer {
, CRYInstanceName_(p.get<std::string>("CRYInstanceName", ""))
, _keMax(p.get<double>("keMax", 10E3))
{
bookHists();
art::ServiceHandle<art::TFileService> tfs;

bookHists(tfs);

_cosmicTree = tfs->make<TTree>("cosmicTree", "TTree with cosmic ray info");

_cosmicTree->Branch("x", &_x, "x/F");
_cosmicTree->Branch("y", &_y, "y/F");
_cosmicTree->Branch("z", &_z, "z/F");
_cosmicTree->Branch("px", &_px, "px/F");
_cosmicTree->Branch("py", &_py, "py/F");
_cosmicTree->Branch("pz", &_pz, "pz/F");
_cosmicTree->Branch("theta", &_theta, "theta/F");
_cosmicTree->Branch("phi", &_phi, "phi/F");
_cosmicTree->Branch("KE", &_KE, "KE/F");
_cosmicTree->Branch("p", &_p, "p/F");
_cosmicTree->Branch("t", &_t, "t/F");
_cosmicTree->Branch("pdgId", &_pdgId, "pdgId/I");
}


Expand Down Expand Up @@ -115,7 +147,34 @@ void mu2e::CRYGenPlots::analyze(art::Event const & e)

HepLorentzVector mom4 = p.momentum();
Hep3Vector mom3(mom4.px(), mom4.py(), mom4.pz());
Hep3Vector yMom3(mom4.pz(), mom4.px(), mom4.py()); // for theta, phi
Hep3Vector yMom3(mom4.pz(), mom4.px(), -mom4.py()); // for theta, phi

_hKE->Fill(mom4.e() - mass);
_hTheta->Fill(yMom3.theta());
_hPhi->Fill(yMom3.phi());

_hPmag->Fill(mom3.mag());
_hTime->Fill(p.time());
_hPyOverPmag->Fill(mom4.py() / mom3.mag());

_x = p.position().x();
_y = p.position().y();
_z = p.position().z();

_px = mom4.px();
_py = mom4.py();
_pz = mom4.pz();

_theta = yMom3.theta();
_phi = yMom3.phi();

_KE = mom4.e() - mass;
_p = mom3.mag();

_t = p.time();

_pdgId = p.pdgId();
_cosmicTree->Fill();

_hKE->Fill(mom4.e() - mass);
_hTheta->Fill(yMom3.theta());
Expand Down Expand Up @@ -178,9 +237,8 @@ void mu2e::CRYGenPlots::endJob()
// Implementation of optional member function here.
}

void mu2e::CRYGenPlots::bookHists()
void mu2e::CRYGenPlots::bookHists(art::ServiceHandle<art::TFileService> &tfs)
{
art::ServiceHandle<art::TFileService> tfs;

_hXZ = tfs->make<TH2F>("XZ", "XZ", 500, -2.0e5, 2.0e5, 500, -2.0e5, 2.0e5 );
_hY = tfs->make<TH1F>("Y", "Y", 500, -15.0e3, 21.0e3 );
Expand Down
Loading