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

AlgFarDetDataQuality.cxx

Go to the documentation of this file.
00001 
00002 #include "AlgFarDetDataQuality.h"
00003 
00004 #include "Algorithm/AlgConfig.h"
00005 #include "Algorithm/AlgFactory.h"
00006 #include "Algorithm/AlgHandle.h"
00007 #include "CandData/CandRecord.h"
00008 #include "Candidate/CandContext.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h" 
00011 
00012 #include "FarDetDataQualityHandle.h"
00013 #include "FarDetDeadChipHandle.h"
00014 #include "SnarlHeader.h"
00015 #include "LiHeader.h"
00016 #include "VarcErrHeader.h"
00017 #include "SpillServHeader.h"
00018 #include "VaChip.h"
00019 
00020 #include "TObjArray.h"
00021 
00022 //
00023 // $Log $
00024 //
00025 
00026 ClassImp(AlgFarDetDataQuality)
00027 
00028 CVSID("$Id: AlgFarDetDataQuality.cxx,v 1.2 2006/04/21 17:40:11 blake Exp $");
00029 
00030 AlgFarDetDataQuality::AlgFarDetDataQuality()
00031 {
00032 
00033 }
00034   
00035 AlgFarDetDataQuality::~AlgFarDetDataQuality()
00036 {
00037 
00038 }
00039 
00040 void AlgFarDetDataQuality::RunAlg(AlgConfig& /*ac*/, CandHandle& ch, CandContext& cx)
00041 {
00042   MSG("AlgFarDetDataQuality", Msg::kDebug) << " AlgFarDetDataQuality::RunAlg(...) " << endl;
00043 
00044   FarDetDataQualityHandle& fardet = dynamic_cast<FarDetDataQualityHandle&>(ch);
00045   const TObjArray* arr = dynamic_cast<const TObjArray*>(cx.GetDataIn()); 
00046 
00047   TObjArray* fChipList = new TObjArray(); 
00048 
00049   AlgFactory &af = AlgFactory::GetInstance();
00050   AlgHandle ahh = af.GetAlgHandle("AlgFarDetDeadChip", "default");
00051   CandContext cxx(this, cx.GetMom());
00052   cxx.SetCandRecord(cxx.GetCandRecord());
00053 
00054   Int_t crate,varc,vmm;
00055   Int_t hotplnchips,coldplnchips,busyplnchips;
00056   Int_t hotshldchips,coldshldchips,busyshldchips;
00057   Int_t tpmtbox,tpmtnanosec;  
00058   Int_t id,time;
00059   Int_t tot,tot0,tot1,tot2;
00060   Int_t i,j;
00061 
00062   SnarlHeader* snarlheader = (SnarlHeader*)(arr->At(0)); 
00063   TObjArray* badlist = (TObjArray*)(arr->At(1));
00064   TObjArray* busylist = (TObjArray*)(arr->At(2));
00065 
00066   if( snarlheader->GetHitPlnChannels()>0 ){
00067     fardet.SetRun(snarlheader->GetRun());
00068     fardet.SetSubRun(snarlheader->GetSubRun());
00069     fardet.SetSnarl(snarlheader->GetSnarl());
00070     fardet.SetDate(snarlheader->GetDate());
00071     fardet.SetTime(snarlheader->GetTime());
00072     fardet.SetTimeFrame(snarlheader->GetTimeFrame());
00073     fardet.SetMicrosec(snarlheader->GetMicrosec());
00074     fardet.SetNanosec(snarlheader->GetNanosec());
00075     fardet.SetLiChannels(snarlheader->GetLiChannels());
00076     fardet.SetHitPlnChannels(snarlheader->GetHitPlnChannels());
00077     fardet.SetHitShldChannels(snarlheader->GetHitShldChannels());
00078     fardet.SetCrateMask(snarlheader->GetCrateMask());
00079 
00080     coldplnchips=0; hotplnchips=0; coldshldchips=0; hotshldchips=0;
00081     for(i=0;i<1+badlist->GetLast();i++){
00082       VaChip* mychip = (VaChip*)(badlist->At(i));
00083       if( mychip->GetVaChipStatus()==VaChip::kCold ){
00084         fChipList->Add(mychip);
00085         if(mychip->GetPlane()>=0) coldplnchips++; if(mychip->GetShld()>=0) coldshldchips++; 
00086       }
00087       if( mychip->GetVaChipStatus()==VaChip::kHot ){
00088         fChipList->Add(mychip);
00089         if(mychip->GetPlane()>=0) hotplnchips++; if(mychip->GetShld()>=0) hotshldchips++;
00090       }
00091     }
00092 
00093     busyplnchips=0; busyshldchips=0; 
00094     for(i=0;i<1+busylist->GetLast();i++){
00095       VaChip* mychip = (VaChip*)(busylist->At(i));
00096       if( mychip->GetVaChipStatus()==VaChip::kBusy ){ 
00097         tot=0; tot0=0; tot1=0; tot2=0;
00098         for(j=0;j<1+busylist->GetLast();j++){
00099           VaChip* mychip2 = (VaChip*)(busylist->At(j));
00100           crate=mychip2->GetCrate(); varc=mychip2->GetVarc(); vmm=mychip2->GetVmm();
00101           if(mychip->IsSameVmm(crate,varc,vmm)){
00102             if( mychip->GetPlane()>=0 ){
00103               if( mychip2->GetNanosec()-mychip->GetNanosec()>=-500
00104                && mychip2->GetNanosec()-mychip->GetNanosec()<500 
00105                && 3*mychip2->GetVaadc()+mychip2->GetVaChip()<=3*mychip->GetVaadc()+mychip->GetVaChip() ) tot0++;
00106               if( mychip2->GetNanosec()-mychip->GetNanosec()<-500
00107                && mychip2->GetNanosec()-mychip->GetNanosec()>=-5000 ) tot1++;
00108               if( mychip2->GetNanosec()-mychip->GetNanosec()<-5000
00109                && mychip2->GetNanosec()-mychip->GetNanosec()>=-10000 ) tot2++;
00110             }
00111             if( mychip->GetShld()>=0 ){
00112               if( mychip2->GetNanosec()-mychip->GetNanosec()>=-5
00113                && mychip2->GetNanosec()-mychip->GetNanosec()<5 
00114                && 3*mychip2->GetVaadc()+mychip2->GetVaChip()<=3*mychip->GetVaadc()+mychip->GetVaChip() ) tot0++;
00115               if( mychip2->GetNanosec()-mychip->GetNanosec()<-5
00116                && mychip2->GetNanosec()-mychip->GetNanosec()>=-5000 ) tot1++;
00117               if( mychip2->GetNanosec()-mychip->GetNanosec()<-5000
00118                && mychip2->GetNanosec()-mychip->GetNanosec()>=-10000 ) tot2++;
00119             }
00120           }
00121         }
00122         tot=tot0; if(tot1>=1) tot+=tot1; if(tot1+tot2>=2) tot+=tot2;
00123         if( mychip->GetNanosec()-snarlheader->GetNanosec()>-tot*5000 ){
00124           fChipList->Add(mychip);      
00125           if(mychip->GetPlane()>=0) busyplnchips++; if(mychip->GetShld()>=0) busyshldchips++; 
00126        }
00127       } 
00128     }
00129 
00130     if(1+fChipList->GetLast()>0){
00131       for(i=0;i<1+fChipList->GetLast();i++){
00132         VaChip* mychip = (VaChip*)(fChipList->At(i));
00133         cxx.SetDataIn(mychip);
00134         FarDetDeadChipHandle mydeadchip = FarDetDeadChip::MakeCandidate(ahh,cxx);
00135         mydeadchip.SetName(TString("FarDetDeadChipHandle"));
00136         mydeadchip.SetTitle(TString("Created by FarDetDataQualityModule"));
00137         fardet.AddDaughterLink(mydeadchip);
00138       }
00139     }
00140 
00141     fardet.SetDeadPlnChips(coldplnchips);
00142     fardet.SetHotPlnChips(hotplnchips);
00143     fardet.SetColdPlnChips(coldplnchips);
00144     fardet.SetBusyPlnChips(busyplnchips);
00145 
00146     fardet.SetDeadShldChips(coldshldchips);
00147     fardet.SetHotShldChips(hotshldchips);
00148     fardet.SetColdShldChips(coldshldchips);
00149     fardet.SetBusyShldChips(busyshldchips);
00150     
00151   }
00152 
00153   LiHeader* liheader = (LiHeader*)(arr->At(3));
00154   TObjArray* tpmtlist = (TObjArray*)(arr->At(4));
00155   if( liheader->GetTimeFrame()==snarlheader->GetTimeFrame() ){
00156 
00157     fardet.SetLiBox(liheader->GetBox());
00158     fardet.SetLiLed(liheader->GetLed());
00159     fardet.SetLiPulseHeight(liheader->GetPulseHeight());
00160     fardet.SetLiPulseWidth(liheader->GetPulseWidth());
00161 
00162     id=-1; time=-1000000000;
00163     tpmtbox=-1; tpmtnanosec=0;  
00164     for(i=0;i<1+tpmtlist->GetLast();i++){
00165       VaChip* mychip = (VaChip*)(tpmtlist->At(i));   
00166       if( mychip->GetNanosec()-snarlheader->GetNanosec()<1000
00167        && mychip->GetNanosec()-snarlheader->GetNanosec()>time ){
00168         id=i; time=mychip->GetNanosec()-snarlheader->GetNanosec();
00169       }
00170     }
00171     if(id>-1){
00172       VaChip* mychip = (VaChip*)(tpmtlist->At(id));   
00173       tpmtbox=mychip->GetVaChannel();
00174       tpmtnanosec=mychip->GetNanosec()-snarlheader->GetNanosec();
00175     }
00176   
00177     fardet.SetTpmtBox(tpmtbox);
00178     fardet.SetTpmtNanosec(tpmtnanosec);
00179   }
00180 
00181   VarcErrHeader* varcerrheader = (VarcErrHeader*)(arr->At(5));
00182   if( varcerrheader->GetTimeFrame()==snarlheader->GetTimeFrame() ){
00183     fardet.SetSparsErrors(varcerrheader->GetSparsErrors());
00184     fardet.SetEtcErrors(varcerrheader->GetEtcErrors());
00185   }
00186 
00187   SpillServHeader* spillservheader = (SpillServHeader*)(arr->At(6));
00188   if( spillservheader->GetTimeFrame()==snarlheader->GetTimeFrame() ){
00189     fardet.SetSpillStatus(spillservheader->GetSpillStatus());
00190     fardet.SetSpillType(spillservheader->GetSpillType());
00191     fardet.SetSpillGpsError(spillservheader->GetSpillGpsError());
00192   }
00193 
00194   delete fChipList;
00195 
00196   return;
00197 }
00198 
00199 void AlgFarDetDataQuality::Trace(const char * /* c */) const
00200 {
00201 
00202 }
00203 
00204 

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