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) {
34 TFile*
f1 =
new TFile(fileName,
"RECREATE");
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,
92 TFile*
file = TFile::Open(fileName,
"READ");
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();
104 if ((maxEvents != -1) && (nentries > maxEvents))
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()));
119 std::cout <<
"ERROR: no file " << fileName
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,
134 TFile*
file = TFile::Open(fileName,
"READ");
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();
144 if ((maxEvents != -1) && (nentries > maxEvents))
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));
159 std::cout <<
"ERROR: no file " << fileName
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) {
174 TFile*
file = TFile::Open(fileName,
"READ");
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();
185 if ((maxEvents != -1) && (nentries > maxEvents))
187 for (Long64_t
i = 0;
i < nentries; ++
i) {
189 savedPair->push_back(*muonPair);
190 if (genPair !=
nullptr) {
191 genPair->push_back(*genMuonPair);
195 std::cout <<
"ERROR: no file " << fileName
196 <<
" found. Please, correct the file name or specify an empty field in the InputRootTreeFileName "
197 "parameter to read events from the edm source."
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
HitContainer const *__restrict__ TkSoA const *__restrict__ Quality const *__restrict__ CAHitNtupletGeneratorKernelsGPU::HitToTuple const *__restrict__ int32_t int iev