27 #include "FWCore/Framework/interface/Frameworkfwd.h"
28 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
29 #include "FWCore/Framework/interface/Event.h"
30 #include "FWCore/Framework/interface/MakerMacros.h"
31 #include "FWCore/ParameterSet/interface/ParameterSet.h"
32 #include "FWCore/ServiceRegistry/interface/Service.h"
33 #include "HGCal/DataFormats/interface/HGCalTBRecHitCollections.h"
34 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
35 #include "HGCal/DataFormats/interface/HGCalTBRecHit.h"
36 #include "HGCal/Geometry/interface/HGCalTBCellVertices.h"
37 #include "HGCal/Geometry/interface/HGCalTBTopology.h"
38 #include "HGCal/Geometry/interface/HGCalTBGeometryParameters.h"
39 #include "CommonTools/UtilAlgos/interface/TFileService.h"
40 #include "HGCal/DataFormats/interface/HGCalTBDataFrameContainers.h"
41 #include "HGCal/CondObjects/interface/HGCalElectronicsMap.h"
42 #include "HGCal/DataFormats/interface/HGCalTBElectronicsId.h"
43 #include "HGCal/DataFormats/interface/SKIROCParameters.h"
49 std::vector<std::pair<double, unsigned int> > _pedestals;
54 _pedestals[detId.
cellType()].first += pedestal;
55 _pedestals[detId.
cellType()].second++;
64 return _pedestals[detId.
cellType()].first / _pedestals[detId.
cellType()].second;
80 edm::Service<TFileService>
fs;
82 class DigiPlotter_New :
public edm::one::EDAnalyzer<edm::one::SharedResources>
86 explicit DigiPlotter_New(
const edm::ParameterSet&);
88 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
90 virtual void beginJob()
override;
91 void analyze(
const edm::Event& ,
const edm::EventSetup&)
override;
92 virtual void endJob()
override;
93 void InitTH2Poly(TH2Poly& poly);
95 Pedestal _pedestals[2];
99 std::vector<std::pair<double, double>> CellXY;
100 std::pair<double, double> CellCentreXY;
101 std::vector<std::pair<double, double>>::const_iterator it;
102 const static int NSAMPLES = 2;
103 const static int NLAYERS = 1;
119 DigiPlotter_New::DigiPlotter_New(
const edm::ParameterSet& iConfig)
122 consumesMany<SKIROC2DigiCollection>();
126 DigiPlotter_New::~DigiPlotter_New()
135 void DigiPlotter_New::InitTH2Poly(TH2Poly& poly)
140 for(
int iv = -7; iv < 8; iv++) {
141 for(
int iu = -7; iu < 8; iu++) {
142 if(!IsCellValid.iu_iv_valid(NLAYERS, Sensor_Iu, Sensor_Iv, iu, iv, sensorsize))
continue;
144 assert(CellXY.size() == 4 || CellXY.size() == 6);
145 unsigned int iVertex = 0;
146 for(it = CellXY.begin(); it != CellXY.end(); it++) {
147 HexX[iVertex] = it->first;
148 HexY[iVertex] = it->second;
152 poly.AddBin(CellXY.size(), HexX, HexY);
163 DigiPlotter_New::analyze(
const edm::Event& event,
const edm::EventSetup& setup)
165 int evId =
event.id().event() - 1;
169 char name[300], title[300];
170 std::vector<edm::Handle<SKIROC2DigiCollection> > ski;
171 event.getManyByType(ski);
176 std::vector<edm::Handle<SKIROC2DigiCollection> >::iterator i;
177 double Average_Pedestal_SKI1_Event1 = 0, Average_Pedestal_SKI1_Event2 = 0, Average_Pedestal_SKI2_Event1 = 0, Average_Pedestal_SKI2_Event2 = 0;
178 int Cell_SKI1_counter1 = 0, Cell_SKI1_counter2 = 0, Cell_SKI2_counter1 = 0, Cell_SKI2_counter2 = 0;
180 for(i = ski.begin(); i != ski.end(); i++) {
183 if(DEBUG) cout <<
"SKIROC2 Digis: " << i->provenance()->branchName() << endl;
186 for(SKIROC2DigiCollection::const_iterator k = Coll.begin(); k != Coll.end(); k++) {
190 int n_layer = (detId).layer();
191 int n_sensor_IU = (detId).sensorIU();
192 int n_sensor_IV = (detId).sensorIV();
193 int n_cell_iu = (detId).iu();
194 int n_cell_iv = (detId).iv();
196 if(DEBUG) cout << endl <<
" Layer = " << n_layer <<
" Sensor IU = " << n_sensor_IU <<
" Sensor IV = " << n_sensor_IV <<
" Cell iu = " << n_cell_iu <<
" Cell iu = " << n_cell_iv << endl;
198 if(!IsCellValid.iu_iv_valid(n_layer, n_sensor_IU, n_sensor_IV, n_cell_iu, n_cell_iv, sensorsize))
continue;
200 CellCentreXY = TheCell.GetCellCentreCoordinatesForPlots(n_layer, n_sensor_IU, n_sensor_IV, n_cell_iu, n_cell_iv, sensorsize);
202 double iyy = (CellCentreXY.second < 0 ) ? (CellCentreXY.second + 0.0001) : (CellCentreXY.second - 0.0001);
208 Average_Pedestal_SKI1_Event1+= skiFrame[0].adcHigh();
209 Cell_SKI1_counter1++;
212 Average_Pedestal_SKI2_Event1+= skiFrame[0].adcHigh();
213 Cell_SKI2_counter1++;
219 Average_Pedestal_SKI1_Event2+= skiFrame[0].adcHigh();
220 Cell_SKI1_counter2++;
223 Average_Pedestal_SKI2_Event2+= skiFrame[0].adcHigh();
224 Cell_SKI2_counter2++;
235 for(
unsigned int iLayer = 0; iLayer <
MAXLAYERS; ++iLayer) {
237 h_digi_layer[iLayer] =
fs->make<TH2Poly>();
238 sprintf(name,
"FullLayer_ADC%i_Layer%i_Event%i", 0, iLayer + 1, evId);
239 sprintf(title,
"Sum of adc counts per cell for ADC%i Layer%i Event%i", 0, iLayer + 1, evId);
240 h_digi_layer[iLayer]->SetName(name);
241 h_digi_layer[iLayer]->SetTitle(title);
242 InitTH2Poly(*h_digi_layer[iLayer]);
244 highGain_hpoly[iLayer] =
fs->make<TH2Poly>();
245 sprintf(name,
"FullLayer_ADC%i_Layer%i_Event%i", 1, iLayer + 1, evId);
246 sprintf(title,
"Sum of adc counts per cell for ADC%i Layer%i Event%i", 1, iLayer + 1, evId);
247 highGain_hpoly[iLayer]->SetName(name);
248 highGain_hpoly[iLayer]->SetTitle(title);
249 InitTH2Poly(*highGain_hpoly[iLayer]);
253 for(SKIROC2DigiCollection::const_iterator j = Coll.begin(); j != Coll.end(); j++) {
258 int n_layer = (SKI.
detid()).layer();
259 int n_sensor_IU = (SKI.
detid()).sensorIU();
260 int n_sensor_IV = (SKI.
detid()).sensorIV();
261 int n_cell_iu = (SKI.
detid()).iu();
262 int n_cell_iv = (SKI.
detid()).iv();
264 if(!IsCellValid.iu_iv_valid(n_layer, n_sensor_IU, n_sensor_IV, n_cell_iu, n_cell_iv, sensorsize))
continue;
268 if(DEBUG) cout << endl <<
" Layer = " << n_layer <<
" Sensor IU = " << n_sensor_IU <<
" Sensor IV = " << n_sensor_IV <<
" Cell iu = " << n_cell_iu <<
" Cell iu = " << n_cell_iv << endl;
272 CellCentreXY = TheCell.GetCellCentreCoordinatesForPlots(n_layer, n_sensor_IU, n_sensor_IV, n_cell_iu, n_cell_iv, sensorsize);
274 double iux = (CellCentreXY.first < 0 ) ? (CellCentreXY.first + 0.0001) : (CellCentreXY.first - 0.0001) ;
275 double iyy = (CellCentreXY.second < 0 ) ? (CellCentreXY.second + 0.0001) : (CellCentreXY.second - 0.0001);
278 cout << endl <<
" Layer = " << n_layer <<
" Sensor IU = " << n_sensor_IU <<
" Sensor IV = " << n_sensor_IV <<
" Cell iu = " << n_cell_iu <<
" Cell iu = " << n_cell_iv <<
" Layers= "<<MAXLAYERS<<endl;
279 if(evId%10 == 0) h_digi_layer[n_layer-1]->Fill(iux, iyy, 0.5 * (SKI[iSample].adcLow()));
281 if(evId%10 == 0) h_digi_layer[n_layer-1]->Fill(iux, iyy, (SKI[iSample].adcLow()));
285 if(n_layer == 1 && iyy<0) highGain_hpoly[n_layer-1]->Fill(iux , iyy, (SKI[iSample].adcHigh() - Average_Pedestal_SKI1_Event1/Cell_SKI1_counter1));
286 if(n_layer == 1 && iyy>0) highGain_hpoly[n_layer-1]->Fill(iux , iyy, (SKI[iSample].adcHigh() - Average_Pedestal_SKI2_Event1/Cell_SKI2_counter1));
287 if(n_layer == 2 && iyy<0) highGain_hpoly[n_layer-1]->Fill(iux , iyy, (SKI[iSample].adcHigh() - Average_Pedestal_SKI1_Event2/Cell_SKI1_counter2));
288 if(n_layer == 2 && iyy>0) highGain_hpoly[n_layer-1]->Fill(iux , iyy, (SKI[iSample].adcHigh() - Average_Pedestal_SKI2_Event2/Cell_SKI2_counter2));
295 edm::LogWarning(
"DQM") <<
"No SKIROC2 Digis";
303 DigiPlotter_New::beginJob()
310 DigiPlotter_New::endJob()
316 DigiPlotter_New::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
320 edm::ParameterSetDescription desc;
322 descriptions.addDefault(desc);
DEFINE_FWK_MODULE(Pedestals)
HGCalTBDetId detid() const
Get the detector id.
edm::Service< TFileService > fs
std::vector< std::pair< double, double > > GetCellCoordinatesForPlots(int layer, int sensor_iu, int sensor_iv, int iu, int iv, int sensorsize)
int cellType() const
cell type