PmtMap Class Reference

#include <PmtMap.h>

List of all members.

Public Member Functions

 PmtMap ()
bool BuildMap (const vector< const RawDigit * > &digitlist, const vector< int > &digitindex, const VldContext *vldc)
bool BuildMap (const TClonesArray *rawdigits)
bool Merge (PmtMap &lhs, PmtMap &rhs)
void PrintSummary ()

Public Attributes

vector< ElecChannelchannel
ElecType::EElecType elecType

Detailed Description

Definition at line 24 of file PmtMap.h.


Constructor & Destructor Documentation

PmtMap::PmtMap (  ) 

Definition at line 44 of file PmtMap.cxx.

00045 {
00046 }


Member Function Documentation

bool PmtMap::BuildMap ( const TClonesArray *  rawdigits  ) 

Definition at line 119 of file PmtMap.cxx.

References ElecChannel::adc, channel, digit(), elecType, Msg::kDebug, Msg::kError, ElecType::kQIE, ElecType::kVA, MSG, ElecChannel::rcid, ElecChannel::tdc, and ElecChannel::valid.

00120 {  
00121   if(rawdigits->GetEntries()==0) return false;
00122   elecType = ((RawDigitInfo*) rawdigits->At(0))->rcid.GetElecType();
00123   if(elecType==ElecType::kVA){
00124     TIter iter(rawdigits);
00125     while(RawDigitInfo *digit = dynamic_cast<RawDigitInfo*>(iter())){
00126       bool found = 0;
00127       const unsigned int nchannel = channel.size();
00128       for(unsigned int ichannel = 0; ichannel<nchannel; ichannel++){
00129         if(channel[ichannel].rcid == digit->rcid){      
00130           MSG("EvtMrg",Msg::kError) << "Found duplicate RCID RawDigitsInfo" <<endl;      
00131           found = 1;
00132         }
00133       }
00134       ElecChannel tmpch;
00135       tmpch.rcid = digit->rcid;
00136       tmpch.tdc  = (int)digit->tdc;
00137       tmpch.adc  = (int)digit->adc;
00138       tmpch.valid = 1;
00139       channel.push_back(tmpch);
00140     }
00141   }
00142   else if(elecType==ElecType::kQIE){
00143     TIter iter(rawdigits);
00144     while(RawDigitInfo *digit = dynamic_cast<RawDigitInfo*>(iter())  ){
00145       bool found = 0;
00146       const unsigned int nchannel = channel.size();
00147       for(unsigned int ichannel = 0; ichannel<nchannel; ichannel++){
00148         if(channel[ichannel].rcid == digit->rcid && 
00149            channel[ichannel].tdc == digit->tdc){        
00150           MSG("EvtMrg",Msg::kDebug) << "Found duplicate RCID RawDigits with same TDC (ADC) " 
00151                                     << channel[ichannel].tdc << " (" 
00152                                     << channel[ichannel].adc << ") cf " 
00153                                     << digit->tdc << " (" << digit->adc << ")" << endl;   
00154           // if we we're generating electrons independently
00155           // these digits would already be merged, so merge now:
00156           channel[ichannel].adc += (int)digit->adc;
00157           found = 1;
00158           break;
00159         }
00160       }
00161       if(!found) {
00162         ElecChannel tmpch;
00163         tmpch.rcid = digit->rcid;
00164         tmpch.tdc  = (int)digit->tdc;
00165         tmpch.adc  = (int)digit->adc;
00166         tmpch.valid = 1;
00167         channel.push_back(tmpch);
00168       }
00169     }
00170   }
00171   return true;
00172 }

bool PmtMap::BuildMap ( const vector< const RawDigit * > &  digitlist,
const vector< int > &  digitindex,
const VldContext vldc 
)

Definition at line 49 of file PmtMap.cxx.

References ElecChannel::adc, channel, elecType, PlexSEIdAltL::GetPlane(), PlexHandle::GetSEIdAltL(), ElecChannel::index, Msg::kError, ElecType::kQIE, ElecType::kVA, MSG, ElecChannel::rcid, ElecChannel::tdc, and ElecChannel::valid.

Referenced by AlgMergeEvent::RunAlg().

