CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CastorTTRecord Class Reference

#include <CastorTTRecord.h>

Inheritance diagram for CastorTTRecord:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CastorTTRecord (const edm::ParameterSet &ps)
 
void getEnergy_fC (double energy[16][14], edm::Handle< CastorDigiCollection > &CastorDigiColl, edm::Event &e, const edm::EventSetup &c) const
 
void getTriggerDecisions (std::vector< bool > &decision, double energy[16][14]) const
 
void getTriggerDecisionsPerOctant (std::vector< bool > tdps[16], double energy[16][14]) const
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~CastorTTRecord ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT
< CastorDigiCollection
CastorDigiColl_
 
unsigned int CastorSignalTS_
 
std::vector< std::string > TrigNames_
 
std::vector< double > TrigThresholds_
 
std::vector< unsigned int > ttpBits_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 11 of file CastorTTRecord.h.

Constructor & Destructor Documentation

CastorTTRecord::CastorTTRecord ( const edm::ParameterSet ps)
explicit

Definition at line 14 of file CastorTTRecord.cc.

References CastorDigiColl_, CastorSignalTS_, edm::ParameterSet::getParameter(), TrigNames_, TrigThresholds_, and ttpBits_.

15 {
16  CastorDigiColl_ = consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("CastorDigiCollection")) ;
17  CastorSignalTS_ = ps.getParameter< unsigned int >("CastorSignalTS") ;
18 
19  ttpBits_ = ps.getParameter< std::vector<unsigned int> >("ttpBits");
20  TrigNames_ = ps.getParameter< std::vector<std::string> >("TriggerBitNames");
21  TrigThresholds_ = ps.getParameter< std::vector<double> >("TriggerThresholds");
22 
23  produces<L1GtTechnicalTriggerRecord>();
24 }
T getParameter(std::string const &) const
std::vector< unsigned int > ttpBits_
unsigned int CastorSignalTS_
std::vector< std::string > TrigNames_
std::vector< double > TrigThresholds_
edm::EDGetTokenT< CastorDigiCollection > CastorDigiColl_
CastorTTRecord::~CastorTTRecord ( )
virtual

Definition at line 27 of file CastorTTRecord.cc.

27  {
28 }

Member Function Documentation

void CastorTTRecord::getEnergy_fC ( double  energy[16][14],
edm::Handle< CastorDigiCollection > &  CastorDigiColl,
edm::Event e,
const edm::EventSetup c 
) const

Definition at line 64 of file CastorTTRecord.cc.

References CastorCoderDb::adc2fC(), CastorSignalTS_, edm::EventSetup::get(), CastorDataFrame::id(), HcalCastorDetId::module(), CastorCalibrations::pedestal(), and HcalCastorDetId::sector().

Referenced by produce().

66 {
67  // Get Conditions
69  eventSetup.get<CastorDbRecord>().get(conditions) ;
70  const CastorQIEShape* shape = conditions->getCastorShape () ; // this one is generic
71 
72  for(int isec=0; isec<16; isec++) for(int imod=0; imod<14; imod++) energy[isec][imod] = 0;
73 
74  // Loop over digis
76  for (idigi=CastorDigiColl->begin(); idigi!=CastorDigiColl->end(); idigi++) {
77  const CastorDataFrame & digi = (*idigi) ;
78  HcalCastorDetId cell = digi.id() ;
79 
80  // Get Castor Coder
81  const CastorQIECoder* channelCoder = conditions->getCastorCoder(cell);
82  CastorCoderDb coder (*channelCoder, *shape);
83 
84  // Get Castor Calibration
85  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
86 
87  // convert adc to fC
88  CaloSamples tool ;
89  coder.adc2fC(digi,tool) ;
90 
91  // pedestal substraction
92  int capid=digi[CastorSignalTS_].capid();
93  double fC = tool[CastorSignalTS_] - calibrations.pedestal(capid);
94  // double eGeV = fC * calibrations.gain(capid); // fC --> GeV
95 
96  energy[digi.id().sector()-1][digi.id().module()-1] = fC;
97  }
98 }
int sector() const
get the sector (1-16)
unsigned int CastorSignalTS_
std::vector< CastorDataFrame >::const_iterator const_iterator
int module() const
get the module (1-2 for EM, 1-12 for HAD)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const HcalCastorDetId & id() const
void CastorTTRecord::getTriggerDecisions ( std::vector< bool > &  decision,
double  energy[16][14] 
) const

