Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

H_2D_Helper.cpp

Go to the documentation of this file.
00001 #include "HTL/H_2D_Helper.h"
00002 
00003 T_Histo1DVar * H_2D_Helper::xBand(I_Histo &h, int whichBin ) {
00004   return band (h,whichBin,1);
00005 }
00006 
00007 T_Histo1DVar * H_2D_Helper::yBand(I_Histo &h, int whichBin ) {
00008   return band (h,whichBin,0);
00009 }
00010 
00011 T_Histo1DVar * H_2D_Helper::xBand(I_Histo &h, double y ) {
00012   Index an_index;
00013   Extra_Index an_extra_index;
00014   //  int whichBin; 
00015   h.i_partition(0).map_point( y, an_index, an_extra_index);
00016   if (an_extra_index == H_IN_RANGE) 
00017     return band (h,an_index,1);
00018   else
00019     return 0;
00020 }
00021 
00022 T_Histo1DVar * H_2D_Helper::yBand(I_Histo &h,double x ) {
00023   Index an_index;
00024   Extra_Index an_extra_index;
00025   // int whichBin; 
00026   h.i_partition(0).map_point( x , an_index, an_extra_index);
00027   if (an_extra_index == H_IN_RANGE) 
00028     return band (h,an_index,0);
00029   else
00030     return 0;
00031 }
00032 
00033 T_Histo1DVar * H_2D_Helper::xProject(I_Histo &h ) {
00034   return project (h,1);
00035 }
00036 
00037 T_Histo1DVar * H_2D_Helper::yProject(I_Histo &h ) {
00038   return project (h,0);
00039 }
00040 
00041 T_Histo1DVar * H_2D_Helper::band(I_Histo &histo,int theBin,int thePart){
00042   T_Histo1DVar * hhh = 0;
00043   int otherPart = 1-thePart;
00044   if (histo.dim() == 2) {
00045     if ((theBin >= 0)&&(Size(theBin)<histo.i_partition(thePart).bin_count())){
00046       int i;
00047       I_Histo::I_Bin_Location bbL(2);
00048       T_Histo_1D_WUD * h1 = 
00049         new T_Histo_1D_WUD("band",histo.i_partition(otherPart));
00050       hhh = new T_Histo1DVar(*h1);
00051       // In range bins
00052       bbL[thePart]=theBin; bbL[otherPart]=0;
00053       for (i = 0 ; Size(i) < histo.i_partition(otherPart).bin_count(); i++) {
00054         bbL[otherPart] = i;
00055         hhh->i_bin(i).make(histo.i_bin(bbL));
00056         // Since we're going from a Weigthed bin to a Gravity bin
00057         // bin centers have to be adjusted to become absolute X values
00058         // rather than relative fractions (0.5)
00059         double low = hhh->i_partition().i_lower_point(i);
00060         double high = hhh->i_partition().i_upper_point(i);
00061         hhh->i_bin(i).set_center((low+high)/2.);
00062       }
00063       // Underflow/overflow bins
00064       bbL[thePart]=theBin; bbL[otherPart]=I_Histo::UNDERFLOW_BIN;
00065       hhh->i_bin(hhh->bin_count()).make(histo.i_any_bin(bbL));
00066       bbL[thePart]=theBin; bbL[otherPart]=I_Histo::OVERFLOW_BIN;
00067       hhh->i_bin(hhh->bin_count()+2).make(histo.i_any_bin(bbL));
00068       delete h1;
00069     } 
00070   } 
00071   return hhh;
00072 }
00073 
00074 T_Histo1DVar * H_2D_Helper::project(I_Histo &histo, int thePart){
00075   T_Histo1DVar * hhh = 0;
00076   int otherPart = 1-thePart;
00077   if (histo.dim() == 2) {
00078     Size i,j;
00079     I_Histo::I_Bin_Location bbL(2);
00080     T_Histo_1D_WUD * h1 = 
00081       new T_Histo_1D_WUD("project",histo.i_partition(otherPart));
00082     hhh = new T_Histo1DVar(*h1);
00083     for (j = 0 ; j < histo.i_partition(thePart).bin_count(); j++) {
00084       bbL[thePart] = j;      
00085       for (i = 0 ; i < histo.i_partition(otherPart).bin_count(); i++) {
00086         bbL[otherPart] = i;
00087         hhh->i_bin(i).add(histo.i_bin(bbL));
00088         // Since we're going from a Weigthed bin to a Gravity bin
00089         // bin cernters have to be adjusted to become absolute X values
00090         // rather than relative fractions (0.5)
00091         double low = hhh->i_partition().i_lower_point(i);
00092         double high = hhh->i_partition().i_upper_point(i);
00093         hhh->i_bin(i).set_center((low+high)/2.);
00094       }
00095     }
00096     // Underflow/overflow bins
00097     bbL[thePart] = I_Histo::UNDERFLOW_BIN; 
00098     // Locate UND/OVR on the 1D histo
00099     I_Histo::I_Extra_Bin_Location loc1(1);
00100     // Sum up proper out-of-range in 1D UNDERFLOW
00101     loc1[0] = H_UNDERFLOW;
00102     // First detailed info
00103     for (i = 0 ; i < histo.i_partition(otherPart).bin_count(); i++) {
00104       bbL[otherPart] = i;
00105       hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00106     }
00107     // Then "corners"
00108     bbL[otherPart] = I_Histo::UNDERFLOW_BIN; 
00109     hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00110     bbL[otherPart] = I_Histo::OVERFLOW_BIN; 
00111     hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00112     // Sum up proper out-of-range in 1D OVERFLOW
00113     loc1[0] = H_OVERFLOW;
00114     // First detailed info
00115     bbL[thePart] = I_Histo::OVERFLOW_BIN;      
00116     for (i = 0 ; i < histo.i_partition(otherPart).bin_count(); i++) {
00117       bbL[otherPart] = i;
00118       hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00119     }
00120     // Then "corners"
00121     bbL[otherPart] = I_Histo::UNDERFLOW_BIN; 
00122     hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00123     bbL[otherPart] = I_Histo::OVERFLOW_BIN; 
00124     hhh->i_extra_bin(loc1).add(histo.i_any_bin(bbL));
00125     delete h1;
00126   } 
00127   return hhh;
00128 }


Anaphe documentation generated by Doxygen (www.doxygen.org)