RerootToRawDataModule Class Reference

#include <RerootToRawDataModule.h>

Inheritance diagram for RerootToRawDataModule:
JobCModule

List of all members.

Public Member Functions

 RerootToRawDataModule ()
 ~RerootToRawDataModule ()
JobCResult Get (MomNavigator *mom)
JobCResult Reco (MomNavigator *mom)
void HandleCommand (JobCommand *command)

Private Member Functions

void InitWorkingArray (void)
void AddToCrate (const PlexStripEndId &seid, const RawChannelId &rcid, Float_t raw, Float_t tdc)
RawDataBlockFinalizeWorkingArray (void)
JobCResult ApplyTrigger ()

Private Attributes

TRandom * random
UInt_t fDebugFlags
Detector::Detector_t detector
Float_t fRawPeCut
Int_t ncrates
TArrayI * workingcrates
TArrayI * cratesizeused
Int_t nwordsblock
TArrayI * workingarray
CheezyDisplaydisplay
TArrayI ndigitsPerPlane
Int_t Nplaneshit
Int_t ofMplanes

Detailed Description

Definition at line 35 of file RerootToRawDataModule.h.


Constructor & Destructor Documentation

RerootToRawDataModule::RerootToRawDataModule (  ) 

Definition at line 53 of file RerootToRawDataModule.cxx.

References Detector::kUnknown.

00054    : random(0), fDebugFlags(0), fRawPeCut(0.2999), 
00055    ncrates(0), workingcrates(0), cratesizeused(0),
00056    workingarray(0), display(0),
00057    Nplaneshit(0), ofMplanes(0)
00058 {
00059    // construct a new "RerootToRawDataModule" JobControl module
00060 
00061    // we'll use a random # generator to set fake "trigbits"
00062    // the generator can live as long as the module
00063    random = new TRandom();
00064 
00065    // initialize detector to non-legal value
00066    detector = Detector::kUnknown;
00067 
00068    ncrates = 128;
00069    cratesizeused  = new TArrayI(ncrates);
00070    workingcrates  = new TArrayI [ncrates];
00071 
00072    Int_t init_alloc = 5 + 100*3;
00073    for (Int_t i=0; i<ncrates; i++) {
00074       cratesizeused->AddAt(0,i);
00075       workingcrates[i].Set(init_alloc);
00076    }
00077 
00078    nwordsblock = 0;
00079    workingarray = new TArrayI(2);
00080 
00081 
00082 }

RerootToRawDataModule::~RerootToRawDataModule (  ) 

Definition at line 86 of file RerootToRawDataModule.cxx.

References cratesizeused, display, Msg::kVerbose, MSG, ncrates, random, workingarray, and workingcrates.

00087 {
00088   MSG("Exodus", Msg::kVerbose) << "RerootToRawDataModule::Destructor\n";
00089 
00090   if (random) delete random;
00091   random = 0;
00092 
00093   if (ncrates) {
00094      delete [] workingcrates;
00095      workingcrates = 0;
00096 
00097      delete cratesizeused;
00098      cratesizeused = 0;
00099 
00100      ncrates = 0;
00101   }
00102 
00103   if (workingarray) delete workingarray;
00104   workingarray = 0;
00105 
00106   if (display) delete display;
00107   display = 0;
00108 
00109 }


Member Function Documentation

void RerootToRawDataModule::AddToCrate ( const PlexStripEndId seid,
const RawChannelId rcid,
Float_t  raw,
Float_t  tdc 
) [private]

Definition at line 419 of file RerootToRawDataModule.cxx.

References PlexStripEndId::AsString(), RawChannelId::AsString(), RerootExodus::BuildVldContext(), cratesizeused, dbg_DumpAddToCrate, dbg_DumpNewCrate, extra(), fDebugFlags, fRawPeCut, RawChannelId::GetChAdd(), RawChannelId::GetCrate(), RawChannelId::GetDetector(), RawChannelId::GetElecType(), PlexStripEndId::GetEncoded(), PlexPlaneId::GetPlane(), VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), Detector::kCalDet, Msg::kFatal, Msg::kInfo, ElecType::kQIE, ElecType::kVA, Msg::kWarning, MSG, ncrates, ndigitsPerPlane, tdc_convert, and workingcrates.

Referenced by Get().

