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/ParticleFlowCandidate/interface/PFCandidateElectronExtra.h"
00034 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateElectronExtraFwd.h"
00035
00036 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00037 #include "DataFormats/MuonReco/interface/Muon.h"
00038
00039 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00040 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00041
00042 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedTrackerVertex.h"
00043
00044 #include "DataFormats/ParticleFlowReco/interface/PFConversion.h"
00045 #include "DataFormats/ParticleFlowReco/interface/PFConversionFwd.h"
00046 #include "DataFormats/ParticleFlowReco/interface/PFV0.h"
00047 #include "DataFormats/ParticleFlowReco/interface/PFV0Fwd.h"
00048
00049 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00050 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00051 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00052 #include "CommonTools/CandUtils/interface/pdgIdUtils.h"
00053
00054
00055 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00056 #include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
00057
00058 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterAlgo.h"
00059 #include "RecoParticleFlow/PFProducer/interface/PFBlockAlgo.h"
00060 #include "RecoParticleFlow/PFProducer/interface/PFAlgo.h"
00061
00062 #include "RecoParticleFlow/PFRootEvent/interface/PFJetAlgorithm.h"
00063 #include "RecoParticleFlow/Benchmark/interface/PFJetBenchmark.h"
00064 #include "RecoParticleFlow/Benchmark/interface/PFMETBenchmark.h"
00065 #include "DQMOffline/PFTau/interface/PFCandidateManager.h"
00066 #include "DQMOffline/PFTau/interface/PFJetMonitor.h"
00067 #include "DQMOffline/PFTau/interface/PFMETMonitor.h"
00068
00069 #include "RecoParticleFlow/PFRootEvent/interface/FWLiteJetProducer.h"
00070 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00071 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00072 #include "DataFormats/JetReco/interface/PFJet.h"
00073 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00074
00075 #include "DataFormats/METReco/interface/PFMETCollection.h"
00076 #include "DataFormats/METReco/interface/PFMET.h"
00077 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00078 #include "DataFormats/METReco/interface/CaloMET.h"
00079 #include "DataFormats/METReco/interface/METCollection.h"
00080 #include "DataFormats/METReco/interface/MET.h"
00081
00082
00083 #include "RecoParticleFlow/PFRootEvent/interface/METManager.h"
00084
00085
00086 #include <TObject.h>
00087 #include "TEllipse.h"
00088 #include "TBox.h"
00089
00090 #include <string>
00091 #include <map>
00092 #include <set>
00093 #include <vector>
00094 #include <memory>
00095 #include <iostream>
00096 #include <fstream>
00097
00098 class TTree;
00099 class TBranch;
00100 class TFile;
00101 class TCanvas;
00102 class TH2F;
00103 class TH1F;
00104
00105
00106 class IO;
00107
00108
00109 class PFBlockElement;
00110
00111 class EventColin;
00112 class PFEnergyCalibration;
00113 class PFEnergyCalibrationHF;
00114 class PFEnergyResolution;
00115
00116 namespace pftools {
00117 class PFClusterCalibration;
00118 }
00119
00120 class METManager;
00121
00122
00123 namespace fwlite {
00124 class ChainEvent;
00125 }
00126
00127 typedef std::pair<double, unsigned> simMatch;
00128 typedef std::list< std::pair<double, unsigned> >::iterator ITM;
00129
00131
00190 class PFRootEventManager {
00191
00192 public:
00193
00195 enum View_t { XY = 0, RZ = 1, EPE = 2, EPH = 3, NViews = 4 };
00196 enum Verbosity {SHUTUP = 0, VERBOSE};
00197
00199 PFRootEventManager();
00200
00202 PFRootEventManager(const char* file);
00203
00205 virtual ~PFRootEventManager();
00206
00207 void initializeEventInformation();
00208
00209 virtual void write();
00210
00212 void reset();
00213
00215 std::string getGenParticleName(int partId,std::string &latexStringName) const;
00216
00217
00220 void readOptions(const char* file,
00221 bool refresh=true,
00222 bool reconnect=false);
00223
00224
00225 virtual void readSpecificOptions(const char* file) {}
00226
00228 void connect(const char* infilename="");
00229
00230 int eventToEntry(int run, int lumi, int event) const;
00231
00233 virtual bool processEvent(int run, int lumi, int event);
00234
00236 virtual bool processEntry(int entry);
00237
00239 bool readFromSimulation(int entry);
00240
00242 bool isHadronicTau() const;
00243
00247 bool countChargedAndPhotons() const;
00248
00252 int chargeValue(const int& pdgId) const;
00253
00254
00256 void PreprocessRecTracks( reco::PFRecTrackCollection& rectracks);
00257 void PreprocessRecTracks( reco::GsfPFRecTrackCollection& rectracks);
00258
00260 void PreprocessRecHits( reco::PFRecHitCollection& rechits,
00261 bool findNeighbours);
00262
00266 void setRecHitNeigbours( reco::PFRecHit& rh,
00267 const std::map<unsigned, unsigned>& detId2index );
00268
00270
00271
00273 void clustering();
00274
00276 void particleFlow();
00277
00279 void pfCandCompare(int);
00280
00282 void reconstructGenJets();
00283
00285 void reconstructCaloJets();
00286
00288 void reconstructPFJets();
00289
00291 void reconstructFWLiteJets(const reco::CandidatePtrVector& Candidates,
00292 std::vector<ProtoJet>& output);
00293
00294 void mcTruthMatching( std::ostream& out,
00295 const reco::PFCandidateCollection& candidates,
00296 std::vector< std::list <simMatch> >& candSimMatchTrack,
00297 std::vector< std::list <simMatch> >& candSimMatchEcal) const;
00298
00302 double tauBenchmark( const reco::PFCandidateCollection& candidates);
00303
00304
00306 void fillOutEventWithClusters(const reco::PFClusterCollection& clusters);
00307
00309 void fillOutEventWithPFCandidates(const reco::PFCandidateCollection& pfCandidates );
00310
00312 void fillOutEventWithSimParticles(const reco::PFSimParticleCollection& ptcs);
00313
00315 void fillOutEventWithCaloTowers(const CaloTowerCollection& cts);
00316
00318 void fillOutEventWithBlocks(const reco::PFBlockCollection& blocks);
00319
00320
00321
00323 void print( std::ostream& out = std::cout,
00324 int maxNLines = -1 ) const;
00325
00327 void printMCCalib( std::ofstream& out ) const;
00328
00329
00331 TTree* tree() {return tree_;}
00332
00333
00334
00335
00336 std::string expand(const std::string& oldString) const;
00337
00339 void printRecHits(const reco::PFRecHitCollection& rechits,
00340 const PFClusterAlgo& clusterAlgo,
00341 std::ostream& out = std::cout) const;
00342
00343 void printRecHit(const reco::PFRecHit& rh, unsigned index,
00344 const char* seed=" ",
00345 std::ostream& out = std::cout) const;
00346
00348 void printClusters(const reco::PFClusterCollection& clusters,
00349 std::ostream& out = std::cout) const;
00350
00351 void printCluster(const reco::PFCluster& cluster,
00352 std::ostream& out = std::cout) const;
00353
00354
00356 void printGenParticles(std::ostream& out = std::cout,
00357 int maxNLines = -1) const;
00358
00359
00360
00361
00362
00364 bool trackInsideGCut( const reco::PFTrack& track ) const;
00365
00367 void fillRecHitMask( std::vector<bool>& mask,
00368 const reco::PFRecHitCollection& rechits ) const;
00369
00371 void fillClusterMask( std::vector<bool>& mask,
00372 const reco::PFClusterCollection& clusters ) const;
00373
00375 void fillTrackMask( std::vector<bool>& mask,
00376 const reco::PFRecTrackCollection& tracks ) const;
00377 void fillTrackMask( std::vector<bool>& mask,
00378 const reco::GsfPFRecTrackCollection& tracks ) const;
00379
00381 void fillPhotonMask (std::vector<bool>& mask,
00382 const reco::PhotonCollection& photons) const;
00383
00385 const reco::PFSimParticle&
00386 closestParticle( reco::PFTrajectoryPoint::LayerType layer,
00387 double eta, double phi,
00388 double& peta, double& pphi, double& pe) const;
00389
00390
00391 const reco::PFBlockCollection& blocks() const { return *pfBlocks_; }
00392
00393
00394 int eventNumber() {return iEvent_;}
00395
00396
00397
00398
00399 void readCMSSWJets();
00400
00402 bool eventAccepted() const;
00403
00405 bool highPtJet( double ptMin ) const;
00406
00408 bool highPtPFCandidate( double ptMin,
00409 reco::PFCandidate::ParticleType type = reco::PFCandidate::X) const;
00410
00412 edm::InputTag stringToTag(const std::vector< std::string >& tagname);
00413
00414
00416 int iEvent_;
00417
00419 IO* options_;
00420
00422 fwlite::ChainEvent* ev_;
00423
00425 TTree* tree_;
00426
00428 TTree* outTree_;
00429
00432 EventColin* outEvent_;
00433
00435 TH1F* h_deltaETvisible_MCEHT_;
00436
00438 TH1F* h_deltaETvisible_MCPF_;
00439
00440
00441
00442
00443
00444 TBranch* eventAuxiliaryBranch_;
00445
00447 edm::EventAuxiliary* eventAuxiliary_;
00448
00450 edm::Handle<reco::PFRecHitCollection> rechitsECALHandle_;
00451 edm::InputTag rechitsECALTag_;
00452 reco::PFRecHitCollection rechitsECAL_;
00453
00455 edm::Handle<reco::PFRecHitCollection> rechitsHCALHandle_;
00456 edm::InputTag rechitsHCALTag_;
00457 reco::PFRecHitCollection rechitsHCAL_;
00458
00460 edm::Handle<reco::PFRecHitCollection> rechitsHFEMHandle_;
00461 edm::InputTag rechitsHFEMTag_;
00462 reco::PFRecHitCollection rechitsHFEM_;
00463
00465 edm::Handle<reco::PFRecHitCollection> rechitsHFHADHandle_;
00466 edm::InputTag rechitsHFHADTag_;
00467 reco::PFRecHitCollection rechitsHFHAD_;
00468
00470 std::vector< reco::PFRecHitCollection > rechitsCLEANEDV_;
00471 std::vector< edm::Handle<reco::PFRecHitCollection> > rechitsCLEANEDHandles_;
00472 std::vector< edm::InputTag > rechitsCLEANEDTags_;
00473 reco::PFRecHitCollection rechitsCLEANED_;
00474
00476 edm::Handle<reco::PFRecHitCollection> rechitsPSHandle_;
00477 edm::InputTag rechitsPSTag_;
00478 reco::PFRecHitCollection rechitsPS_;
00479
00481 edm::Handle<reco::PFClusterCollection> clustersECALHandle_;
00482 edm::InputTag clustersECALTag_;
00483 std::auto_ptr< reco::PFClusterCollection > clustersECAL_;
00484
00486 edm::Handle<reco::PFClusterCollection> clustersHCALHandle_;
00487 edm::InputTag clustersHCALTag_;
00488 std::auto_ptr< reco::PFClusterCollection > clustersHCAL_;
00489
00491 edm::Handle<reco::PFClusterCollection> clustersHFEMHandle_;
00492 edm::InputTag clustersHFEMTag_;
00493 std::auto_ptr< reco::PFClusterCollection > clustersHFEM_;
00494
00496 edm::Handle<reco::PFClusterCollection> clustersHFHADHandle_;
00497 edm::InputTag clustersHFHADTag_;
00498 std::auto_ptr< reco::PFClusterCollection > clustersHFHAD_;
00499
00501 edm::Handle<reco::PFClusterCollection> clustersPSHandle_;
00502 edm::InputTag clustersPSTag_;
00503 std::auto_ptr< reco::PFClusterCollection > clustersPS_;
00504
00506 edm::Handle<CaloTowerCollection> caloTowersHandle_;
00507 edm::InputTag caloTowersTag_;
00508 CaloTowerCollection caloTowers_;
00509
00513 reco::CandidatePtrVector caloTowersPtrs_;
00514
00515
00517 edm::Handle<reco::VertexCollection> primaryVerticesHandle_;
00518 edm::InputTag primaryVerticesTag_;
00519 reco::VertexCollection primaryVertices_;
00520
00522 edm::Handle<reco::PFRecTrackCollection> recTracksHandle_;
00523 edm::Handle<reco::PFRecTrackCollection> displacedRecTracksHandle_;
00524 edm::InputTag recTracksTag_;
00525 edm::InputTag displacedRecTracksTag_;
00526 reco::PFRecTrackCollection recTracks_;
00527 reco::PFRecTrackCollection displacedRecTracks_;
00528
00530 edm::Handle<reco::GsfPFRecTrackCollection> gsfrecTracksHandle_;
00531 edm::InputTag gsfrecTracksTag_;
00532 reco::GsfPFRecTrackCollection gsfrecTracks_;
00533
00534
00535 edm::Handle<reco::GsfElectronCollection> egammaElectronHandle_;
00536 edm::InputTag egammaElectronsTag_;
00537 reco::GsfElectronCollection egammaElectrons_;
00538
00540 edm::Handle<reco::GsfPFRecTrackCollection> convBremGsfrecTracksHandle_;
00541 edm::InputTag convBremGsfrecTracksTag_;
00542 reco::GsfPFRecTrackCollection convBremGsfrecTracks_;
00543
00545 edm::Handle<reco::TrackCollection> stdTracksHandle_;
00546 edm::InputTag stdTracksTag_;
00547 reco::TrackCollection stdTracks_;
00548
00550 edm::Handle<reco::MuonCollection> muonsHandle_;
00551 edm::InputTag muonsTag_;
00552 reco::MuonCollection muons_;
00553
00555 edm::Handle<reco::PFConversionCollection> conversionHandle_;
00556 edm::InputTag conversionTag_;
00557 reco::PFConversionCollection conversion_;
00558
00560 edm::Handle<reco::PhotonCollection> photonHandle_;
00561 edm::InputTag photonTag_;
00562 reco::PhotonCollection photons_;
00563
00565 edm::Handle<reco::PFV0Collection> v0Handle_;
00566 edm::InputTag v0Tag_;
00567 reco::PFV0Collection v0_;
00568
00570 edm::Handle<reco::PFDisplacedTrackerVertexCollection> pfNuclearTrackerVertexHandle_;
00571 edm::InputTag pfNuclearTrackerVertexTag_;
00572 reco::PFDisplacedTrackerVertexCollection pfNuclearTrackerVertex_;
00573
00575 edm::Handle<reco::PFSimParticleCollection> trueParticlesHandle_;
00576 edm::InputTag trueParticlesTag_;
00577 reco::PFSimParticleCollection trueParticles_;
00578
00580 edm::Handle<edm::HepMCProduct> MCTruthHandle_;
00581 edm::InputTag MCTruthTag_;
00582 edm::HepMCProduct MCTruth_;
00583
00585 edm::Handle<reco::GenParticleRefVector> genParticlesforJetsHandle_;
00586 edm::InputTag genParticlesforJetsTag_;
00587 reco::GenParticleRefVector genParticlesforJets_;
00588
00590 reco::GenJetCollection genJets_;
00591
00593 edm::Handle<reco::GenParticleCollection> genParticlesforMETHandle_;
00594 edm::InputTag genParticlesforMETTag_;
00595 reco::GenParticleCollection genParticlesCMSSW_;
00596
00600 reco::CandidatePtrVector genParticlesforJetsPtrs_;
00601
00603 std::auto_ptr< reco::PFBlockCollection > pfBlocks_;
00604
00606 std::auto_ptr< reco::PFCandidateCollection > pfCandidates_;
00607
00609 std::auto_ptr< reco::PFCandidateElectronExtraCollection > pfCandidateElectronExtras_;
00610
00615 reco::CandidatePtrVector pfCandidatesPtrs_;
00616
00618 reco::PFJetCollection pfJets_;
00619
00621 std::vector<ProtoJet> caloJets_;
00622
00624 edm::Handle<reco::PFJetCollection> pfJetsHandle_;
00625 edm::InputTag pfJetsTag_;
00626 reco::PFJetCollection pfJetsCMSSW_;
00627
00629 edm::Handle<reco::GenJetCollection> genJetsHandle_;
00630 edm::InputTag genJetsTag_;
00631 reco::GenJetCollection genJetsCMSSW_;
00632
00634 edm::Handle< std::vector<reco::CaloJet> >caloJetsHandle_;
00635 edm::InputTag caloJetsTag_;
00636 std::vector<reco::CaloJet> caloJetsCMSSW_;
00637
00639 edm::Handle< std::vector<reco::CaloJet> > corrcaloJetsHandle_;
00640 edm::InputTag corrcaloJetsTag_;
00641 std::vector<reco::CaloJet> corrcaloJetsCMSSW_;
00642
00644 reco::PFMETCollection pfMets_;
00645
00647 reco::CaloMETCollection caloMets_;
00648
00650 reco::METCollection tcMets_;
00651
00653 edm::Handle<reco::CaloMETCollection> caloMetsHandle_;
00654 edm::InputTag caloMetsTag_;
00655 reco::CaloMETCollection caloMetsCMSSW_;
00656
00658 edm::Handle<reco::METCollection> tcMetsHandle_;
00659 edm::InputTag tcMetsTag_;
00660 reco::METCollection tcMetsCMSSW_;
00661
00663 edm::Handle<reco::PFMETCollection> pfMetsHandle_;
00664 edm::InputTag pfMetsTag_;
00665 reco::PFMETCollection pfMetsCMSSW_;
00666
00668 edm::Handle<reco::PFCandidateCollection> pfCandidateHandle_;
00669 edm::InputTag pfCandidateTag_;
00670 reco::PFCandidateCollection pfCandCMSSW_;
00671
00673 TFile* file_;
00674
00676 std::vector<std::string> inFileNames_;
00677
00679 TFile* outFile_;
00680
00682 std::string outFileName_;
00683
00684
00685
00688 PFClusterAlgo clusterAlgoECAL_;
00689
00691 PFClusterAlgo clusterAlgoHCAL_;
00692
00694 PFClusterAlgo clusterAlgoHFEM_;
00695
00697 PFClusterAlgo clusterAlgoHFHAD_;
00698
00700 PFClusterAlgo clusterAlgoPS_;
00701
00702
00704 PFBlockAlgo pfBlockAlgo_;
00705
00707 PFAlgo pfAlgo_;
00708
00709
00710
00712 PFJetBenchmark PFJetBenchmark_;
00713
00715 double MET1cut;
00716 double DeltaMETcut;
00717 double DeltaPhicut;
00718
00719 PFCandidateManager pfCandidateManager_;
00720 bool doPFCandidateBenchmark_;
00721
00724 PFJetAlgorithm jetAlgo_;
00725
00727 FWLiteJetProducer jetMaker_;
00728
00729
00730 PFJetMonitor pfJetMonitor_;
00731 PFMETMonitor pfMETMonitor_;
00732 bool doPFDQM_;
00733 TFile* dqmFile_;
00734
00735
00736
00737
00739 bool printRecHits_;
00740 double printRecHitsEMin_;
00741
00743 bool printClusters_;
00744 double printClustersEMin_;
00745
00747 bool printPFBlocks_;
00748
00750 bool printPFCandidates_;
00751 double printPFCandidatesPtMin_;
00752
00754 bool printPFJets_;
00755 double printPFJetsPtMin_;
00756
00758 bool printSimParticles_;
00759 double printSimParticlesPtMin_;
00760
00762 bool printGenParticles_;
00763 double printGenParticlesPtMin_;
00764
00765
00766 bool printMCTruthMatching_;
00767
00769 int verbosity_;
00770
00771
00772
00773 unsigned filterNParticles_;
00774
00775 bool filterHadronicTaus_;
00776
00777 std::vector<int> filterTaus_;
00778
00779
00780
00783 bool doClustering_;
00784
00786 bool doParticleFlow_;
00787
00789 bool doCompare_;
00790
00792 bool useKDTreeTrackEcalLinker_;
00793
00795 bool doJets_;
00796
00798 bool doMet_;
00799
00801 bool JECinCaloMet_;
00802
00804 int jetAlgoType_;
00805
00807 bool doTauBenchmark_;
00808
00810 bool tauBenchmarkDebug_;
00811
00813 bool doPFJetBenchmark_;
00814
00816 bool doPFMETBenchmark_;
00817
00819 bool debug_;
00820
00822 bool findRecHitNeighbours_;
00823
00824
00826 bool jetsDebug_;
00827
00828
00830 bool fastsim_;
00831
00833 bool usePFConversions_;
00834
00836 bool usePFV0s_;
00837
00839 bool usePFNuclearInteractions_;
00840
00842 bool useConvBremGsfTracks_;
00843
00845 bool useConvBremPFRecTracks_;
00846
00848 bool useEGPhotons_;
00849
00851 bool usePFElectrons_;
00852
00854 bool useEGElectrons_;
00855
00857 bool useAtHLT;
00858
00859
00860
00864
00865
00866
00867 boost::shared_ptr<pftools::PFClusterCalibration> clusterCalibration_;
00868 boost::shared_ptr<PFEnergyCalibration> calibration_;
00869 boost::shared_ptr<PFEnergyCalibrationHF> thepfEnergyCalibrationHF_;
00870
00871 std::ofstream* calibFile_;
00872
00873 std::auto_ptr<METManager> metManager_;
00874
00875 typedef std::map<int, int> EventToEntry;
00876 typedef std::map<int, EventToEntry> LumisMap;
00877 typedef std::map<int, LumisMap> RunsMap;
00878 RunsMap mapEventToEntry_;
00879 };
00880 #endif