CMS 3D CMS Logo

EcalTBDigiProducer.cc
Go to the documentation of this file.
1 
14 
16  EcalDigiProducer(params, mixMod, iC)
17 {
18  std::string const instance("simEcalUnsuppressedDigis");
19  m_EBdigiFinalTag = params.getParameter<std::string>( "EBdigiFinalCollection" ) ;
20  m_EBdigiTempTag = params.getParameter<std::string>( "EBdigiCollection");
21 
22  mixMod.produces<EBDigiCollection>(instance + m_EBdigiFinalTag) ; // after selective readout
23  mixMod.produces<EcalTBTDCRawInfo>(instance) ;
24 
25  const bool syncPhase ( params.getParameter<bool>("syncPhase") ) ;
26 
27  // possible phase shift for asynchronous trigger (e.g. test-beam)
28 
30  m_thisPhaseShift = 1. ;
31 
32  typedef std::vector< edm::ParameterSet > Parameters;
33  Parameters ranges=params.getParameter<Parameters>( "tdcRanges" ) ;
34  for( Parameters::iterator itRanges = ranges.begin();
35  itRanges != ranges.end(); ++itRanges )
36  {
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 
46  params.getUntrackedParameter< bool >("use2004OffsetConvention",
47  false ) ;
48 
50  params.getUntrackedParameter<std::string>( "EcalTBInfoLabel" ,
51  "SimEcalTBG4Object" ) ;
52 
53  m_doReadout = params.getParameter<bool>( "doReadout" ) ;
54 
55  m_theTBReadout = new EcalTBReadout( m_ecalTBInfoLabel ) ;
56 
57  m_tunePhaseShift = params.getParameter<double>( "tunePhaseShift" ) ;
58 
59  if( m_doPhaseShift )
60  {
61  iC.consumes<PEcalTBInfo>(edm::InputTag(params.getUntrackedParameter<std::string>("EcalTBInfoLabel","SimEcalTBG4Object")));
62  }
63 }
64 
66 {
67 }
68 
70  std::cout<<"====****Entering EcalTBDigiProducer produce()"<<std::endl ;
71  edm::ESHandle<CaloGeometry> hGeometry ;
72  eventSetup.get<CaloGeometryRecord>().get( hGeometry ) ;
73  const std::vector<DetId>& theBarrelDets (
74  hGeometry->getValidDetIds(DetId::Ecal, EcalBarrel) ) ;
75 
76  m_theTBReadout->setDetIds( theBarrelDets ) ;
77 
78  m_TDCproduct.reset( new EcalTBTDCRawInfo(1) ) ;
79  if( m_doPhaseShift )
80  {
81  edm::Handle<PEcalTBInfo> theEcalTBInfo ;
82  event.getByLabel( m_ecalTBInfoLabel, theEcalTBInfo ) ;
83  m_thisPhaseShift = theEcalTBInfo->phaseShift() ;
84 
85  DetId detId( DetId::Ecal, 1 ) ;
86  setPhaseShift( detId ) ;
87 
88  fillTBTDCRawInfo( *m_TDCproduct ) ; // fill the TDC info in the event
89  }
90  EcalDigiProducer::initializeEvent( event, eventSetup ) ;
91 }
92 
94  m_ebDigis.reset( new EBDigiCollection ) ;
95 
96  EcalDigiProducer::finalizeEvent( event, eventSetup ) ;
97 
98  const EBDigiCollection* barrelResult ( &*m_ebDigis ) ;
99 
100  std::unique_ptr<EBDigiCollection> barrelReadout( new EBDigiCollection() ) ;
101  if( m_doReadout )
102  {
104  m_theTTmap,
105  *barrelResult,
106  *barrelReadout ) ;
107  }
108  else
109  {
110  *barrelReadout = *barrelResult ;
111  }
112 
113  std::cout<< "===**** EcalTBDigiProducer: number of barrel digis = "
114  << barrelReadout->size()<<std::endl ;
115 
116  std::string const instance("simEcalUnsuppressedDigis");
117  event.put(std::move(barrelReadout), instance + m_EBdigiFinalTag) ;
118  event.put(std::move(m_TDCproduct), instance) ;
119 
120  m_ebDigis.reset(); // release memory
121  m_eeDigis.reset(); // release memory
122 }
123 
124 void
126 {
127  const CaloSimParameters& parameters (
128  EcalDigiProducer::m_ParameterMap->simParameters( detId ) ) ;
129 
130  if ( !parameters.syncPhase() )
131  {
132  const int myDet ( detId.subdetId() ) ;
133 
134  LogDebug("EcalDigi") << "Setting the phase shift "
135  << m_thisPhaseShift
136  << " and the offset "
137  << m_tunePhaseShift
138  << " for the subdetector "
139  << myDet;
140 
141  if( myDet == 1 )
142  {
143  double passPhaseShift ( m_thisPhaseShift + m_tunePhaseShift ) ;
144  if( m_use2004OffsetConvention ) passPhaseShift = 1. - passPhaseShift ;
145  EcalDigiProducer::m_EBResponse->setPhaseShift( passPhaseShift ) ;
146  EcalDigiProducer::m_EEResponse->setPhaseShift( passPhaseShift ) ;
147  }
148  }
149 }
150 
151 void
153 {
154  const unsigned int thisChannel ( 1 ) ;
155 
156  const unsigned int thisCount (
157  (unsigned int)( m_thisPhaseShift*( m_tdcRanges[0].tdcMax[0]
158  - m_tdcRanges[0].tdcMin[0] )
159  + m_tdcRanges[0].tdcMin[0] ) ) ;
160 
161  EcalTBTDCSample theTBTDCSample ( thisChannel, thisCount ) ;
162 
163  const unsigned int sampleIndex ( 0 ) ;
164  theTBTDCRawInfo.setSample( sampleIndex, theTBTDCSample ) ;
165 
166  LogDebug("EcalDigi") << theTBTDCSample << "\n" << theTBTDCRawInfo ;
167 }
168 
169 void
171 {
172  m_ebDigis.reset( new EBDigiCollection ) ;
173  *m_ebDigis = *ebDigiPtr ;
174 }
175 
176 void
178 {
179  std::cout<< "===**** EcalTBDigiProducer: number of endcap digis = "
180  << eeDigiPtr->size()<<std::endl ;
181 }
#define LogDebug(id)
const EcalTrigTowerConstituentsMap m_theTTmap
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< EEDigiCollection > m_eeDigis
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static PFTauRenderPlugin instance
void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const override
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 cacheEBDigis(const EBDigiCollection *ebDigiPtr) const override
std::string m_EBdigiFinalTag
void performReadout(edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EBDigiCollection &input, EBDigiCollection &output)
master function to be called once per event
EcalTBDigiProducer(const edm::ParameterSet &params, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
void finalizeEvent(edm::Event &, edm::EventSetup const &) override
string ranges
Definition: diffTwoXMLs.py:78
void setDetIds(const std::vector< DetId > &detIds)
tell the readout which cells exist
Definition: EcalTBReadout.h:27
void initializeEvent(edm::Event const &, edm::EventSetup const &) override
Definition: DetId.h:18
std::unique_ptr< EEHitResponse > m_EEResponse
const T & get() const
Definition: EventSetup.h:55
EcalTBReadout * m_theTBReadout
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:92
~EcalTBDigiProducer() override
double phaseShift() const
Definition: PEcalTBInfo.h:38
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:510
Definition: event.py:1
std::unique_ptr< const EcalSimParameterMap > m_ParameterMap
bool syncPhase() const
choice of the ADC time alignment (synchronous for LHC, asynchronous for test beams) ...