00422 {
00423    // Add this entry into the crate array
00424 
00425    // apply the cut if necessary
00426    if (raw < fRawPeCut ) {
00427       static Float_t last_cut_msg = -1;
00428       if (last_cut_msg != fRawPeCut) {
00429          // one warning for any given cut level
00430          last_cut_msg = fRawPeCut;
00431          MSG("Exodus",Msg::kInfo)
00432             << "::AddToCrate cutting all raw values < "
00433             << fRawPeCut << endl;
00434       }
00435       return;
00436    }
00437 
00438    // keep track of # of digits in each plane (above threshold)
00439    Int_t plane = seid.GetPlane();
00440    if (ndigitsPerPlane.GetSize()<plane+1) ndigitsPerPlane.Set(plane+1);
00441    ndigitsPerPlane[plane]++;
00442 
00443    Int_t crate = rcid.GetCrate();
00444    if (crate>=ncrates) {
00445       MSG("Exodus",Msg::kFatal) 
00446          << "RerootToRawDataModule::AddToCrate "
00447          << crate << " larger than allocated " << ncrates << endl;
00448       return;
00449    }
00450 
00451    TArrayI *wcrate = &workingcrates[crate];
00452 
00453    //  Crate block format is:
00454    //-------------------------
00455    //   0: Crate #
00456    //   1: # ndigits in crate (N)
00457    //   2: GPS T0 sec
00458    //   3: GPS T0 nsec
00459    //   4: readout 1 word 1
00460    //   5: readout 1 word 2
00461    //   6: PlexStripEndId.fEncoded truth
00462    //   7: readout 2 word 1
00463    //   8: readout 2 word 2
00464    //   9: PlexStripEndId.fEncoded truth
00465 
00466    const Int_t hsize        = 4; // header size
00467    const Int_t ndigits_indx = 1; // index for pair count
00468    const Int_t nw_digit     = 3; // 3 words per digit
00469 
00470    // if allocated size is too small make it bigger
00471    Int_t used = cratesizeused->At(crate);
00472    Int_t need = used + nw_digit;  // each new entry adds three words
00473    if (0 == used) need += hsize;
00474 
00475    const Int_t slop = 100; // min extra allocation
00476 
00477    if (wcrate->GetSize() < need) {
00478       wcrate->Set(need+slop);
00479    }
00480 
00481    // add in header stuff if necessary
00482    if (0 == used) {
00483       // crate # + ped/common modes + electronics flag
00484       const Int_t modes = 0x07;
00485       Int_t etype = rcid.GetElecType();
00486       Int_t packedCrate = (modes << 8) |
00487          (etype << 6) | (crate & 0x0000003f);
00488       wcrate->AddAt(packedCrate,used++);
00489       // # digits
00490       if (used != ndigits_indx) {
00491          // this should never happen
00492          MSG("Exodus",Msg::kFatal) 
00493             << "RerootToRawDataModule::AddToCrate ndigits_indx "
00494             << ndigits_indx << " != " << used << endl;
00495       }
00496       wcrate->AddAt(0,used++);
00497       // GPS T0 (sec,nsec)
00498       VldTimeStamp vts = RerootExodus::BuildVldContext().GetTimeStamp();
00499       wcrate->AddAt(vts.GetSec(),used++);
00500       // NT 08/03 The crate T0 measures the time time of the start of the timeframe,
00501       // NOT the time of the event.
00502       //wcrate->AddAt(vts.GetNanoSec(),used++);
00503       wcrate->AddAt(0,used++);
00504 
00505       // if flag is set dump what we just did
00506       if (fDebugFlags & dbg_DumpNewCrate) {
00507          printf("new header for crate %3d %#8.8x\n",crate,packedCrate);
00508       }
00509    }
00510 
00511    //       3         2         1         0
00512    //      10987654321098765432109876543210
00513    //  U:  1PXcccccccccccchhaaaaaaaaaaaaaa   X=common mode,c=chan, h=hdr a=adc
00514    //  L:  0Pttttttttttttttttttttttttttttt   P=parity, t=tdc
00515    //  X:  PlexStripEndId::fEncoded
00516 
00517    const int signbit    = 0x80000000;
00518 //rwh:not_used_yet   const int hdrmask    = 0x0000c000;
00519 //rwh:not_used_yet   const int parityb    = 0x40000000;
00520 //rwh:not_used_yet   const int cmodeb     = 0x20000000;
00521    const int chaddmask  = 0x1fff;
00522    const int chaddshift = 16;
00523    const int adcmask    = 0x00003fff;
00524    const int tdcmask    = 0x3fffffff;
00525 
00526    // ADC = FLSDigit.RawA|B *  60  :  max RawX = (2^17-1)/60  = 2184.5pe
00527    // TDC = FLSDigit.TdcA|B *  10  :  max TdcX = (2^28-1)/10  = 26.8msec
00528 
00529    // create the three words we'll be putting in
00530 //rwh:not_used_yet   Int_t err     = 0;
00531    Int_t chadd   = rcid.GetChAdd();
00532    if (chadd > chaddmask) {
00533       // this should never happen
00534       static int nmsg_chadd = 5;
00535       if (nmsg_chadd) {
00536          MSG("Exodus",Msg::kFatal) 
00537             << "RerootToRawDataModule::AddToCrate chadd "
00538             << hex << chadd << dec << " truncated from " 
00539             << hex << rcid.GetChAdd() << dec << endl;
00540          nmsg_chadd--;
00541          if (nmsg_chadd==0) 
00542             MSG("Exodus",Msg::kFatal) 
00543                << " ... last of these messages" << endl;
00544       }
00545    }
00546    chadd &= chaddmask;
00547 
00548    Int_t iadc     = TMath::Nint( raw * 60.0 );
00549    if(rcid.GetElecType()==ElecType::kQIE) iadc+=50; // Add 50 count pedestal to ND data.
00550    if (iadc > adcmask ) {
00551       // this should never happen
00552       static int nmsg_adc = 5;
00553       if (nmsg_adc) {
00554          MSG("Exodus",Msg::kWarning) 
00555             << "RerootToRawDataModule::AddToCrate iadc "
00556             << iadc << " does not fit in field  (max " 
00557             << adcmask << ")" << endl;
00558          nmsg_adc--;
00559          if (nmsg_adc==0)
00560             MSG("Exodus",Msg::kWarning) 
00561                << " ... last of these messages" << endl;
00562       }     
00563       iadc = TMath::Max(0,TMath::Min(iadc,adcmask));
00564    }
00565    iadc &= adcmask;
00566 
00567 // Convert from 0.1*Munits:ns to standard Munits base time units (sec).
00568    Float_t tdc_convert = 0.1; // REROOT, non-VA, non-QIE scale factor
00569    switch (rcid.GetElecType()) {
00570    case (ElecType::kVA):  
00571      // VA electronics, tick = 1.5625 ns (640MHz)
00572      tdc_convert = 1.5625;
00573      break;
00574    case (ElecType::kQIE):
00575      // QIE electronics, tick = 18.832 ns (RF clock)
00576      tdc_convert =  1000./53.1;  // clock is 53.1MHz
00577      // CalDet has yet a different clock frequency
00578      if (rcid.GetDetector() == Detector::kCalDet)
00579        tdc_convert = 1.5625*16.0*58.0/77.0;
00580      break;
00581    default: // handle non-VA, non-QIE by original initialization
00582       break;
00583    }
00584    Int_t itdc     = TMath::Nint( tdc / tdc_convert );
00585 
00586    if (itdc > tdcmask ) {
00587       // this should never happen
00588       static int nmsg_tdc = 5;
00589       if (nmsg_tdc) {
00590          MSG("Exodus",Msg::kWarning) 
00591             << "RerootToRawDataModule::AddToCrate itdc "
00592             << itdc << " does not fit in field (max " 
00593             << tdcmask << ")" << endl;
00594          nmsg_tdc--;
00595          if (nmsg_tdc==0)
00596             MSG("Exodus",Msg::kWarning) 
00597                << " ... last of these messages" << endl;
00598       }     
00599       itdc = TMath::Max(0,TMath::Min(itdc,tdcmask));
00600    }
00601    itdc &= tdcmask;
00602 
00603    // if flag is set dump what we're about to do
00604    if (fDebugFlags & dbg_DumpAddToCrate) {
00605       MSG("Exodus",Msg::kInfo) 
00606          << "AddToCrate " << rcid.AsString() 
00607          << " seid " << seid.AsString("c") 
00608          << " raw " << raw << " time " << tdc 
00609          << endl
00610          << hex << setfill('0')
00611          << " stored as adc 0x" << setw(8) << iadc
00612          << " tdc 0x" << setw(8) << itdc
00613          << setfill(' ') << dec
00614          << endl;
00615    }
00616 
00617 
00618    // missing parity bits and "hrd"
00619    Int_t upper = signbit | (chadd<<chaddshift) | iadc;
00620    Int_t lower = itdc;
00621    Int_t extra = seid.GetEncoded();
00622       
00623    // push the words in
00624    wcrate->AddAt(upper,used++);
00625    wcrate->AddAt(lower,used++);
00626    wcrate->AddAt(extra,used++);
00627 
00628    // update pair count
00629    Int_t npairs = (used-hsize)/nw_digit;
00630    wcrate->AddAt(npairs,ndigits_indx);
00631 
00632    // update used size
00633    cratesizeused->AddAt(used,crate);
00634 
00635 }

