Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LIPatternFinderFancy.cxx

Go to the documentation of this file.
00001 
00029 #include <TH1D.h>
00030 #include <TH2D.h>
00031 
00032 #include "CandDigit/CandDigitHandle.h"
00033 #include "CandDigit/CandDigitListHandle.h"
00034 #include "DatabaseInterface/DbiResultPtr.h"
00035 #include "MessageService/MsgService.h"
00036 
00037 #include "LIPatternFinderFancy.h"
00038 
00039 ClassImp(LIPatternFinderFancy)
00040 
00041 //_____________________________________________________________________
00042 CVSID(
00043  "$Id: LIPatternFinderFancy.cxx,v 1.3 2004/04/07 20:44:30 costas Exp $"
00044 );
00045 //_____________________________________________________________________
00046 LIPatternFinderFancy::LIPatternFinderFancy()
00047 {
00048   MSG("LIPatternFinder", Msg::kVerbose)
00049                                 << "LIPatternFinderFancy ctor" << endl;
00050   DefaultConfig();
00051 }
00052 //_____________________________________________________________________
00053 LIPatternFinderFancy::~LIPatternFinderFancy()
00054 {
00055   MSG("LIPatternFinder", Msg::kVerbose)
00056                                 << "LIPatternFinderFancy dtor" << endl;
00057 }
00058 //_____________________________________________________________________
00059 void LIPatternFinderFancy::DefaultConfig(void)
00060 {
00061   fFractionalChargeThreshold = 0.75;
00062 }  
00063 //_____________________________________________________________________
00064 void LIPatternFinderFancy::Configure(const Registry & registry)
00065 {
00066   double tmpd;
00067   
00068   if (registry.Get("FractionalChargeThreshold", tmpd))
00069                                      fFractionalChargeThreshold = tmpd;
00070 }  
00071 //_____________________________________________________________________
00072 bool LIPatternFinderFancy::IsLightInjectionTrash(
00073                                             CandDigitListHandle * cdlh)
00074 {
00075   // Use the database interface, read database tables, save results in
00076   // STL maps for easy lookup
00077   
00078   BuildPlexMaps(cdlh); 
00079 
00080   TH2D * hPulserBoxLed = new TH2D("hPulserBoxLed",
00081         "(pulser box, led) q-weighted distribution", 16,0,16,20,0,20);
00082 
00083   CandDigitHandleItr cdh_iter ( cdlh->GetDaughterIterator() );
00084 
00085   double total_charge = 0;
00086   
00087   while ( CandDigitHandle * digit = cdh_iter.Ptr() ) {
00088 
00089     total_charge += digit->GetCharge();
00090 
00091     const PlexSEIdAltL & seid_altl = digit->GetPlexSEIdAltL();    
00092 
00093     seid_altl.SetFirst();
00094 
00095     while( seid_altl.IsValid() ) {
00096 
00097        const PlexSEIdAltLItem & seid_item = seid_altl.GetCurrentItem();
00098 
00099        PlexStripEndId seid = seid_item.GetSEId();
00100 
00101        const PlexLedId * led_id = FindLedIdFromStripEndId(seid);
00102 
00103        if(led_id) {
00104 
00105           MSG("LIPatternFinder", Msg::kDebug)
00106              << " Pbox: " << led_id->GetPulserBox()
00107              << " LED:  " << led_id->GetLedInBox()
00108              << " Q: "    << digit->GetCharge() << endl;
00109 
00110           hPulserBoxLed->Fill(led_id->GetPulserBox(),
00111                            led_id->GetLedInBox(), digit->GetCharge());           
00112        } // if led-id
00113                 
00114        seid_altl.Next();
00115         
00116     } // loop over SEIdAltL  
00117                        
00118     cdh_iter.Next();
00119     
00120   } //loop over CandDigitList
00121 
00122   bool   is_LI = false;
00123   
00124   double max_bin_content  = hPulserBoxLed -> GetMaximum();
00125 
00126   if(total_charge > 0) {
00127 
00128      double fractional_pulse_height  =
00129                                     max_bin_content  / total_charge;
00130                                 
00131      is_LI = (fractional_pulse_height > fFractionalChargeThreshold);
00132 
00133      MSG("LIPatternFinder", Msg::kDebug)
00134           << " Fractional Pulse Height: " << fractional_pulse_height
00135           << endl;
00136   }  
00137   delete hPulserBoxLed;         
00138                            
00139   return is_LI;
00140 }
00141 //_____________________________________________________________________
00142 void LIPatternFinderFancy::BuildPlexMaps(CandDigitListHandle * cdlh)
00143 {
00144   MSG("LIPatternFinder", Msg::kVerbose)
00145                       << "LIPatternFinderFancy::BuildPlexMaps" << endl;
00146 
00147   //-- Get VldContext from input data
00148 
00149   const VldContext * vld = cdlh->GetVldContext();
00150 
00151   //-- Use DatabseInterface to extract Plex information from the dbase
00152 
00153   MSG("LIPatternFinder", Msg::kVerbose)
00154           << "Extracting Plex information from the data-base" << endl;
00155 
00156   DbiResultPtr<PlexStripEndToLed>       strip_to_led   (*vld);
00157 
00158   MSG("LIPatternFinder", Msg::kVerbose)
00159        << "STRIP->LED / nrows: " << strip_to_led.GetNumRows() << endl;
00160 
00161   //-- loop over STRIP END -> LED rows
00162   for(unsigned int s2l_irow = 0;
00163                   s2l_irow < strip_to_led.GetNumRows(); s2l_irow++) {
00164 
00165      const PlexStripEndToLed * s2l_row =
00166                                        strip_to_led.GetRow(s2l_irow);
00167 
00168      PlexStripEndId stripend_id = s2l_row->GetPlexStripEndId();
00169      PlexLedId      led_id      = s2l_row->GetPlexLedId();
00170 
00171      fStrip2LedMap.insert(
00172            map<PlexStripEndId, PlexLedId>::value_type(
00173                                               stripend_id, led_id));
00174   }
00175   MSG("LIPatternFinder", Msg::kVerbose)
00176              << "PlexStripEndId -> PlexLedId map filled in" << endl;
00177 }
00178 //_____________________________________________________________________
00179 const PlexLedId * LIPatternFinderFancy::FindLedIdFromStripEndId(
00180                               const PlexStripEndId & stripend_id) const
00181 {
00182   map<PlexStripEndId, PlexLedId>::const_iterator strip2led_iter;
00183 
00184   for(strip2led_iter = fStrip2LedMap.begin();
00185              strip2led_iter != fStrip2LedMap.end(); ++strip2led_iter) {
00186 
00187       PlexStripEndId curr_stripend_id = strip2led_iter->first;
00188 
00189       if( curr_stripend_id.IsSameStripEnd(stripend_id) )
00190                                       return &(strip2led_iter->second);
00191   }
00192   return 0;
00193 }
00194 //_____________________________________________________________________

Generated on Mon Feb 15 11:06:52 2010 for loon by  doxygen 1.3.9.1