OltNewModule Class Reference

#include <OltNewModule.h>

Inheritance diagram for OltNewModule:
JobCModule

List of all members.

Classes

class  hitsorter
struct  QieHit
class  qiesorter
class  Trigbits
struct  VaHit

Public Member Functions

 OltNewModule ()
 ~OltNewModule ()
JobCResult Reco (MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Member Functions

 OltNewModule (const OltNewModule &)
bool OpenFile (Detector::Detector_t det, Int_t run, Int_t subrun)
bool CloseFile (Detector::Detector_t det, Int_t run, Int_t subrun)
bool OpenSpy (Detector::Detector_t det, Int_t run, Int_t subrun)
bool CloseSpy (Detector::Detector_t det, Int_t run, Int_t subrun)
void ProcessTimeframe (RawRecord *rawrec, string rotoStrmName)
void FormEvents (int tf, string rotoStrmName)
int CalculateDeadChips (int timestamp, int buf, int trigword)
int SuckCrate (int crate, unsigned int &it, bool *hitplane, Trigbits &trigbits, int &teventend, int tf)
int SuckQieCrate (int crate, unsigned int &it, bool *hitplane, Trigbits &trigbits, int &teventend, int tf)
int SuckVaCrate (int crate, unsigned int &it, bool *hitplane, Trigbits &trigbits, int &teventend, int tf)
void WriteEvent (unsigned long teventstart, int ntrig, int tf, unsigned int *start, unsigned int *end, string rotoStrmName)
void WriteConfig (string rotoStrmName)
void WriteMom (MomNavigator *mom, string rotoStrmName, int trigword)
int ToVaTime (unsigned int qietime)

Static Private Member Functions

static int ToChip (int chad)
static int ToVmm (int chad)
static int ToChad (int varc, int vmm, int adc, int chip, int channel)

Private Attributes

struct OltNewModule::VaHit packed
struct OltNewModule::QieHit packed
PerOutputStreamManagerfOutputStreamManager
string fOutDir
string fCurrentFilename
string fSymlinkDir
string fCounterDir
string fSummaryDir
Per::EAccessMode fAccessMode
PerOutputStreamManagerfSpyStreamManager
int fSpyVersion
bool fFileOpen
bool fSpyOpen
bool fSpyMode
Detector::Detector_t fDetector
Int_t fRun
Int_t fSubrun
Int_t fRunType
std::vector< long long > fHits [2][NCRATES]
std::vector< long long > fExtraHits [NCRATES]
std::vector< long long > fSortedHits [NCRATES]
int fCrateId [2][NCRATES]
int fCrates
int fCrateSec [2][NCRATES]
int fCrateNsec [2][NCRATES]
std::vector< std::map< int, int > > fVmmFreeTime [2]
std::vector< std::map< int, int > > fChipFreeTime [2]
int fDeadChipBuffer
int fDeadChipLastBuffer
std::vector< std::map< int, int > > fQieFreeTime [2]
OltCounterfCounter
int fCurrentTF
int fLastTF
int fTimeframe [2]
int fGap
__gnu_cxx::hash_map< int, int > fPlane [NCRATES]
__gnu_cxx::hash_map< int, int > fQiePlane [NCRATES]
bool fFirst
unsigned long * fBuffer
unsigned long fEventNo
unsigned long * fDeadBuf
unsigned long * fToFOutputArray
RawTofConverterfToFConverter [2]
int fTofIndex
int fNumToFHits [2]
int chad_TOF
int chad_CER1
int chad_CER2
int chad_CER3
int chad_TRIGPMT
int chad_ND_TIMING
int fRecord
int fQieOffset
long long fNDTimingHit [2]
string fNewRunScript
bool fNewRun
bool fHaveNDTimingHit
bool fAllData
bool fUseCounter
int fTrigMask
int fExcludeMask
int fNumPlanes
unsigned int fNDFiducialADCCut
int fElec [NCRATES]

Static Private Attributes

static const int CHAD_TOF = 0x1602
static const int CHAD_VARC1 = 0xe02
static const int CHAD_VARC0 = 0x602
static const int CHAD_CER1 = 0x5b0
static const int CHAD_CER2 = 0x590
static const int CHAD_CER3 = 0x5d0
static const int CHAD_TRIGPMT = 0x1524
static const int CHAD_ND_TIMING = 0x590
static const int TRIG_LI_MASK = 0x2
static const int TRIG_PLANE_MASK = 0x4
static const int TRIG_TOF_MASK = 0x8
static const int TRIG_CER1_MASK = 0x10
static const int TRIG_CER2_MASK = 0x20
static const int TRIG_VARC0_MASK = 0x40
static const int TRIG_VARC1_MASK = 0x80
static const int TRIG_SGATE_MASK = 0x80
static const int TRIG_NUM_SHIFT = 8
static const double VATICK
static const int DEADTIME = 6080
static const int QIEDEADTIME = 8000
static const int ONE_SECOND = 640000000
static const unsigned int TOF_TARDIS = 100

Detailed Description

Definition at line 131 of file OltNewModule.h.


Constructor & Destructor Documentation

OltNewModule::OltNewModule (  ) 

Definition at line 323 of file OltNewModule.cxx.

References fAccessMode, fBuffer, fChipFreeTime, fCounter, fCrateId, fCrateNsec, fCrateSec, fCurrentTF, fDeadBuf, fDeadChipBuffer, fDeadChipLastBuffer, fDetector, fEventNo, fExtraHits, fFileOpen, fFirst, fGap, fHaveNDTimingHit, fHits, fLastTF, fNumToFHits, fOutDir, fOutputStreamManager, fQieFreeTime, fRecord, fRun, fSortedHits, fSpyOpen, fSpyStreamManager, fSubrun, fSymlinkDir, fTimeframe, fToFConverter, fTofIndex, fToFOutputArray, fVmmFreeTime, RawChannelId::GetEncoded(), gSystem(), Detector::kCalDet, Per::kNew, ElecType::kQIE, Detector::kUnknown, NCRATES, and ToChad().

00324 {
00325   fOutputStreamManager = new PerOutputStreamManager();
00326   fSpyStreamManager = new PerOutputStreamManager();
00327 
00328   const char * dir = gSystem->Getenv("OLT_OUTPUT_DIR");
00329   if (dir) fOutDir = string(dir);
00330   dir = gSystem->Getenv("OLT_LINK_DIR");
00331   if (dir) fSymlinkDir = string(dir);
00332   fAccessMode = Per::kNew;
00333   fFileOpen = false;
00334   fSpyOpen = false;
00335   fDetector = Detector::kUnknown;
00336   fRun = 0;
00337   fSubrun = 0;
00338   fCounter = 0;
00339   fCurrentTF = 0;
00340   fLastTF = 1;
00341   fTimeframe[0] = -10;
00342   fTimeframe[1] = -10;
00343   fToFConverter[0] = 0;
00344   fToFConverter[1] = 0;
00345   fNumToFHits[0] = 0;
00346   fNumToFHits[1] = 0;
00347   fGap = 100;
00348   fFirst = true;
00349   
00350   fDeadChipBuffer = 0;
00351   fDeadChipLastBuffer = 1;
00352    for (int i=0;i<NCRATES;i++) {
00353       fExtraHits[i].reserve(4000);
00354       fSortedHits[i].reserve(400000);
00355     for (int tf=0;tf<2;tf++) {
00356       fQieFreeTime[tf].push_back(map<int,int>());
00357       fChipFreeTime[tf].push_back(map<int,int>());
00358       fVmmFreeTime[tf].push_back(map<int,int>());
00359       fHits[tf][i].reserve(400000);
00360       fCrateId[tf][i] = 0;
00361       fCrateSec[tf][i]=0;
00362       fCrateNsec[tf][i]=0;
00363       
00364       // And Set times in DeadChip maps to prehistory...
00365       for (int varc=0;varc<3;varc++) {
00366         for (int vmm=0;vmm<6;vmm++) {
00367           for (int adc=0;adc<2;adc++) {
00368             for (int chip=0;chip<3;chip++) {
00369               fChipFreeTime[tf][i][ToChad(varc,vmm,adc,chip,0)] = -1000000;   
00370             }
00371           }
00372           fVmmFreeTime[tf][i][ToChad(varc,vmm,0,0,0)] = -1000000;   
00373         }
00374       }
00375       for (int master = 0 ; master < 32 ; master++ ) {
00376         for (int minder = 0 ; minder < 8 ; minder+=4 ) {
00377           int menu=0;
00378           RawChannelId rcid(Detector::kCalDet, 
00379                             ElecType::kQIE,
00380                             i,master,minder,menu);
00381           int chadmask = rcid.GetEncoded()&0x1fff;
00382           fQieFreeTime[tf][i][chadmask] = -1000000;
00383         }
00384       }
00385     }
00386    }
00387    fBuffer = new unsigned long[200000]; //10k words should be enough
00388    fDeadBuf = new unsigned long[5000]; //1k words should be enough
00389    fToFOutputArray = new unsigned long[200]; // Will be short!
00390    fEventNo = 0;
00391    fTofIndex = 0;
00392    fRecord = 0;
00393    
00394    fHaveNDTimingHit = false;
00395 }

OltNewModule::~OltNewModule (  ) 

Definition at line 397 of file OltNewModule.cxx.

References CloseFile(), CloseSpy(), fBuffer, fCounter, fDeadBuf, fDetector, fFileOpen, fRun, fSpyOpen, fSubrun, fToFOutputArray, Msg::kInfo, MSG, and OltCounter::WriteSummary().

00398 {
00399   if (fFileOpen) CloseFile(fDetector,fRun,fSubrun);
00400   if (fSpyOpen) CloseSpy(fDetector,fRun,fSubrun);
00401   if (fCounter) fCounter->WriteSummary();
00402   if (fCounter) {
00403     MSG("Olt",Msg::kInfo)<<"Deleting counter"<<endl;
00404     delete fCounter;
00405     MSG("Olt",Msg::kInfo)<<"Done"<<endl;
00406   }
00407     MSG("Olt",Msg::kInfo)<<"Deleting buffer"<<endl;
00408   delete [] fBuffer;
00409   delete [] fDeadBuf;
00410   delete [] fToFOutputArray;
00411     MSG("Olt",Msg::kInfo)<<"Done"<<endl;
00412 }

OltNewModule::OltNewModule ( const OltNewModule  )  [private]

Member Function Documentation

int OltNewModule::CalculateDeadChips ( int  timestamp,
int  buf,
int  trigword 
) [private]

Definition at line 1136 of file OltNewModule.cxx.

References BLOCKID_BITPOS_DETECTOR, BLOCKID_BITPOS_IDENTIFIER, OltCounter::DeadChip(), OltCounter::DeadChipTrig(), OltCounter::DeadTime(), fChipFreeTime, fCounter, fCrates, fDeadBuf, fElec, fUseCounter, it, kMdBlockSourceCalDetector, and rdxsum_fill().

Referenced by FormEvents().

01137 {
01138   int ndead = 0;
01139   fDeadBuf[0] = 3;
01140   fDeadBuf[1] = 0;
01141   fDeadBuf[2] = (0xf00<<BLOCKID_BITPOS_IDENTIFIER) | 
01142     (kMdBlockSourceCalDetector<<BLOCKID_BITPOS_DETECTOR);
01143   unsigned long *numptr;
01144   unsigned long *lptr = fDeadBuf + 3;
01145   for (int crate=0;crate<fCrates;crate++) {
01146     numptr = lptr;
01147     ++lptr;
01148     *numptr = 0;
01149     ++(*fDeadBuf);
01150     map<int,int>::iterator it;
01151     //cout<<crate<<"  "<<fElec[crate]<<endl;
01152     if (fElec[crate]==1) {
01153       // VA
01154       for (it = fChipFreeTime[buf][crate].begin();
01155            it != fChipFreeTime[buf][crate].end();
01156            it++) {
01157         if ((*it).second >timestamp) {
01158           // This chip is dead.
01159           if (fUseCounter) {
01160             fCounter->DeadTime((*it).second - timestamp);
01161             fCounter->DeadChip(crate, (*it).first);
01162             if (nplanes>3) fCounter->DeadChipTrig(crate, (*it).first);
01163           }
01164           ++ndead;
01165           ++(*numptr);
01166           *lptr++=(*it).first;
01167           ++(*fDeadBuf);
01168         // Form the buffer here.
01169         }
01170       }
01171     }
01172     else if (fElec[crate]==2) {
01173       for (it = fChipFreeTime[buf][crate].begin();
01174            it != fChipFreeTime[buf][crate].end();
01175            it++) {
01176         if ((*it).second >timestamp) {
01177           // This chip is dead.
01178           ++ndead;
01179           ++(*numptr);
01180           *lptr++=((*it).first&(1<<19));  // Set "Qie" bit if qie
01181           ++(*fDeadBuf);
01182         }
01183       }
01184     }
01185     else {
01186       //      MSG("Olt",Msg::kFatal) << "Don't know about electronics type "<<fElec[crate]<<endl;
01187     }
01188     //    MSG("Olt",Msg::kInfo)<<"There are "<<ndead<<" dead chips up to crate "
01189     //                   <<crate<<" of "<<fCrates<<endl;
01190   }
01191   rdxsum_fill((int32_t*)fDeadBuf,0);  // fill in the checksum value
01192   return ndead;
01193 }

bool OltNewModule::CloseFile ( Detector::Detector_t  det,
Int_t  run,
Int_t  subrun 
) [private]

Definition at line 673 of file OltNewModule.cxx.

References bfld::AsString(), Detector::AsString(), PerStreamManager::CloseStream(), fCurrentFilename, fname, Form(), fOutDir, fOutputStreamManager, fSymlinkDir, Per::kDaqSnarl, Msg::kInfo, Per::kLightInjection, MSG, and PerOutputStreamManager::Write().

Referenced by Reco(), and ~OltNewModule().

00674 {
00675   // Close output file. Name file *.tdaq.root for triggered data
00676   // Stolen from the Rotorooter...
00677   string fname = 
00678     Form("%c%8.8d_%4.4d",Detector::AsString(det)[0],run,subrun);
00679   
00680    // 3 streams in daq file
00681   for (int i = Per::kDaqSnarl;i<=Per::kLightInjection;i++) {
00682     Per::EStreamType stype = (Per::EStreamType) i;
00683     string treeName = Per::AsString(stype);
00684     string rotoStrmName = fname + "." + treeName;
00685     fOutputStreamManager->Write(rotoStrmName);
00686     fOutputStreamManager->CloseStream(rotoStrmName);
00687     MSG("Olt",Msg::kInfo)<<"Closing stream "<<rotoStrmName<<endl;
00688    }
00689 
00690   //  string filename = fOutDir + "/" + fname;
00691   string link = fOutDir + "/LastFileTriggered";
00692   string mylink = fSymlinkDir + "/" + fname + ".tdaq.root";
00693   unlink(mylink.c_str());
00694   symlink(fCurrentFilename.c_str(),mylink.c_str());
00695   unlink(link.c_str());
00696   symlink(fCurrentFilename.c_str(),link.c_str());
00697   return true;
00698 }

bool OltNewModule::CloseSpy ( Detector::Detector_t  det,
Int_t  run,
Int_t  subrun 
) [private]

Definition at line 1394 of file OltNewModule.cxx.

References bfld::AsString(), Detector::AsString(), PerStreamManager::CloseStream(), fname, Form(), fSpyStreamManager, Per::kDaqSnarl, Per::kLightInjection, and PerOutputStreamManager::Write().

Referenced by ProcessTimeframe(), Reco(), and ~OltNewModule().

01395 {
01396   // Close output file. Name file *.tdaq.root for triggered data
01397   // Stolen from the Rotorooter...
01398   string fname = 
01399     Form("%c%8.8d_%4.4d",Detector::AsString(det)[0],run,subrun);
01400   
01401    // 3 streams in daq file
01402   for (int i = Per::kDaqSnarl;i<=Per::kLightInjection;i++) {
01403     Per::EStreamType stype = (Per::EStreamType) i;
01404     string treeName = Per::AsString(stype);
01405     string rotoStrmName = fname + "." + treeName;
01406     fSpyStreamManager->Write(rotoStrmName);
01407     fSpyStreamManager->CloseStream(rotoStrmName);
01408    }
01409   return true;
01410 }

void OltNewModule::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 260 of file OltNewModule.cxx.

00261 {
00262   const char *s;
00263   double d;
00264   int b;
00265   int i;
00266   if (r.Get("OutDir",s)) fOutDir = std::string(s);
00267   if (r.Get("CounterDir",s)) fCounterDir = std::string(s);
00268   if (r.Get("LinkDir",s)) fSymlinkDir = std::string(s);
00269   if (r.Get("SummaryDir",s)) fSummaryDir = std::string(s);
00270   if (r.Get("QieOffset",d)) fQieOffset = int(d);
00271   if (r.Get("SpyMode",b)) fSpyMode = bool(b);
00272   if (r.Get("ChadTOF",i)) chad_TOF = i;
00273   if (r.Get("ChadCER1",i)) chad_CER1 = i;
00274   if (r.Get("ChadCER2",i)) chad_CER2 = i;
00275   if (r.Get("ChadCER3",i)) chad_CER3 = i;
00276   if (r.Get("ChadTRIGPMT",i)) chad_TRIGPMT = i;
00277   if (r.Get("ChadNDTIMING",i)) chad_ND_TIMING = i;
00278   if (r.Get("AllData",b)) fAllData = bool(b);
00279   if (r.Get("UseCounter",b)) fUseCounter = bool(b);
00280   if (r.Get("TrigMask",i)) fTrigMask = i;
00281   if (r.Get("ExcludeMask",i)) fExcludeMask = i;
00282   if (r.Get("NumPlanes",i)) fNumPlanes = i;
00283   if (r.Get("NDFiducialADCCut",i)) fNDFiducialADCCut = i;
00284   if (r.Get("NewRun",b)) fNewRun = bool(b);
00285   if (r.Get("NewRunScript",s)) fNewRunScript = std::string(s);
00286 }

const Registry & OltNewModule::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 288 of file OltNewModule.cxx.

References CHAD_CER1, CHAD_CER2, CHAD_CER3, CHAD_ND_TIMING, CHAD_TOF, CHAD_TRIGPMT, JobCModule::GetName(), Registry::LockValues(), Registry::Set(), Registry::UnLockValues(), and VATICK.

00289 {
00290   static Registry r;
00291   std::string name = this->JobCModule::GetName();
00292   name +=".config.default";
00293   r.SetName(name.c_str());
00294 
00295   // Set defaults
00296   r.UnLockValues();
00297   r.Set("OutDir","/data/dataout");
00298   r.Set("CounterDir","/data/histos");
00299   r.Set("LinkDir","/data");
00300   r.Set("SummaryDir","/data");
00301   r.Set("QieOffset",float(208/VATICK)); 
00302   r.Set("SpyMode",false);
00303   r.Set("ChadTOF",CHAD_TOF);
00304   r.Set("ChadCER1",CHAD_CER1);
00305   r.Set("ChadCER2",CHAD_CER2);
00306   r.Set("ChadCER3",CHAD_CER3);
00307   r.Set("ChadTRIGPMT",CHAD_TRIGPMT);
00308   r.Set("ChadNDTIMING",CHAD_ND_TIMING);
00309   r.Set("AllData",false);
00310   r.Set("UseCounter",true);
00311   r.Set("TrigMask",0xff);
00312   r.Set("ExcludeMask",0);
00313   r.Set("NumPlanes",4);
00314   r.Set("NDFiducialADCCut",1000);
00315   r.Set("NewRun",false);
00316   r.Set("NewRunScript","/bin/echo");
00317  r.LockValues();
00318 
00319   return r;
00320 }

void OltNewModule::FormEvents ( int  tf,
string  rotoStrmName 
) [private]

Definition at line 893 of file OltNewModule.cxx.

References CalculateDeadChips(), OltNewModule::Trigbits::cer1, OltNewModule::Trigbits::cer2, OltNewModule::Trigbits::cer3, OltCounter::Event(), fAllData, fCounter, fCrateId, fCrates, fDeadChipBuffer, fDeadChipLastBuffer, fExcludeMask, fNumPlanes, fSortedHits, fTimeframe, fTrigMask, fUseCounter, OltNewModule::Trigbits::isli, OltNewModule::Trigbits::issgate, OltNewModule::Trigbits::istof, OltNewModule::Trigbits::isv0, OltNewModule::Trigbits::isv1, Msg::kDebug, Msg::kVerbose, MSG, n, NCRATES, OltCounter::RawHits(), size, SuckCrate(), ToVaTime(), TRIG_CER1_MASK, TRIG_CER2_MASK, TRIG_LI_MASK, TRIG_NUM_SHIFT, TRIG_PLANE_MASK, TRIG_SGATE_MASK, TRIG_TOF_MASK, TRIG_VARC0_MASK, OltCounter::Trigger(), and WriteEvent().

Referenced by ProcessTimeframe(), and Reco().

00894 {
00895   unsigned int start[NCRATES]={0};
00896   unsigned int end[NCRATES]={0};
00897   unsigned int hitit[NCRATES]={0};
00898   // indexes over the hitmap for a crate
00899  
00900   int teventstart;
00901   int teventend;
00902   //unused: int firstcrate;
00903 
00904   // Three iterators. start and end delimit events, hitit is the one 
00905   // that actually gets advanced over the hits.
00906   // Also meet hitplane the array. This gets a true if a plane is hit
00907   // so we can then use it in the trigger decision.
00908 
00909   bool hitplane[100]; // CalDet!!!
00910   memset(hitplane,0,sizeof(hitplane));
00911 
00912   // Let's tell the Counter how many hits each crate had:
00913   if (fUseCounter) {
00914     for (int crate=0; crate<fCrates;crate++) {
00915       fCounter->RawHits(fTimeframe[tf],crate,fSortedHits[crate].size());
00916     }
00917   }
00918 
00919   for (;;) {
00920     bool nomorehits = true;
00921     Trigbits trigbits;
00922     int n[NCRATES+1]={0};
00923     //unused: int lastchip=-1;
00924     //unused: Is not unused! Look down 8 lines, and 16 lines!
00925     int firstcrate;
00926     teventstart=1000000000L; // times are always less than this.
00927     
00928     for (int crate=0; crate<fCrates ; crate++) {
00929       bool nohitsleft=(hitit[crate] >= fSortedHits[crate].size());
00930       nomorehits &=nohitsleft;
00931       int thistime;
00932       if (fCrateId[tf][crate] & 0x40) {
00933         // QIE electronics if this bit is set 
00934         thistime = ToVaTime((reinterpret_cast<QieHit *>(&fSortedHits[crate][hitit[crate]]))->timeStamp);
00935       } else {
00936         thistime = (reinterpret_cast<VaHit *>(&fSortedHits[crate][hitit[crate]]))->timeStamp;
00937       }
00938       if (!nohitsleft && thistime < teventstart) {
00939         teventstart = thistime;
00940         firstcrate = crate;
00941       }
00942     }
00943     if (nomorehits) break;
00944     teventend = teventstart;
00945     MSG("Olt",Msg::kVerbose) << "Start at "<<teventstart<<" in crate "<<firstcrate<<" of "<<fCrates<<endl;
00946     // Suck up first crate's worth...
00947     n[firstcrate]+=SuckCrate(firstcrate,hitit[firstcrate],hitplane,
00948                              trigbits,teventend,tf);
00949     end[firstcrate] = hitit[firstcrate];
00950 
00951     // Now loop over all crates until no more added hits.
00952     for (;;) {
00953       int nAdded = 0;
00954       for (int crate=0;crate<fCrates ; crate++) {
00955         int num = SuckCrate(crate,hitit[crate],hitplane,
00956                             trigbits,teventend,tf);
00957         nAdded +=num;
00958         n[crate]+=num;
00959         end[crate] = hitit[crate];
00960       }
00961       if (nAdded == 0) break;
00962     }
00963 
00964     int sum[6][61]={{0},{0}}; // 1 = 2/3, 5 = 6/7
00965     int atplane[6]={0};
00966 
00967    for (int i=1;i<60;i++) {
00968       sum[0][i] = int(hitplane[i]) + int(hitplane[i+1]);
00969     }
00970     for (int j=1;j<6;j++) {
00971       for (int i=60;i>0;i--) {
00972         sum[j][i] = sum[j-1][i] + int(hitplane[i+j+1]);
00973         if (sum[j][i]>=j+1) atplane[j] = i;
00974       } 
00975     }
00976 
00977     int nplanes=0;
00978     int trigword = 0;
00979     
00980     for (int i=5;i>0;i--) {
00981       if (atplane[i]>0) {
00982         MSG("Olt",Msg::kDebug)<<"Trigger "<<i+1<<"/"<<i+2<<" at plane "
00983                                 <<atplane[i]<<endl;
00984         nplanes = i+1;
00985         trigword = ((i+1)<<TRIG_NUM_SHIFT) | TRIG_PLANE_MASK;
00986         break;
00987       }
00988     }
00989     int ndead = -1;
00990 
00991     if (fUseCounter) fCounter->Trigger(trigword,atplane[nplanes-1]);
00992     //if (trigword) fCounter->DeadChips(fChipFreeTime[fDeadChipLastBuffer]);
00993     if (trigbits.isli) trigword |=TRIG_LI_MASK;
00994     if (trigbits.cer1) trigword |=TRIG_CER1_MASK;
00995     if (trigbits.cer2) trigword |=TRIG_CER2_MASK;
00996     if (trigbits.cer3) trigword |=TRIG_VARC0_MASK;
00997     if (trigbits.istof) trigword |=TRIG_TOF_MASK;
00998     if (trigbits.isv0) trigword |=TRIG_VARC0_MASK;
00999     //    if (trigbits.isv1) trigword |=TRIG_VARC1_MASK;
01000     if (trigbits.issgate) trigword |=TRIG_SGATE_MASK;
01001     if (trigword) ndead = CalculateDeadChips(teventstart,fDeadChipLastBuffer,nplanes);
01002     if ((fAllData
01003          ||((TRIG_PLANE_MASK&fTrigMask)&&(nplanes>fNumPlanes))
01004          ||(trigword&(fTrigMask&(~TRIG_PLANE_MASK))))
01005         &&(!(trigword&fExcludeMask))) WriteEvent(teventstart,trigword,tf,start,end,rotoStrmName);
01006         
01007     if (fUseCounter) fCounter->Event(fTimeframe[tf],teventstart,n[0],n[1],
01008                                      nplanes,int(trigbits.istof),
01009                                      int(trigbits.cer1),int(trigbits.cer2),
01010                                      int(trigbits.cer3),
01011                                      int(trigbits.isv0), 
01012                                      int(trigbits.isv1), ndead, 
01013                                      int(trigbits.isli));
01014 
01015     // end of event...
01016 
01017     for (int crate = 0; crate<fCrates; crate++) {
01018       start[crate] = end[crate];
01019     }
01020     memset(hitplane,0,sizeof(hitplane));
01021     swap(fDeadChipBuffer,fDeadChipLastBuffer);
01022 
01023     
01024   }
01025   // No more hits
01026 }

bool OltNewModule::OpenFile ( Detector::Detector_t  det,
Int_t  run,
Int_t  subrun 
) [private]

Definition at line 596 of file OltNewModule.cxx.

References bfld::AsString(), Detector::AsString(), fAccessMode, fCurrentFilename, fDetector, fname, Form(), fOutDir, fOutputStreamManager, fRun, fSubrun, PerStream::GetErrorCode(), Per::kDaqSnarl, Per::kErrFileExists, Per::kErrSuccess, Msg::kInfo, Per::kLightInjection, Per::kRecSplit, MSG, PerOutputStreamManager::OpenStream(), PerOutputStream::SetAutoSave(), PerStreamManager::SetFile(), and WriteConfig().

Referenced by Reco().

00597 {
00598   // Open file for output. Name file *.tdaq.root for triggered data
00599   // Stolen from the Rotorooter...
00600   string fname = 
00601     Form("%c%8.8d_%4.4d",Detector::AsString(det)[0],run,subrun);
00602   
00603   string filename = fOutDir + "/" + fname + ".tdaq.root";
00604   bool ok = true;
00605   int fversion = 0;
00606   // 3 streams in daq file
00607   for (int i = Per::kDaqSnarl;i<=Per::kLightInjection;i++) {
00608     Per::EStreamType stype = (Per::EStreamType) i;
00609     string treeName = Per::AsString(stype);
00610     string rotoStrmName = fname + "." + treeName;
00611     int compressionLevel = 1; // ROOT Default
00612     PerOutputStream* astream =
00613       fOutputStreamManager->OpenStream(rotoStrmName,treeName,
00614                                        "RawRecord","","",Per::kRecSplit,
00615                                        64000,compressionLevel);
00616     if (astream) {
00617       astream->SetAutoSave(0,0); // Turn off autosave
00618       bool openok = 
00619         fOutputStreamManager->SetFile(rotoStrmName,filename,fAccessMode);
00620       MSG("Olt",Msg::kInfo) << "Opened stream "<<rotoStrmName
00621                             << " on file "<<filename<<endl;
00622       // handle potential case where file already exists
00623       // and the rotorooter is in kNew not kRecreate mode
00624       Per::EErrorCode ecode = astream->GetErrorCode();
00625       if (Per::kErrFileExists == ecode) {
00626         string basefilename = filename;
00627         string::size_type where = filename.rfind(".t");
00628         if (string::npos == where) where = filename.rfind(".root");
00629         if (string::npos == where) where = filename.length();
00630         bool keep_trying = true;
00631         // start adding version numbers
00632         do {
00633           ++fversion;
00634           filename = basefilename;  // without any attempt at versioning
00635           filename.insert(where,Form(".%d",fversion));
00636           openok = 
00637             fOutputStreamManager->SetFile(rotoStrmName,filename,fAccessMode);
00638           if (Per::kErrSuccess != ecode) {
00639           MSG("Olt",Msg::kInfo) << "Open versioned file saw Per error: "
00640                                 <<Per::AsString(ecode)<<endl;
00641           }
00642           
00643           ecode = astream->GetErrorCode();
00644           keep_trying = (fversion<100) &&
00645             (Per::kErrFileExists == ecode);
00646         } while (keep_trying);
00647         // report if there was success
00648         if (Per::kErrSuccess == ecode) 
00649           MSG("Olt",Msg::kInfo) << "Open stream on file: "
00650                                 <<filename<<endl;
00651         
00652       } // file exists error
00653       
00654       if (Per::kErrSuccess != ecode) {
00655         MSG("Olt",Msg::kInfo) << "Open stream saw Per error: "
00656                               <<Per::AsString(ecode)<<endl;
00657       }
00658      ok = ok & openok;     
00659     } 
00660     else {
00661       ok = false;
00662     }
00663 
00664   } 
00665   fCurrentFilename = filename;
00666   string rotoStrmName = 
00667     Form("%c%8.8d_%4.4d",Detector::AsString(fDetector)[0],fRun,fSubrun);
00668   WriteConfig(rotoStrmName + "." + "DaqMonitor");
00669   return ok;
00670 }

bool OltNewModule::OpenSpy ( Detector::Detector_t  det,
Int_t  run,
Int_t  subrun 
) [private]

Definition at line 1347 of file OltNewModule.cxx.

References bfld::AsString(), Detector::AsString(), fname, Form(), fOutDir, fSpyStreamManager, fSpyVersion, PerStream::GetErrorCode(), Per::kDaqSnarl, Per::kErrSuccess, Msg::kInfo, Per::kLightInjection, Per::kRecreate, Per::kRecSplit, MSG, PerOutputStreamManager::OpenStream(), PerOutputStream::SetAutoSave(), and PerStreamManager::SetFile().

Referenced by ProcessTimeframe(), and Reco().

01348 {
01349   string fname = 
01350     Form("%c%8.8d_%4.4d",Detector::AsString(det)[0],run,subrun);
01351   string number = Form("_%d",fSpyVersion);
01352   string filename = fOutDir + "/" + fname + number + ".spy.root";
01353   bool ok = true;  
01354   ++fSpyVersion;
01355 
01356 // 3 streams in daq file
01357   for (int i = Per::kDaqSnarl;i<=Per::kLightInjection;i++) {
01358     Per::EStreamType stype = (Per::EStreamType) i;
01359     string treeName = Per::AsString(stype);
01360     string rotoStrmName = fname + "." + treeName;
01361     int compressionLevel = 1; // ROOT Default
01362     PerOutputStream* astream =
01363       fSpyStreamManager->OpenStream(rotoStrmName,treeName,
01364                                        "RawRecord","","",Per::kRecSplit,
01365                                        64000,compressionLevel);
01366     if (astream) {
01367       astream->SetAutoSave(0,0); // Turn off autosave
01368       bool openok = 
01369         fSpyStreamManager->SetFile(rotoStrmName,filename,Per::kRecreate);
01370       MSG("Olt",Msg::kInfo) << "Opened stream "<<rotoStrmName
01371                             << " on file "<<filename<<endl;
01372       // handle potential case where file already exists
01373       // and the rotorooter is in kNew not kRecreate mode
01374       Per::EErrorCode ecode = astream->GetErrorCode();
01375   
01376       
01377       if (Per::kErrSuccess != ecode) {
01378         MSG("Olt",Msg::kInfo) << "Open stream saw Per error: "
01379                               <<Per::AsString(ecode)<<endl;
01380       }
01381       ok = ok & openok;     
01382     } 
01383     else {
01384       ok = false;
01385     }
01386 
01387   } 
01388   return ok;
01389 }

void OltNewModule::ProcessTimeframe ( RawRecord rawrec,
string  rotoStrmName 
) [private]

Definition at line 700 of file OltNewModule.cxx.

References OltNewModule::VaHit::adcValue, OltNewModule::VaHit::chad, chad_ND_TIMING, chad_TOF, CloseSpy(), copy(), DEADTIME, fChipFreeTime, fCounter, fCrateId, fCrateNsec, fCrates, fCrateSec, fCurrentTF, fDetector, fElec, fExtraHits, fHaveNDTimingHit, fHits, fLastTF, fNDFiducialADCCut, fNDTimingHit, fNumToFHits, FormEvents(), fQieFreeTime, fRun, fSortedHits, fSpyMode, fSpyOpen, fSubrun, fTimeframe, fToFConverter, fTofIndex, fUseCounter, fVmmFreeTime, RawRecord::GetRawBlockIter(), RawSnarlHeaderBlock::GetTimeFrameNo(), it, Msg::kDebug, Msg::kInfo, Msg::kVerbose, Msg::kWarning, min, MSG, NCRATES, nentries, OltCounter::NumTDC(), OltCounter::NumTOF(), OpenSpy(), QIEDEADTIME, size, OltNewModule::VaHit::timeStamp, TOF_TARDIS, ToVaTime(), VATICK, and OltCounter::Write().

Referenced by Reco().

00701 {
00702   TIter iter = rawrec->GetRawBlockIter();
00703   while (RawDataBlock *rdb = dynamic_cast<RawDataBlock *>(iter.Next())) {
00704     if (rdb->InheritsFrom("RawSnarlHeaderBlock")) {
00705       RawSnarlHeaderBlock *rshb =dynamic_cast<RawSnarlHeaderBlock *>(rdb);
00706       fTimeframe[fCurrentTF] = rshb->GetTimeFrameNo();
00707       MSG("Olt",Msg::kVerbose) << "Processing Timeframe "<<fTimeframe[fCurrentTF]<<endl;
00708     }
00709     if (rdb->InheritsFrom("RawDigitDataBlock")) {
00710       int size = rdb->GetSize();
00711       const int *block = rdb->GetData();
00712       MSG("Olt",Msg::kVerbose)<<"Data block size: "<<size<<endl;
00713   
00714       int offset = 3;
00715       int thecrate = -1;
00716       while (offset< size-3) {
00717         // Pick up all the crates in the datablock
00718         ++thecrate;
00719         assert(thecrate<NCRATES);
00720         int crateid = block[offset++];
00721         int nentries = block[offset++];
00722         int t0sec = block[offset++];
00723         int t0nsec = block[offset++];
00724         int biggesttime=0; // biggest time for data that hasn;t strayed into
00725                            // the next tf
00726         fCrateId[fCurrentTF][thecrate] = crateid;
00727         fCrateSec[fCurrentTF][thecrate] = t0sec;
00728         fCrateNsec[fCurrentTF][thecrate] = t0nsec;
00729         if (fTimeframe[fCurrentTF]>0) {
00730           //assert(fCrateId[fCurrentTF][thecrate]==fCrateId[fLastTF][thecrate]);
00731         }
00732         if (crateid & 0x40) {
00733           // cout<<"Crate "<<thecrate<<" QIE\n";
00734           fElec[thecrate] = 2;
00735           // QIE
00736           for (int i=0;i<nentries;i++) {
00737             // We don't do anything with the QIE data here, just push it on
00738             // the vector...
00739             long long *qiedata = (long long *)(block + offset);
00740             // Hack to drop hits with times greater than 1s
00741             int thetime = ToVaTime((reinterpret_cast<QieHit *>(qiedata))->timeStamp);
00742             if (thetime > 650000000) {
00743               MSG("Olt",Msg::kWarning)<<"Dropping QIE hit with VA timestamp "
00744                                       << thetime<<endl;
00745             } else {
00746             fHits[fCurrentTF][thecrate].push_back(*qiedata);
00747             }
00748             offset +=2;
00749           }
00750         } else {
00751           //cout<<"Crate "<<thecrate<<" VA\n";
00752           fElec[thecrate] = 1;
00753           //VA
00754           for (int i=0;i<nentries;i++) {
00755             VaHit *hit = (VaHit *)(block + offset);
00756             if (thecrate==0 && hit->chad == (unsigned int)chad_ND_TIMING) {
00757               // Got the ND timing hit.
00758               MSG("Olt",Msg::kDebug)<<"Timeframe "<<fTimeframe[fCurrentTF]<<" timing hit: ";
00759               MSG("Olt",Msg::kDebug)<<"Timestamp "<<int(hit->timeStamp)<<" adc "<<int(hit->adcValue)<<endl;
00760               if (hit->adcValue>fNDFiducialADCCut) {
00761               fNDTimingHit[fCurrentTF] = *(reinterpret_cast<long long *>(hit));
00762               fHaveNDTimingHit = true;
00763               } else {
00764                 MSG("Olt",Msg::kWarning)<<"Ignoring ND fiducial at time "<<int(hit->timeStamp)<<" with adc "<<int(hit->adcValue)<<endl;
00765               }
00766               if (hit->timeStamp>(1000/VATICK)) MSG("Olt",Msg::kWarning)<<
00767                   "Late ND fiducial at time "<<int(hit->timeStamp)<<
00768                   " with adc "<<int(hit->adcValue)<<endl;
00769             }
00770             if (thecrate==0 && hit->chad == (unsigned int)chad_TOF) {
00771               ++fNumToFHits[fCurrentTF];
00772               // if we've produced a -ve number, push the ToF hit to the 
00773               // previous TF.
00774               // if (hit->timeStamp<TOF_TARDIS) hit->timeStamp+=ONE_SECOND;
00775               if (hit->timeStamp<TOF_TARDIS) hit->timeStamp=TOF_TARDIS;
00776               hit->timeStamp-=TOF_TARDIS;
00777             }
00778             int time = hit->timeStamp;
00779             
00780             // Might need to put the ToF tardis in here...
00781             if (time >635000000 && biggesttime < 5000000) {
00782                                                   
00783               if (thecrate==0 && hit->chad == (unsigned int)chad_TOF) --fNumToFHits[fCurrentTF];
00784                       // data really belongs to previous tf
00785               MSG("Olt",Msg::kDebug)<<"Pushing hit with time "<<time
00786                                       <<"to previous tf"<<endl;
00787               if (fTimeframe[fCurrentTF] == 1+fTimeframe[fLastTF]) {
00788                 //push the hit back
00789                 fExtraHits[thecrate].push_back(*(reinterpret_cast<long long *>(hit)));        
00790                 if (thecrate==0 && hit->chad == (unsigned int)chad_TOF) ++fNumToFHits[fLastTF];
00791               }
00792               else {
00793                 if (fTimeframe[fCurrentTF]>0) {
00794                   MSG("Olt",Msg::kWarning)<<"Not pushing hit to previous tf: "
00795                                           <<fTimeframe[fCurrentTF]
00796                                           <<" does not follow "
00797                                           <<fTimeframe[fLastTF]<<endl;
00798                 }
00799               }
00800             }
00801             else {
00802               biggesttime = time;
00803               fHits[fCurrentTF][thecrate].push_back(*(reinterpret_cast<long long *>(hit)));
00804             }
00805             
00806             offset +=2;
00807           }
00808         }
00809       }
00810       fCrates = thecrate + 1;
00811       fCrates = NCRATES;
00812     }
00813   }
00814   // Now Sort This tf, sort extras and insert into last tf.
00815 
00816   for (int i=0;i<fCrates;i++) {
00817     fSortedHits[i].resize(fHits[fLastTF][i].size() + fExtraHits[i].size());
00818     copy(fHits[fLastTF][i].begin(),fHits[fLastTF][i].end(),
00819          fSortedHits[i].begin());
00820     copy(fExtraHits[i].begin(),fExtraHits[i].end(),
00821          fSortedHits[i].begin()+fHits[fLastTF][i].size());
00822     if (fCrateId[fLastTF][i] & 0x40) {
00823       // QIE electronics if this bit is set
00824       sort(fSortedHits[i].begin(),fSortedHits[i].end(),qiesorter());
00825     } else {
00826       sort(fSortedHits[i].begin(),fSortedHits[i].end(),hitsorter());
00827     }
00828   }
00829 
00830   if ((fTimeframe[fLastTF]%60)==0) {
00831     MSG("Olt",Msg::kInfo)<<"Timeframe "
00832                          <<fTimeframe[fLastTF]<<endl;
00833   } else {
00834     MSG("Olt",Msg::kDebug)<<"Timeframe "
00835                           <<fTimeframe[fLastTF]<<endl;
00836     
00837   }
00838  // fLastTF is now guaranteed complete, so form events from it.
00839   // But ditch TF 0
00840     if (fTimeframe[fLastTF] >0) FormEvents(fLastTF,rotoStrmName);
00841   // OK - we've seen all the blocks in this record now, so swap the buffers.
00842 if ((fTofIndex>0) || (fNumToFHits[fLastTF]>0)) 
00843   MSG("Olt",Msg::kInfo) << "TOF: " << fTofIndex << " TDCs, "
00844                         << fNumToFHits[fLastTF] << " hits\n";
00845 
00846   swap(fCurrentTF,fLastTF);
00847   fNumToFHits[fCurrentTF] = 0;
00848   if (fUseCounter && (fTimeframe[fLastTF]%10)==0)fCounter->Write();
00849   if (fSpyMode && (fTimeframe[fLastTF]%120)==0)
00850     {
00851       CloseSpy(fDetector,fRun,fSubrun);
00852       fSpyOpen = OpenSpy(fDetector,fRun,fSubrun);
00853     }
00854   // Dead chip business needs resetting!
00855   for (int crate=0; crate<fCrates; crate++) {
00856     for (int buf=0;buf<2;buf++) {
00857       map<int,int>::iterator it;
00858       for (it = fVmmFreeTime[buf][crate].begin();
00859            it !=fVmmFreeTime[buf][crate].end(); it++) {
00860         (*it).second = min((*it).second-int(1.0e9/VATICK),-2*DEADTIME); // Subtract a second.
00861       }
00862       for (it = fChipFreeTime[buf][crate].begin();
00863            it !=fChipFreeTime[buf][crate].end(); it++) {
00864         (*it).second = min((*it).second-int(1.0e9/VATICK),-2*DEADTIME); // Subtract a second.
00865 
00866       }
00867       for (it = fQieFreeTime[buf][crate].begin();
00868            it!= fQieFreeTime[buf][crate].end(); it++) {
00869         (*it).second = -2*QIEDEADTIME;
00870       }
00871     }
00872   }
00873  
00874   MSG("Olt",Msg::kVerbose)<<"Timeframe "<<fLastTF<<":"
00875                           <<fTimeframe[fLastTF]<<"  "
00876                           <<fCurrentTF<<":"
00877                           <<fTimeframe[fCurrentTF]<<endl;
00878   // and clear the maps ready for the new timeframe
00879 
00880   for (int i=0;i<fCrates;i++) {
00881     fHits[fCurrentTF][i].clear();
00882     fSortedHits[i].clear();
00883     fExtraHits[i].clear();
00884   }
00885  if (fUseCounter && fToFConverter[fCurrentTF]) fCounter->NumTDC(fTimeframe[fCurrentTF],
00886                    fToFConverter[fCurrentTF]->GetNumberOfRawTOFBlocks());
00887   delete fToFConverter[fCurrentTF];
00888   fToFConverter[fCurrentTF]=0;
00889   if (fUseCounter) fCounter->NumTOF(fTimeframe[fCurrentTF],fTofIndex);
00890   fTofIndex = 0;
00891 }

JobCResult OltNewModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 414 of file OltNewModule.cxx.

References Detector::AsString(), CloseFile(), CloseSpy(), copy(), fCounter, fCounterDir, fCrateId, fCrates, fCurrentTF, fDetector, fEventNo, fExtraHits, fFileOpen, fFirst, fHits, RawRecord::FindRawBlock(), fLastTF, fNewRun, fNewRunScript, fNumToFHits, Form(), FormEvents(), fOutputStreamManager, fPlane, fQiePlane, MomNavigator::FragmentIter(), fRecord, fRun, fRunType, fSortedHits, fSpyMode, fSpyOpen, fSubrun, fSummaryDir, fTimeframe, fToFConverter, fUseCounter, Registry::Get(), RawDataBlock::GetBlockId(), VldContext::GetDetector(), RawChannelId::GetEncoded(), PerStreamManager::GetOpenedStream(), PlexSEIdAltL::GetPlane(), RawRecord::GetRawBlockIter(), RawSnarlHeaderBlock::GetRun(), RawDaqHeaderBlock::GetRun(), RawDaqHeaderBlock::GetRunType(), PlexHandle::GetSEIdAltL(), RawSnarlHeaderBlock::GetSubRun(), RawDaqHeaderBlock::GetSubRun(), DataUtil::GetTempTags(), RawSnarlHeaderBlock::GetVldContext(), RawDaqHeaderBlock::GetVldContext(), JobCResult::kAOK, Detector::kCalDet, Msg::kDebug, Msg::kError, JobCResult::kFailed, Msg::kInfo, ElecType::kQIE, Detector::kUnknown, ElecType::kVA, Msg::kVerbose, MSG, OpenFile(), OpenSpy(), ProcessTimeframe(), run(), PerOutputStream::SetObject(), size, PerOutputStream::Store(), and OltCounter::WriteSummary().

00415 {
00416   // Find RawRecord fragment in MOM.
00417   TIter iter = mom->FragmentIter();
00418   while (TObject *obj = iter.Next()) {
00419     RawRecord *rawrec = dynamic_cast<RawRecord *>(obj);
00420     if (rawrec) {
00421       ++fRecord;
00422       MSG("Olt",Msg::kDebug)<<"Record "<<fRecord<<endl;
00423       if (rawrec->FindRawBlock("RawSubRunEndBlock")) continue;
00424       // if (fRecord>5160) {
00425         {
00426       // Find a HeaderBlock and get Run number etc.
00427       int run=0,subrun=0,runtype=0;
00428       Detector::Detector_t detector = Detector::kUnknown;
00429       const RawDaqHeaderBlock *rdhb = dynamic_cast<const RawDaqHeaderBlock *>
00430         (rawrec->FindRawBlock("RawDaqHeaderBlock"));
00431       if (rdhb) {
00432         run = rdhb->GetRun();
00433         subrun = rdhb->GetSubRun();
00434         detector = rdhb->GetVldContext().GetDetector();
00435         runtype = rdhb->GetRunType();
00436         //MSG("Olt",Msg::kInfo)<<rdhb->GetVldContext()<<endl;
00437       }
00438       const RawSnarlHeaderBlock *rshb = dynamic_cast<const RawSnarlHeaderBlock *>(rawrec->FindRawBlock("RawSnarlHeaderBlock"));
00439       if (rshb) {
00440         run = rshb->GetRun();
00441         subrun = rshb->GetSubRun();
00442         detector = rshb->GetVldContext().GetDetector();
00443         //MSG("Olt",Msg::kInfo)<<rshb->GetVldContext()<<endl;
00444         //If first raw record, fill map for plane lookup
00445         //We only trigger on VA electronics at the moment.
00446         if (fFirst) {
00447           VldContext vld = rshb->GetVldContext();
00448           PlexHandle plex(vld);
00449           for (int crate = 0; crate<2;crate++) {
00450             for (int varc=0;varc<3;varc++) {
00451               for (int vmm=0;vmm<7;vmm++) {
00452                 for (int vaadc = 0;vaadc<2;vaadc++) {
00453                   for (int chip=0;chip<3;chip++) {
00454                     for (int channel = 2; channel < 18 ; channel ++) {
00455                       RawChannelId rcid(Detector::kCalDet,
00456                                         ElecType::kVA,
00457                                         crate,varc,vmm,vaadc,chip,channel);
00458                       PlexSEIdAltL seid = plex.GetSEIdAltL(rcid);
00459                       int plane = seid.GetPlane();
00460                       fPlane[crate][channel + (chip<<5) + (vaadc<<7) +
00461                                    (vmm<<8) + (varc<<11)] = plane+1;
00462                     }
00463                   }
00464                 }
00465               }
00466             }
00467           }
00468           // This is a bit of a hack - do this better later
00469           for (int crate = 1 ; crate < 3 ; crate++) {
00470             for (int master = 0 ; master < 32 ; master++ ) {
00471               for (int minder = 0 ; minder < 8 ; minder++ ) {
00472                 for (int menu = 0 ; menu < 16 ; menu++ ) {
00473                   RawChannelId rcid(Detector::kCalDet, 
00474                                     ElecType::kQIE,
00475                                     crate,master,minder,menu);
00476                   PlexSEIdAltL seid = plex.GetSEIdAltL(rcid);
00477                   int plane = seid.GetPlane();
00478                   if (plane>-1&&plane<60) 
00479                     fQiePlane[crate][rcid.GetEncoded()&0x1fff] = plane+1;
00480                 }
00481               }
00482             }
00483           }
00484           fFirst = false;
00485         }
00486       }
00487       if (rdhb || rshb) {
00488         //MSG("Olt",Msg::kInfo)<<"Run "<<run<<" Subrun "<<subrun<<endl;
00489         if (fRun == run && fSubrun == subrun && fFileOpen) {
00490   // OK - we have the right file open
00491         }
00492         else {
00493           if (fFileOpen) {
00494             // Process last TF before closing file.
00495             for (int i=0;i<fCrates;i++) {
00496               fSortedHits[i].resize(fHits[fLastTF][i].size());
00497               copy(fHits[fLastTF][i].begin(),fHits[fLastTF][i].end(),
00498                    fSortedHits[i].begin());
00499               if (fCrateId[fLastTF][i] & 0x40) {
00500                 // QIE electronics if this bit is set
00501                 sort(fSortedHits[i].begin(),fSortedHits[i].end(),qiesorter());
00502               } else {
00503               sort(fSortedHits[i].begin(),fSortedHits[i].end(),hitsorter());
00504               }    
00505             }
00506             MSG("Olt",Msg::kInfo)<<"Last Timeframe "
00507                                  <<fTimeframe[fLastTF]<<endl;
00508             string rotoStrmName = Form("%c%8.8d_%4.4d",
00509                                        Detector::AsString(fDetector)[0],
00510                                        fRun,fSubrun);
00511             rotoStrmName += ".DaqSnarl";
00512             if (fTimeframe[fLastTF] >0) FormEvents(fLastTF,rotoStrmName);
00513             CloseFile(fDetector,fRun,fSubrun);
00514             for (int i=0;i<fCrates;i++) {
00515               fHits[fLastTF][i].clear();
00516               fSortedHits[i].clear();
00517               fExtraHits[i].clear();
00518             }
00519              fTimeframe[fLastTF]=-10;
00520              fNumToFHits[fLastTF] =0;
00521           }
00522           if (fSpyOpen) CloseSpy(fDetector,fRun,fSubrun);
00523           if (fRun !=run) {
00524             fEventNo=0;
00525           }
00526           if (fCounter) fCounter->WriteSummary();
00527           // Hack for Mike and Tricia here!
00528           if (fNewRun && (run!=fRun)) {
00529             // New run, so run script in background.
00530             char c[100];
00531             sprintf(c,"%d",fRun);
00532             string s = fNewRunScript +" "+string(c)+ " &";
00533             system(s.c_str());
00534           }
00535         
00536           fRun = run;
00537           fSubrun = subrun;
00538           fDetector = detector;
00539           fRunType = runtype;
00540           fFileOpen = OpenFile(fDetector,fRun,fSubrun);
00541           if (fSpyMode) fSpyOpen = OpenSpy(fDetector,fRun,fSubrun);
00542           if (fCounter) delete fCounter;
00543           if (fUseCounter) fCounter = new OltCounter(fRun,fSubrun,fCounterDir.c_str(),fSummaryDir);
00544         }
00545         }
00546       if (fRunType==1) return JobCResult::kFailed;
00547 
00548       const char  *streamname =0;
00549       if ( rawrec -> GetTempTags().Get("stream",streamname) )
00550               MSG("Olt",Msg::kVerbose) << "stream " << streamname << endl;
00551       TIter recit = rawrec->GetRawBlockIter();
00552       while (TObject *obj = recit.Next()) {
00553         RawDataBlock *rawdata = dynamic_cast<RawDataBlock *>(obj);
00554         if (rawdata) {
00555           MSG("Olt",Msg::kVerbose) <<rawdata->GetBlockId()<<endl;
00556         }
00557       }
00558       // Write records
00559       string rotoStrmName = 
00560         Form("%c%8.8d_%4.4d",Detector::AsString(detector)[0],run,subrun);
00561       string sname = streamname;
00562       if (sname == "DaqSnarl") {
00563         // Do triggering here
00564         ProcessTimeframe(rawrec,rotoStrmName + "." + streamname);
00565       }
00566       else {
00567         if (sname == "DaqMonitor") {
00568           // Here's a monitor block - construct one of Mike's 
00569           // decoder objects. Have two pointers for these, like [tf].
00570           fToFConverter[fCurrentTF] = new RawTofConverter(rawrec);
00571           //  fCounter->NumTDC(fTimeframe[fCurrentTF],
00572           //               fToFConverter[fCurrentTF]->GetNumberOfRawTOFBlocks());
00573           MSG("Olt",Msg::kDebug)<<"Got TOF TDC data for "<<fCurrentTF<<"  "<<fTimeframe[fCurrentTF]<<endl;
00574         }
00575         rotoStrmName = rotoStrmName + "." + streamname;
00576         if (!fOutputStreamManager) {
00577           MSG("Olt",Msg::kError) << "No output stream manager"<<endl;
00578           return JobCResult::kFailed;
00579         }
00580         PerOutputStream* stream = 0;
00581         stream = dynamic_cast<PerOutputStream*>
00582           (fOutputStreamManager->GetOpenedStream(rotoStrmName));
00583         if (!stream) {
00584           MSG("Olt",Msg::kError) << "Can't find stream "<<rotoStrmName<<endl;
00585           return JobCResult::kFailed;
00586         }
00587         stream->SetObject(rawrec);
00588         stream->Store();
00589       }
00590     }
00591   }
00592   }
00593   return JobCResult::kAOK;
00594 }

int OltNewModule::SuckCrate ( int  crate,
unsigned int &  it,
bool *  hitplane,
OltNewModule::Trigbits trigbits,
int &  teventend,
int  tf 
) [private]

Definition at line 1196 of file OltNewModule.cxx.

References fCrateId, fLastTF, Msg::kVerbose, MSG, SuckQieCrate(), and SuckVaCrate().

Referenced by FormEvents().

01198 {
01199   //cout<<hex<<"Crate "<<crate<<" id "<<fCrateId[fLastTF][crate]<<dec<<endl;
01200   MSG("Olt",Msg::kVerbose)<<"Will Suck Crate"<<crate<<" Id: "<<hex<<fCrateId[fLastTF][crate]<<dec<<endl;
01201   if (fCrateId[fLastTF][crate] & 0x40) {
01202       // QIE electronics if this bit is set
01203     return SuckQieCrate(crate,it,hitplane,trigbits,teventend,tf);
01204   } else {
01205     return SuckVaCrate(crate,it,hitplane,trigbits,teventend,tf);
01206   }
01207 }

int OltNewModule::SuckQieCrate ( int  crate,
unsigned int &  it,
bool *  hitplane,
OltNewModule::Trigbits trigbits,
int &  teventend,
int  tf 
) [private]

Definition at line 1316 of file OltNewModule.cxx.

References OltNewModule::QieHit::adc, fDeadChipBuffer, fGap, fQieFreeTime, fQiePlane, fSortedHits, OltNewModule::QieHit::geo, OltNewModule::Trigbits::issgate, Msg::kVerbose, OltNewModule::QieHit::master, max, OltNewModule::QieHit::minder, MSG, n, QIEDEADTIME, OltNewModule::QieHit::timeStamp, ToVaTime(), and OltNewModule::QieHit::type.

Referenced by SuckCrate().

01319 {
01320   //cout<<"Suck QIE "<<crate<<endl;
01321   MSG("Olt",Msg::kVerbose)<<"In Suck QIE: teventend is "<<teventend<<endl;
01322   //unused: int lastchip = -1;
01323   int n=0;
01324   for (;it<fSortedHits[crate].size();++it) {
01325     QieHit *hit = reinterpret_cast<QieHit *>(&fSortedHits[crate][it]);
01326     if (ToVaTime(hit->timeStamp) < fGap + teventend) {
01327       ++n;
01328       teventend = max(teventend, (int)(ToVaTime(hit->timeStamp)));
01329        MSG("Olt",Msg::kVerbose)<<"Suck QIE Hit at "<<ToVaTime(hit->timeStamp)<<" ts: "<<int(hit->timeStamp)<<" "<<int(hit->master)<<":"<<int(hit->minder)<<" "<<int(hit->adc)<<endl; 
01330        int chad = (hit->minder + (hit->master << 5) + (hit->geo << 8));
01331        hitplane[fQiePlane[crate][chad]] = true;
01332        MSG("Olt",Msg::kVerbose)<<"QIE hit in plane "<<fQiePlane[crate][chad]<<
01333          "  "<<crate<<"  "<<chad<<endl;
01334 
01335        int pmtmask = chad&0x1f80;
01336        fQieFreeTime[fDeadChipBuffer][crate][pmtmask] = ToVaTime(hit->timeStamp) + QIEDEADTIME;
01337 
01338        if (hit->type==4) trigbits.issgate = true;
01339     }
01340     else {
01341       return n;
01342     }
01343   }
01344   return n;
01345 }

int OltNewModule::SuckVaCrate ( int  crate,
unsigned int &  it,
bool *  hitplane,
OltNewModule::Trigbits trigbits,
int &  teventend,
int  tf 
) [private]

Definition at line 1210 of file OltNewModule.cxx.

References OltNewModule::VaHit::adcValue, OltNewModule::Trigbits::cer1, OltNewModule::Trigbits::cer2, OltNewModule::Trigbits::cer3, OltCounter::Cerenkov(), OltNewModule::VaHit::chad, chad_CER1, chad_CER2, chad_CER3, chad_TOF, chad_TRIGPMT, CHAD_VARC0, CHAD_VARC1, DEADTIME, fChipFreeTime, fCounter, fDeadChipBuffer, fDeadChipLastBuffer, fGap, fLastTF, fNumToFHits, fPlane, fSortedHits, fTimeframe, fToFConverter, fTofIndex, fToFOutputArray, fUseCounter, fVmmFreeTime, RawTofConverter::GetNumberOfRawTOFBlocks(), RawTofConverter::GetPackedRawTOFBlock(), OltNewModule::Trigbits::isli, OltNewModule::Trigbits::istof, OltNewModule::Trigbits::isv0, OltNewModule::Trigbits::isv1, Msg::kDebug, Msg::kVerbose, Msg::kWarning, max, MSG, n, OltNewModule::VaHit::timeStamp, ToChip(), OltCounter::Tof(), OltCounter::ToFMismatch(), and ToVmm().

Referenced by SuckCrate().

01213 {
01214   //cout<<"Suck VA "<<crate<<endl;
01215   MSG("Olt",Msg::kVerbose)<<"In Suck VA: teventend is "<<teventend<<endl;
01216   int lastchip = -1;
01217   int n=0;
01218   for (;it<fSortedHits[crate].size();++it) {
01219     VaHit *hit = reinterpret_cast<VaHit *>(&fSortedHits[crate][it]);
01220     if (int(hit->timeStamp) < fGap + teventend) {
01221       ++n;
01222       teventend = max(teventend, (int)hit->timeStamp);
01223       int chad = hit->chad;
01224       MSG("Olt",Msg::kVerbose)<<"Suck VA Hit ts: "<<int(hit->timeStamp)<<" "<<hex<<chad<<dec<<" "<<int(hit->adcValue)<<endl; 
01225      hitplane[fPlane[crate][chad]] = true;
01226      if (crate==0) {
01227         int *tof;
01228         if (chad==chad_TOF) {
01229           trigbits.istof = true;
01230           if (fUseCounter) fCounter->Tof(teventend);
01231           MSG("Olt",Msg::kDebug)<<"Got a hit in [VMM6: VARC2] (TOF)\n";
01232           // We have a TOF hit - get next TDC from the correct Mike
01233           // object here and make an output block.
01234           // shove that block into fToFOutputArray.
01235           if (fToFConverter[tf]) {
01236                     MSG("Olt",Msg::kDebug)<<"TOF Hits: "<<fNumToFHits[tf]<<" TDCs: "<<fToFConverter[tf]->GetNumberOfRawTOFBlocks()<<endl;
01237             if (fToFConverter[tf]->GetNumberOfRawTOFBlocks()==fNumToFHits[tf])
01238               {
01239                 tof =  fToFConverter[tf]->GetPackedRawTOFBlock
01240                   (fTofIndex,reinterpret_cast<long *>(hit));
01241                 if (tof) {
01242                   memcpy(fToFOutputArray,tof,tof[0]*sizeof(long));
01243                   //        ++fTofIndex;        
01244                 } 
01245                 else {
01246                   MSG("Olt",Msg::kWarning)<<"ToF mismatch: tried to assign hit "
01247                                           <<fTofIndex<<" from "
01248                                           <<fToFConverter[fLastTF]->GetNumberOfRawTOFBlocks()
01249                                           <<" TDC readouts at "<<int(hit->timeStamp)<<endl;
01250                 }
01251               }
01252             else {
01253               // Log the ToF Mismatch here
01254               fCounter->ToFMismatch(fTimeframe[tf], fNumToFHits[tf]);
01255             }
01256           }
01257           else {
01258             MSG("Olt",Msg::kWarning)<<"ToF mismatch: tried to assign hit "
01259                                     <<fTofIndex
01260                                     <<" but there was no TOF block present\n";
01261           }         
01262           ++fTofIndex;  
01263         }             
01264         else if (chad==chad_CER1) {
01265           trigbits.cer1 = true;
01266           if (fUseCounter) fCounter->Cerenkov(1,hit->adcValue,hit->timeStamp);
01267         }
01268         else if (chad== chad_CER2) {
01269           trigbits.cer2 = true;
01270           if (fUseCounter) fCounter->Cerenkov(2,hit->adcValue,hit->timeStamp);
01271         }
01272         else if (chad == chad_CER3) {
01273           trigbits.cer3 = true;
01274           if (fUseCounter) fCounter->Cerenkov(3,hit->adcValue,hit->timeStamp);
01275         }
01276         else if (chad==CHAD_VARC1){
01277           trigbits.isv1 = true;
01278           //      MSG("Olt",Msg::kInfo)<<"Got a hit in VMM6: VARC1\n";
01279         }
01280         else if (chad== CHAD_VARC0) {
01281           trigbits.isv0 = true;
01282           //      MSG("Olt",Msg::kInfo)<<"Got a hit in VMM6: VARC0\n";
01283         }
01284         else if (chad==chad_TRIGPMT) {
01285           trigbits.isli = true;
01286         }
01287      }
01288     
01289     
01290       int chip = ToChip(hit->chad);
01291       int vmm = ToVmm(hit->chad);
01292       
01293       if (chip!=lastchip) {
01294           lastchip = chip;
01295           int tstart = max(fVmmFreeTime[fDeadChipLastBuffer][crate][vmm],
01296                            (int)hit->timeStamp);
01297           tstart = max(fVmmFreeTime[fDeadChipBuffer][crate][vmm],
01298                            tstart);
01299           fChipFreeTime[fDeadChipBuffer][crate][chip] = tstart + DEADTIME;
01300           fVmmFreeTime[fDeadChipBuffer][crate][vmm] = tstart + DEADTIME;
01301       }
01302 
01303     }
01304     else {
01305       return n;
01306     }
01307   }
01308   return n;
01309 }

int OltNewModule::ToChad ( int  varc,
int  vmm,
int  adc,
int  chip,
int  channel 
) [static, private]

Definition at line 1131 of file OltNewModule.cxx.

Referenced by OltNewModule().

01132 {
01133   return channel + (chip<<5) + (adc<<7) + (vmm<<8) + (varc<<11);
01134 }

int OltNewModule::ToChip ( int  chad  )  [static, private]

Definition at line 1121 of file OltNewModule.cxx.

Referenced by SuckVaCrate().

01122 {
01123   return (chad & 0x1fe0);
01124 }

int OltNewModule::ToVaTime ( unsigned int  qietime  )  [private]

Definition at line 1311 of file OltNewModule.cxx.

References fQieOffset.

Referenced by FormEvents(), ProcessTimeframe(), and SuckQieCrate().

01312 {
01313   return (int)(qietime * 16 * 58.0/77.0 + fQieOffset);
01314 }

int OltNewModule::ToVmm ( int  chad  )  [static, private]

Definition at line 1126 of file OltNewModule.cxx.

Referenced by SuckVaCrate().

01127 {
01128 return (chad & 0x1f00);
01129 }

void OltNewModule::WriteConfig ( string  rotoStrmName  )  [private]

Definition at line 1412 of file OltNewModule.cxx.

References MomNavigator::AdoptFragment(), RawRecord::AdoptRawBlock(), fDetector, fRun, fRunType, fSubrun, JobCModule::GetConfig(), SimFlag::kData, Registry::PrintStream(), and WriteMom().

Referenced by OpenFile().

01413 {
01414 
01415   VldTimeStamp now((const time_t)0,0); 
01416   VldContext vldc(fDetector,SimFlag::kData,now);
01417   RawDaqHeader *rawHead = new
01418     RawDaqHeader(vldc,fRun,fSubrun,fRunType,0);
01419   RawRecord *rawRec = new RawRecord(rawHead);
01420   RawDaqHeaderBlock *rawHeadBlk =
01421     new RawDaqHeaderBlock(vldc,fRun,fSubrun,fRunType,0);
01422   rawRec->AdoptRawBlock(rawHeadBlk);
01423   Registry &r = this->GetConfig();
01424   ostringstream text;
01425   r.PrintStream(text);
01426   char cvs[] = "$Id: OltNewModule.cxx,v 1.59 2017/03/03 16:53:03 rhatcher Exp $\n";
01427   string blah(cvs);
01428   blah+=text.str();
01429   RawRunConfigBlock *rawRunConfigBlk =
01430      new RawRunConfigBlock(vldc,fRun,fSubrun,fRunType,blah.c_str());
01431   rawRec->AdoptRawBlock(rawRunConfigBlk);
01432 
01433   MomNavigator *mom = new MomNavigator;
01434   mom->AdoptFragment(rawRec);
01435   WriteMom(mom,rotoStrmName,0);
01436   delete mom;
01437 
01438 }

void OltNewModule::WriteEvent ( unsigned long  teventstart,
int  ntrig,
int  tf,
unsigned int *  start,
unsigned int *  end,
string  rotoStrmName 
) [private]

Definition at line 1028 of file OltNewModule.cxx.

References mdBlockGenericHeader_t::blockId, BLOCKID_BITPOS_DETECTOR, BLOCKID_BITPOS_IDENTIFIER, RotoObjectifier::BufferInflate(), mdBlockGenericHeader_t::checksum, mdBlockSnarlHeader_t::errorCode, fBuffer, fCrateId, fCrateNsec, fCrates, fCrateSec, fDeadBuf, fEventNo, fHaveNDTimingHit, fNDTimingHit, fRun, fRunType, fSortedHits, fSubrun, fTimeframe, fToFOutputArray, mdBlockSnarlHeader_t::gHdr, it, kMdBlockCrateReadout, kMdBlockSnarlHeader, kMdBlockSourceCalDetector, mdBlockGenericHeader_t::lenBlockWords, mdTimeStamp_t::nsec, rdxsum_fill(), mdBlockSnarlHeader_t::runNumber, mdTimeStamp_t::sec, mdBlockSnarlHeader_t::snarlNumber, mdBlockSnarlHeader_t::subRunAndType, mdBlockSnarlHeader_t::timeFrameNumber, mdBlockSnarlHeader_t::timeStamp, TRIG_TOF_MASK, mdBlockSnarlHeader_t::triggerSource, VATICK, and WriteMom().

Referenced by FormEvents().

01032 {
01033   int bufpos = 0;
01034   //memset(fBuffer,0,200000*sizeof(long));
01035   //Snarl Header Block.
01036   mdBlockSnarlHeader_t *sh = reinterpret_cast<mdBlockSnarlHeader_t *>
01037     (fBuffer + bufpos);
01038   sh->gHdr.lenBlockWords = 11;
01039   sh->gHdr.checksum = 0;
01040   sh->gHdr.blockId = (kMdBlockSnarlHeader<<BLOCKID_BITPOS_IDENTIFIER) |
01041     (kMdBlockSourceCalDetector<<BLOCKID_BITPOS_DETECTOR) | (1);//minor 1
01042   sh->runNumber = fRun;
01043   sh->subRunAndType = (fSubrun<<16) & fRunType;
01044   sh->timeStamp.sec = fCrateSec[tf][0];
01045   sh->timeStamp.nsec = fCrateNsec[tf][0]+int(teventstart*VATICK);
01046   if (sh->timeStamp.nsec>1000000000L) {
01047     sh->timeStamp.nsec-=1000000000L;
01048     sh->timeStamp.sec+=1;
01049   }
01050   sh->timeFrameNumber = fTimeframe[tf];
01051   sh->snarlNumber = fEventNo;
01052   sh->triggerSource = trigword;
01053   sh->errorCode = 0;
01054   rdxsum_fill((int32_t*)sh,0);  // fill in the checksum value
01055   bufpos +=sh->gHdr.lenBlockWords;
01056 
01057   //Crate Readout Block
01058   mdBlockGenericHeader_t *cratehead = 
01059     reinterpret_cast<mdBlockGenericHeader_t *>(fBuffer + bufpos);
01060   cratehead->checksum = 0;
01061   cratehead->blockId = (kMdBlockCrateReadout<<BLOCKID_BITPOS_IDENTIFIER) | 
01062     (kMdBlockSourceCalDetector<<BLOCKID_BITPOS_DETECTOR) | (1); // minor 1
01063   int nwords=0;
01064   unsigned long *nhits;
01065   bufpos+=3;
01066 
01067   // Special - write ND fiducial hit here.
01068  
01069   for (int crate = 0; crate<fCrates ; crate++) {
01070     if ((fHaveNDTimingHit&&crate==0)||(start[crate]!=end[crate])){
01071       nwords +=4;
01072       fBuffer[bufpos++] = fCrateId[tf][crate];
01073       nhits = fBuffer + bufpos;
01074       fBuffer[bufpos++] = 0;
01075       fBuffer[bufpos++] = fCrateSec[tf][crate]; // cratet0sec
01076       fBuffer[bufpos++] = fCrateNsec[tf][crate]; // cratet0nsec
01077       if (crate==0 && fHaveNDTimingHit) {
01078         long long *ptr = reinterpret_cast<long long *>(fBuffer + bufpos);
01079         *ptr = fNDTimingHit[tf];
01080         bufpos+=2;
01081         nwords+=2;
01082         (*nhits)+=1;
01083       }
01084       for (unsigned int it = start[crate];
01085            it!=end[crate];++it) {
01086         long long *ptr = reinterpret_cast<long long *>(fBuffer + bufpos);
01087         *ptr = fSortedHits[crate][it];
01088         bufpos+=2;
01089         nwords+=2;
01090         (*nhits)+=1;
01091       }
01092     }
01093   }
01094   cratehead->lenBlockWords = nwords + 3;
01095   rdxsum_fill((int32_t*)cratehead,0);  // fill in the checksum value
01096  
01097   // Dead Chips
01098   memcpy(fBuffer+bufpos,fDeadBuf,fDeadBuf[0]*sizeof(long));
01099   bufpos +=fDeadBuf[0];
01100 
01101   // ToF Block
01102   if (trigword & TRIG_TOF_MASK) {
01103     memcpy(fBuffer+bufpos,fToFOutputArray,fToFOutputArray[0]*sizeof(long));
01104     bufpos +=fToFOutputArray[0];
01105     fToFOutputArray[0]=0; // Set size to 0 so we don't keep producing
01106     //the last buffer in the case of mismatched ToF hits.
01107   }
01108 
01109   int status;
01110   MomNavigator *mom = 
01111     RotoObjectifier::BufferInflate(reinterpret_cast<const char*>(fBuffer),
01112                                    bufpos*sizeof(long),status);
01113   WriteMom(mom,rotoStrmName,trigword);
01114   delete mom;
01115   ++fEventNo;
01116 } 

void OltNewModule::WriteMom ( MomNavigator mom,
string  rotoStrmName,
int  trigword 
) [private]

Definition at line 1440 of file OltNewModule.cxx.

References fOutputStreamManager, MomNavigator::FragmentIter(), fSpyMode, fSpyStreamManager, RawDataBlock::GetBlockId(), PerStreamManager::GetOpenedStream(), RawRecord::GetRawBlockIter(), Msg::kDebug, Msg::kError, MSG, PerOutputStream::SetObject(), PerOutputStream::Store(), TRIG_CER1_MASK, TRIG_CER2_MASK, TRIG_PLANE_MASK, TRIG_TOF_MASK, and TRIG_VARC0_MASK.

Referenced by WriteConfig(), and WriteEvent().

01441 {
01442   // MSG("Olt",Msg::kDebug)<<"Sent "<<bufpos<<" words to the rooter"<<endl;
01443   TIter iter = mom->FragmentIter();
01444   while (TObject *obj = iter.Next()) {
01445     RawRecord *rawrec = dynamic_cast<RawRecord *>(obj);
01446     MSG("Olt",Msg::kDebug)<<"RawRec: "<<rawrec<<endl;
01447     TIter recit = rawrec->GetRawBlockIter();
01448     while (TObject *obj = recit.Next()) {
01449       RawDataBlock *rawdata = dynamic_cast<RawDataBlock *>(obj);
01450       if (rawdata) {
01451         MSG("Olt",Msg::kDebug) <<rawdata->GetBlockId()<<endl;
01452       }
01453     }
01454     if (rawrec) {
01455       if (!fOutputStreamManager) {
01456         MSG("Olt",Msg::kError) << "No output stream manager"<<endl;
01457         return;
01458       }
01459       PerOutputStream* stream = 0;
01460       stream = dynamic_cast<PerOutputStream*>
01461         (fOutputStreamManager->GetOpenedStream(rotoStrmName));
01462       if (!stream) {
01463         MSG("Olt",Msg::kError) << "Can't find stream "<<rotoStrmName<<endl;
01464         return;
01465       }
01466       stream->SetObject(rawrec);
01467       stream->Store();
01468       //Spy...
01469       if (fSpyMode) {
01470         if ((trigword & (TRIG_CER2_MASK | TRIG_CER1_MASK | TRIG_TOF_MASK | TRIG_VARC0_MASK))
01471             && (trigword & TRIG_PLANE_MASK)){
01472           if (!fSpyStreamManager) { 
01473             MSG("Olt",Msg::kError) << "No output stream manager"<<endl;
01474             return;
01475           }
01476           PerOutputStream* spystream = 0;
01477           spystream = dynamic_cast<PerOutputStream*>
01478             (fSpyStreamManager->GetOpenedStream(rotoStrmName));
01479           if (!spystream) {
01480             MSG("Olt",Msg::kError) << "Can't find spy stream "<<rotoStrmName<<endl;
01481             return;
01482           }
01483           spystream->SetObject(rawrec);
01484           spystream->Store();
01485         }
01486       }
01487     }
01488     else {
01489       MSG("Olt",Msg::kError) <<"Didn't get a rawrec back from BufferInflate()"
01490                              <<endl;
01491     }
01492   }
01493   
01494 
01495 }


Member Data Documentation

int OltNewModule::chad_CER1 [private]

Definition at line 319 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::CHAD_CER1 = 0x5b0 [static, private]

Definition at line 312 of file OltNewModule.h.

Referenced by DefaultConfig().

int OltNewModule::chad_CER2 [private]

Definition at line 320 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::CHAD_CER2 = 0x590 [static, private]

Definition at line 313 of file OltNewModule.h.

Referenced by DefaultConfig().

int OltNewModule::chad_CER3 [private]

Definition at line 321 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::CHAD_CER3 = 0x5d0 [static, private]

Definition at line 314 of file OltNewModule.h.

Referenced by DefaultConfig().

Definition at line 323 of file OltNewModule.h.

Referenced by ProcessTimeframe().

const int OltNewModule::CHAD_ND_TIMING = 0x590 [static, private]

Definition at line 316 of file OltNewModule.h.

Referenced by DefaultConfig().

int OltNewModule::chad_TOF [private]

Definition at line 318 of file OltNewModule.h.

Referenced by ProcessTimeframe(), and SuckVaCrate().

const int OltNewModule::CHAD_TOF = 0x1602 [static, private]

Definition at line 309 of file OltNewModule.h.

Referenced by DefaultConfig().

Definition at line 322 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::CHAD_TRIGPMT = 0x1524 [static, private]

Definition at line 315 of file OltNewModule.h.

Referenced by DefaultConfig().

const int OltNewModule::CHAD_VARC0 = 0x602 [static, private]

Definition at line 311 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::CHAD_VARC1 = 0xe02 [static, private]

Definition at line 310 of file OltNewModule.h.

Referenced by SuckVaCrate().

const int OltNewModule::DEADTIME = 6080 [static, private]

Definition at line 337 of file OltNewModule.h.

Referenced by ProcessTimeframe(), and SuckVaCrate().

Definition at line 218 of file OltNewModule.h.

Referenced by OltNewModule(), and OpenFile().

bool OltNewModule::fAllData [private]

Definition at line 358 of file OltNewModule.h.

Referenced by FormEvents().

unsigned long* OltNewModule::fBuffer [private]

Definition at line 297 of file OltNewModule.h.

Referenced by OltNewModule(), WriteEvent(), and ~OltNewModule().

std::vector<std::map<int,int> > OltNewModule::fChipFreeTime[2] [private]

Definition at line 268 of file OltNewModule.h.

Referenced by CalculateDeadChips(), OltNewModule(), ProcessTimeframe(), and SuckVaCrate().

string OltNewModule::fCounterDir [private]

Definition at line 216 of file OltNewModule.h.

Referenced by Reco().

int OltNewModule::fCrateId[2][NCRATES] [private]

Definition at line 263 of file OltNewModule.h.

Referenced by FormEvents(), OltNewModule(), ProcessTimeframe(), Reco(), SuckCrate(), and WriteEvent().

int OltNewModule::fCrateNsec[2][NCRATES] [private]

Definition at line 266 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and WriteEvent().

int OltNewModule::fCrates [private]

Definition at line 264 of file OltNewModule.h.

Referenced by CalculateDeadChips(), FormEvents(), ProcessTimeframe(), Reco(), and WriteEvent().

int OltNewModule::fCrateSec[2][NCRATES] [private]

Definition at line 265 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and WriteEvent().

Definition at line 214 of file OltNewModule.h.

Referenced by CloseFile(), and OpenFile().

int OltNewModule::fCurrentTF [private]

Definition at line 282 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and Reco().

unsigned long* OltNewModule::fDeadBuf [private]

Definition at line 299 of file OltNewModule.h.

Referenced by CalculateDeadChips(), OltNewModule(), WriteEvent(), and ~OltNewModule().

Definition at line 269 of file OltNewModule.h.

Referenced by FormEvents(), OltNewModule(), SuckQieCrate(), and SuckVaCrate().

Definition at line 270 of file OltNewModule.h.

Referenced by FormEvents(), OltNewModule(), and SuckVaCrate().

int OltNewModule::fElec[NCRATES] [private]

Definition at line 366 of file OltNewModule.h.

Referenced by CalculateDeadChips(), and ProcessTimeframe().

unsigned long OltNewModule::fEventNo [private]

Definition at line 298 of file OltNewModule.h.

Referenced by OltNewModule(), Reco(), and WriteEvent().

Definition at line 361 of file OltNewModule.h.

Referenced by FormEvents().

std::vector<long long> OltNewModule::fExtraHits[NCRATES] [private]

Definition at line 244 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and Reco().

bool OltNewModule::fFileOpen [private]

Definition at line 223 of file OltNewModule.h.

Referenced by OltNewModule(), Reco(), and ~OltNewModule().

bool OltNewModule::fFirst [private]

Definition at line 295 of file OltNewModule.h.

Referenced by OltNewModule(), and Reco().

int OltNewModule::fGap [private]

Definition at line 287 of file OltNewModule.h.

Referenced by OltNewModule(), SuckQieCrate(), and SuckVaCrate().

Definition at line 357 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and WriteEvent().

std::vector<long long> OltNewModule::fHits[2][NCRATES] [private]

Definition at line 243 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and Reco().

int OltNewModule::fLastTF [private]

Definition at line 283 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), Reco(), SuckCrate(), and SuckVaCrate().