JobCResult RerootToRawDataModule::ApplyTrigger (  )  [private]

Definition at line 267 of file RerootToRawDataModule.cxx.

References detector, PlexPlaneId::GetPlaneCoverage(), JobCResult::kFailed, Detector::kNear, PlaneCoverage::kNoActive, JobCResult::kPassed, Msg::kWarning, MSG, ndigitsPerPlane, Nplaneshit, and ofMplanes.

Referenced by Get().

00268 {
00269   // Apply the N of M trigger for the Far Eetector
00270   // Should also work for CalDet
00271   // Simply punt for Near Detector
00272 
00273   if (Detector::kNear == detector) return JobCResult::kPassed;
00274 
00275   // if no test then always pass
00276   if (Nplaneshit<=0) return JobCResult::kPassed;
00277 
00278   // find first & last plane with digits
00279   Int_t first = 0;
00280   Int_t last  = ndigitsPerPlane.GetSize()-1;
00281   for ( ; last>first; last-- ) if (ndigitsPerPlane[last]>0) break;
00282   for ( ; first<last; first++) if (ndigitsPerPlane[first]>0) break;
00283 
00284   // if impossibly short then don't bother further, it fails
00285   if (last-first+1<Nplaneshit) return JobCResult::kFailed;  
00286 
00287   Int_t running_total = 0;
00288   Int_t excluded_plns = 0;
00289   for (Int_t plane = first; plane<=last; plane++) {
00290 
00291     // check for uninstrumented plane
00292     PlexPlaneId pid(detector,plane);
00293     if (pid.GetPlaneCoverage() == PlaneCoverage::kNoActive) {
00294       excluded_plns++;
00295       if (ndigitsPerPlane[plane]>0)
00296         MSG("Exodus",Msg::kWarning)
00297           << "saw " << ndigitsPerPlane[plane]
00298           << " digits in uninstrumented plane "
00299           << pid << endl;
00300       else
00301         ndigitsPerPlane[plane] = -1; // mark it as to be excluded
00302     }
00303     
00304     // if appropriate, add this plane into total
00305     if (ndigitsPerPlane[plane]>0) running_total++;
00306 
00307     // start subtracting
00308     Int_t window = ofMplanes + excluded_plns;
00309     if (plane>=window-1 && plane-window>=0) { // -1 for zero based indexing
00310       Int_t ngoingout = ndigitsPerPlane[plane-window];
00311       if      (ngoingout < 0) excluded_plns--;
00312       else if (ngoingout > 0) running_total--;
00313     }
00314 
00315     // test if valid
00316     if ( running_total >= Nplaneshit ) return JobCResult::kPassed;
00317 
00318   }
00319   // fell through without passing?  failed!
00320   return JobCResult::kFailed;
00321 }

