CMS 3D CMS Logo

Public Member Functions | Private Attributes

EcalRecHitsMerger Class Reference

#include <EcalRecHitsMerger.h>

Inheritance diagram for EcalRecHitsMerger:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

void beginJob (void)
 EcalRecHitsMerger (const edm::ParameterSet &pset)
void endJob (void)
void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~EcalRecHitsMerger ()

Private Attributes

bool debug_
edm::InputTag EgammaSourceEB_
edm::InputTag EgammaSourceEE_
std::string InputRecHitEB_
std::string InputRecHitEE_
edm::InputTag JetsSourceEB_
edm::InputTag JetsSourceEE_
edm::InputTag MuonsSourceEB_
edm::InputTag MuonsSourceEE_
std::string OutputLabelEB_
std::string OutputLabelEE_
edm::InputTag Pi0SourceEB_
edm::InputTag Pi0SourceEE_
edm::InputTag RestSourceEB_
edm::InputTag RestSourceEE_
edm::InputTag TausSourceEB_
edm::InputTag TausSourceEE_

Detailed Description

Definition at line 17 of file EcalRecHitsMerger.h.


Constructor & Destructor Documentation

EcalRecHitsMerger::EcalRecHitsMerger ( const edm::ParameterSet pset)

Definition at line 17 of file EcalRecHitsMerger.cc.

References edm::ParameterSet::getUntrackedParameter().

                                                                {

 debug_ = pset.getUntrackedParameter<bool>("debug");

 EgammaSourceEB_ = pset.getUntrackedParameter<edm::InputTag>("EgammaSource_EB");
 MuonsSourceEB_  = pset.getUntrackedParameter<edm::InputTag>("MuonsSource_EB");
 TausSourceEB_  = pset.getUntrackedParameter<edm::InputTag>("TausSource_EB");
 JetsSourceEB_   = pset.getUntrackedParameter<edm::InputTag>("JetsSource_EB");
 RestSourceEB_   = pset.getUntrackedParameter<edm::InputTag>("RestSource_EB");
 Pi0SourceEB_   = pset.getUntrackedParameter<edm::InputTag>("Pi0Source_EB",edm::InputTag("dummyPi0"));

 EgammaSourceEE_ = pset.getUntrackedParameter<edm::InputTag>("EgammaSource_EE");
 MuonsSourceEE_  = pset.getUntrackedParameter<edm::InputTag>("MuonsSource_EE");
 TausSourceEE_  = pset.getUntrackedParameter<edm::InputTag>("TausSource_EE");
 JetsSourceEE_   = pset.getUntrackedParameter<edm::InputTag>("JetsSource_EE");
 RestSourceEE_   = pset.getUntrackedParameter<edm::InputTag>("RestSource_EE");
 Pi0SourceEE_   = pset.getUntrackedParameter<edm::InputTag>("Pi0Source_EE",edm::InputTag("dummyPi0"));

 OutputLabelEB_ = pset.getUntrackedParameter<std::string>("OutputLabel_EB");
 OutputLabelEE_ = pset.getUntrackedParameter<std::string>("OutputLabel_EE");

 InputRecHitEB_ = pset.getUntrackedParameter<std::string>("EcalRecHitCollectionEB");
 InputRecHitEE_ = pset.getUntrackedParameter<std::string>("EcalRecHitCollectionEE");

 produces<EcalRecHitCollection>(OutputLabelEB_);
 produces<EcalRecHitCollection>(OutputLabelEE_);

}
EcalRecHitsMerger::~EcalRecHitsMerger ( ) [virtual]

Definition at line 48 of file EcalRecHitsMerger.cc.

                                      {
}

Member Function Documentation

void EcalRecHitsMerger::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 52 of file EcalRecHitsMerger.cc.

                                {
}
void EcalRecHitsMerger::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 55 of file EcalRecHitsMerger.cc.

                              {
}
void EcalRecHitsMerger::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 58 of file EcalRecHitsMerger.cc.

