Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

TSubEvent.cxx

Go to the documentation of this file.
00001 //  TSubEvent.cxx.
00011 #include <iostream>
00012 
00013 #include "TSubEvent.h"
00014 
00015 using std::cout;
00016 using std::endl;
00017 using std::vector;
00018 
00019 // Class implementation tag for ROOT.
00020 //
00021 ClassImp(TSubEvent)
00022 
00023 TSubEvent::TSubEvent()
00024 {
00027 }
00028 
00029 TSubEvent::TSubEvent(const vector<TDataItem<UShort_t> > &adcs,
00030                      const vector<TDataItem<UShort_t> > &tdcs)
00031 {
00038   fAdcs = adcs;
00039   fTdcs = tdcs;
00040 }
00041 
00042 TSubEvent::~TSubEvent()
00043 {
00046 }
00047 
00048 void TSubEvent::Print(const Char_t *option) const
00049 {
00055   cout << "TSubEvent:" << endl
00056        << "ADCs = " << fAdcs.size() << endl;
00057   if (option[0] == 'a')
00058     for (UInt_t i = 0; i < fAdcs.size(); i++)
00059       fAdcs[i].Print("adc: ");
00060   cout << "TDCs = " << fTdcs.size() << endl;
00061   if (option[0] == 'a')
00062     for (UInt_t i = 0; i < fTdcs.size(); i++)
00063       fTdcs[i].Print("tdc: ");
00064 }
00065 
00066 vector<TDataItem<UShort_t> >
00067 TSubEvent::GetChannelValues(const vector<TDataItem<UShort_t> > &module,
00068                             UShort_t channel) const
00069 {
00080   ptrdiff_t n = count_if(module.begin(), module.end(),
00081                          EqualChannel<UShort_t>(channel));
00082   vector<TDataItem<UShort_t> > items(n);
00083   remove_copy_if(module.rbegin(), module.rend(),
00084                  items.begin(), not1(EqualChannel<UShort_t>(channel)));
00085   return items;
00086 }
00087 
00088 UShort_t
00089 TSubEvent::GetChannelValue(const vector<TDataItem<UShort_t> > &module,
00090                            UShort_t channel) const
00091 {
00102   vector<TDataItem<UShort_t> >::const_reverse_iterator item =
00103     find_if(module.rbegin(), module.rend(), EqualChannel<UShort_t>(channel));
00104   return item != module.rend() ? item->GetValue() : 0;
00105 }

Generated on Mon Jan 8 11:54:31 2007 for DragonRoot by  doxygen 1.3.9.1