CMS 3D CMS Logo

L1CaloTowerTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1Ntuples
4 // Class: L1CaloTowerTreeProducer
5 //
13 //
14 // Original Author:
15 // Created:
16 // $Id: L1CaloTowerTreeProducer.cc,v 1.8 2012/08/29 12:44:03 jbrooke Exp $
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // framework
31 
32 // data formats
38 
39 // cond formats
42 
43 // ROOT output stuff
46 #include "TTree.h"
47 
51 
54 
57 
58 //
59 // class declaration
60 //
61 
63 public:
65  ~L1CaloTowerTreeProducer() override;
66 
67 private:
68  void beginJob(void) override;
69  void analyze(const edm::Event&, const edm::EventSetup&) override;
70  void endJob() override;
71 
72 public:
76 
77 private:
78  double ecalLSB_;
79  unsigned maxCaloTP_;
80  unsigned maxL1Tower_;
81  unsigned maxL1Cluster_;
82 
83  // output file
85 
86  // tree
87  TTree* tree_;
88 
89  // EDM input tags
94 
96 };
97 
99  ecalToken_ = consumes<EcalTrigPrimDigiCollection>(iConfig.getUntrackedParameter<edm::InputTag>("ecalToken"));
100  hcalToken_ = consumes<HcalTrigPrimDigiCollection>(iConfig.getUntrackedParameter<edm::InputTag>("hcalToken"));
101  l1TowerToken_ = consumes<l1t::CaloTowerBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("l1TowerToken"));
102 
103  edm::InputTag clusterTag = iConfig.getUntrackedParameter<edm::InputTag>("l1ClusterToken");
104  storeCaloClusters_ = true;
105  if (clusterTag.label() == std::string("") or clusterTag.label() == std::string("none"))
106  storeCaloClusters_ = false;
107 
108  if (clusterTag.instance() != std::string(""))
109  l1ClusterToken_ = consumes<l1t::CaloClusterBxCollection>(clusterTag);
110 
111  ecalLSB_ = iConfig.getUntrackedParameter<double>("ecalLSB", 0.5);
112  maxCaloTP_ = iConfig.getUntrackedParameter<unsigned int>("maxCaloTP", 5760);
113  maxL1Tower_ = iConfig.getUntrackedParameter<unsigned int>("maxL1Tower", 5760);
114  maxL1Cluster_ = iConfig.getUntrackedParameter<unsigned int>("maxL1Cluster", 5760);
115 
116  // set up output
117  tree_ = fs_->make<TTree>("L1CaloTowerTree", "L1CaloTowerTree");
118  tree_->Branch("CaloTP", "L1Analysis::L1AnalysisCaloTPDataFormat", &caloTPData_, 32000, 3);
119  tree_->Branch("L1CaloTower", "L1Analysis::L1AnalysisL1CaloTowerDataFormat", &l1CaloTowerData_, 32000, 3);
120 
121  if (storeCaloClusters_)
122  tree_->Branch("L1CaloCluster", "L1Analysis::L1AnalysisL1CaloClusterDataFormat", &l1CaloClusterData_, 32000, 3);
123 
127 }
128 
130  // do anything here that needs to be done at desctruction time
131  // (e.g. close files, deallocate resources etc.)
132 }
133 
134 //
135 // member functions
136 //
137 
138 // ------------ method called to for each event ------------
140  // do calo towers
141  caloTPData_->Reset();
142 
144  iSetup.get<CaloTPGRecord>().get(decoder);
145 
148 
149  iEvent.getByToken(ecalToken_, ecalTPs);
150  iEvent.getByToken(hcalToken_, hcalTPs);
151 
152  if (ecalTPs.isValid()) {
153  for (auto itr : *(ecalTPs.product())) {
154  short ieta = (short)itr.id().ieta();
155  // unsigned short absIeta = (unsigned short) abs(ieta);
156  // short sign = ieta/absIeta;
157 
158  unsigned short cal_iphi = (unsigned short)itr.id().iphi();
159  unsigned short iphi = (72 + 18 - cal_iphi) % 72;
160  unsigned short compEt = itr.compressedEt();
161  double et = ecalLSB_ * compEt;
162  unsigned short fineGrain = (unsigned short)itr.fineGrain();
163 
164  if (compEt > 0) {
165  caloTPData_->ecalTPieta.push_back(ieta);
166  caloTPData_->ecalTPCaliphi.push_back(cal_iphi);
167  caloTPData_->ecalTPiphi.push_back(iphi);
168  caloTPData_->ecalTPet.push_back(et);
169  caloTPData_->ecalTPcompEt.push_back(compEt);
170  caloTPData_->ecalTPfineGrain.push_back(fineGrain);
171  caloTPData_->nECALTP++;
172  }
173  }
174 
175  } else {
176  edm::LogWarning("L1TNtuple") << "ECAL TPs not found, branch will not be filled";
177  }
178 
179  if (hcalTPs.isValid()) {
180  for (auto itr : (*hcalTPs.product())) {
181  int ver = itr.id().version();
182  short ieta = (short)itr.id().ieta();
183  unsigned short absIeta = (unsigned short)abs(ieta);
184  // short sign = ieta/absIeta;
185 
186  unsigned short cal_iphi = (unsigned short)itr.id().iphi();
187  unsigned short iphi = (72 + 18 - cal_iphi) % 72;
188 
189  unsigned short compEt = itr.SOI_compressedEt();
190  double et = decoder->hcaletValue(itr.id(), itr.t0());
191 
192  unsigned short fineGrain = (unsigned short)itr.SOI_fineGrain();
193 
194  if (compEt > 0 && (absIeta < 29 || ver == 1)) {
195  caloTPData_->hcalTPieta.push_back(ieta);
196  caloTPData_->hcalTPCaliphi.push_back(cal_iphi);
197  caloTPData_->hcalTPiphi.push_back(iphi);
198  caloTPData_->hcalTPet.push_back(et);
199  caloTPData_->hcalTPcompEt.push_back(compEt);
200  caloTPData_->hcalTPfineGrain.push_back(fineGrain);
201  caloTPData_->nHCALTP++;
202  }
203  }
204 
205  } else {
206  edm::LogWarning("L1TNtuple") << "HCAL TPs not found, branch will not be filled";
207  }
208 
209  // do L1 towers
211 
213 
214  iEvent.getByToken(l1TowerToken_, l1Towers);
215 
216  if (l1Towers.isValid()) {
217  for (int ibx = l1Towers->getFirstBX(); ibx <= l1Towers->getLastBX(); ++ibx) {
218  for (auto itr = l1Towers->begin(ibx); itr != l1Towers->end(ibx); ++itr) {
219  if (itr->hwPt() <= 0)
220  continue;
221 
222  // l1CaloTowerData_->bx.push_back( ibx );
223  l1CaloTowerData_->et.push_back(itr->pt());
224  l1CaloTowerData_->eta.push_back(itr->eta());
225  l1CaloTowerData_->phi.push_back(itr->phi());
226  l1CaloTowerData_->iet.push_back(itr->hwPt());
227  l1CaloTowerData_->ieta.push_back(itr->hwEta());
228  l1CaloTowerData_->iphi.push_back(itr->hwPhi());
229  l1CaloTowerData_->iem.push_back(itr->hwEtEm());
230  l1CaloTowerData_->ihad.push_back(itr->hwEtHad());
231  l1CaloTowerData_->iratio.push_back(itr->hwEtRatio());
232  l1CaloTowerData_->iqual.push_back(itr->hwQual());
233 
235  }
236  }
237 
238  } else {
239  edm::LogWarning("L1TNtuple") << "L1 Calo Towerss not found, branch will not be filled";
240  }
241 
242  // do L1 clusters
243  if (storeCaloClusters_) {
245 
247 
248  if (!l1ClusterToken_.isUninitialized())
249  iEvent.getByToken(l1ClusterToken_, l1Clusters);
250 
251  if (l1Clusters.isValid()) {
252  for (int ibx = l1Clusters->getFirstBX(); ibx <= l1Clusters->getLastBX(); ++ibx) {
253  for (auto itr = l1Clusters->begin(ibx); itr != l1Clusters->end(ibx); ++itr) {
254  if (itr->hwPt() <= 0)
255  continue;
256 
257  // l1CaloClusterData_->bx.push_back( ibx );
258  l1CaloClusterData_->et.push_back(itr->pt());
259  l1CaloClusterData_->eta.push_back(itr->eta());
260  l1CaloClusterData_->phi.push_back(itr->phi());
261  l1CaloClusterData_->iet.push_back(itr->hwPt());
262  l1CaloClusterData_->ieta.push_back(itr->hwEta());
263  l1CaloClusterData_->iphi.push_back(itr->hwPhi());
264  l1CaloClusterData_->iqual.push_back(itr->hwQual());
265 
267  }
268  }
269 
270  } else {
271  edm::LogWarning("L1TNtuple") << "L1 Calo Clusters not found, branch will not be filled";
272  }
273  }
274 
275  tree_->Fill();
276 }
277 
278 // ------------ method called once each job just before starting event loop ------------
280 
281 // ------------ method called once each job just after ending the event loop ------------
283 
284 //define this as a plug-in
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPiphi
std::vector< short > hcalTPiphi
Definition: L1AnalysisCaloTPDataFormat.h:39
L1Analysis::L1AnalysisL1CaloClusterDataFormat::iet
std::vector< short int > iet
Definition: L1AnalysisL1CaloClusterDataFormat.h:34
L1Analysis::L1AnalysisCaloTPDataFormat::nECALTP
short nECALTP
Definition: L1AnalysisCaloTPDataFormat.h:45
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
L1CaloTowerTreeProducer::maxCaloTP_
unsigned maxCaloTP_
Definition: L1CaloTowerTreeProducer.cc:79
ESHandle.h
L1CaloTowerTreeProducer::~L1CaloTowerTreeProducer
~L1CaloTowerTreeProducer() override
Definition: L1CaloTowerTreeProducer.cc:129
L1AnalysisL1CaloClusterDataFormat.h
L1Analysis::L1AnalysisL1CaloTowerDataFormat::iqual
std::vector< short > iqual
Definition: L1AnalysisL1CaloTowerDataFormat.h:41
L1Analysis::L1AnalysisL1CaloTowerDataFormat
Definition: L1AnalysisL1CaloTowerDataFormat.h:14
edm::EDGetTokenT
Definition: EDGetToken.h:33
L1Analysis::L1AnalysisL1CaloClusterDataFormat::nCluster
short int nCluster
Definition: L1AnalysisL1CaloClusterDataFormat.h:31
Muon.h
L1Analysis::L1AnalysisL1CaloTowerDataFormat::iet
std::vector< short > iet
Definition: L1AnalysisL1CaloTowerDataFormat.h:37
L1Analysis::L1AnalysisL1CaloClusterDataFormat
Definition: L1AnalysisL1CaloClusterDataFormat.h:14
Jet.h
L1Analysis::L1AnalysisL1CaloTowerDataFormat::phi
std::vector< float > phi
Definition: L1AnalysisL1CaloTowerDataFormat.h:44
L1CaloTowerTreeProducer::maxL1Cluster_
unsigned maxL1Cluster_
Definition: L1CaloTowerTreeProducer.cc:81
L1AnalysisL1CaloTowerDataFormat.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
L1CaloTowerTreeProducer::tree_
TTree * tree_
Definition: L1CaloTowerTreeProducer.cc:87
CaloCluster.h
CaloTPGTranscoder.h
L1Analysis::L1AnalysisL1CaloClusterDataFormat::phi
std::vector< float > phi
Definition: L1AnalysisL1CaloClusterDataFormat.h:38
edm::Handle
Definition: AssociativeIterator.h:50
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
L1Analysis::L1AnalysisL1CaloTowerDataFormat::eta
std::vector< float > eta
Definition: L1AnalysisL1CaloTowerDataFormat.h:43
L1AnalysisCaloTPDataFormat.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
BXVector::getFirstBX
int getFirstBX() const
L1Analysis::L1AnalysisCaloTPDataFormat::Reset
void Reset()
Definition: L1AnalysisCaloTPDataFormat.h:18
MakerMacros.h
L1Analysis::L1AnalysisL1CaloClusterDataFormat::iqual
std::vector< short int > iqual
Definition: L1AnalysisL1CaloClusterDataFormat.h:35
L1Analysis::L1AnalysisL1CaloTowerDataFormat::Reset
void Reset()
Definition: L1AnalysisL1CaloTowerDataFormat.h:18
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CaloTower.h
EGamma.h
Service.h
HcalDigiCollections.h
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPcompEt
std::vector< short > hcalTPcompEt
Definition: L1AnalysisCaloTPDataFormat.h:42
StandaloneTrackMonitor_cfi.clusterTag
clusterTag
Definition: StandaloneTrackMonitor_cfi.py:8
EcalDigiCollections.h
edm::ESHandle< CaloTPGTranscoder >
L1CaloTowerTreeProducer::caloTPData_
L1Analysis::L1AnalysisCaloTPDataFormat * caloTPData_
Definition: L1CaloTowerTreeProducer.cc:73
BXVector::begin
const_iterator begin(int bx) const
L1Analysis::L1AnalysisCaloTPDataFormat::nHCALTP
short nHCALTP
Definition: L1AnalysisCaloTPDataFormat.h:37
L1CaloTowerTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1CaloTowerTreeProducer.cc:84
L1CaloTowerTreeProducer::hcalToken_
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalToken_
Definition: L1CaloTowerTreeProducer.cc:91
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1Analysis::L1AnalysisL1CaloTowerDataFormat::et
std::vector< float > et
Definition: L1AnalysisL1CaloTowerDataFormat.h:42
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPCaliphi
std::vector< short > ecalTPCaliphi
Definition: L1AnalysisCaloTPDataFormat.h:48
edm::LogWarning
Definition: MessageLogger.h:141
TFileService.h
L1Analysis::L1AnalysisL1CaloClusterDataFormat::iphi
std::vector< short int > iphi
Definition: L1AnalysisL1CaloClusterDataFormat.h:33
L1Analysis::L1AnalysisL1CaloClusterDataFormat::et
std::vector< float > et
Definition: L1AnalysisL1CaloClusterDataFormat.h:36
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
BXVector::end
const_iterator end(int bx) const
L1CaloTowerTreeProducer::l1ClusterToken_
edm::EDGetTokenT< l1t::CaloClusterBxCollection > l1ClusterToken_
Definition: L1CaloTowerTreeProducer.cc:93
edm::ParameterSet
Definition: ParameterSet.h:36
L1CaloTowerTreeProducer
Definition: L1CaloTowerTreeProducer.cc:62
Event.h
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPet
std::vector< float > hcalTPet
Definition: L1AnalysisCaloTPDataFormat.h:41
CaloTPGRecord
Definition: CaloTPGRecord.h:26
L1CaloTowerTreeProducer::l1CaloClusterData_
L1Analysis::L1AnalysisL1CaloClusterDataFormat * l1CaloClusterData_
Definition: L1CaloTowerTreeProducer.cc:75
L1CaloTowerTreeProducer::storeCaloClusters_
bool storeCaloClusters_
Definition: L1CaloTowerTreeProducer.cc:95
L1Analysis::L1AnalysisL1CaloClusterDataFormat::Reset
void Reset()
Definition: L1AnalysisL1CaloClusterDataFormat.h:18
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPCaliphi
std::vector< short > hcalTPCaliphi
Definition: L1AnalysisCaloTPDataFormat.h:40
L1CaloTowerTreeProducer::l1TowerToken_
edm::EDGetTokenT< l1t::CaloTowerBxCollection > l1TowerToken_
Definition: L1CaloTowerTreeProducer.cc:92
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
L1CaloTowerTreeProducer::beginJob
void beginJob(void) override
Definition: L1CaloTowerTreeProducer.cc:279
edm::EventSetup
Definition: EventSetup.h:57
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPet
std::vector< float > ecalTPet
Definition: L1AnalysisCaloTPDataFormat.h:49
L1Analysis::L1AnalysisL1CaloTowerDataFormat::ieta
std::vector< short > ieta
Definition: L1AnalysisL1CaloTowerDataFormat.h:35
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
CaloTPGRecord.h
get
#define get
L1CaloTowerTreeProducer::ecalToken_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalToken_
Definition: L1CaloTowerTreeProducer.cc:90
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPiphi
std::vector< short > ecalTPiphi
Definition: L1AnalysisCaloTPDataFormat.h:47
L1CaloTowerTreeProducer::endJob
void endJob() override
Definition: L1CaloTowerTreeProducer.cc:282
L1Analysis::L1AnalysisL1CaloClusterDataFormat::ieta
std::vector< short int > ieta
Definition: L1AnalysisL1CaloClusterDataFormat.h:32
L1Analysis::L1AnalysisL1CaloTowerDataFormat::iphi
std::vector< short > iphi
Definition: L1AnalysisL1CaloTowerDataFormat.h:36
L1CaloTowerTreeProducer::l1CaloTowerData_
L1Analysis::L1AnalysisL1CaloTowerDataFormat * l1CaloTowerData_
Definition: L1CaloTowerTreeProducer.cc:74
L1Analysis::L1AnalysisL1CaloTowerDataFormat::ihad
std::vector< short > ihad
Definition: L1AnalysisL1CaloTowerDataFormat.h:39
Frameworkfwd.h
L1Analysis::L1AnalysisL1CaloTowerDataFormat::iratio
std::vector< short > iratio
Definition: L1AnalysisL1CaloTowerDataFormat.h:40
L1Analysis::L1AnalysisL1CaloClusterDataFormat::eta
std::vector< float > eta
Definition: L1AnalysisL1CaloClusterDataFormat.h:37
L1Analysis::L1AnalysisL1CaloTowerDataFormat::iem
std::vector< short > iem
Definition: L1AnalysisL1CaloTowerDataFormat.h:38
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPfineGrain
std::vector< short > hcalTPfineGrain
Definition: L1AnalysisCaloTPDataFormat.h:43
CaloTPGTranscoder::hcaletValue
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
L1Analysis::L1AnalysisCaloTPDataFormat
Definition: L1AnalysisCaloTPDataFormat.h:14
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
EtSum.h
L1Analysis::L1AnalysisCaloTPDataFormat::hcalTPieta
std::vector< short > hcalTPieta
Definition: L1AnalysisCaloTPDataFormat.h:38
L1CaloTowerTreeProducer::ecalLSB_
double ecalLSB_
Definition: L1CaloTowerTreeProducer.cc:78
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPieta
std::vector< short > ecalTPieta
Definition: L1AnalysisCaloTPDataFormat.h:46
L1CaloTowerTreeProducer::maxL1Tower_
unsigned maxL1Tower_
Definition: L1CaloTowerTreeProducer.cc:80
L1Analysis::L1AnalysisL1CaloTowerDataFormat::nTower
short nTower
Definition: L1AnalysisL1CaloTowerDataFormat.h:34
BXVector::getLastBX
int getLastBX() const
L1CaloTowerTreeProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1CaloTowerTreeProducer.cc:139
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPcompEt
std::vector< short > ecalTPcompEt
Definition: L1AnalysisCaloTPDataFormat.h:50
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
L1CaloTowerTreeProducer::L1CaloTowerTreeProducer
L1CaloTowerTreeProducer(const edm::ParameterSet &)
Definition: L1CaloTowerTreeProducer.cc:98
Tau.h
L1Analysis::L1AnalysisCaloTPDataFormat::ecalTPfineGrain
std::vector< short > ecalTPfineGrain
Definition: L1AnalysisCaloTPDataFormat.h:51