13 typedef std::vector<std::pair<lorentzVector, lorentzVector> >
MuonPairVector;
29 const std::vector<MuonPair>* savedPair,
30 const int muonType = 0,
31 const std::vector<GenMuonPair>* genPair =
nullptr,
32 const bool saveAll =
false) {
35 TTree*
tree =
new TTree(
"T",
"Muon pairs");
39 tree->Branch(
"event",
"MuonPair", &muonPair);
40 if (genPair !=
nullptr) {
41 tree->Branch(
"genEvent",
"GenMuonPair", &genMuonPair);
44 if (savedPair->size() != genPair->size()) {
45 std::cout <<
"Error: savedPair size (" << savedPair->size() <<
") and genPair size (" << genPair->size()
46 <<
") are different. This is severe and I will not write the tree." << std::endl;
50 std::cout <<
"savedPair->size() is " << savedPair->size() << std::endl;
51 std::vector<MuonPair>::const_iterator muonPairIt = savedPair->begin();
53 for (; muonPairIt != savedPair->end(); ++muonPairIt, ++
iev) {
54 if (saveAll || ((muonPairIt->mu1.p4() != emptyLorentzVector) && (muonPairIt->mu2.p4() != emptyLorentzVector))) {
56 muonPair->
copy(*muonPairIt);
63 if (genPair !=
nullptr) {
64 genMuonPair->
copy((*genPair)[
iev]);
74 TH1F muonTypeHisto(
"MuonType",
"MuonType", 40, -20, 20);
75 muonTypeHisto.Fill(muonType);
76 muonTypeHisto.Write();
90 std::vector<std::pair<unsigned int, unsigned long long> >* evtRun,
94 TTree*
tree = (TTree*)
file->Get(
"T");
98 tree->SetBranchAddress(
"event", &muonPair);
99 if (genPair !=
nullptr) {
100 tree->SetBranchAddress(
"genEvent", &genMuonPair);
103 Long64_t nentries =
tree->GetEntries();
106 for (Long64_t
i = 0;
i < nentries; ++
i) {
109 savedPair->push_back(std::make_pair(muonPair->
mu1.
p4(), muonPair->
mu2.
p4()));
112 if (genPair !=
nullptr) {
113 genPair->push_back(std::make_pair(genMuonPair->
mu1.
p4(), genMuonPair->
mu2.
p4()));
120 <<
" found. Please, correct the file name or specify an empty field in the InputRootTreeFileName " 121 "parameter to read events from the edm source." 132 std::vector<std::pair<unsigned int, unsigned long long> >* evtRun,
135 if (
file->IsOpen()) {
136 TTree*
tree = (TTree*)
file->Get(
"T");
139 tree->SetBranchAddress(
"event", &muonPair);
140 if (genPair !=
nullptr) {
141 tree->SetBranchAddress(
"genEvent", &genMuonPair);
143 Long64_t nentries =
tree->GetEntries();
146 for (Long64_t
i = 0;
i < nentries; ++
i) {
149 savedPair->push_back(std::make_pair(muonPair->
mu1, muonPair->
mu2));
152 if (genPair !=
nullptr) {
153 genPair->push_back(std::make_pair(genMuonPair->
mu1, genMuonPair->
mu2));
160 <<
" found. Please, correct the file name or specify an empty field in the InputRootTreeFileName " 161 "parameter to read events from the edm source." 171 std::vector<MuonPair>* savedPair,
173 std::vector<GenMuonPair>* genPair =
nullptr) {
175 if (
file->IsOpen()) {
176 TTree*
tree = (TTree*)
file->Get(
"T");
179 tree->SetBranchAddress(
"event", &muonPair);
180 if (genPair !=
nullptr) {
181 tree->SetBranchAddress(
"genEvent", &genMuonPair);
184 Long64_t nentries =
tree->GetEntries();
187 for (Long64_t
i = 0;
i < nentries; ++
i) {
189 savedPair->push_back(*muonPair);
190 if (genPair !=
nullptr) {
191 genPair->push_back(*genMuonPair);
196 <<
" found. Please, correct the file name or specify an empty field in the InputRootTreeFileName " 197 "parameter to read events from the edm source."
TkSoAView< TrackerTraits > HitToTuple< TrackerTraits > const *__restrict__ int32_t int32_t int iev
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairVector *genPair=nullptr)
reco::Particle::LorentzVector lorentzVector
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=nullptr, const bool saveAll=false)
void readTree(const int maxEvents, const TString &fileName, MuonPairExtendedVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairExtendedVector *genPair=nullptr)
std::vector< std::pair< MuScleFitMuon, MuScleFitMuon > > MuonPairExtendedVector
void copy(const MuonPair ©Pair)
Used to copy the content of another MuonPair.
void copy(const GenMuonPair ©Pair)
Used to copy the content of another GenMuonPair.
void readTree(const int maxEvents, const TString &fileName, std::vector< MuonPair > *savedPair, const int muonType, std::vector< GenMuonPair > *genPair=nullptr)
Used to read the external trees.
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector