Go to the documentation of this file.00001 #ifndef RecoParticleFlow_PFRootEvent_PFRootEventManager_h
00002 #define RecoParticleFlow_PFRootEvent_PFRootEventManager_h
00003
00004 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00005
00006 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
00007
00008 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00009 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00010
00011 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00012 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00013
00014 #include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h"
00015
00016 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
00017 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00018 #include "DataFormats/TrackReco/interface/Track.h"
00019 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00020 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00021 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrack.h"
00022 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrackFwd.h"
00023
00024 #include "DataFormats/ParticleFlowReco/interface/PFSimParticle.h"
00025 #include "DataFormats/ParticleFlowReco/interface/PFSimParticleFwd.h"
00026
00027 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00028 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00029
00030 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00031 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00032
00033 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00034 #include "DataFormats/MuonReco/interface/Muon.h"
00035
00036 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00037 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00038
00039 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedTrackerVertex.h"
00040
00041 #include "DataFormats/ParticleFlowReco/interface/PFConversion.h"
00042 #include "DataFormats/ParticleFlowReco/interface/PFConversionFwd.h"
00043 #include "DataFormats/ParticleFlowReco/interface/PFV0.h"
00044 #include "DataFormats/ParticleFlowReco/interface/PFV0Fwd.h"
00045
00046 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00047 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00048 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00049 #include "CommonTools/CandUtils/interface/pdgIdUtils.h"
00050
00051
00052 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00053 #include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
00054
00055 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterAlgo.h"
00056 #include "RecoParticleFlow/PFProducer/interface/PFBlockAlgo.h"
00057 #include "RecoParticleFlow/PFProducer/interface/PFAlgo.h"
00058
00059 #include "RecoParticleFlow/PFRootEvent/interface/PFJetAlgorithm.h"
00060 #include "RecoParticleFlow/Benchmark/interface/PFJetBenchmark.h"
00061 #include "RecoParticleFlow/Benchmark/interface/PFMETBenchmark.h"
00062 #include "DQMOffline/PFTau/interface/PFCandidateManager.h"
00063 #include "DQMOffline/PFTau/interface/PFJetMonitor.h"
00064 #include "DQMOffline/PFTau/interface/PFMETMonitor.h"
00065
00066 #include "RecoParticleFlow/PFRootEvent/interface/FWLiteJetProducer.h"
00067 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00068 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00069 #include "DataFormats/JetReco/interface/PFJet.h"
00070 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00071
00072 #include "DataFormats/METReco/interface/PFMETCollection.h"
00073 #include "DataFormats/METReco/interface/PFMET.h"
00074 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00075 #include "DataFormats/METReco/interface/CaloMET.h"
00076 #include "DataFormats/METReco/interface/METCollection.h"
00077 #include "DataFormats/METReco/interface/MET.h"
00078
00079
00080 #include "RecoParticleFlow/PFRootEvent/interface/METManager.h"
00081
00082
00083 #include <TObject.h>
00084 #include "TEllipse.h"
00085 #include "TBox.h"
00086
00087 #include <string>
00088 #include <map>
00089 #include <set>
00090 #include <vector>
00091 #include <memory>
00092 #include <iostream>
00093 #include <fstream>
00094
00095 class TTree;
00096 class TBranch;
00097 class TFile;
00098 class TCanvas;
00099 class TH2F;
00100 class TH1F;
00101
00102
00103 class IO;
00104
00105
00106 class PFBlockElement;
00107
00108 class EventColin;
00109 class PFEnergyCalibration;
00110 class PFEnergyCalibrationHF;
00111 class PFEnergyResolution;
00112
00113 namespace pftools {
00114 class PFClusterCalibration;
00115 }
00116
00117 class METManager;
00118
00119
00120 namespace fwlite {
00121 class ChainEvent;
00122 }
00123
00124 typedef std::pair<double, unsigned> simMatch;
00125 typedef std::list< std::pair<double, unsigned> >::iterator ITM;
00126
00128
00187 class PFRootEventManager {
00188
00189 public:
00190
00192 enum View_t { XY = 0, RZ = 1, EPE = 2, EPH = 3, NViews = 4 };
00193 enum Verbosity {SHUTUP = 0, VERBOSE};
00194
00196 PFRootEventManager();
00197
00199 PFRootEventManager(const char* file);
00200
00202 virtual ~PFRootEventManager();
00203
00204 void initializeEventInformation();
00205
00206 virtual void write();
00207
00209 void reset();
00210
00212 std::string getGenParticleName(int partId,std::string &latexStringName) const;
00213
00214
00217 void readOptions(const char* file,
00218 bool refresh=true,
00219 bool reconnect=false);
00220
00221
00222 virtual void readSpecificOptions(const char* file) {}
00223
00225 void connect(const char* infilename="");
00226
00227 int eventToEntry(int run, int lumi, int event) const;
00228
00230 virtual bool processEvent(int run, int lumi, int event);
00231
00233 virtual bool processEntry(int entry);
00234
00236 bool readFromSimulation(int entry);
00237
00239 bool isHadronicTau() const;
00240
00244 bool countChargedAndPhotons() const;
00245
00249 int chargeValue(const int& pdgId) const;
00250
00251
00253 void PreprocessRecTracks( reco::PFRecTrackCollection& rectracks);
00254 void PreprocessRecTracks( reco::GsfPFRecTrackCollection& rectracks);
00255
00257 void PreprocessRecHits( reco::PFRecHitCollection& rechits,
00258 bool findNeighbours);
00259
00263 void setRecHitNeigbours( reco::PFRecHit& rh,
00264 const std::map<unsigned, unsigned>& detId2index );
00265
00267
00268
00270 void clustering();
00271
00273 void particleFlow();
00274
00276 void pfCandCompare(int);
00277
00279 void reconstructGenJets();
00280
00282 void reconstructCaloJets();
00283
00285 void reconstructPFJets();
00286
00288 void reconstructFWLiteJets(const reco::CandidatePtrVector& Candidates,
00289 std::vector<ProtoJet>& output);
00290
00291 void mcTruthMatching( std::ostream& out,
00292 const reco::PFCandidateCollection& candidates,
00293 std::vector< std::list <simMatch> >& candSimMatchTrack,
00294 std::vector< std::list <simMatch> >& candSimMatchEcal) const;
00295
00299 double tauBenchmark( const reco::PFCandidateCollection& candidates);
00300
00301
00303 void fillOutEventWithClusters(const reco::PFClusterCollection& clusters);
00304
00306 void fillOutEventWithPFCandidates(const reco::PFCandidateCollection& pfCandidates );
00307
00309 void fillOutEventWithSimParticles(const reco::PFSimParticleCollection& ptcs);
00310
00312 void fillOutEventWithCaloTowers(const CaloTowerCollection& cts);
00313
00315 void fillOutEventWithBlocks(const reco::PFBlockCollection& blocks);
00316
00317
00318
00320 void print( std::ostream& out = std::cout,
00321 int maxNLines = -1 ) const;
00322
00324 void printMCCalib( std::ofstream& out ) const;
00325
00326
00328 TTree* tree() {return tree_;}
00329
00330
00331
00332
00333 std::string expand(const std::string& oldString) const;
00334
00336 void printRecHits(const reco::PFRecHitCollection& rechits,
00337 const PFClusterAlgo& clusterAlgo,
00338 std::ostream& out = std::cout) const;
00339
00340 void printRecHit(const reco::PFRecHit& rh, unsigned index,
00341 const char* seed=" ",
00342 std::ostream& out = std::cout) const;
00343
00345 void printClusters(const reco::PFClusterCollection& clusters,
00346 std::ostream& out = std::cout) const;
00347
00348 void printCluster(const reco::PFCluster& cluster,
00349 std::ostream& out = std::cout) const;
00350
00351
00353 void printGenParticles(std::ostream& out = std::cout,
00354 int maxNLines = -1) const;
00355
00356
00357
00358
00359
00361 bool trackInsideGCut( const reco::PFTrack& track ) const;
00362
00364 void fillRecHitMask( std::vector<bool>& mask,
00365 const reco::PFRecHitCollection& rechits ) const;
00366
00368 void fillClusterMask( std::vector<bool>& mask,
00369 const reco::PFClusterCollection& clusters ) const;
00370
00372 void fillTrackMask( std::vector<bool>& mask,
00373 const reco::PFRecTrackCollection& tracks ) const;
00374 void fillTrackMask( std::vector<bool>& mask,
00375 const reco::GsfPFRecTrackCollection& tracks ) const;
00376
00378 void fillPhotonMask (std::vector<bool>& mask,
00379 const reco::PhotonCollection& photons) const;
00380
00382 const reco::PFSimParticle&
00383 closestParticle( reco::PFTrajectoryPoint::LayerType layer,
00384 double eta, double phi,
00385 double& peta, double& pphi, double& pe) const;
00386
00387
00388 const reco::PFBlockCollection& blocks() const { return *pfBlocks_; }
00389
00390
00391 int eventNumber() {return iEvent_;}
00392
00393
00394
00395
00396 void readCMSSWJets();
00397
00399 bool eventAccepted() const;
00400
00402 bool highPtJet( double ptMin ) const;
00403
00405 bool highPtPFCandidate( double ptMin,
00406 reco::PFCandidate::ParticleType type = reco::PFCandidate::X) const;
00407
00409 edm::InputTag stringToTag(const std::vector< std::string >& tagname);
00410
00411
00413 int iEvent_;
00414
00416 IO* options_;
00417
00419 fwlite::ChainEvent* ev_;
00420
00422 TTree* tree_;
00423
00425 TTree* outTree_;
00426
00429 EventColin* outEvent_;
00430
00432 TH1F* h_deltaETvisible_MCEHT_;
00433
00435 TH1F* h_deltaETvisible_MCPF_;
00436
00437
00438
00439
00440
00441 TBranch* eventAuxiliaryBranch_;
00442
00444 edm::EventAuxiliary* eventAuxiliary_;
00445
00447 edm::Handle<reco::PFRecHitCollection> rechitsECALHandle_;
00448 edm::InputTag rechitsECALTag_;
00449 reco::PFRecHitCollection rechitsECAL_;
00450
00452 edm::Handle<reco::PFRecHitCollection> rechitsHCALHandle_;
00453 edm::InputTag rechitsHCALTag_;
00454 reco::PFRecHitCollection rechitsHCAL_;
00455
00457 edm::Handle<reco::PFRecHitCollection> rechitsHFEMHandle_;
00458 edm::InputTag rechitsHFEMTag_;
00459 reco::PFRecHitCollection rechitsHFEM_;
00460
00462 edm::Handle<reco::PFRecHitCollection> rechitsHFHADHandle_;
00463 edm::InputTag rechitsHFHADTag_;
00464 reco::PFRecHitCollection rechitsHFHAD_;
00465
00467 std::vector< reco::PFRecHitCollection > rechitsCLEANEDV_;
00468 std::vector< edm::Handle<reco::PFRecHitCollection> > rechitsCLEANEDHandles_;
00469 std::vector< edm::InputTag > rechitsCLEANEDTags_;
00470 reco::PFRecHitCollection rechitsCLEANED_;
00471
00473 edm::Handle<reco::PFRecHitCollection> rechitsPSHandle_;
00474 edm::InputTag rechitsPSTag_;
00475 reco::PFRecHitCollection rechitsPS_;
00476
00478 edm::Handle<reco::PFClusterCollection> clustersECALHandle_;
00479 edm::InputTag clustersECALTag_;
00480 std::auto_ptr< reco::PFClusterCollection > clustersECAL_;
00481
00483 edm::Handle<reco::PFClusterCollection> clustersHCALHandle_;
00484 edm::InputTag clustersHCALTag_;
00485 std::auto_ptr< reco::PFClusterCollection > clustersHCAL_;
00486
00488 edm::Handle<reco::PFClusterCollection> clustersHFEMHandle_;
00489 edm::InputTag clustersHFEMTag_;
00490 std::auto_ptr< reco::PFClusterCollection > clustersHFEM_;
00491
00493 edm::Handle<reco::PFClusterCollection> clustersHFHADHandle_;
00494 edm::InputTag clustersHFHADTag_;
00495 std::auto_ptr< reco::PFClusterCollection > clustersHFHAD_;
00496
00498 edm::Handle<reco::PFClusterCollection> clustersPSHandle_;
00499 edm::InputTag clustersPSTag_;
00500 std::auto_ptr< reco::PFClusterCollection > clustersPS_;
00501
00503 edm::Handle<CaloTowerCollection> caloTowersHandle_;
00504 edm::InputTag caloTowersTag_;
00505 CaloTowerCollection caloTowers_;
00506
00510 reco::CandidatePtrVector caloTowersPtrs_;
00511
00512
00514 edm::Handle<reco::VertexCollection> primaryVerticesHandle_;
00515 edm::InputTag primaryVerticesTag_;
00516 reco::VertexCollection primaryVertices_;
00517
00519 edm::Handle<reco::PFRecTrackCollection> recTracksHandle_;
00520 edm::Handle<reco::PFRecTrackCollection> displacedRecTracksHandle_;
00521 edm::InputTag recTracksTag_;
00522 edm::InputTag displacedRecTracksTag_;
00523 reco::PFRecTrackCollection recTracks_;
00524 reco::PFRecTrackCollection displacedRecTracks_;
00525
00527 edm::Handle<reco::GsfPFRecTrackCollection> gsfrecTracksHandle_;
00528 edm::InputTag gsfrecTracksTag_;
00529 reco::GsfPFRecTrackCollection gsfrecTracks_;
00530
00532 edm::Handle<reco::GsfPFRecTrackCollection> convBremGsfrecTracksHandle_;
00533 edm::InputTag convBremGsfrecTracksTag_;
00534 reco::GsfPFRecTrackCollection convBremGsfrecTracks_;
00535
00537 edm::Handle<reco::TrackCollection> stdTracksHandle_;
00538 edm::InputTag stdTracksTag_;
00539 reco::TrackCollection stdTracks_;
00540
00542 edm::Handle<reco::MuonCollection> muonsHandle_;
00543 edm::InputTag muonsTag_;
00544 reco::MuonCollection muons_;
00545
00547 edm::Handle<reco::PFConversionCollection> conversionHandle_;
00548 edm::InputTag conversionTag_;
00549 reco::PFConversionCollection conversion_;
00550
00552 edm::Handle<reco::PhotonCollection> photonHandle_;
00553 edm::InputTag photonTag_;
00554 reco::PhotonCollection photons_;
00555
00557 edm::Handle<reco::PFV0Collection> v0Handle_;
00558 edm::InputTag v0Tag_;
00559 reco::PFV0Collection v0_;
00560
00562 edm::Handle<reco::PFDisplacedTrackerVertexCollection> pfNuclearTrackerVertexHandle_;
00563 edm::InputTag pfNuclearTrackerVertexTag_;
00564 reco::PFDisplacedTrackerVertexCollection pfNuclearTrackerVertex_;
00565
00567 edm::Handle<reco::PFSimParticleCollection> trueParticlesHandle_;
00568 edm::InputTag trueParticlesTag_;
00569 reco::PFSimParticleCollection trueParticles_;
00570
00572 edm::Handle<edm::HepMCProduct> MCTruthHandle_;
00573 edm::InputTag MCTruthTag_;
00574 edm::HepMCProduct MCTruth_;
00575
00577 edm::Handle<reco::GenParticleRefVector> genParticlesforJetsHandle_;
00578 edm::InputTag genParticlesforJetsTag_;
00579 reco::GenParticleRefVector genParticlesforJets_;
00580
00582 reco::GenJetCollection genJets_;
00583
00585 edm::Handle<reco::GenParticleCollection> genParticlesforMETHandle_;
00586 edm::InputTag genParticlesforMETTag_;
00587 reco::GenParticleCollection genParticlesCMSSW_;
00588
00592 reco::CandidatePtrVector genParticlesforJetsPtrs_;
00593
00595 std::auto_ptr< reco::PFBlockCollection > pfBlocks_;
00596
00598 std::auto_ptr< reco::PFCandidateCollection > pfCandidates_;
00599
00604 reco::CandidatePtrVector pfCandidatesPtrs_;
00605
00607 reco::PFJetCollection pfJets_;
00608
00610 std::vector<ProtoJet> caloJets_;
00611
00613 edm::Handle<reco::PFJetCollection> pfJetsHandle_;
00614 edm::InputTag pfJetsTag_;
00615 reco::PFJetCollection pfJetsCMSSW_;
00616
00618 edm::Handle<reco::GenJetCollection> genJetsHandle_;
00619 edm::InputTag genJetsTag_;
00620 reco::GenJetCollection genJetsCMSSW_;
00621
00623 edm::Handle< std::vector<reco::CaloJet> >caloJetsHandle_;
00624 edm::InputTag caloJetsTag_;
00625 std::vector<reco::CaloJet> caloJetsCMSSW_;
00626
00628 edm::Handle< std::vector<reco::CaloJet> > corrcaloJetsHandle_;
00629 edm::InputTag corrcaloJetsTag_;
00630 std::vector<reco::CaloJet> corrcaloJetsCMSSW_;
00631
00633 reco::PFMETCollection pfMets_;
00634
00636 reco::CaloMETCollection caloMets_;
00637
00639 reco::METCollection tcMets_;
00640
00642 edm::Handle<reco::CaloMETCollection> caloMetsHandle_;
00643 edm::InputTag caloMetsTag_;
00644 reco::CaloMETCollection caloMetsCMSSW_;
00645
00647 edm::Handle<reco::METCollection> tcMetsHandle_;
00648 edm::InputTag tcMetsTag_;
00649 reco::METCollection tcMetsCMSSW_;
00650
00652 edm::Handle<reco::PFMETCollection> pfMetsHandle_;
00653 edm::InputTag pfMetsTag_;
00654 reco::PFMETCollection pfMetsCMSSW_;
00655
00657 edm::Handle<reco::PFCandidateCollection> pfCandidateHandle_;
00658 edm::InputTag pfCandidateTag_;
00659 reco::PFCandidateCollection pfCandCMSSW_;
00660
00662 TFile* file_;
00663
00665 std::vector<std::string> inFileNames_;
00666
00668 TFile* outFile_;
00669
00671 std::string outFileName_;
00672
00673
00674
00677 PFClusterAlgo clusterAlgoECAL_;
00678
00680 PFClusterAlgo clusterAlgoHCAL_;
00681
00683 PFClusterAlgo clusterAlgoHFEM_;
00684
00686 PFClusterAlgo clusterAlgoHFHAD_;
00687
00689 PFClusterAlgo clusterAlgoPS_;
00690
00691
00693 PFBlockAlgo pfBlockAlgo_;
00694
00696 PFAlgo pfAlgo_;
00697
00698
00699
00701 PFJetBenchmark PFJetBenchmark_;
00702
00704 double MET1cut;
00705 double DeltaMETcut;
00706 double DeltaPhicut;
00707
00708 PFCandidateManager pfCandidateManager_;
00709 bool doPFCandidateBenchmark_;
00710
00713 PFJetAlgorithm jetAlgo_;
00714
00716 FWLiteJetProducer jetMaker_;
00717
00718
00719 PFJetMonitor pfJetMonitor_;
00720 PFMETMonitor pfMETMonitor_;
00721 bool doPFDQM_;
00722 TFile* dqmFile_;
00723
00724
00725
00726
00728 bool printRecHits_;
00729 double printRecHitsEMin_;
00730
00732 bool printClusters_;
00733 double printClustersEMin_;
00734
00736 bool printPFBlocks_;
00737
00739 bool printPFCandidates_;
00740 double printPFCandidatesPtMin_;
00741
00743 bool printPFJets_;
00744 double printPFJetsPtMin_;
00745
00747 bool printSimParticles_;
00748 double printSimParticlesPtMin_;
00749
00751 bool printGenParticles_;
00752 double printGenParticlesPtMin_;
00753
00754
00755 bool printMCTruthMatching_;
00756
00758 int verbosity_;
00759
00760
00761
00762 unsigned filterNParticles_;
00763
00764 bool filterHadronicTaus_;
00765
00766 std::vector<int> filterTaus_;
00767
00768
00769
00772 bool doClustering_;
00773
00775 bool doParticleFlow_;
00776
00778 bool doCompare_;
00779
00781 bool doJets_;
00782
00784 bool doMet_;
00785
00787 bool JECinCaloMet_;
00788
00790 int jetAlgoType_;
00791
00793 bool doTauBenchmark_;
00794
00796 bool tauBenchmarkDebug_;
00797
00799 bool doPFJetBenchmark_;
00800
00802 bool doPFMETBenchmark_;
00803
00805 bool debug_;
00806
00808 bool findRecHitNeighbours_;
00809
00810
00812 bool jetsDebug_;
00813
00814
00816 bool fastsim_;
00817
00819 bool usePFConversions_;
00820
00822 bool usePFV0s_;
00823
00825 bool usePFNuclearInteractions_;
00826
00828 bool useConvBremGsfTracks_;
00829
00831 bool useConvBremPFRecTracks_;
00832
00834 bool useEGPhotons_;
00835
00837 bool useAtHLT;
00838
00839
00840
00844
00845
00846
00847 boost::shared_ptr<pftools::PFClusterCalibration> clusterCalibration_;
00848 boost::shared_ptr<PFEnergyCalibration> calibration_;
00849 boost::shared_ptr<PFEnergyCalibrationHF> thepfEnergyCalibrationHF_;
00850
00851 std::ofstream* calibFile_;
00852
00853 std::auto_ptr<METManager> metManager_;
00854
00855 typedef std::map<int, int> EventToEntry;
00856 typedef std::map<int, EventToEntry> LumisMap;
00857 typedef std::map<int, LumisMap> RunsMap;
00858 RunsMap mapEventToEntry_;
00859 };
00860 #endif