unsigned int OltNewModule::fNDFiducialADCCut [private]

Definition at line 363 of file OltNewModule.h.

Referenced by ProcessTimeframe().

long long OltNewModule::fNDTimingHit[2] [private]

Definition at line 352 of file OltNewModule.h.

Referenced by ProcessTimeframe(), and WriteEvent().

bool OltNewModule::fNewRun [private]

Definition at line 355 of file OltNewModule.h.

Referenced by Reco().

string OltNewModule::fNewRunScript [private]

Definition at line 354 of file OltNewModule.h.

Referenced by Reco().

int OltNewModule::fNumPlanes [private]

Definition at line 362 of file OltNewModule.h.

Referenced by FormEvents().

int OltNewModule::fNumToFHits[2] [private]

Definition at line 306 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), Reco(), and SuckVaCrate().

string OltNewModule::fOutDir [private]

Definition at line 213 of file OltNewModule.h.

Referenced by CloseFile(), OltNewModule(), OpenFile(), and OpenSpy().

Definition at line 212 of file OltNewModule.h.

Referenced by CloseFile(), OltNewModule(), OpenFile(), Reco(), and WriteMom().

__gnu_cxx::hash_map<int,int> OltNewModule::fPlane[NCRATES] [private]

Definition at line 292 of file OltNewModule.h.

