- Timestamp:
- Feb 12, 2019, 9:29:17 PM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, llp, master
- Children:
- 6455202
- Parents:
- 45e58be
- Location:
- readers
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
readers/DelphesCMSFWLite.cpp
r45e58be r341014c 18 18 19 19 #include <algorithm> 20 #include <iostream> 21 #include <memory> 22 #include <sstream> 20 23 #include <stdexcept> 21 #include <iostream>22 #include <sstream>23 #include <memory>24 24 25 25 #include <map> 26 26 #include <vector> 27 27 28 #include <stdlib.h>29 28 #include <signal.h> 30 29 #include <stdio.h> 31 30 #include <stdlib.h> 31 32 #include "TApplication.h" 32 33 #include "TROOT.h" 33 #include "TApplication.h" 34 34 35 #include "TDatabasePDG.h" 35 36 #include "TFile.h" 37 #include "TLorentzVector.h" 36 38 #include "TObjArray.h" 39 #include "TParticlePDG.h" 37 40 #include "TStopwatch.h" 38 #include "TDatabasePDG.h" 39 #include "TParticlePDG.h" 40 #include "TLorentzVector.h" 41 42 #include "modules/Delphes.h" 43 #include "classes/DelphesStream.h" 41 44 42 #include "classes/DelphesClasses.h" 45 43 #include "classes/DelphesFactory.h" 46 44 #include "classes/DelphesStream.h" 45 #include "modules/Delphes.h" 46 47 #include "ExRootAnalysis/ExRootProgressBar.h" 48 #include "ExRootAnalysis/ExRootTreeBranch.h" 47 49 #include "ExRootAnalysis/ExRootTreeWriter.h" 48 #include "ExRootAnalysis/ExRootTreeBranch.h" 49 #include "ExRootAnalysis/ExRootProgressBar.h" 50 51 #include "FWCore/FWLite/interface/FWLiteEnabler.h" 50 52 51 #include "DataFormats/FWLite/interface/Event.h" 53 52 #include "DataFormats/FWLite/interface/Handle.h" 54 53 #include "DataFormats/HepMCCandidate/interface/GenParticle.h" 55 54 #include "DataFormats/PatCandidates/interface/PackedGenParticle.h" 55 #include "FWCore/FWLite/interface/FWLiteEnabler.h" 56 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" 56 57 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" 57 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"58 58 #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" 59 59 #include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h" … … 69 69 { 70 70 71 fwlite::Handle< GenEventInfoProduct> handleGenEventInfo;72 fwlite::Handle< LHEEventProduct> handleLHEEvent;73 fwlite::Handle< vector< reco::GenParticle >> handleParticle;74 fwlite::Handle< vector< pat::PackedGenParticle >> handlePackedParticle;75 76 vector< reco::GenParticle>::const_iterator itParticle;77 vector< pat::PackedGenParticle>::const_iterator itPackedParticle;78 79 vector< const reco::Candidate *> vectorCandidate;80 vector< const reco::Candidate *>::iterator itCandidate;71 fwlite::Handle<GenEventInfoProduct> handleGenEventInfo; 72 fwlite::Handle<LHEEventProduct> handleLHEEvent; 73 fwlite::Handle<vector<reco::GenParticle>> handleParticle; 74 fwlite::Handle<vector<pat::PackedGenParticle>> handlePackedParticle; 75 76 vector<reco::GenParticle>::const_iterator itParticle; 77 vector<pat::PackedGenParticle>::const_iterator itPackedParticle; 78 79 vector<const reco::Candidate *> vectorCandidate; 80 vector<const reco::Candidate *>::iterator itCandidate; 81 81 82 82 handleGenEventInfo.getByLabel(event, "generator"); … … 99 99 handleParticle.getByLabel(event, "genParticles"); 100 100 } 101 else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))101 else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty())) 102 102 { 103 103 handleParticle.getByLabel(event, "prunedGenParticles"); … … 106 106 else 107 107 { 108 std::cout <<"Wrong GenParticle Label! Please, check the input file."<<std::endl;108 std::cout << "Wrong GenParticle Label! Please, check the input file." << std::endl; 109 109 exit(-1); 110 110 } 111 111 112 112 Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty()); 113 Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) 113 Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()); 114 114 115 115 HepMCEvent *element; … … 148 148 if(foundLHE) 149 149 { 150 const vector< gen::WeightsInfo> &vectorWeightsInfo = handleLHEEvent->weights();151 vector< gen::WeightsInfo>::const_iterator itWeightsInfo;150 const vector<gen::WeightsInfo> &vectorWeightsInfo = handleLHEEvent->weights(); 151 vector<gen::WeightsInfo>::const_iterator itWeightsInfo; 152 152 153 153 for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo) … … 173 173 status = particle.status(); 174 174 if(isMiniAOD && particle.status() == 1) continue; 175 px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass(); 176 x = particle.vx(); y = particle.vy(); z = particle.vz(); 175 px = particle.px(); 176 py = particle.py(); 177 pz = particle.pz(); 178 e = particle.energy(); 179 mass = particle.mass(); 180 x = particle.vx(); 181 y = particle.vy(); 182 z = particle.vz(); 177 183 178 184 candidate = factory->NewCandidate(); … … 196 202 197 203 pdgParticle = pdg->GetParticle(pid); 198 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() /3.0) : -999;204 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 199 205 candidate->Mass = mass; 200 206 201 207 candidate->Momentum.SetPxPyPzE(px, py, pz, e); 202 208 203 candidate->Position.SetXYZT(x *10.0, y*10.0, z*10.0, 0.0);209 candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0); 204 210 205 211 allParticleOutputArray->Add(candidate); … … 232 238 pid = particle.pdgId(); 233 239 status = particle.status(); 234 px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass(); 235 x = particle.vx(); y = particle.vy(); z = particle.vz(); 240 px = particle.px(); 241 py = particle.py(); 242 pz = particle.pz(); 243 e = particle.energy(); 244 mass = particle.mass(); 245 x = particle.vx(); 246 y = particle.vy(); 247 z = particle.vz(); 236 248 237 249 candidate = factory->NewCandidate(); … … 255 267 256 268 pdgParticle = pdg->GetParticle(pid); 257 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() /3.0) : -999;269 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 258 270 candidate->Mass = mass; 259 271 260 272 candidate->Momentum.SetPxPyPzE(px, py, pz, e); 261 273 262 candidate->Position.SetXYZT(x *10.0, y*10.0, z*10.0, 0.0);274 candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0); 263 275 264 276 allParticleOutputArray->Add(candidate); … … 303 315 if(argc < 4) 304 316 { 305 cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl; 317 cout << " Usage: " << appName << " config_file" 318 << " output_file" 319 << " input_file(s)" << endl; 306 320 cout << " config_file - configuration file in Tcl format," << endl; 307 321 cout << " output_file - output file in ROOT format," << endl; -
readers/DelphesHepMC.cpp
r45e58be r341014c 17 17 */ 18 18 19 #include <stdexcept>20 19 #include <iostream> 21 20 #include <sstream> 21 #include <stdexcept> 22 22 23 23 #include <signal.h> 24 24 25 #include "TApplication.h" 25 26 #include "TROOT.h" 26 #include "TApplication.h" 27 27 28 #include "TDatabasePDG.h" 28 29 #include "TFile.h" 30 #include "TLorentzVector.h" 29 31 #include "TObjArray.h" 32 #include "TParticlePDG.h" 30 33 #include "TStopwatch.h" 31 #include "TDatabasePDG.h" 32 #include "TParticlePDG.h" 33 #include "TLorentzVector.h" 34 35 #include "modules/Delphes.h" 34 36 35 #include "classes/DelphesClasses.h" 37 36 #include "classes/DelphesFactory.h" 38 37 #include "classes/DelphesHepMCReader.h" 39 38 #include "modules/Delphes.h" 39 40 #include "ExRootAnalysis/ExRootProgressBar.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h" 40 42 #include "ExRootAnalysis/ExRootTreeWriter.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h"42 #include "ExRootAnalysis/ExRootProgressBar.h"43 43 44 44 using namespace std; … … 74 74 if(argc < 3) 75 75 { 76 cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl; 76 cout << " Usage: " << appName << " config_file" 77 << " output_file" 78 << " [input_file(s)]" << endl; 77 79 cout << " config_file - configuration file in Tcl format," << endl; 78 80 cout << " output_file - output file in ROOT format," << endl; … … 178 180 reader->Clear(); 179 181 readStopWatch.Start(); 180 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && 181 reader->ReadBlock(factory, allParticleOutputArray, 182 stableParticleOutputArray, partonOutputArray) && !interrupted) 182 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted) 183 183 { 184 184 if(reader->EventReady()) … … 217 217 218 218 ++i; 219 } 220 while(i < argc); 219 } while(i < argc); 221 220 222 221 modularDelphes->FinishTask(); -
readers/DelphesLHEF.cpp
r45e58be r341014c 17 17 */ 18 18 19 #include <stdexcept>20 19 #include <iostream> 21 20 #include <sstream> 21 #include <stdexcept> 22 22 23 23 #include <signal.h> 24 24 25 #include "TApplication.h" 25 26 #include "TROOT.h" 26 #include "TApplication.h" 27 27 28 #include "TDatabasePDG.h" 28 29 #include "TFile.h" 30 #include "TLorentzVector.h" 29 31 #include "TObjArray.h" 32 #include "TParticlePDG.h" 30 33 #include "TStopwatch.h" 31 #include "TDatabasePDG.h" 32 #include "TParticlePDG.h" 33 #include "TLorentzVector.h" 34 35 #include "modules/Delphes.h" 34 36 35 #include "classes/DelphesClasses.h" 37 36 #include "classes/DelphesFactory.h" 38 37 #include "classes/DelphesLHEFReader.h" 39 38 #include "modules/Delphes.h" 39 40 #include "ExRootAnalysis/ExRootProgressBar.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h" 40 42 #include "ExRootAnalysis/ExRootTreeWriter.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h"42 #include "ExRootAnalysis/ExRootProgressBar.h"43 43 44 44 using namespace std; … … 74 74 if(argc < 3) 75 75 { 76 cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl; 76 cout << " Usage: " << appName << " config_file" 77 << " output_file" 78 << " [input_file(s)]" << endl; 77 79 cout << " config_file - configuration file in Tcl format," << endl; 78 80 cout << " output_file - output file in ROOT format," << endl; … … 178 180 reader->Clear(); 179 181 readStopWatch.Start(); 180 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && 181 reader->ReadBlock(factory, allParticleOutputArray, 182 stableParticleOutputArray, partonOutputArray) && !interrupted) 182 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted) 183 183 { 184 184 if(reader->EventReady()) … … 218 218 219 219 ++i; 220 } 221 while(i < argc); 220 } while(i < argc); 222 221 223 222 modularDelphes->FinishTask(); -
readers/DelphesProIO.cpp
r45e58be r341014c 18 18 */ 19 19 20 #include <iostream> 21 #include <memory> 22 #include <sstream> 20 23 #include <stdexcept> 21 #include <iostream>22 #include <sstream>23 #include <memory>24 24 25 25 #include <map> 26 26 27 #include <stdlib.h>28 27 #include <signal.h> 29 28 #include <stdio.h> 30 29 #include <stdlib.h> 30 31 #include "TApplication.h" 31 32 #include "TROOT.h" 32 #include "TApplication.h" 33 33 34 #include "TDatabasePDG.h" 34 35 #include "TFile.h" 36 #include "TLorentzVector.h" 35 37 #include "TObjArray.h" 38 #include "TParticlePDG.h" 36 39 #include "TStopwatch.h" 37 #include "TDatabasePDG.h" 38 #include "TParticlePDG.h" 39 #include "TLorentzVector.h" 40 41 #include "modules/Delphes.h" 42 #include "classes/DelphesStream.h" 40 43 41 #include "classes/DelphesClasses.h" 44 42 #include "classes/DelphesFactory.h" 45 43 #include "classes/DelphesStream.h" 44 #include "modules/Delphes.h" 45 46 #include "ExRootAnalysis/ExRootProgressBar.h" 47 #include "ExRootAnalysis/ExRootTreeBranch.h" 46 48 #include "ExRootAnalysis/ExRootTreeWriter.h" 47 #include "ExRootAnalysis/ExRootTreeBranch.h" 48 #include "ExRootAnalysis/ExRootProgressBar.h" 49 50 #include <proio/reader.h> 49 51 50 #include <proio/event.h> 52 51 #include <proio/model/mc.pb.h> 53 namespace model=proio::model::mc; 54 52 #include <proio/reader.h> 53 namespace model = proio::model::mc; 55 54 56 55 using namespace std; … … 59 58 // This method dynamically checks the message type (varint or not) depending on 60 59 // non-zero value of units momentumUnit and positionUnit. 61 void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit, 60 void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit, 62 61 ExRootTreeBranch *branch, DelphesFactory *factory, 63 62 TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, … … 80 79 element = static_cast<HepMCEvent *>(branch->NewEntry()); 81 80 82 int nID=0; 83 double weight=0; 84 int process_id=0; 85 auto mcentries = event->TaggedEntries("MCParameters"); 86 for (uint64_t mcentryID : mcentries) { 87 auto mcpar = dynamic_cast<proio::model::mc::MCParameters *>(event->GetEntry(mcentryID)); 88 nID=mcpar->number(); 89 weight=mcpar->weight(); 90 process_id=mcpar->processid(); 91 break; // consider only most generic from 1st entry 92 }; 81 int nID = 0; 82 double weight = 0; 83 int process_id = 0; 84 auto mcentries = event->TaggedEntries("MCParameters"); 85 for(uint64_t mcentryID : mcentries) 86 { 87 auto mcpar = dynamic_cast<proio::model::mc::MCParameters *>(event->GetEntry(mcentryID)); 88 nID = mcpar->number(); 89 weight = mcpar->weight(); 90 process_id = mcpar->processid(); 91 break; // consider only most generic from 1st entry 92 }; 93 93 94 94 element->Number = nID; 95 element->ProcessID = process_id;95 element->ProcessID = process_id; 96 96 element->Weight = weight; 97 97 98 /*98 /* 99 99 // Pythia8 specific 100 100 element->MPI = mutableEvent->mpi(); … … 114 114 element->ProcTime = procStopWatch->RealTime(); 115 115 116 117 118 if ( momentumUnit >0 && positionUnit>0) { 119 120 121 auto entries = event->TaggedEntries("VarintPackedParticles"); 122 123 for (uint64_t entryID : entries) { 124 125 auto mutableParticles = dynamic_cast<model::VarintPackedParticles *>(event->GetEntry(entryID)); 126 127 for(int i = 0; i < mutableParticles->pdg_size(); ++i) 128 { 129 pid = mutableParticles->pdg(i); 130 status = mutableParticles->status(i); 131 px = mutableParticles->px(i)/momentumUnit; 132 py = mutableParticles->py(i)/momentumUnit; 133 pz = mutableParticles->pz(i)/momentumUnit; 134 mass = mutableParticles->mass(i)/momentumUnit; 135 x = mutableParticles->x(i)/positionUnit; 136 y = mutableParticles->y(i)/positionUnit; 137 z = mutableParticles->z(i)/positionUnit; 138 t = mutableParticles->t(i)/positionUnit; 139 140 candidate = factory->NewCandidate(); 141 candidate->PID = pid; 142 pdgCode = TMath::Abs(candidate->PID); 143 candidate->Status = status; 144 candidate->M1 = mutableParticles->parent1(i); 145 candidate->M2 = mutableParticles->parent2(i); 146 candidate->D1 = mutableParticles->child1(i); 147 candidate->D2 = mutableParticles->child2(i); 148 pdgParticle = pdg->GetParticle(pid); 149 candidate->Charge = mutableParticles->charge(i)/3.0; 150 //candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999; 151 candidate->Mass = mass; 152 candidate->Momentum.SetXYZM(px, py, pz, mass); 153 candidate->Position.SetXYZT(x, y, z, t); 154 allParticleOutputArray->Add(candidate); 155 if(!pdgParticle) continue; 156 157 if(status == 1) 116 if(momentumUnit > 0 && positionUnit > 0) 117 { 118 119 auto entries = event->TaggedEntries("VarintPackedParticles"); 120 121 for(uint64_t entryID : entries) 158 122 { 159 stableParticleOutputArray->Add(candidate); 160 } 161 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) 162 { 163 partonOutputArray->Add(candidate); 123 124 auto mutableParticles = dynamic_cast<model::VarintPackedParticles *>(event->GetEntry(entryID)); 125 126 for(int i = 0; i < mutableParticles->pdg_size(); ++i) 127 { 128 pid = mutableParticles->pdg(i); 129 status = mutableParticles->status(i); 130 px = mutableParticles->px(i) / momentumUnit; 131 py = mutableParticles->py(i) / momentumUnit; 132 pz = mutableParticles->pz(i) / momentumUnit; 133 mass = mutableParticles->mass(i) / momentumUnit; 134 x = mutableParticles->x(i) / positionUnit; 135 y = mutableParticles->y(i) / positionUnit; 136 z = mutableParticles->z(i) / positionUnit; 137 t = mutableParticles->t(i) / positionUnit; 138 139 candidate = factory->NewCandidate(); 140 candidate->PID = pid; 141 pdgCode = TMath::Abs(candidate->PID); 142 candidate->Status = status; 143 candidate->M1 = mutableParticles->parent1(i); 144 candidate->M2 = mutableParticles->parent2(i); 145 candidate->D1 = mutableParticles->child1(i); 146 candidate->D2 = mutableParticles->child2(i); 147 pdgParticle = pdg->GetParticle(pid); 148 candidate->Charge = mutableParticles->charge(i) / 3.0; 149 //candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999; 150 candidate->Mass = mass; 151 candidate->Momentum.SetXYZM(px, py, pz, mass); 152 candidate->Position.SetXYZT(x, y, z, t); 153 allParticleOutputArray->Add(candidate); 154 if(!pdgParticle) continue; 155 156 if(status == 1) 157 { 158 stableParticleOutputArray->Add(candidate); 159 } 160 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) 161 { 162 partonOutputArray->Add(candidate); 163 } 164 } 164 165 } 165 166 } 166 167 } 168 169 } else { 170 171 172 auto entries = event->TaggedEntries("Particle"); 173 174 for (uint64_t entryID : entries) { 175 auto part = dynamic_cast<model::Particle *>(event->GetEntry(entryID)); 176 pid = part->pdg(); 177 status = part->status(); 178 model::XYZF pvector=part->p(); 179 px=pvector.x(); 180 py=pvector.y(); 181 pz=pvector.z(); 182 mass = part->mass(); 183 auto v =part->vertex(); 184 x=v.x(); 185 y=v.y(); 186 z=v.z(); 187 t=v.t(); 188 189 candidate = factory->NewCandidate(); 190 candidate->PID = pid; 191 pdgCode = TMath::Abs(candidate->PID); 192 candidate->Status = status; 193 194 int M1=0; 195 int M2=0; 196 for (int k1=0; k1<part->parent_size(); k1++){ 197 if (k1==0) { 198 auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(0))); 199 M1=mother->barcode(); 200 } 201 if (k1==1) { 202 auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(1))); 203 M2=mother->barcode(); 204 } 167 else 168 { 169 170 auto entries = event->TaggedEntries("Particle"); 171 172 for(uint64_t entryID : entries) 173 { 174 auto part = dynamic_cast<model::Particle *>(event->GetEntry(entryID)); 175 pid = part->pdg(); 176 status = part->status(); 177 model::XYZF pvector = part->p(); 178 px = pvector.x(); 179 py = pvector.y(); 180 pz = pvector.z(); 181 mass = part->mass(); 182 auto v = part->vertex(); 183 x = v.x(); 184 y = v.y(); 185 z = v.z(); 186 t = v.t(); 187 188 candidate = factory->NewCandidate(); 189 candidate->PID = pid; 190 pdgCode = TMath::Abs(candidate->PID); 191 candidate->Status = status; 192 193 int M1 = 0; 194 int M2 = 0; 195 for(int k1 = 0; k1 < part->parent_size(); k1++) 196 { 197 if(k1 == 0) 198 { 199 auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(0))); 200 M1 = mother->barcode(); 201 } 202 if(k1 == 1) 203 { 204 auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(1))); 205 M2 = mother->barcode(); 206 } 207 } 208 209 int D1 = 0; 210 int D2 = 0; 211 for(int k1 = 0; k1 < part->child_size(); k1++) 212 { 213 if(k1 == 0) 214 { 215 auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(0))); 216 D1 = child->barcode(); 217 } 218 219 if(k1 == 1) 220 { 221 auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(1))); 222 D2 = child->barcode(); 223 }; 224 } 225 226 candidate->M1 = M1; 227 candidate->M2 = M2; 228 candidate->D1 = D1; 229 candidate->D2 = D2; 230 231 pdgParticle = pdg->GetParticle(pid); 232 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 233 candidate->Mass = mass; 234 235 candidate->Momentum.SetXYZM(px, py, pz, mass); 236 237 candidate->Position.SetXYZT(x, y, z, t); 238 239 allParticleOutputArray->Add(candidate); 240 241 if(!pdgParticle) continue; 242 243 if(status == 1) 244 { 245 stableParticleOutputArray->Add(candidate); 246 } 247 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) 248 { 249 partonOutputArray->Add(candidate); 250 } 205 251 } 206 252 207 208 int D1=0; 209 int D2=0; 210 for (int k1=0; k1<part->child_size(); k1++){ 211 if (k1==0) { 212 auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(0))); 213 D1=child->barcode(); 214 } 215 216 if (k1==1) { 217 auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(1))); 218 D2=child->barcode(); 219 }; 220 } 221 222 223 candidate->M1 = M1; 224 candidate->M2 = M2; 225 candidate->D1 = D1; 226 candidate->D2 = D2; 227 228 pdgParticle = pdg->GetParticle(pid); 229 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999; 230 candidate->Mass = mass; 231 232 candidate->Momentum.SetXYZM(px, py, pz, mass); 233 234 candidate->Position.SetXYZT(x, y, z, t); 235 236 allParticleOutputArray->Add(candidate); 237 238 if(!pdgParticle) continue; 239 240 if(status == 1) 241 { 242 stableParticleOutputArray->Add(candidate); 243 } 244 else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15) 245 { 246 partonOutputArray->Add(candidate); 247 } 248 249 } 250 251 252 } // end particle type 253 253 } // end particle type 254 254 } 255 255 … … 283 283 if(argc < 4) 284 284 { 285 cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl; 285 cout << " Usage: " << appName << " config_file" 286 << " output_file" 287 << " input_file(s)" << endl; 286 288 cout << " config_file - configuration file in Tcl format," << endl; 287 289 cout << " output_file - output file in ROOT format," << endl; … … 330 332 cout << "** INFO: Reading " << argv[i] << endl; 331 333 332 inputFile =new proio::Reader( argv[i]);334 inputFile = new proio::Reader(argv[i]); 333 335 334 336 if(inputFile == NULL) … … 338 340 } 339 341 340 341 /* 342 /* 342 343 // this is slow method, but general 343 344 inputFile->SeekToStart(); … … 350 351 */ 351 352 352 353 auto event = new proio::Event(); 354 355 356 double varint_energy=0; 357 double varint_length=0; 358 359 360 auto max_n_events = std::numeric_limits<uint64_t>::max(); 361 auto nn = inputFile->Skip(max_n_events); 362 cout << "** INFO: " << nn-1 << " events found in ProIO file" << endl; 363 inputFile->SeekToStart(); 364 numberOfEvents = nn-1; // last event has only metadata (no particle record) 365 366 if(numberOfEvents <= 0) continue; 367 368 ExRootProgressBar progressBar(numberOfEvents - 1); 369 353 auto event = new proio::Event(); 354 355 double varint_energy = 0; 356 double varint_length = 0; 357 358 auto max_n_events = std::numeric_limits<uint64_t>::max(); 359 auto nn = inputFile->Skip(max_n_events); 360 cout << "** INFO: " << nn - 1 << " events found in ProIO file" << endl; 361 inputFile->SeekToStart(); 362 numberOfEvents = nn - 1; // last event has only metadata (no particle record) 363 364 if(numberOfEvents <= 0) continue; 365 366 ExRootProgressBar progressBar(numberOfEvents - 1); 370 367 371 368 // Loop over all objects … … 376 373 for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter) 377 374 { 378 inputFile->Next(event); 375 inputFile->Next(event); 379 376 if(event == 0) continue; 380 377 381 // get metadata 382 if (eventCounter == 0) { 383 auto metadata = event->Metadata(); 384 std::cout << "** INFO: ProIO file metadata:" << std::endl; 385 for (auto element : metadata) { 386 string key=(string)element.first; 387 string value=(string)(*element.second); 388 std::cout << "** INFO: " << key << " = " << value << std::endl; 389 if (key=="info:varint_energy") varint_energy=std::stod(value); 390 if (key=="info:varint_length") varint_length=std::stod(value); 391 } 392 } 393 378 // get metadata 379 if(eventCounter == 0) 380 { 381 auto metadata = event->Metadata(); 382 std::cout << "** INFO: ProIO file metadata:" << std::endl; 383 for(auto element : metadata) 384 { 385 string key = (string)element.first; 386 string value = (string)(*element.second); 387 std::cout << "** INFO: " << key << " = " << value << std::endl; 388 if(key == "info:varint_energy") varint_energy = std::stod(value); 389 if(key == "info:varint_length") varint_length = std::stod(value); 390 } 391 } 394 392 395 393 readStopWatch.Stop(); … … 397 395 procStopWatch.Start(); 398 396 399 ConvertInput(event, varint_energy, varint_length, 397 ConvertInput(event, varint_energy, varint_length, 400 398 branchEvent, factory, 401 399 allParticleOutputArray, stableParticleOutputArray, 402 400 partonOutputArray, &readStopWatch, &procStopWatch); 403 401 404 402 modularDelphes->ProcessTask(); 405 403 procStopWatch.Stop(); … … 414 412 } 415 413 416 417 414 progressBar.Update(eventCounter, eventCounter, kTRUE); 418 415 progressBar.Finish(); … … 420 417 delete inputFile; 421 418 } 422 423 419 424 420 modularDelphes->FinishTask(); -
readers/DelphesProMC.cpp
r45e58be r341014c 17 17 */ 18 18 19 #include <iostream> 20 #include <memory> 21 #include <sstream> 19 22 #include <stdexcept> 20 #include <iostream>21 #include <sstream>22 #include <memory>23 23 24 24 #include <map> 25 25 26 #include <stdlib.h>27 26 #include <signal.h> 28 27 #include <stdio.h> 29 28 #include <stdlib.h> 29 30 #include "TApplication.h" 30 31 #include "TROOT.h" 31 #include "TApplication.h" 32 32 33 #include "TDatabasePDG.h" 33 34 #include "TFile.h" 35 #include "TLorentzVector.h" 34 36 #include "TObjArray.h" 37 #include "TParticlePDG.h" 35 38 #include "TStopwatch.h" 36 #include "TDatabasePDG.h" 37 #include "TParticlePDG.h" 38 #include "TLorentzVector.h" 39 40 #include "modules/Delphes.h" 41 #include "classes/DelphesStream.h" 39 42 40 #include "classes/DelphesClasses.h" 43 41 #include "classes/DelphesFactory.h" 44 42 #include "classes/DelphesStream.h" 43 #include "modules/Delphes.h" 44 45 #include "ExRootAnalysis/ExRootProgressBar.h" 46 #include "ExRootAnalysis/ExRootTreeBranch.h" 45 47 #include "ExRootAnalysis/ExRootTreeWriter.h" 46 #include "ExRootAnalysis/ExRootTreeBranch.h"47 #include "ExRootAnalysis/ExRootProgressBar.h"48 48 49 49 #include "ProMC.pb.h" … … 109 109 status = mutableParticles->status(i); 110 110 111 px = mutableParticles->px(i) /momentumUnit;112 py = mutableParticles->py(i) /momentumUnit;113 pz = mutableParticles->pz(i) /momentumUnit;114 mass = mutableParticles->mass(i) /momentumUnit;115 x = mutableParticles->x(i) /positionUnit;116 y = mutableParticles->y(i) /positionUnit;117 z = mutableParticles->z(i) /positionUnit;118 t = mutableParticles->t(i) /positionUnit;111 px = mutableParticles->px(i) / momentumUnit; 112 py = mutableParticles->py(i) / momentumUnit; 113 pz = mutableParticles->pz(i) / momentumUnit; 114 mass = mutableParticles->mass(i) / momentumUnit; 115 x = mutableParticles->x(i) / positionUnit; 116 y = mutableParticles->y(i) / positionUnit; 117 z = mutableParticles->z(i) / positionUnit; 118 t = mutableParticles->t(i) / positionUnit; 119 119 120 120 candidate = factory->NewCandidate(); … … 125 125 candidate->Status = status; 126 126 127 candidate->IsPU =0;128 if (mutableParticles->barcode(i)>0) candidate->IsPU=1; // pileup particle127 candidate->IsPU = 0; 128 if(mutableParticles->barcode(i) > 0) candidate->IsPU = 1; // pileup particle 129 129 130 130 candidate->M1 = mutableParticles->mother1(i); … … 135 135 136 136 pdgParticle = pdg->GetParticle(pid); 137 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() /3.0) : -999;137 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 138 138 candidate->Mass = mass; 139 139 … … 187 187 if(argc < 4) 188 188 { 189 cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl; 189 cout << " Usage: " << appName << " config_file" 190 << " output_file" 191 << " input_file(s)" << endl; 190 192 cout << " config_file - configuration file in Tcl format," << endl; 191 193 cout << " output_file - output file in ROOT format," << endl; … … 234 236 cout << "** Reading " << argv[i] << endl; 235 237 236 // use 64 bit 238 // use 64 bit 237 239 //inputFile = new ProMCBook(argv[i], "r", true); 238 240 … … 244 246 momentumUnit = static_cast<double>(header.momentumunit()); 245 247 positionUnit = static_cast<double>(header.lengthunit()); 246 247 248 248 249 249 if(inputFile == NULL) -
readers/DelphesPythia8.cpp
r45e58be r341014c 17 17 */ 18 18 19 #include <stdexcept>20 19 #include <iostream> 21 20 #include <sstream> 21 #include <stdexcept> 22 22 #include <string> 23 23 … … 27 27 #include "Pythia8Plugins/CombineMatchingInput.h" 28 28 29 #include "TApplication.h" 29 30 #include "TROOT.h" 30 #include "TApplication.h" 31 31 32 #include "TDatabasePDG.h" 32 33 #include "TFile.h" 34 #include "TLorentzVector.h" 33 35 #include "TObjArray.h" 36 #include "TParticlePDG.h" 34 37 #include "TStopwatch.h" 35 #include "TDatabasePDG.h" 36 #include "TParticlePDG.h" 37 #include "TLorentzVector.h" 38 39 #include "modules/Delphes.h" 38 40 39 #include "classes/DelphesClasses.h" 41 40 #include "classes/DelphesFactory.h" 42 41 #include "classes/DelphesLHEFReader.h" 43 42 #include "modules/Delphes.h" 43 44 #include "ExRootAnalysis/ExRootProgressBar.h" 45 #include "ExRootAnalysis/ExRootTreeBranch.h" 44 46 #include "ExRootAnalysis/ExRootTreeWriter.h" 45 #include "ExRootAnalysis/ExRootTreeBranch.h"46 #include "ExRootAnalysis/ExRootProgressBar.h"47 47 48 48 using namespace std; … … 98 98 pid = particle.id(); 99 99 status = particle.statusHepMC(); 100 px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e(); mass = particle.m(); 101 x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd(); 100 px = particle.px(); 101 py = particle.py(); 102 pz = particle.pz(); 103 e = particle.e(); 104 mass = particle.m(); 105 x = particle.xProd(); 106 y = particle.yProd(); 107 z = particle.zProd(); 108 t = particle.tProd(); 102 109 103 110 candidate = factory->NewCandidate(); … … 115 122 116 123 pdgParticle = pdg->GetParticle(pid); 117 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() /3.0) : -999;124 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 118 125 candidate->Mass = mass; 119 126 … … 166 173 167 174 // pMin = 0.1 GeV for single particles 168 pp = pow(10, - 175 pp = pow(10, -1.0 + (log10(pMax) + 1.0) * rndm.flat()); 169 176 eta = (2.0 * rndm.flat() - 1.0) * etaMax; 170 177 phi = 2.0 * M_PI * rndm.flat(); 171 178 mm = pdt.mSel(id); 172 ee = Pythia8::sqrtpos(pp *pp + mm*mm);179 ee = Pythia8::sqrtpos(pp * pp + mm * mm); 173 180 pt = pp / cosh(eta); 174 181 … … 193 200 phi = 2.0 * M_PI * rndm.flat(); 194 201 mm = pdt.mSel(id); 195 ee = Pythia8::sqrtpos(pp *pp + mm*mm);202 ee = Pythia8::sqrtpos(pp * pp + mm * mm); 196 203 pt = pp / cosh(eta); 197 204 198 if( 205 if((id == 4 || id == 5) && pt < 10.0) return; 199 206 200 207 if(id == 21) … … 238 245 // for matching 239 246 Pythia8::CombineMatchingInput *combined = 0; 240 Pythia8::UserHooks *matching = 0;247 Pythia8::UserHooks *matching = 0; 241 248 242 249 if(argc != 4) 243 250 { 244 cout << " Usage: " << appName << " config_file" << " pythia_card" << " output_file" << endl; 251 cout << " Usage: " << appName << " config_file" 252 << " pythia_card" 253 << " output_file" << endl; 245 254 cout << " config_file - configuration file in Tcl format," << endl; 246 255 cout << " pythia_card - Pythia8 configuration file," << endl; … … 293 302 } 294 303 pythia->setUserHooksPtr(matching); 295 296 304 297 305 if(pythia == NULL) … … 348 356 for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter) 349 357 { 350 while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, 351 stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady());358 while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady()) 359 ; 352 360 353 361 if(spareFlag1) -
readers/DelphesROOT.cpp
r45e58be r341014c 18 18 19 19 #include <algorithm> 20 #include <iostream> 21 #include <memory> 22 #include <sstream> 20 23 #include <stdexcept> 21 #include <iostream>22 #include <sstream>23 #include <memory>24 24 25 25 #include <map> 26 26 #include <vector> 27 27 28 #include <stdlib.h>29 28 #include <signal.h> 30 29 #include <stdio.h> 31 30 #include <stdlib.h> 31 32 #include "TApplication.h" 32 33 #include "TROOT.h" 33 #include "TApplication.h" 34 34 35 #include "TClonesArray.h" 36 #include "TDatabasePDG.h" 35 37 #include "TFile.h" 36 #include "T ClonesArray.h"38 #include "TLorentzVector.h" 37 39 #include "TObjArray.h" 40 #include "TParticlePDG.h" 38 41 #include "TStopwatch.h" 39 #include "TDatabasePDG.h" 40 #include "TParticlePDG.h" 41 #include "TLorentzVector.h" 42 43 #include "modules/Delphes.h" 44 #include "classes/DelphesStream.h" 42 45 43 #include "classes/DelphesClasses.h" 46 44 #include "classes/DelphesFactory.h" 47 45 #include "classes/DelphesStream.h" 46 #include "modules/Delphes.h" 47 48 #include "ExRootAnalysis/ExRootProgressBar.h" 49 #include "ExRootAnalysis/ExRootTreeBranch.h" 50 #include "ExRootAnalysis/ExRootTreeReader.h" 48 51 #include "ExRootAnalysis/ExRootTreeWriter.h" 49 #include "ExRootAnalysis/ExRootTreeReader.h"50 #include "ExRootAnalysis/ExRootTreeBranch.h"51 #include "ExRootAnalysis/ExRootProgressBar.h"52 53 54 52 55 53 using namespace std; 56 54 57 55 //--------------------------------------------------------------------------- 58 59 56 60 57 //--------------------------------------------------------------------------- … … 94 91 if(argc < 4) 95 92 { 96 cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl; 93 cout << " Usage: " << appName << " config_file" 94 << " output_file" 95 << " input_file(s)" << endl; 97 96 cout << " config_file - configuration file in Tcl format," << endl; 98 97 cout << " output_file - output file in ROOT format," << endl; … … 122 121 123 122 branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class()); 124 123 125 124 confReader = new ExRootConfReader; 126 125 confReader->ReadFile(argv[1]); … … 129 128 modularDelphes->SetConfReader(confReader); 130 129 modularDelphes->SetTreeWriter(treeWriter); 131 130 132 131 TChain *chain = new TChain("Delphes"); 133 132 134 133 factory = modularDelphes->GetFactory(); 135 134 allParticleOutputArray = modularDelphes->ExportArray("allParticles"); … … 145 144 chain->Add(argv[i]); 146 145 ExRootTreeReader *treeReader = new ExRootTreeReader(chain); 147 146 148 147 inputFile = TFile::Open(argv[i]); 149 148 … … 153 152 throw runtime_error(message.str()); 154 153 } 155 154 156 155 numberOfEvents = treeReader->GetEntries(); 157 TClonesArray *branchParticle 156 TClonesArray *branchParticle = treeReader->UseBranch("Particle"); 158 157 TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event"); 159 158 160 159 if(numberOfEvents <= 0) continue; 161 160 … … 169 168 for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry) 170 169 { 171 170 172 171 treeReader->ReadEntry(entry); 173 172 174 // -- TBC need also to include event weights -- 175 176 eve = (HepMCEvent *)branchHepMCEvent->At(0);173 // -- TBC need also to include event weights -- 174 175 eve = (HepMCEvent *)branchHepMCEvent->At(0); 177 176 element = static_cast<HepMCEvent *>(branchEvent->NewEntry()); 178 177 179 178 element->Number = eventCounter; 180 179 … … 197 196 element->ProcTime = eve->ProcTime; 198 197 199 for(Int_t j =0; j < branchParticle->GetEntriesFast(); j++)200 { 201 202 gen = (GenParticle *) branchParticle->At(j);198 for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++) 199 { 200 201 gen = (GenParticle *)branchParticle->At(j); 203 202 candidate = factory->NewCandidate(); 204 203 205 204 candidate->Momentum = gen->P4(); 206 candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T *1.0E3*c_light);207 205 candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light); 206 208 207 candidate->PID = gen->PID; 209 208 candidate->Status = gen->Status; 210 209 211 210 candidate->M1 = gen->M1; 212 211 candidate->M2 = gen->M2; … … 216 215 217 216 candidate->Charge = gen->Charge; 218 candidate->Mass 219 217 candidate->Mass = gen->Mass; 218 220 219 allParticleOutputArray->Add(candidate); 221 220 222 221 pdgCode = TMath::Abs(gen->PID); 223 222 … … 231 230 } 232 231 } 233 232 234 233 modularDelphes->ProcessTask(); 235 234 … … 242 241 ++eventCounter; 243 242 } 244 243 245 244 progressBar.Update(eventCounter, eventCounter, kTRUE); 246 245 progressBar.Finish(); 247 246 248 247 inputFile->Close(); 249 248 250 249 delete treeReader; 251 252 250 } 253 251 … … 262 260 delete outputFile; 263 261 delete chain; 264 262 265 263 return 0; 266 264 } -
readers/DelphesSTDHEP.cpp
r45e58be r341014c 17 17 */ 18 18 19 #include <stdexcept>20 19 #include <iostream> 21 20 #include <sstream> 21 #include <stdexcept> 22 22 23 23 #include <signal.h> 24 24 25 #include "TApplication.h" 25 26 #include "TROOT.h" 26 #include "TApplication.h" 27 27 28 #include "TDatabasePDG.h" 28 29 #include "TFile.h" 30 #include "TLorentzVector.h" 29 31 #include "TObjArray.h" 32 #include "TParticlePDG.h" 30 33 #include "TStopwatch.h" 31 #include "TDatabasePDG.h" 32 #include "TParticlePDG.h" 33 #include "TLorentzVector.h" 34 35 #include "modules/Delphes.h" 34 36 35 #include "classes/DelphesClasses.h" 37 36 #include "classes/DelphesFactory.h" 38 37 #include "classes/DelphesSTDHEPReader.h" 39 38 #include "modules/Delphes.h" 39 40 #include "ExRootAnalysis/ExRootProgressBar.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h" 40 42 #include "ExRootAnalysis/ExRootTreeWriter.h" 41 #include "ExRootAnalysis/ExRootTreeBranch.h"42 #include "ExRootAnalysis/ExRootProgressBar.h"43 43 44 44 using namespace std; … … 74 74 if(argc < 3) 75 75 { 76 cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl; 76 cout << " Usage: " << appName << " config_file" 77 << " output_file" 78 << " [input_file(s)]" << endl; 77 79 cout << " config_file - configuration file in Tcl format," << endl; 78 80 cout << " output_file - output file in ROOT format," << endl; … … 177 179 reader->Clear(); 178 180 readStopWatch.Start(); 179 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && 180 reader->ReadBlock(factory, allParticleOutputArray, 181 stableParticleOutputArray, partonOutputArray) && !interrupted) 181 while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted) 182 182 { 183 183 if(reader->EventReady()) … … 215 215 216 216 ++i; 217 } 218 while(i < argc); 217 } while(i < argc); 219 218 220 219 modularDelphes->FinishTask();
Note:
See TracChangeset
for help on using the changeset viewer.