26 #include <CLHEP/Vector/LorentzVector.h>
36 outputFile =
new TFile(theGenInfoRootFileName.c_str(),
"RECREATE");
52 std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> muFromRes;
55 int mothersFound[] = {0, 0, 0, 0, 0, 0};
57 for( reco::GenParticleCollection::const_iterator mcIter=genParticles->begin(); mcIter!=genParticles->end(); ++mcIter ) {
58 int status = mcIter->status();
62 ( pdgId==23 || pdgId==443 || pdgId==100443 ||
63 pdgId==553 || pdgId==100553 || pdgId==200553 ) ) {
64 genRes = mcIter->p4();
66 if( pdgId == 23 )
mapHisto[
"hGenResZ"]->Fill(genRes);
67 else if( pdgId == 443 || pdgId == 100443 )
mapHisto[
"hGenResJPsi"]->Fill(genRes);
68 else if( pdgId == 553 || pdgId == 100553 || pdgId == 200553 )
mapHisto[
"hGenResUpsilon1S"]->Fill(genRes);
71 if( status==1 && pdgId==13 && !PATmuons) {
72 int momPdgId =
std::abs(mcIter->mother()->pdgId());
73 if( momPdgId==23 || momPdgId==443 || momPdgId==100443 ||
74 momPdgId==553 || momPdgId==100553 || momPdgId==200553 ) {
75 if( momPdgId == 23 ) mothersFound[0] = 1;
76 if( momPdgId == 443 || momPdgId == 100443 ) mothersFound[5] = 1;
77 if( momPdgId == 553 || momPdgId == 100553 || momPdgId == 200553 ) mothersFound[3] = 1;
78 mapHisto[
"hGenMu"]->Fill(mcIter->p4());
79 std::cout<<
"genmu "<<mcIter->p4()<<std::endl;
80 if(mcIter->charge()>0){
81 muFromRes.first = mcIter->p4();
84 else muFromRes.second = mcIter->p4();
87 if( status==1 && pdgId==13 && PATmuons) {
89 mapHisto[
"hGenMu"]->Fill(mcIter->p4());
90 std::cout<<
"genmu "<<mcIter->p4()<<std::endl;
91 if(mcIter->charge()>0){
92 muFromRes.first = mcIter->p4();
95 else muFromRes.second = mcIter->p4();
101 if( mothersFound[0] == 1 ) {
102 mapHisto[
"hGenMuMuZ"]->Fill(muFromRes.first+muFromRes.second);
103 mapHisto[
"hGenResVSMuZ"]->Fill( muFromRes.first, genRes, 1 );
104 mapHisto[
"hGenResVSMuZ"]->Fill( muFromRes.second,genRes, -1 );
106 if( mothersFound[3] == 1 ) {
107 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(muFromRes.first+muFromRes.second);
108 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( muFromRes.first, genRes, 1 );
109 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( muFromRes.second,genRes, -1 );
111 if( mothersFound[5] == 1 ) {
112 mapHisto[
"hGenMuMuJPsi"]->Fill(muFromRes.first+muFromRes.second);
113 mapHisto[
"hGenResVSMuJPsi"]->Fill( muFromRes.first, genRes, 1 );
114 mapHisto[
"hGenResVSMuJPsi"]->Fill( muFromRes.second,genRes, -1 );
117 mapHisto[
"hGenResVsSelf"]->Fill( genRes, genRes, 1 );
126 std::pair<reco::Particle::LorentzVector,reco::Particle::LorentzVector> muFromRes;
129 int mothersFound[] = {0, 0, 0, 0, 0, 0};
133 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
134 part!=Evt->particles_end();
part++) {
135 if (fabs((*part)->pdg_id())==13 && (*part)->status()==1) {
136 bool fromRes =
false;
137 for (HepMC::GenVertex::particle_iterator mother = (*part)->production_vertex()->particles_begin(HepMC::ancestors);
138 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
139 unsigned int motherPdgId = (*mother)->pdg_id();
140 if( motherPdgId == 13 && (*mother)->status() == 3 ) fromRes =
true;
143 if((*part)->pdg_id()==13){
144 muFromRes.first = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
145 (*part)->momentum().pz(),(*part)->momentum().e()));
147 else if((*part)->pdg_id()==-13){
148 muFromRes.second = (
lorentzVector((*part)->momentum().px(),(*part)->momentum().py(),
149 (*part)->momentum().pz(),(*part)->momentum().e()));
155 mapHisto[
"hGenResZ"]->Fill(muFromRes.first+muFromRes.second);
158 for (HepMC::GenEvent::particle_const_iterator
part=Evt->particles_begin();
159 part!=Evt->particles_end();
part++) {
160 int status = (*part)->status();
168 if (pdgId==13 && status==1) {
170 ( pdgId==23 || pdgId==443 || pdgId==100443 ||
171 pdgId==553 || pdgId==100553 || pdgId==200553 ) ) {
173 (*part)->momentum().pz(),(*part)->momentum().e());
175 if( pdgId == 23 )
mapHisto[
"hGenResZ"]->Fill(genRes);
176 if( pdgId == 443 )
mapHisto[
"hGenResJPsi"]->Fill(genRes);
179 mapHisto[
"hGenResUpsilon1S"]->Fill(genRes);
184 if (pdgId==13 && status==1) {
186 for (HepMC::GenVertex::particle_iterator mother =
187 (*part)->production_vertex()->particles_begin(HepMC::ancestors);
188 mother != (*part)->production_vertex()->particles_end(HepMC::ancestors); ++mother) {
189 int motherPdgId = (*mother)->pdg_id();
190 if (motherPdgId==23 || motherPdgId==443 || motherPdgId==100443 ||
191 motherPdgId==553 || motherPdgId==100553 || motherPdgId==200553) {
193 if( motherPdgId == 23 ) mothersFound[0] = 1;
194 if( motherPdgId == 443 ) mothersFound[3] = 1;
195 if( motherPdgId == 553 ) mothersFound[5] = 1;
201 (*part)->momentum().pz(),(*part)->momentum().e()));
203 (*part)->momentum().pz(),(*part)->momentum().e()));
204 if((*part)->pdg_id()==-13)
206 (*part)->momentum().pz(),(*part)->momentum().e()));
209 (*part)->momentum().pz(),(*part)->momentum().e()));
215 if( mothersFound[0] == 1 ) {
216 mapHisto[
"hGenMuMuZ"]->Fill(muFromRes.first+muFromRes.second);
217 mapHisto[
"hGenResVSMuZ"]->Fill( muFromRes.first, genRes, 1 );
218 mapHisto[
"hGenResVSMuZ"]->Fill( muFromRes.second,genRes, -1 );
220 if( mothersFound[3] == 1 ) {
221 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(muFromRes.first+muFromRes.second);
222 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( muFromRes.first, genRes, 1 );
223 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( muFromRes.second,genRes, -1 );
225 if( mothersFound[5] == 1 ) {
226 mapHisto[
"hGenMuMuJPsi"]->Fill(muFromRes.first+muFromRes.second);
227 mapHisto[
"hGenResVSMuJPsi"]->Fill( muFromRes.first, genRes, 1 );
228 mapHisto[
"hGenResVSMuJPsi"]->Fill( muFromRes.second,genRes, -1 );
230 mapHisto[
"hGenResVsSelf"]->Fill( genRes, genRes, 1 );
237 std::vector<SimTrack> simMuons;
240 for( edm::SimTrackContainer::const_iterator simTrack=simTracks->begin(); simTrack!=simTracks->end(); ++simTrack ) {
242 if (fabs((*simTrack).type())==13) {
243 simMuons.push_back(*simTrack);
244 mapHisto[
"hSimMu"]->Fill((*simTrack).momentum());
247 mapHisto[
"hSimMu"]->Fill(simMuons.size());
250 if( simMuons.size() >= 2 ) {
251 for( std::vector<SimTrack>::const_iterator imu=simMuons.begin(); imu != simMuons.end(); ++imu ) {
252 for( std::vector<SimTrack>::const_iterator imu2=imu+1; imu2!=simMuons.end(); ++imu2 ) {
253 if (imu==imu2)
continue;
256 if (((*imu).charge()*(*imu2).charge())<0) {
266 mapHisto[
"hSimBestRes"]->Fill(bestSimZ);
267 if (fabs(simMuFromBestRes.first.momentum().eta())<2.5 && fabs(simMuFromBestRes.second.momentum().eta())<2.5 &&
268 simMuFromBestRes.first.momentum().pt()>2.5 && simMuFromBestRes.second.momentum().pt()>2.5) {
269 mapHisto[
"hSimBestResVSMu"]->Fill (simMuFromBestRes.first.momentum(), bestSimZ, int(simMuFromBestRes.first.charge()));
270 mapHisto[
"hSimBestResVSMu"]->Fill (simMuFromBestRes.second.momentum(),bestSimZ, int(simMuFromBestRes.second.charge()));
279 std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> simMuFromRes =
283 mapHisto[
"hSimRightRes"]->Fill(rightSimRes);
309 for(std::vector<MuScleFitMuon>::const_iterator mu1 = muons.begin(); mu1!=muons.end(); mu1++){
310 mapHisto[
"hRecMu"]->Fill(mu1->p4());
311 mapHisto[
"hRecMuVSEta"]->Fill(mu1->p4());
312 for(std::vector<MuScleFitMuon>::const_iterator mu2 = muons.begin(); mu2!=muons.end(); mu2++){
313 if (mu1->charge()<0 || mu2->charge()>0)
319 mapHisto[
"hRecMu"]->Fill(muons.size());
326 std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >::const_iterator muonPair = savedPairs.begin();
327 for( ; muonPair != savedPairs.end(); ++muonPair ) {
328 mapHisto[
"hRecMu"]->Fill(muonPair->first);
329 mapHisto[
"hRecMuVSEta"]->Fill(muonPair->first);
330 mapHisto[
"hRecMu"]->Fill(muonPair->second);
331 mapHisto[
"hRecMuVSEta"]->Fill(muonPair->second);
334 mapHisto[
"hRecMu"]->Fill(savedPairs.size());
345 std::vector<std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> >::const_iterator genPair = genPairs.begin();
346 for( ; genPair != genPairs.end(); ++genPair ) {
349 mapHisto[
"hGenMu"]->Fill(genPair->first);
350 mapHisto[
"hGenMuVSEta"]->Fill(genPair->first);
351 mapHisto[
"hGenMuMuZ"]->Fill(genRes);
352 mapHisto[
"hGenResVSMuZ"]->Fill( genPair->first, genRes, 1 );
353 mapHisto[
"hGenResVSMuZ"]->Fill( genPair->second, genRes, -1 );
354 mapHisto[
"hGenMuMuUpsilon1S"]->Fill(genRes);
355 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( genPair->first, genRes, 1 );
356 mapHisto[
"hGenResVSMuUpsilon1S"]->Fill( genPair->second, genRes, -1 );
357 mapHisto[
"hGenMuMuJPsi"]->Fill(genRes);
358 mapHisto[
"hGenResVSMuJPsi"]->Fill( genPair->first, genRes, 1 );
359 mapHisto[
"hGenResVSMuJPsi"]->Fill( genPair->second, genRes, -1 );
360 mapHisto[
"hGenResVsSelf"]->Fill( genRes, genRes, 1 );
409 for (std::map<std::string, Histograms*>::const_iterator
histo=
mapHisto.begin();
411 (*histo).second->Write();
const double Z[kNumberCalorimeter]
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::map< std::string, Histograms * > mapHisto
static std::pair< lorentzVector, lorentzVector > findSimMuFromRes(const edm::Handle< edm::HepMCProduct > &evtMC, const edm::Handle< edm::SimTrackContainer > &simTracks)
void fillGenSim(edm::Handle< edm::HepMCProduct > evtMC, edm::Handle< edm::SimTrackContainer > simTracks)
void fillTreeRec(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &savedPairs)
Used when running on the root tree containing preselected muon pairs.
virtual ~MuScleFitPlotter()
MuScleFitPlotter(std::string)
reco::Particle::LorentzVector lorentzVector
static std::pair< SimTrack, SimTrack > findBestSimuRes(const std::vector< SimTrack > &simMuons)
void fillRec(std::vector< MuScleFitMuon > &muons)
Used when running on the root tree containing preselected muon pairs.
void fillSim(edm::Handle< edm::SimTrackContainer > simTracks)
Abs< T >::type abs(const T &t)
const HepMC::GenEvent * GetEvent() const
void fillTreeGen(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &genPairs)
void fillGen(const reco::GenParticleCollection *genParticles, bool=false)
math::XYZTLorentzVector LorentzVector
Lorentz vector.