Referenced by Reco(), and SuckVaCrate().

std::vector<std::map<int,int> > OltNewModule::fQieFreeTime[2] [private]

Definition at line 272 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and SuckQieCrate().

int OltNewModule::fQieOffset [private]

Definition at line 349 of file OltNewModule.h.

Referenced by ToVaTime().

__gnu_cxx::hash_map<int,int> OltNewModule::fQiePlane[NCRATES] [private]

Definition at line 293 of file OltNewModule.h.

Referenced by Reco(), and SuckQieCrate().

int OltNewModule::fRecord [private]

Definition at line 345 of file OltNewModule.h.

Referenced by OltNewModule(), and Reco().

Int_t OltNewModule::fRun [private]
Int_t OltNewModule::fRunType [private]

Definition at line 231 of file OltNewModule.h.

Referenced by Reco(), WriteConfig(), and WriteEvent().

std::vector<long long> OltNewModule::fSortedHits[NCRATES] [private]
bool OltNewModule::fSpyMode [private]

Definition at line 226 of file OltNewModule.h.

Referenced by ProcessTimeframe(), Reco(), and WriteMom().

bool OltNewModule::fSpyOpen [private]

Definition at line 224 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), Reco(), and ~OltNewModule().

Definition at line 220 of file OltNewModule.h.