RawDataBlock * RerootToRawDataModule::FinalizeWorkingArray ( void   )  [private]

Definition at line 639 of file RerootToRawDataModule.cxx.

References bfld::AsString(), RawBlockId::AsString(), cratesizeused, RawBlockProxy::CreateRawDataBlock(), detector, RawBlockId::GetEncoded(), RawBlockProxy::GetMajorId(), RawBlockRegistry::Instance(), RawBlockProxy::IsDCS(), Msg::kDebug, SimFlag::kReroot, RawBlockRegistry::LookUp(), MSG, ncrates, nwordsblock, rdxsum_fill(), workingarray, and workingcrates.

Referenced by Get().

00640 {
00641    // Build final array from crate arrays
00642 
00643    //  Block format is:
00644    //---------------------
00645    //  # words in block
00646    //  checksum
00647    //  Block Id
00648    //  Crate #
00649    //  GPS T0 sec
00650    //  GPS T0 nsec
00651    //  Crate status
00652    //  # pairs in crate (N)
00653    //  readout 1 word 1
00654    //  readout 1 word 2
00655    //   < truth PlexStripEndId if Reroot data>
00656    //  readout 2 word 1
00657    //  readout 2 word 2
00658    //  ...
00659    //  readout N word 1
00660    //  readout N word 2
00661    //  Crate #
00662    //  GPS T0 sec
00663    //  GPS T0 nsec
00664    //  Crate status
00665    //  # pairs in crate (N)
00666    //  readout 1 word 1
00667 
00668    Int_t need = 3;  // #words, checksum, blockid
00669    for (Int_t crate=0; crate < ncrates; crate++) {
00670       need += cratesizeused->At(crate);
00671    }
00672 
00673    // float to highwater mark without copying contents
00674    if (workingarray->GetSize() < need) {
00675       workingarray->Set(0);    // deletes old array
00676       workingarray->Set(need); // set to necessary size
00677    }
00678 
00679    RawBlockRegistry& rbr = RawBlockRegistry::Instance();
00680    RawBlockProxy*    rbp = rbr.LookUp("RawDigitDataBlock");
00681 
00682    Bool_t isDCS   = rbp->IsDCS();
00683    Int_t  majorId = rbp->GetMajorId();
00684 
00685    RawBlockProxy*    rbp2 = rbr.LookUp(isDCS,majorId);
00686    if ( rbp2 != rbp ) cout << "RawBlockProxy cross check failed" << endl;
00687 
00688    Int_t  minorId = 0;
00689    RawBlockId rbid(majorId,minorId,isDCS,detector,SimFlag::kReroot);
00690    MSG("Exodus", Msg::kDebug)
00691       << " to be stored with RawBlockId " 
00692       << " 0x" << hex << rbid.GetEncoded() << dec
00693       << " == " << rbid.AsString() << endl
00694       << " majorId " << majorId << " minorId " << minorId
00695       << ((isDCS) ? " DCS " : " DAQ ")
00696       << " " << Detector::AsString(detector) << endl;
00697 
00698    Int_t checksum = 0xdeadbeef;
00699 
00700    Int_t& indx = nwordsblock;  // set "next" index to # words in block
00701    indx = 0;
00702    workingarray->AddAt(need,indx++);
00703    workingarray->AddAt(checksum,indx++);
00704    workingarray->AddAt(rbid.GetEncoded(),indx++);
00705    for (Int_t crate=0; crate<ncrates; crate++) {
00706       Int_t csize = cratesizeused->At(crate);
00707       TArrayI *wcrate = &workingcrates[crate];
00708       Int_t   *array  = wcrate->GetArray();  // gawd, it's guts are public
00709       for (Int_t i=0; i<csize; i++) {
00710          workingarray->AddAt(array[i],indx++);
00711       }
00712    }     
00713    
00714    // fill in the true checksum
00715    int xsum_version = 0;
00716    rdxsum_fill((int32_t*)workingarray->GetArray(),xsum_version);
00717    
00718    // use the proxy to actually create a block
00719    return rbp->CreateRawDataBlock(workingarray->GetArray());
00720 
00721 }

