00001 #ifndef RecoParticleFlow_PFRootEvent_PFRootEventManager_h
00002 #define RecoParticleFlow_PFRootEvent_PFRootEventManager_h
00003
00004 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00005
00006 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00007 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00008
00009 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00010 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00011
00012 #include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h"
00013
00014 #include "DataFormats/ParticleFlowReco/interface/PFRecTrack.h"
00015 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00016 #include "DataFormats/TrackReco/interface/Track.h"
00017 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00018 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrack.h"
00019 #include "DataFormats/ParticleFlowReco/interface/GsfPFRecTrackFwd.h"
00020
00021 #include "DataFormats/ParticleFlowReco/interface/PFSimParticle.h"
00022 #include "DataFormats/ParticleFlowReco/interface/PFSimParticleFwd.h"
00023
00024 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00025 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
00026
00027 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00028 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00029
00030 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00031 #include "DataFormats/MuonReco/interface/Muon.h"
00032
00033 #include "DataFormats/ParticleFlowReco/interface/PFNuclearInteraction.h"
00034
00035 #include "DataFormats/ParticleFlowReco/interface/PFConversion.h"
00036 #include "DataFormats/ParticleFlowReco/interface/PFConversionFwd.h"
00037 #include "DataFormats/ParticleFlowReco/interface/PFV0.h"
00038 #include "DataFormats/ParticleFlowReco/interface/PFV0Fwd.h"
00039
00040 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00041 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00042 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00043 #include "PhysicsTools/CandUtils/interface/pdgIdUtils.h"
00044
00045 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00046 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00047 #include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
00048
00049 #include "RecoParticleFlow/PFClusterAlgo/interface/PFClusterAlgo.h"
00050 #include "RecoParticleFlow/PFBlockAlgo/interface/PFBlockAlgo.h"
00051 #include "RecoParticleFlow/PFAlgo/interface/PFAlgo.h"
00052
00053 #include "RecoParticleFlow/PFRootEvent/interface/PFJetAlgorithm.h"
00054 #include "RecoParticleFlow/Benchmark/interface/PFJetBenchmark.h"
00055
00056 #include "RecoParticleFlow/PFRootEvent/interface/FWLiteJetProducer.h"
00057 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
00058 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00059 #include "DataFormats/JetReco/interface/PFJet.h"
00060 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00061
00062 #include <TObject.h>
00063 #include "TEllipse.h"
00064 #include "TBox.h"
00065
00066 #include <string>
00067 #include <map>
00068 #include <set>
00069 #include <vector>
00070 #include <memory>
00071
00072 class TTree;
00073 class TBranch;
00074 class TFile;
00075 class TCanvas;
00076 class TH2F;
00077 class TH1F;
00078
00079
00080 class IO;
00081
00082
00083 class PFBlockElement;
00084
00085 class EventColin;
00086 class PFEnergyCalibration;
00087 class PFEnergyResolution;
00088
00089 typedef std::pair<double, unsigned> simMatch;
00090 typedef std::list< std::pair<double, unsigned> >::iterator ITM;
00091
00093
00152 class PFRootEventManager {
00153
00154 public:
00155
00157 enum View_t { XY = 0, RZ = 1, EPE = 2, EPH = 3, NViews = 4 };
00158 enum Verbosity {SHUTUP = 0, VERBOSE};
00159
00161 PFRootEventManager();
00162
00164 PFRootEventManager(const char* file);
00165
00167 virtual ~PFRootEventManager();
00168
00169 virtual void write();
00170
00172 void reset();
00173
00175 std::string getGenParticleName(int partId,std::string &latexStringName) const;
00176
00177
00180 void readOptions(const char* file,
00181 bool refresh=true,
00182 bool reconnect=false);
00183
00184
00185 virtual void readSpecificOptions(const char* file) {}
00186
00188 void connect(const char* infilename="");
00189
00191 void setAddresses();
00192
00194 virtual bool processEntry(int entry);
00195
00197 bool readFromSimulation(int entry);
00198
00200 bool isHadronicTau() const;
00201
00205 bool countChargedAndPhotons() const;
00206
00210 int chargeValue(const int& pdgId) const;
00211
00212
00214 void PreprocessRecTracks( reco::PFRecTrackCollection& rectracks);
00215 void PreprocessRecTracks( reco::GsfPFRecTrackCollection& rectracks);
00216
00218 void PreprocessRecHits( reco::PFRecHitCollection& rechits,
00219 bool findNeighbours);
00220
00224 void setRecHitNeigbours( reco::PFRecHit& rh,
00225 const std::map<unsigned, unsigned>& detId2index );
00226
00228
00229
00231 void clustering();
00232
00234 void particleFlow();
00235
00237 void reconstructGenJets();
00238
00240 void reconstructCaloJets();
00241
00243 void reconstructPFJets();
00244
00245
00247 void reconstructFWLiteJets(const reco::CandidatePtrVector& Candidates,
00248 std::vector<ProtoJet>& output);
00249
00250 void mcTruthMatching( std::ostream& out,
00251 const reco::PFCandidateCollection& candidates,
00252 std::vector< std::list <simMatch> >& candSimMatchTrack,
00253 std::vector< std::list <simMatch> >& candSimMatchEcal) const;
00254
00258 double tauBenchmark( const reco::PFCandidateCollection& candidates);
00259
00260
00262 void fillOutEventWithClusters(const reco::PFClusterCollection& clusters);
00263
00265 void fillOutEventWithPFCandidates(const reco::PFCandidateCollection& pfCandidates );
00266
00268 void fillOutEventWithSimParticles(const reco::PFSimParticleCollection& ptcs);
00269
00271 void fillOutEventWithCaloTowers(const CaloTowerCollection& cts);
00272
00274 void fillOutEventWithBlocks(const reco::PFBlockCollection& blocks);
00275
00276
00277
00279 void print( std::ostream& out = std::cout,
00280 int maxNLines = -1 ) const;
00281
00282
00284 TTree* tree() {return tree_;}
00285
00286
00287
00288
00289 std::string expand(const std::string& oldString) const;
00290
00292 void printRecHit(const reco::PFRecHit& rh,
00293 const char* seed=" ",
00294 std::ostream& out = std::cout) const;
00295
00297 void printCluster(const reco::PFCluster& cluster,
00298 std::ostream& out = std::cout) const;
00299
00300
00301
00303 void printGenParticles(std::ostream& out = std::cout,
00304 int maxNLines = -1) const;
00305
00306
00307
00308
00309
00311 bool trackInsideGCut( const reco::PFTrack& track ) const;
00312
00314 void fillRecHitMask( std::vector<bool>& mask,
00315 const reco::PFRecHitCollection& rechits ) const;
00316
00318 void fillClusterMask( std::vector<bool>& mask,
00319 const reco::PFClusterCollection& clusters ) const;
00320
00322 void fillTrackMask( std::vector<bool>& mask,
00323 const reco::PFRecTrackCollection& tracks ) const;
00324 void fillTrackMask( std::vector<bool>& mask,
00325 const reco::GsfPFRecTrackCollection& tracks ) const;
00326
00328 const reco::PFSimParticle&
00329 closestParticle( reco::PFTrajectoryPoint::LayerType layer,
00330 double eta, double phi,
00331 double& peta, double& pphi, double& pe) const;
00332
00333
00334 const reco::PFBlockCollection& blocks() const { return *pfBlocks_; }
00335
00336
00337 int eventNumber() {return iEvent_;}
00338
00339
00340
00341
00342 void readCMSSWJets();
00343
00344
00345
00346
00347
00349 int iEvent_;
00350
00352 IO* options_;
00353
00355 TTree* tree_;
00356
00358 TTree* outTree_;
00359
00362 EventColin* outEvent_;
00363
00365 TH1F* h_deltaETvisible_MCEHT_;
00366
00368 TH1F* h_deltaETvisible_MCPF_;
00369
00370
00371
00372
00374 TBranch* hitsBranch_;
00375
00377 TBranch* rechitsECALBranch_;
00378
00380 TBranch* rechitsHCALBranch_;
00381
00383 TBranch* rechitsPSBranch_;
00384
00386 TBranch* clustersECALBranch_;
00387
00389 TBranch* clustersHCALBranch_;
00390
00392 TBranch* clustersPSBranch_;
00393
00395 TBranch* clustersIslandBarrelBranch_;
00396
00398 TBranch* caloTowersBranch_;
00399
00401 TBranch* recTracksBranch_;
00402
00404 TBranch* stdTracksBranch_;
00405
00407 TBranch* gsfrecTracksBranch_;
00408
00410 TBranch* muonsBranch_;
00411
00413 TBranch* nuclearBranch_;
00414
00416 TBranch* conversionBranch_;
00417
00419 TBranch* v0Branch_;
00420
00421
00423 TBranch* trueParticlesBranch_;
00424
00426 TBranch* MCTruthBranch_;
00427
00429 TBranch* genParticlesforJetsBranch_;
00430
00432 TBranch* caloTowerBaseCandidatesBranch_;
00433
00435 TBranch* genJetBranch_;
00436
00438 TBranch* recCaloBranch_;
00439
00441 TBranch* recPFBranch_;
00442
00443
00444
00446 reco::PFRecHitCollection rechitsECAL_;
00447
00449 reco::PFRecHitCollection rechitsHCAL_;
00450
00452 reco::PFRecHitCollection rechitsPS_;
00453
00455 std::auto_ptr< reco::PFClusterCollection > clustersECAL_;
00456
00458 std::auto_ptr< reco::PFClusterCollection > clustersHCAL_;
00459
00461 std::auto_ptr< reco::PFClusterCollection > clustersPS_;
00462
00464 std::vector<reco::BasicCluster> clustersIslandBarrel_;
00465
00467 CaloTowerCollection caloTowers_;
00468
00472 reco::CandidatePtrVector caloTowersPtrs_;
00473
00475 reco::PFRecTrackCollection recTracks_;
00476
00478 reco::GsfPFRecTrackCollection gsfrecTracks_;
00479
00481 reco::TrackCollection stdTracks_;
00482
00484 reco::MuonCollection muons_;
00485
00487 reco::PFNuclearInteractionCollection nuclear_;
00488
00490 reco::PFConversionCollection conversion_;
00491
00493 reco::PFV0Collection v0_;
00494
00496 reco::PFSimParticleCollection trueParticles_;
00497
00499 edm::HepMCProduct MCTruth_;
00500
00502 std::auto_ptr< reco::PFBlockCollection > pfBlocks_;
00503
00505 std::auto_ptr< reco::PFCandidateCollection > pfCandidates_;
00506
00511 reco::CandidatePtrVector pfCandidatesPtrs_;
00512
00514 reco::GenParticleRefVector genParticlesforJets_;
00515
00519 reco::CandidatePtrVector genParticlesforJetsPtrs_;
00520
00521
00522
00523
00525 reco::PFJetCollection pfJets_;
00526
00528 reco::GenJetCollection genJets_;
00529
00531 std::vector<ProtoJet> caloJets_;
00532
00534 reco::PFJetCollection pfJetsCMSSW_;
00535
00537 reco::GenJetCollection genJetsCMSSW_;
00538
00540 std::vector<reco::CaloJet> caloJetsCMSSW_;
00542 TFile* file_;
00543
00545 std::string inFileName_;
00546
00548 TFile* outFile_;
00549
00551 std::string outFileName_;
00552
00553
00554
00557 PFClusterAlgo clusterAlgoECAL_;
00558
00560 PFClusterAlgo clusterAlgoHCAL_;
00561
00563 PFClusterAlgo clusterAlgoPS_;
00564
00565
00567 PFBlockAlgo pfBlockAlgo_;
00568
00570 PFAlgo pfAlgo_;
00571
00573 PFJetBenchmark PFJetBenchmark_;
00574
00577 PFJetAlgorithm jetAlgo_;
00578
00580 FWLiteJetProducer jetMaker_;
00581
00582
00583
00584
00586 bool printRecHits_;
00587
00589 bool printClusters_;
00590
00592 bool printPFBlocks_;
00593
00595 bool printPFCandidates_;
00596
00598 bool printPFJets_;
00599
00601 bool printSimParticles_;
00602
00604 bool printGenParticles_;
00605
00606
00607 bool printMCTruthMatching_;
00608
00610 int verbosity_;
00611
00612
00613
00614 unsigned filterNParticles_;
00615
00616 bool filterHadronicTaus_;
00617
00618 std::vector<int> filterTaus_;
00619
00620
00621
00624 bool doClustering_;
00625
00627 bool doParticleFlow_;
00628
00630 bool doJets_;
00631
00633 int jetAlgoType_;
00634
00636 bool doTauBenchmark_;
00637
00639 bool tauBenchmarkDebug_;
00640
00642 bool doPFJetBenchmark_;
00643
00645 bool debug_;
00646
00648 bool findRecHitNeighbours_;
00649
00650
00652 bool jetsDebug_;
00653
00654
00656 bool fastsim_;
00657
00659 bool useNuclear_;
00660
00662 bool useConversions_;
00663
00665 bool useV0_;
00666
00667
00668
00672
00673
00674 };
00675 #endif