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

OltTimeScan.cxx

Go to the documentation of this file.
00001 
00002 // $Id: OltTimeScan.cxx,v 1.7 2004/03/18 17:10:16 rhatcher 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/OltTimeScan.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(OltTimeScan)
00049 
00050   // ......
00051 
00052 CVSID("$Id: OltTimeScan.cxx,v 1.7 2004/03/18 17:10:16 rhatcher Exp $");
00053 JOBMODULE(OltTimeScan,"OltTimeScan","The Offline Trigger Time Scanner");
00054 
00055 
00056 OltTimeScan::OltTimeScan()
00057 {
00058   fRecord = 0;
00059   TDirectory *save = gDirectory;
00060   fFile = new TFile("/home/pa/bs.root","RECREATE");
00061   fTree = new TTree("tree","Timing Summary");
00062   fTree->Branch("crate",&fTreeCrate,"crate/I");
00063   fTree->Branch("time",&fTreeTime,"time/I");
00064   fTree->Branch("sec",&fCrateSec,"sec/I");
00065   fTree->Branch("nsec",&fCrateNSec,"nsec/I");
00066   fTree->Branch("tf",&fTreeTF,"tf/I");
00067   fTree->Branch("index",&fTreeIndex,"index/I");
00068   save->cd();
00069   fPlex = 0;
00070 }
00071 
00072 OltTimeScan::~OltTimeScan()
00073 {
00074   TDirectory *save = gDirectory;
00075   fFile->cd();
00076   fTree->Write();
00077   fFile->Close();
00078   save->cd();
00079 }
00080 
00081 JobCResult OltTimeScan::Reco(MomNavigator* mom)
00082 {
00083   int plane[2][61] = {{0}, {0}};
00084   TIter iter = mom->FragmentIter();
00085   while (TObject *obj = iter.Next()) {
00086     RawRecord *rawrec = dynamic_cast<RawRecord *>(obj);
00087     if (rawrec) {
00088       ++fRecord;
00089       MSG("Olt",Msg::kInfo) <<"---------------New Record---------------"<<endl;
00090       TIter recit = rawrec->GetRawBlockIter();
00091       while (TObject *obj = recit.Next()) {
00092         RawDataBlock *rawdata = dynamic_cast<RawDataBlock *>(obj);
00093         if (rawdata) {
00094           if (rawdata->InheritsFrom("RawSnarlHeaderBlock")) {
00095             RawSnarlHeaderBlock *rshb =dynamic_cast<RawSnarlHeaderBlock *>(rawdata);
00096             fTreeTF = rshb->GetTimeFrameNo();
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           MSG("Olt",Msg::kInfo) <<fRecord<<": "<<rawdata->GetBlockId()<<endl;
00103           if (fDump) {
00104           RawDigitDataBlock *rddb = dynamic_cast<RawDigitDataBlock *>(rawdata);
00105           if (rddb) {
00106             multimap<int,RawDigit *> hitmap;
00107             TIter it = rddb->GetDatumIter();
00108             while (TObject *obj = it.Next()) {
00109               RawVaDigit *rvd = dynamic_cast<RawVaDigit *>(obj);
00110               if (rvd) {
00111                 hitmap.insert(pair<int,RawDigit *>(rvd->GetTDC(),rvd));
00112               }
00113               RawQieDigit *rqd = dynamic_cast<RawQieDigit *>(obj);
00114               if (rqd) {
00115                 hitmap.insert(pair<int,RawDigit *>(int(rqd->GetTDC()*16*58.0/77.0 + 133),rqd));
00116               }
00117              }
00118 
00119             for (multimap<int,RawDigit *>::iterator it = hitmap.begin();
00120                  it!=hitmap.end();++it) {
00121               if (!fDoPlex) {         MSG("Olt",Msg::kInfo)<<(*it).first<<" "<<*((*it).second)<<endl; }
00122               else {
00123                 // Use the plex
00124                 RawChannelId rcid = (*it).second->GetChannel();
00125                 PlexSEIdAltL altl= fPlex->GetSEIdAltL(rcid);
00126                 MSG("Olt",Msg::kInfo)<<"Time: "<<(*it).first<<" Plane "<<altl.GetPlane()
00127                                      <<" End "<<altl.GetEnd()
00128                                      <<"   "<<rcid<<endl;
00129                 int p = altl.GetPlane();
00130                 if (p>-1 && p < 61) ++plane[altl.GetEnd()-1][p];
00131               }
00132             }
00133             for (int q=0;q<2;q++) {
00134             for (int i=0;i<61;i++) {
00135               if (plane[q][i]==0) {cout<<"-";}
00136               else if (plane[q][i]>9) {cout<<"9";}
00137               else {cout<<plane[q][i];}
00138 
00139             }
00140             cout<<endl;
00141             }
00142            }
00143           }       
00144           RawRunCommentBlock *rc = dynamic_cast<RawRunCommentBlock *>(rawdata);
00145           if (rc) cout<<rc->GetRunComment()<<endl;
00146 
00147           RawDeadChipBlock *dead = dynamic_cast<RawDeadChipBlock *>(rawdata);
00148           if (dead) cout<<"Dead Chips: "<<dead->GetNumberOfEntries()<<endl;
00149         }
00150       }
00151       
00152     }
00153   }
00154   return JobCResult::kAOK;
00155 
00156 }
00157 
00158 
00159  
00160 const Registry& OltTimeScan::DefaultConfig() const
00161 {
00162 
00163   static Registry r; // Default configuration for module
00164 
00165 
00166   std::string name = this->JobCModule::GetName();
00167   name += ".config.default";
00168   r.SetName(name.c_str());
00169 
00170   // Set values in configuration
00171   r.UnLockValues();
00172   r.Set("DumpData", true);
00173   r.Set("Plex", true);
00174   r.LockValues();
00175 
00176   return r;
00177 }
00178 
00179 //......................................................................
00180 
00181 void OltTimeScan::Config(const Registry& r)
00182 {
00183   int   tmpb;
00184   cout<<"Teapots\n";
00185   cout<<r<<endl;
00186   if (r.Get("DumpData",tmpb)) { cout<<"Hello "<<tmpb<<endl;fDump = bool(tmpb); }
00187   if (r.Get("Plex",tmpb)) { cout<<"Plex "<<tmpb<<endl;fDoPlex = bool(tmpb); }
00188 }
00189 

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