| 1 | void fact_trigger()
|
|---|
| 2 | {
|
|---|
| 3 | MLut lut;
|
|---|
| 4 |
|
|---|
| 5 | // read all trigger patches
|
|---|
| 6 | lut.ReadFile("resmc/fact-trigger-all.txt");
|
|---|
| 7 | // read only the regular trigger patches
|
|---|
| 8 | //lut.ReadFile("resmc/fact-trigger-sum.txt");
|
|---|
| 9 |
|
|---|
| 10 | // For crosscheck print the table to the console
|
|---|
| 11 | lut.Print();
|
|---|
| 12 |
|
|---|
| 13 | // Create FACT camera geometry
|
|---|
| 14 | MGeomCamFACT fact;
|
|---|
| 15 |
|
|---|
| 16 | // create to camera histograms, one for the colors and one for the patch number
|
|---|
| 17 | MHCamera h(fact);
|
|---|
| 18 | MHCamera p(fact);
|
|---|
| 19 | h.SetTitle("FACT trigger layout in MARS");
|
|---|
| 20 |
|
|---|
| 21 | // remove all obsolete stuff around
|
|---|
| 22 | h.SetStats(kFALSE);
|
|---|
| 23 | h.SetBit(MHCamera::kNoLegend);
|
|---|
| 24 |
|
|---|
| 25 | // Number of maximum colors
|
|---|
| 26 | Int_t n = 99;
|
|---|
| 27 |
|
|---|
| 28 | for (int i=0; i<lut.GetNumRows(); i++)
|
|---|
| 29 | {
|
|---|
| 30 | // Get the i-th patch
|
|---|
| 31 | MArrayI &row = lut.GetRow(i);
|
|---|
| 32 |
|
|---|
| 33 | // Check for all colors already used in the neighborhood
|
|---|
| 34 | MArrayI col(n+1);
|
|---|
| 35 | for (int j=0; j<9; j++)
|
|---|
| 36 | {
|
|---|
| 37 | if (row[j]==1438 || row[j]==1439)
|
|---|
| 38 | continue;
|
|---|
| 39 |
|
|---|
| 40 | for (int k=0; k<fact[row[j]].GetNumNeighbors(); k++)
|
|---|
| 41 | col[TMath::Nint(h.GetBinContent(fact[row[j]].GetNeighbor(k)+1))]=1;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | // Find the first unused color
|
|---|
| 45 | int k = 1;
|
|---|
| 46 | for (; k<n+1; k++)
|
|---|
| 47 | if (col[k]<0.5)
|
|---|
| 48 | break;
|
|---|
| 49 |
|
|---|
| 50 | // This is just to "adjust" the colors a bit more to the palette
|
|---|
| 51 | // For simplicity (rounding below) the adjustment must not exceed +- 0.5
|
|---|
| 52 | // If the number of needed colors is different this needs adjustment!
|
|---|
| 53 | Double_t c[99] = { 1.0, 2.4, 3.4, 4.1, 5.0 };
|
|---|
| 54 |
|
|---|
| 55 | // Loop over all nine pixles in the patch
|
|---|
| 56 | for (int j=0; j<9; j++)
|
|---|
| 57 | {
|
|---|
| 58 | if (row[j]==1438 || row[j]==1439)
|
|---|
| 59 | continue;
|
|---|
| 60 |
|
|---|
| 61 | h.SetBinContent(row[j]+1, c[k-1]); // Color (For a funny symmetry replace it by row[0]%6)
|
|---|
| 62 | p.SetBinContent(row[j]+1, i); // Patch number
|
|---|
| 63 | h.SetUsed(row[j]); // Switch on that the color is shown
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // Plot the colors and the numbers on top
|
|---|
| 68 | h.DrawCopy("");
|
|---|
| 69 | p.DrawCopy("same integer");
|
|---|
| 70 |
|
|---|
| 71 | // Adjust the canvas attributes
|
|---|
| 72 | gPad->SetBorderMode(0);
|
|---|
| 73 | gPad->SetFillColor(kWhite);
|
|---|
| 74 | }
|
|---|