JobCResult RerootToRawDataModule::Get ( MomNavigator mom  )  [virtual]

Implement if your module needs to read data from some external source and fill mom

Reimplemented from JobCModule.

Definition at line 113 of file RerootToRawDataModule.cxx.

References AddToCrate(), MomNavigator::AdoptFragment(), RawRecord::AdoptRawBlock(), ApplyTrigger(), PlexStripEndId::AsString(), RerootExodus::BuildVldContext(), dbg_PrintRawDigitDataBlock, dbg_WarnAllMissingRCId, fDebugFlags, FinalizeWorkingArray(), VldContext::GetDetector(), RerootExodus::GetEventNo(), RerootExodus::GetFLSDigitList(), RawDigitDataBlock::GetNumberOfDigits(), PlexHandle::GetRawChannelId(), RerootExodus::GetRunNo(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), RecMinos::GetTempTags(), VldContext::GetTimeStamp(), gMINFast, REROOT_FLSDigit::ICell(), REROOT_FLSDigit::IExtr(), InitWorkingArray(), REROOT_FLSDigit::IPln(), JobCResult::kError, Msg::kFatal, Msg::kWarning, MSG, ndigitsPerPlane, RerootExodus::PECAB2SEId(), RawDataBlock::Print(), random, REROOT_FLSDigit::RawA(), REROOT_FLSDigit::RawB(), run(), Registry::Set(), REROOT_FLSDigit::TDCA(), and REROOT_FLSDigit::TDCB().