00051 {
00052   //set elecType:
00053   if(digitlist.size()==0) return false;
00054   elecType = digitlist[0]->GetChannel().GetElecType();
00055   //fill vector:
00056   if(elecType==ElecType::kVA){
00057     const unsigned int ndigit = digitlist.size(); 
00058     for(unsigned int idigit= 0 ; idigit<ndigit; idigit++){    
00059       RawChannelId rcid = digitlist[idigit]->GetChannel();
00060       Int_t        tdc  = digitlist[idigit]->GetTDC();
00061       Int_t        adc  = digitlist[idigit]->GetADC();
00062       bool found = 0;
00063       const unsigned int nchannel = channel.size();
00064       for(unsigned int ichannel = 0; ichannel<nchannel; ichannel++){
00065         if(channel[ichannel].rcid == rcid){
00066           MSG("EvtMrg",Msg::kError) << "Found duplicate RCID RawDigits:" 
00067                                     << channel[ichannel].tdc << "  cf " 
00068                                     << digitlist[idigit]->GetTDC() << endl;
00069           found = 1;
00070         }
00071       }
00072       ElecChannel tmpch;
00073       tmpch.rcid = rcid;
00074       tmpch.tdc  = tdc;
00075       tmpch.adc  = adc;
00076       tmpch.valid = 1;
00077       tmpch.index = digit_index[idigit];
00078       channel.push_back(tmpch);
00079     }  
00080   }
00081   else if(elecType==ElecType::kQIE){
00082     PlexHandle ph(*vldc);
00083     const unsigned int ndigit = digitlist.size();
00084     for(unsigned int idigit= 0 ; idigit<ndigit; idigit++){
00085       RawChannelId rcid = digitlist[idigit]->GetChannel();
00086       Int_t        tdc  = digitlist[idigit]->GetTDC();
00087       Int_t        adc  = digitlist[idigit]->GetADC();
00088       Int_t        pln  = ph.GetSEIdAltL(rcid).GetPlane();
00089       bool found = 0;
00090       const unsigned int nchannel = channel.size();
00091       for(unsigned int ichannel = 0; ichannel<nchannel; ichannel++){
00092         if(channel[ichannel].rcid == rcid && channel[ichannel].tdc == tdc){
00093           if(pln>=121) found = 1;  //spectrometer
00094           else { 
00095             MSG("EvtMrg",Msg::kError) << "Found duplicate RCID RawDigits with same TDC (ADC) " 
00096                                       << channel[ichannel].tdc << " (" 
00097                                       << channel[ichannel].adc << ") cf " 
00098                                       << tdc << " (" << adc << ") in plane " << pln << endl;
00099             
00100           }
00101         }
00102       }
00103       // not going to add multiple spectrometer digits; these come from previous reco pass
00104       if(!found){
00105         ElecChannel tmpch;
00106         tmpch.rcid = rcid;
00107         tmpch.tdc  = tdc;
00108         tmpch.adc  = adc;
00109         tmpch.valid = 1;
00110         tmpch.index = digit_index[idigit];
00111         channel.push_back(tmpch);
00112       }
00113     }
00114   }
00115   return true;
00116 }

bool PmtMap::Merge ( PmtMap lhs,
PmtMap rhs 
)

Definition at line 175 of file PmtMap.cxx.

References ElecChannel::adc, channel, elecType, ElecChannel::index, ElecType::kQIE, ElecType::kVA, Msg::kVerbose, MSG, ElecChannel::rcid, ElecChannel::tdc, and ElecChannel::valid.

Referenced by AlgMergeEvent::RunAlg().

