00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "AtlfastAlgs/JetMaker.h"
00010 #include "AtlfastAlgs/ISmearer.h"
00011 #include "AtlfastAlgs/JetSmearer.h"
00012 #include "AtlfastAlgs/MissingMomentum.h"
00013 #include "AtlfastAlgs/GlobalEventData.h"
00014 #include "AtlfastAlgs/ContainerAssocsDispatcher.h"
00015
00016 #include "AtlfastEvent/Jet.h"
00017 #include "AtlfastEvent/ICell.h"
00018 #include "AtlfastEvent/CollectionDefs.h"
00019 #include "AtlfastEvent/ReconstructedParticle.h"
00020 #include "AtlfastEvent/ParticleCodes.h"
00021 #include "AtlfastEvent/MsgStreamDefs.h"
00022 #include "AtlfastEvent/ICluster.h"
00023 #include "AtlfastEvent/MCparticleCollection.h"
00024 #include "AtlfastEvent/SimpleKinematic.h"
00025 #include "AtlfastEvent/Phi.h"
00026
00027 #include "AtlfastUtils/TesIO.h"
00028 #include "AtlfastUtils/HeaderPrinter.h"
00029 #include "AtlfastUtils/FunctionObjects.h"
00030 #include "AtlfastUtils/IsAssociated.h"
00031
00032 #include <cmath>
00033 #include <algorithm>
00034 #include <numeric>
00035 #include <assert.h>
00036 #include "GaudiKernel/DataSvc.h"
00037 #include "GaudiKernel/ISvcLocator.h"
00038 #include "GaudiKernel/MsgStream.h"
00039
00040
00041
00042
00043 #include "GeneratorObjects/McEventCollection.h"
00044 #include "HepMC/GenEvent.h"
00045 #include "HepMC/GenVertex.h"
00046
00047 #include "CLHEP/Units/SystemOfUnits.h"
00048
00049 namespace Atlfast{
00050
00051
00052 class SmearCell{
00053 public:
00054 SmearCell(ISmearer* is, double *sumET):
00055 m_smearer(is), m_doSmear((is== 0)? false:true),m_sumET(sumET){}
00056 HepLorentzVector operator()(const HepLorentzVector& sumSoFar,
00057 const ICell* c){
00058
00059 HepLorentzVector sum(0., 0., 0., 0.);
00060 HepLorentzVector smeared;
00061 if(m_doSmear){
00062 smeared = m_smearer->smear( c->momentum() );
00063 sum = sumSoFar+smeared;
00064 (*m_sumET) += smeared.perp();
00065 }else{
00066 smeared = c->momentum();
00067 sum = sumSoFar+smeared;
00068 (*m_sumET) += smeared.perp();
00069 }
00070
00071 return sum;
00072 }
00073 private:
00074 ISmearer* m_smearer;
00075 bool m_doSmear;
00076 double *m_sumET;
00077 };
00078
00079
00080
00081
00082
00083
00084 using std::abs;
00085 using std::sort;
00086 using std::partition;
00087
00088 JetMaker::JetMaker
00089 ( const std::string& name, ISvcLocator* pSvcLocator )
00090 : Algorithm( name, pSvcLocator ),
00091 m_bSelector(0),
00092 m_cSelector(0),
00093 m_tauSelector(0),
00094 m_smearer(0),
00095 m_cellSmearer(0),
00096 m_tesIO(0)
00097 {
00098
00099
00100 m_minPT = 10*GeV;
00101 m_maxEta = 5.0;
00102 m_doSmearing = true;
00103 m_rconeb = 0.400;
00104 m_rconef = 0.400;
00105
00106 m_bPtMin = 5.0*GeV;
00107 m_bMaxDeltaR = 0.3;
00108
00109 m_cPtMin = 5.0*GeV;
00110 m_cMaxDeltaR = 0.3;
00111
00112 m_tauPtMin = 10.0*GeV;
00113 m_tauMaxDeltaR = 0.3;
00114
00115 m_etaTagMax = 2.5;
00116
00117 m_tauJetPtRatio = 0;
00118
00119 m_adjustMissETForIsolation = true;
00120
00121
00122 m_inputLocation = "/Event/AtlfastClusters";
00123 m_outputLocation = "/Event/AtlfastJets";
00124 m_muonLocation = "/Event/AtlfastNonIsolatedMuons";
00125 m_unusedCellLocation = "/Event/AtlfastUnusedCells";
00126 m_missingMomentumLocation = "/Event/AtlfastMissingMomentum";
00127 m_isolatedElectronLocation = "/Event/AtlfastIsolatedElectrons";
00128 m_isolatedPhotonLocation = "/Event/AtlfastIsolatedPhotons";
00129
00130
00131
00132 declareProperty( "MinimumPT", m_minPT ) ;
00133 declareProperty( "MaximumEta", m_maxEta ) ;
00134 declareProperty( "DoSmearing", m_doSmearing );
00135 declareProperty( "RconeB", m_rconeb );
00136 declareProperty( "RconeF", m_rconef );
00137 declareProperty( "bPtMin", m_bPtMin );
00138 declareProperty( "bMaxDeltaR", m_bMaxDeltaR );
00139 declareProperty( "cPtMin", m_cPtMin );
00140 declareProperty( "cMaxDeltaR", m_cMaxDeltaR );
00141 declareProperty( "tauPtMin", m_tauPtMin );
00142 declareProperty( "tauMaxDeltaR", m_tauMaxDeltaR );
00143 declareProperty( "etaTagMax", m_etaTagMax );
00144 declareProperty( "tauJetPtRatio", m_tauJetPtRatio);
00145 declareProperty( "adjustMissETForIsolation", m_adjustMissETForIsolation);
00146
00147 declareProperty( "InputLocation", m_inputLocation ) ;
00148 declareProperty( "OutputLocation", m_outputLocation ) ;
00149 declareProperty( "UnusedCellLocation", m_unusedCellLocation ) ;
00150 declareProperty( "MuonLocation", m_muonLocation );
00151 declareProperty( "MissingMomentumLocation", m_missingMomentumLocation );
00152 declareProperty( "IsolatedElectronLocation", m_isolatedElectronLocation );
00153 declareProperty( "IsolatedPhotonLocation", m_isolatedPhotonLocation );
00154
00155 }
00156
00157 JetMaker::~JetMaker() {
00158
00159 MsgStream log( messageService(), name() ) ;
00160 log << MSG::INFO << "Destructor Called" << endreq;
00161
00162 if (m_smearer) {
00163 log << MSG::INFO << "Deleting jet Smearer" << endreq;
00164 delete m_smearer;
00165 }
00166 if (m_cellSmearer) {
00167 log << MSG::INFO << "Deleting Cell Smearer" << endreq;
00168 delete m_cellSmearer;
00169 }
00170 if (m_tesIO) {
00171 delete m_tesIO;
00172 }
00173 }
00174
00175
00176
00177
00178
00179 StatusCode JetMaker::initialize(){
00180 MsgStream log( messageService(), name() ) ;
00181
00182 log << MSG::DEBUG << "instantiating a JetSmearer" << endreq;
00183
00184
00185
00186 GlobalEventData* ged = GlobalEventData::Instance();
00187 int lumi = ged->lumi();
00188 int randSeed = ged->randSeed() ;
00189 m_barrelForwardEta = ged->barrelForwardEta();
00190 m_mcLocation = ged->mcLocation();
00191
00192
00193 ged->set_adjustMissEtForIsolation(m_adjustMissETForIsolation);
00194
00195
00196 m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00197
00198 if(m_doSmearing){
00199 m_smearer = new JetSmearer(randSeed,
00200 lumi,
00201 m_rconeb,
00202 m_rconef,
00203 m_barrelForwardEta);
00204 m_cellSmearer = new JetSmearer(randSeed,
00205 lumi,
00206 0.,
00207 0.,
00208 m_barrelForwardEta);
00209 } else {
00210 m_smearer = NULL;
00211 m_cellSmearer = NULL;
00212 }
00213
00214 const int BQUARK(ParticleCodes::BQUARK);
00215 const int CQUARK(ParticleCodes::CQUARK);
00216
00217
00218
00219
00220 HepMC_helper::IMCselector* selector;
00221
00222 std::vector<HepMC_helper::IMCselector*> bSelectors;
00223 selector = new HepMC_helper::IsFromHardScatter();
00224 bSelectors.push_back( selector );
00225 selector = new HepMC_helper::SelectJetTag(BQUARK, m_bPtMin, m_etaTagMax);
00226 bSelectors.push_back( selector );
00227 m_bSelector = new HepMC_helper::NCutter(bSelectors);
00228
00229 std::vector<HepMC_helper::IMCselector*> cSelectors;
00230 selector = new HepMC_helper::IsFromHardScatter();
00231 cSelectors.push_back( selector );
00232 selector = new HepMC_helper::SelectJetTag(CQUARK, m_cPtMin, m_etaTagMax);
00233 cSelectors.push_back( selector );
00234 m_cSelector = new HepMC_helper::NCutter(cSelectors);
00235
00236 std::vector<HepMC_helper::IMCselector*> tauSelectors;
00237 selector = new HepMC_helper::IsFromHardScatter();
00238 tauSelectors.push_back( selector );
00239 selector = new HepMC_helper::SelectTauTag(m_tauPtMin, m_etaTagMax);
00240 tauSelectors.push_back( selector );
00241 m_tauSelector = new HepMC_helper::NCutter(tauSelectors);
00242
00243
00244
00245 std::vector<HepMC_helper::IMCselector*>::iterator iter;
00246 for(iter=bSelectors.begin(); iter!=bSelectors.end(); delete *iter, ++iter);
00247 for(iter=cSelectors.begin(); iter!=cSelectors.end(); delete *iter, ++iter);
00248 for(iter=tauSelectors.begin(); iter!=tauSelectors.end(); delete *iter, ++iter);
00249
00250
00251
00252 HeaderPrinter hp("Atlfast JetMaker:", log);
00253
00254 hp.add("TES Locations: ");
00255 hp.add(" Muons from ", m_muonLocation);
00256 hp.add(" Clusters from ", m_inputLocation);
00257 hp.add(" MC Input Location ", m_mcLocation);
00258 hp.add(" Jets to ", m_outputLocation);
00259 hp.add(" unused cell,cluster sum to ", m_missingMomentumLocation);
00260 hp.add("Smearing on ", m_doSmearing);
00261 hp.add("Cluster min Pt ", m_minPT);
00262 hp.add("Cluster max Eta ", m_maxEta);
00263 hp.add("Luminosity ", lumi);
00264 hp.add("Initial random seed ", randSeed);
00265 hp.add("End cap Cone size ", m_rconef);
00266 hp.add("Barrel Cone size ", m_rconeb);
00267 hp.add("Eta of start of end cap ", m_barrelForwardEta);
00268 hp.add("Parameters for labels ", " ");
00269 hp.add(" Max eta ", m_etaTagMax);
00270 hp.add(" b-quark min pt ", m_bPtMin);
00271 hp.add(" b-quark max DeltaR ", m_bMaxDeltaR);
00272 hp.add(" c-quark min pt ", m_cPtMin);
00273 hp.add(" c-quark max DeltaR ", m_cMaxDeltaR);
00274 hp.add(" tau lep min pt ", m_tauPtMin);
00275 hp.add(" tau lep max DeltaR ", m_tauMaxDeltaR);
00276 hp.add(" tau/Jet Pt Ratio ", m_tauJetPtRatio);
00277 hp.print();
00278
00279
00280
00281 return StatusCode::SUCCESS ;
00282 }
00283
00284
00285
00286
00287
00288 StatusCode JetMaker::finalize(){
00289
00290 MsgStream log( messageService(), name() ) ;
00291 log << MSG::INFO << "finalizing" << endreq;
00292
00293 if (m_bSelector) delete m_bSelector;
00294 if (m_cSelector) delete m_cSelector;
00295 if (m_tauSelector) delete m_tauSelector;
00296
00297 return StatusCode::SUCCESS ;
00298 }
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 StatusCode JetMaker::execute( ){
00318
00319 MsgStream log( messageService(), name() ) ;
00320
00321 std::string mess;
00322
00323
00324
00325
00326
00327
00328
00329 localClusterCollection my_Clusters ;
00330 MuonCollection my_Muons ;
00331
00332
00333
00334 if( ! m_tesIO->copy<IClusterCollection> ( my_Clusters, m_inputLocation ) ) {
00335 log << MSG::INFO << "No Clusters in TES " << endreq;
00336 } else {
00337 log << MSG::DEBUG << my_Clusters.size()<<" Clusters from TES " << endreq;
00338 }
00339
00340
00341 if( ! m_tesIO->copy<ReconstructedParticleCollection>
00342 ( my_Muons, m_muonLocation ) ) {
00343 log << MSG::DEBUG << "No muons in TES " << endreq;
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353 JetCollection* myJets = new JetCollection ;
00354
00355
00356
00357
00358
00359 Jet* candidate ;
00360 localClusterIterator src ;
00361 m_sumET = 0.;
00362 HepLorentzVector missingMomentum(0.,0.,0.,0.);
00363
00364 MCparticleCollection mcParticles_b ;
00365 MCparticleCollection mcParticles_c ;
00366 MCparticleCollection mcParticles_tau ;
00367
00368
00369
00370
00371 TesIoStat stat = m_tesIO->getMC( mcParticles_b, m_bSelector ) ;
00372 if(!stat){
00373 log << MSG::ERROR <<"Problem getting b-quarks" << endreq;
00374 return stat;
00375 }
00376 stat = m_tesIO->getMC( mcParticles_c, m_cSelector ) ;
00377 if(!stat){
00378 log << MSG::ERROR <<"Problem getting c-quarks" << endreq;
00379 return stat;
00380 }
00381 stat = m_tesIO->getMC( mcParticles_tau, m_tauSelector ) ;
00382 if(!stat){
00383 log << MSG::ERROR <<"Problem getting taus" << endreq;
00384 return stat;
00385 }
00386
00387 for( src = my_Clusters.begin() ; src != my_Clusters.end() ; ++src ) {
00388
00389
00390
00391
00392
00393
00394 if ( !IsAssociated<ReconstructedParticle>( *src ) ){
00395
00396 candidate = this->create( *src );
00397
00398
00399
00400 HepLorentzVector temp4Vec = candidate->momentum();
00401
00402
00403 this->addMuons(candidate, my_Muons);
00404
00405
00406
00407
00408 if( this->isAcceptable( candidate ) ) {
00409
00410
00411 this->label(candidate,mcParticles_b,mcParticles_c,mcParticles_tau);
00412
00413 log << MSG::DEBUG << "Pushing back a Jet" << endreq;
00414 myJets->push_back( candidate ) ;
00415 log<<MSG::DEBUG<<"jet "<<*candidate<<endreq;
00416 }else {
00417 log << MSG::DEBUG << "Jet fails cuts" << endreq;
00418
00419 missingMomentum += temp4Vec;
00420 m_sumET += temp4Vec.perp();
00421 delete candidate;
00422 }
00423 }else{
00424 log << MSG::DEBUG << "Cluster is associated, so ignored" << endreq;
00425 }
00426 }
00427
00428 log<<MSG::DEBUG<<"Missing momentum: clusters "<<missingMomentum<<endreq;
00429 missingMomentum += addCells(log);
00430 log << MSG::DEBUG << "sumET after adding cells: " << m_sumET << endreq;
00431 log<<MSG::DEBUG<<"Missing momentum: cells+clstrs "
00432 <<missingMomentum<<endreq;
00433
00434
00435
00436
00437
00438 log<<MSG::DEBUG<<"Storing "<< myJets->size() <<" Jets"<<endreq;
00439 stat = m_tesIO->store( myJets, m_outputLocation, true) ;
00440 if(!stat){
00441 log<<MSG::ERROR<<"Could not store jets"<<endreq;
00442 return stat;
00443 }
00444
00445
00446 MissingMomentum* mm = new MissingMomentum(missingMomentum,m_sumET);
00447 stat = m_tesIO->store(mm,m_missingMomentumLocation ) ;
00448 std::string message = stat? "Stored missing mom":"Failed to store missing mom";
00449 log<<MSG::DEBUG<<message<<endreq;
00450
00451
00452 return StatusCode::SUCCESS;
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 Jet* JetMaker::create ( ICluster* src )
00469 {
00470 Jet* jet;
00471 MsgStream log( messageService(), name() ) ;
00472 HepLorentzVector vec = src->momentum();
00473
00474 if (m_doSmearing)
00475 {
00476
00477 vec = m_smearer->smear(vec);
00478 }
00479
00480 jet = new Jet(vec, *src);
00481 log << MSG::DEBUG << "Unsmeared Cluster: " << *src << endreq;
00482 log << MSG::DEBUG << "Smeared Jet : " << jet << endreq ;
00483
00484
00485
00486
00487 return jet;
00488
00489
00490 }
00491
00492
00493
00494
00495
00496
00497 void JetMaker::addMuons(Jet* jet, MuonCollection& muons )
00498 {
00499
00500 MsgStream log( messageService(), name() ) ;
00501
00502 if (muons.size() == 0) return;
00503
00504 MuonIterator first = muons.begin() ;
00505 MuonIterator last = muons.end() ;
00506
00507
00508 MuonIterator partitionLast =
00509 partition(first,last,PartitionCondition::BelowThresholdDeltaR(jet,m_rconeb,m_rconef,m_barrelForwardEta));
00510
00511 if (partitionLast == first){
00512 log << MSG::DEBUG << "No muons in R cone" << endreq;
00513 return;
00514 }
00515
00516 log << MSG::DEBUG << "Adding " << partitionLast-first << " muons to Jet" << endreq;
00517
00518
00519 for (MuonIterator muItr = first; muItr != partitionLast;++muItr) jet->addMuon(*muItr);
00520
00521
00522 muons.erase(first,partitionLast);
00523
00524 }
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534 bool JetMaker::isAcceptable ( Jet* candidate)
00535 {
00536
00537 MsgStream log( messageService(), name() ) ;
00538
00539
00540
00541 if( candidate->pT() < m_minPT ) {
00542 log << MSG::DEBUG << "Candidate failed pt cut: pt " << candidate->pT()
00543 << " min was " << m_minPT << endreq;
00544 return false ;
00545 }
00546
00547 if( abs(candidate->eta()) > m_maxEta ) {
00548 log << MSG::DEBUG << "Candidate failed max eta cut: eta "
00549 << candidate->eta()
00550 << " max was " << m_maxEta << endreq;
00551 return false ;
00552 }
00553
00554 return true ;
00555 }
00556
00557
00558
00559
00560
00561
00562 void JetMaker::label(Jet* jet,
00563 MCparticleCollection& mcParticles_b,
00564 MCparticleCollection& mcParticles_c,
00565 MCparticleCollection& mcParticles_tau)const {
00566
00567 MsgStream log( messageService(), name() ) ;
00568
00569 double dR = 0.;
00570
00571
00572
00573
00574
00575 int bLabel = getJetLabel(mcParticles_b, jet, m_bMaxDeltaR, dR);
00576 jet->setdRbquark(dR);
00577 int cLabel = getJetLabel(mcParticles_c, jet, m_cMaxDeltaR, dR);
00578 jet->setdRcquark(dR);
00579 int tauLabel = getTauLabel( mcParticles_tau, jet, m_tauMaxDeltaR, dR);
00580 jet->setdRhadtau(dR);
00581
00582
00583 if(bLabel){
00584 jet->setPdg_id(bLabel);
00585 return;
00586 }
00587 if(cLabel){
00588 jet->setPdg_id(cLabel);
00589 return;
00590 }
00591 if(tauLabel){
00592 jet->setPdg_id(tauLabel);
00593 return;
00594 }
00595
00596 jet->setPdg_id(0);
00597 return;
00598
00599 }
00600
00601
00602
00603 int JetMaker::getJetLabel(MCparticleCollection& mcParticles,
00604 Jet* jet,
00605 double maxDeltaR,
00606 double &deltaR) const {
00607
00608 MsgStream log( messageService(), name() ) ;
00609
00610 int pdgId = 0;
00611 double drMin = 999.;
00612
00613
00614 PartitionCondition::BelowThresholdDeltaR labelSelector(jet, maxDeltaR);
00615 MCparticleCollectionCIter src ;
00616 for( src = mcParticles.begin(); src != mcParticles.end(); ++src ){
00617 SimpleKinematic sk(*src);
00618 if(labelSelector(sk)){
00619 pdgId = (*src)->pdg_id();
00620 }
00621 Phi dPhi( sk.phi() - jet->phi() );
00622 double dR = sqrt((dPhi*dPhi) +
00623 (sk.eta()-jet->eta())*(sk.eta()-jet->eta()));
00624 if (dR < drMin) drMin = dR;
00625 }
00626 deltaR = drMin;
00627 return pdgId;
00628 }
00629
00630
00631
00632 int JetMaker::getTauLabel(MCparticleCollection& mcParticles,
00633 Jet* jet,
00634 double maxDeltaR,
00635 double &deltaR) const {
00636
00637 MsgStream log( messageService(), name() ) ;
00638
00639 int pdgId = 0;
00640 double drMin = 999.;
00641
00642
00643 PartitionCondition::BelowThresholdDeltaR labelSelector(jet, maxDeltaR);
00644 MCparticleCollectionCIter src ;
00645 for( src = mcParticles.begin() ; src != mcParticles.end() ; ++src )
00646 {
00647 HepLorentzVector tauHlv = (*src)->momentum();
00648 HepLorentzVector neuHlv;
00649
00650
00651 HepMC::GenVertex* endVertex = (*src)->end_vertex();
00652 if(!endVertex) continue;
00653
00654 HepMC::GenVertex::particle_iterator firstChild =
00655 endVertex->particles_begin(HepMC::children);
00656
00657 HepMC::GenVertex::particle_iterator endChild =
00658 endVertex->particles_end(HepMC::children);
00659
00660 HepMC::GenVertex::particle_iterator thisChild = firstChild;
00661
00662
00663 for(; thisChild!=endChild; ++thisChild){
00664 if( abs((*thisChild)->pdg_id()) == 16){
00665 neuHlv = (*thisChild)->momentum();
00666 }
00667 }
00668 double sigma;
00669 double sqrtene = sqrt(jet->momentum().e()/GeV);
00670 if ( fabs(jet->eta()) < m_barrelForwardEta )
00671 sigma = 0.5/sqrtene;
00672 else
00673 sigma = 1.0/sqrtene;
00674
00675 double cutQuantity = (m_tauJetPtRatio) ? m_tauJetPtRatio : 1.0 - 2*sigma;
00676
00677 log << MSG::DEBUG << "m_tauJetPtRatio = " << m_tauJetPtRatio
00678 << ", cutQuantity = " << cutQuantity << endreq;
00679
00680 HepMC::GenParticle trueHadSystem;
00681 trueHadSystem.set_momentum(tauHlv-neuHlv);
00682 SimpleKinematic sk(trueHadSystem);
00683 if (labelSelector(sk) &&
00684 (tauHlv-neuHlv).perp()/jet->pT() >= cutQuantity){
00685 Phi dPhi( sk.phi() - jet->phi() );
00686 deltaR = sqrt((dPhi*dPhi) +
00687 (sk.eta()-jet->eta())*(sk.eta()-jet->eta()));
00688 pdgId = (*src)->pdg_id();
00689 }
00690 Phi dPhi( sk.phi() - jet->phi() );
00691 double dR = sqrt((dPhi*dPhi) +
00692 (sk.eta()-jet->eta())*(sk.eta()-jet->eta()));
00693 if (dR < drMin) drMin = dR;
00694 }
00695
00696 deltaR = drMin;
00697 return pdgId;
00698 }
00699
00700 HepLorentzVector JetMaker::addCells(MsgStream& log){
00701
00702 std::vector<const ITwoCptCell*> cellsToSmear(0);
00703 std::vector<const ITwoCptCell*> newCellsVector(0);
00704
00705 getUnusedCells(cellsToSmear,log);
00706
00707 if (m_adjustMissETForIsolation){
00708 getIsolationCorrectionCells(cellsToSmear,newCellsVector,m_isolatedElectronLocation,log);
00709 getIsolationCorrectionCells(cellsToSmear,newCellsVector,m_isolatedPhotonLocation,log);
00710 }
00711
00712 log << MSG::DEBUG << "Smearing a total of " << cellsToSmear.size() << " cells" << endreq;
00713 log << MSG::DEBUG << "sumET before adding cells: " << m_sumET << endreq;
00714
00715
00716
00717 HepLorentzVector temp(0., 0., 0., 0.);
00718 HepLorentzVector sum = std::accumulate(cellsToSmear.begin(),
00719 cellsToSmear.end(),
00720 temp,
00721 SmearCell(m_cellSmearer,&m_sumET));
00722
00723
00724 std::vector<const ITwoCptCell*>::iterator itccItr = newCellsVector.begin();
00725 std::vector<const ITwoCptCell*>::iterator itccItrE = newCellsVector.end();
00726
00727 for (;itccItr!=itccItrE;++itccItr) delete *itccItr;
00728 newCellsVector.clear();
00729
00730 return sum;
00731 }
00732
00733 void JetMaker::getUnusedCells(std::vector<const ITwoCptCell*> &cellsToSmear, MsgStream& log){
00734
00735 std::vector<const TwoCptCell*> unusedCells(0);
00736 if( !m_tesIO->copy<std::vector<const TwoCptCell*> >(unusedCells,
00737 m_unusedCellLocation)){
00738 log << MSG::INFO << "No unused cells in TES " << endreq;
00739 return;
00740 }
00741
00742 log << MSG::DEBUG << unusedCells.size() << " unused cells in TES" << endreq;
00743
00744 std::copy(unusedCells.begin(),unusedCells.end(),std::back_inserter(cellsToSmear));
00745
00746 log << MSG::DEBUG << "Added " << unusedCells.size() << " unused cells to cellToSmear" << endreq;
00747
00748 return;
00749
00750 }
00751
00752 void JetMaker::getIsolationCorrectionCells(std::vector<const ITwoCptCell*> &cellsToSmear,
00753 std::vector<const ITwoCptCell*> &newcellsVector,
00754 std::string tesAddress,
00755 MsgStream& log){
00756
00757
00758 std::vector<const ITwoCptCell*> isolationCorrectionCells(0);
00759
00760 const ReconstructedParticleCollection* dh(0);
00761 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00762
00763 ReconstructedParticleCollection::const_iterator iter = dh->begin();
00764
00765 for (; iter != dh->end(); ++iter){
00766
00767 const HepMC::GenParticle* gp = (*iter)->truth();
00768
00769
00770 const IAOO* iaooRP = (*iter);
00771 TypeVisitor tv =
00772 ContainerAssocsDispatcher( iaooRP->begin(), iaooRP->end(), TypeVisitor() );
00773
00774
00775 std::vector<const TwoCptCell*> tccv = tv.typeVector(TwoCptCell());
00776 log << MSG::DEBUG << "TypeVisitor found " << tccv.size()
00777 << " TwoCptCells in this cluster" << endreq;
00778
00779 std::vector<const TwoCptCell*>::iterator tccvi;
00780
00781 for ( tccvi = tccv.begin(); tccvi != tccv.end();){
00782 const ICell* ic = (*tccvi);
00783
00784
00785
00786 std::vector<const GenParticle*> gpv = ic->particles();
00787 std::vector<const GenParticle*>::iterator gpi;
00788 gpi = std::find(gpv.begin(),gpv.end(),gp);
00789
00790 if ( gpi == gpv.end() ) ++tccvi;
00791 else{
00792 log << MSG::DEBUG << "GenParticle found in this cell, one of "
00793 << gpv.size() << " GenParticles" << endreq;
00794 log << MSG::DEBUG << "GenParticle momentum = " << (*gpi)->momentum() << endreq;
00795 log << MSG::DEBUG << "Cell momentum = " << ic->momentum() << endreq;
00796
00797 if ( gpv.size() > 1){
00798
00799 ITwoCptCell* newcell_itcc = (*tccvi)->cloneITCC();
00800 newcell_itcc->resetCell();
00801 ICell* newcell = newcell_itcc;
00802 double newpT = ic->momentum().perp() - (*gpi)->momentum().perp();
00803 newpT = ( fabs(newpT) < 1e-10 ) ? 0 : newpT;
00804 newcell->newHit( newpT );
00805
00806
00807 isolationCorrectionCells.push_back(newcell_itcc);
00808 newcellsVector.push_back(newcell_itcc);
00809 }
00810
00811
00812 tccvi = tccv.erase(tccvi);
00813
00814 }
00815 }
00816
00817 std::copy(tccv.begin(),tccv.end(),std::back_inserter(isolationCorrectionCells));
00818 }
00819
00820 log << MSG::DEBUG << "Added " << isolationCorrectionCells.size()
00821 << " isolation correction cells to cellsToSmear" << endreq;
00822
00823
00824 std::copy(isolationCorrectionCells.begin(),
00825 isolationCorrectionCells.end(),
00826 std::back_inserter(cellsToSmear));
00827
00828 return;
00829
00830 }
00831
00832 }