1 |
yilmaz |
1.1 |
/*
|
2 |
|
|
* $Id: Raddam.cc,v 1.3 2012/02/22 18:49:18 yilmaz Exp $
|
3 |
|
|
*
|
4 |
|
|
* Description : Raddam
|
5 |
|
|
* Author : Sercan Sen, Taylan Yetkin
|
6 |
|
|
* Created : $Date: 2012/02/22 18:49:18 $
|
7 |
|
|
* Credits for PMT Event Rejection Algorithms:
|
8 |
|
|
* https://twiki.cern.ch/twiki/bin/viewauth/CMS/HcalRecHitReflagger
|
9 |
|
|
* Dinko Ferencek, Francesco Santanastasio, Jeff Temple
|
10 |
|
|
* The code from above authors has been modified to make it work locally
|
11 |
|
|
*
|
12 |
|
|
*/
|
13 |
|
|
|
14 |
|
|
// system include files
|
15 |
|
|
#include <memory>
|
16 |
|
|
#include <algorithm>
|
17 |
|
|
#include <vector>
|
18 |
|
|
#include <string>
|
19 |
|
|
#include <sys/time.h>
|
20 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
21 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
22 |
|
|
|
23 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
24 |
|
|
|
25 |
|
|
#include "DataFormats/DetId/interface/DetId.h"
|
26 |
|
|
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
|
27 |
|
|
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
|
28 |
|
|
#include "CondFormats/HcalObjects/interface/HcalQIECoder.h"
|
29 |
|
|
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
|
30 |
|
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
|
31 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
32 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
33 |
|
|
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
|
34 |
|
|
#include "DataFormats/Candidate/interface/Candidate.h"
|
35 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
36 |
|
|
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
37 |
|
|
#include "CalibFormats/HcalObjects/interface/HcalCoder.h"
|
38 |
|
|
#include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
|
39 |
|
|
#include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
|
40 |
|
|
#include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
|
41 |
|
|
#include "DataFormats/CaloTowers/interface/CaloTower.h"
|
42 |
|
|
#include "DataFormats/HcalDigi/interface/HcalLaserDigi.h"
|
43 |
|
|
|
44 |
|
|
//MET
|
45 |
|
|
#include "DataFormats/METReco/interface/CaloMET.h"
|
46 |
|
|
#include "DataFormats/METReco/interface/CaloMETCollection.h"
|
47 |
|
|
//trigger
|
48 |
|
|
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
|
49 |
|
|
#include "DataFormats/Common/interface/TriggerResults.h"
|
50 |
|
|
#include "FWCore/Common/interface/TriggerNames.h"
|
51 |
|
|
#include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
|
52 |
|
|
//RecHitFlags
|
53 |
|
|
#include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
|
54 |
|
|
#include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h" // for eta bounds
|
55 |
|
|
//
|
56 |
|
|
#include "DataFormats/Provenance/interface/Timestamp.h"
|
57 |
|
|
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
|
58 |
|
|
#include "TTree.h"
|
59 |
yilmaz |
1.2 |
#include "UserCode/HFmon2012/interface/Raddam.h"
|
60 |
yilmaz |
1.1 |
|
61 |
|
|
using namespace edm;
|
62 |
|
|
using namespace std;
|
63 |
|
|
using namespace reco;
|
64 |
|
|
|
65 |
|
|
Raddam::Raddam(const ParameterSet & iConfig) {
|
66 |
|
|
|
67 |
|
|
fRunNo = 0;
|
68 |
|
|
fEventNo = 0;
|
69 |
|
|
fNumDigis = 0;
|
70 |
|
|
for (int i = 0; i < 1728; ++i) {
|
71 |
|
|
fEta[i] = -999;
|
72 |
|
|
fPhi[i] = -999;
|
73 |
|
|
fDepth[i] = -999;
|
74 |
|
|
for(int j = 0; j < 10; ++j)fCharge[i][j] = -999;
|
75 |
|
|
for(int j = 0; j < 10; ++j)fCharge_fc[i][j] = -999;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
fTree =fs->make<TTree>("hfTree", "Tree for HF analysis");
|
79 |
|
|
|
80 |
|
|
if(0){
|
81 |
|
|
|
82 |
|
|
fTree->Branch("NumLaser", &tNumLaser, "NumLaser/I");
|
83 |
|
|
fTree->Branch("HitChannel", tHitChannel, "HitChannel[NumLaser]/I");
|
84 |
|
|
fTree->Branch("HitNS", tHitNS, "HitNS[NumLaser]/F");
|
85 |
|
|
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
if(1){
|
89 |
|
|
fTree->Branch("ClockOpto", &tClockOpto, "ClockOpto/F");
|
90 |
|
|
fTree->Branch("RawOpto", &tRawOpto, "RawOpto/F");
|
91 |
|
|
fTree->Branch("Trig", &tTrig, "Trig/F");
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
fTree->Branch("NumDigis", &fNumDigis, "NumDigis/I");
|
96 |
|
|
fTree->Branch("Eta", fEta, "Eta[NumDigis]/I");
|
97 |
|
|
fTree->Branch("Phi", fPhi, "Phi[NumDigis]/I");
|
98 |
|
|
fTree->Branch("Depth", fDepth, "Depth[NumDigis]/I");
|
99 |
|
|
fTree->Branch("Charge", fCharge, "Charge[NumDigis][10]/I");
|
100 |
|
|
fTree->Branch("ChargeFC", fCharge_fc, "ChargeFC[NumDigis][10]/I");
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
Raddam::~Raddam() {
|
104 |
|
|
|
105 |
|
|
}
|
106 |
|
|
void Raddam::initialize(){
|
107 |
|
|
fRunNo = 0;
|
108 |
|
|
fEventNo = 0;
|
109 |
|
|
fNumDigis = 0;
|
110 |
|
|
|
111 |
|
|
tNumLaser = 0;
|
112 |
|
|
for (int i = 0; i < 1728; ++i) {
|
113 |
|
|
fEta[i] = -999;
|
114 |
|
|
fPhi[i] = -999;
|
115 |
|
|
fDepth[i] = -999;
|
116 |
|
|
for(int j = 0; j < 10; ++j)fCharge[i][j] = -999;
|
117 |
|
|
for(int j = 0; j < 10; ++j)fCharge_fc[i][j] = -999;
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
void Raddam::analyze(const Event & iEvent, const EventSetup & iSetup) {
|
121 |
|
|
|
122 |
|
|
initialize();
|
123 |
|
|
/*
|
124 |
|
|
edm::Timestamp time_stamp = iEvent.time();
|
125 |
|
|
edm::TimeValue_t t_current_time = (cond::Time_t)time_stamp.value();
|
126 |
|
|
time_t i_current_time = (time_t)(t_current_time>>32);
|
127 |
|
|
const time_t* p_current_time = &i_current_time;
|
128 |
|
|
char* ascitime = ctime(p_current_time);
|
129 |
|
|
cout << "TIME " << ascitime << endl;
|
130 |
|
|
*/
|
131 |
|
|
|
132 |
|
|
edm::Handle<HcalLaserDigi> laserDigi;
|
133 |
|
|
iEvent.getByType(laserDigi);
|
134 |
|
|
|
135 |
|
|
tClockOpto = -99;
|
136 |
|
|
tTrig = -99;
|
137 |
|
|
tRawOpto = -99;
|
138 |
|
|
|
139 |
|
|
for( uint i = 0; i < laserDigi->tdcHits(); ++i ) {
|
140 |
|
|
tHitChannel[tNumLaser] = laserDigi->hitChannel(i);
|
141 |
|
|
tHitNS[tNumLaser] = laserDigi->hitNS(i);
|
142 |
|
|
tNumLaser++;
|
143 |
|
|
|
144 |
|
|
if( laserDigi->hitChannel(i) == 1 && tClockOpto < 0 ) {
|
145 |
|
|
tClockOpto = laserDigi->hitNS(i);
|
146 |
|
|
}
|
147 |
|
|
if( laserDigi->hitChannel(i) == 2 && tTrig < 0 ) {
|
148 |
|
|
tTrig = laserDigi->hitNS(i);
|
149 |
|
|
}
|
150 |
|
|
if( laserDigi->hitChannel(i) == 3 && tRawOpto < 0 ) {
|
151 |
|
|
tRawOpto = laserDigi->hitNS(i);
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
fRunNo = iEvent.id().run();
|
157 |
|
|
fEventNo = iEvent.id().event();
|
158 |
|
|
Handle < HFDigiCollection > hf_digi_h;
|
159 |
|
|
iEvent.getByType(hf_digi_h);
|
160 |
|
|
const HFDigiCollection *hf_digis = hf_digi_h.failedToGet()? 0 : &*hf_digi_h;
|
161 |
|
|
if (!hf_digis){
|
162 |
|
|
cout << "no HF digis" << endl;
|
163 |
|
|
}
|
164 |
|
|
if (hf_digis) { // object is available
|
165 |
|
|
int k = 0;
|
166 |
|
|
for (HFDigiCollection::const_iterator j = hf_digis->begin(); j != hf_digis->end(); j++) {
|
167 |
|
|
const HFDataFrame digi = (const HFDataFrame) (*j);
|
168 |
|
|
DetId fid = digi.id();
|
169 |
|
|
HcalDetId id = fid;
|
170 |
|
|
fEta[k] = id.ieta();
|
171 |
|
|
fPhi[k] = id.iphi();
|
172 |
|
|
fDepth[k] = id.depth();
|
173 |
|
|
float fData[10] = { -999. };
|
174 |
|
|
int nTS = digi.size();
|
175 |
|
|
for (int i = 0; i < nTS; ++i) {
|
176 |
|
|
fCharge[k][i] = j->sample(i).adc();
|
177 |
|
|
fCharge_fc[k][i] = j->sample(i).nominal_fC();
|
178 |
|
|
}
|
179 |
|
|
++k;
|
180 |
|
|
}
|
181 |
|
|
fNumDigis = k;
|
182 |
|
|
}else {
|
183 |
|
|
cout << "hf digis not found!" << endl;
|
184 |
|
|
}
|
185 |
|
|
fTree->Fill();
|
186 |
|
|
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
void Raddam::beginRun(const edm::Run & run,const edm::EventSetup& iSetup){
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
void Raddam::beginJob() {
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
void Raddam::endJob() {
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
//define this as a plug-in
|
199 |
|
|
DEFINE_FWK_MODULE(Raddam);
|