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

OltRawLI.cxx

Go to the documentation of this file.
00001 
00002 // $Id: OltRawLI.cxx,v 1.2 2003/09/04 13:10:55 phil.adamson Exp $
00003 //
00004 // OltBlockScan.cxx
00005 //
00006 // Block Scan
00007 //
00008 // Author: Phil Adamson 5/2002
00010 
00011 #include "JobControl/JobCModuleRegistry.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "OfflineTrigger/OltRawLI.h"
00014 #include "MessageService/MsgService.h"
00015 #include "RawData/RawRecord.h"
00016 #include "RawData/RawHeader.h"
00017 #include "RawData/RawDataBlock.h"
00018 #include "RawData/RawDaqHeaderBlock.h"
00019 #include "RawData/RawSnarlHeaderBlock.h"
00020 #include "RawData/RawChannelId.h"
00021 #include "RawData/RawVaDigit.h"
00022 #include "RawData/RawQieDigit.h"
00023 #include "RawData/RawDigitDataBlock.h"
00024 #include "RawData/RawRunCommentBlock.h"
00025 #include "RawData/RawDeadChipBlock.h"
00026 
00027 #include "Persistency/PerOutputStreamManager.h"
00028 #include "Persistency/PerOutputStream.h"
00029 #include "Rotorooter/RotoObjectifier.h"
00030 #include "Plex/PlexHandle.h"
00031 #include "Plex/PlexSEIdAltL.h"
00032 #include "Validity/VldContext.h"
00033 
00034 #include "TString.h"
00035 #include "TFile.h"
00036 #include "TTree.h"
00037 #include <string>
00038 
00039 #include <algorithm>
00040 #include <cstdio>
00041 #include <cstring>
00042 #include <iostream>
00043 #include <fstream>
00044 #include <map>
00045 #ifndef __CINT__
00046 #include "OnlineUtil/mdBlockDefinitions.h"
00047 #endif
00048 ClassImp(OltRawLI)
00049 
00050   // ......
00051 
00052 CVSID("$Id: OltRawLI.cxx,v 1.2 2003/09/04 13:10:55 phil.adamson Exp $");
00053 JOBMODULE(OltRawLI,"OltRawLI","The Offline Trigger Time Scanner");
00054 
00055 
00056 OltRawLI::OltRawLI()
00057 {
00058   fRecord = 0;
00059   TDirectory *save = gDirectory;
00060   fFile = new TFile("/home/pa/rawli.root","RECREATE");
00061   fTree = new TTree("tree","Raw LI Timing Summary");
00062   fTree->Branch("crate",&fTreeCrate,"crate/I");
00063   fTree->Branch("time",&fTreeTime,"time/I");
00064   fTree->Branch("subtime",&fTreeSubTime,"subtime/I");
00065   fTree->Branch("elec",&fElec,"elec/I");
00066   fTree->Branch("tf",&fTreeTF,"tf/I");
00067   fTree->Branch("index",&fTreeIndex,"index/I");
00068   save->cd();
00069   fPlex = 0;
00070 }
00071 
00072 OltRawLI::~OltRawLI()
00073 {
00074   TDirectory *save = gDirectory;
00075   fFile->cd();
00076   fTree->Print();
00077   fTree->Write();
00078   fFile->Close();
00079   save->cd();
00080 }
00081 
00082 JobCResult OltRawLI::Reco(MomNavigator* mom)
00083 {
00084   TIter iter = mom->FragmentIter();
00085   while (TObject *obj = iter.Next()) {
00086     RawRecord *rawrec = dynamic_cast<RawRecord *>(obj);
00087     if (rawrec) {
00088       ++fRecord;
00089       TIter recit = rawrec->GetRawBlockIter();
00090       while (TObject *obj = recit.Next()) {
00091         RawDataBlock *rawdata = dynamic_cast<RawDataBlock *>(obj);
00092         if (rawdata) {
00093           if (rawdata->InheritsFrom("RawSnarlHeaderBlock")) {
00094             RawSnarlHeaderBlock *rshb =dynamic_cast<RawSnarlHeaderBlock *>(rawdata);
00095             fTreeTF = rshb->GetTimeFrameNo();
00096             fTreeIndex = rshb->GetSnarl();
00097             MSG("Olt",Msg::kInfo)<<"Timeframe "<<fTreeTF<<"  "
00098                                  <<"Snarl "<<rshb->GetSnarl()<<endl;
00099             if (fDoPlex && !fPlex) fPlex = new PlexHandle(rshb->GetVldContext());
00100           } 
00101           //      fTreeIndex = 0;
00102           RawDigitDataBlock *rddb = dynamic_cast<RawDigitDataBlock *>(rawdata);
00103           if (rddb) {
00104             multimap<int,RawDigit *> hitmap;
00105             bool gottrig = false;
00106             TIter it = rddb->GetDatumIter();
00107             while (TObject *obj = it.Next()) {
00108               RawVaDigit *rvd = dynamic_cast<RawVaDigit *>(obj);
00109               if (rvd) {
00110                 hitmap.insert(pair<int,RawDigit *>(rvd->GetTDC(),rvd));
00111                 RawChannelId rcid = rvd->GetChannel();
00112                 if (rcid.GetCrate()==0 && CHAD_TRIGPMT==rcid.GetChAdd()) {
00113                   fTrigTime = rvd->GetTDC();
00114                   gottrig = true;
00115                   MSG("Olt",Msg::kVerbose)<<"Trigger PMT is at "<<fTrigTime<<endl;
00116                 }
00117               }
00118               RawQieDigit *rqd = dynamic_cast<RawQieDigit *>(obj);
00119               if (rqd) {
00120                 hitmap.insert(pair<int,RawDigit *>(int(rqd->GetTDC()*16*58.0/77.0 + 133),rqd));
00121               }
00122             }
00123             if (!gottrig) MSG("Olt",Msg::kWarning)<<"Missing Trigger PMT in tf "<<fTreeTF<<" snarl "<<fTreeIndex<<endl;
00124             for (multimap<int,RawDigit *>::iterator it = hitmap.begin();
00125                  it!=hitmap.end();++it) {
00126               RawQieDigit *q = dynamic_cast<RawQieDigit *>((*it).second);
00127               if (q) {
00128                 fElec = 2;
00129                 fTreeTime = int(q->GetTDC()*16*58.0/77.0 + 133);
00130               } else {
00131                 fElec = 1;
00132                 fTreeTime = (*it).second->GetTDC();
00133               }
00134               RawChannelId rcid = (*it).second->GetChannel();
00135               fTreeCrate = rcid.GetCrate();
00136               fTreeSubTime = fTreeTime - fTrigTime;
00137               MSG("Olt",Msg::kVerbose)<<"Time "<<fTreeTime<<" Trig "<<fTrigTime<<endl;
00138               fTree->Fill();
00139 
00140         
00141             }
00142           }
00143           
00144           
00145           
00146         }
00147       }
00148       
00149     }
00150   }
00151   return JobCResult::kAOK;
00152   
00153 }
00154 
00155 
00156  
00157 const Registry& OltRawLI::DefaultConfig() const
00158 {
00159 
00160   static Registry r; // Default configuration for module
00161 
00162 
00163   std::string name = this->JobCModule::GetName();
00164   name += ".config.default";
00165   r.SetName(name.c_str());
00166 
00167   // Set values in configuration
00168   r.UnLockValues();
00169   r.Set("DumpData", true);
00170   r.Set("Plex", true);
00171   r.LockValues();
00172 
00173   return r;
00174 }
00175 
00176 //......................................................................
00177 
00178 void OltRawLI::Config(const Registry& r)
00179 {
00180   int   tmpb;
00181   cout<<"Teapots\n";
00182   cout<<r<<endl;
00183   if (r.Get("DumpData",tmpb)) { cout<<"Hello "<<tmpb<<endl;fDump = bool(tmpb); }
00184   if (r.Get("Plex",tmpb)) { cout<<"Plex "<<tmpb<<endl;fDoPlex = bool(tmpb); }
00185 }
00186 

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