Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:06

0001 BEGIN{
0002     n=0;
0003     endedParsing=0;
0004     selfArrange=0;
0005     min=99999999999;
0006     max=-1*min;
0007     selfArrange=2;
0008 }
0009 function getcolor(val){
0010     red=0;green=0;blue=0;
0011     delta=(max-min);
0012     x =(val-min);
0013     if(val<min){red=0;green=0;blue=255;}
0014     if(val>max){red=255;green=0;blue=0;}
0015     if(val>=min&&val<=max){ 
0016   red = int ( x<(delta/2) ? 0 : ( x > ((3./4.)*delta) ?  255 : 255/(delta/4) * (x-(2./4.)*delta)  ) );
0017   green= int ( x<delta/4 ? (x*255/(delta/4)) : ( x > ((3./4.)*delta) ?  255-255/(delta/4) *(x-(3./4.)*delta) : 255 ) );
0018   blue = int ( x<delta/4 ? 255 : ( x > ((1./2.)*delta) ?  0 : 255-255/(delta/4) * (x-(1./4.)*delta) ) );
0019     }
0020     color=sprintf("%d,%d,%d",red,green,blue);
0021     return color; 
0022 }
0023 function parseSource(){
0024     value[$1]=$2;
0025     print min " " max;
0026     if(selfArrange==1){   
0027   if($2<min)
0028       min=$2;
0029   if($2>max)
0030       max=$2;
0031     }
0032 }
0033 function fillTkMap(){
0034     if(match($2,"detid")){
0035   det=substr($2,8,9);
0036   if(det in value){
0037       tmp=$0
0038       stringVal=sprintf("value=\"%f\"",value[det]);
0039       sub("255,255,255", getcolor(value[det]), tmp);
0040       sub("value=\"0\"", stringVal, tmp);
0041       print tmp
0042   } else 
0043       print $0
0044     } else
0045   print $0
0046 }
0047 {
0048     if(selfArrange==2){
0049   selfArrange=1;
0050   if(vmin!=vmax){
0051       min=vmin;
0052       max=vmax;
0053       selfArrange=0;
0054   }
0055     }
0056     if(!match(FILENAME,"tkmap_white.xml")) parseSource();
0057     
0058     if(match(FILENAME,"tkmap_white.xml")) fillTkMap();
0059 }