00114 {
00115    // Create RawRecord from the current REROOT event
00116    // available via gMINFast.
00117 
00118   if (!gMINFast) {
00119     static int nmsg = 10;
00120     if (nmsg) {
00121       MSG("Exodus",Msg::kFatal) 
00122         << "RerootToRawDataModule lacked gMINFast" << endl
00123         << "   perhaps the input isn't a REROOT file"
00124         << endl;
00125       nmsg--;
00126       if (!nmsg) MSG("Exodus",Msg::kFatal) 
00127         << " ... last such message" << endl;
00128     }
00129     return JobCResult::kError;
00130   }
00131 
00132   // Prepare to start by getting current REROOT pointers
00133   // and clearing out the working array
00134   InitWorkingArray();
00135 
00136   ndigitsPerPlane.Reset();
00137 
00138   // For a PlexHandle we need a context
00139   VldContext vldc = RerootExodus::BuildVldContext();
00140 
00141   // Get a PlexHandle for PlexStripEndId to RawChannelId conversions
00142   PlexHandle ph(vldc);
00143 
00144   // Prepare to loop over REROOT digits
00145   const TClonesArray *flsdigits   = RerootExodus::GetFLSDigitList();
00146   REROOT_FLSDigit    *flsdigit = 0;
00147   TIter diter(flsdigits);
00148 
00149   PlexStripEndId seid;
00150   RawChannelId   rcid;
00151   Float_t raw, tdc;
00152   Int_t   isAB;
00153 
00154   // Keep track of earliest time.
00155   Float_t tearly = 2e9; // Set to something not crazy, so (int)tearly isn't a fpe.
00156 
00157   // ADAMO unfilled entries have special values
00158   // but exact testing doesn't seem to work...
00159   Float_t ADAMO_RNULL =  699050. * (Float_t) (16<<26); // 699050*16.0**26
00160 
00161   // loop over all digits
00162   while ( ( flsdigit = (REROOT_FLSDigit*) diter.Next() ) ) {
00163 
00164      static int nmsgIsNull = 20; // default, limit to 20 messages
00165 
00166      // process A side
00167      raw  = flsdigit->RawA();
00168      tdc  = flsdigit->TDCA();
00169      isAB = 0;
00170      if ( raw > 0.0 && raw < ADAMO_RNULL ) {
00171         seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(),
00172                                         flsdigit->ICell(),isAB);
00173         // make an entry
00174         rcid = ph.GetRawChannelId(seid);
00175         if (rcid.IsNull()) {
00176            if (( fDebugFlags & dbg_WarnAllMissingRCId) || nmsgIsNull>0)
00177               MSG("Exodus",Msg::kWarning) 
00178                  << "rcid.IsNull() on A side " << seid.AsString() << endl;
00179            if (nmsgIsNull==1 & !(fDebugFlags&dbg_WarnAllMissingRCId)) 
00180               MSG("Exodus",Msg::kWarning)
00181                  << " ... last IsNull message" << endl;
00182            nmsgIsNull--;
00183         }
00184         // add no matter if rcid.IsNull, so we see MC truth
00185         AddToCrate(seid,rcid,raw,tdc);
00186         if(tdc < tearly) tearly = tdc;
00187      }
00188 
00189      // process B side
00190      raw  = flsdigit->RawB();
00191      tdc  = flsdigit->TDCB();
00192      isAB = 1;
00193      if ( raw > 0.0 && raw < ADAMO_RNULL ) {
00194         seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(),
00195                                         flsdigit->ICell(),isAB);
00196         // make an entry
00197         rcid = ph.GetRawChannelId(seid);
00198         if (rcid.IsNull()) {
00199            if (( fDebugFlags & dbg_WarnAllMissingRCId) || nmsgIsNull>0)
00200               MSG("Exodus",Msg::kWarning) 
00201                  << "rcid.IsNull() on B side " << seid.AsString() << endl;
00202            if (nmsgIsNull==1 & !(fDebugFlags&dbg_WarnAllMissingRCId)) 
00203               MSG("Exodus",Msg::kWarning)
00204                  << " ... last IsNull message" << endl;
00205            nmsgIsNull--;
00206         }
00207         // add no matter if rcid.IsNull, so we see MC truth
00208         AddToCrate(seid,rcid,raw,tdc);
00209         if(tdc < tearly) tearly = tdc;
00210      }
00211   }
00212 
00213   // Finalize the working array, produce RawDigitDataBlock
00214   RawDataBlock *rawblk = FinalizeWorkingArray();
00215   RawDigitDataBlock *rrdb = dynamic_cast<RawDigitDataBlock*>(rawblk);
00216 
00217   if (fDebugFlags & dbg_PrintRawDigitDataBlock) rawblk->Print();
00218 
00219   // produce a RawDaqSnarlHeader (specialized RawHeader)
00220   // which the RawRecord will adopt
00221 
00222   Int_t   run      = RerootExodus::GetRunNo();
00223   Int_t   snarl    = RerootExodus::GetEventNo();
00224   Int_t   trigbits = random->Integer(0x0fffffff);
00225   Short_t subrun = 0;
00226   Short_t runtype = 0;
00227   Int_t   errcode = 0;
00228   static Int_t tf = 0;
00229   Int_t   nrawdigits = (rrdb) ? rrdb->GetNumberOfDigits() : -1;
00230   Int_t   spilltype = -1;
00231 
00232   // Convert tearly to trigger time.
00233   VldTimeStamp trigTime(vldc.GetTimeStamp().GetSec(),
00234                         (int)(tearly));
00235   // Build a new, slightly different context:
00236   VldContext trigContext(vldc.GetDetector(),
00237                          vldc.GetSimFlag(),
00238                          trigTime);
00239 
00240   RawDaqSnarlHeader *head = 
00241      new RawDaqSnarlHeader(trigContext,run,subrun,runtype,++tf,
00242                            snarl,trigbits,errcode,nrawdigits,spilltype);
00243 
00244   // produce a RawRecord, have it adopt the header
00245   
00246   RawRecord *rawrec = new RawRecord(head);
00247 
00248   // give the block to the RawRecord
00249 
00250   rawrec->AdoptRawBlock(rawblk);
00251 
00252   // tag this RawRecord AS IF it had come from the DaqSnarl stream
00253 
00254   rawrec->GetTempTags().Set("stream","DaqSnarl");
00255 
00256   // give the RawRecord to MOM to hold as a "fragment"
00257   
00258   mom->AdoptFragment(rawrec);
00259 
00260   // 
00261 
00262   return ApplyTrigger(); // result depends on trigger
00263 }