References begin, gather_cfg::cout, edm::EventID::event(), edm::Event::getManyByType(), i, edm::EventBase::id(), instance, edm::Event::put(), edm::EventID::run(), and findQualityFiles::size.

                                                                        {

 if (debug_) std::cout << " EcalRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl;

 std::vector< edm::Handle<EcalRecHitCollection> > EcalRecHits_done;
 e.getManyByType(EcalRecHits_done);

 std::auto_ptr<EcalRecHitCollection> EBMergedRecHits(new EcalRecHitCollection);
 std::auto_ptr<EcalRecHitCollection> EEMergedRecHits(new EcalRecHitCollection);

 unsigned int nColl = EcalRecHits_done.size();

 int nEB = 0;
 int nEE = 0;


 for (unsigned int i=0; i < nColl; i++) {

   std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
   std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();

   if ( module_label != EgammaSourceEB_.label() && 
        module_label != MuonsSourceEB_.label() &&
        module_label != JetsSourceEB_.label() &&
        module_label != TausSourceEB_.label() &&
        module_label != RestSourceEB_.label() &&
        module_label != Pi0SourceEB_.label() ) continue;

   if (instance == InputRecHitEB_)  {
        nEB += EcalRecHits_done[i] -> size();
   }
   else if (instance == InputRecHitEE_) {
        nEE += EcalRecHits_done[i] -> size();
   }

 }

 EBMergedRecHits -> reserve(nEB);
 EEMergedRecHits -> reserve(nEE);
 if (debug_) std::cout << " Number of EB Rechits to merge  = " << nEB << std::endl;
 if (debug_) std::cout << " Number of EE Rechits to merge  = " << nEE << std::endl;

 for (unsigned int i=0; i < nColl; i++) {
   std::string instance = EcalRecHits_done[i].provenance()->productInstanceName(); 

   std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
   if ( module_label != EgammaSourceEB_.label() && 
        module_label != MuonsSourceEB_.label() &&
        module_label != JetsSourceEB_.label() &&
        module_label != TausSourceEB_.label() &&
        module_label != RestSourceEB_.label() &&
        module_label != Pi0SourceEB_.label() ) continue;

    if (instance == InputRecHitEB_) {
        for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) {
                EBMergedRecHits -> push_back(*it);
        }
   }
   else if (instance == InputRecHitEE_) {
        for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) {
                EEMergedRecHits -> push_back(*it);
        }
   }

 }


 // std::cout << " avant le put " << std::endl;
 e.put(EBMergedRecHits,OutputLabelEB_);
 e.put(EEMergedRecHits,OutputLabelEE_);
 // std::cout << " apres le put " << std::endl;

}

Member Data Documentation

bool EcalRecHitsMerger::debug_ [private]

Definition at line 47 of file EcalRecHitsMerger.h.

Definition at line 27 of file EcalRecHitsMerger.h.

Definition at line 35 of file EcalRecHitsMerger.h.

std::string EcalRecHitsMerger::InputRecHitEB_ [private]

Definition at line 43 of file EcalRecHitsMerger.h.

std::string EcalRecHitsMerger::InputRecHitEE_ [private]

Definition at line 44 of file EcalRecHitsMerger.h.

Definition at line 30 of file EcalRecHitsMerger.h.

Definition at line 38 of file EcalRecHitsMerger.h.

Definition at line 28 of file EcalRecHitsMerger.h.

Definition at line 36 of file EcalRecHitsMerger.h.

std::string EcalRecHitsMerger::OutputLabelEB_ [private]

Definition at line 33 of file EcalRecHitsMerger.h.

std::string EcalRecHitsMerger::OutputLabelEE_ [private]

Definition at line 41 of file EcalRecHitsMerger.h.

Definition at line 32 of file EcalRecHitsMerger.h.

Definition at line 40 of file EcalRecHitsMerger.h.

Definition at line 31 of file EcalRecHitsMerger.h.

Definition at line 39 of file EcalRecHitsMerger.h.

Definition at line 29 of file EcalRecHitsMerger.h.

Definition at line 37 of file EcalRecHitsMerger.h.