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

FillNPlane.cxx

Go to the documentation of this file.
00001 // $Id: FillNPlane.cxx,v 1.2 2008/03/31 17:25:35 rustem Exp $
00002 
00003 // C++
00004 #include <vector>
00005 
00006 // MINOS
00007 #include "Registry/Registry.h"
00008 
00009 //Local
00010 #include "PhysicsNtuple/Factory.h"
00011 
00012 //Local
00013 #include "FillNPlane.h"
00014 
00015 REGISTER_ANP_OBJECT(AlgSnarl,FillNPlane)
00016 REGISTER_ANP_OBJECT(AlgEvent,FillNPlane)
00017 
00018 using namespace std;
00019 
00020 //---------------------------------------------------------------------------------------
00021 Anp::FillNPlane::FillNPlane()
00022    :fKeyBase(4900),
00023     fMinStripAdc(200.0)
00024 {
00025 }
00026 
00027 //------------------------------------------------------------------------------------------
00028 Anp::FillNPlane::~FillNPlane()
00029 {
00030 }
00031 
00032 //------------------------------------------------------------------------------------------
00033 bool Anp::FillNPlane::Run(Record &record)
00034 {
00035    for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00036    {
00037       FillNPlane::Run(*ievent, record, true);
00038    }
00039 
00040    return true;
00041 }
00042 
00043 //----------------------------------------------------------------------
00044 bool Anp::FillNPlane::Run(Event &event, const Record& record, const bool pass)
00045 { 
00046    //
00047    // Count number of planes above pulse height cut
00048    //
00049    if(!pass) return true;
00050 
00051    //
00052    // First loop: collect maximum strip pulse height in each plane
00053    //
00054    vector<DataNPlane> dvec;
00055 
00056    double dsum = 0.0, asum = 0.0;
00057    for(StripIter istrip = record.StripBeg(); istrip != record.StripEnd(); ++istrip)
00058    {
00059       if(!istrip -> MatchEvt(event.EventIndex()))
00060       {
00061          continue;
00062       }
00063       
00064       asum += istrip -> SigCor();
00065 
00066       if(istrip -> SigCor() > fMinStripAdc)
00067       {
00068          dvec.push_back(Anp::DataNPlane(*istrip));
00069          dsum += istrip -> SigCor();
00070       }
00071    }
00072    
00073    //
00074    // No strips above threshold found
00075    //
00076    if(dvec.empty())
00077    {
00078       event.Add(fKeyBase + 2, static_cast<float>(0.0));
00079       event.Add(fKeyBase + 3, static_cast<float>(0.0));
00080       event.Add(fKeyBase + 4, static_cast<float>(0.0));
00081       event.Add(fKeyBase + 5, static_cast<float>(0.0));
00082       event.Add(fKeyBase + 6, static_cast<float>(0.0));
00083       return true;
00084    }
00085 
00086    //
00087    // Sort data by plane number
00088    //
00089    std::sort(dvec.begin(), dvec.end());
00090 
00091    double min_time = dvec.front().time;
00092    double max_time = dvec.front().time;
00093    vector<short> pvec;
00094 
00095    for(vector<DataNPlane>::const_iterator idata = dvec.begin(); idata != dvec.end(); ++idata)
00096    {
00097       min_time = min<double>(min_time, idata -> time);
00098       max_time = max<double>(max_time, idata -> time);
00099       
00100       if(std::find(pvec.begin(), pvec.end(), idata -> plane) == pvec.end())
00101       {
00102          pvec.push_back(idata -> plane);
00103       }
00104    }
00105    
00106    //
00107    // Sort plane numbers
00108    //
00109    std::sort(pvec.begin(), pvec.end());
00110 
00111    short icount = 1, ncount = 1, nsize = pvec.size();
00112    for(int i = 1; i < nsize; ++i)
00113    {
00114       if(pvec[i-1] + 1 == pvec[i])
00115       {
00116          ++icount;
00117       }
00118       else
00119       {
00120          ncount = std::max<short>(ncount, icount);
00121          icount = 1;
00122       }
00123    }
00124 
00125    //
00126    // Maximum number of contiguous planes
00127    //
00128    ncount = std::max<short>(ncount, icount);
00129    
00130    event.Add(fKeyBase + 1, static_cast<float>(1.0e9*(max_time - min_time)));
00131    event.Add(fKeyBase + 2, static_cast<float>(dvec.size()));
00132    event.Add(fKeyBase + 3, static_cast<float>(dsum));
00133    event.Add(fKeyBase + 4, static_cast<float>(pvec.size()));
00134    event.Add(fKeyBase + 5, static_cast<float>(ncount));
00135 
00136    if(asum > 0.0)
00137    {
00138       event.Add(fKeyBase + 6, static_cast<float>(dsum/asum));
00139    }
00140 
00141    return true;
00142 }
00143 
00144 //-----------------------------------------------------------------------------
00145 void Anp::FillNPlane::Config(const Registry &reg)
00146 {
00147    //
00148    // Configure self
00149    //
00150 
00151    reg.Get("FillNPlaneKeyBase",     fKeyBase);
00152    reg.Get("FillNPlaneMinStripAdc", fMinStripAdc);
00153 
00154    if(reg.KeyExists("PrintConfig"))
00155    {
00156       cout << "FillNPlane::Config" << endl
00157            << "   KeyBase = " << fKeyBase << endl
00158            << "   MinStripAdc = " << fMinStripAdc << endl;
00159    }
00160 }
00161 
00162 //-----------------------------------------------------------------------------
00163 Anp::DataNPlane::DataNPlane()
00164    :plane(-1),
00165     pulse(-1.0),
00166     time(-1.0)
00167 {
00168 }
00169 
00170 //-----------------------------------------------------------------------------
00171 Anp::DataNPlane::DataNPlane(const Strip &strip)
00172    :plane(strip.GetPlane()),
00173     pulse(strip.SigCor()),
00174     time(strip.Time())
00175 {
00176 }
00177 
00178 //-----------------------------------------------------------------------------
00179 bool Anp::operator<(const DataNPlane &lhs, const DataNPlane &rhs)
00180 {
00181    return (lhs.plane < rhs.plane);
00182 }
00183 
00184 //-----------------------------------------------------------------------------
00185 bool Anp::operator==(const DataNPlane &lhs, const DataNPlane &rhs)
00186 {
00187    return (lhs.plane == rhs.plane);
00188 }

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