Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: release_13_0_10 ] [ release_13_0_30 ] [ release_13_0_40 ] [ release_13_1_0 ]

001 package atlantis.graphics;
002 
003 import java.awt.Color;
004 import java.awt.geom.*;
005 
006 import atlantis.canvas.AWindow;
007 import atlantis.event.AEvent;
008 import atlantis.event.ALVL1ResultData;
009 import atlantis.parameters.AEnumeratorParameter;
010 import atlantis.parameters.APar;
011 import atlantis.projection.AProjectionLegoPlot;
012 import atlantis.utils.AMath;
013 
014 public class ALegoDraw
015 {
016     static int legendHeight=0;
017     static int lineHeight = 17;//seperation of lines
018     //colors to use in legend
019     static Color textColor=Color.black, 
020         backgroundColor=AProjectionLegoPlot.defaultColorMap[APar.get("LegoPlot", "Fill").getI()],
021         borderColor=Color.lightGray;
022 
023     public static void fillBackground(AWindow window, AGraphics ag)
024     {
025         ag.setColor(AProjectionLegoPlot.defaultColorMap[APar.get("LegoPlot", "Fill").getI()]);
026         ag.fillRect(0, 0, window.getWidth(), window.getHeight());
027     }
028 
029     public static void drawLegend(AWindow window, AGraphics ag, AEvent event, double met, double maxEt, double AODmaxEt)
030     {
031         //colors to use
032         textColor=Color.black;
033         backgroundColor=AProjectionLegoPlot.defaultColorMap[APar.get("LegoPlot", "Fill").getI()];
034         if(backgroundColor.getBlue()+backgroundColor.getGreen()+backgroundColor.getRed() < 150)
035             textColor=Color.white;
036         //change the font size (reset at end)
037         float originalFontSize= ag.g.getFont().getSize2D();
038         float newFontSize= (float) 0.9*originalFontSize;
039         ag.g.setFont(ag.g.getFont().deriveFont(newFontSize));
040         //variables to locate where to write/draw
041         legendHeight = lineHeight+2;//distance from top of legend
042         int indent = window.getWidth()- 200;//distance from left of legend
043         int pos = 90;//distance to start writing second half of line
044         ALVL1ResultData lvl1ResultData = event.getLvl1ResultData();
045         
046         //draw main legend
047         if(APar.get("LegoPlot", "Main").getStatus())
048             drawLegendMain(window, ag, event, met, maxEt, AODmaxEt, lvl1ResultData, indent, pos);
049         if (lvl1ResultData != null) 
050         {
051             //draw lvl1 sumEt and missEt
052             if(APar.get("LegoPlot", "L1Et").getStatus())
053                 drawLegendL1ET(ag, lvl1ResultData, indent);
054             //draw the item list
055             if(APar.get("LegoPlot", "Items").getStatus())
056                 drawLegendItems(window, ag, lvl1ResultData);
057         }
058         //reset font size
059         ag.g.setFont(ag.g.getFont().deriveFont(originalFontSize));
060     }
061 
062     public static void drawLegendMain(AWindow window, AGraphics ag, AEvent event, double met, double maxEt, double AODmaxEt, ALVL1ResultData lvl1ResultData, int indent, int pos)
063     {
064         // create legend boarder with two concentric rectangles
065         // outer rectangle:
066         ag.setColor(borderColor);
067         ag.fillRect(indent - 4, 5, 200, 105);
068         // inner rectangle:
069         ag.setColor(backgroundColor);
070         ag.fillRect(indent - 4 + 2, 7, 200 - 4, 105 - 4);
071         ag.setColor(textColor);
072         ag.updateColor();
073 
074         //First item Missing ET  (may remove met box from plot later)
075         if(met!=0)
076             drawLegendPartMain1(ag, met, indent, pos);
077         else
078             ag.drawString("No Missing Et", indent + 6, legendHeight);
079         legendHeight += lineHeight;
080         ag.setColor(textColor);
081         ag.updateColor();
082         
083         //Second item colourby
084         if(maxEt!=0)
085             drawLegendMain2(ag, indent, pos);
086         else
087         {
088             ag.setColor(textColor);
089             ag.updateColor();
090             ag.drawString("No cells", indent + 6, legendHeight);
091         }
092         legendHeight += lineHeight;
093         ag.setColor(textColor);
094         ag.updateColor();
095         
096         //Third item maximum height of towers
097         if(maxEt!=0 || AODmaxEt!=0)
098             drawLegendMain3(ag, maxEt, AODmaxEt, indent, pos);
099         else
100         {
101             ag.drawString("No towers", indent + 6, legendHeight);
102             legendHeight += lineHeight;
103         }
104         legendHeight += lineHeight;
105         ag.setColor(textColor);
106         ag.updateColor();
107         
108         //Fourth item lvl1 result
109         if (lvl1ResultData == null)
110             ag.drawString("Trigger Decision N/A", indent+6, legendHeight);
111         else
112             drawLegendMain4(ag, lvl1ResultData, indent, pos);
113         legendHeight+=lineHeight;
114         ag.setColor(textColor);
115         ag.updateColor();
116     }
117 
118     public static void drawLegendPartMain1(AGraphics ag, double met, int indent, int pos)
119     {
120         ag.setColor(AProjectionLegoPlot.defaultColorMap[APar.get("ETMis", "Constant").getI()]);
121         //draw dashed line
122         ag.fillRect(indent + 6, 11, 5, 3); 
123         ag.fillRect(indent + 6 + 10, 11, 5, 3);
124         ag.fillRect(indent + 6 + 20, 11, 5, 3);
125         ag.fillRect(indent + 6 + 30, 11, 5, 3);
126         ag.setColor(textColor);
127         ag.updateColor();
128         ag.drawString("Max Missing ET= " + Math.round(met) + " GeV" , indent + 0.6*pos, legendHeight);
129     }
130 
131     public static void drawLegendMain2(AGraphics ag, int indent, int pos)
132     {
133         String modeName;
134         if (AProjectionLegoPlot.mode == 0)
135         {
136             modeName="LAr";
137         }
138         else if (AProjectionLegoPlot.mode == 1)
139         {
140             modeName="LVL1TriggerTower";
141         }
142         else
143         {
144             modeName="LVL1JetElement";
145         }
146         AEnumeratorParameter param = (AEnumeratorParameter) APar.get(modeName, "ColorFunction");
147         String colorFunction = param.getText(param.getI());
148         {
149             ag.drawString(colorFunction + " (1-" + AProjectionLegoPlot.colorset.size() + ")",indent + pos, legendHeight);
150         }
151         int barwidth = 6, barheight = 6;
152         if(AProjectionLegoPlot.getDrawEMHAD())
153         {
154             if(AProjectionLegoPlot.colorset.size()==2)
155             {
156                 //for Em/had option should only have 2 colors
157                 ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorEM]);
158                 ag.fillRect(indent + barwidth * 2, 28, barwidth * 2, barheight);
159                 ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorHad]);
160                 ag.fillRect(indent + 2 * barwidth* 2, 28, barwidth * 2, barheight);
161             }
162             else
163             {
164                 //if more colors then lists must be in use
165                 int c = 0;
166                 ++c;
167                 ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorEM]);
168                 ag.fillRect(indent + c * barwidth, 28, barwidth, barheight);
169                 ++c;
170                 ag.setColor(AProjectionLegoPlot.defaultColorMap[AProjectionLegoPlot.colorHad]);
171                 ag.fillRect(indent + c * barwidth, 28, barwidth, barheight);
172                 for (int i = 0; i <AProjectionLegoPlot.caloColorMap.length ; i++)
173                 {
174                     if (!AProjectionLegoPlot.colorset.contains(new Integer(i)))
175                         continue;
176                     if(i==AProjectionLegoPlot.colorEM || i==AProjectionLegoPlot.colorHad)
177                         continue;
178                     ++c;
179                     ag.setColor(AProjectionLegoPlot.caloColorMap[i]);
180                     ag.fillRect(indent + c * barwidth, 28, barwidth, barheight);
181                 }
182             }
183         }
184         else
185         {
186             //if not Em/Had then loop over colors
187             int c = 0;
188             for (int i = 0; i <AProjectionLegoPlot.caloColorMap.length ; i++)
189             {
190                 if (!AProjectionLegoPlot.colorset.contains(new Integer(i)))
191                     continue;
192                 ++c;
193                 ag.setColor(AProjectionLegoPlot.caloColorMap[i]);
194                 ag.fillRect(indent + c * barwidth, 28, barwidth, barheight);
195             }
196         }
197     }
198     
199     public static void drawLegendMain3(AGraphics ag, double maxEt, double AODmaxEt, int indent, int pos)
200     {
201         ag.drawString( "Height of tallest tower:", indent + 6, legendHeight);
202         //next line has the values
203         legendHeight += lineHeight;
204         if (APar.get("LegoPlot", "ETAxisHeight").getD() > 0.0)
205             ag.drawString("User selection: " + Math.round(maxEt) + " GeV ", indent +6, legendHeight);
206         else
207         {
208             if(maxEt!=0)
209             {
210                     ag.drawString("Cells: " + Math.round(maxEt) + " GeV ", indent +6, legendHeight);
211                     if(AODmaxEt!=0)
212                         ag.drawString("AOD: " + Math.round(AODmaxEt) + " GeV ", indent + pos, legendHeight);
213             }
214             else
215                 ag.drawString("AOD: " + Math.round(AODmaxEt) + " GeV ", indent + 6, legendHeight);
216         }   
217     }
218     
219     public static void drawLegendMain4(AGraphics ag, ALVL1ResultData lvl1ResultData, int indent, int pos)
220     {
221         ag.drawString("Trigger Decision:", indent +6, legendHeight);
222         legendHeight+=lineHeight;
223         String[] trigRes={"NA","NA","NA"};
224         int[] temp=new int[3];
225         temp[0]=lvl1ResultData.getPassedL1(0);
226         temp[1]=lvl1ResultData.getPassedL2(0);
227         temp[2]=lvl1ResultData.getPassedEF(0);
228         for(int i=0;i<3;i++)
229         {
230             switch(temp[i])
231             {
232                 case -1:
233                     trigRes[i]="N/C";
234                     break;
235                 case 0:
236                     trigRes[i]="failed";
237                     break;
238                 case 1:
239                     trigRes[i]="passed";
240                     break;
241                 default:
242                     trigRes[i]="NA";
243             }
244         }
245         ag.drawString("L1:" + trigRes[0] +" L2:" + trigRes[1]+" EF:" + trigRes[2], indent +6, legendHeight);
246     }
247     
248     public static void drawLegendL1ET(AGraphics ag, ALVL1ResultData lvl1ResultData, int indent)
249     {
250         // create legend boarder with two concentric rectangles
251         // outer rectangle:
252         ag.setColor(borderColor);
253         ag.fillRect(indent - 4, legendHeight, 200, (int) (lineHeight*1.5));
254         // inner rectangle:
255         ag.setColor(backgroundColor);
256         ag.fillRect(indent - 4 + 2, legendHeight + 2, 200 - 4, (int) (lineHeight*1.5 - 4));
257         float LVL1EtMiss=lvl1ResultData.getEnergyEtMiss(0);
258         float LVL1SumEt=lvl1ResultData.getEnergySumEt(0);            
259         ag.setColor(textColor);
260         ag.updateColor();
261         legendHeight+=lineHeight; 
262         ag.drawString("L1-EtMiss: "+LVL1EtMiss+" L1-SumEt: "+LVL1SumEt, indent , legendHeight);
263         legendHeight+=lineHeight;
264     }
265     
266     public static void drawLegendItems(AWindow window, AGraphics ag, ALVL1ResultData lvl1ResultData)
267     {
268         int origlineHeight =lineHeight;//save lineheight to be reset at end of function
269         lineHeight*=0.8;//for item list bunch together
270         //Output of items in one column in new legend box
271         String[][] items=new String[3][];
272         items[0]=lvl1ResultData.getCtpItemListSplit(0,true);
273         items[1]=lvl1ResultData.getitemListL2Split(0,true);
274         items[2]=lvl1ResultData.getitemListEFSplit(0,true);
275         String[] levels={"L1","L2","EF"};
276         
277         int noOfItems=3;//for titles
278         int noOfColumns=0;
279         int columnWidth= 70;
280         int[] toAddOn=new int[3];
281         int toAddOnMax=0;
282         int maxItems=(int) Math.round(((0.8*window.getHeight()-legendHeight)/lineHeight )-0.5);
283         int maxColumns=(int) Math.floor(((0.9*window.getWidth())/(3*columnWidth)))*3;
284         for(int a=0; a<3; a++)
285         {
286             if(items[a]!=null)
287             {
288                 toAddOn[a]=items[a].length;//adds on row for each item
289                 if(toAddOn[a]>toAddOnMax)//finds max amount of items
290                     toAddOnMax=toAddOn[a];
291             }
292             else
293                 toAddOn[0]++;//adds on row for N/A
294         }
295         //sort out number of columns and how many rows
296         if(toAddOn[0]+toAddOn[1]+toAddOn[2]<maxItems)
297         {
298             noOfColumns=1;
299             noOfItems+=toAddOn[0]+toAddOn[1]+toAddOn[2];
300         }
301         else
302         {
303             for(int a=0; a<3; a++)
304             {
305                 int columns = (int)((toAddOn[a]-0.5)/maxItems);
306                 if(columns>=maxColumns/3)
307                     noOfColumns+=maxColumns/3;
308                 else
309                     noOfColumns+=1+columns;
310             }
311             if(toAddOnMax<maxItems+1)
312                 noOfItems=1+toAddOnMax;
313             else
314                 noOfItems=maxItems+1;
315         }
316         int columnNumber =noOfColumns+1;//starts by taking off a column
317         int startrowHeight =legendHeight;
318         int rowNumber=0;
319         
320         // makes outer and inner borders of table:
321         ag.setColor(borderColor);
322         ag.fillRect(window.getWidth() -noOfColumns*columnWidth - 4, legendHeight, (int)(noOfColumns*columnWidth), (int) Math.round((noOfItems+0.5)*lineHeight));
323         
324         for(int a=0; a<3; a++)
325         {
326             if(a==0 || noOfColumns>1)
327             {
328                 //draw column to draw onto
329                 columnNumber--;
330                 legendHeight=startrowHeight;
331                 ag.setColor(backgroundColor);
332                 ag.updateColor();
333                 ag.fillRect(window.getWidth() -columnNumber*columnWidth - 4 + 2, legendHeight + 2, columnWidth - 4, (int) Math.round((noOfItems+0.5)*lineHeight)-4);
334                 ag.setColor(textColor);
335                 ag.updateColor();
336                 legendHeight+=lineHeight;
337             }
338             //write item list title and items
339             rowNumber=1;
340             int columnCount=1;
341             ag.drawString(levels[a] +" items:", window.getWidth() - columnNumber*columnWidth -2, legendHeight);
342             if(items[a]!=null)
343             {
344                 for(int i=0; i<items[a].length;i++)
345                 {
346                     if(rowNumber>maxItems)
347                     {
348                         columnCount++;
349                         if(columnCount>maxColumns/3)
350                         {
351                             //draw under columns
352                             ag.setColor(borderColor);
353                             ag.updateColor();
354                             ag.fillRect(window.getWidth() -columnNumber*columnWidth - 4, legendHeight+4, columnWidth, (int) Math.round(2.5*lineHeight));
355                             ag.setColor(backgroundColor);
356                             ag.updateColor();
357                             ag.fillRect(window.getWidth() -columnNumber*columnWidth - 4 + 2, legendHeight +4+ 2, columnWidth - 4, (int) Math.round(2.5*lineHeight)-4);
358                             ag.setColor(textColor);
359                             ag.updateColor();
360                             legendHeight+=lineHeight;
361                             ag.drawString("more items", window.getWidth() - columnNumber*columnWidth + 2, legendHeight+4);
362                             legendHeight+=lineHeight;
363                             ag.drawString("in list", window.getWidth() - columnNumber*columnWidth + 2, legendHeight+4);
364                             break;
365                         }
366                         else
367                             columnNumber--;
368                         rowNumber=1;
369                         legendHeight=startrowHeight;
370                         ag.setColor(backgroundColor);
371                         ag.updateColor();
372                         ag.fillRect(window.getWidth() -columnNumber*columnWidth - 4 + 2, legendHeight + 2, columnWidth - 4, (int) Math.round((noOfItems+0.5)*lineHeight)-4);
373                         ag.setColor(textColor);
374                         ag.updateColor();
375                         legendHeight+=lineHeight;
376                     }
377                     legendHeight+=lineHeight;   
378                     ag.drawString(items[a][i], window.getWidth() - columnNumber*columnWidth + 2, legendHeight);
379                     rowNumber++;
380                 }
381             }
382             else
383             {
384                 legendHeight+=lineHeight;
385                 ag.drawString("N/A", window.getWidth() - columnNumber*columnWidth + 2, legendHeight);
386             }
387             legendHeight+=lineHeight;
388         }
389         lineHeight=origlineHeight;//reset line height
390     }
391     
392     static void drawline(AWindow window, AGraphics ag, Point2D.Double from, Point2D.Double to)
393     {
394         from=window.calculateDisplay(from);
395         to=window.calculateDisplay(to);
396         ag.drawLine( from.x,from.y,to.x,to.y);
397     }
398     
399     static void drawline(AWindow window, AGraphics ag, double fromX, double fromY, double toX, double toY)
400     {
401         Point2D.Double from= new Point2D.Double(fromX,fromY);
402         Point2D.Double to= new Point2D.Double(toX,toY);
403         drawline(window, ag, from, to);
404     }
405 
406     //converts from energy into eta coords
407     static void drawline(AWindow window, AGraphics ag, double fromX, double fromY, double toX, double toY, int etAxisMaximum)
408     {
409         fromY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(fromY/etAxisMaximum)*0.9;
410         toY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(toY/etAxisMaximum)*0.9;
411         Point2D.Double from= new Point2D.Double(fromX,fromY);
412         Point2D.Double to= new Point2D.Double(toX,toY);
413         drawline(window, ag, from, to);
414     }
415     
416     static void drawstring(AWindow window, AGraphics ag, String str, double hereX, double hereY)
417     {
418         Point2D.Double here= new Point2D.Double(hereX,hereY);
419         here=window.calculateDisplay(here);
420         ag.drawString(str, here.x,here.y);
421     }
422     
423     //converts from energy into eta coords
424     static void drawstring(AWindow window, AGraphics ag, String str, double hereX, double hereY, int etAxisMaximum)
425     {
426         hereY=-5-(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(hereY/etAxisMaximum)*0.9;  
427         Point2D.Double here= new Point2D.Double(hereX,hereY);
428         here=window.calculateDisplay(here);
429         ag.drawString(str, here.x,here.y);
430     }
431 
432     public static void drawGrid(AWindow window, AGraphics ag, double maxEt)
433     {
434         // Draw the scale and labels on Et axis
435         ag.setColor(Color.lightGray);
436         ag.updateColor();
437         ag.setLineWidth(2);
438         int etAxisMaximum=(int) maxEt;//convert to int for use later on
439         int etAxisScale = 10;//seperation of ticks in ET
440         if (AProjectionLegoPlot.defaultScale ==1 )
441         {
442             etAxisScale=1;
443         }
444         else if (maxEt > 10.0)
445         {
446             //set scale to 0.1 of nearest hundred to maximum
447             etAxisScale = 10 * ((int) Math.ceil(maxEt / 100.0));
448         }
449         else if (maxEt == 10.0)
450         {
451             etAxisScale = 5;
452         }
453         else if (maxEt < 10.0)
454         {
455             etAxisScale = 2;
456         }
457         double lowPhi=-360*AProjectionLegoPlot.getxz(window.getIndex());
458         int ticksizex = 10;
459         double ticksizey = 0.5;
460 
461         //Draw Et axis
462         drawline(window,ag,lowPhi,0.0,lowPhi,etAxisMaximum, etAxisMaximum);
463         //Draw the ticks
464         for(int s = etAxisMaximum-etAxisScale; s >= 0.0; s-=etAxisScale)
465         {
466             drawline(window,ag,lowPhi, s,lowPhi + ticksizex,s, etAxisMaximum);
467             if (AProjectionLegoPlot.defaultScale ==1 )
468                 drawstring(window,ag,"10^" + Integer.toString( s + AProjectionLegoPlot.minimumofLogScale ),lowPhi + 2*ticksizex,s,etAxisMaximum);
469             else
470                 drawstring(window,ag,Integer.toString( s ),lowPhi + 2*ticksizex,s,etAxisMaximum);
471         }
472         // Draw the title on Et axis
473         drawline(window,ag,lowPhi, etAxisMaximum,lowPhi + ticksizex,etAxisMaximum, etAxisMaximum);
474         if (AProjectionLegoPlot.defaultScale ==1)
475             drawstring(window,ag,"10^" + Integer.toString( etAxisMaximum + AProjectionLegoPlot.minimumofLogScale) + " ET (GeV)",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum);
476         else if(AProjectionLegoPlot.defaultScale ==2)
477             drawstring(window,ag,Integer.toString( etAxisMaximum ) + " ET (GeV)^1/2",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum);
478         else
479             drawstring(window,ag,Integer.toString( etAxisMaximum ) + " ET (GeV)",lowPhi + 2*ticksizex,etAxisMaximum,etAxisMaximum);
480 
481         // Draw a grid
482         int t = -1;
483         for (double p = 0.; p <= 1.; p += 1. / 4.)
484         {
485             // parallel to the right side
486             drawline(window, ag, 360*p+lowPhi, -5.0, 360*p, 5.0);
487             if (++t % 2 == 0)
488             {
489                 // a tick
490                 drawline(window,ag,360*p,5.0,360*p,5.0+ticksizey);
491                 String str = new Integer(((int) (360. * p))).toString();
492                 drawstring(window,ag,str,360*p,5.0+3*ticksizey);
493             }
494         }
495         //Draw the title on phi axis
496         drawstring(window,ag,AMath.PHI,0.6*360,5.0+5*ticksizey);
497 
498         for (double e = 0.; e <= 1.; e += 1. / 5.)
499         {
500             // parallel to the bottom
501             drawline(window, ag, lowPhi*(1-e), 10.0*e-5.0, 360.0+lowPhi*(1-e), 10.0*e-5.0);
502             // a tick
503             drawline(window, ag, lowPhi*(1-e), 10.0*e-5.0, lowPhi*(1-e), 10.0*e-5.0+ticksizey);
504             String str = new Integer(((int) (10 * e - 5))).toString();
505             if (AProjectionLegoPlot.reverse)
506                 str = new Integer(((int) (5 - 10 * e))).toString();
507             drawstring(window,ag,str,lowPhi*(1-e)-20, 10.0*e-5.0+1.5*ticksizey);
508         }
509         //Draw the title on eta axis
510         drawstring(window,ag,AMath.ETA,0.5*lowPhi-30,+2.5*ticksizey);
511     }
512 
513     public static void drawJet(double et, double eta, double phi, Color color, AWindow window, AGraphics ag, int fill, double radius)
514     {
515         double x = (phi*360)/ AMath.TWO_PI;//x is phi converted from rad to deg
516         int numPoints = 128;//points around circumference of circle
517         double[][] hj = new double[2][numPoints];
518         double[][] vj = new double[2][numPoints];
519         int phiwrap = 0;
520         double old_jetx = -1;
521         int[] pj = new int[2];
522         pj[0] = pj[1] = 0;
523         for (int p = 0; p < numPoints; p++)
524         {
525             //add on fraction of diameter of circle in phi
526             double jetx = x + radius*36 * Math.cos(AMath.TWO_PI * p / (numPoints - 1));
527             if (jetx < 0)
528                 jetx += 360;
529             if(jetx >= 360)
530                 jetx -= 360;
531             if(old_jetx > 0) 
532             {
533                 double jetx_diff = Math.abs(jetx - old_jetx);
534                 if(jetx_diff > 360 / 2)
535                     phiwrap = (phiwrap + 1) % 2;
536             }
537             // remember the last jetx, to see if we've wrapped around next time
538             old_jetx = jetx;
539             double y = eta;
540             if (AProjectionLegoPlot.reverse)
541                 y = -y;
542             //add on fraction of diameter of circle in eta
543             double jety = y + radius * Math.sin(AMath.TWO_PI * p / (numPoints - 1));
544             jetx=AProjectionLegoPlot.adjustPhi(window,jetx,jety);//move phi value due to slant of eta axis
545             Point2D.Double[] corners=window.getUserCorners();
546             if(jetx < corners[0].x || jetx > corners[1].x || jety < corners[1].y || jety > corners[2].y)
547                 continue;//exits loop if not in limits of drawn plot
548             hj[phiwrap][pj[phiwrap]] = jetx;
549             vj[phiwrap][pj[phiwrap]] = jety;
550             ++pj[phiwrap];
551         }
552         ag.setLineWidth(3);
553         ag.setColor(color);
554 
555         Point2D.Double p= new Point2D.Double(0,0);
556         for(int i=0; i<pj[0]; i++)
557         {
558             p = window.calculateDisplay(hj[0][i],vj[0][i]);
559             hj[0][i]=p.x;
560             vj[0][i]=p.y;
561         }
562         p.x=0; p.y=0;
563         for(int i=0; i<pj[1]; i++)
564         {
565             p = window.calculateDisplay(hj[1][i],vj[1][i]);
566             hj[1][i]=p.x;
567             vj[1][i]=p.y;
568         }
569         
570         if (pj[0] > 2)
571         {
572             if (fill > 0)
573                 ag.fillPolygon(hj[0], vj[0], pj[0]);
574             else
575                 ag.drawPolygon(hj[0], vj[0], pj[0]);
576         }
577         if (pj[1] > 2)
578         {
579             if (fill > 0)
580                 ag.fillPolygon(hj[1], vj[1], pj[1]);
581             else
582                 ag.drawPolygon(hj[1], vj[1], pj[1]);
583         }
584     }
585     
586     public static void drawMissEt(AWindow window, AGraphics ag, int phi)
587     {
588         double phibinsize=360.0/AProjectionLegoPlot.nPhiCells;
589         //color
590         ag.setColor(AProjectionLegoPlot.defaultColorMap[APar.get("ETMis", "Constant").getI()]);
591         double[] h = new double[4];
592         double[] v = new double[4];
593         double etaChange = 0.5;
594         for(double etaStart=-5.0; etaStart<5.0; etaStart+=2*etaChange)
595         {
596             v[0] = etaStart;
597             h[0] = AProjectionLegoPlot.adjustPhi(window,phi*phibinsize,v[0]);
598             v[1] = v[0]+etaChange;
599             h[1] = AProjectionLegoPlot.adjustPhi(window,phi*phibinsize,v[1]);
600             v[2] = v[1];
601             h[2] = h[1] + phibinsize;
602             v[3] = v[0];
603             h[3] = h[0] + phibinsize;
604             //convert to window coords
605             Point2D.Double p= new Point2D.Double(0,0);
606             for(int i=0; i<4; i++)
607             {
608                 p = window.calculateDisplay(h[i],v[i]);
609                 h[i]=p.x;
610                 v[i]=p.y;
611             }
612             //draw
613             ag.fillPolygon(h, v, 4);
614         }
615     }
616 
617     public static void drawBox(AWindow window, AGraphics ag, int phi, int eta, int em_had, double et1, double et2, double maxEt)
618     {
619         Color drawingColor;
620         if (em_had == -2)
621             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("Muon", "Constant").getI()];
622         else if (em_had == -3)
623             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("Electron", "Constant").getI()];
624         else if (em_had == -4)
625             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("Photon", "Constant").getI()];
626         else if (em_had == -5)
627             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("Cluster", "Constant").getI()];
628         else if (em_had == -6)
629             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("CompositeParticle", "Constant").getI()];
630         else if (em_had == -7)
631             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("BJet", "Constant").getI()];
632         else if (em_had == -8)
633             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("TauJet", "Constant").getI()];
634         else if (em_had == -9)
635             drawingColor=AProjectionLegoPlot.defaultColorMap[APar.get("Jet", "Constant").getI()];
636         else 
637         {
638             drawingColor=AProjectionLegoPlot.caloColorMap[em_had];
639         }
640         double phibinsize=360.0/AProjectionLegoPlot.nPhiCells;
641         double etabinsize=10.0/AProjectionLegoPlot.nEtaCells;
642         double y = eta*etabinsize-5;//y is real eta position
643         double x1 = AProjectionLegoPlot.adjustPhi(window,(phi*phibinsize), y);//x1 is real phi position
644         double x2 = AProjectionLegoPlot.adjustPhi(window,(phi*phibinsize),(y-etabinsize));//shifted x due to eta bin size
645         double[][] h = new double[3][4];
646         double[][] v = new double[3][4];
647         //adjust the values of the energies
648         et1=(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et1/maxEt)*0.9;
649         et2=et1+(1-AProjectionLegoPlot.getyz(window.getIndex()))*50*(et2/maxEt)*0.9;
650         //front
651         h[0][0] = x1;
652         v[0][0] = y-et1;
653         h[0][1] = x1;
654         v[0][1] = y-et2;
655         h[0][2] = x1 + phibinsize;
656         v[0][2] = y-et2;
657         h[0][3] = x1 + phibinsize;
658         v[0][3] = y-et1;
659         //top
660         h[1][0] = x2;
661         v[1][0] = y-et2-etabinsize;
662         h[1][1] = x1;
663         v[1][1] = y-et2;
664         h[1][2] = x1 + phibinsize;
665         v[1][2] = y-et2;
666         h[1][3] = x2 + phibinsize;
667         v[1][3] = y-et2-etabinsize;
668         //side
669         h[2][0] = x2;
670         v[2][0] = y-et2-etabinsize;
671         h[2][1] = x1;
672         v[2][1] = y-et2;
673         h[2][2] = x1;
674         v[2][2] = y-et1;
675         h[2][3] = x2;
676         v[2][3] = y-et1-etabinsize;
677         //convert to window coords
678         Point2D.Double p= new Point2D.Double(0,0);
679         for(int i=0; i<4; i++)
680         {
681             p = window.calculateDisplay(h[0][i],v[0][i]);
682             h[0][i]=p.x;
683             v[0][i]=p.y;
684             p.x=0; p.y=0;
685             p = window.calculateDisplay(h[1][i],v[1][i]);
686             h[1][i]=p.x;
687             v[1][i]=p.y;
688             p.x=0; p.y=0;
689             p = window.calculateDisplay(h[2][i],v[2][i]);
690             h[2][i]=p.x;
691             v[2][i]=p.y;
692         }
693 
694         //color of sides
695         ag.setColor(drawingColor.darker());
696         //draw sides
697         if (em_had>=0) 
698             ag.fillPolygon(h[2], v[2], 4);
699         else 
700             ag.drawPolygon(h[2], v[2], 4);
701 
702         //colour front
703         ag.setColor(drawingColor);
704         //draw front        
705         if (em_had>=0) 
706             ag.fillPolygon(h[0], v[0], 4);
707         else 
708             ag.drawPolygon(h[0], v[0], 4);
709 
710         //colour top
711         ag.setColor(drawingColor.darker().darker());
712         //draw top
713         if (em_had>=0) 
714             ag.fillPolygon(h[1], v[1], 4);
715         else 
716             ag.drawPolygon(h[1], v[1], 4);
717     }
718 }

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine. Valid HTML 4.01!