RerootFlsDigitToDigiPE Class Reference

#include <RerootFlsDigitToDigiPE.h>

Inheritance diagram for RerootFlsDigitToDigiPE:
JobCModule

List of all members.

Public Member Functions

 RerootFlsDigitToDigiPE ()
 ~RerootFlsDigitToDigiPE ()
JobCResult Get (MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Member Functions

void AddPE (DigiList< DigiPE > &list, PlexStripEndId &seid, PlexPixelSpotId &psid, Double_t pe, Double_t time, const DigiScintHit *scintHit)

Detailed Description

Definition at line 34 of file RerootFlsDigitToDigiPE.h.


Constructor & Destructor Documentation

RerootFlsDigitToDigiPE::RerootFlsDigitToDigiPE (  ) 

Definition at line 43 of file RerootFlsDigitToDigiPE.cxx.

00044 {
00045 }

RerootFlsDigitToDigiPE::~RerootFlsDigitToDigiPE (  ) 

Definition at line 49 of file RerootFlsDigitToDigiPE.cxx.

References Msg::kVerbose, and MSG.

00050 {
00051   MSG("DetSim", Msg::kVerbose) << "RerootFlsDigitToDigiPE::Destructor\n";
00052 }


Member Function Documentation

void RerootFlsDigitToDigiPE::AddPE ( DigiList< DigiPE > &  list,
PlexStripEndId seid,
PlexPixelSpotId psid,
Double_t  pe,
Double_t  time,
const DigiScintHit scintHit 
) [private]

Definition at line 233 of file RerootFlsDigitToDigiPE.cxx.

References PlexStripEndId::AsString(), PlexPixelSpotId::AsString(), MuELoss::e, PlexPixelSpotId::IsValid(), Msg::kVerbose, and MSG.

Referenced by Get().

00239 {
00240   //
00241   // Make a set of PEs from a info given and add them to the list.
00242   //
00243   // TODO: Add some sort of realistic time structure to this.
00244   // As it is, I just add all hits at time t, instead of making
00245   // my own distribution.
00246   
00247   MsgFormat f51("%5.1f");
00248   MSG("Reroot",Msg::kVerbose) << "FlsDigit: "
00249                               << f51(pe) << "pe " << f51(time) << "s " 
00250                               << psid.AsString() << "  " << seid.AsString() << endl;
00251 
00252   
00253 
00254   if(! psid.IsValid() ) {
00255     // This is a perfectly valid condition: the strip
00256     // is not attached to an output pixel.
00257     MSG("Reroot",Msg::kVerbose) << "Ignoring invalid PlexPixelSpotId:" 
00258                                 << psid.AsString() << "  "
00259                                 << seid.AsString() << "  "
00260                                 << f51(pe) << "pe " << endl;
00261     return;
00262   }
00263 
00264   int npe = TMath::Nint(pe);
00265   if(npe>0) {
00266     for(int ipe=0; ipe<npe; ipe++) {
00267       DigiPE d(time*1e-9, // convert from ns to Munits.
00268                psid,      // pixel spot id
00269                scintHit);     // no hit info
00270       list.push_back(d);
00271     }
00272   }
00273 }

void RerootFlsDigitToDigiPE::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 296 of file RerootFlsDigitToDigiPE.cxx.

00297 {
00298 }

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

References JobCModule::GetName(), and Registry::UnLockValues().

00281 {
00282   static Registry r;
00283 
00284   // Set name of config
00285   std::string name = this->GetName();
00286   name += ".config.default";
00287   r.SetName(name.c_str());
00288 
00289 
00290   // Set values in configuration
00291   r.UnLockValues();
00292  
00293   return r;
00294 }

JobCResult RerootFlsDigitToDigiPE::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 56 of file RerootFlsDigitToDigiPE.cxx.

References AddPE(), RecDataRecord< T >::AdoptTemporary(), PlexStripEndId::AsString(), PlexStripEndId::Build18BitPlnStripKey(), RerootExodus::BuildVldContext(), DigiList< T >::CreateObjArray(), RecDataRecord< T >::FindComponent(), MomNavigator::FragmentIter(), RerootExodus::GetFLSDigitList(), RerootExodus::GetGminosCodeName(), RerootExodus::GetGminosHostName(), RerootExodus::GetLastEventHistoryTimeStamp(), PlexHandle::GetPixelSpotId(), RerootExodus::GetRunNo(), RerootExodus::GetSnarlNum(), RerootExodus::GetSubRunNum(), RecRecordImp< T >::GetTempTags(), RerootExodus::GetTimeFrame(), gMINFast, REROOT_FLSDigit::ICell(), REROOT_FLSDigit::IExtr(), REROOT_FLSDigit::IPln(), Msg::kDebug, Msg::kError, JobCResult::kError, Msg::kFatal, JobCResult::kPassed, Msg::kVerbose, MSG, RerootExodus::PECAB2SEId(), REROOT_FLSDigit::RawA(), REROOT_FLSDigit::RawB(), run(), Registry::Set(), REROOT_FLSDigit::SignalPEA(), REROOT_FLSDigit::SignalPEB(), DigiScintHit::StripEndId(), REROOT_FLSDigit::TDCA(), and REROOT_FLSDigit::TDCB().

00057 {
00058    // Create RawRecord from the current REROOT event
00059    // available via gMINFast.
00060 
00061   if (!gMINFast) {
00062     static int nmsg = 10;
00063     if (nmsg) {
00064       MSG("DetSim",Msg::kFatal) 
00065         << "RerootFlsDigitToDigiPE lacked gMINFast" << endl
00066         << "   perhaps the input isn't a REROOT file"
00067         << endl;
00068       nmsg--;
00069       if (!nmsg) MSG("DetSim",Msg::kFatal) 
00070         << " ... last such message" << endl;
00071     }
00072     return JobCResult::kError;
00073   }
00074 
00075   // For a PlexHandle we need a context
00076   VldContext vldc = RerootExodus::BuildVldContext();
00077 
00079   // Make or find the SimSnarl
00080     
00081   SimSnarlRecord* simsnarl = 0;
00082 
00083   // See if a SimSnarl already exists. 
00084   TObject* tobj;
00085   TIter    fragiter = mom->FragmentIter();
00086   while( ( tobj = fragiter.Next() ) ) {
00087     simsnarl = dynamic_cast<SimSnarlRecord*>(tobj);
00088     if(simsnarl) break;
00089   }
00090   
00091   // If not, make one.
00092   if(simsnarl == 0) {  
00093     Int_t   run      = RerootExodus::GetRunNo();
00094     Short_t subrun   = RerootExodus::GetSubRunNum();
00095     Int_t   snarl    = RerootExodus::GetSnarlNum(); // tied to tree entry
00096     Int_t   trigbits = 0;
00097     Short_t runtype = 0;
00098     Int_t   errcode = 0;
00099     Int_t   timeframe = RerootExodus::GetTimeFrame(vldc);
00100     Int_t   spilltype = -1;
00101 
00102     VldTimeStamp mcGenTime(RerootExodus::GetLastEventHistoryTimeStamp());
00103     std::string  mcCodename(RerootExodus::GetGminosCodeName().Data());
00104     std::string  mcHostname(RerootExodus::GetGminosHostName().Data());
00105     SimSnarlHeader simheader(vldc,run,subrun,runtype,
00106                              errcode,snarl,trigbits,timeframe,spilltype,
00107                              mcGenTime,mcCodename,mcHostname);
00108     
00109     simsnarl = new SimSnarlRecord(simheader);
00110 
00111     simsnarl->GetTempTags().Set("stream","SimSnarl");  // no idea....
00112     
00113     // Give it to mom.
00114     mom -> AdoptFragment(simsnarl);
00115   }
00116 
00118   // Find the DigiScintHitList if it exists.
00119   const TObjArray* scintHitListObj = 
00120     dynamic_cast<const TObjArray*>(simsnarl->FindComponent(0,"DigiScintHits"));
00121 
00122   std::map<Int_t,const DigiScintHit*> scintMap;
00123   std::map<Int_t,const DigiScintHit*>::iterator scintMapItr;
00124 
00125   if(scintHitListObj == 0) {
00126     MSG("Reroot",Msg::kError) << "Cannot find DigiScintHit list in the SimSnarl. (Need to run RerootToTruth Module)" << endl;
00127   } else {  
00128     // Build a lookup table for the strip ends. Use it to associate hits and digits.
00129      TObjArrayIter itr(scintHitListObj);
00130      const DigiScintHit* scintHit = 0;
00131      while( (scintHit = dynamic_cast<DigiScintHit*>(itr.Next())) !=0 ){
00132        PlexStripEndId seid = scintHit->StripEndId();
00133        scintMap[seid.Build18BitPlnStripKey()] = scintHit;
00134      }      
00135   }
00136   MSG("Reroot",Msg::kDebug) << "ScintHit map has " << scintMap.size() << " entries\n";
00137   
00138   // Get a PlexHandle for PlexStripEndId to RawChannelId conversions
00139   PlexHandle ph(vldc);
00140 
00141   // Prepare to loop over REROOT digits
00142   const TClonesArray *flsdigits = RerootExodus::GetFLSDigitList();
00143   REROOT_FLSDigit    *flsdigit  = 0;
00144   TIter diter(flsdigits);
00145 
00146   PlexStripEndId seid;
00147   PlexPixelSpotId psid;
00148   Float_t raw;
00149   Int_t   isAB;
00150   const DigiScintHit* scintHit=0;
00151   Int_t totalDigits = 0;
00152   Int_t mappedDigits = 0;
00153   
00154   // ADAMO unfilled entries have special values
00155   // but exact testing doesn't seem to work...
00156   Float_t ADAMO_RNULL =  699050. * (Float_t) (16<<26); // 699050*16.0**26
00157 
00158   JobCResult result = JobCResult::kPassed;
00159       
00160   // Make the list to store the entries in.
00161   DigiList<DigiPE> peList(0);
00162 
00163   while ( ( flsdigit = (REROOT_FLSDigit*) diter.Next() ) ) {
00164     // process A side
00165     raw  = flsdigit->RawA();
00166     isAB = 0;
00167     if ( raw > 0.0 && raw < ADAMO_RNULL ) {
00168       seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(),
00169                                       flsdigit->ICell(),isAB);
00170       psid = ph.GetPixelSpotId(seid);
00171       MSG("Reroot",Msg::kVerbose) << "FlsDigit: IPln()==" << flsdigit->IPln()
00172                                   << "  IExtr()=" << flsdigit->IExtr()
00173                                   << "  ICell()=" << flsdigit->ICell()
00174                                   << "  isAB=" << isAB
00175                                   << "  -> " << seid.AsString() << endl;
00176 
00177       // Strip ID:
00178       scintMapItr = scintMap.find(seid.Build18BitPlnStripKey());
00179       if(scintMapItr!=scintMap.end()){
00180         scintHit = scintMapItr->second;
00181         mappedDigits++;
00182       } else {
00183         scintHit = NULL;
00184       }
00185 
00186       AddPE(peList,seid,psid,flsdigit->SignalPEA(),flsdigit->TDCA(),scintHit);
00187       totalDigits++;
00188     }
00189     
00190     // process B side
00191     raw  = flsdigit->RawB();
00192     isAB = 1;
00193     if ( raw > 0.0 && raw < ADAMO_RNULL ) {
00194       seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(),
00195                                       flsdigit->ICell(),isAB);      
00196       psid = ph.GetPixelSpotId(seid);
00197 
00198       MSG("Reroot",Msg::kVerbose) << "FlsDigit: IPln()==" << flsdigit->IPln()
00199                                   << "  IExtr()=" << flsdigit->IExtr()
00200                                   << "  ICell()=" << flsdigit->ICell()
00201                                   << "  isAB=" << isAB
00202                                   << "  -> " << seid.AsString() << endl;
00203 
00204       // Strip ID:
00205       scintMapItr = scintMap.find(seid.Build18BitPlnStripKey());
00206       if(scintMapItr!=scintMap.end()){
00207         scintHit = scintMapItr->second;
00208         mappedDigits++;
00209       } else {
00210         scintHit = NULL;
00211       }
00212 
00213       AddPE(peList,seid,psid,flsdigit->SignalPEB(),flsdigit->TDCB(),scintHit);
00214       totalDigits++;
00215     }
00216   }
00217 
00218   MSG("Reroot",Msg::kDebug) << totalDigits << " FLSDigits converted to DigiPE. "
00219                            << mappedDigits << " of them mapped to DigiScintHits.\n";
00220 
00222   // Put list into SimSnarl.
00223 
00224 
00225   // Add the DigiPE list to the simsnarl.
00226   TObjArray* storageArray = peList.CreateObjArray("DigiListPe");
00227   simsnarl->AdoptTemporary(storageArray);
00228 
00229   return result;
00230 }


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1