CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

edm::HiMixingModule Class Reference

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

List of all members.

Public Member Functions

 HiMixingModule (const edm::ParameterSet &)
 ~HiMixingModule ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)
bool verifyRegistry (std::string object, std::string subdet, InputTag &tag, std::string &label)

Private Attributes

std::vector< HiMixingWorkerBase * > workers_

Detailed Description

Definition at line 148 of file HiMixingModule.cc.


Constructor & Destructor Documentation

HiMixingModule::HiMixingModule ( const edm::ParameterSet pset) [explicit]

Definition at line 176 of file HiMixingModule.cc.

References gather_cfg::cout, edm::InputTag::encode(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), collect_tpl::input, edm::InputTag::instance(), label, edm::InputTag::label(), h::names, GlobalPosition_Frontier_DevDB_cff::tag, and o2o::tags.

{

   ParameterSet ps=pset.getParameter<ParameterSet>("mixObjects");
   std::vector<std::string> names = ps.getParameterNames();
   std::vector<std::string> simtags = pset.getParameter<std::vector<std::string> >("srcSIM");
   std::vector<std::string> gentags = pset.getParameter<std::vector<std::string> >("srcGEN");

   if(simtags.size() != gentags.size()) LogError("MixingInput")<<"Generator and Simulation input lists are not matching each other"<<endl;
   
   for (std::vector<string>::iterator it=names.begin();it!= names.end();++it){
      
      ParameterSet pstag=ps.getParameter<ParameterSet>((*it));
      if (!pstag.exists("type"))  continue; //to allow replacement by empty pset
      std::string object = pstag.getParameter<std::string>("type");
      std::vector<InputTag>  tags=pstag.getParameter<std::vector<InputTag> >("input");

      std::string signal;
      for(size_t itag = 0; itag < tags.size(); ++itag){
         InputTag tag=tags[itag];
         std::vector<InputTag> inputs;

         for(size_t input = 0; input < simtags.size(); ++input){
            if (object=="HepMCProduct") signal = gentags[input];
            else signal = simtags[input];
            inputs.push_back(InputTag(signal,tag.instance()));
         }

         std::string label=tag.label()+tag.instance();
         //      verifyRegistry(object,std::string(""),tag,label);
            if (object=="HepMCProduct"){
               workers_.push_back(new HiMixingWorker<HepMCProduct>(object,inputs,label));
               produces<CrossingFrame<HepMCProduct> >(label);
            }else if (object=="SimTrack"){
               workers_.push_back(new HiMixingWorker<SimTrack>(object,inputs,label));
               produces<CrossingFrame<SimTrack> >(label);
            }else if (object=="SimVertex"){
               workers_.push_back(new HiMixingWorker<SimVertex>(object,inputs,label));
               produces<CrossingFrame<SimVertex> >(label);
            }else if (object=="PSimHit"){
               workers_.push_back(new HiMixingWorker<PSimHit>(object,inputs,label));
               produces<CrossingFrame<PSimHit> >(label);
            }else if (object=="PCaloHit"){
               workers_.push_back(new HiMixingWorker<PCaloHit>(object,inputs,label));
               produces<CrossingFrame<PCaloHit> >(label);
            }else LogInfo("Error")<<"What the hell is this object?!";
            
            LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;         
            cout<<"The COUT : "<<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<endl;        
      }
   }  
}
HiMixingModule::~HiMixingModule ( )

Definition at line 230 of file HiMixingModule.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void HiMixingModule::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 256 of file HiMixingModule.cc.

{
}
void HiMixingModule::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 262 of file HiMixingModule.cc.

                       {
}
void HiMixingModule::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 245 of file HiMixingModule.cc.

References i.

{
   using namespace edm;

   for(size_t i = 0; i < workers_.size(); ++i){
      (workers_[i])->addSignals(iEvent);
   }
}
bool HiMixingModule::verifyRegistry ( std::string  object,
std::string  subdet,
InputTag tag,
std::string &  label 
) [private]

Definition at line 265 of file HiMixingModule.cc.

References edm::BranchDescription::className(), newFWLiteAna::found, edm::InputTag::instance(), edm::InputTag::label(), edm::BranchDescription::moduleLabel(), dbtoconf::object, and edm::BranchDescription::productInstanceName().

                                                                                                      {
   // verify that the given product exists in the product registry                                                                          
   // and create the label to be given to the CrossingFrame                                                                                 

   edm::Service<edm::ConstProductRegistry> reg;
   // Loop over provenance of products in registry.                                                                                         
   std::string lookfor;
   if (object=="HepMCProduct") lookfor="edm::"+object;//exception for HepMCProduct                                                          
   else if (object=="edm::HepMCProduct") lookfor=object;
   else  lookfor="std::vector<"+object+">";
   bool found=false;
   for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
        it != reg->productList().end(); ++it) {
      // See FWCore/Framework/interface/BranchDescription.h                                                                                  
      // BranchDescription contains all the information for the product.                                                                     
      edm::BranchDescription desc = it->second;
      if (desc.className()==lookfor && desc.moduleLabel()==tag.label() && desc.productInstanceName()==tag.instance()) {
         label=desc.moduleLabel()+desc.productInstanceName();
         found=true;
         /*
         wantedBranches_.push_back(desc.friendlyClassName() + '_' +
                                   desc.moduleLabel() + '_' +
                                   desc.productInstanceName());
         */
         break;
      }
   }
   if (!found) {
      LogWarning("MixingModule")<<"!!!!!!!!!Could not find in registry requested object: "<<object<<" with "<<tag<<".\nWill NOT be considered for mixing!!!!!!!!!";
      return false;
   }

   return true;
}

Member Data Documentation

Definition at line 160 of file HiMixingModule.cc.