CMS 3D CMS Logo

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

#include <EcalTPGAnalyzer.h>

Inheritance diagram for EcalTPGAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  EcalTPGVariables
 

Public Member Functions

virtual void analyze (edm::Event const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
 EcalTPGAnalyzer (const edm::ParameterSet &)
 
 ~EcalTPGAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool allowTP_
 
edm::InputTag digiCollectionEB_
 
edm::InputTag digiCollectionEE_
 
edm::ESHandle
< EcalTrigTowerConstituentsMap
eTTmap_
 
TFile * file_
 
std::string gtRecordCollectionTag_
 
bool print_
 
const CaloSubdetectorGeometrytheBarrelGeometry_
 
const CaloSubdetectorGeometrytheEndcapGeometry_
 
edm::InputTag tpCollection_
 
edm::InputTag tpEmulatorCollection_
 
TTree * tree_
 
EcalTPGVariables treeVariables_
 
bool useEE_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 39 of file EcalTPGAnalyzer.h.

Constructor & Destructor Documentation

EcalTPGAnalyzer::EcalTPGAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 51 of file EcalTPGAnalyzer.cc.

References edm::ParameterSet::getParameter(), edm::hash_detail::print_(), and AlCaHLTBitMon_QueryRunRegistry::string.

52 {
53  tpCollection_ = iConfig.getParameter<edm::InputTag>("TPCollection") ;
54  tpEmulatorCollection_ = iConfig.getParameter<edm::InputTag>("TPEmulatorCollection") ;
55  digiCollectionEB_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEB") ;
56  digiCollectionEE_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEE") ;
57  gtRecordCollectionTag_ = iConfig.getParameter<std::string>("GTRecordCollection") ;
58 
59  allowTP_ = iConfig.getParameter<bool>("ReadTriggerPrimitives");
60  useEE_ = iConfig.getParameter<bool>("UseEndCap");
61  print_ = iConfig.getParameter<bool>("Print");
62 
63  // file
64  file_ = new TFile("ECALTPGtree.root","RECREATE");
65  file_->cd() ;
66 
67  // tree
68  tree_ = new TTree( "EcalTPGAnalysis","EcalTPGAnalysis" );
69 
70  tree_->Branch("runNb",&treeVariables_.runNb,"runNb/i"); //
71  tree_->Branch("evtNb",&treeVariables_.evtNb,"evtNb/i"); //
72  tree_->Branch("bxNb",&treeVariables_.bxNb,"bxNb/i"); //
73  tree_->Branch("orbitNb",&treeVariables_.orbitNb,"orbitNb/i"); //
74  tree_->Branch("nbOfActiveTriggers",&treeVariables_.nbOfActiveTriggers,"nbOfActiveTriggers/i"); //
75  tree_->Branch("activeTriggers",treeVariables_.activeTriggers,"activeTriggers[nbOfActiveTriggers]/I"); //
76 
77  tree_->Branch("nbOfTowers",&treeVariables_.nbOfTowers,"nbOfTowers/i"); //
78  tree_->Branch("ieta", treeVariables_.ieta,"ieta[nbOfTowers]/I");//
79  tree_->Branch("iphi", treeVariables_.iphi,"iphi[nbOfTowers]/I");//
80  tree_->Branch("nbOfXtals", treeVariables_.nbOfXtals,"nbOfXtals[nbOfTowers]/I");//
81  tree_->Branch("rawTPData", treeVariables_.rawTPData,"rawTPData[nbOfTowers]/I");//
82  tree_->Branch("rawTPEmul1", treeVariables_.rawTPEmul1,"rawTPEmul1[nbOfTowers]/I");//
83  tree_->Branch("rawTPEmul2", treeVariables_.rawTPEmul2,"rawTPEmul2[nbOfTowers]/I");//
84  tree_->Branch("rawTPEmul3", treeVariables_.rawTPEmul3,"rawTPEmul3[nbOfTowers]/I");//
85  tree_->Branch("rawTPEmul4", treeVariables_.rawTPEmul4,"rawTPEmul4[nbOfTowers]/I");//
86  tree_->Branch("rawTPEmul5", treeVariables_.rawTPEmul5,"rawTPEmul5[nbOfTowers]/I");//
87  tree_->Branch("eRec", treeVariables_.eRec,"eRec[nbOfTowers]/F");//
88 }
std::string gtRecordCollectionTag_
T getParameter(std::string const &) const
EcalTPGVariables treeVariables_
edm::InputTag digiCollectionEB_
edm::InputTag tpEmulatorCollection_
edm::InputTag tpCollection_
edm::InputTag digiCollectionEE_
EcalTPGAnalyzer::~EcalTPGAnalyzer ( )

Definition at line 91 of file EcalTPGAnalyzer.cc.

92 {
93  file_->cd();
94  tree_->Write();
95  file_->Close();
96 }

Member Function Documentation

void EcalTPGAnalyzer::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 114 of file EcalTPGAnalyzer.cc.

References edm::EventBase::bunchCrossing(), gather_cfg::cout, edm::EventID::event(), edm::EventSetup::get(), edm::Event::getByLabel(), i, EEDataFrame::id(), EBDataFrame::id(), EcalTriggerPrimitiveDigi::id(), edm::EventBase::id(), EcalTrigTowerDetId::ieta(), towerEner::ieta_, EcalTrigTowerDetId::iphi(), towerEner::iphi_, j, edm::EventBase::orbitNumber(), edm::hash_detail::print_(), edm::Handle< T >::product(), edm::EventID::run(), and towerEner::tpgADC_.

115 {
116 
117 
118  using namespace edm;
119  using namespace std;
120 
121  if (print_) std::cout<<"==========="<<iEvent.id()<<std::endl ;
122 
123 
124  map<EcalTrigTowerDetId, towerEner> mapTower ;
125  map<EcalTrigTowerDetId, towerEner>::iterator itTT ;
126 
127 
128 
130  // get Evts info
132 
133  treeVariables_.runNb = iEvent.id().run() ;
134  treeVariables_.evtNb = iEvent.id().event() ;
135  treeVariables_.bxNb = iEvent.bunchCrossing() ;
136  treeVariables_.orbitNb = iEvent.orbitNumber() ;
137 
138 
140  // get L1 info
142 
144  iEvent.getByLabel( edm::InputTag(gtRecordCollectionTag_), gtRecord);
145  DecisionWord dWord = gtRecord->decisionWord(); // this will get the decision word *before* masking disabled bits
146 
148  iSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
149  std::vector<unsigned int> triggerMaskAlgoTrig = l1GtTmAlgo.product()->gtTriggerMask();
150 
151  // apply masks on algo
152  int iDaq = 0;
153  int iBit = -1;
155  for (std::vector<bool>::iterator itBit = dWord.begin(); itBit != dWord.end(); ++itBit) {
156  iBit++;
157  int maskBit = triggerMaskAlgoTrig[iBit] & (1 << iDaq);
158  if (maskBit) *itBit = false;
159  if (*itBit) {
162  }
163  }
164 
165 
166 
167 
168 
170  // Get TP data
172 
174  iEvent.getByLabel(tpCollection_,tp);
175  if (print_) std::cout<<"TP collection size="<<tp.product()->size()<<std::endl ;
176 
177  for (unsigned int i=0;i<tp.product()->size();i++) {
178  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
179  const EcalTrigTowerDetId TPtowid= d.id();
180  towerEner tE ;
181  tE.iphi_ = TPtowid.iphi() ;
182  tE.ieta_ = TPtowid.ieta() ;
183  tE.tpgADC_ = d[0].raw() ;
184  mapTower[TPtowid] = tE ;
185  }
186 
187 
188 
190  // Get Emulators TP
192 
194  iEvent.getByLabel(tpEmulatorCollection_, tpEmul);
195  if (print_) std::cout<<"TPEmulator collection size="<<tpEmul.product()->size()<<std::endl ;
196 
197  for (unsigned int i=0;i<tpEmul.product()->size();i++) {
198  EcalTriggerPrimitiveDigi d = (*(tpEmul.product()))[i];
199  const EcalTrigTowerDetId TPtowid= d.id();
200  itTT = mapTower.find(TPtowid) ;
201  if (itTT != mapTower.end())
202  for (int j=0 ; j<5 ; j++) (itTT->second).tpgEmul_[j] = d[j].raw() ;
203  }
204 
205 
206 
208  // Get nb of crystals read out
210 
211  // Get EB xtal digi inputs
213  iEvent.getByLabel(digiCollectionEB_, digiEB);
214 
215  for (unsigned int i=0;i<digiEB.product()->size();i++) {
216  const EBDataFrame & df = (*(digiEB.product()))[i];
217  const EBDetId & id = df.id();
218  const EcalTrigTowerDetId towid = id.tower();
219  itTT = mapTower.find(towid) ;
220  if (itTT != mapTower.end()) (itTT->second).nbXtal_++ ;
221  }
222 
223  if (useEE_) {
224  // Get EE xtal digi inputs
226  iEvent.getByLabel(digiCollectionEE_, digiEE);
227  for (unsigned int i=0;i<digiEE.product()->size();i++) {
228  const EEDataFrame & df = (*(digiEE.product()))[i];
229  const EEDetId & id = df.id();
230  const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id);
231  itTT = mapTower.find(towid) ;
232  if (itTT != mapTower.end()) (itTT->second).nbXtal_++ ;
233  }
234  }
235 
237  // Get rechits
239 
240  //... to be completed
241 
242 
243 
244 
245 
247  // fill tree
249 
250  treeVariables_.nbOfTowers = mapTower.size() ;
251  int towerNb = 0 ;
252  for (itTT = mapTower.begin() ; itTT != mapTower.end() ; ++itTT) {
253  treeVariables_.ieta[towerNb] = (itTT->second).ieta_ ;
254  treeVariables_.iphi[towerNb] = (itTT->second).iphi_ ;
255  treeVariables_.nbOfXtals[towerNb] = (itTT->second).nbXtal_ ;
256  treeVariables_.rawTPData[towerNb] = (itTT->second).tpgADC_ ;
257  treeVariables_.rawTPEmul1[towerNb] = (itTT->second).tpgEmul_[0] ;
258  treeVariables_.rawTPEmul2[towerNb] = (itTT->second).tpgEmul_[1] ;
259  treeVariables_.rawTPEmul3[towerNb] = (itTT->second).tpgEmul_[2] ;
260  treeVariables_.rawTPEmul4[towerNb] = (itTT->second).tpgEmul_[3] ;
261  treeVariables_.rawTPEmul5[towerNb] = (itTT->second).tpgEmul_[4] ;
262  treeVariables_.eRec[towerNb] = (itTT->second).eRec_ ;
263  towerNb++ ;
264  }
265 
266  tree_->Fill() ;
267 
268 }
std::string gtRecordCollectionTag_
int i
Definition: DBlmapReader.cc:9
key_type id() const
Definition: EBDataFrame.h:31
int ieta() const
get the tower ieta
int iEvent
Definition: GenABIO.cc:243
EcalTPGVariables treeVariables_
edm::InputTag digiCollectionEB_
std::vector< bool > DecisionWord
typedefs
edm::InputTag tpEmulatorCollection_
int j
Definition: DBlmapReader.cc:9
edm::InputTag tpCollection_
key_type id() const
Definition: EEDataFrame.h:28
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
T const * product() const
Definition: Handle.h:81
tuple cout
Definition: gather_cfg.py:121
edm::InputTag digiCollectionEE_
void EcalTPGAnalyzer::beginRun ( edm::Run const &  ,
edm::EventSetup const &  evtSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 98 of file EcalTPGAnalyzer.cc.

References edm::EventSetup::get().

99 {
100  // geometry
101  ESHandle<CaloGeometry> theGeometry;
102  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
103 
104  evtSetup.get<CaloGeometryRecord>().get( theGeometry );
105  evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle);
106  evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle);
107 
108  evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
109  theEndcapGeometry_ = &(*theEndcapGeometry_handle);
110  theBarrelGeometry_ = &(*theBarrelGeometry_handle);
111 }
const CaloSubdetectorGeometry * theEndcapGeometry_
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
const CaloSubdetectorGeometry * theBarrelGeometry_

