00001 #include "DataFormats/Common/interface/OrphanHandle.h"
00002 #include "DataFormats/Provenance/interface/ProductID.h"
00003 #include "DataFormats/Common/interface/RefToPtr.h"
00004
00005 #include "DataFormats/Math/interface/LorentzVector.h"
00006 #include "DataFormats/Math/interface/Point3D.h"
00007
00008 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
00009
00010 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00011 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
00012
00013 #include "DataFormats/FWLite/interface/ChainEvent.h"
00014
00015 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterAlgo.h"
00016 #include "RecoParticleFlow/PFTracking/interface/PFGeometry.h"
00017
00018 #include "RecoParticleFlow/PFRootEvent/interface/PFRootEventManager.h"
00019
00020 #include "RecoParticleFlow/PFRootEvent/interface/IO.h"
00021
00022 #include "RecoParticleFlow/PFRootEvent/interface/PFJetAlgorithm.h"
00023 #include "RecoParticleFlow/PFRootEvent/interface/JetMaker.h"
00024
00025 #include "RecoParticleFlow/PFRootEvent/interface/Utils.h"
00026 #include "RecoParticleFlow/PFRootEvent/interface/EventColin.h"
00027 #include "RecoParticleFlow/PFRootEvent/interface/METManager.h"
00028
00029 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h"
00030 #include "RecoParticleFlow/PFClusterTools/interface/PFSCEnergyCalibration.h"
00031 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibrationHF.h"
00032 #include "RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h"
00033 #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyResolution.h"
00034
00035 #include "FWCore/ServiceRegistry/interface/Service.h"
00036 #include "DQMServices/Core/interface/DQMStore.h"
00037 #include "DQMServices/Core/interface/MonitorElement.h"
00038
00039 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00040
00041 #include "TFile.h"
00042 #include "TTree.h"
00043 #include "TBranch.h"
00044 #include "TCutG.h"
00045 #include "TVector3.h"
00046 #include "TROOT.h"
00047
00048 #include <iostream>
00049 #include <vector>
00050 #include <cstdlib>
00051
00052 using namespace std;
00053
00054 using namespace reco;
00055
00056 using boost::shared_ptr;
00057
00058 PFRootEventManager::PFRootEventManager() {}
00059
00060
00061
00062 PFRootEventManager::PFRootEventManager(const char* file)
00063 :
00064 iEvent_(0),
00065 options_(0),
00066 ev_(0),
00067 tree_(0),
00068 outTree_(0),
00069 outEvent_(0),
00070
00071 eventAuxiliary_( new edm::EventAuxiliary ),
00072 clustersECAL_(new reco::PFClusterCollection),
00073 clustersHCAL_(new reco::PFClusterCollection),
00074 clustersHO_(new reco::PFClusterCollection),
00075 clustersHFEM_(new reco::PFClusterCollection),
00076 clustersHFHAD_(new reco::PFClusterCollection),
00077 clustersPS_(new reco::PFClusterCollection),
00078 pfBlocks_(new reco::PFBlockCollection),
00079 pfCandidates_(new reco::PFCandidateCollection),
00080 pfCandidateElectronExtras_(new reco::PFCandidateElectronExtraCollection),
00081
00082 outFile_(0),
00083 calibFile_(0)
00084 {
00085
00086
00087
00088 h_deltaETvisible_MCEHT_
00089 = new TH1F("h_deltaETvisible_MCEHT","Jet Et difference CaloTowers-MC"
00090 ,1000,-50.,50.);
00091 h_deltaETvisible_MCPF_
00092 = new TH1F("h_deltaETvisible_MCPF" ,"Jet Et difference ParticleFlow-MC"
00093 ,1000,-50.,50.);
00094
00095 readOptions(file, true, true);
00096
00097 initializeEventInformation();
00098
00099
00100
00101
00102 }
00103
00104
00105 void PFRootEventManager::initializeEventInformation() {
00106
00107 unsigned int nev = ev_->size();
00108 for ( unsigned int entry = 0; entry < nev; ++entry ) {
00109 ev_->to(entry);
00110 const edm::EventBase& iEv = *ev_;
00111 mapEventToEntry_[iEv.id().run()][iEv.id().luminosityBlock()][iEv.id().event()] = entry;
00112 }
00113
00114 cout<<"Number of events: "<< nev
00115 <<" starting with event: "<<mapEventToEntry_.begin()->first<<endl;
00116 }
00117
00118
00119 void PFRootEventManager::reset() {
00120
00121 if(outEvent_) {
00122 outEvent_->reset();
00123 outTree_->GetBranch("event")->SetAddress(&outEvent_);
00124 }
00125
00126 if ( ev_ && ev_->isValid() )
00127 ev_->getTFile()->cd();
00128 }
00129
00130
00131
00132 void PFRootEventManager::readOptions(const char* file,
00133 bool refresh,
00134 bool reconnect) {
00135
00136 readSpecificOptions(file);
00137
00138 cout<<"calling PFRootEventManager::readOptions"<<endl;
00139
00140
00141 reset();
00142
00143 PFGeometry pfGeometry;
00144
00145
00146
00147 try {
00148 if( !options_ )
00149 options_ = new IO(file);
00150 else if( refresh) {
00151 delete options_;
00152 options_ = new IO(file);
00153 }
00154 }
00155 catch( const string& err ) {
00156 cout<<err<<endl;
00157 return;
00158 }
00159
00160
00161 debug_ = false;
00162 options_->GetOpt("rootevent", "debug", debug_);
00163
00164
00165
00166 string calibfilename;
00167 options_->GetOpt("calib","outfile",calibfilename);
00168 if (!calibfilename.empty()) {
00169 calibFile_ = new std::ofstream(calibfilename.c_str());
00170 std::cout << "Calib file name " << calibfilename << " " << calibfilename.c_str() << std::endl;
00171 }
00172
00173
00174
00175
00176 if(!outFile_) {
00177 string outfilename;
00178 options_->GetOpt("root","outfile", outfilename);
00179 bool doOutTree = false;
00180 options_->GetOpt("root","outtree", doOutTree);
00181 if(doOutTree) {
00182 if(!outfilename.empty() ) {
00183 outFile_ = TFile::Open(outfilename.c_str(), "recreate");
00184
00185 outFile_->cd();
00186
00187
00188
00189 outEvent_ = new EventColin();
00190 outTree_ = new TTree("Eff","");
00191 outTree_->Branch("event","EventColin", &outEvent_,32000,2);
00192 }
00193
00194 }
00195 }
00196
00197
00198 doPFJetBenchmark_ = false;
00199 options_->GetOpt("pfjet_benchmark", "on/off", doPFJetBenchmark_);
00200
00201 if (doPFJetBenchmark_) {
00202 string outjetfilename;
00203 options_->GetOpt("pfjet_benchmark", "outjetfile", outjetfilename);
00204
00205 bool pfjBenchmarkDebug;
00206 options_->GetOpt("pfjet_benchmark", "debug", pfjBenchmarkDebug);
00207
00208 bool plotAgainstReco=0;
00209 options_->GetOpt("pfjet_benchmark", "plotAgainstReco", plotAgainstReco);
00210
00211 bool onlyTwoJets=1;
00212 options_->GetOpt("pfjet_benchmark", "onlyTwoJets", onlyTwoJets);
00213
00214 double deltaRMax=0.1;
00215 options_->GetOpt("pfjet_benchmark", "deltaRMax", deltaRMax);
00216
00217 fastsim_=true;
00218 options_->GetOpt("Simulation","Fast",fastsim_);
00219
00220 PFJetBenchmark_.setup( outjetfilename,
00221 pfjBenchmarkDebug,
00222 plotAgainstReco,
00223 onlyTwoJets,
00224 deltaRMax );
00225 }
00226
00227
00228
00229 doPFMETBenchmark_ = false;
00230 options_->GetOpt("pfmet_benchmark", "on/off", doPFMETBenchmark_);
00231
00232 if (doPFMETBenchmark_) {
00233
00234
00235 doMet_ = false;
00236 options_->GetOpt("MET", "on/off", doMet_);
00237
00238 JECinCaloMet_ = false;
00239 options_->GetOpt("pfmet_benchmark", "JECinCaloMET", JECinCaloMet_);
00240
00241 std::string outmetfilename;
00242 options_->GetOpt("pfmet_benchmark", "outmetfile", outmetfilename);
00243
00244
00245 metManager_.reset( new METManager(outmetfilename) );
00246 metManager_->addGenBenchmark("PF");
00247 metManager_->addGenBenchmark("Calo");
00248 if ( doMet_ ) metManager_->addGenBenchmark("recompPF");
00249 if (JECinCaloMet_) metManager_->addGenBenchmark("corrCalo");
00250
00251 bool pfmetBenchmarkDebug;
00252 options_->GetOpt("pfmet_benchmark", "debug", pfmetBenchmarkDebug);
00253
00254 MET1cut = 10.0;
00255 options_->GetOpt("pfmet_benchmark", "truemetcut", MET1cut);
00256
00257 DeltaMETcut = 30.0;
00258 options_->GetOpt("pfmet_benchmark", "deltametcut", DeltaMETcut);
00259
00260 DeltaPhicut = 0.8;
00261 options_->GetOpt("pfmet_benchmark", "deltaphicut", DeltaPhicut);
00262
00263
00264 std::vector<unsigned int> vIgnoreParticlesIDs;
00265 options_->GetOpt("pfmet_benchmark", "trueMetIgnoreParticlesIDs", vIgnoreParticlesIDs);
00266
00267
00268 metManager_->SetIgnoreParticlesIDs(&vIgnoreParticlesIDs);
00269
00270 std::vector<unsigned int> trueMetSpecificIdCut;
00271 std::vector<double> trueMetSpecificEtaCut;
00272 options_->GetOpt("pfmet_benchmark", "trueMetSpecificIdCut", trueMetSpecificIdCut);
00273 options_->GetOpt("pfmet_benchmark", "trueMetSpecificEtaCut", trueMetSpecificEtaCut);
00274 if (trueMetSpecificIdCut.size()!=trueMetSpecificEtaCut.size()) std::cout << "Warning: PFRootEventManager: trueMetSpecificIdCut.size()!=trueMetSpecificEtaCut.size()" << std::endl;
00275 else metManager_->SetSpecificIdCut(&trueMetSpecificIdCut,&trueMetSpecificEtaCut);
00276
00277 }
00278
00279 doPFCandidateBenchmark_ = true;
00280 options_->GetOpt("pfCandidate_benchmark", "on/off", doPFCandidateBenchmark_);
00281 if (doPFCandidateBenchmark_) {
00282 cout<<"+++ Setting PFCandidate benchmark"<<endl;
00283 TDirectory* dir = outFile_->mkdir("DQMData");
00284 dir = dir->mkdir("PFTask");
00285 dir = dir->mkdir("particleFlowManager");
00286 pfCandidateManager_.setDirectory( dir );
00287
00288 float dRMax = 0.5;
00289 options_->GetOpt("pfCandidate_benchmark", "dRMax", dRMax);
00290 float ptMin = 2;
00291 options_->GetOpt("pfCandidate_benchmark", "ptMin", ptMin);
00292 bool matchCharge = true;
00293 options_->GetOpt("pfCandidate_benchmark", "matchCharge", matchCharge);
00294 int mode = static_cast<int>(Benchmark::DEFAULT);
00295 options_->GetOpt("pfCandidate_benchmark", "mode", mode);
00296
00297 pfCandidateManager_.setParameters( dRMax, matchCharge,
00298 static_cast<Benchmark::Mode>(mode));
00299 pfCandidateManager_.setRange( ptMin, 10e5, -4.5, 4.5, -10, 10);
00300 pfCandidateManager_.setup();
00301
00302 cout<<"+++ Done "<<endl;
00303 }
00304
00305 doPFDQM_ = true;
00306 options_->GetOpt("pfDQM_monitor", "on/off", doPFDQM_);
00307
00308 if (doPFDQM_) {
00309 cout<<"+++ Setting PFDQM Monitoring " <<endl;
00310 string dqmfilename;
00311 dqmFile_ = 0;
00312 options_->GetOpt("pfDQM_monitor","DQMFilename", dqmfilename);
00313 dqmFile_ = TFile::Open(dqmfilename.c_str(), "recreate");
00314
00315 TDirectory* dir = dqmFile_->mkdir("DQMData");
00316 TDirectory* dir1 = dir->mkdir("PFJetValidation");
00317 TDirectory* dir2 = dir->mkdir("PFMETValidation");
00318 pfJetMonitor_.setDirectory( dir1 );
00319 pfMETMonitor_.setDirectory( dir2 );
00320 float dRMax = 0.5;
00321 options_->GetOpt("pfCandidate_benchmark", "dRMax", dRMax);
00322 float ptMin = 2;
00323 options_->GetOpt("pfCandidate_benchmark", "ptMin", ptMin);
00324 bool matchCharge = true;
00325 options_->GetOpt("pfCandidate_benchmark", "matchCharge", matchCharge);
00326 int mode = static_cast<int>(Benchmark::DEFAULT);
00327 options_->GetOpt("pfCandidate_benchmark", "mode", mode);
00328
00329 pfJetMonitor_.setParameters( dRMax, matchCharge, static_cast<Benchmark::Mode>(mode),
00330 ptMin, 10e5, -4.5, 4.5, -10.0, 10.0, false);
00331 pfJetMonitor_.setup();
00332
00333 pfMETMonitor_.setParameters( static_cast<Benchmark::Mode>(mode),
00334 ptMin, 10e5, -4.5, 4.5, -10.0, 10.0, false);
00335 pfMETMonitor_.setup();
00336 }
00337
00338
00339
00340 std::string outputFile0;
00341 TFile* file0 = 0;
00342 TH2F* hBNeighbour0 = 0;
00343 TH2F* hENeighbour0 = 0;
00344 options_->GetOpt("clustering", "ECAL", outputFile0);
00345 if(!outputFile0.empty() ) {
00346 file0 = TFile::Open(outputFile0.c_str(),"recreate");
00347 hBNeighbour0 = new TH2F("BNeighbour0","f_{Neighbours} vs 1/E_{Seed} (ECAL Barrel)",500, 0., 0.5, 1000,0.,1.);
00348 hENeighbour0 = new TH2F("ENeighbour0","f_{Neighbours} vs 1/E_{Seed} (ECAL Endcap)",500, 0., 0.2, 1000,0.,1.);
00349 }
00350
00351 std::string outputFile1;
00352 TFile* file1 = 0;
00353 TH2F* hBNeighbour1 = 0;
00354 TH2F* hENeighbour1 = 0;
00355 options_->GetOpt("clustering", "HCAL", outputFile1);
00356 if(!outputFile1.empty() ) {
00357 file1 = TFile::Open(outputFile1.c_str(),"recreate");
00358 hBNeighbour1 = new TH2F("BNeighbour1","f_{Neighbours} vs 1/E_{Seed} (HCAL Barrel)",500, 0., 0.05, 400,0.,1.);
00359 hENeighbour1 = new TH2F("ENeighbour1","f_{Neighbours} vs 1/E_{Seed} (HCAL Endcap)",500, 0., 0.05, 400,0.,1.);
00360 }
00361
00362 std::string outputFile2;
00363 TFile* file2 = 0;
00364 TH2F* hBNeighbour2 = 0;
00365 TH2F* hENeighbour2 = 0;
00366 options_->GetOpt("clustering", "HFEM", outputFile2);
00367 if(!outputFile2.empty() ) {
00368 file2 = TFile::Open(outputFile2.c_str(),"recreate");
00369 hBNeighbour2 = new TH2F("BNeighbour2","f_{Neighbours} vs 1/E_{Seed} (HFEM Barrel)",500, 0., 0.02, 400,0.,1.);
00370 hENeighbour2 = new TH2F("ENeighbour2","f_{Neighbours} vs 1/E_{Seed} (HFEM Endcap)",500, 0., 0.02, 400,0.,1.);
00371 }
00372
00373 std::string outputFile3;
00374 TFile* file3 = 0;
00375 TH2F* hBNeighbour3 = 0;
00376 TH2F* hENeighbour3 = 0;
00377 options_->GetOpt("clustering", "HFHAD", outputFile3);
00378 if(!outputFile3.empty() ) {
00379 file3 = TFile::Open(outputFile3.c_str(),"recreate");
00380 hBNeighbour3 = new TH2F("BNeighbour3","f_{Neighbours} vs 1/E_{Seed} (HFHAD Barrel)",500, 0., 0.02, 400,0.,1.);
00381 hENeighbour3 = new TH2F("ENeighbour3","f_{Neighbours} vs 1/E_{Seed} (HFHAD Endcap)",500, 0., 0.02, 400,0.,1.);
00382 }
00383
00384 std::string outputFile4;
00385 TFile* file4 = 0;
00386 TH2F* hBNeighbour4 = 0;
00387 TH2F* hENeighbour4 = 0;
00388 options_->GetOpt("clustering", "Preshower", outputFile4);
00389 if(!outputFile4.empty() ) {
00390 file4 = TFile::Open(outputFile4.c_str(),"recreate");
00391 hBNeighbour4 = new TH2F("BNeighbour4","f_{Neighbours} vs 1/E_{Seed} (Preshower Barrel)",200, 0., 1000., 400,0.,1.);
00392 hENeighbour4 = new TH2F("ENeighbour4","f_{Neighbours} vs 1/E_{Seed} (Preshower Endcap)",200, 0., 1000., 400,0.,1.);
00393 }
00394
00395
00396
00397 if( reconnect )
00398 connect();
00399
00400
00401
00402 filterNParticles_ = 0;
00403 options_->GetOpt("filter", "nparticles", filterNParticles_);
00404
00405 filterHadronicTaus_ = true;
00406 options_->GetOpt("filter", "hadronic_taus", filterHadronicTaus_);
00407
00408 filterTaus_.clear();
00409 options_->GetOpt("filter", "taus", filterTaus_);
00410 if( !filterTaus_.empty() &&
00411 filterTaus_.size() != 2 ) {
00412 cerr<<"PFRootEventManager::ReadOptions, bad filter/taus option."<<endl
00413 <<"please use : "<<endl
00414 <<"\tfilter taus n_charged n_neutral"<<endl;
00415 filterTaus_.clear();
00416 }
00417
00418
00419
00420
00421
00422 double threshold_R0=0.4;
00423 options_->GetOpt("clustering", "threshold_Hit_R0", threshold_R0);
00424
00425 double threshold_R1=1.0;
00426 options_->GetOpt("clustering", "threshold_Hit_R1", threshold_R1);
00427
00428
00429 double threshHO_Seed_Ring0=1.0;
00430 options_->GetOpt("clustering", "threshHO_Seed_Ring0", threshHO_Seed_Ring0);
00431
00432 double threshHO_Ring0=0.5;
00433 options_->GetOpt("clustering", "threshHO_Ring0", threshHO_Ring0);
00434
00435 double threshHO_Seed_Outer=3.1;
00436 options_->GetOpt("clustering", "threshHO_Seed_Outer", threshHO_Seed_Outer);
00437
00438 double threshHO_Outer=1.0;
00439 options_->GetOpt("clustering", "threshHO_Outer", threshHO_Outer);
00440
00441
00442 doClustering_ = true;
00443
00444
00445 bool clusteringDebug = false;
00446 options_->GetOpt("clustering", "debug", clusteringDebug );
00447
00448 findRecHitNeighbours_ = true;
00449 options_->GetOpt("clustering", "findRecHitNeighbours",
00450 findRecHitNeighbours_);
00451
00452 double threshEcalBarrel = 0.1;
00453 options_->GetOpt("clustering", "thresh_Ecal_Barrel", threshEcalBarrel);
00454
00455 double threshPtEcalBarrel = 0.0;
00456 options_->GetOpt("clustering", "thresh_Pt_Ecal_Barrel", threshPtEcalBarrel);
00457
00458 double threshSeedEcalBarrel = 0.3;
00459 options_->GetOpt("clustering", "thresh_Seed_Ecal_Barrel",
00460 threshSeedEcalBarrel);
00461
00462 double threshPtSeedEcalBarrel = 0.0;
00463 options_->GetOpt("clustering", "thresh_Pt_Seed_Ecal_Barrel",
00464 threshPtSeedEcalBarrel);
00465
00466 double threshCleanEcalBarrel = 1E5;
00467 options_->GetOpt("clustering", "thresh_Clean_Ecal_Barrel",
00468 threshCleanEcalBarrel);
00469
00470 std::vector<double> minS4S1CleanEcalBarrel;
00471 options_->GetOpt("clustering", "minS4S1_Clean_Ecal_Barrel",
00472 minS4S1CleanEcalBarrel);
00473
00474 double threshDoubleSpikeEcalBarrel = 10.;
00475 options_->GetOpt("clustering", "thresh_DoubleSpike_Ecal_Barrel",
00476 threshDoubleSpikeEcalBarrel);
00477
00478 double minS6S2DoubleSpikeEcalBarrel = 0.04;
00479 options_->GetOpt("clustering", "minS6S2_DoubleSpike_Ecal_Barrel",
00480 minS6S2DoubleSpikeEcalBarrel);
00481
00482 double threshEcalEndcap = 0.2;
00483 options_->GetOpt("clustering", "thresh_Ecal_Endcap", threshEcalEndcap);
00484
00485 double threshPtEcalEndcap = 0.0;
00486 options_->GetOpt("clustering", "thresh_Pt_Ecal_Endcap", threshPtEcalEndcap);
00487
00488 double threshSeedEcalEndcap = 0.8;
00489 options_->GetOpt("clustering", "thresh_Seed_Ecal_Endcap",
00490 threshSeedEcalEndcap);
00491
00492 double threshPtSeedEcalEndcap = 0.0;
00493 options_->GetOpt("clustering", "thresh_Pt_Seed_Ecal_Endcap",
00494 threshPtSeedEcalEndcap);
00495
00496 double threshCleanEcalEndcap = 1E5;
00497 options_->GetOpt("clustering", "thresh_Clean_Ecal_Endcap",
00498 threshCleanEcalEndcap);
00499
00500 std::vector<double> minS4S1CleanEcalEndcap;
00501 options_->GetOpt("clustering", "minS4S1_Clean_Ecal_Endcap",
00502 minS4S1CleanEcalEndcap);
00503
00504 double threshDoubleSpikeEcalEndcap = 1E9;
00505 options_->GetOpt("clustering", "thresh_DoubleSpike_Ecal_Endcap",
00506 threshDoubleSpikeEcalEndcap);
00507
00508 double minS6S2DoubleSpikeEcalEndcap = -1.;
00509 options_->GetOpt("clustering", "minS6S2_DoubleSpike_Ecal_Endcap",
00510 minS6S2DoubleSpikeEcalEndcap);
00511
00512 double showerSigmaEcal = 3;
00513 options_->GetOpt("clustering", "shower_Sigma_Ecal",
00514 showerSigmaEcal);
00515
00516 int nNeighboursEcal = 4;
00517 options_->GetOpt("clustering", "neighbours_Ecal", nNeighboursEcal);
00518
00519 int posCalcNCrystalEcal = -1;
00520 options_->GetOpt("clustering", "posCalc_nCrystal_Ecal",
00521 posCalcNCrystalEcal);
00522
00523 double posCalcP1Ecal
00524 = threshEcalBarrel<threshEcalEndcap ? threshEcalBarrel:threshEcalEndcap;
00525
00526
00527
00528 bool useCornerCellsEcal = false;
00529 options_->GetOpt("clustering", "useCornerCells_Ecal",
00530 useCornerCellsEcal);
00531
00532 clusterAlgoECAL_.setHistos(file0,hBNeighbour0,hENeighbour0);
00533
00534 clusterAlgoECAL_.setThreshBarrel( threshEcalBarrel );
00535 clusterAlgoECAL_.setThreshSeedBarrel( threshSeedEcalBarrel );
00536
00537 clusterAlgoECAL_.setThreshPtBarrel( threshPtEcalBarrel );
00538 clusterAlgoECAL_.setThreshPtSeedBarrel( threshPtSeedEcalBarrel );
00539
00540 clusterAlgoECAL_.setThreshCleanBarrel(threshCleanEcalBarrel);
00541 clusterAlgoECAL_.setS4S1CleanBarrel(minS4S1CleanEcalBarrel);
00542
00543 clusterAlgoECAL_.setThreshDoubleSpikeBarrel( threshDoubleSpikeEcalBarrel );
00544 clusterAlgoECAL_.setS6S2DoubleSpikeBarrel( minS6S2DoubleSpikeEcalBarrel );
00545
00546 clusterAlgoECAL_.setThreshEndcap( threshEcalEndcap );
00547 clusterAlgoECAL_.setThreshSeedEndcap( threshSeedEcalEndcap );
00548
00549 clusterAlgoECAL_.setThreshPtEndcap( threshPtEcalEndcap );
00550 clusterAlgoECAL_.setThreshPtSeedEndcap( threshPtSeedEcalEndcap );
00551
00552 clusterAlgoECAL_.setThreshCleanEndcap(threshCleanEcalEndcap);
00553 clusterAlgoECAL_.setS4S1CleanEndcap(minS4S1CleanEcalEndcap);
00554
00555 clusterAlgoECAL_.setThreshDoubleSpikeEndcap( threshDoubleSpikeEcalEndcap );
00556 clusterAlgoECAL_.setS6S2DoubleSpikeEndcap( minS6S2DoubleSpikeEcalEndcap );
00557
00558 clusterAlgoECAL_.setNNeighbours( nNeighboursEcal );
00559 clusterAlgoECAL_.setShowerSigma( showerSigmaEcal );
00560
00561 clusterAlgoECAL_.setPosCalcNCrystal( posCalcNCrystalEcal );
00562 clusterAlgoECAL_.setPosCalcP1( posCalcP1Ecal );
00563
00564 clusterAlgoECAL_.setUseCornerCells( useCornerCellsEcal );
00565
00566 clusterAlgoECAL_.enableDebugging( clusteringDebug );
00567
00568 int dcormode = 0;
00569 options_->GetOpt("clustering", "depthCor_Mode", dcormode);
00570
00571 double dcora = -1;
00572 options_->GetOpt("clustering", "depthCor_A", dcora);
00573 double dcorb = -1;
00574 options_->GetOpt("clustering", "depthCor_B", dcorb);
00575 double dcorap = -1;
00576 options_->GetOpt("clustering", "depthCor_A_preshower", dcorap);
00577 double dcorbp = -1;
00578 options_->GetOpt("clustering", "depthCor_B_preshower", dcorbp);
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588 reco::PFCluster::setDepthCorParameters( dcormode,
00589 dcora, dcorb,
00590 dcorap, dcorbp);
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600 double threshHcalBarrel = 0.8;
00601 options_->GetOpt("clustering", "thresh_Hcal_Barrel", threshHcalBarrel);
00602
00603 double threshPtHcalBarrel = 0.0;
00604 options_->GetOpt("clustering", "thresh_Pt_Hcal_Barrel", threshPtHcalBarrel);
00605
00606 double threshSeedHcalBarrel = 1.4;
00607 options_->GetOpt("clustering", "thresh_Seed_Hcal_Barrel",
00608 threshSeedHcalBarrel);
00609
00610 double threshPtSeedHcalBarrel = 0.0;
00611 options_->GetOpt("clustering", "thresh_Pt_Seed_Hcal_Barrel",
00612 threshPtSeedHcalBarrel);
00613
00614 double threshCleanHcalBarrel = 1E5;
00615 options_->GetOpt("clustering", "thresh_Clean_Hcal_Barrel",
00616 threshCleanHcalBarrel);
00617
00618 std::vector<double> minS4S1CleanHcalBarrel;
00619 options_->GetOpt("clustering", "minS4S1_Clean_Hcal_Barrel",
00620 minS4S1CleanHcalBarrel);
00621
00622 double threshHcalEndcap = 0.8;
00623 options_->GetOpt("clustering", "thresh_Hcal_Endcap", threshHcalEndcap);
00624
00625 double threshPtHcalEndcap = 0.0;
00626 options_->GetOpt("clustering", "thresh_Pt_Hcal_Endcap", threshPtHcalEndcap);
00627
00628 double threshSeedHcalEndcap = 1.4;
00629 options_->GetOpt("clustering", "thresh_Seed_Hcal_Endcap",
00630 threshSeedHcalEndcap);
00631
00632 double threshPtSeedHcalEndcap = 0.0;
00633 options_->GetOpt("clustering", "thresh_Pt_Seed_Hcal_Endcap",
00634 threshPtSeedHcalEndcap);
00635
00636 double threshCleanHcalEndcap = 1E5;
00637 options_->GetOpt("clustering", "thresh_Clean_Hcal_Endcap",
00638 threshCleanHcalEndcap);
00639
00640 std::vector<double> minS4S1CleanHcalEndcap;
00641 options_->GetOpt("clustering", "minS4S1_Clean_Hcal_Endcap",
00642 minS4S1CleanHcalEndcap);
00643
00644 double showerSigmaHcal = 15;
00645 options_->GetOpt("clustering", "shower_Sigma_Hcal",
00646 showerSigmaHcal);
00647
00648 int nNeighboursHcal = 4;
00649 options_->GetOpt("clustering", "neighbours_Hcal", nNeighboursHcal);
00650
00651 int posCalcNCrystalHcal = 5;
00652 options_->GetOpt("clustering", "posCalc_nCrystal_Hcal",
00653 posCalcNCrystalHcal);
00654
00655 bool useCornerCellsHcal = false;
00656 options_->GetOpt("clustering", "useCornerCells_Hcal",
00657 useCornerCellsHcal);
00658
00659 bool cleanRBXandHPDs = false;
00660 options_->GetOpt("clustering", "cleanRBXandHPDs_Hcal",
00661 cleanRBXandHPDs);
00662
00663 double posCalcP1Hcal
00664 = threshHcalBarrel<threshHcalEndcap ? threshHcalBarrel:threshHcalEndcap;
00665
00666
00667
00668
00669 clusterAlgoHCAL_.setHistos(file1,hBNeighbour1,hENeighbour1);
00670
00671
00672 clusterAlgoHCAL_.setThreshBarrel( threshHcalBarrel );
00673 clusterAlgoHCAL_.setThreshSeedBarrel( threshSeedHcalBarrel );
00674
00675 clusterAlgoHCAL_.setThreshPtBarrel( threshPtHcalBarrel );
00676 clusterAlgoHCAL_.setThreshPtSeedBarrel( threshPtSeedHcalBarrel );
00677
00678 clusterAlgoHCAL_.setThreshCleanBarrel(threshCleanHcalBarrel);
00679 clusterAlgoHCAL_.setS4S1CleanBarrel(minS4S1CleanHcalBarrel);
00680
00681 clusterAlgoHCAL_.setThreshEndcap( threshHcalEndcap );
00682 clusterAlgoHCAL_.setThreshSeedEndcap( threshSeedHcalEndcap );
00683
00684 clusterAlgoHCAL_.setThreshPtEndcap( threshPtHcalEndcap );
00685 clusterAlgoHCAL_.setThreshPtSeedEndcap( threshPtSeedHcalEndcap );
00686
00687 clusterAlgoHCAL_.setThreshCleanEndcap(threshCleanHcalEndcap);
00688 clusterAlgoHCAL_.setS4S1CleanEndcap(minS4S1CleanHcalEndcap);
00689
00690 clusterAlgoHCAL_.setNNeighbours( nNeighboursHcal );
00691 clusterAlgoHCAL_.setShowerSigma( showerSigmaHcal );
00692
00693 clusterAlgoHCAL_.setPosCalcNCrystal( posCalcNCrystalHcal );
00694 clusterAlgoHCAL_.setPosCalcP1( posCalcP1Hcal );
00695
00696 clusterAlgoHCAL_.setUseCornerCells( useCornerCellsHcal );
00697 clusterAlgoHCAL_.setCleanRBXandHPDs( cleanRBXandHPDs );
00698
00699 clusterAlgoHCAL_.enableDebugging( clusteringDebug );
00700
00701
00702
00703 double threshHOBarrel = 0.5;
00704 options_->GetOpt("clustering", "thresh_HO_Barrel", threshHOBarrel);
00705
00706 double threshPtHOBarrel = 0.0;
00707 options_->GetOpt("clustering", "thresh_Pt_HO_Barrel", threshPtHOBarrel);
00708
00709 double threshSeedHOBarrel = 1.0;
00710 options_->GetOpt("clustering", "thresh_Seed_HO_Barrel",
00711 threshSeedHOBarrel);
00712
00713 double threshPtSeedHOBarrel = 0.0;
00714 options_->GetOpt("clustering", "thresh_Pt_Seed_HO_Barrel",
00715 threshPtSeedHOBarrel);
00716
00717 double threshCleanHOBarrel = 1E5;
00718 options_->GetOpt("clustering", "thresh_Clean_HO_Barrel",
00719 threshCleanHOBarrel);
00720
00721 std::vector<double> minS4S1CleanHOBarrel;
00722 options_->GetOpt("clustering", "minS4S1_Clean_HO_Barrel",
00723 minS4S1CleanHOBarrel);
00724
00725 double threshDoubleSpikeHOBarrel = 1E9;
00726 options_->GetOpt("clustering", "thresh_DoubleSpike_HO_Barrel",
00727 threshDoubleSpikeHOBarrel);
00728
00729 double minS6S2DoubleSpikeHOBarrel = -1;
00730 options_->GetOpt("clustering", "minS6S2_DoubleSpike_HO_Barrel",
00731 minS6S2DoubleSpikeHOBarrel);
00732
00733 double threshHOEndcap = 1.0;
00734 options_->GetOpt("clustering", "thresh_HO_Endcap", threshHOEndcap);
00735
00736 double threshPtHOEndcap = 0.0;
00737 options_->GetOpt("clustering", "thresh_Pt_HO_Endcap", threshPtHOEndcap);
00738
00739 double threshSeedHOEndcap = 3.1;
00740 options_->GetOpt("clustering", "thresh_Seed_HO_Endcap",
00741 threshSeedHOEndcap);
00742
00743 double threshPtSeedHOEndcap = 0.0;
00744 options_->GetOpt("clustering", "thresh_Pt_Seed_HO_Endcap",
00745 threshPtSeedHOEndcap);
00746
00747 double threshCleanHOEndcap = 1E5;
00748 options_->GetOpt("clustering", "thresh_Clean_HO_Endcap",
00749 threshCleanHOEndcap);
00750
00751 std::vector<double> minS4S1CleanHOEndcap;
00752 options_->GetOpt("clustering", "minS4S1_Clean_HO_Endcap",
00753 minS4S1CleanHOEndcap);
00754
00755 double threshDoubleSpikeHOEndcap = 1E9;
00756 options_->GetOpt("clustering", "thresh_DoubleSpike_HO_Endcap",
00757 threshDoubleSpikeHOEndcap);
00758
00759 double minS6S2DoubleSpikeHOEndcap = -1;
00760 options_->GetOpt("clustering", "minS6S2_DoubleSpike_HO_Endcap",
00761 minS6S2DoubleSpikeHOEndcap);
00762
00763 double showerSigmaHO = 15;
00764 options_->GetOpt("clustering", "shower_Sigma_HO",
00765 showerSigmaHO);
00766
00767 int nNeighboursHO = 4;
00768 options_->GetOpt("clustering", "neighbours_HO", nNeighboursHO);
00769
00770 int posCalcNCrystalHO = 5;
00771 options_->GetOpt("clustering", "posCalc_nCrystal_HO",
00772 posCalcNCrystalHO);
00773
00774 bool useCornerCellsHO = false;
00775 options_->GetOpt("clustering", "useCornerCells_HO",
00776 useCornerCellsHO);
00777
00778 bool cleanRBXandHPDsHO = false;
00779 options_->GetOpt("clustering", "cleanRBXandHPDs_HO",
00780 cleanRBXandHPDsHO);
00781
00782 double posCalcP1HO
00783 = threshHOBarrel<threshHOEndcap ? threshHOBarrel:threshHOEndcap;
00784
00785
00786
00787
00788 clusterAlgoHO_.setHistos(file1,hBNeighbour1,hENeighbour1);
00789
00790
00791 clusterAlgoHO_.setThreshBarrel( threshHOBarrel );
00792 clusterAlgoHO_.setThreshSeedBarrel( threshSeedHOBarrel );
00793
00794 clusterAlgoHO_.setThreshPtBarrel( threshPtHOBarrel );
00795 clusterAlgoHO_.setThreshPtSeedBarrel( threshPtSeedHOBarrel );
00796
00797 clusterAlgoHO_.setThreshCleanBarrel(threshCleanHOBarrel);
00798 clusterAlgoHO_.setS4S1CleanBarrel(minS4S1CleanHOBarrel);
00799
00800 clusterAlgoHO_.setThreshDoubleSpikeBarrel( threshDoubleSpikeHOBarrel );
00801 clusterAlgoHO_.setS6S2DoubleSpikeBarrel( minS6S2DoubleSpikeHOBarrel );
00802
00803 clusterAlgoHO_.setThreshEndcap( threshHOEndcap );
00804 clusterAlgoHO_.setThreshSeedEndcap( threshSeedHOEndcap );
00805
00806 clusterAlgoHO_.setThreshPtEndcap( threshPtHOEndcap );
00807 clusterAlgoHO_.setThreshPtSeedEndcap( threshPtSeedHOEndcap );
00808
00809 clusterAlgoHO_.setThreshCleanEndcap(threshCleanHOEndcap);
00810 clusterAlgoHO_.setS4S1CleanEndcap(minS4S1CleanHOEndcap);
00811
00812 clusterAlgoHO_.setThreshDoubleSpikeEndcap( threshDoubleSpikeHOEndcap );
00813 clusterAlgoHO_.setS6S2DoubleSpikeEndcap( minS6S2DoubleSpikeHOEndcap );
00814
00815 clusterAlgoHO_.setNNeighbours( nNeighboursHO );
00816 clusterAlgoHO_.setShowerSigma( showerSigmaHO );
00817
00818 clusterAlgoHO_.setPosCalcNCrystal( posCalcNCrystalHO );
00819 clusterAlgoHO_.setPosCalcP1( posCalcP1HO );
00820
00821 clusterAlgoHO_.setUseCornerCells( useCornerCellsHO );
00822 clusterAlgoHO_.setCleanRBXandHPDs( cleanRBXandHPDs );
00823
00824 clusterAlgoHO_.enableDebugging( clusteringDebug );
00825
00826
00827
00828
00829 double threshHFEM = 0.;
00830 options_->GetOpt("clustering", "thresh_HFEM", threshHFEM);
00831
00832 double threshPtHFEM = 0.;
00833 options_->GetOpt("clustering", "thresh_Pt_HFEM", threshPtHFEM);
00834
00835 double threshSeedHFEM = 0.001;
00836 options_->GetOpt("clustering", "thresh_Seed_HFEM",
00837 threshSeedHFEM);
00838
00839 double threshPtSeedHFEM = 0.0;
00840 options_->GetOpt("clustering", "thresh_Pt_Seed_HFEM",
00841 threshPtSeedHFEM);
00842
00843 double threshCleanHFEM = 1E5;
00844 options_->GetOpt("clustering", "thresh_Clean_HFEM",
00845 threshCleanHFEM);
00846
00847 std::vector<double> minS4S1CleanHFEM;
00848 options_->GetOpt("clustering", "minS4S1_Clean_HFEM",
00849 minS4S1CleanHFEM);
00850
00851 double showerSigmaHFEM = 0.1;
00852 options_->GetOpt("clustering", "shower_Sigma_HFEM",
00853 showerSigmaHFEM);
00854
00855 int nNeighboursHFEM = 4;
00856 options_->GetOpt("clustering", "neighbours_HFEM", nNeighboursHFEM);
00857
00858 int posCalcNCrystalHFEM = -1;
00859 options_->GetOpt("clustering", "posCalc_nCrystal_HFEM",
00860 posCalcNCrystalHFEM);
00861
00862 bool useCornerCellsHFEM = false;
00863 options_->GetOpt("clustering", "useCornerCells_HFEM",
00864 useCornerCellsHFEM);
00865
00866 double posCalcP1HFEM = threshHFEM;
00867
00868
00869
00870
00871 clusterAlgoHFEM_.setHistos(file2,hBNeighbour2,hENeighbour2);
00872
00873 clusterAlgoHFEM_.setThreshEndcap( threshHFEM );
00874 clusterAlgoHFEM_.setThreshSeedEndcap( threshSeedHFEM );
00875
00876 clusterAlgoHFEM_.setThreshPtEndcap( threshPtHFEM );
00877 clusterAlgoHFEM_.setThreshPtSeedEndcap( threshPtSeedHFEM );
00878
00879 clusterAlgoHFEM_.setThreshCleanEndcap(threshCleanHFEM);
00880 clusterAlgoHFEM_.setS4S1CleanEndcap(minS4S1CleanHFEM);
00881
00882 clusterAlgoHFEM_.setNNeighbours( nNeighboursHFEM );
00883 clusterAlgoHFEM_.setShowerSigma( showerSigmaHFEM );
00884
00885 clusterAlgoHFEM_.setPosCalcNCrystal( posCalcNCrystalHFEM );
00886 clusterAlgoHFEM_.setPosCalcP1( posCalcP1HFEM );
00887
00888 clusterAlgoHFEM_.setUseCornerCells( useCornerCellsHFEM );
00889
00890 clusterAlgoHFEM_.enableDebugging( clusteringDebug );
00891
00892
00893
00894 double threshHFHAD = 0.;
00895 options_->GetOpt("clustering", "thresh_HFHAD", threshHFHAD);
00896
00897 double threshPtHFHAD = 0.;
00898 options_->GetOpt("clustering", "thresh_Pt_HFHAD", threshPtHFHAD);
00899
00900 double threshSeedHFHAD = 0.001;
00901 options_->GetOpt("clustering", "thresh_Seed_HFHAD",
00902 threshSeedHFHAD);
00903
00904 double threshPtSeedHFHAD = 0.0;
00905 options_->GetOpt("clustering", "thresh_Pt_Seed_HFHAD",
00906 threshPtSeedHFHAD);
00907
00908 double threshCleanHFHAD = 1E5;
00909 options_->GetOpt("clustering", "thresh_Clean_HFHAD",
00910 threshCleanHFHAD);
00911
00912 std::vector<double> minS4S1CleanHFHAD;
00913 options_->GetOpt("clustering", "minS4S1_Clean_HFHAD",
00914 minS4S1CleanHFHAD);
00915
00916 double showerSigmaHFHAD = 0.1;
00917 options_->GetOpt("clustering", "shower_Sigma_HFHAD",
00918 showerSigmaHFHAD);
00919
00920 int nNeighboursHFHAD = 4;
00921 options_->GetOpt("clustering", "neighbours_HFHAD", nNeighboursHFHAD);
00922
00923 int posCalcNCrystalHFHAD = -1;
00924 options_->GetOpt("clustering", "posCalc_nCrystal_HFHAD",
00925 posCalcNCrystalHFHAD);
00926
00927 bool useCornerCellsHFHAD = false;
00928 options_->GetOpt("clustering", "useCornerCells_HFHAD",
00929 useCornerCellsHFHAD);
00930
00931 double posCalcP1HFHAD = threshHFHAD;
00932
00933
00934
00935
00936 clusterAlgoHFHAD_.setHistos(file3,hBNeighbour3,hENeighbour3);
00937
00938 clusterAlgoHFHAD_.setThreshEndcap( threshHFHAD );
00939 clusterAlgoHFHAD_.setThreshSeedEndcap( threshSeedHFHAD );
00940
00941 clusterAlgoHFHAD_.setThreshPtEndcap( threshPtHFHAD );
00942 clusterAlgoHFHAD_.setThreshPtSeedEndcap( threshPtSeedHFHAD );
00943
00944 clusterAlgoHFHAD_.setThreshCleanEndcap(threshCleanHFHAD);
00945 clusterAlgoHFHAD_.setS4S1CleanEndcap(minS4S1CleanHFHAD);
00946
00947 clusterAlgoHFHAD_.setNNeighbours( nNeighboursHFHAD );
00948 clusterAlgoHFHAD_.setShowerSigma( showerSigmaHFHAD );
00949
00950 clusterAlgoHFHAD_.setPosCalcNCrystal( posCalcNCrystalHFHAD );
00951 clusterAlgoHFHAD_.setPosCalcP1( posCalcP1HFHAD );
00952
00953 clusterAlgoHFHAD_.setUseCornerCells( useCornerCellsHFHAD );
00954
00955 clusterAlgoHFHAD_.enableDebugging( clusteringDebug );
00956
00957
00958
00959 double threshPS = 0.0001;
00960 options_->GetOpt("clustering", "thresh_PS", threshPS);
00961
00962 double threshPtPS = 0.0;
00963 options_->GetOpt("clustering", "thresh_Pt_PS", threshPtPS);
00964
00965 double threshSeedPS = 0.001;
00966 options_->GetOpt("clustering", "thresh_Seed_PS",
00967 threshSeedPS);
00968
00969 double threshPtSeedPS = 0.0;
00970 options_->GetOpt("clustering", "thresh_Pt_Seed_PS", threshPtSeedPS);
00971
00972 double threshCleanPS = 1E5;
00973 options_->GetOpt("clustering", "thresh_Clean_PS", threshCleanPS);
00974
00975 std::vector<double> minS4S1CleanPS;
00976 options_->GetOpt("clustering", "minS4S1_Clean_PS", minS4S1CleanPS);
00977
00978
00979 double threshPSBarrel = threshPS;
00980 double threshSeedPSBarrel = threshSeedPS;
00981
00982 double threshPtPSBarrel = threshPtPS;
00983 double threshPtSeedPSBarrel = threshPtSeedPS;
00984
00985 double threshCleanPSBarrel = threshCleanPS;
00986 std::vector<double> minS4S1CleanPSBarrel = minS4S1CleanPS;
00987
00988 double threshPSEndcap = threshPS;
00989 double threshSeedPSEndcap = threshSeedPS;
00990
00991 double threshPtPSEndcap = threshPtPS;
00992 double threshPtSeedPSEndcap = threshPtSeedPS;
00993
00994 double threshCleanPSEndcap = threshCleanPS;
00995 std::vector<double> minS4S1CleanPSEndcap = minS4S1CleanPS;
00996
00997 double showerSigmaPS = 0.1;
00998 options_->GetOpt("clustering", "shower_Sigma_PS",
00999 showerSigmaPS);
01000
01001 int nNeighboursPS = 4;
01002 options_->GetOpt("clustering", "neighbours_PS", nNeighboursPS);
01003
01004 int posCalcNCrystalPS = -1;
01005 options_->GetOpt("clustering", "posCalc_nCrystal_PS",
01006 posCalcNCrystalPS);
01007
01008 bool useCornerCellsPS = false;
01009 options_->GetOpt("clustering", "useCornerCells_PS",
01010 useCornerCellsPS);
01011
01012 double posCalcP1PS = threshPS;
01013
01014
01015
01016
01017 clusterAlgoPS_.setHistos(file4,hBNeighbour4,hENeighbour4);
01018
01019
01020
01021 clusterAlgoPS_.setThreshBarrel( threshPSBarrel );
01022 clusterAlgoPS_.setThreshSeedBarrel( threshSeedPSBarrel );
01023
01024 clusterAlgoPS_.setThreshPtBarrel( threshPtPSBarrel );
01025 clusterAlgoPS_.setThreshPtSeedBarrel( threshPtSeedPSBarrel );
01026
01027 clusterAlgoPS_.setThreshCleanBarrel(threshCleanPSBarrel);
01028 clusterAlgoPS_.setS4S1CleanBarrel(minS4S1CleanPSBarrel);
01029
01030 clusterAlgoPS_.setThreshEndcap( threshPSEndcap );
01031 clusterAlgoPS_.setThreshSeedEndcap( threshSeedPSEndcap );
01032
01033 clusterAlgoPS_.setThreshPtEndcap( threshPtPSEndcap );
01034 clusterAlgoPS_.setThreshPtSeedEndcap( threshPtSeedPSEndcap );
01035
01036 clusterAlgoPS_.setThreshCleanEndcap(threshCleanPSEndcap);
01037 clusterAlgoPS_.setS4S1CleanEndcap(minS4S1CleanPSEndcap);
01038
01039 clusterAlgoPS_.setNNeighbours( nNeighboursPS );
01040 clusterAlgoPS_.setShowerSigma( showerSigmaPS );
01041
01042 clusterAlgoPS_.setPosCalcNCrystal( posCalcNCrystalPS );
01043 clusterAlgoPS_.setPosCalcP1( posCalcP1PS );
01044
01045 clusterAlgoPS_.setUseCornerCells( useCornerCellsPS );
01046
01047 clusterAlgoPS_.enableDebugging( clusteringDebug );
01048
01049
01050
01051
01052 doParticleFlow_ = true;
01053 doCompare_ = false;
01054 options_->GetOpt("particle_flow", "on/off", doParticleFlow_);
01055 options_->GetOpt("particle_flow", "comparison", doCompare_);
01056
01057 useKDTreeTrackEcalLinker_ = true;
01058 options_->GetOpt("particle_flow", "useKDTreeTrackEcalLinker", useKDTreeTrackEcalLinker_);
01059 std::cout << "Use Track-ECAL link optimization: " << useKDTreeTrackEcalLinker_ << std::endl;
01060 pfBlockAlgo_.setUseOptimization(useKDTreeTrackEcalLinker_);
01061
01062 std::vector<double> DPtovPtCut;
01063 std::vector<unsigned> NHitCut;
01064 bool useIterTracking;
01065 int nuclearInteractionsPurity;
01066 options_->GetOpt("particle_flow", "DPtoverPt_Cut", DPtovPtCut);
01067 options_->GetOpt("particle_flow", "NHit_Cut", NHitCut);
01068 options_->GetOpt("particle_flow", "useIterTracking", useIterTracking);
01069 options_->GetOpt("particle_flow", "nuclearInteractionsPurity", nuclearInteractionsPurity);
01070
01071
01072 std::vector<double> PhotonSelectionCuts;
01073 options_->GetOpt("particle_flow","useEGPhotons",useEGPhotons_);
01074 options_->GetOpt("particle_flow","photonSelection", PhotonSelectionCuts);
01075
01076 try {
01077 pfBlockAlgo_.setParameters( DPtovPtCut,
01078 NHitCut,
01079 useIterTracking,
01080 useConvBremPFRecTracks_,
01081 nuclearInteractionsPurity,
01082 useEGPhotons_,
01083 PhotonSelectionCuts);
01084 }
01085 catch( std::exception& err ) {
01086 cerr<<"exception setting PFBlockAlgo parameters: "
01087 <<err.what()<<". terminating."<<endl;
01088 delete this;
01089 exit(1);
01090 }
01091
01092
01093 bool blockAlgoDebug = false;
01094 options_->GetOpt("blockAlgo", "debug", blockAlgoDebug);
01095 pfBlockAlgo_.setDebug( blockAlgoDebug );
01096
01097 bool AlgoDebug = false;
01098 options_->GetOpt("PFAlgo", "debug", AlgoDebug);
01099 pfAlgo_.setDebug( AlgoDebug );
01100
01101
01102 boost::shared_ptr<PFEnergyCalibration>
01103 calibration( new PFEnergyCalibration() );
01104 calibration_ = calibration;
01105
01106 bool usePFSCEleCalib;
01107 std::vector<double> calibPFSCEle_Fbrem_barrel;
01108 std::vector<double> calibPFSCEle_Fbrem_endcap;
01109 std::vector<double> calibPFSCEle_barrel;
01110 std::vector<double> calibPFSCEle_endcap;
01111 options_->GetOpt("particle_flow","usePFSCEleCalib",usePFSCEleCalib);
01112 options_->GetOpt("particle_flow","calibPFSCEle_Fbrem_barrel",calibPFSCEle_Fbrem_barrel);
01113 options_->GetOpt("particle_flow","calibPFSCEle_Fbrem_endcap",calibPFSCEle_Fbrem_endcap);
01114 options_->GetOpt("particle_flow","calibPFSCEle_barrel",calibPFSCEle_barrel);
01115 options_->GetOpt("particle_flow","calibPFSCEle_endcap",calibPFSCEle_endcap);
01116 boost::shared_ptr<PFSCEnergyCalibration>
01117 thePFSCEnergyCalibration (new PFSCEnergyCalibration(calibPFSCEle_Fbrem_barrel,calibPFSCEle_Fbrem_endcap,
01118 calibPFSCEle_barrel,calibPFSCEle_endcap ));
01119
01120 bool useEGammaSupercluster;
01121 double sumEtEcalIsoForEgammaSC_barrel;
01122 double sumEtEcalIsoForEgammaSC_endcap;
01123 double coneEcalIsoForEgammaSC;
01124 double sumPtTrackIsoForEgammaSC_barrel;
01125 double sumPtTrackIsoForEgammaSC_endcap;
01126 unsigned int nTrackIsoForEgammaSC;
01127 double coneTrackIsoForEgammaSC;
01128 options_->GetOpt("particle_flow","useEGammaSupercluster",useEGammaSupercluster);
01129 options_->GetOpt("particle_flow","sumEtEcalIsoForEgammaSC_barrel",sumEtEcalIsoForEgammaSC_barrel);
01130 options_->GetOpt("particle_flow","sumEtEcalIsoForEgammaSC_endcap",sumEtEcalIsoForEgammaSC_endcap);
01131 options_->GetOpt("particle_flow","coneEcalIsoForEgammaSC",coneEcalIsoForEgammaSC);
01132 options_->GetOpt("particle_flow","sumPtTrackIsoForEgammaSC_barrel",sumPtTrackIsoForEgammaSC_barrel);
01133 options_->GetOpt("particle_flow","sumPtTrackIsoForEgammaSC_endcap",sumPtTrackIsoForEgammaSC_endcap);
01134 options_->GetOpt("particle_flow","nTrackIsoForEgammaSC",nTrackIsoForEgammaSC);
01135 options_->GetOpt("particle_flow","coneTrackIsoForEgammaSC",coneTrackIsoForEgammaSC);
01136 options_->GetOpt("particle_flow","useEGammaElectrons",useEGElectrons_);
01137
01138
01139 bool calibHF_use = false;
01140 std::vector<double> calibHF_eta_step;
01141 std::vector<double> calibHF_a_EMonly;
01142 std::vector<double> calibHF_b_HADonly;
01143 std::vector<double> calibHF_a_EMHAD;
01144 std::vector<double> calibHF_b_EMHAD;
01145
01146 options_->GetOpt("particle_flow","calib_calibHF_use",calibHF_use);
01147 options_->GetOpt("particle_flow","calib_calibHF_eta_step",calibHF_eta_step);
01148 options_->GetOpt("particle_flow","calib_calibHF_a_EMonly",calibHF_a_EMonly);
01149 options_->GetOpt("particle_flow","calib_calibHF_b_HADonly",calibHF_b_HADonly);
01150 options_->GetOpt("particle_flow","calib_calibHF_a_EMHAD",calibHF_a_EMHAD);
01151 options_->GetOpt("particle_flow","calib_calibHF_b_EMHAD",calibHF_b_EMHAD);
01152
01153 boost::shared_ptr<PFEnergyCalibrationHF> thepfEnergyCalibrationHF
01154 ( new PFEnergyCalibrationHF(calibHF_use,calibHF_eta_step,calibHF_a_EMonly,calibHF_b_HADonly,calibHF_a_EMHAD,calibHF_b_EMHAD) ) ;
01155
01156 thepfEnergyCalibrationHF_ = thepfEnergyCalibrationHF;
01157
01158
01159
01160 double nSigmaECAL = 99999;
01161 options_->GetOpt("particle_flow", "nsigma_ECAL", nSigmaECAL);
01162 double nSigmaHCAL = 99999;
01163 options_->GetOpt("particle_flow", "nsigma_HCAL", nSigmaHCAL);
01164
01165 try {
01166 pfAlgo_.setParameters( nSigmaECAL, nSigmaHCAL,
01167 calibration, thepfEnergyCalibrationHF_);
01168 }
01169 catch( std::exception& err ) {
01170 cerr<<"exception setting PFAlgo parameters: "
01171 <<err.what()<<". terminating."<<endl;
01172 delete this;
01173 exit(1);
01174 }
01175
01176 std::vector<double> muonHCAL;
01177 std::vector<double> muonECAL;
01178 std::vector<double> muonHO;
01179 options_->GetOpt("particle_flow", "muon_HCAL", muonHCAL);
01180 options_->GetOpt("particle_flow", "muon_ECAL", muonECAL);
01181 options_->GetOpt("particle_flow", "muon_HO", muonHO);
01182
01183 assert ( muonHCAL.size() == 2 && muonECAL.size() == 2 && muonHO.size() == 2);
01184
01185 double nSigmaTRACK = 3.0;
01186 options_->GetOpt("particle_flow", "nsigma_TRACK", nSigmaTRACK);
01187
01188 double ptError = 1.0;
01189 options_->GetOpt("particle_flow", "pt_error", ptError);
01190
01191 std::vector<double> factors45;
01192 options_->GetOpt("particle_flow", "factors_45", factors45);
01193 assert ( factors45.size() == 2 );
01194
01195 bool usePFMuonMomAssign = false;
01196 options_->GetOpt("particle_flow", "usePFMuonMomAssign", usePFMuonMomAssign);
01197
01198 bool useBestMuonTrack = false;
01199 options_->GetOpt("particle_flow", "useBestMuonTrack", useBestMuonTrack);
01200
01201 try {
01202 pfAlgo_.setPFMuonAndFakeParameters(muonHCAL,
01203 muonECAL,
01204 muonHO,
01205 nSigmaTRACK,
01206 ptError,
01207 factors45,
01208 usePFMuonMomAssign,
01209 useBestMuonTrack);
01210 }
01211 catch( std::exception& err ) {
01212 cerr<<"exception setting PFAlgo Muon and Fake parameters: "
01213 <<err.what()<<". terminating."<<endl;
01214 delete this;
01215 exit(1);
01216 }
01217
01218 bool postHFCleaning = true;
01219 options_->GetOpt("particle_flow", "postHFCleaning", postHFCleaning);
01220 double minHFCleaningPt = 5.;
01221 options_->GetOpt("particle_flow", "minHFCleaningPt", minHFCleaningPt);
01222 double minSignificance = 2.5;
01223 options_->GetOpt("particle_flow", "minSignificance", minSignificance);
01224 double maxSignificance = 2.5;
01225 options_->GetOpt("particle_flow", "maxSignificance", maxSignificance);
01226 double minSignificanceReduction = 1.4;
01227 options_->GetOpt("particle_flow", "minSignificanceReduction", minSignificanceReduction);
01228 double maxDeltaPhiPt = 7.0;
01229 options_->GetOpt("particle_flow", "maxDeltaPhiPt", maxDeltaPhiPt);
01230 double minDeltaMet = 0.4;
01231 options_->GetOpt("particle_flow", "minDeltaMet", minDeltaMet);
01232
01233
01234 try {
01235 pfAlgo_.setPostHFCleaningParameters(postHFCleaning,
01236 minHFCleaningPt,
01237 minSignificance,
01238 maxSignificance,
01239 minSignificanceReduction,
01240 maxDeltaPhiPt,
01241 minDeltaMet);
01242 }
01243 catch( std::exception& err ) {
01244 cerr<<"exception setting post HF cleaning parameters: "
01245 <<err.what()<<". terminating."<<endl;
01246 delete this;
01247 exit(1);
01248 }
01249
01250 useAtHLT_ = false;
01251 options_->GetOpt("particle_flow", "useAtHLT", useAtHLT_);
01252 cout<<"use HLT tracking "<<useAtHLT_<<endl;
01253
01254 useHO_ = true;
01255 options_->GetOpt("particle_flow", "useHO", useHO_);
01256 cout<<"use of HO "<<useHO_<<endl;
01257
01258
01259 usePFElectrons_ = false;
01260 options_->GetOpt("particle_flow", "usePFElectrons", usePFElectrons_);
01261 cout<<"use PFElectrons "<<usePFElectrons_<<endl;
01262
01263 if( usePFElectrons_ ) {
01264
01265 double mvaEleCut = -1.;
01266 options_->GetOpt("particle_flow", "electron_mvaCut", mvaEleCut);
01267
01268 bool applyCrackCorrections=true;
01269 options_->GetOpt("particle_flow","electron_crackCorrection",applyCrackCorrections);
01270
01271 string mvaWeightFileEleID = "";
01272 options_->GetOpt("particle_flow", "electronID_mvaWeightFile",
01273 mvaWeightFileEleID);
01274 mvaWeightFileEleID = expand(mvaWeightFileEleID);
01275
01276 std::string egammaElectronstagname;
01277 options_->GetOpt("particle_flow","egammaElectrons",egammaElectronstagname);
01278 egammaElectronsTag_ = edm::InputTag(egammaElectronstagname);
01279
01280
01281 pfBlockAlgo_.setHOTag(useHO_);
01282 pfAlgo_.setHOTag(useHO_);
01283
01284 try {
01285 pfAlgo_.setPFEleParameters(mvaEleCut,
01286 mvaWeightFileEleID,
01287 usePFElectrons_,
01288 thePFSCEnergyCalibration,
01289 calibration,
01290 sumEtEcalIsoForEgammaSC_barrel,
01291 sumEtEcalIsoForEgammaSC_endcap,
01292 coneEcalIsoForEgammaSC,
01293 sumPtTrackIsoForEgammaSC_barrel,
01294 sumPtTrackIsoForEgammaSC_endcap,
01295 nTrackIsoForEgammaSC,
01296 coneTrackIsoForEgammaSC,
01297 applyCrackCorrections,
01298 usePFSCEleCalib,
01299 useEGElectrons_,
01300 useEGammaSupercluster);
01301 }
01302 catch( std::exception& err ) {
01303 cerr<<"exception setting PFAlgo Electron parameters: "
01304 <<err.what()<<". terminating."<<endl;
01305 delete this;
01306 exit(1);
01307 }
01308 }
01309
01310 bool usePFPhotons = true;
01311 bool useReg=false;
01312 string mvaWeightFileConvID = "";
01313 string mvaWeightFileRegLC="";
01314 string mvaWeightFileRegGC="";
01315 string mvaWeightFileRegRes="";
01316 string X0Map="";
01317 double mvaConvCut=-1.;
01318 double sumPtTrackIsoForPhoton=2.0;
01319 double sumPtTrackIsoSlopeForPhoton=0.001;
01320 options_->GetOpt("particle_flow", "usePFPhotons", usePFPhotons);
01321 options_->GetOpt("particle_flow", "conv_mvaCut", mvaConvCut);
01322 options_->GetOpt("particle_flow", "useReg", useReg);
01323 options_->GetOpt("particle_flow", "convID_mvaWeightFile", mvaWeightFileConvID);
01324 options_->GetOpt("particle_flow", "mvaWeightFileRegLC", mvaWeightFileRegLC);
01325 options_->GetOpt("particle_flow", "mvaWeightFileRegGC", mvaWeightFileRegGC);
01326 options_->GetOpt("particle_flow", "mvaWeightFileRegRes", mvaWeightFileRegRes);
01327 options_->GetOpt("particle_flow", "X0Map", X0Map);
01328 options_->GetOpt("particle_flow","sumPtTrackIsoForPhoton",sumPtTrackIsoForPhoton);
01329 options_->GetOpt("particle_flow","sumPtTrackIsoSlopeForPhoton",sumPtTrackIsoSlopeForPhoton);
01330
01331
01332 if( usePFPhotons ) {
01333
01334 TFile *fgbr = new TFile(mvaWeightFileRegGC.c_str(),"READ");
01335 const GBRForest * ReaderGC =(const GBRForest*)fgbr->Get("GBRForest");
01336 TFile *fgbr2 = new TFile(mvaWeightFileRegLC.c_str(),"READ");
01337 const GBRForest* ReaderLC = (const GBRForest*)fgbr2->Get("GBRForest");
01338 TFile *fgbr3 = new TFile(mvaWeightFileRegRes.c_str(),"READ");
01339 const GBRForest* ReaderRes = (const GBRForest*)fgbr3->Get("GBRForest");
01340 try {
01341 pfAlgo_.setPFPhotonParameters
01342 (usePFPhotons,
01343 mvaWeightFileConvID,
01344 mvaConvCut,
01345 useReg,
01346 X0Map,
01347 calibration,
01348 sumPtTrackIsoForPhoton,
01349 sumPtTrackIsoSlopeForPhoton
01350 );
01351 pfAlgo_.setPFPhotonRegWeights(ReaderLC, ReaderGC, ReaderRes);
01352 }
01353 catch( std::exception& err ) {
01354 cerr<<"exception setting PFAlgo Photon parameters: "
01355 <<err.what()<<". terminating."<<endl;
01356 delete this;
01357 exit(1);
01358 }
01359 }
01360
01361
01362
01363 bool rejectTracks_Bad = true;
01364 bool rejectTracks_Step45 = true;
01365 bool usePFConversions = false;
01366 bool usePFNuclearInteractions = false;
01367 bool usePFV0s = false;
01368
01369
01370 double dptRel_DispVtx = 10;
01371
01372
01373 options_->GetOpt("particle_flow", "usePFConversions", usePFConversions);
01374 options_->GetOpt("particle_flow", "usePFV0s", usePFV0s);
01375 options_->GetOpt("particle_flow", "usePFNuclearInteractions", usePFNuclearInteractions);
01376 options_->GetOpt("particle_flow", "dptRel_DispVtx", dptRel_DispVtx);
01377
01378 try {
01379 pfAlgo_.setDisplacedVerticesParameters(rejectTracks_Bad,
01380 rejectTracks_Step45,
01381 usePFNuclearInteractions,
01382 usePFConversions,
01383 usePFV0s,
01384 dptRel_DispVtx);
01385
01386 }
01387 catch( std::exception& err ) {
01388 cerr<<"exception setting PFAlgo displaced vertex parameters: "
01389 <<err.what()<<". terminating."<<endl;
01390 delete this;
01391 exit(1);
01392 }
01393
01394 bool bCorrect = false;
01395 bool bCalibPrimary = false;
01396 double dptRel_PrimaryTrack = 0;
01397 double dptRel_MergedTrack = 0;
01398 double ptErrorSecondary = 0;
01399 vector<double> nuclCalibFactors;
01400
01401 options_->GetOpt("particle_flow", "bCorrect", bCorrect);
01402 options_->GetOpt("particle_flow", "bCalibPrimary", bCalibPrimary);
01403 options_->GetOpt("particle_flow", "dptRel_PrimaryTrack", dptRel_PrimaryTrack);
01404 options_->GetOpt("particle_flow", "dptRel_MergedTrack", dptRel_MergedTrack);
01405 options_->GetOpt("particle_flow", "ptErrorSecondary", ptErrorSecondary);
01406 options_->GetOpt("particle_flow", "nuclCalibFactors", nuclCalibFactors);
01407
01408 try {
01409 pfAlgo_.setCandConnectorParameters(bCorrect, bCalibPrimary, dptRel_PrimaryTrack, dptRel_MergedTrack, ptErrorSecondary, nuclCalibFactors);
01410 }
01411 catch( std::exception& err ) {
01412 cerr<<"exception setting PFAlgo cand connector parameters: "
01413 <<err.what()<<". terminating."<<endl;
01414 delete this;
01415 exit(1);
01416 }
01417
01418
01419
01420
01421 int algo = 2;
01422 options_->GetOpt("particle_flow", "algorithm", algo);
01423
01424 pfAlgo_.setAlgo( algo );
01425
01426
01427
01428
01429
01430 doJets_ = false;
01431 options_->GetOpt("jets", "on/off", doJets_);
01432
01433 jetsDebug_ = false;
01434 options_->GetOpt("jets", "debug", jetsDebug_);
01435
01436 jetAlgoType_=3;
01437 options_->GetOpt("jets", "algo", jetAlgoType_);
01438
01439 double mEtInputCut = 0.5;
01440 options_->GetOpt("jets", "EtInputCut", mEtInputCut);
01441
01442 double mEInputCut = 0.;
01443 options_->GetOpt("jets", "EInputCut", mEInputCut);
01444
01445 double seedThreshold = 1.0;
01446 options_->GetOpt("jets", "seedThreshold", seedThreshold);
01447
01448 double coneRadius = 0.5;
01449 options_->GetOpt("jets", "coneRadius", coneRadius);
01450
01451 double coneAreaFraction= 1.0;
01452 options_->GetOpt("jets", "coneAreaFraction", coneAreaFraction);
01453
01454 int maxPairSize=2;
01455 options_->GetOpt("jets", "maxPairSize", maxPairSize);
01456
01457 int maxIterations=100;
01458 options_->GetOpt("jets", "maxIterations", maxIterations);
01459
01460 double overlapThreshold = 0.75;
01461 options_->GetOpt("jets", "overlapThreshold", overlapThreshold);
01462
01463 double ptMin = 10.;
01464 options_->GetOpt("jets", "ptMin", ptMin);
01465
01466 double rparam = 1.0;
01467 options_->GetOpt("jets", "rParam", rparam);
01468
01469 jetMaker_.setmEtInputCut (mEtInputCut);
01470 jetMaker_.setmEInputCut(mEInputCut);
01471 jetMaker_.setSeedThreshold(seedThreshold);
01472 jetMaker_.setConeRadius(coneRadius);
01473 jetMaker_.setConeAreaFraction(coneAreaFraction);
01474 jetMaker_.setMaxPairSize(maxPairSize);
01475 jetMaker_.setMaxIterations(maxIterations) ;
01476 jetMaker_.setOverlapThreshold(overlapThreshold) ;
01477 jetMaker_.setPtMin (ptMin);
01478 jetMaker_.setRParam (rparam);
01479 jetMaker_.setDebug(jetsDebug_);
01480 jetMaker_.updateParameter();
01481 cout <<"Opt: doJets? " << doJets_ <<endl;
01482 cout <<"Opt: jetsDebug " << jetsDebug_ <<endl;
01483 cout <<"Opt: algoType " << jetAlgoType_ <<endl;
01484 cout <<"----------------------------------" << endl;
01485
01486
01487
01488
01489 doTauBenchmark_ = false;
01490 options_->GetOpt("tau_benchmark", "on/off", doTauBenchmark_);
01491
01492 if (doTauBenchmark_) {
01493 double coneAngle = 0.5;
01494 options_->GetOpt("tau_benchmark", "cone_angle", coneAngle);
01495
01496 double seedEt = 0.4;
01497 options_->GetOpt("tau_benchmark", "seed_et", seedEt);
01498
01499 double coneMerge = 100.0;
01500 options_->GetOpt("tau_benchmark", "cone_merge", coneMerge);
01501
01502 options_->GetOpt("tau_benchmark", "debug", tauBenchmarkDebug_);
01503
01504
01505
01506 if( tauBenchmarkDebug_ ) {
01507 cout << "Tau Benchmark Options : ";
01508 cout << "Angle=" << coneAngle << " seedEt=" << seedEt
01509 << " Merge=" << coneMerge << endl;
01510 }
01511
01512 jetAlgo_.SetConeAngle(coneAngle);
01513 jetAlgo_.SetSeedEt(seedEt);
01514 jetAlgo_.SetConeMerge(coneMerge);
01515 }
01516
01517
01518
01519
01520
01521 printRecHits_ = false;
01522 printRecHitsEMin_ = 0.;
01523 options_->GetOpt("print", "rechits", printRecHits_ );
01524 options_->GetOpt("print", "rechits_emin", printRecHitsEMin_ );
01525
01526 printClusters_ = false;
01527 printClustersEMin_ = 0.;
01528 options_->GetOpt("print", "clusters", printClusters_ );
01529 options_->GetOpt("print", "clusters_emin", printClustersEMin_ );
01530
01531 printPFBlocks_ = false;
01532 options_->GetOpt("print", "PFBlocks", printPFBlocks_ );
01533
01534 printPFCandidates_ = true;
01535 printPFCandidatesPtMin_ = 0.;
01536 options_->GetOpt("print", "PFCandidates", printPFCandidates_ );
01537 options_->GetOpt("print", "PFCandidates_ptmin", printPFCandidatesPtMin_ );
01538
01539 printPFJets_ = true;
01540 printPFJetsPtMin_ = 0.;
01541 options_->GetOpt("print", "jets", printPFJets_ );
01542 options_->GetOpt("print", "jets_ptmin", printPFJetsPtMin_ );
01543
01544 printSimParticles_ = true;
01545 printSimParticlesPtMin_ = 0.;
01546 options_->GetOpt("print", "simParticles", printSimParticles_ );
01547 options_->GetOpt("print", "simParticles_ptmin", printSimParticlesPtMin_ );
01548
01549 printGenParticles_ = true;
01550 printGenParticlesPtMin_ = 0.;
01551 options_->GetOpt("print", "genParticles", printGenParticles_ );
01552 options_->GetOpt("print", "genParticles_ptmin", printGenParticlesPtMin_ );
01553
01554
01555
01556
01557 printMCTruthMatching_ = false;
01558 options_->GetOpt("print", "mctruthmatching", printMCTruthMatching_ );
01559
01560
01561 verbosity_ = VERBOSE;
01562 options_->GetOpt("print", "verbosity", verbosity_ );
01563 cout<<"verbosity : "<<verbosity_<<endl;
01564
01565
01566
01567
01568
01569 }
01570
01571 void PFRootEventManager::connect( const char* infilename ) {
01572
01573 cout<<"Opening input root files"<<endl;
01574
01575 options_->GetOpt("root","file", inFileNames_);
01576
01577
01578
01579 try {
01580 AutoLibraryLoader::enable();
01581 }
01582 catch(string& err) {
01583 cout<<err<<endl;
01584 }
01585
01586 ev_ = new fwlite::ChainEvent(inFileNames_);
01587
01588
01589 if ( !ev_ || !ev_->isValid() ) {
01590 cout << "The rootfile(s) " << endl;
01591 for ( unsigned int ifile=0; ifile<inFileNames_.size(); ++ifile )
01592 std::cout << " - " << inFileNames_[ifile] << std::endl;
01593 cout << " is (are) not valid file(s) to open" << endl;
01594 return;
01595 } else {
01596 cout << "The rootfile(s) : " << endl;
01597 for ( unsigned int ifile=0; ifile<inFileNames_.size(); ++ifile )
01598 std::cout << " - " << inFileNames_[ifile] << std::endl;
01599 cout<<" are opened with " << ev_->size() << " events." <<endl;
01600 }
01601
01602
01603 std::string rechitsECALtagname;
01604 options_->GetOpt("root","rechits_ECAL_inputTag", rechitsECALtagname);
01605 rechitsECALTag_ = edm::InputTag(rechitsECALtagname);
01606
01607 std::string rechitsHCALtagname;
01608 options_->GetOpt("root","rechits_HCAL_inputTag", rechitsHCALtagname);
01609 rechitsHCALTag_ = edm::InputTag(rechitsHCALtagname);
01610
01611 std::string rechitsHOtagname;
01612 options_->GetOpt("root","rechits_HO_inputTag", rechitsHOtagname);
01613 rechitsHOTag_ = edm::InputTag(rechitsHOtagname);
01614
01615 std::string rechitsHFEMtagname;
01616 options_->GetOpt("root","rechits_HFEM_inputTag", rechitsHFEMtagname);
01617 rechitsHFEMTag_ = edm::InputTag(rechitsHFEMtagname);
01618
01619 std::string rechitsHFHADtagname;
01620 options_->GetOpt("root","rechits_HFHAD_inputTag", rechitsHFHADtagname);
01621 rechitsHFHADTag_ = edm::InputTag(rechitsHFHADtagname);
01622
01623 std::vector<string> rechitsCLEANEDtagnames;
01624 options_->GetOpt("root","rechits_CLEANED_inputTags", rechitsCLEANEDtagnames);
01625 for ( unsigned tags = 0; tags<rechitsCLEANEDtagnames.size(); ++tags )
01626 rechitsCLEANEDTags_.push_back(edm::InputTag(rechitsCLEANEDtagnames[tags]));
01627 rechitsCLEANEDV_.resize(rechitsCLEANEDTags_.size());
01628 rechitsCLEANEDHandles_.resize(rechitsCLEANEDTags_.size());
01629
01630
01631
01632 std::string rechitsPStagname;
01633 options_->GetOpt("root","rechits_PS_inputTag", rechitsPStagname);
01634 rechitsPSTag_ = edm::InputTag(rechitsPStagname);
01635
01636 std::string recTrackstagname;
01637 options_->GetOpt("root","recTracks_inputTag", recTrackstagname);
01638 recTracksTag_ = edm::InputTag(recTrackstagname);
01639
01640 std::string displacedRecTrackstagname;
01641 options_->GetOpt("root","displacedRecTracks_inputTag", displacedRecTrackstagname);
01642 displacedRecTracksTag_ = edm::InputTag(displacedRecTrackstagname);
01643
01644 std::string primaryVerticestagname;
01645 options_->GetOpt("root","primaryVertices_inputTag", primaryVerticestagname);
01646 primaryVerticesTag_ = edm::InputTag(primaryVerticestagname);
01647
01648 std::string stdTrackstagname;
01649 options_->GetOpt("root","stdTracks_inputTag", stdTrackstagname);
01650 stdTracksTag_ = edm::InputTag(stdTrackstagname);
01651
01652 std::string gsfrecTrackstagname;
01653 options_->GetOpt("root","gsfrecTracks_inputTag", gsfrecTrackstagname);
01654 gsfrecTracksTag_ = edm::InputTag(gsfrecTrackstagname);
01655
01656 useConvBremGsfTracks_ = false;
01657 options_->GetOpt("particle_flow", "useConvBremGsfTracks", useConvBremGsfTracks_);
01658 if ( useConvBremGsfTracks_ ) {
01659 std::string convBremGsfrecTrackstagname;
01660 options_->GetOpt("root","convBremGsfrecTracks_inputTag", convBremGsfrecTrackstagname);
01661 convBremGsfrecTracksTag_ = edm::InputTag(convBremGsfrecTrackstagname);
01662 }
01663
01664 useConvBremPFRecTracks_ = false;
01665 options_->GetOpt("particle_flow", "useConvBremPFRecTracks", useConvBremPFRecTracks_);
01666
01667
01668
01669 std::string muonstagname;
01670 options_->GetOpt("root","muon_inputTag", muonstagname);
01671 muonsTag_ = edm::InputTag(muonstagname);
01672
01673
01674 usePFConversions_=false;
01675 options_->GetOpt("particle_flow", "usePFConversions", usePFConversions_);
01676 if( usePFConversions_ ) {
01677 std::string conversiontagname;
01678 options_->GetOpt("root","conversion_inputTag", conversiontagname);
01679 conversionTag_ = edm::InputTag(conversiontagname);
01680 }
01681
01682
01683 usePFV0s_=false;
01684 options_->GetOpt("particle_flow", "usePFV0s", usePFV0s_);
01685 if( usePFV0s_ ) {
01686 std::string v0tagname;
01687 options_->GetOpt("root","V0_inputTag", v0tagname);
01688 v0Tag_ = edm::InputTag(v0tagname);
01689 }
01690
01691
01692 std::string photontagname;
01693 options_->GetOpt("root","Photon_inputTag",photontagname);
01694 photonTag_ = edm::InputTag(photontagname);
01695
01696
01697 usePFNuclearInteractions_=false;
01698 options_->GetOpt("particle_flow", "usePFNuclearInteractions", usePFNuclearInteractions_);
01699 if( usePFNuclearInteractions_ ) {
01700 std::string pfNuclearTrackerVertextagname;
01701 options_->GetOpt("root","PFDisplacedVertex_inputTag", pfNuclearTrackerVertextagname);
01702 pfNuclearTrackerVertexTag_ = edm::InputTag(pfNuclearTrackerVertextagname);
01703 }
01704
01705 std::string trueParticlestagname;
01706 options_->GetOpt("root","trueParticles_inputTag", trueParticlestagname);
01707 trueParticlesTag_ = edm::InputTag(trueParticlestagname);
01708
01709 std::string MCTruthtagname;
01710 options_->GetOpt("root","MCTruth_inputTag", MCTruthtagname);
01711 MCTruthTag_ = edm::InputTag(MCTruthtagname);
01712
01713 std::string caloTowerstagname;
01714 options_->GetOpt("root","caloTowers_inputTag", caloTowerstagname);
01715 caloTowersTag_ = edm::InputTag(caloTowerstagname);
01716
01717 std::string genJetstagname;
01718 options_->GetOpt("root","genJets_inputTag", genJetstagname);
01719 genJetsTag_ = edm::InputTag(genJetstagname);
01720
01721
01722 std::string genParticlesforMETtagname;
01723 options_->GetOpt("root","genParticlesforMET_inputTag", genParticlesforMETtagname);
01724 genParticlesforMETTag_ = edm::InputTag(genParticlesforMETtagname);
01725
01726 std::string genParticlesforJetstagname;
01727 options_->GetOpt("root","genParticlesforJets_inputTag", genParticlesforJetstagname);
01728 genParticlesforJetsTag_ = edm::InputTag(genParticlesforJetstagname);
01729
01730
01731 std::string pfCandidatetagname;
01732 options_->GetOpt("root","particleFlowCand_inputTag", pfCandidatetagname);
01733 pfCandidateTag_ = edm::InputTag(pfCandidatetagname);
01734
01735 std::string caloJetstagname;
01736 options_->GetOpt("root","CaloJets_inputTag", caloJetstagname);
01737 caloJetsTag_ = edm::InputTag(caloJetstagname);
01738
01739 std::string corrcaloJetstagname;
01740 options_->GetOpt("root","corrCaloJets_inputTag", corrcaloJetstagname);
01741 corrcaloJetsTag_ = edm::InputTag(corrcaloJetstagname);
01742
01743 std::string pfJetstagname;
01744 options_->GetOpt("root","PFJets_inputTag", pfJetstagname);
01745 pfJetsTag_ = edm::InputTag(pfJetstagname);
01746
01747 std::string pfMetstagname;
01748 options_->GetOpt("root","PFMET_inputTag", pfMetstagname);
01749 pfMetsTag_ = edm::InputTag(pfMetstagname);
01750
01751 std::string caloMetstagname;
01752 options_->GetOpt("root","CaloMET_inputTag", caloMetstagname);
01753 caloMetsTag_ = edm::InputTag(caloMetstagname);
01754
01755 std::string tcMetstagname;
01756 options_->GetOpt("root","TCMET_inputTag", tcMetstagname);
01757 tcMetsTag_ = edm::InputTag(tcMetstagname);
01758
01759 }
01760
01761
01762
01763
01764
01765 PFRootEventManager::~PFRootEventManager() {
01766
01767 if(outFile_) {
01768 outFile_->Close();
01769 }
01770
01771 if(outEvent_) delete outEvent_;
01772
01773 delete options_;
01774
01775 }
01776
01777
01778 void PFRootEventManager::write() {
01779
01780 if(doPFJetBenchmark_) PFJetBenchmark_.write();
01781 if(doPFMETBenchmark_) metManager_->write();
01782 clusterAlgoECAL_.write();
01783 clusterAlgoHCAL_.write();
01784 clusterAlgoHO_.write();
01785 clusterAlgoPS_.write();
01786 clusterAlgoHFEM_.write();
01787 clusterAlgoHFHAD_.write();
01788
01789
01790 if (doPFDQM_) {
01791 cout << " Writing DQM root file " << endl;
01792 pfJetMonitor_.write();
01793 pfMETMonitor_.write();
01794 dqmFile_->Write();
01795 }
01796
01797 if(outFile_) {
01798 outFile_->Write();
01799
01800
01801
01802
01803
01804
01805
01806 }
01807 }
01808
01809
01810 int PFRootEventManager::eventToEntry(int run, int lumi, int event) const {
01811
01812 RunsMap::const_iterator iR = mapEventToEntry_.find( run );
01813 if( iR != mapEventToEntry_.end() ) {
01814 LumisMap::const_iterator iL = iR->second.find( lumi );
01815 if( iL != iR->second.end() ) {
01816 EventToEntry::const_iterator iE = iL->second.find( event );
01817 if( iE != iL->second.end() ) {
01818 return iE->second;
01819 }
01820 else {
01821 cout<<"event "<<event<<" not found in run "<<run<<", lumi "<<lumi<<endl;
01822 }
01823 }
01824 else {
01825 cout<<"lumi "<<lumi<<" not found in run "<<run<<endl;
01826 }
01827 }
01828 else{
01829 cout<<"run "<<run<<" not found"<<endl;
01830 }
01831 return -1;
01832 }
01833
01834 bool PFRootEventManager::processEvent(int run, int lumi, int event) {
01835
01836 int entry = eventToEntry(run, lumi, event);
01837 if( entry < 0 ) {
01838 cout<<"event "<<event<<" is not present, sorry."<<endl;
01839 return false;
01840 }
01841 else
01842 return processEntry( entry );
01843 }
01844
01845
01846 bool PFRootEventManager::processEntry(int entry) {
01847
01848 reset();
01849
01850 iEvent_ = entry;
01851
01852 bool exists = ev_->to(entry);
01853 if ( !exists ) {
01854 std::cout << "Entry " << entry << " does not exist " << std::endl;
01855 return false;
01856 }
01857 const edm::EventBase& iEvent = *ev_;
01858
01859 if( outEvent_ ) outEvent_->setNumber(entry);
01860
01861 if(verbosity_ == VERBOSE ||
01862
01863 entry < 10 ||
01864 (entry < 100 && entry%10 == 0) ||
01865 (entry < 1000 && entry%100 == 0) ||
01866 entry%1000 == 0 )
01867 cout<<"process entry "<< entry
01868 <<", run "<<iEvent.id().run()
01869 <<", lumi "<<iEvent.id().luminosityBlock()
01870 <<", event:"<<iEvent.id().event()
01871 << endl;
01872
01873
01874
01875 bool goodevent = readFromSimulation(entry);
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885 if(verbosity_ == VERBOSE ) {
01886 cout<<"number of vertices : "<<primaryVertices_.size()<<endl;
01887 cout<<"number of recTracks : "<<recTracks_.size()<<endl;
01888 cout<<"number of gsfrecTracks : "<<gsfrecTracks_.size()<<endl;
01889 cout<<"number of convBremGsfrecTracks : "<<convBremGsfrecTracks_.size()<<endl;
01890 cout<<"number of muons : "<<muons_.size()<<endl;
01891 cout<<"number of displaced vertices : "<<pfNuclearTrackerVertex_.size()<<endl;
01892 cout<<"number of conversions : "<<conversion_.size()<<endl;
01893 cout<<"number of v0 : "<<v0_.size()<<endl;
01894 cout<<"number of stdTracks : "<<stdTracks_.size()<<endl;
01895 cout<<"number of true particles : "<<trueParticles_.size()<<endl;
01896 cout<<"number of ECAL rechits : "<<rechitsECAL_.size()<<endl;
01897 cout<<"number of HCAL rechits : "<<rechitsHCAL_.size()<<endl;
01898 cout<<"number of HO rechits : "<<rechitsHO_.size()<<endl;
01899 cout<<"number of HFEM rechits : "<<rechitsHFEM_.size()<<endl;
01900 cout<<"number of HFHAD rechits : "<<rechitsHFHAD_.size()<<endl;
01901 cout<<"number of HF Cleaned rechits : "<<rechitsCLEANED_.size()<<endl;
01902 cout<<"number of PS rechits : "<<rechitsPS_.size()<<endl;
01903 }
01904
01905 if( doClustering_ ) {
01906 clustering();
01907
01908 } else if( verbosity_ == VERBOSE ) {
01909 cout<<"clustering is OFF - clusters come from the input file"<<endl;
01910 }
01911
01912 if(verbosity_ == VERBOSE ) {
01913 if(clustersECAL_.get() ) {
01914 cout<<"number of ECAL clusters : "<<clustersECAL_->size()<<endl;
01915 }
01916 if(clustersHCAL_.get() ) {
01917 cout<<"number of HCAL clusters : "<<clustersHCAL_->size()<<endl;
01918 }
01919
01920 if(useHO_ && clustersHO_.get() ) {
01921 cout<<"number of HO clusters : "<<clustersHO_->size()<<endl;
01922 }
01923
01924 if(clustersHFEM_.get() ) {
01925 cout<<"number of HFEM clusters : "<<clustersHFEM_->size()<<endl;
01926 }
01927 if(clustersHFHAD_.get() ) {
01928 cout<<"number of HFHAD clusters : "<<clustersHFHAD_->size()<<endl;
01929 }
01930 if(clustersPS_.get() ) {
01931 cout<<"number of PS clusters : "<<clustersPS_->size()<<endl;
01932 }
01933 }
01934
01935 if(doParticleFlow_) {
01936 particleFlow();
01937 if (doCompare_) pfCandCompare(entry);
01938 }
01939
01940 if(doJets_) {
01941 reconstructGenJets();
01942 reconstructCaloJets();
01943 reconstructPFJets();
01944 }
01945
01946
01947 if( verbosity_ == VERBOSE ) print();
01948
01949
01950
01951
01952 goodevent = eventAccepted();
01953
01954
01955 if(doPFJetBenchmark_) {
01956
01957 PFJetBenchmark_.process(pfJets_, genJets_);
01958 double resPt = PFJetBenchmark_.resPtMax();
01959 double resChargedHadEnergy = PFJetBenchmark_.resChargedHadEnergyMax();
01960 double resNeutralHadEnergy = PFJetBenchmark_.resNeutralHadEnergyMax();
01961 double resNeutralEmEnergy = PFJetBenchmark_.resNeutralEmEnergyMax();
01962
01963 if( verbosity_ == VERBOSE ){
01964
01965 cout << " =====================PFJetBenchmark =================" << endl;
01966 cout<<"Resol Pt max "<<resPt
01967 <<" resChargedHadEnergy Max " << resChargedHadEnergy
01968 <<" resNeutralHadEnergy Max " << resNeutralHadEnergy
01969 << " resNeutralEmEnergy Max "<< resNeutralEmEnergy << endl;
01970 }
01971
01972
01973
01974
01975
01976
01977
01978 if ( resPt < -1. ) {
01979 cout << " =====================PFJetBenchmark =================" << endl;
01980 cout<<"process entry "<< entry << endl;
01981 cout<<"Resol Pt max "<<resPt
01982 <<" resChargedHadEnergy Max " << resChargedHadEnergy
01983 <<" resNeutralHadEnergy Max " << resNeutralHadEnergy
01984 << " resNeutralEmEnergy Max "<< resNeutralEmEnergy
01985 << " Jet pt " << genJets_[0].pt() << endl;
01986
01987 } else {
01988
01989 }
01990
01991
01992 }
01993
01994
01995 reco::MET reComputedMet_;
01996 reco::MET computedGenMet_;
01997
01998
01999
02000
02001 if(doPFMETBenchmark_) {
02002
02003
02004
02005 metManager_->setMET1(&genParticlesCMSSW_);
02006 metManager_->setMET2(&pfMetsCMSSW_[0]);
02007 metManager_->FillHisto("PF");
02008
02009 metManager_->coutTailEvents(entry,DeltaMETcut,DeltaPhicut, MET1cut);
02010
02011
02012 metManager_->setMET2(&caloMetsCMSSW_[0]);
02013 metManager_->FillHisto("Calo");
02014
02015 if ( doMet_ ) {
02016
02017 metManager_->setMET2(*pfCandidates_);
02018 metManager_->FillHisto("recompPF");
02019 metManager_->coutTailEvents(entry,DeltaMETcut,DeltaPhicut, MET1cut);
02020 }
02021
02022 if (JECinCaloMet_)
02023 {
02024
02025 metManager_->setMET2(&caloMetsCMSSW_[0]);
02026 metManager_->propagateJECtoMET2(caloJetsCMSSW_, corrcaloJetsCMSSW_);
02027 metManager_->FillHisto("corrCalo");
02028 }
02029 }
02030
02031 if( goodevent && doPFCandidateBenchmark_ ) {
02032 pfCandidateManager_.fill( *pfCandidates_, genParticlesCMSSW_);
02033 }
02034
02035
02036 if( goodevent && doPFDQM_ ) {
02037 float deltaMin, deltaMax;
02038 pfJetMonitor_.fill( pfJets_, genJets_, deltaMin, deltaMax);
02039 if (doPFMETBenchmark_) {
02040 pfMETMonitor_.fillOne( reComputedMet_, computedGenMet_, deltaMin, deltaMax);
02041 }
02042 }
02043
02044
02045 if( goodevent && doTauBenchmark_) {
02046 double deltaEt = 0.;
02047 deltaEt = tauBenchmark( *pfCandidates_ );
02048 if( verbosity_ == VERBOSE ) cout<<"delta E_t ="<<deltaEt <<endl;
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059 }
02060
02061 if(goodevent && outTree_)
02062 outTree_->Fill();
02063
02064 if(calibFile_)
02065 printMCCalib(*calibFile_);
02066
02067 return goodevent;
02068
02069 }
02070
02071
02072
02073 bool PFRootEventManager::eventAccepted() const {
02074
02075
02076 return true;
02077 }
02078
02079 bool PFRootEventManager::highPtJet(double ptMin) const {
02080 for( unsigned i=0; i<pfJets_.size(); ++i) {
02081 if( pfJets_[i].pt() > ptMin ) return true;
02082 }
02083 return false;
02084 }
02085
02086 bool PFRootEventManager::highPtPFCandidate( double ptMin,
02087 PFCandidate::ParticleType type) const {
02088 for( unsigned i=0; i<pfCandidates_->size(); ++i) {
02089
02090 const PFCandidate& pfc = (*pfCandidates_)[i];
02091 if(type!= PFCandidate::X &&
02092 pfc.particleId() != type ) continue;
02093 if( pfc.pt() > ptMin ) return true;
02094 }
02095 return false;
02096 }
02097
02098
02099 bool PFRootEventManager::readFromSimulation(int entry) {
02100
02101 if (verbosity_ == VERBOSE ) {
02102 cout <<"start reading from simulation"<<endl;
02103 }
02104
02105
02106
02107
02108 const edm::EventBase& iEvent = *ev_;
02109
02110
02111 bool foundstdTracks = iEvent.getByLabel(stdTracksTag_,stdTracksHandle_);
02112 if ( foundstdTracks ) {
02113 stdTracks_ = *stdTracksHandle_;
02114
02115 } else {
02116 cerr<<"PFRootEventManager::ProcessEntry : stdTracks Collection not found : "
02117 <<entry << " " << stdTracksTag_<<endl;
02118 }
02119
02120 bool foundMCTruth = iEvent.getByLabel(MCTruthTag_,MCTruthHandle_);
02121 if ( foundMCTruth ) {
02122 MCTruth_ = *MCTruthHandle_;
02123
02124 } else {
02125
02126
02127 }
02128
02129 bool foundTP = iEvent.getByLabel(trueParticlesTag_,trueParticlesHandle_);
02130 if ( foundTP ) {
02131 trueParticles_ = *trueParticlesHandle_;
02132
02133 } else {
02134
02135
02136 }
02137
02138 bool foundECAL = iEvent.getByLabel(rechitsECALTag_,rechitsECALHandle_);
02139 if ( foundECAL ) {
02140 rechitsECAL_ = *rechitsECALHandle_;
02141
02142 } else {
02143 cerr<<"PFRootEventManager::ProcessEntry : rechitsECAL Collection not found : "
02144 <<entry << " " << rechitsECALTag_<<endl;
02145 }
02146
02147 bool foundHCAL = iEvent.getByLabel(rechitsHCALTag_,rechitsHCALHandle_);
02148 if ( foundHCAL ) {
02149 rechitsHCAL_ = *rechitsHCALHandle_;
02150
02151 } else {
02152 cerr<<"PFRootEventManager::ProcessEntry : rechitsHCAL Collection not found : "
02153 <<entry << " " << rechitsHCALTag_<<endl;
02154 }
02155
02156 if (useHO_) {
02157 bool foundHO = iEvent.getByLabel(rechitsHOTag_,rechitsHOHandle_);
02158 if ( foundHO ) {
02159 rechitsHO_ = *rechitsHOHandle_;
02160
02161 } else {
02162 cerr<<"PFRootEventManager::ProcessEntry : rechitsHO Collection not found : "
02163 <<entry << " " << rechitsHOTag_<<endl;
02164 }
02165 }
02166
02167 bool foundHFEM = iEvent.getByLabel(rechitsHFEMTag_,rechitsHFEMHandle_);
02168 if ( foundHFEM ) {
02169 rechitsHFEM_ = *rechitsHFEMHandle_;
02170
02171 } else {
02172 cerr<<"PFRootEventManager::ProcessEntry : rechitsHFEM Collection not found : "
02173 <<entry << " " << rechitsHFEMTag_<<endl;
02174 }
02175
02176 bool foundHFHAD = iEvent.getByLabel(rechitsHFHADTag_,rechitsHFHADHandle_);
02177 if ( foundHFHAD ) {
02178 rechitsHFHAD_ = *rechitsHFHADHandle_;
02179
02180 } else {
02181 cerr<<"PFRootEventManager::ProcessEntry : rechitsHFHAD Collection not found : "
02182 <<entry << " " << rechitsHFHADTag_<<endl;
02183 }
02184
02185 for ( unsigned i=0; i<rechitsCLEANEDTags_.size(); ++i ) {
02186 bool foundCLEANED = iEvent.getByLabel(rechitsCLEANEDTags_[i],
02187 rechitsCLEANEDHandles_[i]);
02188 if ( foundCLEANED ) {
02189 rechitsCLEANEDV_[i] = *(rechitsCLEANEDHandles_[i]);
02190
02191 } else {
02192 cerr<<"PFRootEventManager::ProcessEntry : rechitsCLEANED Collection not found : "
02193 <<entry << " " << rechitsCLEANEDTags_[i]<<endl;
02194 }
02195
02196 }
02197
02198 bool foundPS = iEvent.getByLabel(rechitsPSTag_,rechitsPSHandle_);
02199 if ( foundPS ) {
02200 rechitsPS_ = *rechitsPSHandle_;
02201
02202 } else {
02203 cerr<<"PFRootEventManager::ProcessEntry : rechitsPS Collection not found : "
02204 <<entry << " " << rechitsPSTag_<<endl;
02205 }
02206
02207 bool foundCT = iEvent.getByLabel(caloTowersTag_,caloTowersHandle_);
02208 if ( foundCT ) {
02209 caloTowers_ = *caloTowersHandle_;
02210
02211 } else {
02212 cerr<<"PFRootEventManager::ProcessEntry : caloTowers Collection not found : "
02213 <<entry << " " << caloTowersTag_<<endl;
02214 }
02215
02216 bool foundPV = iEvent.getByLabel(primaryVerticesTag_,primaryVerticesHandle_);
02217 if ( foundPV ) {
02218 primaryVertices_ = *primaryVerticesHandle_;
02219
02220 } else {
02221 cerr<<"PFRootEventManager::ProcessEntry : primaryVertices Collection not found : "
02222 <<entry << " " << primaryVerticesTag_<<endl;
02223 }
02224
02225
02226 bool foundPFV = iEvent.getByLabel(pfNuclearTrackerVertexTag_,pfNuclearTrackerVertexHandle_);
02227 if ( foundPFV ) {
02228 pfNuclearTrackerVertex_ = *pfNuclearTrackerVertexHandle_;
02229
02230 } else if ( usePFNuclearInteractions_ ) {
02231 cerr<<"PFRootEventManager::ProcessEntry : pfNuclearTrackerVertex Collection not found : "
02232 <<entry << " " << pfNuclearTrackerVertexTag_<<endl;
02233 }
02234
02235 bool foundrecTracks = iEvent.getByLabel(recTracksTag_,recTracksHandle_);
02236 if ( foundrecTracks ) {
02237 recTracks_ = *recTracksHandle_;
02238
02239 } else {
02240 cerr<<"PFRootEventManager::ProcessEntry : recTracks Collection not found : "
02241 <<entry << " " << recTracksTag_<<endl;
02242 }
02243
02244 bool founddisplacedRecTracks = iEvent.getByLabel(displacedRecTracksTag_,displacedRecTracksHandle_);
02245 if ( founddisplacedRecTracks ) {
02246 displacedRecTracks_ = *displacedRecTracksHandle_;
02247
02248 } else {
02249 cerr<<"PFRootEventManager::ProcessEntry : displacedRecTracks Collection not found : "
02250 <<entry << " " << displacedRecTracksTag_<<endl;
02251 }
02252
02253
02254 bool foundgsfrecTracks = iEvent.getByLabel(gsfrecTracksTag_,gsfrecTracksHandle_);
02255 if ( foundgsfrecTracks ) {
02256 gsfrecTracks_ = *gsfrecTracksHandle_;
02257
02258 } else {
02259 cerr<<"PFRootEventManager::ProcessEntry : gsfrecTracks Collection not found : "
02260 <<entry << " " << gsfrecTracksTag_<<endl;
02261 }
02262
02263 bool foundconvBremGsfrecTracks = iEvent.getByLabel(convBremGsfrecTracksTag_,convBremGsfrecTracksHandle_);
02264 if ( foundconvBremGsfrecTracks ) {
02265 convBremGsfrecTracks_ = *convBremGsfrecTracksHandle_;
02266
02267 } else if ( useConvBremGsfTracks_ ) {
02268 cerr<<"PFRootEventManager::ProcessEntry : convBremGsfrecTracks Collection not found : "
02269 <<entry << " " << convBremGsfrecTracksTag_<<endl;
02270 }
02271
02272 bool foundmuons = iEvent.getByLabel(muonsTag_,muonsHandle_);
02273 if ( foundmuons ) {
02274 muons_ = *muonsHandle_;
02275
02276
02277
02278
02279
02280
02281
02282
02283 } else {
02284 cerr<<"PFRootEventManager::ProcessEntry : muons Collection not found : "
02285 <<entry << " " << muonsTag_<<endl;
02286 }
02287
02288 bool foundconversion = iEvent.getByLabel(conversionTag_,conversionHandle_);
02289 if ( foundconversion ) {
02290 conversion_ = *conversionHandle_;
02291
02292 } else if ( usePFConversions_ ) {
02293 cerr<<"PFRootEventManager::ProcessEntry : conversion Collection not found : "
02294 <<entry << " " << conversionTag_<<endl;
02295 }
02296
02297
02298
02299 bool foundv0 = iEvent.getByLabel(v0Tag_,v0Handle_);
02300 if ( foundv0 ) {
02301 v0_ = *v0Handle_;
02302
02303 } else if ( usePFV0s_ ) {
02304 cerr<<"PFRootEventManager::ProcessEntry : v0 Collection not found : "
02305 <<entry << " " << v0Tag_<<endl;
02306 }
02307
02308 if(useEGPhotons_) {
02309 bool foundPhotons = iEvent.getByLabel(photonTag_,photonHandle_);
02310 if ( foundPhotons) {
02311 photons_ = *photonHandle_;
02312 } else {
02313 cerr <<"PFRootEventManager::ProcessEntry : photon collection not found : "
02314 << entry << " " << photonTag_ << endl;
02315 }
02316 }
02317
02318 if(useEGElectrons_) {
02319 bool foundElectrons = iEvent.getByLabel(egammaElectronsTag_,egammaElectronHandle_);
02320 if ( foundElectrons) {
02321
02322 egammaElectrons_ = *egammaElectronHandle_;
02323 } else
02324 {
02325 cerr <<"PFRootEventManager::ProcessEntry : electron collection not found : "
02326 << entry << " " << egammaElectronsTag_ << endl;
02327 }
02328 }
02329
02330 bool foundgenJets = iEvent.getByLabel(genJetsTag_,genJetsHandle_);
02331 if ( foundgenJets ) {
02332 genJetsCMSSW_ = *genJetsHandle_;
02333
02334 } else {
02335
02336
02337 }
02338
02339 bool foundgenParticlesforJets = iEvent.getByLabel(genParticlesforJetsTag_,genParticlesforJetsHandle_);
02340 if ( foundgenParticlesforJets ) {
02341 genParticlesforJets_ = *genParticlesforJetsHandle_;
02342
02343 } else {
02344
02345
02346 }
02347
02348 bool foundgenParticlesforMET = iEvent.getByLabel(genParticlesforMETTag_,genParticlesforMETHandle_);
02349 if ( foundgenParticlesforMET ) {
02350 genParticlesCMSSW_ = *genParticlesforMETHandle_;
02351
02352 } else {
02353
02354
02355 }
02356
02357 bool foundcaloJets = iEvent.getByLabel(caloJetsTag_,caloJetsHandle_);
02358 if ( foundcaloJets ) {
02359 caloJetsCMSSW_ = *caloJetsHandle_;
02360
02361 } else {
02362 cerr<<"PFRootEventManager::ProcessEntry : caloJets Collection not found : "
02363 <<entry << " " << caloJetsTag_<<endl;
02364 }
02365
02366 bool foundcorrcaloJets = iEvent.getByLabel(corrcaloJetsTag_,corrcaloJetsHandle_);
02367 if ( foundcorrcaloJets ) {
02368 corrcaloJetsCMSSW_ = *corrcaloJetsHandle_;
02369
02370 } else {
02371
02372
02373 }
02374
02375 bool foundpfJets = iEvent.getByLabel(pfJetsTag_,pfJetsHandle_);
02376 if ( foundpfJets ) {
02377 pfJetsCMSSW_ = *pfJetsHandle_;
02378
02379 } else {
02380 cerr<<"PFRootEventManager::ProcessEntry : PFJets Collection not found : "
02381 <<entry << " " << pfJetsTag_<<endl;
02382 }
02383
02384 bool foundpfCands = iEvent.getByLabel(pfCandidateTag_,pfCandidateHandle_);
02385 if ( foundpfCands ) {
02386 pfCandCMSSW_ = *pfCandidateHandle_;
02387
02388 } else {
02389 cerr<<"PFRootEventManager::ProcessEntry : PFCandidate Collection not found : "
02390 <<entry << " " << pfCandidateTag_<<endl;
02391 }
02392
02393 bool foundpfMets = iEvent.getByLabel(pfMetsTag_,pfMetsHandle_);
02394 if ( foundpfMets ) {
02395 pfMetsCMSSW_ = *pfMetsHandle_;
02396
02397 } else {
02398 cerr<<"PFRootEventManager::ProcessEntry : PFMets Collection not found : "
02399 <<entry << " " << pfMetsTag_<<endl;
02400 }
02401
02402 bool foundtcMets = iEvent.getByLabel(tcMetsTag_,tcMetsHandle_);
02403 if ( foundtcMets ) {
02404 tcMetsCMSSW_ = *tcMetsHandle_;
02405
02406 } else {
02407 cerr<<"TCRootEventManager::ProcessEntry : TCMets Collection not found : "
02408 <<entry << " " << tcMetsTag_<<endl;
02409 }
02410
02411 bool foundcaloMets = iEvent.getByLabel(caloMetsTag_,caloMetsHandle_);
02412 if ( foundcaloMets ) {
02413 caloMetsCMSSW_ = *caloMetsHandle_;
02414
02415 } else {
02416 cerr<<"CALORootEventManager::ProcessEntry : CALOMets Collection not found : "
02417 <<entry << " " << caloMetsTag_<<endl;
02418 }
02419
02420
02421
02422 bool goodevent = true;
02423 if(trueParticles_.size() ) {
02424
02425 if(filterNParticles_ && doTauBenchmark_ &&
02426 trueParticles_.size() != filterNParticles_ ) {
02427 cout << "PFRootEventManager : event discarded Nparticles="
02428 <<filterNParticles_<< endl;
02429 goodevent = false;
02430 }
02431 if(goodevent && doTauBenchmark_ && filterHadronicTaus_ && !isHadronicTau() ) {
02432 cout << "PFRootEventManager : leptonic tau discarded " << endl;
02433 goodevent = false;
02434 }
02435 if( goodevent && doTauBenchmark_ && !filterTaus_.empty()
02436 && !countChargedAndPhotons() ) {
02437 assert( filterTaus_.size() == 2 );
02438 cout <<"PFRootEventManager : tau discarded: "
02439 <<"number of charged and neutral particles different from "
02440 <<filterTaus_[0]<<","<<filterTaus_[1]<<endl;
02441 goodevent = false;
02442 }
02443
02444 if(goodevent)
02445 fillOutEventWithSimParticles( trueParticles_ );
02446
02447 }
02448
02449
02450
02451
02452
02453
02454 if(rechitsECAL_.size()) {
02455 PreprocessRecHits( rechitsECAL_ , findRecHitNeighbours_);
02456 }
02457 if(rechitsHCAL_.size()) {
02458 PreprocessRecHits( rechitsHCAL_ , findRecHitNeighbours_);
02459 }
02460
02461 if (useHO_) {
02462 if(rechitsHO_.size()) {
02463 PreprocessRecHits( rechitsHO_ , findRecHitNeighbours_);
02464 }
02465 }
02466
02467 if(rechitsHFEM_.size()) {
02468 PreprocessRecHits( rechitsHFEM_ , findRecHitNeighbours_);
02469 }
02470 if(rechitsHFHAD_.size()) {
02471 PreprocessRecHits( rechitsHFHAD_ , findRecHitNeighbours_);
02472 }
02473 rechitsCLEANED_.clear();
02474 for ( unsigned i=0; i<rechitsCLEANEDV_.size(); ++i ) {
02475 if(rechitsCLEANEDV_[i].size()) {
02476 PreprocessRecHits( rechitsCLEANEDV_[i] , false);
02477 for ( unsigned j=0; j<rechitsCLEANEDV_[i].size(); ++j ) {
02478 rechitsCLEANED_.push_back( (rechitsCLEANEDV_[i])[j] );
02479 }
02480 }
02481 }
02482
02483 if(rechitsPS_.size()) {
02484 PreprocessRecHits( rechitsPS_ , findRecHitNeighbours_);
02485 }
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507 return goodevent;
02508 }
02509
02510
02511 bool PFRootEventManager::isHadronicTau() const {
02512
02513 for ( unsigned i=0; i < trueParticles_.size(); i++) {
02514 const reco::PFSimParticle& ptc = trueParticles_[i];
02515 const std::vector<int>& ptcdaughters = ptc.daughterIds();
02516 if (std::abs(ptc.pdgCode()) == 15) {
02517 for ( unsigned int dapt=0; dapt < ptcdaughters.size(); ++dapt) {
02518
02519 const reco::PFSimParticle& daughter
02520 = trueParticles_[ptcdaughters[dapt]];
02521
02522
02523 int pdgdaugther = daughter.pdgCode();
02524 int abspdgdaughter = std::abs(pdgdaugther);
02525
02526
02527 if (abspdgdaughter == 11 ||
02528 abspdgdaughter == 13) {
02529 return false;
02530 }
02531 }
02532 }
02533 }
02534
02535
02536 return true;
02537 }
02538
02539
02540
02541 bool PFRootEventManager::countChargedAndPhotons() const {
02542
02543 int nPhoton = 0;
02544 int nCharged = 0;
02545
02546 for ( unsigned i=0; i < trueParticles_.size(); i++) {
02547 const reco::PFSimParticle& ptc = trueParticles_[i];
02548
02549 const std::vector<int>& daughters = ptc.daughterIds();
02550
02551
02552
02553 if(!daughters.empty() ) continue;
02554
02555 double charge = ptc.charge();
02556 double pdgCode = ptc.pdgCode();
02557
02558 if( std::abs(charge)>1e-9)
02559 nCharged++;
02560 else if( pdgCode==22 )
02561 nPhoton++;
02562 }
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591 if( nCharged == filterTaus_[0] &&
02592 nPhoton == filterTaus_[1] )
02593 return true;
02594 else
02595 return false;
02596 }
02597
02598
02599
02600 int PFRootEventManager::chargeValue(const int& Id) const {
02601
02602
02603
02604
02605
02606
02607
02608 int kqa,kq1,kq2,kq3,kqj,irt,kqx,kqn;
02609 int hepchg;
02610
02611
02612 int ichg[109]={-1,2,-1,2,-1,2,-1,2,0,0,-3,0,-3,0,-3,0,
02613 -3,0,0,0,0,0,0,3,0,0,0,0,0,0,3,0,3,6,0,0,3,6,0,0,-1,2,-1,2,-1,2,0,0,0,0,
02614 -3,0,-3,0,-3,0,0,0,0,0,-1,2,-1,2,-1,2,0,0,0,0,
02615 -3,0,-3,0,-3,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
02616
02617
02618
02619 hepchg=0;
02620 kqa=std::abs(Id);
02621 kqn=kqa/1000000000%10;
02622 kqx=kqa/1000000%10;
02623 kq3=kqa/1000%10;
02624 kq2=kqa/100%10;
02625 kq1=kqa/10%10;
02626 kqj=kqa%10;
02627 irt=kqa%10000;
02628
02629
02630
02631 if(kqa==0 || kqa >= 10000000) {
02632
02633 if(kqn==1) {hepchg=0;}
02634 }
02635
02636 else if(kqa<=100) {hepchg = ichg[kqa-1];}
02637
02638 else if(kqa==100 || kqa==101) {hepchg = -3;}
02639
02640 else if(kqa==102 || kqa==104) {hepchg = -6;}
02641
02642 else if(kqj == 0) {hepchg = 0;}
02643
02644 else if(kqx>0 && irt<100)
02645 {
02646 hepchg = ichg[irt-1];
02647 if(kqa==1000017 || kqa==1000018) {hepchg = 0;}
02648 if(kqa==1000034 || kqa==1000052) {hepchg = 0;}
02649 if(kqa==1000053 || kqa==1000054) {hepchg = 0;}
02650 if(kqa==5100061 || kqa==5100062) {hepchg = 6;}
02651 }
02652
02653
02654 else if(kq3==0)
02655 {
02656 hepchg = ichg[kq2-1]-ichg[kq1-1];
02657
02658 if((kq2==3) || (kq2==5)) {hepchg = ichg[kq1-1]-ichg[kq2-1];}
02659 }
02660 else if(kq1 == 0) {
02661
02662 hepchg = ichg[kq3-1] + ichg[kq2-1];
02663 }
02664
02665 else{
02666
02667 hepchg = ichg[kq3-1]+ichg[kq2-1]+ichg[kq1-1];
02668 }
02669
02670
02671 if(Id<0 && hepchg!=0) {hepchg = -1*hepchg;}
02672
02673
02674 return hepchg;
02675 }
02676
02677
02678
02679 void
02680 PFRootEventManager::PreprocessRecTracks(reco::PFRecTrackCollection& recTracks) {
02681
02682
02683
02684
02685
02686 }
02687
02688 void
02689 PFRootEventManager::PreprocessRecTracks(reco::GsfPFRecTrackCollection& recTracks) {
02690
02691
02692
02693
02694
02695
02696 }
02697
02698
02699
02700 void
02701 PFRootEventManager::PreprocessRecHits(reco::PFRecHitCollection& rechits,
02702 bool findNeighbours) {
02703
02704
02705 map<unsigned, unsigned> detId2index;
02706
02707 for(unsigned i=0; i<rechits.size(); i++) {
02708 rechits[i].calculatePositionREP();
02709
02710 if(findNeighbours)
02711 detId2index.insert( make_pair(rechits[i].detId(), i) );
02712 }
02713
02714 if(findNeighbours) {
02715 for(unsigned i=0; i<rechits.size(); i++) {
02716 setRecHitNeigbours( rechits[i], detId2index );
02717 }
02718 }
02719 }
02720
02721
02722 void PFRootEventManager::setRecHitNeigbours
02723 ( reco::PFRecHit& rh,
02724 const map<unsigned, unsigned>& detId2index ) {
02725
02726 rh.clearNeighbours();
02727
02728 vector<unsigned> neighbours4DetId = rh.neighboursIds4();
02729 vector<unsigned> neighbours8DetId = rh.neighboursIds8();
02730
02731 for( unsigned i=0; i<neighbours4DetId.size(); i++) {
02732 unsigned detId = neighbours4DetId[i];
02733
02734 const map<unsigned, unsigned>::const_iterator& it = detId2index.find(detId);
02735
02736 if(it != detId2index.end() ) {
02737
02738 rh.add4Neighbour( it->second );
02739 }
02740 }
02741
02742 for( unsigned i=0; i<neighbours8DetId.size(); i++) {
02743 unsigned detId = neighbours8DetId[i];
02744
02745 const map<unsigned, unsigned>::const_iterator& it = detId2index.find(detId);
02746
02747 if(it != detId2index.end() ) {
02748
02749 rh.add8Neighbour( it->second );
02750 }
02751 }
02752
02753
02754 }
02755
02756
02757 void PFRootEventManager::clustering() {
02758
02759 if (verbosity_ == VERBOSE ) {
02760 cout <<"start clustering"<<endl;
02761 }
02762
02763 vector<bool> mask;
02764
02765
02766 fillRecHitMask( mask, rechitsECAL_ );
02767 clusterAlgoECAL_.doClustering( rechitsECAL_, mask );
02768 clustersECAL_ = clusterAlgoECAL_.clusters();
02769
02770 assert(clustersECAL_.get() );
02771
02772 fillOutEventWithClusters( *clustersECAL_ );
02773
02774
02775
02776 fillRecHitMask( mask, rechitsHCAL_ );
02777 clusterAlgoHCAL_.doClustering( rechitsHCAL_, mask );
02778 clustersHCAL_ = clusterAlgoHCAL_.clusters();
02779
02780 fillOutEventWithClusters( *clustersHCAL_ );
02781
02782
02783
02784 if (useHO_) {
02785 fillRecHitMask( mask, rechitsHO_ );
02786
02787 clusterAlgoHO_.doClustering( rechitsHO_, mask );
02788
02789 clustersHO_ = clusterAlgoHO_.clusters();
02790
02791 fillOutEventWithClusters( *clustersHO_ );
02792 }
02793
02794
02795
02796 fillRecHitMask( mask, rechitsHFEM_ );
02797 clusterAlgoHFEM_.doClustering( rechitsHFEM_, mask );
02798 clustersHFEM_ = clusterAlgoHFEM_.clusters();
02799
02800 fillRecHitMask( mask, rechitsHFHAD_ );
02801 clusterAlgoHFHAD_.doClustering( rechitsHFHAD_, mask );
02802 clustersHFHAD_ = clusterAlgoHFHAD_.clusters();
02803
02804
02805
02806 fillRecHitMask( mask, rechitsPS_ );
02807 clusterAlgoPS_.doClustering( rechitsPS_, mask );
02808 clustersPS_ = clusterAlgoPS_.clusters();
02809
02810 fillOutEventWithClusters( *clustersPS_ );
02811
02812 }
02813
02814
02815
02816 void
02817 PFRootEventManager::fillOutEventWithClusters(const reco::PFClusterCollection&
02818 clusters) {
02819
02820 if(!outEvent_) return;
02821
02822 for(unsigned i=0; i<clusters.size(); i++) {
02823 EventColin::Cluster cluster;
02824 cluster.eta = clusters[i].position().Eta();
02825 cluster.phi = clusters[i].position().Phi();
02826 cluster.e = clusters[i].energy();
02827 cluster.layer = clusters[i].layer();
02828 if (!useHO_ && cluster.layer==PFLayer::HCAL_BARREL2) continue;
02829 cluster.type = 1;
02830
02831 reco::PFTrajectoryPoint::LayerType tpLayer =
02832 reco::PFTrajectoryPoint::NLayers;
02833 switch( clusters[i].layer() ) {
02834 case PFLayer::ECAL_BARREL:
02835 case PFLayer::ECAL_ENDCAP:
02836 tpLayer = reco::PFTrajectoryPoint::ECALEntrance;
02837 break;
02838 case PFLayer::HCAL_BARREL1:
02839 case PFLayer::HCAL_ENDCAP:
02840 tpLayer = reco::PFTrajectoryPoint::HCALEntrance;
02841 break;
02842
02843 case PFLayer::HCAL_BARREL2:
02844 tpLayer = reco::PFTrajectoryPoint::HOLayer;
02845 break;
02846
02847 default:
02848 break;
02849 }
02850 if(tpLayer < reco::PFTrajectoryPoint::NLayers) {
02851 try {
02852 double peta = -10;
02853 double phi = -10;
02854 double pe = -10;
02855
02856 const reco::PFSimParticle& ptc
02857 = closestParticle( tpLayer,
02858 cluster.eta, cluster.phi,
02859 peta, phi, pe );
02860
02861
02862 cluster.particle.eta = peta;
02863 cluster.particle.phi = phi;
02864 cluster.particle.e = pe;
02865 cluster.particle.pdgCode = ptc.pdgCode();
02866
02867
02868 }
02869 catch( std::exception& err ) {
02870
02871 }
02872 }
02873
02874 outEvent_->addCluster(cluster);
02875 }
02876 }
02877
02878
02879 void
02880 PFRootEventManager::fillOutEventWithSimParticles(const reco::PFSimParticleCollection& trueParticles ) {
02881
02882 if(!outEvent_) return;
02883
02884 for ( unsigned i=0; i < trueParticles.size(); i++) {
02885
02886 const reco::PFSimParticle& ptc = trueParticles[i];
02887
02888 unsigned ntrajpoints = ptc.nTrajectoryPoints();
02889
02890 if(ptc.daughterIds().empty() ) {
02891 reco::PFTrajectoryPoint::LayerType ecalEntrance
02892 = reco::PFTrajectoryPoint::ECALEntrance;
02893
02894 if(ntrajpoints == 3) {
02895
02896
02897
02898 ecalEntrance = static_cast<reco::PFTrajectoryPoint::LayerType>(1);
02899 }
02900
02901
02902 const reco::PFTrajectoryPoint& tpatecal
02903 = ptc.extrapolatedPoint( ecalEntrance );
02904
02905 EventColin::Particle outptc;
02906 outptc.eta = tpatecal.position().Eta();
02907 outptc.phi = tpatecal.position().Phi();
02908 outptc.e = tpatecal.momentum().E();
02909 outptc.pdgCode = ptc.pdgCode();
02910
02911
02912 outEvent_->addParticle(outptc);
02913 }
02914 }
02915 }
02916
02917 void
02918 PFRootEventManager::fillOutEventWithPFCandidates(const reco::PFCandidateCollection& pfCandidates ) {
02919
02920 if(!outEvent_) return;
02921
02922 for ( unsigned i=0; i < pfCandidates.size(); i++) {
02923
02924 const reco::PFCandidate& candidate = pfCandidates[i];
02925
02926 EventColin::Particle outptc;
02927 outptc.eta = candidate.eta();
02928 outptc.phi = candidate.phi();
02929 outptc.e = candidate.energy();
02930 outptc.pdgCode = candidate.particleId();
02931
02932
02933 outEvent_->addCandidate(outptc);
02934 }
02935 }
02936
02937
02938 void
02939 PFRootEventManager::fillOutEventWithCaloTowers( const CaloTowerCollection& cts ){
02940
02941 if(!outEvent_) return;
02942
02943 for ( unsigned i=0; i < cts.size(); i++) {
02944
02945 const CaloTower& ct = cts[i];
02946
02947 EventColin::CaloTower outct;
02948 outct.e = ct.energy();
02949 outct.ee = ct.emEnergy();
02950 outct.eh = ct.hadEnergy();
02951
02952 outEvent_->addCaloTower( outct );
02953 }
02954 }
02955
02956
02957 void
02958 PFRootEventManager::fillOutEventWithBlocks( const reco::PFBlockCollection&
02959 blocks ) {
02960
02961 if(!outEvent_) return;
02962
02963 for ( unsigned i=0; i < blocks.size(); i++) {
02964
02965
02966
02967 EventColin::Block outblock;
02968
02969 outEvent_->addBlock( outblock );
02970 }
02971 }
02972
02973
02974
02975 void PFRootEventManager::particleFlow() {
02976
02977 if (verbosity_ == VERBOSE ) {
02978 cout <<"start particle flow"<<endl;
02979 }
02980
02981
02982 if( debug_) {
02983 cout<<"PFRootEventManager::particleFlow start"<<endl;
02984
02985
02986 }
02987
02988
02989 edm::OrphanHandle< reco::PFRecTrackCollection > trackh( &recTracks_,
02990 edm::ProductID(1) );
02991
02992 edm::OrphanHandle< reco::PFRecTrackCollection > displacedtrackh( &displacedRecTracks_,
02993 edm::ProductID(77) );
02994
02995 edm::OrphanHandle< reco::PFClusterCollection > ecalh( clustersECAL_.get(),
02996 edm::ProductID(2) );
02997
02998 edm::OrphanHandle< reco::PFClusterCollection > hcalh( clustersHCAL_.get(),
02999 edm::ProductID(3) );
03000
03001 edm::OrphanHandle< reco::PFClusterCollection > hoh( clustersHO_.get(),
03002 edm::ProductID(21) );
03003
03004 edm::OrphanHandle< reco::PFClusterCollection > hfemh( clustersHFEM_.get(),
03005 edm::ProductID(31) );
03006
03007 edm::OrphanHandle< reco::PFClusterCollection > hfhadh( clustersHFHAD_.get(),
03008 edm::ProductID(32) );
03009
03010 edm::OrphanHandle< reco::PFClusterCollection > psh( clustersPS_.get(),
03011 edm::ProductID(4) );
03012
03013 edm::OrphanHandle< reco::GsfPFRecTrackCollection > gsftrackh( &gsfrecTracks_,
03014 edm::ProductID(5) );
03015
03016 edm::OrphanHandle< reco::MuonCollection > muonh( &muons_,
03017 edm::ProductID(6) );
03018
03019 edm::OrphanHandle< reco::PFDisplacedTrackerVertexCollection > nuclearh( &pfNuclearTrackerVertex_,
03020 edm::ProductID(7) );
03021
03022
03023
03024
03025 edm::OrphanHandle< reco::PFConversionCollection > convh( &conversion_,
03026 edm::ProductID(8) );
03027
03028 edm::OrphanHandle< reco::PFV0Collection > v0( &v0_,
03029 edm::ProductID(9) );
03030
03031
03032 edm::OrphanHandle< reco::VertexCollection > vertexh( &primaryVertices_,
03033 edm::ProductID(10) );
03034
03035 edm::OrphanHandle< reco::GsfPFRecTrackCollection > convBremGsftrackh( &convBremGsfrecTracks_,
03036 edm::ProductID(11) );
03037
03038 edm::OrphanHandle< reco::PhotonCollection > photonh( &photons_, edm::ProductID(12) ) ;
03039
03040 vector<bool> trackMask;
03041 fillTrackMask( trackMask, recTracks_ );
03042 vector<bool> gsftrackMask;
03043 fillTrackMask( gsftrackMask, gsfrecTracks_ );
03044 vector<bool> ecalMask;
03045 fillClusterMask( ecalMask, *clustersECAL_ );
03046 vector<bool> hcalMask;
03047 fillClusterMask( hcalMask, *clustersHCAL_ );
03048
03049
03050 vector<bool> hoMask;
03051 if (useHO_) {fillClusterMask( hoMask, *clustersHO_ );}
03052
03053 vector<bool> hfemMask;
03054 fillClusterMask( hfemMask, *clustersHFEM_ );
03055 vector<bool> hfhadMask;
03056 fillClusterMask( hfhadMask, *clustersHFHAD_ );
03057 vector<bool> psMask;
03058 fillClusterMask( psMask, *clustersPS_ );
03059 vector<bool> photonMask;
03060 fillPhotonMask( photonMask, photons_ );
03061
03062 if ( !useAtHLT_ )
03063 pfBlockAlgo_.setInput( trackh, gsftrackh, convBremGsftrackh,
03064 muonh, nuclearh, displacedtrackh, convh, v0,
03065 ecalh, hcalh, hoh, hfemh, hfhadh, psh,
03066 photonh, trackMask,gsftrackMask,
03067 ecalMask, hcalMask, hoMask, hfemMask, hfhadMask, psMask,photonMask );
03068 else
03069 pfBlockAlgo_.setInput( trackh, muonh, ecalh, hcalh, hfemh, hfhadh, psh, hoh,
03070 trackMask, ecalMask, hcalMask, hoMask, psMask);
03071
03072 pfBlockAlgo_.findBlocks();
03073
03074 if( debug_) cout<<pfBlockAlgo_<<endl;
03075
03076 pfBlocks_ = pfBlockAlgo_.transferBlocks();
03077
03078 pfAlgo_.setPFVertexParameters(true, primaryVertices_);
03079 if(useEGElectrons_)
03080 pfAlgo_.setEGElectronCollection(egammaElectrons_);
03081
03082 pfAlgo_.reconstructParticles( *pfBlocks_.get() );
03083
03084
03085 pfAlgo_.postMuonCleaning(muonsHandle_, *vertexh);
03086
03087 if(usePFElectrons_) {
03088 pfCandidateElectronExtras_= pfAlgo_.transferElectronExtra();
03089 edm::OrphanHandle<reco::PFCandidateElectronExtraCollection > electronExtraProd(&(*pfCandidateElectronExtras_),edm::ProductID(20));
03090 pfAlgo_.setElectronExtraRef(electronExtraProd);
03091 }
03092
03093 pfAlgo_.checkCleaning( rechitsCLEANED_ );
03094
03095 if( debug_) cout<< pfAlgo_<<endl;
03096 pfCandidates_ = pfAlgo_.transferCandidates();
03097
03098
03099 fillOutEventWithPFCandidates( *pfCandidates_ );
03100
03101 if( debug_) cout<<"PFRootEventManager::particleFlow stop"<<endl;
03102 }
03103
03104 void PFRootEventManager::pfCandCompare(int entry) {
03105
03106
03107
03108
03109
03110
03111
03112 bool differentSize = pfCandCMSSW_.size() != pfCandidates_->size();
03113 if ( differentSize ) {
03114 cout << "+++WARNING+++ PFCandidate size changed for entry "
03115 << entry << " !" << endl
03116 << " - original size : " << pfCandCMSSW_.size() << endl
03117 << " - current size : " << pfCandidates_->size() << endl;
03118 } else {
03119 for(unsigned i=0; i<pfCandidates_->size(); i++) {
03120 double deltaE = (*pfCandidates_)[i].energy()-pfCandCMSSW_[i].energy();
03121 double deltaEta = (*pfCandidates_)[i].eta()-pfCandCMSSW_[i].eta();
03122 double deltaPhi = (*pfCandidates_)[i].phi()-pfCandCMSSW_[i].phi();
03123 if ( fabs(deltaE) > 1E-4 ||
03124 fabs(deltaEta) > 1E-9 ||
03125 fabs(deltaPhi) > 1E-9 ) {
03126 cout << "+++WARNING+++ PFCandidate " << i
03127 << " changed for entry " << entry << " ! " << endl
03128 << " - Original : " << pfCandCMSSW_[i] << endl
03129 << " - Current : " << (*pfCandidates_)[i] << endl
03130 << " DeltaE = : " << deltaE << endl
03131 << " DeltaEta = : " << deltaEta << endl
03132 << " DeltaPhi = : " << deltaPhi << endl << endl;
03133 }
03134 }
03135 }
03136 }
03137
03138
03139 void PFRootEventManager::reconstructGenJets() {
03140
03141 if (verbosity_ == VERBOSE || jetsDebug_) {
03142 cout<<endl;
03143 cout<<"start reconstruct GenJets --- "<<endl;
03144 cout<< " input gen particles for jet: all neutrinos removed ; muons present" << endl;
03145 }
03146
03147 genJets_.clear();
03148 genParticlesforJetsPtrs_.clear();
03149
03150 if ( !genParticlesforJets_.size() ) return;
03151
03152 for(unsigned i=0; i<genParticlesforJets_.size(); i++) {
03153
03154 const reco::GenParticle& genPart = *(genParticlesforJets_[i]);
03155
03156
03157
03158
03159 if (reco::isNeutrino( genPart )) continue;
03160
03161 if (std::abs(genPart.pdgId())<7 || std::abs(genPart.pdgId())==21 ) continue;
03162
03163 if (jetsDebug_ ) {
03164 cout << " #" << i << " PDG code:" << genPart.pdgId()
03165 << " status " << genPart.status()
03166 << ", p/pt/eta/phi: " << genPart.p() << '/' << genPart.pt()
03167 << '/' << genPart.eta() << '/' << genPart.phi() << endl;
03168 }
03169
03170 genParticlesforJetsPtrs_.push_back( refToPtr(genParticlesforJets_[i]) );
03171 }
03172
03173 vector<ProtoJet> protoJets;
03174 reconstructFWLiteJets(genParticlesforJetsPtrs_, protoJets );
03175
03176
03177
03178 int ijet = 0;
03179 typedef vector <ProtoJet>::const_iterator IPJ;
03180 for (IPJ ipj = protoJets.begin(); ipj != protoJets.end (); ipj++) {
03181 const ProtoJet& protojet = *ipj;
03182 const ProtoJet::Constituents& constituents = protojet.getTowerList();
03183
03184 reco::Jet::Point vertex (0,0,0);
03185 GenJet::Specific specific;
03186 JetMaker::makeSpecific(constituents, &specific);
03187
03188 GenJet newJet (protojet.p4(), vertex, specific);
03189
03190
03191
03192
03193
03194
03195
03196 ProtoJet::Constituents::const_iterator constituent = constituents.begin();
03197 for (; constituent != constituents.end(); ++constituent) {
03198
03199
03200 uint index = constituent->index();
03201 newJet.addDaughter( genParticlesforJetsPtrs_[index] );
03202 }
03203
03204 newJet.setJetArea(protojet.jetArea());
03205 newJet.setPileup(protojet.pileup());
03206 newJet.setNPasses(protojet.nPasses());
03207 ++ijet;
03208 if (jetsDebug_ ) cout<<" gen jet "<<ijet<<" "<<newJet.print()<<endl;
03209 genJets_.push_back (newJet);
03210
03211 }
03212
03213 }
03214
03215 void PFRootEventManager::reconstructCaloJets() {
03216
03217 if (verbosity_ == VERBOSE || jetsDebug_ ) {
03218 cout<<endl;
03219 cout<<"start reconstruct CaloJets --- "<<endl;
03220 }
03221 caloJets_.clear();
03222 caloTowersPtrs_.clear();
03223
03224 for( unsigned i=0; i<caloTowers_.size(); i++) {
03225 reco::CandidatePtr candPtr( &caloTowers_, i );
03226 caloTowersPtrs_.push_back( candPtr );
03227 }
03228
03229 reconstructFWLiteJets( caloTowersPtrs_, caloJets_ );
03230
03231 if (jetsDebug_ ) {
03232 for(unsigned ipj=0; ipj<caloJets_.size(); ipj++) {
03233 const ProtoJet& protojet = caloJets_[ipj];
03234 cout<<" calo jet "<<ipj<<" "<<protojet.pt() <<endl;
03235 }
03236 }
03237
03238 }
03239
03240
03241 void PFRootEventManager::reconstructPFJets() {
03242
03243 if (verbosity_ == VERBOSE || jetsDebug_) {
03244 cout<<endl;
03245 cout<<"start reconstruct PF Jets --- "<<endl;
03246 }
03247 pfJets_.clear();
03248 pfCandidatesPtrs_.clear();
03249
03250 for( unsigned i=0; i<pfCandidates_->size(); i++) {
03251 reco::CandidatePtr candPtr( pfCandidates_.get(), i );
03252 pfCandidatesPtrs_.push_back( candPtr );
03253 }
03254
03255 vector<ProtoJet> protoJets;
03256 reconstructFWLiteJets(pfCandidatesPtrs_, protoJets );
03257
03258
03259
03260 int ijet = 0;
03261 typedef vector <ProtoJet>::const_iterator IPJ;
03262 for (IPJ ipj = protoJets.begin(); ipj != protoJets.end (); ipj++) {
03263 const ProtoJet& protojet = *ipj;
03264 const ProtoJet::Constituents& constituents = protojet.getTowerList();
03265
03266 reco::Jet::Point vertex (0,0,0);
03267 PFJet::Specific specific;
03268 JetMaker::makeSpecific(constituents, &specific);
03269
03270 PFJet newJet (protojet.p4(), vertex, specific);
03271
03272
03273
03274
03275
03276
03277
03278 ProtoJet::Constituents::const_iterator constituent = constituents.begin();
03279 for (; constituent != constituents.end(); ++constituent) {
03280
03281
03282 uint index = constituent->index();
03283 newJet.addDaughter(pfCandidatesPtrs_[index]);
03284 }
03285
03286 newJet.setJetArea(protojet.jetArea());
03287 newJet.setPileup(protojet.pileup());
03288 newJet.setNPasses(protojet.nPasses());
03289 ++ijet;
03290 if (jetsDebug_ ) cout<<" PF jet "<<ijet<<" "<<newJet.print()<<endl;
03291 pfJets_.push_back (newJet);
03292
03293 }
03294
03295 }
03296
03297 void
03298 PFRootEventManager::reconstructFWLiteJets(const reco::CandidatePtrVector& Candidates, vector<ProtoJet>& output ) {
03299
03300
03301 JetReco::InputCollection input;
03302
03303 jetMaker_.applyCuts (Candidates, &input);
03304 if (jetAlgoType_==1) {
03306 jetMaker_.makeIterativeConeJets(input, &output);
03307 }
03308 if (jetAlgoType_==2) {
03309 jetMaker_.makeMidpointJets(input, &output);
03310 }
03311 if (jetAlgoType_==3) {
03312 jetMaker_.makeFastJets(input, &output);
03313 }
03314 if((jetAlgoType_>3)||(jetAlgoType_<0)) {
03315 cout<<"Unknown Jet Algo ! " <<jetAlgoType_ << endl;
03316 }
03317
03318
03319 }
03320
03321
03322
03324 double
03325 PFRootEventManager::tauBenchmark( const reco::PFCandidateCollection& candidates) {
03326
03327
03328
03329
03330 jetAlgo_.Clear();
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358 TLorentzVector partTOTMC;
03359 bool tauFound = false;
03360 bool tooManyTaus = false;
03361 if (fastsim_){
03362
03363 for ( unsigned i=0; i < trueParticles_.size(); i++) {
03364 const reco::PFSimParticle& ptc = trueParticles_[i];
03365 if (std::abs(ptc.pdgCode()) == 15) {
03366
03367 if( i ) tooManyTaus = true;
03368 else tauFound=true;
03369 }
03370 }
03371
03372 if(!tauFound || tooManyTaus ) {
03373
03374 return -9999;
03375 }
03376
03377
03378 const std::vector<int>& ptcdaughters = trueParticles_[0].daughterIds();
03379
03380
03381
03382
03383
03384 for ( unsigned int dapt=0; dapt < ptcdaughters.size(); ++dapt) {
03385
03386 const reco::PFTrajectoryPoint& tpatvtx
03387 = trueParticles_[ptcdaughters[dapt]].trajectoryPoint(0);
03388 TLorentzVector partMC;
03389 partMC.SetPxPyPzE(tpatvtx.momentum().Px(),
03390 tpatvtx.momentum().Py(),
03391 tpatvtx.momentum().Pz(),
03392 tpatvtx.momentum().E());
03393
03394 partTOTMC += partMC;
03395 if (tauBenchmarkDebug_) {
03396
03397 int pdgcode = trueParticles_[ptcdaughters[dapt]].pdgCode();
03398 cout << pdgcode << endl;
03399 cout << tpatvtx << endl;
03400 cout << partMC.Px() << " " << partMC.Py() << " "
03401 << partMC.Pz() << " " << partMC.E()
03402 << " PT="
03403 << sqrt(partMC.Px()*partMC.Px()+partMC.Py()*partMC.Py())
03404 << endl;
03405 }
03406 }
03407 }else{
03408
03409 uint itau=0;
03410 const HepMC::GenEvent* myGenEvent = MCTruth_.GetEvent();
03411 for ( HepMC::GenEvent::particle_const_iterator
03412 piter = myGenEvent->particles_begin();
03413 piter != myGenEvent->particles_end();
03414 ++piter ) {
03415
03416
03417 if (std::abs((*piter)->pdg_id())==15){
03418 itau++;
03419 tauFound=true;
03420 for ( HepMC::GenVertex::particles_out_const_iterator bp =
03421 (*piter)->end_vertex()->particles_out_const_begin();
03422 bp != (*piter)->end_vertex()->particles_out_const_end(); ++bp ) {
03423 uint nuId=std::abs((*bp)->pdg_id());
03424 bool isNeutrino=(nuId==12)||(nuId==14)||(nuId==16);
03425 if (!isNeutrino){
03426
03427
03428 TLorentzVector partMC;
03429 partMC.SetPxPyPzE((*bp)->momentum().x(),
03430 (*bp)->momentum().y(),
03431 (*bp)->momentum().z(),
03432 (*bp)->momentum().e());
03433 partTOTMC += partMC;
03434 }
03435 }
03436 }
03437 }
03438 if (itau>1) tooManyTaus=true;
03439
03440 if(!tauFound || tooManyTaus ) {
03441 cerr<<"PFRootEventManager::tauBenchmark : not a single tau event"<<endl;
03442 return -9999;
03443 }
03444 }
03445
03446
03447 EventColin::Jet jetmc;
03448
03449 jetmc.eta = partTOTMC.Eta();
03450 jetmc.phi = partTOTMC.Phi();
03451 jetmc.et = partTOTMC.Et();
03452 jetmc.e = partTOTMC.E();
03453
03454 if(outEvent_) outEvent_->addJetMC( jetmc );
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487 if (tauBenchmarkDebug_) {
03488 cout << " ET Vector=" << partTOTMC.Et()
03489 << " " << partTOTMC.Eta()
03490 << " " << partTOTMC.Phi() << endl; cout << endl;
03491 }
03492
03494
03495
03496
03497
03498 vector<TLorentzVector> allcalotowers;
03499
03500
03501 double threshCaloTowers = 1E-10;
03502 for ( unsigned int i = 0; i < caloTowers_.size(); ++i) {
03503
03504 if(caloTowers_[i].energy() < threshCaloTowers) {
03505
03506 continue;
03507 }
03508
03509 TLorentzVector caloT;
03510 TVector3 pepr( caloTowers_[i].eta(),
03511 caloTowers_[i].phi(),
03512 caloTowers_[i].energy());
03513 TVector3 pxyz = Utils::VectorEPRtoXYZ( pepr );
03514 caloT.SetPxPyPzE(pxyz.X(),pxyz.Y(),pxyz.Z(),caloTowers_[i].energy());
03515 allcalotowers.push_back(caloT);
03516
03517
03518 }
03519 if ( tauBenchmarkDebug_)
03520 cout << " RETRIEVED " << allcalotowers.size()
03521 << " CALOTOWER 4-VECTORS " << endl;
03522
03523
03524 jetAlgo_.Clear();
03525 const vector< PFJetAlgorithm::Jet >& caloTjets
03526 = jetAlgo_.FindJets( &allcalotowers );
03527
03528
03529 double JetEHTETmax = 0.0;
03530 for ( unsigned i = 0; i < caloTjets.size(); i++) {
03531 TLorentzVector jetmom = caloTjets[i].GetMomentum();
03532 double jetcalo_pt = sqrt(jetmom.Px()*jetmom.Px()+jetmom.Py()*jetmom.Py());
03533 double jetcalo_et = jetmom.Et();
03534
03535 EventColin::Jet jet;
03536 jet.eta = jetmom.Eta();
03537 jet.phi = jetmom.Phi();
03538 jet.et = jetmom.Et();
03539 jet.e = jetmom.E();
03540
03541 const vector<int>& indexes = caloTjets[i].GetIndexes();
03542 for( unsigned ii=0; ii<indexes.size(); ii++){
03543 jet.ee += caloTowers_[ indexes[ii] ].emEnergy();
03544 jet.eh += caloTowers_[ indexes[ii] ].hadEnergy();
03545 jet.ete += caloTowers_[ indexes[ii] ].emEt();
03546 jet.eth += caloTowers_[ indexes[ii] ].hadEt();
03547 }
03548
03549 if(outEvent_) outEvent_->addJetEHT( jet );
03550
03551 if ( tauBenchmarkDebug_) {
03552 cout << " ECAL+HCAL jet : " << caloTjets[i] << endl;
03553 cout << jetmom.Px() << " " << jetmom.Py() << " "
03554 << jetmom.Pz() << " " << jetmom.E()
03555 << " PT=" << jetcalo_pt << endl;
03556 }
03557
03558 if (jetcalo_et >= JetEHTETmax)
03559 JetEHTETmax = jetcalo_et;
03560 }
03561
03563
03564 vector<TLorentzVector> allrecparticles;
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576 for(unsigned i=0; i<candidates.size(); i++) {
03577
03578
03579
03580
03581
03582 const reco::PFCandidate& candidate = candidates[i];
03583
03584 if (tauBenchmarkDebug_) {
03585 cout << i << " " << candidate << endl;
03586 int type = candidate.particleId();
03587 cout << " type= " << type << " " << candidate.charge()
03588 << endl;
03589 }
03590
03591 const math::XYZTLorentzVector& PFpart = candidate.p4();
03592
03593 TLorentzVector partRec(PFpart.Px(),
03594 PFpart.Py(),
03595 PFpart.Pz(),
03596 PFpart.E());
03597
03598
03599 allrecparticles.push_back( partRec );
03600
03601 }
03602
03603
03604 if (tauBenchmarkDebug_)
03605 cout << " THERE ARE " << allrecparticles.size()
03606 << " RECONSTRUCTED 4-VECTORS" << endl;
03607
03608 jetAlgo_.Clear();
03609 const vector< PFJetAlgorithm::Jet >& PFjets
03610 = jetAlgo_.FindJets( &allrecparticles );
03611
03612 if (tauBenchmarkDebug_)
03613 cout << PFjets.size() << " PF Jets found" << endl;
03614 double JetPFETmax = 0.0;
03615 for ( unsigned i = 0; i < PFjets.size(); i++) {
03616 TLorentzVector jetmom = PFjets[i].GetMomentum();
03617 double jetpf_pt = sqrt(jetmom.Px()*jetmom.Px()+jetmom.Py()*jetmom.Py());
03618 double jetpf_et = jetmom.Et();
03619
03620 EventColin::Jet jet;
03621 jet.eta = jetmom.Eta();
03622 jet.phi = jetmom.Phi();
03623 jet.et = jetmom.Et();
03624 jet.e = jetmom.E();
03625
03626 if(outEvent_) outEvent_->addJetPF( jet );
03627
03628 if (tauBenchmarkDebug_) {
03629 cout <<" Rec jet : "<< PFjets[i] <<endl;
03630 cout << jetmom.Px() << " " << jetmom.Py() << " "
03631 << jetmom.Pz() << " " << jetmom.E()
03632 << " PT=" << jetpf_pt << " eta="<< jetmom.Eta()
03633 << " Phi=" << jetmom.Phi() << endl;
03634 cout << "------------------------------------------------" << endl;
03635 }
03636
03637 if (jetpf_et >= JetPFETmax)
03638 JetPFETmax = jetpf_et;
03639 }
03640
03641
03642
03643 double deltaEtEHT = JetEHTETmax - partTOTMC.Et();
03644 h_deltaETvisible_MCEHT_->Fill(deltaEtEHT);
03645
03646 double deltaEt = JetPFETmax - partTOTMC.Et();
03647 h_deltaETvisible_MCPF_ ->Fill(deltaEt);
03648
03649 if (verbosity_ == VERBOSE ) {
03650 cout << "tau benchmark E_T(PF) - E_T(true) = " << deltaEt << endl;
03651 }
03652
03653 return deltaEt/partTOTMC.Et();
03654 }
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706 string PFRootEventManager::expand(const string& oldString) const {
03707
03708 string newString = oldString;
03709
03710 string dollar = "$";
03711 string slash = "/";
03712
03713
03714 int dollarPos = newString.find(dollar,0);
03715 if( dollarPos == -1 ) return oldString;
03716
03717 int lengh = newString.find(slash,0) - newString.find(dollar,0) + 1;
03718 string env_variable =
03719 newString.substr( ( newString.find(dollar,0) + 1 ), lengh -2);
03720
03721 int begin = env_variable.find_first_of("{");
03722 int end = env_variable.find_last_of("}");
03723
03724
03725
03726
03727 env_variable = env_variable.substr( begin+1, end-1 );
03728
03729
03730
03731
03732 char* directory = getenv( env_variable.c_str() );
03733
03734 if(!directory) {
03735 cerr<<"please define environment variable $"<<env_variable<<endl;
03736 delete this;
03737 exit(1);
03738 }
03739 string sdir = directory;
03740 sdir += "/";
03741
03742 newString.replace( 0, lengh , sdir);
03743
03744 if (verbosity_ == VERBOSE ) {
03745 cout << "expand " <<oldString<<" to "<< newString << endl;
03746 }
03747
03748 return newString;
03749 }
03750
03751
03752 void
03753 PFRootEventManager::printMCCalib(ofstream& out) const {
03754
03755 if(!out) return;
03756
03757
03758
03759 const HepMC::GenEvent* myGenEvent = MCTruth_.GetEvent();
03760 if(!myGenEvent) return;
03761 int nGen = 0;
03762 for ( HepMC::GenEvent::particle_const_iterator
03763 piter = myGenEvent->particles_begin();
03764 piter != myGenEvent->particles_end();
03765 ++piter ) nGen++;
03766 int nSim = trueParticles_.size();
03767 if ( nGen != 1 || nSim != 1 ) return;
03768
03769
03770 if ( genJets_.size() != 1 ) return;
03771 double true_E = genJets_[0].p();
03772 double true_eta = genJets_[0].eta();
03773 double true_phi = genJets_[0].phi();
03774
03775
03776
03777 double rec_ECALEnergy = 0.;
03778 double rec_HCALEnergy = 0.;
03779 double deltaRMin = 999.;
03780 unsigned int theJet = 0;
03781 for ( unsigned int ijet=0; ijet<pfJets_.size(); ++ijet ) {
03782 double rec_ECAL = pfJets_[ijet].neutralEmEnergy();
03783 double rec_HCAL = pfJets_[ijet].neutralHadronEnergy();
03784 double rec_eta = pfJets_[0].eta();
03785 double rec_phi = pfJets_[0].phi();
03786 double deltaR = std::sqrt( (rec_eta-true_eta)*(rec_eta-true_eta)
03787 + (rec_phi-true_phi)*(rec_phi-true_phi) );
03788 if ( deltaR < deltaRMin ) {
03789 deltaRMin = deltaR;
03790 rec_ECALEnergy = rec_ECAL;
03791 rec_HCALEnergy = rec_HCAL;
03792 }
03793 }
03794 if ( deltaRMin > 0.1 ) return;
03795
03796 std::vector < PFCandidatePtr > constituents = pfJets_[theJet].getPFConstituents ();
03797 double pat_ECALEnergy = 0.;
03798 double pat_HCALEnergy = 0.;
03799 for (unsigned ic = 0; ic < constituents.size (); ++ic) {
03800 if ( constituents[ic]->particleId() < 4 ) continue;
03801 if ( constituents[ic]->particleId() == 4 )
03802 pat_ECALEnergy += constituents[ic]->rawEcalEnergy();
03803 else if ( constituents[ic]->particleId() == 5 )
03804 pat_HCALEnergy += constituents[ic]->rawHcalEnergy();
03805 }
03806
03807 out << true_eta << " " << true_phi << " " << true_E
03808 << " " << rec_ECALEnergy << " " << rec_HCALEnergy
03809 << " " << pat_ECALEnergy << " " << pat_HCALEnergy
03810 << " " << deltaRMin << std::endl;
03811 }
03812
03813 void PFRootEventManager::print(ostream& out,int maxNLines ) const {
03814
03815 if(!out) return;
03816
03817
03818
03819
03820 std::vector< std::list <simMatch> > candSimMatchTrack;
03821 std::vector< std::list <simMatch> > candSimMatchEcal;
03822 if( printMCTruthMatching_){
03823 mcTruthMatching( std::cout,
03824 *pfCandidates_,
03825 candSimMatchTrack,
03826 candSimMatchEcal);
03827 }
03828
03829
03830 if( printRecHits_ ) {
03831 out<<"ECAL RecHits ==============================================="<<endl;
03832 printRecHits(rechitsECAL_, clusterAlgoECAL_, out ); out<<endl;
03833 out<<"HCAL RecHits ==============================================="<<endl;
03834 printRecHits(rechitsHCAL_, clusterAlgoHCAL_, out ); out<<endl;
03835 if (useHO_) {
03836 out<<"HO RecHits ================================================="<<endl;
03837 printRecHits(rechitsHO_, clusterAlgoHO_, out ); out<<endl;
03838 }
03839 out<<"HFEM RecHits ==============================================="<<endl;
03840 printRecHits(rechitsHFEM_, clusterAlgoHFEM_, out ); out<<endl;
03841 out<<"HFHAD RecHits =============================================="<<endl;
03842 printRecHits(rechitsHFHAD_, clusterAlgoHFHAD_, out ); out<<endl;
03843 out<<"PS RecHits ================================================="<<endl;
03844 printRecHits(rechitsPS_, clusterAlgoPS_, out ); out<<endl;
03845 }
03846
03847 if( printClusters_ ) {
03848 out<<"ECAL Clusters ============================================="<<endl;
03849 printClusters( *clustersECAL_, out); out<<endl;
03850 out<<"HCAL Clusters ============================================="<<endl;
03851 printClusters( *clustersHCAL_, out); out<<endl;
03852 if (useHO_) {
03853 out<<"HO Clusters ==============================================="<<endl;
03854 printClusters( *clustersHO_, out); out<<endl;
03855 }
03856 out<<"HFEM Clusters ============================================="<<endl;
03857 printClusters( *clustersHFEM_, out); out<<endl;
03858 out<<"HFHAD Clusters ============================================"<<endl;
03859 printClusters( *clustersHFHAD_, out); out<<endl;
03860 out<<"PS Clusters ============================================="<<endl;
03861 printClusters( *clustersPS_, out); out<<endl;
03862 }
03863 bool printTracks = true;
03864 if( printTracks) {
03865
03866 }
03867 if( printPFBlocks_ ) {
03868 out<<"Particle Flow Blocks ======================================"<<endl;
03869 for(unsigned i=0; i<pfBlocks_->size(); i++) {
03870 out<<i<<" "<<(*pfBlocks_)[i]<<endl;
03871 }
03872 out<<endl;
03873 }
03874 if(printPFCandidates_) {
03875 out<<"Particle Flow Candidates =================================="<<endl;
03876 double mex = 0.;
03877 double mey = 0.;
03878 for(unsigned i=0; i<pfCandidates_->size(); i++) {
03879 const PFCandidate& pfc = (*pfCandidates_)[i];
03880 mex -= pfc.px();
03881 mey -= pfc.py();
03882 if(pfc.pt()>printPFCandidatesPtMin_)
03883 out<<i<<" " <<(*pfCandidates_)[i]<<endl;
03884 }
03885 out<<endl;
03886 out<< "MEX, MEY, MET ============================================" <<endl
03887 << mex << " " << mey << " " << sqrt(mex*mex+mey*mey);
03888 out<<endl;
03889 out<<endl;
03890
03891
03892
03893 if(printMCTruthMatching_){
03894 cout<<"MCTruthMatching Results"<<endl;
03895 for(unsigned icand=0; icand<pfCandidates_->size();
03896 icand++) {
03897 out <<icand<<" " <<(*pfCandidates_)[icand]<<endl;
03898 out << "is matching:" << endl;
03899
03900
03901 ITM it_t = candSimMatchTrack[icand].begin();
03902 ITM itend_t = candSimMatchTrack[icand].end();
03903 for(;it_t!=itend_t;++it_t){
03904 unsigned simid = it_t->second;
03905 out << "\tSimParticle " << trueParticles_[simid]
03906 <<endl;
03907 out << "\t\tthrough Track matching pTrectrack="
03908 << it_t->first << " GeV" << endl;
03909 }
03910
03911 ITM it_e = candSimMatchEcal[icand].begin();
03912 ITM itend_e = candSimMatchEcal[icand].end();
03913 for(;it_e!=itend_e;++it_e){
03914 unsigned simid = it_e->second;
03915 out << "\tSimParticle " << trueParticles_[simid]
03916 << endl;
03917 out << "\t\tsimparticle contributing to a total of "
03918 << it_e->first
03919 << " GeV of its ECAL cluster"
03920 << endl;
03921 }
03922 cout<<"________________"<<endl;
03923 }
03924 }
03925 }
03926 if(printPFJets_) {
03927 out<<"Jets ====================================================="<<endl;
03928 out<<"Particle Flow: "<<endl;
03929 for(unsigned i=0; i<pfJets_.size(); i++) {
03930 if (pfJets_[i].pt() > printPFJetsPtMin_ )
03931 out<<i<<pfJets_[i].print()<<endl;
03932 }
03933 out<<endl;
03934 out<<"Generated: "<<endl;
03935 for(unsigned i=0; i<genJets_.size(); i++) {
03936 if (genJets_[i].pt() > printPFJetsPtMin_ )
03937 out<<i<<genJets_[i].print()<<endl;
03938
03939 }
03940 out<<endl;
03941 out<<"Calo: "<<endl;
03942 for(unsigned i=0; i<caloJets_.size(); i++) {
03943 out<<"pt = "<<caloJets_[i].pt()<<endl;
03944 }
03945 out<<endl;
03946 }
03947 if( printSimParticles_ ) {
03948 out<<"Sim Particles ==========================================="<<endl;
03949
03950 for(unsigned i=0; i<trueParticles_.size(); i++) {
03951 if( trackInsideGCut( trueParticles_[i]) ){
03952
03953 const reco::PFSimParticle& ptc = trueParticles_[i];
03954
03955
03956 const reco::PFTrajectoryPoint& tp0 = ptc.extrapolatedPoint( 0 );
03957
03958 if(tp0.momentum().pt()>printSimParticlesPtMin_)
03959 out<<"\t"<<trueParticles_[i]<<endl;
03960 }
03961 }
03962
03963
03964
03965 if(printMCTruthMatching_) {
03966 cout<<"MCTruthMatching Results"<<endl;
03967 for ( unsigned i=0; i < trueParticles_.size(); i++) {
03968 cout << "==== Particle Simulated " << i << endl;
03969 const reco::PFSimParticle& ptc = trueParticles_[i];
03970 out <<i<<" "<<trueParticles_[i]<<endl;
03971
03972 if(!ptc.daughterIds().empty()){
03973 cout << "Look at the desintegration products" << endl;
03974 cout << endl;
03975 continue;
03976 }
03977
03978
03979 if(ptc.rectrackId() != 99999){
03980 cout << "matching pfCandidate (trough tracking): " << endl;
03981 for( unsigned icand=0; icand<pfCandidates_->size()
03982 ; icand++ )
03983 {
03984 ITM it = candSimMatchTrack[icand].begin();
03985 ITM itend = candSimMatchTrack[icand].end();
03986 for(;it!=itend;++it)
03987 if( i == it->second ){
03988 out<<icand<<" "<<(*pfCandidates_)[icand]<<endl;
03989 cout << endl;
03990 }
03991 }
03992 }
03993
03994
03995 vector<unsigned> rechitSimIDs
03996 = ptc.recHitContrib();
03997 vector<double> rechitSimFrac
03998 = ptc.recHitContribFrac();
03999
04000 if( !rechitSimIDs.size() ) continue;
04001
04002 cout << "matching pfCandidate (through ECAL): " << endl;
04003
04004
04005 double totalEcalE = 0.0;
04006 for(unsigned irh=0; irh<rechitsECAL_.size();++irh)
04007 for ( unsigned isimrh=0; isimrh < rechitSimIDs.size();
04008 isimrh++ )
04009 if(rechitSimIDs[isimrh] == rechitsECAL_[irh].detId())
04010 totalEcalE += (rechitsECAL_[irh].energy()*rechitSimFrac[isimrh]/100.0);
04011 cout << "For info, this particle deposits E=" << totalEcalE
04012 << "(GeV) in the ECAL" << endl;
04013
04014 for( unsigned icand=0; icand<pfCandidates_->size()
04015 ; icand++ )
04016 {
04017 ITM it = candSimMatchEcal[icand].begin();
04018 ITM itend = candSimMatchEcal[icand].end();
04019 for(;it!=itend;++it)
04020 if( i == it->second )
04021 out<<icand<<" "<<it->first<<"GeV "<<(*pfCandidates_)[icand]<<endl;
04022 }
04023 cout << endl;
04024 }
04025 }
04026
04027 }
04028
04029
04030 if ( printGenParticles_ ) {
04031 printGenParticles(out,maxNLines);
04032 }
04033 }
04034
04035
04036 void
04037 PFRootEventManager::printGenParticles(std::ostream& out,
04038 int maxNLines) const {
04039
04040
04041 const HepMC::GenEvent* myGenEvent = MCTruth_.GetEvent();
04042 if(!myGenEvent) return;
04043
04044 out<<"GenParticles ==========================================="<<endl;
04045
04046 std::cout << "Id Gen Name eta phi pT E Vtx1 "
04047 << " x y z "
04048 << "Moth Vtx2 eta phi R Z Da1 Da2 Ecal?"
04049 << std::endl;
04050
04051 int nLines = 0;
04052 for ( HepMC::GenEvent::particle_const_iterator
04053 piter = myGenEvent->particles_begin();
04054 piter != myGenEvent->particles_end();
04055 ++piter ) {
04056
04057 if( nLines == maxNLines) break;
04058 nLines++;
04059
04060 HepMC::GenParticle* p = *piter;
04061
04062 int partId = p->pdg_id();
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098
04099
04100
04101
04102
04103
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148
04149
04150
04151
04152
04153
04154
04155
04156
04157
04158
04159
04160
04161
04162
04163
04164
04165
04166
04167
04168
04169 std::string latexString;
04170 std::string name = getGenParticleName(partId,latexString);
04171
04172 math::XYZTLorentzVector momentum1(p->momentum().px(),
04173 p->momentum().py(),
04174 p->momentum().pz(),
04175 p->momentum().e() );
04176
04177 if(momentum1.pt()<printGenParticlesPtMin_) continue;
04178
04179 int vertexId1 = 0;
04180
04181 if ( !p->production_vertex() && p->pdg_id() == 2212 ) continue;
04182
04183 math::XYZVector vertex1;
04184 vertexId1 = -1;
04185
04186 if(p->production_vertex() ) {
04187 vertex1.SetCoordinates( p->production_vertex()->position().x()/10.,
04188 p->production_vertex()->position().y()/10.,
04189 p->production_vertex()->position().z()/10. );
04190 vertexId1 = p->production_vertex()->barcode();
04191 }
04192
04193 out.setf(std::ios::fixed, std::ios::floatfield);
04194 out.setf(std::ios::right, std::ios::adjustfield);
04195
04196 out << std::setw(4) << p->barcode() << " "
04197 << name;
04198
04199 for(unsigned int k=0;k<11-name.length() && k<12; k++) out << " ";
04200
04201 double eta = momentum1.eta();
04202 if ( eta > +10. ) eta = +10.;
04203 if ( eta < -10. ) eta = -10.;
04204
04205 out << std::setw(6) << std::setprecision(2) << eta << " "
04206 << std::setw(6) << std::setprecision(2) << momentum1.phi() << " "
04207 << std::setw(7) << std::setprecision(2) << momentum1.pt() << " "
04208 << std::setw(7) << std::setprecision(2) << momentum1.e() << " "
04209 << std::setw(4) << vertexId1 << " "
04210 << std::setw(6) << std::setprecision(1) << vertex1.x() << " "
04211 << std::setw(6) << std::setprecision(1) << vertex1.y() << " "
04212 << std::setw(6) << std::setprecision(1) << vertex1.z() << " ";
04213
04214
04215 if( p->production_vertex() ) {
04216 if ( p->production_vertex()->particles_in_size() ) {
04217 const HepMC::GenParticle* mother =
04218 *(p->production_vertex()->particles_in_const_begin());
04219
04220 out << std::setw(4) << mother->barcode() << " ";
04221 }
04222 else
04223 out << " " ;
04224 }
04225
04226 if ( p->end_vertex() ) {
04227 math::XYZTLorentzVector vertex2(p->end_vertex()->position().x()/10.,
04228 p->end_vertex()->position().y()/10.,
04229 p->end_vertex()->position().z()/10.,
04230 p->end_vertex()->position().t()/10.);
04231 int vertexId2 = p->end_vertex()->barcode();
04232
04233 std::vector<const HepMC::GenParticle*> children;
04234 HepMC::GenVertex::particles_out_const_iterator firstDaughterIt =
04235 p->end_vertex()->particles_out_const_begin();
04236 HepMC::GenVertex::particles_out_const_iterator lastDaughterIt =
04237 p->end_vertex()->particles_out_const_end();
04238 for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) {
04239 children.push_back(*firstDaughterIt);
04240 }
04241
04242 out << std::setw(4) << vertexId2 << " "
04243 << std::setw(6) << std::setprecision(2) << vertex2.eta() << " "
04244 << std::setw(6) << std::setprecision(2) << vertex2.phi() << " "
04245 << std::setw(5) << std::setprecision(1) << vertex2.pt() << " "
04246 << std::setw(6) << std::setprecision(1) << vertex2.z() << " ";
04247
04248 for ( unsigned id=0; id<children.size(); ++id )
04249 out << std::setw(4) << children[id]->barcode() << " ";
04250 }
04251 out << std::endl;
04252 }
04253 }
04254
04255 void PFRootEventManager::printRecHits(const reco::PFRecHitCollection& rechits, const PFClusterAlgo& clusterAlgo, ostream& out) const{
04256
04257 for(unsigned i=0; i<rechits.size(); i++) {
04258 string seedstatus = " ";
04259 if(clusterAlgo.isSeed(i) )
04260 seedstatus = "SEED";
04261 printRecHit(rechits[i], i, seedstatus.c_str(), out);
04262 }
04263 return;
04264 }
04265
04266 void PFRootEventManager::printRecHit(const reco::PFRecHit& rh,
04267 unsigned index,
04268 const char* seedstatus,
04269 ostream& out) const {
04270
04271 if(!out) return;
04272 double eta = rh.position().Eta();
04273 double phi = rh.position().Phi();
04274 double energy = rh.energy();
04275
04276 if(energy<printRecHitsEMin_) return;
04277
04278 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04279 if( !cutg || cutg->IsInside( eta, phi ) )
04280 out<<index<<"\t"<<seedstatus<<" "<<rh<<endl;
04281 }
04282
04283 void PFRootEventManager::printClusters(const reco::PFClusterCollection& clusters,
04284 ostream& out ) const {
04285 for(unsigned i=0; i<clusters.size(); i++) {
04286 printCluster(clusters[i], out);
04287 }
04288 return;
04289 }
04290
04291 void PFRootEventManager::printCluster(const reco::PFCluster& cluster,
04292 ostream& out ) const {
04293
04294 if(!out) return;
04295
04296 double eta = cluster.position().Eta();
04297 double phi = cluster.position().Phi();
04298 double energy = cluster.energy();
04299
04300 if(energy<printClustersEMin_) return;
04301
04302 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04303 if( !cutg || cutg->IsInside( eta, phi ) )
04304 out<<cluster<<endl;
04305 }
04306
04307 bool PFRootEventManager::trackInsideGCut( const reco::PFTrack& track ) const {
04308
04309 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04310 if(!cutg) return true;
04311
04312 const vector< reco::PFTrajectoryPoint >& points = track.trajectoryPoints();
04313
04314 for( unsigned i=0; i<points.size(); i++) {
04315 if( ! points[i].isValid() ) continue;
04316
04317 const math::XYZPoint& pos = points[i].position();
04318 if( cutg->IsInside( pos.Eta(), pos.Phi() ) ) return true;
04319 }
04320
04321
04322 return false;
04323 }
04324
04325
04326 void
04327 PFRootEventManager::fillRecHitMask( vector<bool>& mask,
04328 const reco::PFRecHitCollection& rechits )
04329 const {
04330
04331 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04332 if(!cutg) {
04333 mask.resize( rechits.size(), true);
04334 return;
04335 }
04336
04337 mask.clear();
04338 mask.reserve( rechits.size() );
04339 for(unsigned i=0; i<rechits.size(); i++) {
04340
04341 double eta = rechits[i].position().Eta();
04342 double phi = rechits[i].position().Phi();
04343
04344 if( cutg->IsInside( eta, phi ) )
04345 mask.push_back( true );
04346 else
04347 mask.push_back( false );
04348 }
04349 }
04350
04351 void
04352 PFRootEventManager::fillClusterMask(vector<bool>& mask,
04353 const reco::PFClusterCollection& clusters)
04354 const {
04355
04356 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04357 if(!cutg) return;
04358
04359 mask.clear();
04360 mask.reserve( clusters.size() );
04361 for(unsigned i=0; i<clusters.size(); i++) {
04362
04363 double eta = clusters[i].position().Eta();
04364 double phi = clusters[i].position().Phi();
04365
04366 if( cutg->IsInside( eta, phi ) )
04367 mask.push_back( true );
04368 else
04369 mask.push_back( false );
04370 }
04371 }
04372
04373 void
04374 PFRootEventManager::fillTrackMask(vector<bool>& mask,
04375 const reco::PFRecTrackCollection& tracks)
04376 const {
04377
04378 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04379 if(!cutg) return;
04380
04381 mask.clear();
04382 mask.reserve( tracks.size() );
04383 for(unsigned i=0; i<tracks.size(); i++) {
04384 if( trackInsideGCut( tracks[i] ) )
04385 mask.push_back( true );
04386 else
04387 mask.push_back( false );
04388 }
04389 }
04390
04391 void
04392 PFRootEventManager::fillPhotonMask(vector<bool>& mask,
04393 const reco::PhotonCollection& photons)
04394 const {
04395
04396 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04397 if(!cutg) return;
04398
04399 mask.clear();
04400 mask.reserve( photons.size() );
04401 for(unsigned i=0; i<photons.size(); i++) {
04402 double eta = photons[i].caloPosition().Eta();
04403 double phi = photons[i].caloPosition().Phi();
04404 if( cutg->IsInside( eta, phi ) )
04405 mask.push_back( true );
04406 else
04407 mask.push_back( false );
04408 }
04409 }
04410
04411
04412 void
04413 PFRootEventManager::fillTrackMask(vector<bool>& mask,
04414 const reco::GsfPFRecTrackCollection& tracks)
04415 const {
04416
04417 TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
04418 if(!cutg) return;
04419
04420 mask.clear();
04421 mask.reserve( tracks.size() );
04422 for(unsigned i=0; i<tracks.size(); i++) {
04423 if( trackInsideGCut( tracks[i] ) )
04424 mask.push_back( true );
04425 else
04426 mask.push_back( false );
04427 }
04428 }
04429
04430
04431 const reco::PFSimParticle&
04432 PFRootEventManager::closestParticle( reco::PFTrajectoryPoint::LayerType layer,
04433 double eta, double phi,
04434 double& peta, double& pphi, double& pe)
04435 const {
04436
04437
04438 if( trueParticles_.empty() ) {
04439 string err = "PFRootEventManager::closestParticle : ";
04440 err += "vector of PFSimParticles is empty";
04441 throw std::length_error( err.c_str() );
04442 }
04443
04444 double mindist2 = 99999999;
04445 unsigned iClosest=0;
04446 for(unsigned i=0; i<trueParticles_.size(); i++) {
04447
04448 const reco::PFSimParticle& ptc = trueParticles_[i];
04449
04450
04451
04452 if( layer >= reco::PFTrajectoryPoint::NLayers ||
04453 ptc.nTrajectoryMeasurements() + layer >=
04454 ptc.nTrajectoryPoints() ) {
04455 continue;
04456 }
04457
04458 const reco::PFTrajectoryPoint& tp
04459 = ptc.extrapolatedPoint( layer );
04460
04461 peta = tp.position().Eta();
04462 pphi = tp.position().Phi();
04463 pe = tp.momentum().E();
04464
04465 double deta = peta - eta;
04466 double dphi = pphi - phi;
04467
04468 double dist2 = deta*deta + dphi*dphi;
04469
04470 if(dist2<mindist2) {
04471 mindist2 = dist2;
04472 iClosest = i;
04473 }
04474 }
04475
04476 return trueParticles_[iClosest];
04477 }
04478
04479
04480
04481
04482 void
04483 PFRootEventManager::readCMSSWJets() {
04484
04485 cout<<"CMSSW Gen jets : size = " << genJetsCMSSW_.size() << endl;
04486 for ( unsigned i = 0; i < genJetsCMSSW_.size(); i++) {
04487 cout<<"Gen jet Et : " << genJetsCMSSW_[i].et() << endl;
04488 }
04489 cout<<"CMSSW PF jets : size = " << pfJetsCMSSW_.size() << endl;
04490 for ( unsigned i = 0; i < pfJetsCMSSW_.size(); i++) {
04491 cout<<"PF jet Et : " << pfJetsCMSSW_[i].et() << endl;
04492 }
04493 cout<<"CMSSW Calo jets : size = " << caloJetsCMSSW_.size() << endl;
04494 for ( unsigned i = 0; i < caloJetsCMSSW_.size(); i++) {
04495 cout<<"Calo jet Et : " << caloJetsCMSSW_[i].et() << endl;
04496 }
04497 }
04498
04499 std::string PFRootEventManager::getGenParticleName(int partId, std::string &latexString) const
04500 {
04501 std::string name;
04502 switch(partId) {
04503 case 1: { name = "d";latexString="d"; break; }
04504 case 2: { name = "u";latexString="u";break; }
04505 case 3: { name = "s";latexString="s" ;break; }
04506 case 4: { name = "c";latexString="c" ; break; }
04507 case 5: { name = "b";latexString="b" ; break; }
04508 case 6: { name = "t";latexString="t" ; break; }
04509 case -1: { name = "~d";latexString="#bar{d}" ; break; }
04510 case -2: { name = "~u";latexString="#bar{u}" ; break; }
04511 case -3: { name = "~s";latexString="#bar{s}" ; break; }
04512 case -4: { name = "~c";latexString="#bar{c}" ; break; }
04513 case -5: { name = "~b";latexString="#bar{b}" ; break; }
04514 case -6: { name = "~t";latexString="#bar{t}" ; break; }
04515 case 11: { name = "e-";latexString=name ; break; }
04516 case -11: { name = "e+";latexString=name ; break; }
04517 case 12: { name = "nu_e";latexString="#nu_{e}" ; break; }
04518 case -12: { name = "~nu_e";latexString="#bar{#nu}_{e}" ; break; }
04519 case 13: { name = "mu-";latexString="#mu-" ; break; }
04520 case -13: { name = "mu+";latexString="#mu+" ; break; }
04521 case 14: { name = "nu_mu";latexString="#nu_{mu}" ; break; }
04522 case -14: { name = "~nu_mu";latexString="#bar{#nu}_{#mu}"; break; }
04523 case 15: { name = "tau-";latexString="#tau^{-}" ; break; }
04524 case -15: { name = "tau+";latexString="#tau^{+}" ; break; }
04525 case 16: { name = "nu_tau";latexString="#nu_{#tau}" ; break; }
04526 case -16: { name = "~nu_tau";latexString="#bar{#nu}_{#tau}"; break; }
04527 case 21: { name = "gluon";latexString= name; break; }
04528 case 22: { name = "gamma";latexString= "#gamma"; break; }
04529 case 23: { name = "Z0";latexString="Z^{0}" ; break; }
04530 case 24: { name = "W+";latexString="W^{+}" ; break; }
04531 case 25: { name = "H0";latexString=name ; break; }
04532 case -24: { name = "W-";latexString="W^{-}" ; break; }
04533 case 111: { name = "pi0";latexString="#pi^{0}" ; break; }
04534 case 113: { name = "rho0";latexString="#rho^{0}" ; break; }
04535 case 223: { name = "omega";latexString="#omega" ; break; }
04536 case 333: { name = "phi";latexString= "#phi"; break; }
04537 case 443: { name = "J/psi";latexString="J/#psi" ; break; }
04538 case 553: { name = "Upsilon";latexString="#Upsilon" ; break; }
04539 case 130: { name = "K0L";latexString=name ; break; }
04540 case 211: { name = "pi+";latexString="#pi^{+}" ; break; }
04541 case -211: { name = "pi-";latexString="#pi^{-}" ; break; }
04542 case 213: { name = "rho+";latexString="#rho^{+}" ; break; }
04543 case -213: { name = "rho-";latexString="#rho^{-}" ; break; }
04544 case 221: { name = "eta";latexString="#eta" ; break; }
04545 case 331: { name = "eta'";latexString="#eta'" ; break; }
04546 case 441: { name = "etac";latexString="#eta_{c}" ; break; }
04547 case 551: { name = "etab";latexString= "#eta_{b}"; break; }
04548 case 310: { name = "K0S";latexString=name ; break; }
04549 case 311: { name = "K0";latexString="K^{0}" ; break; }
04550 case -311: { name = "Kbar0";latexString="#bar{#Kappa}^{0}" ; break; }
04551 case 321: { name = "K+";latexString= "K^{+}"; break; }
04552 case -321: { name = "K-";latexString="K^{-}"; break; }
04553 case 411: { name = "D+";latexString="D^{+}" ; break; }
04554 case -411: { name = "D-";latexString="D^{-}"; break; }
04555 case 421: { name = "D0";latexString="D^{0}" ; break; }
04556 case -421: { name = "D0-bar";latexString="#overline{D^{0}}" ; break; }
04557 case 423: { name = "D*0";latexString="D^{*0}" ; break; }
04558 case -423: { name = "D*0-bar";latexString="#overline{D^{*0}}" ; break; }
04559 case 431: { name = "Ds_+";latexString="Ds_{+}" ; break; }
04560 case -431: { name = "Ds_-";latexString="Ds_{-}" ; break; }
04561 case 511: { name = "B0";latexString= name; break; }
04562 case 521: { name = "B+";latexString="B^{+}" ; break; }
04563 case -521: { name = "B-";latexString="B^{-}" ; break; }
04564 case 531: { name = "Bs_0";latexString="Bs_{0}" ; break; }
04565 case -531: { name = "anti-Bs_0";latexString="#overline{Bs_{0}}" ; break; }
04566 case 541: { name = "Bc_+";latexString="Bc_{+}" ; break; }
04567 case -541: { name = "Bc_+";latexString="Bc_{+}" ; break; }
04568 case 313: { name = "K*0";latexString="K^{*0}" ; break; }
04569 case -313: { name = "K*bar0";latexString="#bar{K}^{*0}" ; break; }
04570 case 323: { name = "K*+";latexString="#K^{*+}"; break; }
04571 case -323: { name = "K*-";latexString="#K^{*-}" ; break; }
04572 case 413: { name = "D*+";latexString= "D^{*+}"; break; }
04573 case -413: { name = "D*-";latexString= "D^{*-}" ; break; }
04574
04575 case 433: { name = "Ds*+";latexString="D_{s}^{*+}" ; break; }
04576 case -433: { name = "Ds*-";latexString="B_{S}{*-}" ; break; }
04577
04578 case 513: { name = "B*0";latexString="B^{*0}" ; break; }
04579 case -513: { name = "anti-B*0";latexString="#overline{B^{*0}}" ; break; }
04580 case 523: { name = "B*+";latexString="B^{*+}" ; break; }
04581 case -523: { name = "B*-";latexString="B^{*-}" ; break; }
04582
04583 case 533: { name = "B*_s0";latexString="B^{*}_{s0}" ; break; }
04584 case -533 : {name="anti-B_s0"; latexString= "#overline{B_{s}^{0}}";break; }
04585
04586 case 543: { name = "B*_c+";latexString= "B^{*}_{c+}"; break; }
04587 case -543: { name = "B*_c-";latexString= "B^{*}_{c-}"; break; }
04588 case 1114: { name = "Delta-";latexString="#Delta^{-}" ; break; }
04589 case -1114: { name = "Deltabar+";latexString="#bar{#Delta}^{+}" ; break; }
04590 case -2112: { name = "nbar0";latexString="{bar}n^{0}" ; break; }
04591 case 2112: { name = "n"; latexString=name ;break;}
04592 case 2114: { name = "Delta0"; latexString="#Delta^{0}" ;break; }
04593 case -2114: { name = "Deltabar0"; latexString="#bar{#Delta}^{0}" ;break; }
04594 case 3122: { name = "Lambda0";latexString= "#Lambda^{0}"; break; }
04595 case -3122: { name = "Lambdabar0";latexString="#bar{#Lambda}^{0}" ; break; }
04596 case 3112: { name = "Sigma-"; latexString="#Sigma" ;break; }
04597 case -3112: { name = "Sigmabar+"; latexString="#bar{#Sigma}^{+}" ;break; }
04598 case 3114: { name = "Sigma*-"; latexString="#Sigma^{*}" ;break; }
04599 case -3114: { name = "Sigmabar*+"; latexString="#bar{#Sigma}^{*+}" ;break; }
04600
04601
04602 case 3212: { name = "Sigma0";latexString="#Sigma^{0}" ; break; }
04603 case -3212: { name = "Sigmabar0";latexString="#bar{#Sigma}^{0}" ; break; }
04604 case 3214: { name = "Sigma*0"; latexString="#Sigma^{*0}" ;break; }
04605 case -3214: { name = "Sigma*bar0";latexString="#bar{#Sigma}^{*0}" ; break; }
04606 case 3222: { name = "Sigma+"; latexString="#Sigma^{+}" ;break; }
04607 case -3222: { name = "Sigmabar-"; latexString="#bar{#Sigma}^{-}";break; }
04608 case 3224: { name = "Sigma*+"; latexString="#Sigma^{*+}" ;break; }
04609 case -3224: { name = "Sigmabar*-"; latexString="#bar{#Sigma}^{*-}";break; }
04610
04611 case 2212: { name = "p";latexString=name ; break; }
04612 case -2212: { name = "~p";latexString="#bar{p}" ; break; }
04613 case -2214: { name = "Delta-";latexString="#Delta^{-}" ; break; }
04614 case 2214: { name = "Delta+";latexString="#Delta^{+}" ; break; }
04615 case -2224: { name = "Deltabar--"; latexString="#bar{#Delta}^{--}" ;break; }
04616 case 2224: { name = "Delta++"; latexString= "#Delta^{++}";break; }
04617
04618 case 3312: { name = "Xi-"; latexString= "#Xi^{-}";break; }
04619 case -3312: { name = "Xi+"; latexString= "#Xi^{+}";break; }
04620 case 3314: { name = "Xi*-"; latexString= "#Xi^{*-}";break; }
04621 case -3314: { name = "Xi*+"; latexString= "#Xi^{*+}";break; }
04622
04623 case 3322: { name = "Xi0"; latexString= "#Xi^{0}";break; }
04624 case -3322: { name = "anti-Xi0"; latexString= "#overline{Xi^{0}}";break; }
04625 case 3324: { name = "Xi*0"; latexString= "#Xi^{*0}";break; }
04626 case -3324: { name = "anti-Xi*0"; latexString= "#overline{Xi^{*0}}";break; }
04627
04628 case 3334: { name = "Omega-"; latexString= "#Omega^{-}";break; }
04629 case -3334: { name = "anti-Omega+"; latexString= "#Omega^{+}";break; }
04630
04631 case 4122: { name = "Lambda_c+"; latexString= "#Lambda_{c}^{+}";break; }
04632 case -4122: { name = "Lambda_c-"; latexString= "#Lambda_{c}^{-}";break; }
04633 case 4222: { name = "Sigma_c++"; latexString= "#Sigma_{c}^{++}";break; }
04634 case -4222: { name = "Sigma_c--"; latexString= "#Sigma_{c}^{--}";break; }
04635
04636
04637 case 92 : {name="String"; latexString= "String";break; }
04638
04639 case 2101 : {name="ud_0"; latexString= "ud_{0}";break; }
04640 case -2101 : {name="anti-ud_0"; latexString= "#overline{ud}_{0}";break; }
04641 case 2103 : {name="ud_1"; latexString= "ud_{1}";break; }
04642 case -2103 : {name="anti-ud_1"; latexString= "#overline{ud}_{1}";break; }
04643 case 2203 : {name="uu_1"; latexString= "uu_{1}";break; }
04644 case -2203 : {name="anti-uu_1"; latexString= "#overline{uu}_{1}";break; }
04645 case 3303 : {name="ss_1"; latexString= "#overline{ss}_{1}";break; }
04646 case 3101 : {name="sd_0"; latexString= "sd_{0}";break; }
04647 case -3101 : {name="anti-sd_0"; latexString= "#overline{sd}_{0}";break; }
04648 case 3103 : {name="sd_1"; latexString= "sd_{1}";break; }
04649 case -3103 : {name="anti-sd_1"; latexString= "#overline{sd}_{1}";break; }
04650
04651 case 20213 : {name="a_1+"; latexString= "a_{1}^{+}";break; }
04652 case -20213 : {name="a_1-"; latexString= "a_{1}^{-}";break; }
04653
04654 default:
04655 {
04656 name = "unknown";
04657 cout << "Unknown code : " << partId << endl;
04658 break;
04659 }
04660
04661
04662 }
04663 return name;
04664
04665 }
04666
04667
04668 void PFRootEventManager::mcTruthMatching( std::ostream& out,
04669 const reco::PFCandidateCollection& candidates,
04670 std::vector< std::list <simMatch> >& candSimMatchTrack,
04671 std::vector< std::list <simMatch> >& candSimMatchEcal) const
04672 {
04673
04674 if(!out) return;
04675 out << endl;
04676 out << "Running Monte Carlo Truth Matching Tool" << endl;
04677 out << endl;
04678
04679
04680 candSimMatchTrack.resize(candidates.size());
04681 candSimMatchEcal.resize(candidates.size());
04682
04683 for(unsigned i=0; i<candidates.size(); i++) {
04684 const reco::PFCandidate& pfCand = candidates[i];
04685
04686
04687 if (verbosity_ == VERBOSE ) {
04688 out <<i<<" " <<(*pfCandidates_)[i]<<endl;
04689 out << "is matching:" << endl;
04690 }
04691
04692 PFCandidate::ElementsInBlocks eleInBlocks
04693 = pfCand.elementsInBlocks();
04694
04695 for(unsigned iel=0; iel<eleInBlocks.size(); ++iel) {
04696 PFBlockRef blockRef = eleInBlocks[iel].first;
04697 unsigned indexInBlock = eleInBlocks[iel].second;
04698
04699
04700 const reco::PFBlock& blockh
04701 = *blockRef;
04702 const edm::OwnVector< reco::PFBlockElement >&
04703 elements_h = blockh.elements();
04704
04705 reco::PFBlockElement::Type type
04706 = elements_h[ indexInBlock ].type();
04707
04708
04709
04710
04711 if(type == reco::PFBlockElement::TRACK){
04712 const reco::PFRecTrackRef trackref
04713 = elements_h[ indexInBlock ].trackRefPF();
04714 assert( !trackref.isNull() );
04715 const reco::PFRecTrack& track = *trackref;
04716 const reco::TrackRef trkREF = track.trackRef();
04717 unsigned rtrkID = track.trackId();
04718
04719
04720 for ( unsigned isim=0; isim < trueParticles_.size(); isim++) {
04721 const reco::PFSimParticle& ptc = trueParticles_[isim];
04722 unsigned trackIDM = ptc.rectrackId();
04723 if(trackIDM != 99999
04724 && trackIDM == rtrkID){
04725
04726 if (verbosity_ == VERBOSE )
04727 out << "\tSimParticle " << isim
04728 << " through Track matching pTrectrack="
04729 << trkREF->pt() << " GeV" << endl;
04730
04731
04732 std::pair<double, unsigned> simtrackmatch
04733 = make_pair(trkREF->pt(),trackIDM);
04734 candSimMatchTrack[i].push_back(simtrackmatch);
04735 }
04736 }
04737
04738 }
04739
04740
04741 if(type == reco::PFBlockElement::ECAL)
04742 {
04743 const reco::PFClusterRef clusterref
04744 = elements_h[ indexInBlock ].clusterRef();
04745 assert( !clusterref.isNull() );
04746 const reco::PFCluster& cluster = *clusterref;
04747
04748 const std::vector< reco::PFRecHitFraction >&
04749 fracs = cluster.recHitFractions();
04750
04751
04752
04753 vector<unsigned> simpID;
04754 vector<double> simpEC(trueParticles_.size(),0.0);
04755 vector<unsigned> simpCN(trueParticles_.size(),0);
04756 for(unsigned int rhit = 0; rhit < fracs.size(); ++rhit){
04757
04758 const reco::PFRecHitRef& rh = fracs[rhit].recHitRef();
04759 if(rh.isNull()) continue;
04760 const reco::PFRecHit& rechit_cluster = *rh;
04761
04762
04763
04764
04765
04766
04767 for ( unsigned isim=0; isim < trueParticles_.size(); isim++) {
04768 const reco::PFSimParticle& ptc = trueParticles_[isim];
04769
04770 vector<unsigned> rechitSimIDs
04771 = ptc.recHitContrib();
04772 vector<double> rechitSimFrac
04773 = ptc.recHitContribFrac();
04774
04775 if( !rechitSimIDs.size() ) continue;
04776
04777 for ( unsigned isimrh=0; isimrh < rechitSimIDs.size(); isimrh++) {
04778 if( rechitSimIDs[isimrh] == rechit_cluster.detId() ){
04779
04780 bool takenalready = false;
04781 for(unsigned iss = 0; iss < simpID.size(); ++iss)
04782 if(simpID[iss] == isim) takenalready = true;
04783 if(!takenalready) simpID.push_back(isim);
04784
04785 simpEC[isim] +=
04786 ((rechit_cluster.energy()*rechitSimFrac[isimrh])/100.0)
04787 *fracs[rhit].fraction();
04788
04789 simpCN[isim]++;
04790
04791
04792
04793 }
04794 }
04795 }
04796
04797 }
04798
04799 for(unsigned is=0; is < simpID.size(); ++is)
04800 {
04801 double frac_of_cluster
04802 = (simpEC[simpID[is]]/cluster.energy())*100.0;
04803
04804
04805 std::pair<double, unsigned> simecalmatch
04806 = make_pair(simpEC[simpID[is]],simpID[is]);
04807 candSimMatchEcal[i].push_back(simecalmatch);
04808
04809 if (verbosity_ == VERBOSE ) {
04810 out << "\tSimParticle " << simpID[is]
04811 << " through ECAL matching Epfcluster="
04812 << cluster.energy()
04813 << " GeV with N=" << simpCN[simpID[is]]
04814 << " rechits in common "
04815 << endl;
04816 out << "\t\tsimparticle contributing to a total of "
04817 << simpEC[simpID[is]]
04818 << " GeV of this cluster ("
04819 << frac_of_cluster << "%) "
04820 << endl;
04821 }
04822 }
04823 }
04824
04825 }
04826
04827 if (verbosity_ == VERBOSE )
04828 cout << "==============================================================="
04829 << endl;
04830
04831 }
04832
04833 if (verbosity_ == VERBOSE ){
04834
04835 cout << "=================================================================="
04836 << endl;
04837 cout << "SimParticles" << endl;
04838
04839
04840 for ( unsigned i=0; i < trueParticles_.size(); i++) {
04841 cout << "==== Particle Simulated " << i << endl;
04842 const reco::PFSimParticle& ptc = trueParticles_[i];
04843 out <<i<<" "<<trueParticles_[i]<<endl;
04844
04845 if(!ptc.daughterIds().empty()){
04846 cout << "Look at the desintegration products" << endl;
04847 cout << endl;
04848 continue;
04849 }
04850
04851
04852 if(ptc.rectrackId() != 99999){
04853 cout << "matching pfCandidate (trough tracking): " << endl;
04854 for( unsigned icand=0; icand<candidates.size(); icand++ )
04855 {
04856 ITM it = candSimMatchTrack[icand].begin();
04857 ITM itend = candSimMatchTrack[icand].end();
04858 for(;it!=itend;++it)
04859 if( i == it->second ){
04860 out<<icand<<" "<<(*pfCandidates_)[icand]<<endl;
04861 cout << endl;
04862 }
04863 }
04864 }
04865
04866
04867
04868 vector<unsigned> rechitSimIDs
04869 = ptc.recHitContrib();
04870 vector<double> rechitSimFrac
04871 = ptc.recHitContribFrac();
04872
04873 if( !rechitSimIDs.size() ) continue;
04874
04875 cout << "matching pfCandidate (through ECAL): " << endl;
04876
04877
04878 double totalEcalE = 0.0;
04879 for(unsigned irh=0; irh<rechitsECAL_.size();++irh)
04880 for ( unsigned isimrh=0; isimrh < rechitSimIDs.size();
04881 isimrh++ )
04882 if(rechitSimIDs[isimrh] == rechitsECAL_[irh].detId())
04883 totalEcalE += (rechitsECAL_[irh].energy()*rechitSimFrac[isimrh]/100.0);
04884 cout << "For info, this particle deposits E=" << totalEcalE
04885 << "(GeV) in the ECAL" << endl;
04886
04887 for( unsigned icand=0; icand<candidates.size(); icand++ )
04888 {
04889 ITM it = candSimMatchEcal[icand].begin();
04890 ITM itend = candSimMatchEcal[icand].end();
04891 for(;it!=itend;++it)
04892 if( i == it->second )
04893 out<<icand<<" "<<it->first<<"GeV "<<(*pfCandidates_)[icand]<<endl;
04894 }
04895 cout << endl;
04896 }
04897 }
04898
04899 }
04900
04901
04902 edm::InputTag
04903 PFRootEventManager::stringToTag(const std::vector< std::string >& tagname) {
04904
04905 if ( tagname.size() == 1 )
04906 return edm::InputTag(tagname[0]);
04907
04908 else if ( tagname.size() == 2 )
04909 return edm::InputTag(tagname[0], tagname[1]);
04910
04911 else if ( tagname.size() == 3 )
04912 return tagname[2] == '*' ?
04913 edm::InputTag(tagname[0], tagname[1]) :
04914 edm::InputTag(tagname[0], tagname[1], tagname[2]);
04915 else {
04916 cout << "Invalid tag name with " << tagname.size() << " strings "<< endl;
04917 return edm::InputTag();
04918 }
04919
04920 }