CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CalibFormats/SiPixelObjects/src/PixelROCDACSettings.cc

Go to the documentation of this file.
00001 //
00002 // This class provide the data structure for the
00003 // ROC DAC parameters
00004 //
00005 // At this point I do not see a reason to make an
00006 // abstract layer for this code.
00007 //
00008 
00009 #include "CalibFormats/SiPixelObjects/interface/PixelROCDACSettings.h"
00010 #include "CalibFormats/SiPixelObjects/interface/PixelDACNames.h"
00011 #include <fstream>
00012 #include <iostream>
00013 
00014 using namespace pos;
00015 using namespace std;
00016 
00017 PixelROCDACSettings::PixelROCDACSettings(){}
00018 
00019 
00020 void PixelROCDACSettings::getDACs(vector<unsigned int>& dacs) const
00021 {
00022     dacs.clear();
00023     dacs.push_back(Vdd_);
00024     dacs.push_back(Vana_);
00025     dacs.push_back(Vsf_);
00026     dacs.push_back(Vcomp_);
00027     dacs.push_back(Vleak_);
00028     dacs.push_back(VrgPr_);
00029     dacs.push_back(VwllPr_);
00030     dacs.push_back(VrgSh_);
00031     dacs.push_back(VwllSh_);
00032     dacs.push_back(VHldDel_);
00033     dacs.push_back(Vtrim_);
00034     dacs.push_back(VcThr_);
00035     dacs.push_back(VIbias_bus_);
00036     dacs.push_back(VIbias_sf_);
00037     dacs.push_back(VOffsetOp_);
00038     dacs.push_back(VbiasOp_);
00039     dacs.push_back(VOffsetRO_);
00040     dacs.push_back(VIon_);
00041     dacs.push_back(VIbias_PH_);
00042     dacs.push_back(VIbias_DAC_);
00043     dacs.push_back(VIbias_roc_);
00044     dacs.push_back(VIColOr_);
00045     dacs.push_back(Vnpix_);
00046     dacs.push_back(VsumCol_);
00047     dacs.push_back(Vcal_);
00048     dacs.push_back(CalDel_);
00049     dacs.push_back(TempRange_);
00050     dacs.push_back(WBC_);
00051     dacs.push_back(ChipContReg_);
00052 }
00053 
00054 // Added by Dario
00055 void PixelROCDACSettings::getDACs(std::map<std::string, unsigned int>& dacs) const
00056 {
00057     dacs.clear();
00058     dacs[k_DACName_Vdd        ] = Vdd_        ;
00059     dacs[k_DACName_Vana       ] = Vana_       ;     
00060     dacs[k_DACName_Vsf        ] = Vsf_        ;      
00061     dacs[k_DACName_Vcomp      ] = Vcomp_      ;      
00062     dacs[k_DACName_Vleak      ] = Vleak_      ;      
00063     dacs[k_DACName_VrgPr      ] = VrgPr_      ;      
00064     dacs[k_DACName_VwllPr     ] = VwllPr_     ;     
00065     dacs[k_DACName_VrgSh      ] = VrgSh_      ;      
00066     dacs[k_DACName_VwllSh     ] = VwllSh_     ;     
00067     dacs[k_DACName_VHldDel    ] = VHldDel_    ;    
00068     dacs[k_DACName_Vtrim      ] = Vtrim_      ;      
00069     dacs[k_DACName_VcThr      ] = VcThr_      ;      
00070     dacs[k_DACName_VIbias_bus ] = VIbias_bus_ ;
00071     dacs[k_DACName_VIbias_sf  ] = VIbias_sf_  ; 
00072     dacs[k_DACName_VOffsetOp  ] = VOffsetOp_  ; 
00073     dacs[k_DACName_VbiasOp    ] = VbiasOp_    ;    
00074     dacs[k_DACName_VOffsetRO  ] = VOffsetRO_  ; 
00075     dacs[k_DACName_VIon       ] = VIon_       ;       
00076     dacs[k_DACName_VIbias_PH  ] = VIbias_PH_  ; 
00077     dacs[k_DACName_VIbias_DAC ] = VIbias_DAC_ ;
00078     dacs[k_DACName_VIbias_roc ] = VIbias_roc_ ;
00079     dacs[k_DACName_VIColOr    ] = VIColOr_    ;    
00080     dacs[k_DACName_Vnpix      ] = Vnpix_      ;      
00081     dacs[k_DACName_VsumCol    ] = VsumCol_    ;    
00082     dacs[k_DACName_Vcal       ] = Vcal_       ;       
00083     dacs[k_DACName_CalDel     ] = CalDel_     ;     
00084     dacs[k_DACName_TempRange  ] = TempRange_  ; 
00085     dacs[k_DACName_WBC        ] = WBC_        ;
00086     dacs[k_DACName_ChipContReg] = ChipContReg_;
00087 }
00088 
00089 // Added by Dario
00090 void PixelROCDACSettings::setDACs(std::map<std::string, unsigned int>& dacs) 
00091 {
00092     Vdd_         = dacs[k_DACName_Vdd        ] ;
00093     Vana_        = dacs[k_DACName_Vana       ] ;    
00094     Vsf_         = dacs[k_DACName_Vsf        ] ;     
00095     Vcomp_       = dacs[k_DACName_Vcomp      ] ;     
00096     Vleak_       = dacs[k_DACName_Vleak      ] ;     
00097     VrgPr_       = dacs[k_DACName_VrgPr      ] ;     
00098     VwllPr_      = dacs[k_DACName_VwllPr     ] ;    
00099     VrgSh_       = dacs[k_DACName_VrgSh      ] ;     
00100     VwllSh_      = dacs[k_DACName_VwllSh     ] ;    
00101     VHldDel_     = dacs[k_DACName_VHldDel    ] ;   
00102     Vtrim_       = dacs[k_DACName_Vtrim      ] ;     
00103     VcThr_       = dacs[k_DACName_VcThr      ] ;     
00104     VIbias_bus_  = dacs[k_DACName_VIbias_bus ] ;
00105     VIbias_sf_   = dacs[k_DACName_VIbias_sf  ] ; 
00106     VOffsetOp_   = dacs[k_DACName_VOffsetOp  ] ; 
00107     VbiasOp_     = dacs[k_DACName_VbiasOp    ] ;   
00108     VOffsetRO_   = dacs[k_DACName_VOffsetRO  ] ; 
00109     VIon_        = dacs[k_DACName_VIon       ] ;      
00110     VIbias_PH_   = dacs[k_DACName_VIbias_PH  ] ; 
00111     VIbias_DAC_  = dacs[k_DACName_VIbias_DAC ] ;
00112     VIbias_roc_  = dacs[k_DACName_VIbias_roc ] ;
00113     VIColOr_     = dacs[k_DACName_VIColOr    ] ;   
00114     Vnpix_       = dacs[k_DACName_Vnpix      ] ;     
00115     VsumCol_     = dacs[k_DACName_VsumCol    ] ;   
00116     Vcal_        = dacs[k_DACName_Vcal       ] ;      
00117     CalDel_      = dacs[k_DACName_CalDel     ] ;    
00118     TempRange_   = dacs[k_DACName_TempRange  ] ; 
00119     WBC_         = dacs[k_DACName_WBC        ] ;
00120     ChipContReg_ = dacs[k_DACName_ChipContReg] ;
00121 }
00122 
00123 // Added by Dario
00124 void PixelROCDACSettings::compareDACs(std::map<std::string, unsigned int>& dacs, 
00125                                       std::map<std::string, bool>& changes, 
00126                                       std::map<std::string, unsigned int>& previous) 
00127 {
00128     changes[k_DACName_Vdd        ] = false;
00129     changes[k_DACName_Vana       ] = false;
00130     changes[k_DACName_Vsf        ] = false;
00131     changes[k_DACName_Vcomp      ] = false;
00132     changes[k_DACName_Vleak      ] = false;
00133     changes[k_DACName_VrgPr      ] = false;
00134     changes[k_DACName_VwllPr     ] = false;
00135     changes[k_DACName_VrgSh      ] = false;
00136     changes[k_DACName_VwllSh     ] = false;
00137     changes[k_DACName_VHldDel    ] = false;
00138     changes[k_DACName_Vtrim      ] = false;
00139     changes[k_DACName_VcThr      ] = false;
00140     changes[k_DACName_VIbias_bus ] = false;
00141     changes[k_DACName_VIbias_sf  ] = false;
00142     changes[k_DACName_VOffsetOp  ] = false;
00143     changes[k_DACName_VbiasOp    ] = false;
00144     changes[k_DACName_VOffsetRO  ] = false;
00145     changes[k_DACName_VIon       ] = false;
00146     changes[k_DACName_VIbias_PH  ] = false;
00147     changes[k_DACName_VIbias_DAC ] = false;
00148     changes[k_DACName_VIbias_roc ] = false;
00149     changes[k_DACName_VIColOr    ] = false;
00150     changes[k_DACName_Vnpix      ] = false;
00151     changes[k_DACName_VsumCol    ] = false;
00152     changes[k_DACName_Vcal       ] = false;
00153     changes[k_DACName_CalDel     ] = false;
00154     changes[k_DACName_TempRange  ] = false;
00155     changes[k_DACName_WBC        ] = false;
00156     changes[k_DACName_ChipContReg] = false;
00157 
00158     if( Vdd_         != dacs[k_DACName_Vdd        ] ) {changes[k_DACName_Vdd        ] = true; previous[k_DACName_Vdd        ] = Vdd_        ;} 
00159     if( Vana_        != dacs[k_DACName_Vana       ] ) {changes[k_DACName_Vana       ] = true; previous[k_DACName_Vana       ] = Vana_       ;} 
00160     if( Vsf_         != dacs[k_DACName_Vsf        ] ) {changes[k_DACName_Vsf        ] = true; previous[k_DACName_Vsf        ] = Vsf_        ;}         
00161     if( Vcomp_       != dacs[k_DACName_Vcomp      ] ) {changes[k_DACName_Vcomp      ] = true; previous[k_DACName_Vcomp      ] = Vcomp_      ;}         
00162     if( Vleak_       != dacs[k_DACName_Vleak      ] ) {changes[k_DACName_Vleak      ] = true; previous[k_DACName_Vleak      ] = Vleak_      ;}         
00163     if( VrgPr_       != dacs[k_DACName_VrgPr      ] ) {changes[k_DACName_VrgPr      ] = true; previous[k_DACName_VrgPr      ] = VrgPr_      ;}         
00164     if( VwllPr_      != dacs[k_DACName_VwllPr     ] ) {changes[k_DACName_VwllPr     ] = true; previous[k_DACName_VwllPr     ] = VwllPr_     ;}        
00165     if( VrgSh_       != dacs[k_DACName_VrgSh      ] ) {changes[k_DACName_VrgSh      ] = true; previous[k_DACName_VrgSh      ] = VrgSh_      ;}         
00166     if( VwllSh_      != dacs[k_DACName_VwllSh     ] ) {changes[k_DACName_VwllSh     ] = true; previous[k_DACName_VwllSh     ] = VwllSh_     ;}        
00167     if( VHldDel_     != dacs[k_DACName_VHldDel    ] ) {changes[k_DACName_VHldDel    ] = true; previous[k_DACName_VHldDel    ] = VHldDel_    ;} 
00168     if( Vtrim_       != dacs[k_DACName_Vtrim      ] ) {changes[k_DACName_Vtrim      ] = true; previous[k_DACName_Vtrim      ] = Vtrim_      ;}         
00169     if( VcThr_       != dacs[k_DACName_VcThr      ] ) {changes[k_DACName_VcThr      ] = true; previous[k_DACName_VcThr      ] = VcThr_      ;}         
00170     if( VIbias_bus_  != dacs[k_DACName_VIbias_bus ] ) {changes[k_DACName_VIbias_bus ] = true; previous[k_DACName_VIbias_bus ] = VIbias_bus_ ;} 
00171     if( VIbias_sf_   != dacs[k_DACName_VIbias_sf  ] ) {changes[k_DACName_VIbias_sf  ] = true; previous[k_DACName_VIbias_sf  ] = VIbias_sf_  ;} 
00172     if( VOffsetOp_   != dacs[k_DACName_VOffsetOp  ] ) {changes[k_DACName_VOffsetOp  ] = true; previous[k_DACName_VOffsetOp  ] = VOffsetOp_  ;} 
00173     if( VbiasOp_     != dacs[k_DACName_VbiasOp    ] ) {changes[k_DACName_VbiasOp    ] = true; previous[k_DACName_VbiasOp    ] = VbiasOp_    ;} 
00174     if( VOffsetRO_   != dacs[k_DACName_VOffsetRO  ] ) {changes[k_DACName_VOffsetRO  ] = true; previous[k_DACName_VOffsetRO  ] = VOffsetRO_  ;} 
00175     if( VIon_        != dacs[k_DACName_VIon       ] ) {changes[k_DACName_VIon       ] = true; previous[k_DACName_VIon       ] = VIon_       ;}          
00176     if( VIbias_PH_   != dacs[k_DACName_VIbias_PH  ] ) {changes[k_DACName_VIbias_PH  ] = true; previous[k_DACName_VIbias_PH  ] = VIbias_PH_  ;} 
00177     if( VIbias_DAC_  != dacs[k_DACName_VIbias_DAC ] ) {changes[k_DACName_VIbias_DAC ] = true; previous[k_DACName_VIbias_DAC ] = VIbias_DAC_ ;} 
00178     if( VIbias_roc_  != dacs[k_DACName_VIbias_roc ] ) {changes[k_DACName_VIbias_roc ] = true; previous[k_DACName_VIbias_roc ] = VIbias_roc_ ;} 
00179     if( VIColOr_     != dacs[k_DACName_VIColOr    ] ) {changes[k_DACName_VIColOr    ] = true; previous[k_DACName_VIColOr    ] = VIColOr_    ;} 
00180     if( Vnpix_       != dacs[k_DACName_Vnpix      ] ) {changes[k_DACName_Vnpix      ] = true; previous[k_DACName_Vnpix      ] = Vnpix_      ;}         
00181     if( VsumCol_     != dacs[k_DACName_VsumCol    ] ) {changes[k_DACName_VsumCol    ] = true; previous[k_DACName_VsumCol    ] = VsumCol_    ;} 
00182     if( Vcal_        != dacs[k_DACName_Vcal       ] ) {changes[k_DACName_Vcal       ] = true; previous[k_DACName_Vcal       ] = Vcal_       ;}          
00183     if( CalDel_      != dacs[k_DACName_CalDel     ] ) {changes[k_DACName_CalDel     ] = true; previous[k_DACName_CalDel     ] = CalDel_     ;}        
00184     if( TempRange_   != dacs[k_DACName_TempRange  ] ) {changes[k_DACName_TempRange  ] = true; previous[k_DACName_TempRange  ] = TempRange_  ;} 
00185     if( WBC_         != dacs[k_DACName_WBC        ] ) {changes[k_DACName_WBC        ] = true; previous[k_DACName_WBC        ] = WBC_        ;} 
00186     if( ChipContReg_ != dacs[k_DACName_ChipContReg] ) {changes[k_DACName_ChipContReg] = true; previous[k_DACName_ChipContReg] = ChipContReg_;} 
00187 }                                                                                           
00188                                                                                        
00189 void PixelROCDACSettings::setDAC(unsigned int dacaddress, unsigned int dacvalue)       
00190 {
00191         std::string mthn = "[PixelROCDACSettings::setDAC()]\t\t\t\t    " ;
00192         switch (dacaddress) {
00193                 case   1: Vdd_         = dacvalue;  break;
00194                 case   2: Vana_        = dacvalue;  break;
00195                 case   3: Vsf_         = dacvalue;  break;
00196                 case   4: Vcomp_       = dacvalue;  break;
00197                 case   5: Vleak_       = dacvalue;  break;
00198                 case   6: VrgPr_       = dacvalue;  break;
00199                 case   7: VwllPr_      = dacvalue;  break;
00200                 case   8: VrgSh_       = dacvalue;  break;
00201                 case   9: VwllSh_      = dacvalue;  break;
00202                 case  10: VHldDel_     = dacvalue;  break;
00203                 case  11: Vtrim_       = dacvalue;  break;
00204                 case  12: VcThr_       = dacvalue;  break;
00205                 case  13: VIbias_bus_  = dacvalue;  break;
00206                 case  14: VIbias_sf_   = dacvalue;  break;
00207                 case  15: VOffsetOp_   = dacvalue;  break;
00208                 case  16: VbiasOp_     = dacvalue;  break;
00209                 case  17: VOffsetRO_   = dacvalue;  break;
00210                 case  18: VIon_        = dacvalue;  break;
00211                 case  19: VIbias_PH_   = dacvalue;  break;
00212                 case  20: VIbias_DAC_  = dacvalue;  break;
00213                 case  21: VIbias_roc_  = dacvalue;  break;
00214                 case  22: VIColOr_     = dacvalue;  break;
00215                 case  23: Vnpix_       = dacvalue;  break;
00216                 case  24: VsumCol_     = dacvalue;  break;
00217                 case  25: Vcal_        = dacvalue;  break;
00218                 case  26: CalDel_      = dacvalue;  break;
00219                 case  27: TempRange_   = dacvalue;  break;
00220                 case 254: WBC_         = dacvalue;  break;
00221                 case 253: ChipContReg_ = dacvalue;  break;
00222                 default: cout << __LINE__ << "]\t" << mthn 
00223                               << "DAC Address " << dacaddress << " does not exist!" << endl;
00224         }
00225 
00226 }
00227 
00228 void PixelROCDACSettings::writeBinary(ofstream& out) const
00229 {
00230     out << (char)rocid_.rocname().size();
00231     out.write(rocid_.rocname().c_str(),rocid_.rocname().size());
00232 
00233     out << Vdd_;
00234     out << Vana_;
00235     out << Vsf_;
00236     out << Vcomp_;
00237     out << Vleak_;
00238     out << VrgPr_;
00239     out << VwllPr_;
00240     out << VrgSh_;
00241     out << VwllSh_;
00242     out << VHldDel_;
00243     out << Vtrim_;
00244     out << VcThr_;
00245     out << VIbias_bus_;
00246     out << VIbias_sf_;
00247     out << VOffsetOp_;
00248     out << VbiasOp_;
00249     out << VOffsetRO_;
00250     out << VIon_;
00251     out << VIbias_PH_;
00252     out << VIbias_DAC_;
00253     out << VIbias_roc_;
00254     out << VIColOr_;
00255     out << Vnpix_;
00256     out << VsumCol_;
00257     out << Vcal_;
00258     out << CalDel_;
00259     out << TempRange_;
00260     out << WBC_;
00261     out << ChipContReg_;        
00262 }
00263 
00264 
00265 int PixelROCDACSettings::readBinary(ifstream& in, const PixelROCName& rocid){
00266     
00267     rocid_=rocid;
00268 
00269     in.read((char*)&Vdd_,1);
00270     in.read((char*)&Vana_,1);
00271     in.read((char*)&Vsf_,1);
00272     in.read((char*)&Vcomp_,1);
00273     in.read((char*)&Vleak_,1);
00274     in.read((char*)&VrgPr_,1);
00275     in.read((char*)&VwllPr_,1);
00276     in.read((char*)&VrgSh_,1);
00277     in.read((char*)&VwllSh_,1);
00278     in.read((char*)&VHldDel_,1);
00279     in.read((char*)&Vtrim_,1);
00280     in.read((char*)&VcThr_,1);
00281     in.read((char*)&VIbias_bus_,1);
00282     in.read((char*)&VIbias_sf_,1);
00283     in.read((char*)&VOffsetOp_,1);
00284     in.read((char*)&VbiasOp_,1);
00285     in.read((char*)&VOffsetRO_,1);
00286     in.read((char*)&VIon_,1);
00287     in.read((char*)&VIbias_PH_,1);
00288     in.read((char*)&VIbias_DAC_,1);
00289     in.read((char*)&VIbias_roc_,1);
00290     in.read((char*)&VIColOr_,1);
00291     in.read((char*)&Vnpix_,1);
00292     in.read((char*)&VsumCol_,1);
00293     in.read((char*)&Vcal_,1);
00294     in.read((char*)&CalDel_,1);
00295     in.read((char*)&TempRange_,1);
00296     in.read((char*)&WBC_,1);
00297     in.read((char*)&ChipContReg_,1);    
00298     
00299     return 1;
00300 
00301 }
00302 
00303 void PixelROCDACSettings::writeASCII(ostream& out) const{
00304 
00305     out << "ROC:           " << rocid_.rocname()   <<endl;
00306 
00307     out << k_DACName_Vdd << ":           " << (int)Vdd_          <<endl;
00308     out << k_DACName_Vana << ":          " << (int)Vana_         <<endl;
00309     out << k_DACName_Vsf << ":           " << (int)Vsf_          <<endl;
00310     out << k_DACName_Vcomp << ":         " << (int)Vcomp_        <<endl;
00311     out << k_DACName_Vleak << ":         " << (int)Vleak_        <<endl;
00312     out << k_DACName_VrgPr << ":         " << (int)VrgPr_        <<endl;
00313     out << k_DACName_VwllPr << ":        " << (int)VwllPr_       <<endl;
00314     out << k_DACName_VrgSh << ":         " << (int)VrgSh_        <<endl;
00315     out << k_DACName_VwllSh << ":        " << (int)VwllSh_       <<endl;
00316     out << k_DACName_VHldDel << ":       " << (int)VHldDel_      <<endl;
00317     out << k_DACName_Vtrim << ":         " << (int)Vtrim_        <<endl;
00318     out << k_DACName_VcThr << ":         " << (int)VcThr_        <<endl;
00319     out << k_DACName_VIbias_bus << ":    " << (int)VIbias_bus_   <<endl;
00320     out << k_DACName_VIbias_sf << ":     " << (int)VIbias_sf_    <<endl;
00321     out << k_DACName_VOffsetOp << ":     " << (int)VOffsetOp_    <<endl;
00322     out << k_DACName_VbiasOp << ":       " << (int)VbiasOp_      <<endl;
00323     out << k_DACName_VOffsetRO << ":     " << (int)VOffsetRO_    <<endl;
00324     out << k_DACName_VIon << ":          " << (int)VIon_         <<endl;
00325     out << k_DACName_VIbias_PH << ":     " << (int)VIbias_PH_    <<endl;
00326     out << k_DACName_VIbias_DAC << ":    " << (int)VIbias_DAC_   <<endl;
00327     out << k_DACName_VIbias_roc << ":    " << (int)VIbias_roc_   <<endl;
00328     out << k_DACName_VIColOr << ":       " << (int)VIColOr_      <<endl;
00329     out << k_DACName_Vnpix << ":         " << (int)Vnpix_        <<endl;
00330     out << k_DACName_VsumCol << ":       " << (int)VsumCol_      <<endl;
00331     out << k_DACName_Vcal << ":          " << (int)Vcal_         <<endl;
00332     out << k_DACName_CalDel << ":        " << (int)CalDel_       <<endl;
00333     out << k_DACName_TempRange << ":     " << (int)TempRange_    <<endl;
00334     out << k_DACName_WBC << ":           " << (int)WBC_          <<endl;
00335     out << k_DACName_ChipContReg << ":   " << (int)ChipContReg_  <<endl;
00336 
00337 }
00338 
00339 //=============================================================================================
00340 void PixelROCDACSettings::writeXML(ofstream *out) const {
00341   std::string mthn = "[PixelROCDACSettings::writeXML()]\t\t\t    " ;
00342 
00343   *out << "  <DATA>"                                                  << endl ;
00344   *out << "   <ROC_NAME>"    << rocid_.rocname()  << "</ROC_NAME>"    << endl ;
00345   *out << "   <VDD>"         << (int)Vdd_         << "</VDD>"         << endl ;
00346   *out << "   <VANA>"        << (int)Vana_        << "</VANA>"        << endl ;
00347   *out << "   <VSF>"         << (int)Vsf_         << "</VSF>"         << endl ;
00348   *out << "   <VCOMP>"       << (int)Vcomp_       << "</VCOMP>"       << endl ;
00349   *out << "   <VLEAK>"       << (int)Vleak_       << "</VLEAK>"       << endl ;
00350   *out << "   <VRGPR>"       << (int)VrgPr_       << "</VRGPR>"       << endl ;
00351   *out << "   <VWLLPR>"      << (int)VwllPr_      << "</VWLLPR>"      << endl ;
00352   *out << "   <VRGSH>"       << (int)VrgSh_       << "</VRGSH>"       << endl ;
00353   *out << "   <VWLLSH>"      << (int)VwllSh_      << "</VWLLSH>"      << endl ;
00354   *out << "   <VHLDDEL>"     << (int)VHldDel_     << "</VHLDDEL>"     << endl ;
00355   *out << "   <VTRIM>"       << (int)Vtrim_       << "</VTRIM>"       << endl ;
00356   *out << "   <VCTHR>"       << (int)VcThr_       << "</VCTHR>"       << endl ;
00357   *out << "   <VIBIAS_BUS>"  << (int)VIbias_bus_  << "</VIBIAS_BUS>"  << endl ;
00358   *out << "   <VIBIAS_SF>"   << (int)VIbias_sf_   << "</VIBIAS_SF>"   << endl ;
00359   *out << "   <VOFFSETOP>"   << (int)VOffsetOp_   << "</VOFFSETOP>"   << endl ;
00360   *out << "   <VBIASOP>"     << (int)VbiasOp_     << "</VBIASOP>"     << endl ;
00361   *out << "   <VOFFSETRO>"   << (int)VOffsetRO_   << "</VOFFSETRO>"   << endl ;
00362   *out << "   <VION>"        << (int)VIon_        << "</VION>"        << endl ;
00363   *out << "   <VIBIAS_PH>"   << (int)VIbias_PH_   << "</VIBIAS_PH>"   << endl ;
00364   *out << "   <VIBIAS_DAC>"  << (int)VIbias_DAC_  << "</VIBIAS_DAC>"  << endl ;
00365   *out << "   <VIBIAS_ROC>"  << (int)VIbias_roc_  << "</VIBIAS_ROC>"  << endl ;
00366   *out << "   <VICOLOR>"     << (int)VIColOr_     << "</VICOLOR>"     << endl ;
00367   *out << "   <VNPIX>"       << (int)Vnpix_       << "</VNPIX>"       << endl ;
00368   *out << "   <VSUMCOL>"     << (int)VsumCol_     << "</VSUMCOL>"     << endl ;
00369   *out << "   <VCAL>"        << (int)Vcal_        << "</VCAL>"        << endl ;
00370   *out << "   <CALDEL>"      << (int)CalDel_      << "</CALDEL>"      << endl ;
00371   *out << "   <TEMPRANGE>"   << (int)TempRange_   << "</TEMPRANGE>"   << endl ;
00372   *out << "   <WBC>"         << (int)WBC_         << "</WBC>"         << endl ;
00373   *out << "   <CHIPCONTREG>" << (int)ChipContReg_ << "</CHIPCONTREG>" << endl ;
00374   *out << "  </DATA>"                                                 << endl ;
00375   *out << " "                                                         << endl ;
00376 
00377 }
00378 
00379 //=============================================================================================
00380 void PixelROCDACSettings::checkTag(string tag, 
00381                                    string dacName,
00382                                    const PixelROCName& rocid){
00383   
00384   std::string mthn = "[PixelROCDACSettings::checkTag()]\t\t\t\t    " ;
00385   dacName+=":";
00386   if (tag!=dacName) {
00387     cout << __LINE__ << "]\t" << mthn << "Read ROC name       : "             << tag     << endl;
00388     cout << __LINE__ << "]\t" << mthn << "But expected to find: "             << dacName << endl;
00389     cout << __LINE__ << "]\t" << mthn << "When reading DAC settings for ROC " << rocid   << endl;
00390     assert(0);
00391   }
00392 
00393 }
00394 
00395 int PixelROCDACSettings::read(std::istringstream& in, const PixelROCName& rocid)
00396 {
00397     std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t    " ;
00398 
00399     rocid_=rocid;
00400 
00401     unsigned int tmp;
00402     string tag;
00403 
00404     //    cout << "[PixelROCDACSettings::read()] |" << in.str() << "|" << endl ;
00405     in >> tag; 
00406     checkTag(tag,k_DACName_Vdd,rocid);
00407     in >> tmp; Vdd_=tmp;
00408     in >> tag; 
00409     checkTag(tag,k_DACName_Vana,rocid);
00410     in >> tmp; Vana_=tmp;
00411     in >> tag; 
00412     checkTag(tag,k_DACName_Vsf,rocid);
00413     in >> tmp; Vsf_=tmp;
00414     in >> tag; 
00415     checkTag(tag,k_DACName_Vcomp,rocid);
00416     in >> tmp; Vcomp_=tmp;
00417     in >> tag; 
00418     checkTag(tag,k_DACName_Vleak,rocid);
00419     in >> tmp; Vleak_=tmp;
00420     in >> tag; 
00421     checkTag(tag,k_DACName_VrgPr,rocid);
00422     in >> tmp; VrgPr_=tmp;
00423     in >> tag; 
00424     checkTag(tag,k_DACName_VwllPr,rocid);
00425     in >> tmp; VwllPr_=tmp;
00426     in >> tag; 
00427     checkTag(tag,k_DACName_VrgSh,rocid);
00428     in >> tmp; VrgSh_=tmp;
00429     in >> tag; 
00430     checkTag(tag,k_DACName_VwllSh,rocid);
00431     in >> tmp; VwllSh_=tmp;
00432     in >> tag; 
00433     checkTag(tag,k_DACName_VHldDel,rocid);
00434     in >> tmp; VHldDel_=tmp;
00435     in >> tag; 
00436     checkTag(tag,k_DACName_Vtrim,rocid);
00437     in >> tmp; Vtrim_=tmp;
00438     in >> tag; 
00439     checkTag(tag,k_DACName_VcThr,rocid);
00440     in >> tmp; VcThr_=tmp;
00441     in >> tag; 
00442     checkTag(tag,k_DACName_VIbias_bus,rocid);
00443     in >> tmp; VIbias_bus_=tmp;
00444     in >> tag; 
00445     checkTag(tag,k_DACName_VIbias_sf,rocid);
00446     in >> tmp; VIbias_sf_=tmp;
00447     in >> tag; 
00448     checkTag(tag,k_DACName_VOffsetOp,rocid);
00449     in >> tmp; VOffsetOp_=tmp;
00450     in >> tag; 
00451     checkTag(tag,k_DACName_VbiasOp,rocid);
00452     in >> tmp; VbiasOp_=tmp;
00453     in >> tag; 
00454     checkTag(tag,k_DACName_VOffsetRO,rocid);
00455     in >> tmp; VOffsetRO_=tmp;
00456     in >> tag; 
00457     checkTag(tag,k_DACName_VIon,rocid);
00458     in >> tmp; VIon_=tmp;
00459     in >> tag; 
00460     checkTag(tag,k_DACName_VIbias_PH,rocid);
00461     in >> tmp; VIbias_PH_=tmp;
00462     in >> tag; 
00463     checkTag(tag,k_DACName_VIbias_DAC,rocid);
00464     in >> tmp; VIbias_DAC_=tmp;
00465     in >> tag; 
00466     checkTag(tag,k_DACName_VIbias_roc,rocid);
00467     in >> tmp; VIbias_roc_=tmp;
00468     in >> tag; 
00469     checkTag(tag,k_DACName_VIColOr,rocid);
00470     in >> tmp; VIColOr_=tmp;
00471     in >> tag; 
00472     checkTag(tag,k_DACName_Vnpix,rocid);
00473     in >> tmp; Vnpix_=tmp;
00474     in >> tag; 
00475     checkTag(tag,k_DACName_VsumCol,rocid);
00476     in >> tmp; VsumCol_=tmp;
00477     in >> tag; 
00478     checkTag(tag,k_DACName_Vcal,rocid);
00479     in >> tmp; Vcal_=tmp;
00480     in >> tag; 
00481     checkTag(tag,k_DACName_CalDel,rocid);
00482     in >> tmp; CalDel_=tmp;
00483     in >> tag; 
00484     if (tag==k_DACName_WBC+":"){
00485       static bool first=true;
00486       if (first){
00487         cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
00488         cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
00489         cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4."                 << endl;
00490         cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once"     << endl;
00491         cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
00492         TempRange_=4;
00493         first=false;
00494       }
00495       in >> tmp; WBC_=tmp;
00496     } else {    
00497       checkTag(tag,k_DACName_TempRange,rocid);
00498       in >> tmp; TempRange_=tmp;
00499       in >> tag; 
00500       checkTag(tag,k_DACName_WBC,rocid);
00501       in >> tmp; WBC_=tmp;
00502     }
00503     in >> tag; 
00504     checkTag(tag,k_DACName_ChipContReg,rocid);
00505     in >> tmp; ChipContReg_=tmp;
00506 
00507     return 0;
00508 }
00509 
00510 int PixelROCDACSettings::read(ifstream& in, const PixelROCName& rocid){
00511     
00512     std::string mthn = "[PixelROCDACSettings::read()]\t\t\t\t    " ;
00513     rocid_=rocid;
00514 
00515     unsigned int tmp;
00516     string tag;
00517 
00518     in >> tag; 
00519     checkTag(tag,k_DACName_Vdd,rocid);
00520     in >> tmp; Vdd_=tmp;
00521     in >> tag; 
00522     checkTag(tag,k_DACName_Vana,rocid);
00523     in >> tmp; Vana_=tmp;
00524     in >> tag; 
00525     checkTag(tag,k_DACName_Vsf,rocid);
00526     in >> tmp; Vsf_=tmp;
00527     in >> tag; 
00528     checkTag(tag,k_DACName_Vcomp,rocid);
00529     in >> tmp; Vcomp_=tmp;
00530     in >> tag; 
00531     checkTag(tag,k_DACName_Vleak,rocid);
00532     in >> tmp; Vleak_=tmp;
00533     in >> tag; 
00534     checkTag(tag,k_DACName_VrgPr,rocid);
00535     in >> tmp; VrgPr_=tmp;
00536     in >> tag; 
00537     checkTag(tag,k_DACName_VwllPr,rocid);
00538     in >> tmp; VwllPr_=tmp;
00539     in >> tag; 
00540     checkTag(tag,k_DACName_VrgSh,rocid);
00541     in >> tmp; VrgSh_=tmp;
00542     in >> tag; 
00543     checkTag(tag,k_DACName_VwllSh,rocid);
00544     in >> tmp; VwllSh_=tmp;
00545     in >> tag; 
00546     checkTag(tag,k_DACName_VHldDel,rocid);
00547     in >> tmp; VHldDel_=tmp;
00548     in >> tag; 
00549     checkTag(tag,k_DACName_Vtrim,rocid);
00550     in >> tmp; Vtrim_=tmp;
00551     in >> tag; 
00552     checkTag(tag,k_DACName_VcThr,rocid);
00553     in >> tmp; VcThr_=tmp;
00554     in >> tag; 
00555     checkTag(tag,k_DACName_VIbias_bus,rocid);
00556     in >> tmp; VIbias_bus_=tmp;
00557     in >> tag; 
00558     checkTag(tag,k_DACName_VIbias_sf,rocid);
00559     in >> tmp; VIbias_sf_=tmp;
00560     in >> tag; 
00561     checkTag(tag,k_DACName_VOffsetOp,rocid);
00562     in >> tmp; VOffsetOp_=tmp;
00563     in >> tag; 
00564     checkTag(tag,k_DACName_VbiasOp,rocid);
00565     in >> tmp; VbiasOp_=tmp;
00566     in >> tag; 
00567     checkTag(tag,k_DACName_VOffsetRO,rocid);
00568     in >> tmp; VOffsetRO_=tmp;
00569     in >> tag; 
00570     checkTag(tag,k_DACName_VIon,rocid);
00571     in >> tmp; VIon_=tmp;
00572     in >> tag; 
00573     checkTag(tag,k_DACName_VIbias_PH,rocid);
00574     in >> tmp; VIbias_PH_=tmp;
00575     in >> tag; 
00576     checkTag(tag,k_DACName_VIbias_DAC,rocid);
00577     in >> tmp; VIbias_DAC_=tmp;
00578     in >> tag; 
00579     checkTag(tag,k_DACName_VIbias_roc,rocid);
00580     in >> tmp; VIbias_roc_=tmp;
00581     in >> tag; 
00582     checkTag(tag,k_DACName_VIColOr,rocid);
00583     in >> tmp; VIColOr_=tmp;
00584     in >> tag; 
00585     checkTag(tag,k_DACName_Vnpix,rocid);
00586     in >> tmp; Vnpix_=tmp;
00587     in >> tag; 
00588     checkTag(tag,k_DACName_VsumCol,rocid);
00589     in >> tmp; VsumCol_=tmp;
00590     in >> tag; 
00591     checkTag(tag,k_DACName_Vcal,rocid);
00592     in >> tmp; Vcal_=tmp;
00593     in >> tag; 
00594     checkTag(tag,k_DACName_CalDel,rocid);
00595     in >> tmp; CalDel_=tmp;
00596     in >> tag; 
00597     if (tag==k_DACName_WBC+":"){
00598       static bool first=true;
00599       if (first){
00600         cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
00601         cout << __LINE__ << "]\t" << mthn << "Did not find TempRange setting in DAC settings" << endl;
00602         cout << __LINE__ << "]\t" << mthn << "Will use a default value of 4."                 << endl;
00603         cout << __LINE__ << "]\t" << mthn << "This message will only be printed out once"     << endl;
00604         cout << __LINE__ << "]\t" << mthn << "**********************************************" << endl;
00605         TempRange_=4;
00606         first=false;
00607       }
00608       in >> tmp; WBC_=tmp;
00609     } else {    
00610       checkTag(tag,k_DACName_TempRange,rocid);
00611       in >> tmp; TempRange_=tmp;
00612       in >> tag; 
00613       checkTag(tag,k_DACName_WBC,rocid);
00614       in >> tmp; WBC_=tmp;
00615     }
00616     in >> tag; 
00617     checkTag(tag,k_DACName_ChipContReg,rocid);
00618     in >> tmp; ChipContReg_=tmp;
00619 
00620     return 0;
00621 }
00622 
00623 
00624 string PixelROCDACSettings::getConfigCommand(){
00625 
00626   string s;
00627 
00628   return s;
00629 
00630 }
00631 
00632 ostream& pos::operator<<(ostream& s, const PixelROCDACSettings& dacs){
00633   
00634   s << k_DACName_Vdd << "          :" << (unsigned int)dacs.Vdd_ << endl;
00635   s << k_DACName_Vana << "         :" << (unsigned int)dacs.Vana_ << endl;
00636   s << k_DACName_Vsf << "          :" << (unsigned int)dacs.Vsf_ << endl;
00637   s << k_DACName_Vcomp << "        :" << (unsigned int)dacs.Vcomp_ << endl;
00638   s << k_DACName_Vleak << "        :" << (unsigned int)dacs.Vleak_ << endl;
00639   s << k_DACName_VrgPr << "        :" << (unsigned int)dacs.VrgPr_ << endl;
00640   s << k_DACName_VwllPr << "       :" << (unsigned int)dacs.VwllPr_ << endl;
00641   s << k_DACName_VrgSh << "        :" << (unsigned int)dacs.VrgSh_ << endl;
00642   s << k_DACName_VwllSh << "       :" << (unsigned int)dacs.VwllSh_ << endl;
00643   s << k_DACName_VHldDel << "      :" << (unsigned int)dacs.VHldDel_ << endl;
00644   s << k_DACName_Vtrim << "        :" << (unsigned int)dacs.Vtrim_ << endl;
00645   s << k_DACName_VcThr << "        :" << (unsigned int)dacs.VcThr_ << endl;
00646   s << k_DACName_VIbias_bus << "   :" << (unsigned int)dacs.VIbias_bus_ << endl;
00647   s << k_DACName_VIbias_sf << "    :" << (unsigned int)dacs.VIbias_sf_ << endl;
00648   s << k_DACName_VOffsetOp << "    :" << (unsigned int)dacs.VOffsetOp_ << endl;
00649   s << k_DACName_VbiasOp << "      :" << (unsigned int)dacs.VbiasOp_ << endl;
00650   s << k_DACName_VOffsetRO << "    :" << (unsigned int)dacs.VOffsetRO_ << endl;
00651   s << k_DACName_VIon << "         :" << (unsigned int)dacs.VIon_ << endl;
00652   s << k_DACName_VIbias_PH << "    :" << (unsigned int)dacs.VIbias_PH_ << endl;
00653   s << k_DACName_VIbias_DAC << "   :" << (unsigned int)dacs.VIbias_DAC_ << endl;
00654   s << k_DACName_VIbias_roc << "   :" << (unsigned int)dacs.VIbias_roc_ << endl;
00655   s << k_DACName_VIColOr << "      :" << (unsigned int)dacs.VIColOr_ << endl;
00656   s << k_DACName_Vnpix << "        :" << (unsigned int)dacs.Vnpix_ << endl;
00657   s << k_DACName_VsumCol << "      :" << (unsigned int)dacs.VsumCol_ << endl;
00658   s << k_DACName_Vcal << "         :" << (unsigned int)dacs.Vcal_ << endl;
00659   s << k_DACName_CalDel << "       :" << (unsigned int)dacs.CalDel_ << endl;
00660   s << k_DACName_TempRange << "    :" << (unsigned int)dacs.TempRange_ << endl;
00661   s << k_DACName_WBC << "          :" << (unsigned int)dacs.WBC_ << endl;
00662   s << k_DACName_ChipContReg << "  :" << (unsigned int)dacs.ChipContReg_ << endl;
00663   
00664   return s;
00665 
00666 }
00667 
00668 //Added by Umesh
00669 void PixelROCDACSettings::setDac(string dacName, int dacValue){
00670   if(ToLower(dacName) == ToLower(k_DACName_Vdd)){
00671     Vdd_ = dacValue;
00672   }
00673   else if(ToLower(dacName) == ToLower(k_DACName_Vana)){
00674     Vana_ = dacValue;
00675   }
00676   else if(ToLower(dacName) == ToLower(k_DACName_Vsf)){
00677     Vsf_ = dacValue;
00678   }
00679   else if(ToLower(dacName) == ToLower(k_DACName_Vcomp)){
00680     Vcomp_ = dacValue;
00681   }
00682   else if(ToLower(dacName)==ToLower(k_DACName_Vleak)){
00683     Vleak_ = dacValue;
00684   }
00685   else if(ToLower(dacName)==ToLower(k_DACName_VrgPr)){
00686     VrgPr_ = dacValue;
00687   }
00688   else if(ToLower(dacName)==ToLower(k_DACName_VwllPr)){
00689     VwllPr_ = dacValue;
00690   }
00691   else if(ToLower(dacName)==ToLower(k_DACName_VrgSh)){
00692     VrgSh_ = dacValue;
00693   }
00694   else if(ToLower(dacName)==ToLower(k_DACName_VwllSh)){
00695     VwllSh_ = dacValue;
00696   }
00697   else if(ToLower(dacName)==ToLower(k_DACName_VHldDel)){
00698     VHldDel_ = dacValue;
00699   }
00700   else if(ToLower(dacName)==ToLower(k_DACName_Vtrim)){
00701     Vtrim_ = dacValue;
00702   }
00703   else if(ToLower(dacName)==ToLower(k_DACName_VcThr)){
00704     VcThr_ = dacValue;
00705   }
00706   else if(ToLower(dacName)==ToLower(k_DACName_VIbias_bus)){
00707     VIbias_bus_ = dacValue;
00708   }
00709   else if(ToLower(dacName)==ToLower(k_DACName_VIbias_sf)){
00710     VIbias_sf_ = dacValue;
00711   }
00712   else if(ToLower(dacName)==ToLower(k_DACName_VOffsetOp)){
00713     VOffsetOp_ = dacValue;
00714   }
00715   else if(ToLower(dacName)==ToLower(k_DACName_VbiasOp)){
00716     VbiasOp_ = dacValue;
00717   }
00718   else if(ToLower(dacName)==ToLower(k_DACName_VOffsetRO)){
00719     VOffsetRO_ = dacValue;
00720   }
00721   else if(ToLower(dacName)==ToLower(k_DACName_VIon)){
00722     VIon_ = dacValue;
00723   }
00724   else if(ToLower(dacName)==ToLower(k_DACName_VIbias_PH)){
00725     VIbias_PH_ = dacValue;
00726   }
00727   else if(ToLower(dacName)==ToLower(k_DACName_VIbias_DAC)){
00728     VIbias_DAC_ = dacValue;
00729   }
00730   else if(ToLower(dacName)==ToLower(k_DACName_VIbias_roc)){
00731     VIbias_roc_ = dacValue;
00732   }
00733   else if(ToLower(dacName)==ToLower(k_DACName_VIColOr)){
00734     VIColOr_ = dacValue;
00735   }
00736   else if(ToLower(dacName)==ToLower(k_DACName_Vnpix)){;
00737     Vnpix_ = dacValue;
00738   }
00739   else if(ToLower(dacName)==ToLower(k_DACName_VsumCol)){
00740     VsumCol_ = dacValue;
00741   }
00742   else if(ToLower(dacName)==ToLower(k_DACName_Vcal)){
00743     Vcal_ = dacValue;
00744   }
00745   else if(ToLower(dacName)==ToLower(k_DACName_CalDel)){
00746     CalDel_ = dacValue;
00747   }
00748   else if(ToLower(dacName)==ToLower(k_DACName_TempRange)){
00749     TempRange_ = dacValue;
00750   }
00751   else if(ToLower(dacName)==ToLower(k_DACName_WBC)){
00752     WBC_ = dacValue;
00753   }
00754   else if(ToLower(dacName)==ToLower(k_DACName_ChipContReg)){
00755     ChipContReg_ = dacValue;
00756   }
00757   else
00758   {
00759     cout << "ERROR in PixelROCDACSettings::setDac: DAC name " << dacName << " does not exist." << endl;
00760     assert(0);
00761   }
00762 
00763 }
00764 
00765 unsigned int PixelROCDACSettings::getDac(string dacName) const {
00766   
00767   if(dacName == k_DACName_Vdd){
00768     return Vdd_;
00769   }
00770   else if(dacName == k_DACName_Vana){
00771     return Vana_;
00772   }
00773   else if(dacName == k_DACName_Vsf){
00774     return Vsf_;
00775   }
00776   else if(dacName == k_DACName_Vcomp){
00777     return Vcomp_;
00778   }
00779   else if(dacName == k_DACName_Vleak){
00780     return Vleak_;
00781   }
00782   else if(dacName == k_DACName_VrgPr){
00783     return VrgPr_;
00784   }
00785   else if(dacName == k_DACName_VwllPr){
00786     return VwllPr_;
00787   }
00788   else if(dacName == k_DACName_VrgSh){
00789     return VrgSh_;
00790   }
00791   else if(dacName == k_DACName_VwllSh){
00792     return VwllSh_;
00793   }
00794   else if(dacName == k_DACName_VHldDel){
00795     return VHldDel_;
00796   }
00797   else if(dacName == k_DACName_Vtrim){
00798     return Vtrim_;
00799   }
00800   else if(dacName == k_DACName_VcThr){
00801     return VcThr_;
00802   }
00803   else if(dacName == k_DACName_VIbias_bus){
00804     return VIbias_bus_;
00805   }
00806   else if(dacName == k_DACName_VIbias_sf){
00807     return VIbias_sf_;
00808   }
00809   else if(dacName == k_DACName_VOffsetOp){
00810     return VOffsetOp_;
00811   }
00812   else if(dacName == k_DACName_VbiasOp){
00813     return VbiasOp_;
00814   }
00815   else if(dacName == k_DACName_VOffsetRO){
00816     return VOffsetRO_;
00817   }
00818   else if(dacName == k_DACName_VIon){
00819     return VIon_;
00820   }
00821   else if(dacName == k_DACName_VIbias_PH){
00822     return VIbias_PH_;
00823   }
00824   else if(dacName == k_DACName_VIbias_DAC){
00825     return VIbias_DAC_;
00826   }
00827   else if(dacName == k_DACName_VIbias_roc){
00828     return VIbias_roc_;
00829   }
00830   else if(dacName == k_DACName_VIColOr){
00831     return VIColOr_;
00832   }
00833   else if(dacName == k_DACName_Vnpix){
00834     return Vnpix_;
00835   }
00836   else if(dacName == k_DACName_VsumCol){
00837     return VsumCol_;
00838   }
00839   else if(dacName == k_DACName_Vcal){
00840     return Vcal_;
00841   }
00842   else if(dacName == k_DACName_CalDel){
00843     return CalDel_;
00844   }
00845   else if(dacName == k_DACName_TempRange){
00846     return TempRange_;
00847   }
00848   else if(dacName == k_DACName_WBC){
00849     return WBC_;
00850   }
00851   else if(dacName == k_DACName_ChipContReg){
00852     return ChipContReg_;
00853   }
00854   else {
00855     cout << "ERROR in PixelROCDACSettings::getDac: DAC name " << dacName << " does not exist." << endl;
00856     assert(0);
00857   }
00858 }                         
00859 
00860 
00861 string PixelROCDACSettings::ToLower(string generic)
00862 {
00863   string result ;
00864   for(unsigned int i = 0; i < generic.length() ; i++)
00865     {
00866       result.append(1,(char)tolower(generic[i]) );
00867     }
00868   return result ;
00869 }