00175                                           {
00176   //look at lhs and add in any overlapping digits
00177   if(lhs.elecType!=rhs.elecType) return false;
00178   elecType = lhs.elecType;
00179   if(elecType==ElecType::kVA){
00180     Int_t max_index = 0;
00181     const unsigned int nlhs = lhs.channel.size();
00182     const unsigned int nrhs = rhs.channel.size();  
00183     for(unsigned int ilhs=0; ilhs<nlhs; ilhs++){   
00184       ElecChannel tmp;
00185       tmp.rcid = lhs.channel[ilhs].rcid;
00186       tmp.adc = lhs.channel[ilhs].adc;
00187       tmp.tdc = lhs.channel[ilhs].tdc;
00188       tmp.index = lhs.channel[ilhs].index;
00189       tmp.valid = 1;        
00190       for(unsigned int irhs=0; irhs<nrhs; irhs++){
00191         if(lhs.channel[ilhs].rcid == rhs.channel[irhs].rcid && rhs.channel[irhs].valid){
00192           MSG("EvtMrg",Msg::kVerbose) 
00193             << "Merging digits Dt:" << abs(tmp.tdc  - rhs.channel[irhs].tdc) 
00194             <<  "  Different time:" 
00195             << ((abs(tmp.tdc  - rhs.channel[irhs].tdc)>3200)?" Okay " : " combine" ) << endl;
00196           if(abs(tmp.tdc  - rhs.channel[irhs].tdc)<3200){
00197             tmp.adc+=rhs.channel[irhs].adc;
00198             if(rhs.channel[irhs].tdc< tmp.tdc) tmp.tdc = rhs.channel[irhs].tdc;
00199             if(rhs.channel[irhs].index!=-1) tmp.index = rhs.channel[irhs].index;
00200             rhs.channel[irhs].valid = 0;
00201           }
00202         }
00203       }
00204       this->channel.push_back(tmp);
00205       if(tmp.index>max_index) max_index = tmp.index;
00206     }
00207 
00208     //
00209     //pick up any remaining digits
00210     //
00211     for(unsigned int irhs=0; irhs<nrhs; irhs++){
00212       if(rhs.channel[irhs].valid){
00213         ElecChannel tmp;
00214         tmp.rcid = rhs.channel[irhs].rcid;
00215         tmp.adc = rhs.channel[irhs].adc;
00216         tmp.tdc = rhs.channel[irhs].tdc;
00217         tmp.valid = 1;        
00218         tmp.index = max_index; //rhs.channel[irhs].index;
00219         this->channel.push_back(tmp);
00220       }
00221     }
00222   }
00223   else if(elecType==ElecType::kQIE){
00224     const unsigned int nlhs = lhs.channel.size();
00225     const unsigned int nrhs = rhs.channel.size();
00226     Int_t max_index = 0;
00227     for(unsigned int ilhs=0; ilhs<nlhs; ilhs++){
00228       ElecChannel tmp;
00229       tmp.rcid = lhs.channel[ilhs].rcid;
00230       tmp.adc = lhs.channel[ilhs].adc;
00231       tmp.tdc = lhs.channel[ilhs].tdc;
00232       tmp.index = lhs.channel[ilhs].index;
00233       tmp.valid = 1;
00234       for(unsigned int irhs=0; irhs<nrhs; irhs++){
00235         if(lhs.channel[ilhs].rcid == rhs.channel[irhs].rcid && 
00236            lhs.channel[ilhs].tdc  == rhs.channel[irhs].tdc && 
00237            rhs.channel[irhs].valid){
00238           MSG("EvtMrg",Msg::kVerbose) << "Merging digits RCID = " << tmp.rcid 
00239                                       << " TDC = " << tmp.tdc << endl;
00240           tmp.adc+=rhs.channel[irhs].adc;
00241           rhs.channel[irhs].valid = 0;
00242         }
00243     }
00244       this->channel.push_back(tmp);
00245       if(tmp.index>max_index) max_index = tmp.index;
00246     }
00247     
00248     //
00249     //pick up any remaining digits
00250     //
00251     for(unsigned int irhs=0; irhs<nrhs; irhs++){
00252       if(rhs.channel[irhs].valid){
00253         ElecChannel tmp;
00254         tmp.rcid = rhs.channel[irhs].rcid;
00255         tmp.adc = rhs.channel[irhs].adc;
00256         tmp.tdc = rhs.channel[irhs].tdc;
00257         tmp.valid = 1;
00258         tmp.index = max_index;
00259         this->channel.push_back(tmp);
00260         rhs.channel[irhs].valid = 0;
00261       }
00262     }
00263   }
00264   return true;  
00265 }

void PmtMap::PrintSummary (  ) 

Definition at line 267 of file PmtMap.cxx.

References channel.

00267                          {
00268   const unsigned int nchannel = channel.size();
00269   for(unsigned int ichannel = 0; ichannel<nchannel; ichannel++){
00270     channel[ichannel].PrintSummary();
00271   }
00272 }


Member Data Documentation

Definition at line 31 of file PmtMap.h.

Referenced by BuildMap(), Merge(), PrintSummary(), and AlgMergeEvent::RunAlg().

Definition at line 32 of file PmtMap.h.

Referenced by BuildMap(), and Merge().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1