Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TMuiHVMask.cxx

Go to the documentation of this file.
00001 #include<TMuiHVMask.h>
00002 #include<TMuiKeyGen.h>
00003 #include<fstream>
00004 #include<sstream>
00005 #include<MUIOO.h>
00006 #include<boost/array.hpp>
00007 #include<string>
00008 #include<MutGeom.h>
00009 #include<MuiGeomClasses.hh>
00010 
00011 ClassImp(TMuiHVMask)
00012 
00013 // Static data members definitions
00014 //
00015 sgi::hash_map<ULong_t, double> TMuiHVMask::_map;
00016 ULong_t TMuiHVMask::_run_number = 0;
00017 bool TMuiHVMask::_use_override = false;
00018 float TMuiHVMask::_one_tube_effic = 0.65;
00019 float TMuiHVMask::_two_tube_effic = 0.93;
00020 bool TMuiHVMask::_disabled = true;
00021 int TMuiHVMask::_mask_plane = -1;
00022 std::string TMuiHVMask::_filename_north("tube_eff_north_default.txt");
00023 std::string TMuiHVMask::_filename_south("tube_eff_south_default.txt");                  
00024 
00025 
00026 bool
00027 TMuiHVMask::initialize()
00028 {  
00029   // Default filenames
00030   //
00031   boost::array<const char*,2> files = {{_filename_north.c_str(),_filename_south.c_str()}};
00032   MUTOO::PRINT(std::cout,"TMuiHVMask::Initialize");
00033   std::cout << _filename_north.c_str() << std::endl;
00034   std::cout << _filename_south.c_str() << std::endl;
00035   MUTOO::PRINT(std::cout,"**");
00036   
00037   for(size_t i=0; i<files.size(); ++i){
00038 
00039     ifstream lookup_file;    
00040 
00041     // Input file
00042     //
00043     lookup_file.open(files[i]);
00044     if(!lookup_file.is_open()) {
00045       MUIOO::TRACE("TMuiHVMask: can't find input file");
00046       continue;
00047     }
00048     
00049     // Fill the map
00050     //
00051     while(lookup_file) {
00052 
00053       UShort_t iarm=0, iplane=0, ipanel=0, iorient=0, itwopack=0;
00054       float effic=0;
00055       lookup_file >> iarm;
00056       lookup_file >> iplane;
00057       lookup_file >> ipanel;
00058       lookup_file >> iorient;
00059       lookup_file >> itwopack;
00060       lookup_file >> effic;    
00061 
00062       // Figure out how to to this correctly
00063       //
00064       if(iarm==0&&iplane==0&&ipanel==0&&iorient==0&&itwopack==0&&effic==0.0) continue;
00065 
00066       ULong_t key = TMuiKeyGen::get_key(iarm,iplane,ipanel,iorient,itwopack);
00067       
00068       // The number read is is 0, 65, 90 -- We reserve the right to adjust these
00069       // numbers hence the condition below that selects either the one tube or
00070       // two tube efficiency numbers from class data members
00071       //
00072       if(_use_override) {
00073         if(effic == 90) {
00074           _map.insert(std::make_pair(key,_two_tube_effic));
00075         } else if(effic == 65){
00076           _map.insert(std::make_pair(key,_one_tube_effic));
00077         } else if(effic == 0){
00078           _map.insert(std::make_pair(key,0));
00079         }
00080       } else {
00081         _map.insert(std::make_pair(key,effic));
00082       }
00083     }
00084     lookup_file.close();
00085   }
00086   
00087   // Message for the masses
00088   //
00089   MUIOO::PRINT(std::cout, "TMuiHVMask Initialization");
00090   std::cout << "TMuiHVMask read " << _map.size() << " entries" << std::endl;
00091   MUIOO::PRINT(std::cout, "**");
00092   
00093   return true;
00094 }
00095 
00096 
00097 double
00098 TMuiHVMask::get_effic_twopack(UShort_t arm, UShort_t plane, UShort_t panel, UShort_t orient, UShort_t twopack)
00099 {
00100   if(_disabled) return 1.0;
00101 
00102   static bool init = initialize();
00103   if(!init) return 1.0;
00104 
00105   private_map::const_iterator iter = _map.find(TMuiKeyGen::get_key(arm,plane,panel,orient,twopack));
00106   if(iter == _map.end()) {    
00107     std::ostringstream msg;
00108     msg << "TMuiHVMask no entry " << arm << " " << panel << " " << orient << " " << twopack << " "  << " entries";
00109     MUIOO::TRACE(msg.str().c_str());
00110     return _two_tube_effic;    
00111   } else {
00112     return iter->second;
00113   }
00114 }
00115 
00116 double
00117 TMuiHVMask::get_effic_hvgroup(UShort_t arm, UShort_t plane, UShort_t panel, UShort_t orient,  UShort_t hvgroup)
00118 {
00119   TMuiPanelGeo* panel_geo = TMuiGeometry::Geom()->getPanel(arm,plane,panel);    
00120   EOrient_t muid_orient = (orient==0) ? kHORIZ : kVERT;
00121   UShort_t ntwopack = panel_geo->getTwoPackCount(muid_orient);
00122 
00123   // Loop over two packs and return the effic for the first hv group
00124   //
00125   for(int twopack = 0; twopack<ntwopack; ++twopack){
00126     TMuiChannelId channel_id(arm,plane,panel,muid_orient,twopack);
00127     if(channel_id.get_HV_chain_group() == hvgroup){
00128       return get_effic_twopack(arm,plane,panel,orient,twopack);
00129     }
00130   }
00131   return 0.0;
00132 }

MUIOO: PHENIX Muon Identifier Analysis Framework. Documentation by doxygen
Last modified: