29 #include "FWCore/Framework/interface/Frameworkfwd.h"
30 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
31 #include "FWCore/Framework/interface/Event.h"
32 #include "FWCore/Framework/interface/MakerMacros.h"
33 #include "FWCore/ParameterSet/interface/ParameterSet.h"
34 #include "FWCore/ServiceRegistry/interface/Service.h"
35 #include "HGCal/DataFormats/interface/HGCalTBRecHitCollections.h"
36 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
37 #include "HGCal/DataFormats/interface/HGCalTBRecHit.h"
38 #include "HGCal/Geometry/interface/HGCalTBCellVertices.h"
39 #include "HGCal/Geometry/interface/HGCalTBTopology.h"
40 #include "CommonTools/UtilAlgos/interface/TFileService.h"
41 #include "HGCal/CondObjects/interface/HGCalElectronicsMap.h"
42 #include "HGCal/CondObjects/interface/HGCalCondObjectTextIO.h"
43 #include "HGCal/DataFormats/interface/HGCalTBElectronicsId.h"
44 #include "HGCal/Geometry/interface/HGCalTBGeometryParameters.h"
56 static const double delta = 0.00001;
59 return sqrt(mean_sq - mean*mean);
62 class RecHitPlotter_HighGain_Correlation_CM :
public edm::one::EDAnalyzer<edm::one::SharedResources>
66 explicit RecHitPlotter_HighGain_Correlation_CM(
const edm::ParameterSet&);
67 ~RecHitPlotter_HighGain_Correlation_CM();
68 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
71 virtual void beginJob()
override;
72 void analyze(
const edm::Event& ,
const edm::EventSetup&)
override;
73 virtual void endJob()
override;
76 edm::EDGetToken HGCalTBRecHitCollection_;
79 std::string mapfile_ =
"HGCal/CondObjects/data/map_FNAL_SB2_Layer16.txt";
84 std::vector<std::pair<double, double>> CellXY;
85 std::pair<double, double> CellCentreXY;
86 std::vector<std::pair<double, double>>::const_iterator it;
90 const static int NLAYERS = 128;
91 TH2Poly *h_RecHit_layer[128];
92 const static int cellx = 15;
93 const static int celly = 15;
103 TH1F* Sum_Cluster_ADC;
106 TH2F* Noise_2D_Profile;
107 char name[50], title[50];
121 RecHitPlotter_HighGain_Correlation_CM::RecHitPlotter_HighGain_Correlation_CM(
const edm::ParameterSet& iConfig)
124 usesResource(
"TFileService");
125 edm::Service<TFileService>
fs;
126 HGCalTBRecHitCollection_ = consumes<HGCalTBRecHitCollection>(iConfig.getParameter<edm::InputTag>(
"HGCALTBRECHITS"));
129 AllCells_Ped =
fs->make<TH1F>(
"AllCells_Ped",
"AllCells_Ped",500,-250,250);
130 AllCells_CM =
fs->make<TH1F>(
"AllCells_CM",
"AllCells_CM",500,-250,250);
131 sprintf(name,
"Noise_2D_Profile_Layer");
132 sprintf(title,
"Noise 2D Profile Layer");
133 Noise_2D_Profile =
fs->make<TH2F>(name,title,2048,0,2048,8000,-4000,4000);
134 for(
int ILayer=0;ILayer<
MAXLAYERS;ILayer++){
135 sprintf(name,
"Full_Cell_Layer_%i",ILayer);
136 sprintf(title,
"Full Cell Layer %i",ILayer);
137 Full_Cell[ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
138 sprintf(name,
"Half_Cell_Layer_%i",ILayer);
139 sprintf(title,
"Half Cell Layer %i",ILayer);
140 Half_Cell[ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
141 sprintf(name,
"MB_Cell_Layer_%i",ILayer);
142 sprintf(title,
"MB Cell Layer %i",ILayer);
143 MB_Cell[ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
144 sprintf(name,
"Calib_Pads_Layer_%i",ILayer);
145 sprintf(title,
"Calib Pads Layer %i",ILayer);
146 Calib_Pads[ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
147 sprintf(name,
"Merged_Cell_Layer_%i",ILayer);
148 sprintf(title,
"Merged Cell Layer %i",ILayer);
149 Merged_Cell[ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
150 for(
int ISkiroc = 1;ISkiroc<=
MAXSKIROCS;ISkiroc++){
151 for(
int Channel=0; Channel<64;Channel++){
152 sprintf(name,
"Ski_%i_Channel_%i_Layer_%i",ISkiroc,Channel,ILayer);
153 sprintf(title,
"Ski %i Channel %i Layer %i",ISkiroc,Channel,ILayer);
154 h_digi_layer_channel[ISkiroc-1][Channel][ILayer] =
fs->make<TH1F>(name, title, 1000,-500., 500.);
167 RecHitPlotter_HighGain_Correlation_CM::~RecHitPlotter_HighGain_Correlation_CM()
182 RecHitPlotter_HighGain_Correlation_CM::analyze(
const edm::Event& event,
const edm::EventSetup& setup)
187 edm::Handle<HGCalTBRecHitCollection> Rechits;
188 event.getByToken(HGCalTBRecHitCollection_, Rechits);
189 edm::Handle<HGCalTBRecHitCollection> Rechits1;
190 event.getByToken(HGCalTBRecHitCollection_, Rechits1);
192 double Average_Pedestal_Per_Event_Full[
MAXLAYERS] = {0};
194 double Average_Pedestal_Per_Event_Half[
MAXLAYERS] = {0};
196 double Average_Pedestal_Per_Event_MB[
MAXLAYERS] = {0};
198 double Average_Pedestal_Per_Event_Calib_Pad[
MAXLAYERS] = {0};
199 int Cell_counter_Calib_Pad[
MAXLAYERS] = {0};
200 double Average_Pedestal_Per_Event_Merged_Cell[
MAXLAYERS] = {0};
201 int Cell_counter_Merged_Cell[
MAXLAYERS] = {0};
202 for(
auto RecHit1 : *Rechits1) {
203 CellCentreXY = TheCell.GetCellCentreCoordinatesForPlots((RecHit1.id()).layer(), (RecHit1.id()).sensorIU(), (RecHit1.id()).sensorIV(), (RecHit1.id()).iu(), (RecHit1.id()).iv(), sensorsize);
204 uint32_t EID = essource_.emap_.detId2eid(RecHit1.id());
212 if((RecHit1.id()).cellType() == 0){
214 Cell_counter[(RecHit1.id()).layer() - 1]++;
215 Average_Pedestal_Per_Event_Full[(RecHit1.id()).layer() - 1] += RecHit1.energyHigh();
217 else if((RecHit1.id()).cellType() == 2){
219 Cell_counter_Half[(RecHit1.id()).layer() - 1]++;
220 Average_Pedestal_Per_Event_Half[(RecHit1.id()).layer() - 1] += RecHit1.energyHigh();
222 else if(((RecHit1.id()).cellType() == 3) && ( ((RecHit1.id()).iu() == 4 && (RecHit1.id()).iv() == 3) || ((RecHit1.id()).iu() == -7 && (RecHit1.id()).iv() == 4) || ((RecHit1.id()).iu() == 7 && (RecHit1.id()).iv() == -3) || ((RecHit1.id()).iu() == -4 && (RecHit1.id()).iv() == -3) )){
224 Cell_counter_MB[(RecHit1.id()).layer() - 1]++;
225 Average_Pedestal_Per_Event_MB[(RecHit1.id()).layer() - 1] += RecHit1.energyHigh();
227 else if(((RecHit1.id()).cellType() == 3) && (((RecHit1.id()).iu() == -4 && (RecHit1.id()).iv() == 6) || ((RecHit1.id()).iu() == -2 && (RecHit1.id()).iv() == 6) || ((RecHit1.id()).iu() == 4 && (RecHit1.id()).iv() == -7) || ((RecHit1.id()).iu() == 2 && (RecHit1.id()).iv() == -6))){
229 Cell_counter_Merged_Cell[(RecHit1.id()).layer() - 1]++;
230 Average_Pedestal_Per_Event_Merged_Cell[(RecHit1.id()).layer() - 1] += RecHit1.energyHigh();
232 else if((RecHit1.id()).cellType() == 1){
234 Cell_counter_Calib_Pad[(RecHit1.id()).layer() - 1]++;
235 Average_Pedestal_Per_Event_Calib_Pad[(RecHit1.id()).layer() - 1] += RecHit1.energyHigh();
241 for(
int iii = 0; iii <
MAXLAYERS; iii++){
242 if(Cell_counter[iii] != 0) Full_Cell[iii]->Fill(Average_Pedestal_Per_Event_Full[iii]/Cell_counter[iii]);
243 if(Cell_counter_Half[iii] != 0) Half_Cell[iii]->Fill(Average_Pedestal_Per_Event_Half[iii]/Cell_counter_Half[iii]);
244 if(Cell_counter_MB[iii] != 0) MB_Cell[iii]->Fill(Average_Pedestal_Per_Event_MB[iii]/Cell_counter_MB[iii]);
245 if(Cell_counter_Merged_Cell[iii] != 0) Merged_Cell[iii]->Fill(Average_Pedestal_Per_Event_Merged_Cell[iii]/Cell_counter_Merged_Cell[iii]);
246 if(Cell_counter_Calib_Pad[iii] != 0) Calib_Pads[iii]->Fill(Average_Pedestal_Per_Event_Calib_Pad[iii]/Cell_counter_Calib_Pad[iii]);
250 for(
auto RecHit : *Rechits) {
252 if(!IsCellValid.iu_iv_valid((RecHit.id()).layer(), (RecHit.id()).sensorIU(), (RecHit.id()).sensorIV(), (RecHit.id()).iu(), (RecHit.id()).iv(), sensorsize))
continue;
253 CellCentreXY = TheCell.GetCellCentreCoordinatesForPlots((RecHit.id()).layer(), (RecHit.id()).sensorIU(), (RecHit.id()).sensorIV(), (RecHit.id()).iu(), (RecHit.id()).iv(), sensorsize);
256 uint32_t EID = essource_.emap_.detId2eid(RecHit.id());
260 h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh());
261 Noise_2D_Profile->Fill((64*(eid.iskiroc()-1) + eid.ichan()),RecHit.energyHigh());
264 AllCells_Ped->Fill(RecHit.energyHigh());
266 if((RecHit.id()).cellType() == 0 || (RecHit.id()).cellType() == 4) h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh() - (Average_Pedestal_Per_Event_Full[(RecHit.id()).layer() - 1]/(Cell_counter[(RecHit.id()).layer() -1])));
267 else if((RecHit.id()).cellType() == 2 ) h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh() - (Average_Pedestal_Per_Event_Half[(RecHit.id()).layer() -1]/(Cell_counter_Half[(RecHit.id()).layer() -1])));
268 else if((RecHit.id()).cellType() == 1) h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh() - (Average_Pedestal_Per_Event_Calib_Pad[(RecHit.id()).layer() - 1]/(Cell_counter_Calib_Pad[(RecHit.id()).layer() -1])));
269 else if(((RecHit.id()).cellType() == 3) && ( ((RecHit.id()).iu() == 4 && (RecHit.id()).iv() == 3) || ((RecHit.id()).iu() == -7 && (RecHit.id()).iv() == 4) || ((RecHit.id()).iu() == 7 && (RecHit.id()).iv() == -3) || ((RecHit.id()).iu() == -4 && (RecHit.id()).iv() == -3) ) ){
270 h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh() - (Average_Pedestal_Per_Event_MB[(RecHit.id()).layer() -1]/(Cell_counter_MB[(RecHit.id()).layer() -1])));
272 else if(((RecHit.id()).cellType() == 3) && (((RecHit.id()).iu() == -4 && (RecHit.id()).iv() == 6) || ((RecHit.id()).iu() == -2 && (RecHit.id()).iv() == 6) || ((RecHit.id()).iu() == 4 && (RecHit.id()).iv() == -7) || ((RecHit.id()).iu() == 2 && (RecHit.id()).iv() == -6))){
273 h_digi_layer_channel[eid.iskiroc()-1][eid.ichan()][(RecHit.id()).layer() -1]->Fill(RecHit.energyHigh() - (Average_Pedestal_Per_Event_Merged_Cell[(RecHit.id()).layer() -1]/(Cell_counter_Merged_Cell[(RecHit.id()).layer() -1])));
275 Noise_2D_Profile->Fill((64*(eid.iskiroc()-1) + eid.ichan()),RecHit.energyHigh() - (Average_Pedestal_Per_Event_Full[(RecHit.id()).layer() -1]/(Cell_counter[(RecHit.id()).layer() -1])));
287 RecHitPlotter_HighGain_Correlation_CM::beginJob()
290 edm::FileInPath fip(mapfile_);
291 if (!io.load(fip.fullPath(), essource_.emap_)) {
292 throw cms::Exception(
"Unable to load electronics map");
298 RecHitPlotter_HighGain_Correlation_CM::endJob()
305 RecHitPlotter_HighGain_Correlation_CM::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
309 edm::ParameterSetDescription desc;
311 descriptions.addDefault(desc);
DEFINE_FWK_MODULE(Pedestals)
edm::Service< TFileService > fs
provides the conversion between electronics Id to DetId
double return_RMS_CM(double mean_sq, double mean)