NoiseFilterModule Class Reference

#include <NoiseFilterModule.h>

Inheritance diagram for NoiseFilterModule:
JobCModule

List of all members.

Public Member Functions

 NoiseFilterModule ()
 ~NoiseFilterModule ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Attributes

Int_t fMinPulseHeightND
Int_t fMinEventLengthND
Bool_t fTriggerTimeCutND
Int_t fMinPulseHeightFD
Int_t fMinEventLengthFD
Bool_t fTriggerTimeCutFD

Detailed Description

Definition at line 18 of file NoiseFilterModule.h.


Constructor & Destructor Documentation

NoiseFilterModule::NoiseFilterModule (  ) 

Definition at line 44 of file NoiseFilterModule.cxx.

References Msg::kVerbose, and MSG.

00045 {
00046   MSG("NoiseFilter", Msg::kVerbose) 
00047     << "NoiseFilterModule::Constructor\n";
00048 }

NoiseFilterModule::~NoiseFilterModule (  ) 

Definition at line 52 of file NoiseFilterModule.cxx.

References Msg::kVerbose, and MSG.

00053 {
00054   MSG("NoiseFilter", Msg::kVerbose) 
00055     << "NoiseFilterModule::Destructor\n";
00056 }


Member Function Documentation

JobCResult NoiseFilterModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 69 of file NoiseFilterModule.cxx.

References RawChannelId::AsString(), VldTimeStamp::AsString(), RawRecord::FindRawBlock(), fMinEventLengthFD, fMinEventLengthND, fMinPulseHeightFD, fMinPulseHeightND, MomNavigator::FragmentIter(), fTriggerTimeCutFD, fTriggerTimeCutND, RawDigitDataBlock::GetDatumIter(), VldContext::GetDetector(), VldTimeStamp::GetNanoSec(), PlexSEIdAltL::GetPlane(), RawRecord::GetRawHeader(), PlexHandle::GetReadoutType(), PlexHandle::GetSEIdAltL(), Calibrator::GetTimeFromTDC(), VldContext::GetTimeStamp(), RecMinosHdr::GetVldContext(), Calibrator::Instance(), PlexSEIdAltL::IsVetoShield(), Msg::kDebug, JobCResult::kFailed, Detector::kFar, Detector::kNear, JobCResult::kPassed, ReadoutType::kScintStrip, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, Munits::ns, and Munits::s.

