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 
9 
10 #include <map>
11 #include <iostream>
12 
14  public:
16  std::vector< std::string > inpuTags = pset.getParameterNamesForType<edm::InputTag>();
17  for (std::vector< std::string >::iterator i=inpuTags.begin();i!=inpuTags.end();++i)
19  }
21  std::map<std::string, edm::InputTag>::iterator findMe = inputTags_.find(s);
22  if (findMe!=inputTags_.end())
23  return findMe->second;
24  else{
25  std::stringstream known;
26  for (findMe=inputTags_.begin();findMe!=inputTags_.end();++findMe)
27  known<<findMe->first<<" ---> "<<findMe->second<<"\n";
28  edm::LogError("InputTagDistributor")<<" cannot distribute InputTag: "<<s<<"\n knonw mapping is:\n"<<known.str();
29  }
30  return inputTags_[s];
31  }
32 
33  private:
34  std::map<std::string, edm::InputTag> inputTags_;
35 };
36 
37 
39  private:
41  std::map<std::string, InputTagDistributor*> multipleInstance_;
42 
43  public:
46  };
48 
50  if (multipleInstance_.find(user)!=multipleInstance_.end()){
51  std::cerr<<user<<" InputTagDistributor user already defined."<<std::endl;
52  throw;}
56  }
57  void preModule(const edm::ModuleDescription& desc){
58  //does a set with the module name, except that it does not throw on non-configured modules
59  std::map<std::string, InputTagDistributor*>::iterator f=multipleInstance_.find(desc.moduleLabel());
60  if (f != multipleInstance_.end()) SetInputTagDistributorUniqueInstance_ = f->second;
61  else{
62  //do not say anything but set it to zero to get a safe crash in get() if ever called
64  }
65  /* InputTagDistributor & set(std::string & user){
66  std::map<std::string, InputTagDistributor*>::iterator f=multipleInstance_.find(user);
67  if (f == multipleInstance_.end()){
68  std::cerr<<user<<" InputTagDistributor user not defined. but it does not matter."<<std::endl;
69  // throw;}
70  }
71  else {
72  SetInputTagDistributorUniqueInstance_ = f->second;
73  return (*SetInputTagDistributorUniqueInstance_);
74  }
75  }*/
77  if (!SetInputTagDistributorUniqueInstance_){
78  std::cerr<<" SetInputTagDistributorUniqueInstance_ is not valid."<<std::endl;
79  throw;
80  }
81  else{ return (*SetInputTagDistributorUniqueInstance_);}
82  }
83 
85  //if used without setting any InputTag mapping
86  if (multipleInstance_.size()==0)
87  return pset.getParameter<edm::InputTag>(src);
88 
89  // some mapping was setup
90  InputTagDistributor & which=get();
91  std::map<std::string, InputTagDistributor*>::iterator inverseMap=multipleInstance_.begin();
92  std::map<std::string, InputTagDistributor*>::iterator inverseMap_end=multipleInstance_.end();
93  for (;inverseMap!=inverseMap_end;++inverseMap) if (inverseMap->second==&which) break;
94  LogDebug("InputTagDistributor")<<"typeCode: "<<pset.retrieve(src).typeCode()
95  <<"\n"<<pset.dump()<<"\n"
96  <<"looking for: "<<src
97  <<" by user: "<< inverseMap->first
98  <<std::endl;
100  typeCode+=pset.retrieve(src).typeCode();
101  std::string iTC;iTC+='S';
102  if (typeCode==iTC)
103  return which.inputTag(pset.getParameter<std::string>(src));
104  else
105  return pset.getParameter<edm::InputTag>(src);
106  }
107 };
108 
109 
110 
111 #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
std::map< std::string, edm::InputTag > inputTags_
std::string const & moduleLabel() const
void watchPreModule(PreModule::slot_type const &iSlot)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
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)
edm::InputTag retrieve(std::string src, const edm::ParameterSet &pset)
InputTagDistributor(const edm::ParameterSet &pset)
InputTagDistributor & init(std::string user, const edm::ParameterSet &iConfig)
InputTagDistributor * SetInputTagDistributorUniqueInstance_
char typeCode() const
Definition: Entry.h:175
for(const auto &isodef:isoDefs)