CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTrigPrimProducer.cc
Go to the documentation of this file.
1 
17 
24 
30 
57 
58 #include "EcalTrigPrimProducer.h"
60 
62  barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
63  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
64  debug_(iConfig.getParameter<bool>("Debug")),ps_(iConfig)
65 {
66  //register your products
67  produces <EcalTrigPrimDigiCollection >();
68  if (tcpFormat_) produces <EcalTrigPrimDigiCollection >("formatTCP");
69 
70  label_= iConfig.getParameter<std::string>("Label");
71  instanceNameEB_ = iConfig.getParameter<std::string>("InstanceEB");;
72  instanceNameEE_ = iConfig.getParameter<std::string>("InstanceEE");;
73  algo_=NULL;
74 }
75 
77  bool famos = ps_.getParameter<bool>("Famos");
78 
80 
81  // get a first version of the records
82  cacheID_=this->getRecords(setup);
83 }
84 
86  delete algo_;
87 }
88 
90 
91  // get binOfMax
92  // try first in cfg, then in ProductRegistry
93  // =6 is default (1-10 possible values)
94  binOfMaximum_=0; //starts at 1!
95  bool found=false;
96  std::vector<std::string> names = ps_.getParameterNames();
97  if (find(names.begin(), names.end(), std::string("binOfMaximum"))
98  != names.end()) {
99  binOfMaximum_=ps_.getParameter<int>("binOfMaximum");
100  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in cfg file : "<<binOfMaximum_;
101  found = true;
102  }
103 
105  // Loop over provenance of products in registry.
106  for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
107  it != reg->productList().end(); ++it) {
108  edm::BranchDescription desc = it->second;
109  if (desc.friendlyClassName().find("EBDigiCollection")==0 &&
110  desc.moduleLabel()=="ecalUnsuppressedDigis") {
112  if (found ) {
113  if ( result.getParameter<int>("binOfMaximum")!=binOfMaximum_)edm:: LogWarning("EcalTPG")<< "binofMaximum given in configuration (="<<binOfMaximum_<<") is different from the one found in ProductRegistration(="<<result.getParameter<int>("binOfMaximum")<<")!!!";
114  }else {
115  binOfMaximum_=result.getParameter<int>("binOfMaximum");
116  edm::LogInfo("EcalTPG") <<"EcalTrigPrimProducer is using binOfMaximum found in ProductRegistry : "<<binOfMaximum_;
117  break;
118  }
119  }
120  }
121 
122 
123  if (binOfMaximum_==0) {
124  binOfMaximum_=6;
125  edm::LogWarning("EcalTPG")<<"Could not find product registry of EBDigiCollection (label ecalUnsuppressedDigis), had to set the following parameters by Hand: binOfMaximum="<<binOfMaximum_;
126  }
127 }
128 
130  // get Eventsetup records
131 
132  // for EcalFenixStrip...
133  // get parameter records for xtals
134  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
135  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
136  const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
137  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
138  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
139  const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
140  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
141  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
142  const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
143 
144 
145  //for strips
146  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
147  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
148  const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
149  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
150  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
151  const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
152  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
153  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
154  const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
155  edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
156  setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
157  const EcalTPGFineGrainStripEE * ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();
158 
159  algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgSlidW,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgFgStripEE,ecaltpgBadX);
160 
161  // .. and for EcalFenixTcp
162  // get parameter records for towers
163  edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
164  setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
165  const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
166 
167  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
168  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
169  const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
170 
171  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
172  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
173  const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
174 
175  edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
176  setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
177  const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
178 
179  edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
180  setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
181  const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
182 
183  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
184  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
185  const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
186 
187 
188  algo_->setPointers2(ecaltpgFgEBGroup,ecaltpgLutGroup,ecaltpgLut,ecaltpgFineGrainEB,ecaltpgFineGrainTowerEE,ecaltpgBadTT);
189 
190  // we will suppose that everything is to be updated if the EcalTPGLinearizationConstRcd has changed
191  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
192 }
193 
195 {}
196 
197 
198 // ------------ method called to produce the data ------------
199 void
201 {
202 
203  // update constants if necessary
205 
206  // get input collections
207 
210  bool barrel=true;
211  bool endcap=true;
212  if (barrelOnly_) endcap=false;
213 
214  if (!e.getByLabel(label_,instanceNameEB_,ebDigis)) {
215  barrel=false;
216  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with producer "<<label_<<" and label "<<instanceNameEB_<<"!!!";
217  }
218  if (!barrelOnly_) {
219  if (!e.getByLabel(label_,instanceNameEE_,eeDigis)) {
220  endcap=false;
221  edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with producer "<<label_<<" and label "<<instanceNameEE_<<"!!!";
222  }
223  }
224  if (!barrel && !endcap) {
225  throw cms::Exception(" ProductNotFound") <<"No EBDataFrames(EEDataFrames) with producer "<<label_<<" and label "<<instanceNameEB_<<" found in input!!\n";
226  }
227 
228  if (!barrelOnly_) LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size()<<", Number of EEDataFrames "<<eeDigis.product()->size() ;
229  else LogDebug("EcalTPG") <<" =================> Treating event "<<e.id()<<", Number of EBDataFrames "<<ebDigis.product()->size();
230 
231  std::auto_ptr<EcalTrigPrimDigiCollection> pOut(new EcalTrigPrimDigiCollection);
232  std::auto_ptr<EcalTrigPrimDigiCollection> pOutTcp(new EcalTrigPrimDigiCollection);
233 
234 
235  // invoke algorithm
236 
237  const EBDigiCollection *ebdc=NULL;
238  const EEDigiCollection *eedc=NULL;
239  if (barrel) {
240  ebdc=ebDigis.product();
241  algo_->run(iSetup,ebdc,*pOut,*pOutTcp);
242  }
243 
244  if (endcap) {
245  eedc=eeDigis.product();
246  algo_->run(iSetup,eedc,*pOut,*pOutTcp);
247  }
248 
249  edm::LogInfo("produce") <<"For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced";
250 
251  // debug prints if TP >0
252 
253  for (unsigned int i=0;i<pOut->size();++i) {
254  bool print=false;
255  for (int isam=0;isam<(*pOut)[i].size();++isam) {
256  if ((*pOut)[i][isam].raw()) print=true;
257  }
258  if (print) LogDebug("EcalTPG") <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i];
259  }
260  if (barrelOnly_) LogDebug("EcalTPG") <<"\n =================> For Barrel , "<<pOut->size()<<" TP Digis were produced (including zero ones)";
261  else LogDebug("EcalTPG") <<"\n =================> For Barrel + Endcap, "<<pOut->size()<<" TP Digis were produced (including zero ones)";
262 
263  // put result into the Event
264 
265  e.put(pOut);
266  if (tcpFormat_) e.put(pOutTcp,"formatTCP");
267 }
#define LogDebug(id)
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
int i
Definition: DBlmapReader.cc:9
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
ParameterSet const & getParameterSet(ParameterSetID const &id)
EcalTrigPrimFunctionalAlgo * algo_
#define NULL
Definition: scimark2.h:8
EcalTrigPrimProducer(const edm::ParameterSet &conf)
void setPointers(const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
ParameterSetID const & psetID() const
void beginRun(edm::Run &run, const edm::EventSetup &es)
unsigned long long cacheID_
void setPointers2(const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT)
std::string const & moduleLabel() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
void run(const edm::EventSetup &, const EBDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
tuple result
Definition: query.py:137
unsigned long long getRecords(edm::EventSetup const &setup)
std::string const & friendlyClassName() const
std::vector< std::string > getParameterNames() const
void endRun(edm::Run &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
virtual void produce(edm::Event &e, const edm::EventSetup &c)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
const edm::ParameterSet ps_
edm::EventID id() const
Definition: EventBase.h:56
static const HistoName names[]
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
ProductList const & productList() const
Definition: Run.h:32