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

BlockEvent.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BlockEvent.cxx,v 1.5 2005/02/22 21:44:43 bspeak Exp $
00003 //
00004 // BlockEvent is the base class for events written to a TTree in
00005 // .rate.root and joined in a TChain together by the rate_plot program
00006 //
00007 // Author: B. Speakman 2004.09.03
00008 //
00010 #include <fstream>
00011 #include <iostream>
00012 #include <sstream>
00013 #include <string>
00014 
00015 #include "BlockEvent.h"
00016 #include "ChipEvent.h"
00017 #include "TClonesArray.h"
00018 #include "RSM.h"
00019 
00020 #include "MessageService/MsgService.h"
00021 
00022 ClassImp(BlockEvent)
00023 CVSID("$Id: BlockEvent.cxx,v 1.5 2005/02/22 21:44:43 bspeak Exp $");
00024 
00025 BlockEvent::BlockEvent() {
00026   RSMVer << "BlockEvent::BlockEvent" << endl;
00027   ChipEvents = new TClonesArray("ChipEvent",2304);
00028   this->Reset();
00029 }
00030 
00031 BlockEvent::~BlockEvent() {
00032   RSMVer << "BlockEvent::~BlockEvent" << endl;
00033   this->Reset();
00034   delete ChipEvents;
00035 }
00036 
00037 void BlockEvent::Reset() {
00038   RunNum = 0;
00039   SubRunNum = 0;
00040 
00041   Time = 0;
00042 
00043   for(int i=0; i<=ChipEvents->GetLast(); i++)
00044     if(ChipEvents->At(i))
00045       ChipEvents->At(i)->Clear();
00046   ChipEvents->Delete();
00047 
00048   this->LocalReset();
00049 }
00050 
00051 ChipEvent* BlockEvent::ChipGen(Char_t Crate,
00052                                Char_t Varc,
00053                                Char_t Vmm,
00054                                Char_t Vadc,
00055                                Char_t Vachip,
00056                                Char_t Vachan) {
00057   int ichip = IChip(Crate,Varc,Vmm,Vadc,Vachip,Vachan);
00058 
00059   ChipEvent* chip = 0;
00060   if((chip=dynamic_cast<ChipEvent*>(ChipEvents->At(ichip))))
00061     return chip;
00062 
00063   chip = new((*ChipEvents)[ichip]) ChipEvent();
00064   chip->PackLoc(Crate,Varc,Vmm,Vadc,Vachip,Vachan);
00065   return chip;
00066 }
00067 
00068 int BlockEvent::IChip(Char_t Crate,
00069                       Char_t Varc,
00070                       Char_t Vmm,
00071                       Char_t Vadc,
00072                       Char_t Vachip,
00073                       Char_t Vachan) {
00074   int ichip = Crate;
00075   ichip = Varc + NVARC*ichip;
00076   ichip = Vmm + NVMM*ichip;
00077   ichip = Vadc + NVADC*ichip;
00078   if(Vachip>=0) ichip = Vachip + NVACHIP*ichip;
00079   if(Vachan>=0) ichip = Vachan + NVACHAN*ichip;
00080   return ichip;
00081 }
00082 
00083 bool BlockEvent::IsFilled() {
00084   bool retval;
00085   retval = ((RunNum!=0)&&(Time!=0));
00086 
00087   return retval;
00088 }
00089 
00090 void BlockEvent::GenerateAllChips() {
00091   for(int icrate=0;icrate<NCRATE;icrate++)
00092   for(int ivarc=0;ivarc<NVARC;ivarc++)
00093   for(int ivmm=0;ivmm<NVMM;ivmm++)
00094   for(int ivadc=0;ivadc<NVADC;ivadc++)
00095   for(int ivachip=0;ivachip<NVACHIP;ivachip++)
00096   if(! this->ChipGen(icrate,ivarc,ivmm,ivadc,ivachip))
00097     RSMWar << "ChipGen Failed" << endl;
00098 }
00099 
00100 void BlockEvent::CheckChips() {
00101   bool fix_this = false;
00102   for(int i=0;i<ChipEvents->GetLast();i++)
00103   if(! ChipEvents->At(i)) fix_this = true;
00104 
00105   if(fix_this) ChipEvents->Compress();
00106 
00107   fix_this=false;
00108   for(int i=0;i<ChipEvents->GetLast();i++)
00109   if(! ChipEvents->At(i)) fix_this = true;
00110 
00111   if(fix_this) cout << "Compressing ChipEvents Failed" << endl;
00112 }

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