Referenced by CloseSpy(), OltNewModule(), OpenSpy(), and WriteMom().

Definition at line 221 of file OltNewModule.h.

Referenced by OpenSpy().

Int_t OltNewModule::fSubrun [private]
string OltNewModule::fSummaryDir [private]

Definition at line 217 of file OltNewModule.h.

Referenced by Reco().

string OltNewModule::fSymlinkDir [private]

Definition at line 215 of file OltNewModule.h.

Referenced by CloseFile(), and OltNewModule().

int OltNewModule::fTimeframe[2] [private]

Definition at line 304 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), Reco(), and SuckVaCrate().

int OltNewModule::fTofIndex [private]

Definition at line 305 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and SuckVaCrate().

unsigned long* OltNewModule::fToFOutputArray [private]

Definition at line 303 of file OltNewModule.h.

Referenced by OltNewModule(), SuckVaCrate(), WriteEvent(), and ~OltNewModule().

int OltNewModule::fTrigMask [private]

Definition at line 360 of file OltNewModule.h.

Referenced by FormEvents().

bool OltNewModule::fUseCounter [private]

Definition at line 359 of file OltNewModule.h.

Referenced by CalculateDeadChips(), FormEvents(), ProcessTimeframe(), Reco(), and SuckVaCrate().

std::vector<std::map<int,int> > OltNewModule::fVmmFreeTime[2] [private]

