CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InputTagDistributor.h
Go to the documentation of this file.
1 #ifndef InputTagDistributor_H
2 #define InputTagDistributor_H
3 
10 
11 #include <map>
12 #include <iostream>
13 
15  public:
17  std::vector< std::string > inpuTags = pset.getParameterNamesForType<edm::InputTag>();
18  for (std::vector< std::string >::iterator i=inpuTags.begin();i!=inpuTags.end();++i)
20  }
22  std::map<std::string, edm::InputTag>::iterator findMe = inputTags_.find(s);
23  if (findMe!=inputTags_.end())
24  return findMe->second;
25  else{
26  std::stringstream known;
27  for (findMe=inputTags_.begin();findMe!=inputTags_.end();++findMe)
28  known<<findMe->first<<" ---> "<<findMe->second<<"\n";
29  edm::LogError("InputTagDistributor")<<" cannot distribute InputTag: "<<s<<"\n knonw mapping is:\n"<<known.str();
30  }
31  return inputTags_[s];
32  }
33 
34  private:
35  std::map<std::string, edm::InputTag> inputTags_;
36 };
37 
38 
40  private:
42  std::map<std::string, InputTagDistributor*> multipleInstance_;
43 
44  public:
46  //r.watchPreModule(this, &InputTagDistributorService::preModule );
48  };
50 
52  if (multipleInstance_.find(user)!=multipleInstance_.end()){
53  std::cerr<<user<<" InputTagDistributor user already defined."<<std::endl;
54  throw;}
58  }
59  void preModule(const edm::ModuleDescription& desc){
60  //does a set with the module name, except that it does not throw on non-configured modules
61  std::map<std::string, InputTagDistributor*>::iterator f=multipleInstance_.find(desc.moduleLabel());
62  if (f != multipleInstance_.end()) SetInputTagDistributorUniqueInstance_ = f->second;
63  else{
64  //do not say anything but set it to zero to get a safe crash in get() if ever called
66  }
67  /* InputTagDistributor & set(std::string & user){
68  std::map<std::string, InputTagDistributor*>::iterator f=multipleInstance_.find(user);
69  if (f == multipleInstance_.end()){
70  std::cerr<<user<<" InputTagDistributor user not defined. but it does not matter."<<std::endl;
71  // throw;}
72  }
73  else {
74  SetInputTagDistributorUniqueInstance_ = f->second;
75  return (*SetInputTagDistributorUniqueInstance_);
76  }
77  }*/
79  if (!SetInputTagDistributorUniqueInstance_){
80  std::cerr<<" SetInputTagDistributorUniqueInstance_ is not valid."<<std::endl;
81  throw;
82  }
83  else{ return (*SetInputTagDistributorUniqueInstance_);}
84  }
85 
87  //if used without setting any InputTag mapping
88  if (multipleInstance_.size()==0)
89  return pset.getParameter<edm::InputTag>(src);
90 
91  // some mapping was setup
92  InputTagDistributor & which=get();
93  std::map<std::string, InputTagDistributor*>::iterator inverseMap=multipleInstance_.begin();
94  std::map<std::string, InputTagDistributor*>::iterator inverseMap_end=multipleInstance_.end();
95  for (;inverseMap!=inverseMap_end;++inverseMap) if (inverseMap->second==&which) break;
96  LogDebug("InputTagDistributor")<<"typeCode: "<<pset.retrieve(src).typeCode()
97  <<"\n"<<pset.dump()<<"\n"
98  <<"looking for: "<<src
99  <<" by user: "<< inverseMap->first
100  <<std::endl;
102  typeCode+=pset.retrieve(src).typeCode();
103  std::string iTC;iTC+='S';
104  if (typeCode==iTC)
105  return which.inputTag(pset.getParameter<std::string>(src));
106  else
107  return pset.getParameter<edm::InputTag>(src);
108  }
109 };
110 
111 
112 
113 #endif
#define LogDebug(id)
T getParameter(std::string const &) const
Entry const & retrieve(char const *) const
int i
Definition: DBlmapReader.cc:9
def which
Definition: eostools.py:335
std::string dump(unsigned int indent=0) const
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
std::map< std::string, edm::InputTag > inputTags_
std::string const & moduleLabel() const
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
InputTagDistributor & init(std::string user, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
std::map< std::string, InputTagDistributor * > multipleInstance_
void preModule(const edm::ModuleDescription &desc)
TypeCode typeCode(const edm::TypeWithDict &t)
Definition: returnType.cc:44
double f[11][100]
InputTagDistributorService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &r)
const edm::InputTag & inputTag(std::string s)
InputTagDistributor(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
edm::InputTag retrieve(std::string src, const edm::ParameterSet &pset)
InputTagDistributor * SetInputTagDistributorUniqueInstance_
char typeCode() const
Definition: Entry.h:175
for(const auto &isodef:isoDefs)