CMS 3D CMS Logo

EcalTBDigiProducer.cc
Go to the documentation of this file.
1 
2 #include <memory>
3 
15 
17  edm::ProducesCollector producesCollector,
19  : EcalDigiProducer(params, producesCollector, iC), m_geometryToken(iC.esConsumes()) {
20  std::string const instance("simEcalUnsuppressedDigis");
21  m_EBdigiFinalTag = params.getParameter<std::string>("EBdigiFinalCollection");
22  m_EBdigiTempTag = params.getParameter<std::string>("EBdigiCollection");
23 
24  producesCollector.produces<EBDigiCollection>(instance + m_EBdigiFinalTag); // after selective readout
25  producesCollector.produces<EcalTBTDCRawInfo>(instance);
26 
27  const bool syncPhase(params.getParameter<bool>("syncPhase"));
28 
29  // possible phase shift for asynchronous trigger (e.g. test-beam)
30 
32  m_thisPhaseShift = 1.;
33 
34  typedef std::vector<edm::ParameterSet> Parameters;
35  Parameters ranges = params.getParameter<Parameters>("tdcRanges");
36  for (Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges) {
38  aRange.runRanges.first = itRanges->getParameter<int>("startRun");
39  aRange.runRanges.second = itRanges->getParameter<int>("endRun");
40  aRange.tdcMin = itRanges->getParameter<std::vector<double>>("tdcMin");
41  aRange.tdcMax = itRanges->getParameter<std::vector<double>>("tdcMax");
42  m_tdcRanges.push_back(std::move(aRange));
43  }
44 
45  m_use2004OffsetConvention = params.getUntrackedParameter<bool>("use2004OffsetConvention", false);
46 
47  m_ecalTBInfoLabel = params.getUntrackedParameter<std::string>("EcalTBInfoLabel", "SimEcalTBG4Object");
48 
49  m_doReadout = params.getParameter<bool>("doReadout");
50 
52 
53  m_tunePhaseShift = params.getParameter<double>("tunePhaseShift");
54 
55  if (m_doPhaseShift) {
57  edm::InputTag(params.getUntrackedParameter<std::string>("EcalTBInfoLabel", "SimEcalTBG4Object")));
58  }
59 }
60 
62 
64  std::cout << "====****Entering EcalTBDigiProducer produce()" << std::endl;
65  const std::vector<DetId> &theBarrelDets = eventSetup.getData(m_geometryToken).getValidDetIds(DetId::Ecal, EcalBarrel);
66 
67  m_theTBReadout->setDetIds(theBarrelDets);
68 
69  m_TDCproduct = std::make_unique<EcalTBTDCRawInfo>(1);
70  if (m_doPhaseShift) {
71  edm::Handle<PEcalTBInfo> theEcalTBInfo;
72  event.getByLabel(m_ecalTBInfoLabel, theEcalTBInfo);
73  m_thisPhaseShift = theEcalTBInfo->phaseShift();
74 
75  DetId detId(DetId::Ecal, 1);
76  setPhaseShift(detId);
77 
78  fillTBTDCRawInfo(*m_TDCproduct); // fill the TDC info in the event
79  }
81 }
82 
84  m_ebDigis = std::make_unique<EBDigiCollection>();
85 
87 
88  const EBDigiCollection *barrelResult(&*m_ebDigis);
89 
90  std::unique_ptr<EBDigiCollection> barrelReadout(new EBDigiCollection());
91  if (m_doReadout) {
92  m_theTBReadout->performReadout(event, m_theTTmap, *barrelResult, *barrelReadout);
93  } else {
94  *barrelReadout = *barrelResult;
95  }
96 
97  std::cout << "===**** EcalTBDigiProducer: number of barrel digis = " << barrelReadout->size() << std::endl;
98 
99  std::string const instance("simEcalUnsuppressedDigis");
100  event.put(std::move(barrelReadout), instance + m_EBdigiFinalTag);
101  event.put(std::move(m_TDCproduct), instance);
102 
103  m_ebDigis.reset(); // release memory
104  m_eeDigis.reset(); // release memory
105 }
106 
108  const CaloSimParameters &parameters(EcalDigiProducer::m_ParameterMap->simParameters(detId));
109 
110  if (!parameters.syncPhase()) {
111  const int myDet(detId.subdetId());
112 
113  LogDebug("EcalDigi") << "Setting the phase shift " << m_thisPhaseShift << " and the offset " << m_tunePhaseShift
114  << " for the subdetector " << myDet;
115 
116  if (myDet == 1) {
117  double passPhaseShift(m_thisPhaseShift + m_tunePhaseShift);
119  passPhaseShift = 1. - passPhaseShift;
120  EcalDigiProducer::m_EBResponse->setPhaseShift(passPhaseShift);
121  EcalDigiProducer::m_EEResponse->setPhaseShift(passPhaseShift);
122  }
123  }
124 }
125 
127  const unsigned int thisChannel(1);
128 
129  const unsigned int thisCount((unsigned int)(m_thisPhaseShift * (m_tdcRanges[0].tdcMax[0] - m_tdcRanges[0].tdcMin[0]) +
130  m_tdcRanges[0].tdcMin[0]));
131 
132  EcalTBTDCSample theTBTDCSample(thisChannel, thisCount);
133 
134  const unsigned int sampleIndex(0);
135  theTBTDCRawInfo.setSample(sampleIndex, theTBTDCSample);
136 
137  LogDebug("EcalDigi") << theTBTDCSample << "\n" << theTBTDCRawInfo;
138 }
139 
141  m_ebDigis = std::make_unique<EBDigiCollection>();
142  *m_ebDigis = *ebDigiPtr;
143 }
144 
146  std::cout << "===**** EcalTBDigiProducer: number of endcap digis = " << eeDigiPtr->size() << std::endl;
147 }
const EcalTrigTowerConstituentsMap m_theTTmap
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< EEDigiCollection > m_eeDigis
void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
static PFTauRenderPlugin instance
double phaseShift() const
Definition: PEcalTBInfo.h:37
std::vector< EcalTBTDCRecInfoAlgo::EcalTBTDCRanges > m_tdcRanges
Main class for Parameters in different subdetectors.
void fillTBTDCRawInfo(EcalTBTDCRawInfo &theTBTDCRawInfo)
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
std::unique_ptr< EBDigiCollection > m_ebDigis
vector< ParameterSet > Parameters
void setPhaseShift(const DetId &detId)
void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const override
std::string m_EBdigiFinalTag
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
void performReadout(edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EBDigiCollection &input, EBDigiCollection &output)
master function to be called once per event
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > m_geometryToken
void finalizeEvent(edm::Event &, edm::EventSetup const &) override
string ranges
Definition: diffTwoXMLs.py:79
void setDetIds(const std::vector< DetId > &detIds)
tell the readout which cells exist
Definition: EcalTBReadout.h:25
void initializeEvent(edm::Event const &, edm::EventSetup const &) override
Definition: DetId.h:17
std::unique_ptr< EEHitResponse > m_EEResponse
EcalTBDigiProducer(const edm::ParameterSet &params, edm::ProducesCollector, edm::ConsumesCollector &iC)
EcalTBReadout * m_theTBReadout
~EcalTBDigiProducer() override
void setSample(unsigned int i, const EcalTBTDCSample &sam)
std::string m_EBdigiTempTag
std::unique_ptr< EBHitResponse > m_EBResponse
std::unique_ptr< EcalTBTDCRawInfo > m_TDCproduct
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
std::string m_ecalTBInfoLabel
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
std::unique_ptr< const EcalSimParameterMap > m_ParameterMap
#define LogDebug(id)