00079 {
00080 
00081   MSG("NoiseFilter", Msg::kDebug) << "NoiseFilterModule::Ana\n";
00082 
00083   TObject* tobj;
00084   TIter    fragiter = mom->FragmentIter();
00085 
00086   RawRecord*                 rr   = 0;
00087   const RawDigitDataBlock*   rddb = 0;
00088   const RawDaqSnarlHeader*   rdsh = 0;
00089 
00090   // find the right raw records
00091 
00092   while( ( tobj = fragiter.Next() ) ) { 
00093     if( ( rr = dynamic_cast<RawRecord*>(tobj) ) ) {
00094 
00095       MSG("NoiseFilter", Msg::kDebug) 
00096         << "Found Next RawRecord at "<<rr<<".\n";
00097 
00098       if ( !rddb )  rddb  = dynamic_cast<const RawDigitDataBlock*>
00099                       (rr->FindRawBlock("RawDigitDataBlock"));
00100 
00101       if ( !rdsh )  rdsh  = dynamic_cast<const RawDaqSnarlHeader*>
00102                       (rr->GetRawHeader());
00103 
00104     }  // if
00105   } // while
00106   
00107   // check RawDigitDataBlock
00108 
00109   if ( !rddb) {
00110     MSG("NoiseFilter", Msg::kWarning) 
00111       <<"No RawDigitDataBlock in RawRecord.\n";
00112     return JobCResult::kFailed;
00113   }
00114 
00115   if ( !rdsh) {
00116     MSG("NoiseFilter", Msg::kWarning) 
00117       <<"No RawDaqSnarlHeader in RawRecord.\n";
00118     return JobCResult::kFailed;
00119   }
00120 
00121   // only active for near and far detector
00122   
00123   VldContext               vldc     = rdsh->GetVldContext();
00124   Detector::Detector_t Detector = vldc.GetDetector();
00125   if ( Detector != Detector::kNear &&
00126        Detector != Detector::kFar ) {
00127     MSG("NoiseFilter", Msg::kDebug) 
00128       << "Accepting snarl: Neither Near nor Far Detector.\n";
00129     return JobCResult::kPassed;
00130   }
00131 
00132   // now get set detector specific quantities
00133 
00134   Int_t MinPH = 0;
00135   Int_t MinEL = 0;
00136   Int_t PlaneMax = 0;
00137   Bool_t TriggerTimeCut = false;
00138   switch (Detector) {
00139   case Detector::kNear:
00140     MinPH    = fMinPulseHeightND;
00141     MinEL    = fMinEventLengthND;
00142     PlaneMax = 282;
00143     TriggerTimeCut = fTriggerTimeCutND;
00144     break;
00145   case Detector::kFar:
00146     MinPH    = fMinPulseHeightFD;
00147     MinEL    = fMinEventLengthFD;
00148     PlaneMax = 486;
00149     TriggerTimeCut = fTriggerTimeCutFD;
00150     break;
00151   default:
00152     break;
00153   }
00154 
00155   PlexHandle ph(vldc);
00156   VldTimeStamp vldcts   = vldc.GetTimeStamp();
00157 
00158   MSG("NoiseFilter", Msg::kDebug) << "VldTimeStamp = " 
00159                                   << vldcts.AsString("c") << endl;
00160 
00161   Double_t     TrigTime = vldcts.GetNanoSec()*Munits::ns;
00162   MSG("NoiseFilter", Msg::kDebug) << "TrigTime = " << TrigTime 
00163                                   << " (in sec)" <<endl;
00164 
00165   // define some quantities which are used later
00166 
00167   Int_t TotAdc  = 0;                                 // total energy in snarl
00168   Int_t rdcount = 0;                                 // raw digit counter
00169   std::vector<Bool_t> HitInPlane(PlaneMax,kFALSE);   // vector of hit planes 
00170   
00171   // loop over raw digits to calculate filter quantities
00172 
00173   Calibrator& calibrator = Calibrator::Instance();
00174   TIter rdit = rddb->GetDatumIter();
00175 
00176   while (RawDigit *rd = dynamic_cast<RawDigit*>(rdit())) {
00177 
00178     RawChannelId rcid  = rd->GetChannel();
00179     Int_t        adc   = rd->GetADC();
00180     Int_t        tdc   = rd->GetTDC();
00181     Int_t        error = rd->GetErrorCode();
00182     Double_t     time  = calibrator.GetTimeFromTDC(tdc, rcid);
00183     PlexSEIdAltL seid  = ph.GetSEIdAltL(rcid);
00184     Int_t        plane = seid.GetPlane();
00185 
00186     // now treat TDC reset at 1 secound boundary
00187     time += ( (rd->GetCrateT0()).GetSec()
00188               - (vldc.GetTimeStamp()).GetSec() )*Munits::s
00189       // add CrateT0
00190       +  (rd->GetCrateT0()).GetNanoSec()*Munits::ns;
00191       
00192     // now re-map ND spectrometer
00193 
00194     Int_t planeRAW = plane;
00195     if ( (vldc.GetDetector() == Detector::kNear) && (plane>121) )
00196          plane = 121 + (plane-121) / 5;
00197 
00198     MSG("NoiseFilter", Msg::kDebug) << "Digit("   << setw(3) << rdcount << "):"
00199                                     << " plane =" << setw(5) << plane <<"/" 
00200                                                   << setw(3) << planeRAW
00201                                     << " ADC ="   << setw(6) << adc
00202                                     << " TDC ="   << setw(12) << tdc
00203                                     << " err = "  << error
00204                                     << " Dt = "   << time-TrigTime 
00205                                     << endl;
00206 
00207     // only count the following hits
00208     //    - not veto counter
00209     //    - no error
00210     //    - scintilator strips
00211     //    - not in pretrigger window 
00212     //                   un-less no TriggerTimeCut or ND
00213 
00214     if ( !(seid.IsVetoShield()) && 
00215          ph.GetReadoutType(rcid) == ReadoutType::kScintStrip &&
00216          !error &&
00217          ( (time+50*Munits::ns>=TrigTime) || !TriggerTimeCut ) ) {
00218 
00219       // the following cut protects against unknown rcid
00220 
00221       if ( (plane>=0) && (plane<PlaneMax) ) {
00222 
00223         TotAdc            += adc;
00224         HitInPlane[plane]  = kTRUE;
00225 
00226       } else {
00227 
00228         MAXMSG("NoiseFilter", Msg::kWarning, 20) 
00229           << "Found plane number " << plane 
00230           << " outside allowed range 0 - " <<  PlaneMax << endl
00231           << "    ADC = "<< adc << " TDC = " << tdc << " t = " << time
00232           << endl << "    rcid = " << rcid.AsString("e") << endl;
00233 
00234       }
00235 
00236     } // hit cut
00237 
00238     rdcount++;
00239 
00240   } //while loop
00241 
00242   // now calculate event length (max number of cont. planes)
00243 
00244   MSG("NoiseFilter", Msg::kDebug) << "Now calculating snarl length.\n";
00245 
00246   Int_t EventLength = 0;
00247   Int_t PlaneCount  = 0;
00248 
00249   for (Int_t plane = 0; plane<PlaneMax; plane++) {
00250     if ( HitInPlane[plane] ) {
00251       PlaneCount++;
00252       if ( PlaneCount > EventLength ) {
00253         EventLength = PlaneCount;
00254       }
00255       MSG("NoiseFilter", Msg::kVerbose) 
00256         << "Plane " << plane << " was hit. PC = " << PlaneCount
00257         << " EL = " << EventLength << endl;
00258     }  else {
00259       MSG("NoiseFilter", Msg::kVerbose) 
00260         << "Plane " << plane << " was not hit."<< endl;
00261       PlaneCount = 0;
00262     }
00263   }
00264 
00265   // cut on total pulse height
00266 
00267   if (TotAdc<MinPH) {
00268     MSG("NoiseFilter", Msg::kDebug) << "Failing snarl: SumAdc = "
00269                                     << TotAdc << "/" << MinPH 
00270                                     << endl;
00271     return JobCResult::kFailed;
00272   }
00273 
00274   // cut on event length
00275 
00276   if (EventLength<MinEL) {
00277     MSG("NoiseFilter", Msg::kDebug) << "Failing snarl: EventLength = " 
00278                                     << EventLength << "/" << MinEL 
00279                                     << endl;
00280     return JobCResult::kFailed;
00281   }
00282 
00283   MSG("NoiseFilter", Msg::kDebug) 
00284     << "Snarl passed filter: EventLength = " 
00285     << EventLength << " and total ADC = " 
00286     << TotAdc << endl;
00287 
00288   return JobCResult::kPassed;
00289 
00290 }

void NoiseFilterModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 60 of file NoiseFilterModule.cxx.

References Msg::kVerbose, and MSG.

00061 {
00062   MSG("NoiseFilter", Msg::kVerbose) 
00063     << "NoiseFilterModule::BeginJob\n";
00064 
00065 }

void NoiseFilterModule::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 329 of file NoiseFilterModule.cxx.

References fMinEventLengthFD, fMinEventLengthND, fMinPulseHeightFD, fMinPulseHeightND, fTriggerTimeCutFD, fTriggerTimeCutND, Registry::Get(), Msg::kDebug, and MSG.

00330 {
00331 //====================================================================
00332 // Configure the module given the registry r
00333 // Do all configuration here.
00334 // Beware: this methode may be called several times!
00335 //====================================================================
00336 
00337   MSG("NoiseFilter", Msg::kDebug) << "NoiseFilterModule::Config\n";
00338 
00339   Int_t tmpi;
00340 
00341   if (r.Get("MinPulseHeightND", tmpi)) { fMinPulseHeightND = tmpi;}
00342   if (r.Get("MinEventLengthND", tmpi)) { fMinEventLengthND = tmpi;}
00343   if (r.Get("TriggerTimeCutND", tmpi)) { fTriggerTimeCutND = tmpi!=0;}
00344   if (r.Get("MinPulseHeightFD", tmpi)) { fMinPulseHeightFD = tmpi;}
00345   if (r.Get("MinEventLengthFD", tmpi)) { fMinEventLengthFD = tmpi;}
00346   if (r.Get("TriggerTimeCutFD", tmpi)) { fTriggerTimeCutFD = tmpi!=0;}
00347 
00348   return;
00349 
00350 }

const Registry & NoiseFilterModule::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 294 of file NoiseFilterModule.cxx.

References JobCModule::GetName(), Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00295 {
00296 //  Purpose:    Method to return default configuration.
00297 //
00298 //  Arguments:  n/a
00299 //
00300 //  Return:     Registry item containing default configuration.
00301 //
00302 
00303   MSG("NoiseFilter", Msg::kDebug) 
00304     << "NoiseFilterModule::DefaultConfig\n";
00305 
00306   static Registry r;
00307 
00308   std::string name = this->JobCModule::GetName();
00309   name            += ".config.default";
00310   r.SetName(name.c_str());
00311 
00312   r.UnLockValues();
00313 
00314   r.Set("MinPulseHeightFD", 2000);
00315   r.Set("MinEventLengthFD", 2);
00316   r.Set("TriggerTimeCutFD", kTRUE);
00317   r.Set("MinPulseHeightND", 3000);
00318   r.Set("MinEventLengthND", 1);
00319   r.Set("TriggerTimeCutND", kTRUE);
00320 
00321   r.LockValues();
00322 
00323   return r;
00324 
00325 }


Member Data Documentation

Definition at line 51 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().

Definition at line 48 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().

Definition at line 50 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().

Definition at line 47 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().

Definition at line 52 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().

Definition at line 49 of file NoiseFilterModule.h.

Referenced by Ana(), and Config().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1