Member Data Documentation

bool EcalTPGAnalyzer::allowTP_
private

Definition at line 82 of file EcalTPGAnalyzer.h.

edm::InputTag EcalTPGAnalyzer::digiCollectionEB_
private

Definition at line 78 of file EcalTPGAnalyzer.h.

edm::InputTag EcalTPGAnalyzer::digiCollectionEE_
private

Definition at line 79 of file EcalTPGAnalyzer.h.

edm::ESHandle<EcalTrigTowerConstituentsMap> EcalTPGAnalyzer::eTTmap_
private

Definition at line 88 of file EcalTPGAnalyzer.h.

TFile* EcalTPGAnalyzer::file_
private

Definition at line 72 of file EcalTPGAnalyzer.h.

std::string EcalTPGAnalyzer::gtRecordCollectionTag_
private

Definition at line 80 of file EcalTPGAnalyzer.h.

bool EcalTPGAnalyzer::print_
private

Definition at line 84 of file EcalTPGAnalyzer.h.

const CaloSubdetectorGeometry* EcalTPGAnalyzer::theBarrelGeometry_
private

Definition at line 87 of file EcalTPGAnalyzer.h.

const CaloSubdetectorGeometry* EcalTPGAnalyzer::theEndcapGeometry_
private

Definition at line 86 of file EcalTPGAnalyzer.h.

edm::InputTag EcalTPGAnalyzer::tpCollection_
private

Definition at line 76 of file EcalTPGAnalyzer.h.

edm::InputTag EcalTPGAnalyzer::tpEmulatorCollection_
private

Definition at line 77 of file EcalTPGAnalyzer.h.

TTree* EcalTPGAnalyzer::tree_
private

Definition at line 73 of file EcalTPGAnalyzer.h.

EcalTPGVariables EcalTPGAnalyzer::treeVariables_
private

Definition at line 74 of file EcalTPGAnalyzer.h.

bool EcalTPGAnalyzer::useEE_
private

Definition at line 83 of file EcalTPGAnalyzer.h.