void RerootToRawDataModule::HandleCommand ( JobCommand command  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 725 of file RerootToRawDataModule.cxx.

References fDebugFlags, fRawPeCut, Msg::kInfo, Msg::kWarning, MSG, Nplaneshit, ofMplanes, JobCommand::PopCmd(), JobCommand::PopFloatOpt(), JobCommand::PopIntOpt(), and JobCommand::PopOpt().

00726 {
00727 //
00728 // Process configuration commands
00729 //
00730   TString cmd = command->PopCmd();
00731   if (cmd == "Set") {
00732      TString opt = command->PopOpt();
00733      if      (opt == "fRawPeCut")   fRawPeCut   = command->PopFloatOpt();
00734      else if (opt ==  "RawPeCut")   fRawPeCut   = command->PopFloatOpt();
00735      else if (opt == "fDebugFlags") fDebugFlags = command->PopIntOpt();
00736      else if (opt == "Trigger") {
00737        Nplaneshit = command->PopIntOpt();
00738        ofMplanes  = command->PopIntOpt();
00739        MSG("Exodus", Msg::kInfo)
00740            << "RerootToRawDataModule: Trigger is " 
00741            << Nplaneshit << " of " << ofMplanes << endl;
00742      }
00743      else {
00744         MSG("Exodus", Msg::kWarning)
00745            << "RerootToRawDataModule: Unrecognized option " << opt << endl;
00746      }
00747   } else {
00748      MSG("Exodus", Msg::kWarning)
00749         << "RerootToRawDataModule: Unrecognized command " << cmd << endl;
00750   }
00751 }

void RerootToRawDataModule::InitWorkingArray ( void   )  [private]

Definition at line 404 of file RerootToRawDataModule.cxx.

References cratesizeused, detector, DataUtil::GetDetector(), ncrates, and nwordsblock.

Referenced by Get().

00405 {
00406    // Initialize for new "Get"
00407 
00408    // zero out used sizes ...
00409    for (Int_t i=0; i<ncrates; i++) {
00410       cratesizeused->AddAt(0,i);
00411    }
00412    nwordsblock = 0;
00413 
00414    detector = RerootExodus::GetDetector();
00415 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 325 of file RerootToRawDataModule.cxx.

References CheezyDisplay::AddStripEndId(), CheezyDisplay::ClearLists(), digit(), display, CheezyDisplay::Draw(), RawDigit::GetChannel(), PlexSEIdAltL::GetCurrentSEId(), RawDigitDataBlock::GetDatumIter(), MomNavigator::GetFragment(), RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), PlexHandle::GetSEIdAltL(), RawMCDigitMixIn::GetTrueSEIdEncoded(), RecMinosHdr::GetVldContext(), PlexSEIdAltL::IsValid(), JobCResult::kAOK, JobCResult::kError, Msg::kFatal, MSG, PlexSEIdAltL::Next(), PlexSEIdAltL::SetFirst(), and CheezyDisplay::SetVldContext().

00326 {
00327   // A test job for "reconstruction"
00328   // This example code unpacks the RawDataBlocks in the RawRecord
00329   // and displays them on a CheezyDisplay using the Plex
00330   // to convert from RawRecordId into PlexStripEndId's
00331   
00332   //  MSG("Exodus", Msg::kVerbose) << "RerootToRawDataModule::Reco\n";
00333 
00334   TObject   *obj;
00335 
00336   // Get the RawRecord from Mom
00337   RawRecord *rawrec = dynamic_cast<RawRecord *>
00338                                         (mom->GetFragment("RawRecord"));
00339   if ( ! rawrec ) {
00340      MSG("Exodus",Msg::kFatal) << "RerootToRawDataModule::Reco" <<
00341         " failed to fin a \"RawRecord\"" << endl;
00342      return JobCResult::kError;
00343   }
00344   
00345   // For a PlexHandle we need a context
00346   VldContext vldc = rawrec->GetRawHeader()->GetVldContext();
00347 
00348   // Get a PlexHandle for PlexStripEndId to RawChannelId conversions
00349   PlexHandle ph(vldc);
00350 
00351   // Create (if necessary) a display
00352   if ( ! display ) display = 
00353                       new CheezyDisplay("RerootToRawDataModule",
00354                                         "RerootToRawDataModule display");
00355   display->ClearLists();
00356   display->SetVldContext(vldc);
00357 
00358 
00359   // from the RawRecord loop over the RawDataBlocks
00360   RawDigitDataBlock     *digitblk  = 0;
00361   TIter blkiter = rawrec->GetRawBlockIter();
00362   while ( ( obj = blkiter.Next() ) ) {
00363      digitblk  = dynamic_cast<RawDigitDataBlock*>(obj);
00364      if (digitblk) {
00365 
00366         // Loop over the digits make counts
00367         RawDigit       *digit = 0;
00368         TIter diter = digitblk->GetDatumIter();
00369 
00370         while ( ( digit = (RawDigit*) diter.Next() ) ) {
00371            
00372            // if it came from a Raw{Qie,Va}MCDigit then there
00373            // is Truth(TM) info available
00374            // cast the digit correctly and retrieve it
00375            RawMCDigitMixIn *truthDigit = dynamic_cast<RawMCDigitMixIn*>(digit);
00376            if (truthDigit) {
00377               PlexStripEndId seid(truthDigit->GetTrueSEIdEncoded());
00378               display->AddStripEndId(seid,kTRUE);
00379            }           
00380 
00381            // ALT LIST
00382            RawChannelId rcid = digit->GetChannel();
00383            PlexSEIdAltL altlist = ph.GetSEIdAltL(rcid);
00384            altlist.SetFirst();
00385            while ( altlist.IsValid() ) {
00386               PlexStripEndId seid = altlist.GetCurrentSEId();
00387               display->AddStripEndId(seid,kFALSE);
00388               altlist.Next();
00389            }
00390         }
00391 
00392      }
00393   }
00394      
00395   // Now actually draw these things
00396   display->Draw();
00397 
00398   return JobCResult::kAOK;
00399 
00400 }


Member Data Documentation

Definition at line 77 of file RerootToRawDataModule.h.

Referenced by ApplyTrigger(), FinalizeWorkingArray(), and InitWorkingArray().

Definition at line 91 of file RerootToRawDataModule.h.

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

Definition at line 75 of file RerootToRawDataModule.h.

Referenced by AddToCrate(), Get(), and HandleCommand().

Definition at line 80 of file RerootToRawDataModule.h.

Referenced by AddToCrate(), and HandleCommand().

Definition at line 93 of file RerootToRawDataModule.h.

Referenced by AddToCrate(), ApplyTrigger(), and Get().

Definition at line 94 of file RerootToRawDataModule.h.

Referenced by ApplyTrigger(), and HandleCommand().

Definition at line 88 of file RerootToRawDataModule.h.

Referenced by FinalizeWorkingArray(), and InitWorkingArray().

Definition at line 95 of file RerootToRawDataModule.h.

Referenced by ApplyTrigger(), and HandleCommand().

TRandom* RerootToRawDataModule::random [private]

Definition at line 72 of file RerootToRawDataModule.h.

Referenced by Get(), and ~RerootToRawDataModule().

Definition at line 89 of file RerootToRawDataModule.h.

Referenced by FinalizeWorkingArray(), and ~RerootToRawDataModule().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1