Definition at line 100 of file CastorTTRecord.cc.

References asciidump::at, and getTriggerDecisionsPerOctant().

Referenced by produce().

101 {
102  // check if number of bits is at least four
103  if( decision.size() < 4 ) return;
104 
105  std::vector<bool> tdpo[8]; // TriggerDecisionsPerOctant
107 
108 
109  // preset trigger decisions
110  decision.at(0) = true;
111  decision.at(1) = false;
112  decision.at(2) = false;
113  decision.at(3) = false;
114 
115  bool EM_decision = false;
116  bool HAD_decision = false;
117  // loop over castor octants
118  for(int ioct=0; ioct<8; ioct++) {
119  int next_oct = (ioct+1)%8;
120  int prev_oct = (ioct+8-1)%8;
121 
122  // gap Trigger
123  if( !tdpo[ioct].at(0) ) decision.at(0) = false;
124  if( !tdpo[ioct].at(1) ) decision.at(0) = false;
125 
126  // jet Trigger
127  if( tdpo[ioct].at(2) ) decision.at(1) = true;
128 
129  // electron
130  if( tdpo[ioct].at(3) ) EM_decision = true;
131  if( tdpo[ioct].at(4) ) HAD_decision = true;
132 
133  // iso muon
134  if( tdpo[ioct].at(5) ) {
135  // was one of the other sectors
136  // in the octant empty ?
137  if( tdpo[ioct].at(0) ) {
138  if( tdpo[prev_oct].at(1) &&
139  tdpo[next_oct].at(0) &&
140  tdpo[next_oct].at(1) )
141  decision.at(3) = true;
142  }
143  else if( tdpo[ioct].at(1) ) {
144  if( tdpo[prev_oct].at(0) &&
145  tdpo[prev_oct].at(1) &&
146  tdpo[next_oct].at(0) )
147  decision.at(3) = true;
148  }
149  // when not no iso muon
150  }
151  }
152 
153  // for EM Trigger whole castor not hadronic and somewhere EM
154  decision.at(2) = EM_decision && !HAD_decision;
155 }
void getTriggerDecisionsPerOctant(std::vector< bool > tdps[16], double energy[16][14]) const
list at
Definition: asciidump.py:428
void CastorTTRecord::getTriggerDecisionsPerOctant ( std::vector< bool >  tdps[16],
double  energy[16][14] 
) const

Definition at line 157 of file CastorTTRecord.cc.

References asciidump::at, and TrigThresholds_.

Referenced by getTriggerDecisions().

