22 #include "TIterator.h"
26 #include "HGCal/CondObjects/interface/HGCalElectronicsMap.h"
27 #include "HGCal/CondObjects/interface/HGCalCondObjectTextIO.h"
28 #include "HGCal/DataFormats/interface/SKIROCParameters.h"
29 #include "HGCal/DataFormats/interface/HGCalTBElectronicsId.h"
30 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
31 #include "HGCal/Geometry/interface/HGCalTBCellParameters.h"
32 #include "HGCal/Geometry/interface/HGCalTBCellVertices.h"
33 #include "HGCal/Geometry/interface/HGCalTBTopology.h"
34 #include "HGCal/TBStandaloneSimulator/interface/HGCSSGeometryConversion.hh"
43 double CELL_SIDE = 10 * HGCAL_TB_CELL::FULL_CELL_SIDE;
45 double SENSOR_SIDE = NCELL * CELL_SIDE;
46 double WIDTH = 2 * SENSOR_SIDE;
56 int main(
int argc,
char **argv)
59 string electronicsmapfile(
"map_FNAL_1234.txt");
61 electronicsmapfile = string(argv[1]);
64 <<
"=> Using (u, v) to (skiroc, channel) map file "
66 <<
" HGCal/CondObjects/data/"
74 sprintf(mfile,
"$CMSSW_BASE/src/HGCal/CondObjects/data/%s",
75 electronicsmapfile.c_str());
76 sprintf(mfile,
"%s", gSystem->ExpandPathName(mfile));
77 ifstream mapin(mfile);
78 if ( ! mapin.good() ) {
79 cout <<
"*** cannot open file " << mfile << endl;
85 int skiroc, channel, layer, sensor_u, sensor_v, u, v, celltype;
86 map<int, map<pair<int, int>, Cell> > layer2uv2eid;
90 >> skiroc >> channel >> layer
91 >> sensor_u >> sensor_v
96 cell.channel = channel;
97 cell.sensor_u = sensor_u;
98 cell.sensor_v = sensor_v;
99 cell.celltype = celltype;
100 pair<int, int> uv(u, v);
102 if ( layer2uv2eid.find(layer) == layer2uv2eid.end() )
103 layer2uv2eid[layer] = map<pair<int, int>, Cell>();
104 layer2uv2eid[layer][uv] = cell;
106 if ( layer != lastlayer ) layers.push_back(layer);
115 HGCSSGeometryConversion geom(MODEL, WIDTH, CELL_SIDE);
116 geom.initialiseHoneyComb(WIDTH, CELL_SIDE);
117 TH2Poly* map = geom.hexagonMap();
125 hsensor.SetName(
"hsensor");
126 hsensor.SetTitle(
"sensor");
130 double S = 0.98 * SENSOR_SIDE;
131 double H = S * sqrt(3) / 2;
147 hsensor.AddBin(7, x, y);
151 TIter it(hsensor.GetBins());
152 TH2PolyBin* sensor = (TH2PolyBin*)it();
158 gStyle->SetPalette(1);
159 gStyle->SetOptStat(
"");
161 TCanvas csensor(
"sensor_cellids",
"cellid", 600, 600);
162 map->GetXaxis()->CenterTitle();
163 map->GetXaxis()->SetTitle(
"#font[12]{x} axis");
164 map->GetYaxis()->CenterTitle();
165 map->GetYaxis()->SetTitle(
"#font[12]{y} axis");
169 hsensortrue.SetName(
"hsensortrue");
186 hsensortrue.AddBin(7, x, y);
187 hsensortrue.SetMinimum(0.0);
188 hsensortrue.SetMaximum(1.0);
189 hsensortrue.SetBinContent(1, 0.7);
193 hsensortrue.Draw(
"col same");
197 TCanvas cuv(
"sensor_u_v",
"u, v", 600, 600);
198 hsensortrue.SetBinContent(1, 0.0);
200 hsensortrue.SetBinContent(1, 0.7);
204 hsensortrue.Draw(
"col same");
211 ofstream sout(
"sensor_map.txt");
213 "%5s %5s %5s %5s %5s %5s %5s "
216 "layer",
"posid",
"cid",
"s_u",
"s_v",
"u",
"v",
217 "ski",
"chan",
"ctype",
219 cout << record << endl;
220 sout << record << endl;
222 TList* bins = map->GetBins();
224 text.SetTextSize(0.02);
225 text.SetTextAlign(22);
233 for(
size_t c = 0; c < layers.size(); c++) {
235 int layer = layers[c];
238 bool new_column =
true;
239 bool odd_column =
true;
246 while ( TH2PolyBin* bin = (TH2PolyBin*)next() ) {
254 int binnumber = bin->GetBinNumber();
255 new_column = binnumber == number;
261 if ( colnumber % 2 == 1 ) u_start++;
272 odd_column = !odd_column;
279 pair<int, int> uv(u, v);
280 Cell cell = layer2uv2eid[layer][uv];
288 pair<double, double> pos
294 double x = pos.first;
295 double y = pos.second;
302 if ( ! sensor->IsInside(x, y) ) {
310 }
else if ( v < -3 ) {
326 sprintf(record,
"%d", binnumber);
327 text.DrawText(x, y, record);
329 sprintf(record,
"%d,%d", u, v);
330 text.DrawText(x, y, record);
333 "%5d %5d %5d %5d %5d %5d %5d "
336 layer, posid, binnumber,
337 cell.sensor_u, cell.sensor_v,
339 cell.skiroc, cell.channel, cell.celltype,
341 cout << record << endl;
342 sout << record << endl;
347 map->SetTitle(
"TB2016 Standalone Simulator Cell IDs");
349 csensor.SaveAs(
".png");
351 map->SetTitle(
"TB2016 Sensor (u,v) Coordinates");
std::pair< double, double > GetCellCentreCoordinates(int layer, int sensor_iu, int sensor_iv, int iu, int iv, int sensorsize, bool flipX=false)
returns the coordinates of each vertex of cell in the lab frame (x,y)
bool iu_iv_valid(int layer, int sensor_iu, int sensor_iv, int iu, int iv, int sensorSize) const
int main(int argc, char *argv[])