Definition at line 267 of file OltNewModule.h.

Referenced by OltNewModule(), ProcessTimeframe(), and SuckVaCrate().

const int OltNewModule::ONE_SECOND = 640000000 [static, private]

Definition at line 339 of file OltNewModule.h.

const int OltNewModule::QIEDEADTIME = 8000 [static, private]

Definition at line 338 of file OltNewModule.h.

Referenced by ProcessTimeframe(), and SuckQieCrate().

const unsigned int OltNewModule::TOF_TARDIS = 100 [static, private]

Definition at line 340 of file OltNewModule.h.

Referenced by ProcessTimeframe().

const int OltNewModule::TRIG_CER1_MASK = 0x10 [static, private]

Definition at line 328 of file OltNewModule.h.

Referenced by FormEvents(), and WriteMom().

const int OltNewModule::TRIG_CER2_MASK = 0x20 [static, private]

Definition at line 329 of file OltNewModule.h.

Referenced by FormEvents(), and WriteMom().

const int OltNewModule::TRIG_LI_MASK = 0x2 [static, private]

Definition at line 325 of file OltNewModule.h.

Referenced by FormEvents().

const int OltNewModule::TRIG_NUM_SHIFT = 8 [static, private]

Definition at line 333 of file OltNewModule.h.

Referenced by FormEvents().

const int OltNewModule::TRIG_PLANE_MASK = 0x4 [static, private]

Definition at line 326 of file OltNewModule.h.

Referenced by FormEvents(), and WriteMom().

const int OltNewModule::TRIG_SGATE_MASK = 0x80 [static, private]

Definition at line 332 of file OltNewModule.h.

Referenced by FormEvents().

const int OltNewModule::TRIG_TOF_MASK = 0x8 [static, private]

Definition at line 327 of file OltNewModule.h.

Referenced by FormEvents(), WriteEvent(), and WriteMom().

const int OltNewModule::TRIG_VARC0_MASK = 0x40 [static, private]

Definition at line 330 of file OltNewModule.h.

Referenced by FormEvents(), and WriteMom().

const int OltNewModule::TRIG_VARC1_MASK = 0x80 [static, private]

Definition at line 331 of file OltNewModule.h.

const double OltNewModule::VATICK [static, private]

Definition at line 335 of file OltNewModule.h.

Referenced by DefaultConfig(), ProcessTimeframe(), and WriteEvent().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1