158 {
159  // loop over octatants
160  for(int ioct=0; ioct<8; ioct++)
161  {
162  // six bits from HTR card
163  // 0. first sector empty
164  // 1. second sector empty
165  // 2. jet any sector
166  // 3. EM any sector
167  // 4. HAD any sector
168  // 5. muon any sector
169  tdpo[ioct].resize(6);
170 
171  for(int ibit=0; ibit<6; ibit++)
172  tdpo[ioct].at(ibit) = false;
173 
174  // loop over castor sectors in octant
175  for(int ioctsec=0; ioctsec<2; ioctsec++)
176  {
177  // absolute sector number
178  int isec = 2*ioct+ioctsec;
179 
180  // init module sums for every sector
181  double fCsum_mod = 0;
182  double fCsum_em = 0, fCsum_ha = 0;
183  double fCsum_col[3] = { 0, 0, 0 };
184 
185  // loop over modules
186  for(int imod=0; imod<14; imod++) {
187  // total sum
188  fCsum_mod += energy[isec][imod];
189 
190  // EM & HAD sum
191  if( imod < 2 ) fCsum_em += energy[isec][imod];
192  if( imod > 2 && imod < 12 ) fCsum_ha += energy[isec][imod];
193 
194  // sum over three sector parts
195  if( imod < 4 ) fCsum_col[0] += energy[isec][imod];
196  else if( imod < 8 ) fCsum_col[1] += energy[isec][imod];
197  else if( imod < 12 ) fCsum_col[2] += energy[isec][imod];
198  }
199 
200  // gap Trigger
201  if( fCsum_mod < TrigThresholds_.at(0) ) {
202  if( ioctsec == 0 ) tdpo[ioct].at(0) = true;
203  else if( ioctsec == 1 ) tdpo[ioct].at(1) = true;
204  }
205 
206  // jet Trigger
207  if( fCsum_mod > TrigThresholds_.at(1) )
208  tdpo[ioct].at(2) = true;
209 
210  // egamma Trigger
211  if( fCsum_em > TrigThresholds_.at(2) )
212  tdpo[ioct].at(3) = true;
213  if( fCsum_ha > TrigThresholds_.at(3) )
214  tdpo[ioct].at(4) = true;
215 
216  // muon Trigger
217  int countColumns = 0;
218  for( int icol=0; icol<3; icol++ )
219  if( fCsum_col[icol] > TrigThresholds_.at(4) )
220  countColumns++;
221  if( countColumns >= 2 )
222  tdpo[ioct].at(5) = true;
223  }
224  }
225 }
std::vector< double > TrigThresholds_
list at
Definition: asciidump.py:428
void CastorTTRecord::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 30 of file CastorTTRecord.cc.

References CastorDigiColl_, edm::Event::getByToken(), getEnergy_fC(), getTriggerDecisions(), i, convertSQLitetoXML_cfg::output, edm::Event::put(), TrigNames_, and ttpBits_.

30  {
31 
32  std::vector<L1GtTechnicalTrigger> vecTT(ttpBits_.size()) ;
33 
34  // Get Inputs
35  edm::Handle<CastorDigiCollection> CastorDigiColl ;
36  e.getByToken(CastorDigiColl_,CastorDigiColl) ;
37 
38  if ( !CastorDigiColl.failedToGet() ) {
39 
40  double cas_efC[16][14];
41  getEnergy_fC(cas_efC,CastorDigiColl,e,eventSetup);
42 
43 
44  std::vector<bool> decision(ttpBits_.size());
45 
46  getTriggerDecisions(decision,cas_efC);
47 
48  for(unsigned int i=0; i<ttpBits_.size(); i++) {
49  // std::cout << "Run CastorTTRecord::produce. TriggerBit = " << ttpBits_.at(i) << "; TriggerName = " << TrigNames_.at(i) << "; Decision = " << decision[i] << std::endl;
50  vecTT.at(i) = L1GtTechnicalTrigger(TrigNames_.at(i), ttpBits_.at(i), 0, decision.at(i)) ;
51  }
52 
53  } else {
54  vecTT.clear() ;
55  }
56 
57  // Put output into event
58  std::auto_ptr<L1GtTechnicalTriggerRecord> output(new L1GtTechnicalTriggerRecord()) ;
59  output->setGtTechnicalTrigger(vecTT) ;
60  e.put(output) ;
61 }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > ttpBits_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
std::vector< std::string > TrigNames_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
void getTriggerDecisions(std::vector< bool > &decision, double energy[16][14]) const
void getEnergy_fC(double energy[16][14], edm::Handle< CastorDigiCollection > &CastorDigiColl, edm::Event &e, const edm::EventSetup &c) const
edm::EDGetTokenT< CastorDigiCollection > CastorDigiColl_

Member Data Documentation

edm::EDGetTokenT<CastorDigiCollection> CastorTTRecord::CastorDigiColl_
private

Definition at line 32 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().

unsigned int CastorTTRecord::CastorSignalTS_
private

Definition at line 33 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and getEnergy_fC().

std::vector<std::string> CastorTTRecord::TrigNames_
private

Definition at line 36 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().

std::vector<double> CastorTTRecord::TrigThresholds_
private

Definition at line 37 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and getTriggerDecisionsPerOctant().

std::vector<unsigned int> CastorTTRecord::ttpBits_
private

Definition at line 35 of file CastorTTRecord.h.

Referenced by CastorTTRecord(), and produce().