TridModelMaker Class Reference

#include <TridModelMaker.h>

List of all members.

Public Member Functions

 TridModelMaker ()
 ~TridModelMaker ()
void Prepare (const MomNavigator *mom)
Int_t CreateStripModels (const MomNavigator *mom, TridModelList &list)
Int_t CreateIntersectionModels (const MomNavigator *mom, TridModelList &list)
Int_t CreateShowerModels (const MomNavigator *mom, TridModelList &list)
Int_t CreateTrackModels (const MomNavigator *mom, TridModelList &list)
Int_t CreatePmtModels (const MomNavigator *mom, TridModelList &list)
Int_t CreateChannelModels (const MomNavigator *mom, TridModelList &list)
Int_t CreateSliceModels (const MomNavigator *mom, TridModelList &list)

Public Attributes

VldContext fContext
const CandRecordfCandRecord
const NtpStRecordfNtpStRecord

Detailed Description

Definition at line 12 of file TridModelMaker.h.


Constructor & Destructor Documentation

TridModelMaker::TridModelMaker (  )  [inline]

Definition at line 15 of file TridModelMaker.h.

00015 {};

TridModelMaker::~TridModelMaker (  )  [inline]

Definition at line 16 of file TridModelMaker.h.

00016 {}; 


Member Function Documentation

Int_t TridModelMaker::CreateChannelModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 728 of file TridModelMaker.cxx.

References TridModel::AddDigit(), TridModelList::AddModel(), TridModel::AddStrip(), fContext, fNtpStRecord, PlexSEIdAltL::GetBestItem(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), TridModelList::GetIterator(), PlexHandle::GetRawChannelId(), PlexSEIdAltL::GetSize(), TridModel::GetSortKey(), NtpSRStrip::index, StripEnd::kNegative, StripEnd::kPositive, StripEnd::kUnknown, TridModelItr::Next(), NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRPulseHeight::raw, TridModelCrate::ShouldContain(), NtpStRecord::stp, and NtpSRStrip::strip.

Referenced by TridCratePage::CreateModels().

00730 {
00731   Int_t nmodel=0;
00732 
00733   const CandDigitListHandle* digitList =
00734     DataUtil::GetCandidate<CandDigitListHandle>(mom,
00735                                                 "CandDigitListHandle",
00736                                                 "canddigitlist");
00737 
00738   if(digitList) {
00739 
00740   CandDigitHandleItr cdhItr(digitList->GetDaughterIterator());
00741   while(CandDigitHandle *cdh = cdhItr()) {
00742     PlexSEIdAltL altList = cdh->GetPlexSEIdAltL();
00743     if(altList.GetSize()>0) {
00744       PlexSEIdAltLItem item = altList.GetBestItem();
00745       
00746       // Make a model, or find the correct one.
00747       
00748       // Make a new model, which might be redundant.
00749       TridModelCrate* newmodel = new TridModelCrate(cdh->GetChannelId());
00750       
00751       // Try to find a matching one.
00752       bool need_new = true;
00753       TridModelCrate* oldmodel;
00754       TridModelItr itr = models.GetIterator(newmodel->GetSortKey());
00755       while( (oldmodel = dynamic_cast<TridModelCrate*>(itr.Next())) ) {
00756         if(oldmodel->ShouldContain(cdh->GetChannelId()) ) {
00757           oldmodel->AddDigit(*cdh);
00758           need_new = false;
00759           delete newmodel;
00760           break;
00761         }
00762       }
00763         
00764       if(need_new) {
00765         newmodel->AddDigit(*cdh);
00766         models.AddModel(newmodel);      
00767         nmodel++;
00768       }
00769     }
00770   }
00771   }
00772 
00773   // Try from ntuple.
00774   if((nmodel==0) && (fNtpStRecord)) {
00775     if(fNtpStRecord->stp) {
00776       PlexHandle plex(fContext);
00777       
00778       TIter iter(fNtpStRecord->stp);
00779       TObject* tobj;
00780       const NtpSRStrip* strip;
00781       while( (tobj = iter.Next()) ) {
00782         if( (strip = dynamic_cast<const NtpSRStrip*>(tobj)) ) {
00783           PlexStripEndId seid(fContext.GetDetector(),
00784                               strip->plane,
00785                               strip->strip,
00786                               StripEnd::kUnknown);         
00787 
00788           for(int iend=1; iend<=2; iend++) {
00789             float raw = strip->ph0.raw;
00790             StripEnd::StripEnd_t end = StripEnd::kNegative;
00791             if(iend==2) {
00792               end = StripEnd::kPositive;
00793               raw = strip->ph1.raw;
00794             }
00795             if(raw>0) {
00796               // Got an end.
00797               seid.SetEnd(end);
00798               RawChannelId rcid = plex.GetRawChannelId(seid);
00799               
00800               // Make a new model, which might be redundant.
00801               TridModelCrate* newmodel = new TridModelCrate(rcid);            
00802               
00803               // Try to find a matching one.
00804               bool need_new = true;
00805               TridModelCrate* oldmodel;
00806               TridModelItr itr = models.GetIterator(newmodel->GetSortKey());
00807               while( (oldmodel = dynamic_cast<TridModelCrate*>(itr.Next())) ) {
00808                 if(oldmodel->ShouldContain(rcid) ) {
00809                   oldmodel->AddStrip(strip->index,fContext,
00810                                      strip, end);
00811                   need_new = false;
00812                   delete newmodel;
00813                   break;
00814                 }
00815               }
00816               
00817               if(need_new) {
00818                 newmodel->AddStrip(strip->index,fContext,
00819                                    strip, end);
00820                 models.AddModel(newmodel);      
00821                 nmodel++;
00822               }
00823             }
00824             
00825           }
00826         }
00827       }
00828     }
00829   }
00830   return nmodel;
00831 }

Int_t TridModelMaker::CreateIntersectionModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 535 of file TridModelMaker.cxx.

References TridModelList::AddModel(), MuELoss::e, TridModelStrip::fIntersections, TridModel::GetId(), TridModelList::GetIterator(), TridModel::GetMeanTime(), TridModel::GetSortKey(), Msg::kDebug, MSG, and TridModelItr::Next().

Referenced by TridPageDetector::CreateModels().

00537 {
00539   // Create intesection models
00541   
00542   Int_t nmodel = 0;
00543   
00544   // loop through existing models. Models should be sorted by plane number.
00545   TridModel*      model1;
00546   TridModel*      model2;
00547   TridModelStrip* modelStrip1;
00548   TridModelStrip* modelStrip2;
00549 
00550   TridModelItr itr = models.GetIterator();
00551   while( (model1 = itr.Next()) ) {
00552     modelStrip1 = dynamic_cast<TridModelStrip*>(model1);
00553     if(modelStrip1) {
00554       // Get the plane numbers.
00555       Int_t plane1 = modelStrip1->GetSortKey();
00556       Int_t plane2 = plane1+1;
00557       if(plane1<500) { // It's not in the veto shield
00558 
00559         // Ask for any models matching plane 2
00560         TridModelItr matchItr = models.GetIterator(plane2);
00561         while( (model2 = matchItr.Next() ) ) {
00562           modelStrip2 = dynamic_cast<TridModelStrip*>(model2);
00563           if(modelStrip2) {
00564             // We now have two strips in neigboring planes.
00565             // Are they in time?
00566             if(fabs(modelStrip1->GetMeanTime() - modelStrip2->GetMeanTime())<100e-9) {
00567               // Make the intersection.
00568               TridModelIntersect* intersectModel =
00569                 new TridModelIntersect( *modelStrip1, *modelStrip2 );
00570               models.AddModel(intersectModel);
00571               nmodel++;
00572               MSG("TriD",Msg::kDebug) << "Created intersection model - "
00573                                       << " ModelAdd:"     << intersectModel 
00574                                       << " Model ID:"     << ((intersectModel) ? (intersectModel->GetId()) : 0)
00575                                       << " ModelKey:"     << ((intersectModel) ? (intersectModel->GetSortKey()) : 0)
00576                                       << std::endl;
00577               
00578               // Mark strips as having been correctly intersected.
00579               modelStrip1->fIntersections++;
00580               modelStrip2->fIntersections++;
00581             }
00582           }
00583         }
00584       }
00585     }
00586   }
00587 
00588   return nmodel;
00589 }

Int_t TridModelMaker::CreatePmtModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 592 of file TridModelMaker.cxx.

References TridModel::AddDigit(), TridModelList::AddModel(), TridModel::AddStrip(), fContext, fNtpStRecord, PlexSEIdAltL::GetBestItem(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), TridModelList::GetIterator(), PlexHandle::GetPixelSpotId(), PlexSEIdAltLItem::GetPixelSpotId(), PlexSEIdAltL::GetSize(), TridModel::GetSortKey(), NtpSRStrip::index, StripEnd::kNegative, StripEnd::kPositive, StripEnd::kUnknown, Munits::m, TridModelItr::Next(), NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRPulseHeight::raw, TridModelPmt::ShouldContain(), TridModelPixel::ShouldContain(), NtpStRecord::stp, and NtpSRStrip::strip.

Referenced by TridPmtPage::CreateModels().

00594 {
00595   // Build PMT list.
00596   Int_t nmodel=0;
00597 
00598   const CandDigitListHandle* digitList =
00599     DataUtil::GetCandidate<CandDigitListHandle>(mom,
00600                                                 "CandDigitListHandle",
00601                                                 "canddigitlist");
00602 
00603   if(digitList) {
00604     CandDigitHandleItr cdhItr(digitList->GetDaughterIterator());
00605     while(CandDigitHandle *cdh = cdhItr()) {
00606       PlexSEIdAltL altList = cdh->GetPlexSEIdAltL();
00607       if(altList.GetSize()>0) {
00608         PlexSEIdAltLItem item = altList.GetBestItem();
00609         
00610         // Make a model, or find the correct one.
00611         bool need_new_pmt = true;
00612         bool need_new_pixel = true;
00613         
00614         // Make a model to get the sort key.
00615         TridModelPmt newmodel(item.GetPixelSpotId());
00616         
00617         TridModel* oldmodel;
00618         TridModelItr itr = models.GetIterator(newmodel.GetSortKey());
00619         while( (oldmodel = itr.Next()) ) {
00620           TridModelPmt* oldpmt = dynamic_cast<TridModelPmt*>(oldmodel);
00621           if(oldpmt) 
00622             if(oldpmt->ShouldContain(item.GetPixelSpotId()) ) {
00623               // We already have this one. Add in this item.
00624               oldpmt->AddDigit(*cdh);
00625               need_new_pmt = false;
00626             }
00627           TridModelPixel* oldpix = dynamic_cast<TridModelPixel*>(oldmodel);
00628           if(oldpix)    
00629             if(oldpix->ShouldContain(item.GetPixelSpotId()) ) {
00630               // We already have this one. Add in this item.
00631               oldpix->AddDigit(*cdh);
00632               need_new_pixel = false;
00633             }  
00634         }
00635 
00636         if(need_new_pmt) {      
00637           TridModel* m = new TridModelPmt(item.GetPixelSpotId());
00638           m->AddDigit(*cdh);
00639           models.AddModel(m);     
00640           nmodel++;
00641         }
00642         if(need_new_pixel) {    
00643           TridModel* m = new TridModelPixel(item.GetPixelSpotId());
00644           m->AddDigit(*cdh);
00645           models.AddModel(m);
00646           nmodel++;
00647         }
00648         
00649       }
00650       
00651     }
00652   } // have digitList
00653 
00654   // Try from ntuple.
00655   if((nmodel==0) && (fNtpStRecord)) {
00656     if(fNtpStRecord->stp) {
00657       PlexHandle plex(fContext);
00658       
00659       TIter iter(fNtpStRecord->stp);
00660       TObject* tobj;
00661       const NtpSRStrip* strip;
00662       while( (tobj = iter.Next()) ) {
00663         if( (strip = dynamic_cast<const NtpSRStrip*>(tobj)) ) {
00664           PlexStripEndId seid(fContext.GetDetector(),
00665                               strip->plane,
00666                               strip->strip,
00667                               StripEnd::kUnknown);         
00668 
00669           for(int iend=1; iend<=2; iend++) {
00670             float raw = strip->ph0.raw;
00671             StripEnd::StripEnd_t end = StripEnd::kNegative;
00672             if(iend==2) {
00673               end = StripEnd::kPositive;
00674               raw = strip->ph1.raw;
00675             }
00676             if(raw>0) {
00677               // Got an end.
00678               seid.SetEnd(end);
00679               PlexPixelSpotId psid = plex.GetPixelSpotId(seid);
00680                
00681               // Make a model, or find the correct one.
00682               bool need_new_pmt = true;
00683               bool need_new_pixel = true;
00684                
00685               // Make a model to get the sort key.
00686               TridModelPmt newmodel(psid);
00687                
00688               TridModel* oldmodel;
00689               TridModelItr itr = models.GetIterator(newmodel.GetSortKey());
00690               while( (oldmodel = itr.Next()) ) {
00691                 TridModelPmt* oldpmt = dynamic_cast<TridModelPmt*>(oldmodel);
00692                 if(oldpmt) 
00693                   if(oldpmt->ShouldContain(psid) ) {
00694                     // We already have this one. Add in this item.
00695                     oldpmt->AddStrip(strip->index, fContext, strip, end);
00696                     need_new_pmt = false;
00697                   }
00698                 TridModelPixel* oldpix = dynamic_cast<TridModelPixel*>(oldmodel);
00699                 if(oldpix)      
00700                   if(oldpix->ShouldContain(psid) ) {
00701                     // We already have this one. Add in this item.
00702                     oldpix->AddStrip(strip->index, fContext, strip, end);
00703                     need_new_pixel = false;
00704                   }  
00705               }
00706         
00707               if(need_new_pmt) {        
00708                 TridModelPmt* newpmt = new TridModelPmt(psid);
00709                 newpmt->AddStrip(strip->index, fContext, strip, end);
00710                 models.AddModel(newpmt);         
00711                 nmodel++;
00712               }
00713               if(need_new_pixel) {      
00714                 TridModelPixel* newpix = new TridModelPixel(psid);
00715                 newpix->AddStrip(strip->index, fContext, strip, end);
00716                 models.AddModel(newpix);
00717                 nmodel++;
00718               }        
00719             }
00720           }
00721         }
00722       }
00723     }
00724   }
00725   return nmodel;
00726 }

Int_t TridModelMaker::CreateShowerModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 203 of file TridModelMaker.cxx.

References TridModel::AddCandidate(), TridModelList::AddModel(), TridModel::AddStrip(), MuELoss::e, fContext, TridModelShower::fFirstPlane, TridModelShower::fLastPlane, TridModelShower::fN, fNtpStRecord, TridModelShower::fT, TridModel::fTotalCharge, TridModelShower::fU, TridModelShower::fV, TridModelShower::fWidth, CandHandle::GetDaughterIterator(), VldContext::GetDetector(), VldTimeStamp::GetNanoSec(), UgliGeomHandle::GetStripHandle(), VldContext::GetTimeStamp(), TridModelShower::GetU(), TridModelShower::GetV(), TridModelShower::GetWidth(), NtpSRStripPulseHeight::gev, NtpSRStrip::index, TridModelShower::IsValid(), CalStripType::kGeV, CalStripType::kMIP, Detector::kNear, CalStripType::kNone, CalStripType::kPE, TridModelRecoStrip::kShower, CalStripType::kSigCorr, CalStripType::kSigLin, CalStripType::kSigMapped, PlaneView::kU, PlaneView::kV, StripEnd::kWest, StripEnd::kWhole, NtpSRStripPulseHeight::mip, NtpSRShower::nstrip, NtpSRPulseHeight::pe, NtpSRShower::ph, NtpSRStrip::plane, NtpSRPulseHeight::raw, NtpStRecord::shw, NtpSRPulseHeight::sigcor, NtpSRPulseHeight::siglin, NtpSRStripPulseHeight::sigmap, NtpSRShower::stp, NtpStRecord::stp, NtpSRStrip::strip, NtpSRStrip::time0, NtpSRStrip::time1, and NtpSRStrip::tpos.

Referenced by TridUVPage::CreateModels(), and TridPageDetector::CreateModels().

00205 {
00207   // Create shower models.
00209   Int_t nmodel=0;
00210   
00211   UgliGeomHandle ugli(fContext);
00212   
00213   const CandShowerListHandle* showerlist =
00214     DataUtil::GetCandidate<CandShowerListHandle>(mom,
00215                                                  0,"CandShowerList");
00216   if (showerlist) {
00217     TIter showerItr(showerlist->GetDaughterIterator());
00218     while(CandShowerHandle* shower = dynamic_cast<CandShowerHandle*>(showerItr())) {
00219       //cout << "Got a shower! " << endl;
00220       if(shower) {
00221         TridModelShower* showermodel = new TridModelShower;
00222         showermodel->AddCandidate(*shower);
00223         for(int i=0;i<500;i++) {
00224           if(shower->GetNStrips(i)>0) {
00225             PlexPlaneId plane(fContext.GetDetector(),i);
00226             showermodel->fN[i] = shower->GetNStrips(i);
00227             showermodel->fU[i] = shower->GetU(i);
00228             showermodel->fV[i] = shower->GetV(i);
00229 
00230             if(plane.GetPlaneView()==PlaneView::kU) {
00231               showermodel->fWidth[i] = TMath::Max(fabs(shower->GetMinU(i)-shower->GetU(i)),
00232                                                   fabs(shower->GetMaxU(i)-shower->GetU(i)));
00233             } else {
00234               showermodel->fWidth[i] = TMath::Max(fabs(shower->GetMinV(i)-shower->GetV(i)),
00235                                                   fabs(shower->GetMaxV(i)-shower->GetV(i)));        }
00236           }
00237           showermodel->fT[i] = shower->GetT(i);
00238         }      
00239         models.AddModel(showermodel);
00240         nmodel++;
00241 
00243         // Create shower recostrips
00244         TIter stripItr(shower->GetDaughterIterator());
00245         while(CandStripHandle* strip = dynamic_cast<CandStripHandle*>(stripItr())) {
00246           UgliStripHandle ustrip = ugli.GetStripHandle(strip->GetStripEndId());
00247           Int_t plane = strip->GetPlane();
00248           Float_t width_u = 0.1;
00249           Float_t width_v = 0.1;
00250           Float_t nu = 0;
00251           Float_t nv = 0;
00252           for(int p = plane-1; p<= plane+1; p++) {
00253             if(shower->IsTPosValid(p)) {
00254               PlexPlaneId planeId(fContext.GetDetector(),p);
00255               if(planeId.GetPlaneView()==PlaneView::kU) {
00256                 width_u += (shower->GetMaxU(p)-shower->GetMinU(p))*0.5; 
00257                 nu++;
00258               } else {
00259                 width_v += (shower->GetMaxV(p)-shower->GetMinV(p))*0.5;
00260                 nv++;
00261               }
00262             }
00263           }
00264           if(nu>0) width_u /= nu;
00265           if(nv>0) width_v /= nv;
00266 
00267           TridModelRecoStrip* recostrip = 
00268             new TridModelRecoStrip(ustrip,
00269                                    shower->GetU(plane),
00270                                    shower->GetV(plane),
00271                                    width_u,
00272                                    width_v,
00273                                    TridModelRecoStrip::kShower,
00274                                    showermodel
00275                                    );
00276           recostrip->AddCandidate(*strip);
00277 
00278           recostrip->fTotalCharge[CalStripType::kSigMapped] += shower->GetStripCharge(strip,CalStripType::kSigMapped);
00279           recostrip->fTotalCharge[CalStripType::kMIP]    += shower->GetStripCharge(strip,CalStripType::kMIP);
00280           recostrip->fTotalCharge[CalStripType::kGeV]    += shower->GetStripCharge(strip,CalStripType::kGeV);
00281 
00282           models.AddModel(recostrip);
00283           nmodel++;
00284         }
00285       }
00286     }
00287   }
00288 
00289   // Try from ntuple.
00290   if((nmodel==0) && (fNtpStRecord)) {
00291     if(fNtpStRecord->shw) {
00292       TIter iter(fNtpStRecord->shw);
00293        TObject* tobj;
00294        const NtpSRShower* shower;
00295        while( (tobj = iter.Next()) ) {
00296          if( (shower = dynamic_cast<const NtpSRShower*>(tobj)) ) {
00297            //if(shower->stpu == 0) { cout << "Bad shower in ntp! " << endl; continue; };
00298            TridModelShower* model = new TridModelShower;           
00299            for(int i=0;i<shower->nstrip;i++) {
00300              int stripid = shower->stp[i];
00301              const NtpSRStrip* strip = dynamic_cast<const NtpSRStrip*>(fNtpStRecord->stp->At(stripid));
00302              model->AddStrip(stripid,
00303                              fContext,
00304                              strip,
00305                              (fContext.GetDetector()==Detector::kNear)?StripEnd::kWest:StripEnd::kWhole
00306                              );
00307              if(strip) {
00308                PlexPlaneId plane(fContext.GetDetector(),strip->plane);
00309                model->fN[strip->plane] += 1;
00310                model->fU[strip->plane] += strip->tpos; // just use U as tpos holder
00311                double t = 0;
00312                double ends = 0;
00313                if(strip->time0>-999990) { t+=(strip->time0 - fContext.GetTimeStamp().GetNanoSec()*1e-9); ends++; }
00314                if(strip->time1>-999990) { t=+(strip->time1 - fContext.GetTimeStamp().GetNanoSec()*1e-9); ends++; }
00315                model->fT[strip->plane] += t/ends;
00316              }
00317              model->fTotalCharge[CalStripType::kNone]      = shower->ph.raw;
00318              model->fTotalCharge[CalStripType::kSigLin]    = shower->ph.siglin;
00319              model->fTotalCharge[CalStripType::kSigCorr]   = shower->ph.sigcor;
00320              model->fTotalCharge[CalStripType::kPE]        = shower->ph.pe;
00321              model->fTotalCharge[CalStripType::kSigMapped] = shower->ph.sigmap;
00322              model->fTotalCharge[CalStripType::kMIP]       = shower->ph.mip;
00323              model->fTotalCharge[CalStripType::kGeV]       = shower->ph.gev;
00324            }
00325          
00326            // Normalize to number of strips per plane.
00327            for(int p=0;p<500;p++) {
00328              if(model->fN[p]>0) {
00329                model->fU[p]/=(float)model->fN[p];
00330                if(model->fFirstPlane>p) model->fFirstPlane=p;
00331                if(model->fLastPlane<p)  model->fLastPlane=p;
00332                model->fT[p]/=(double)(model->fN[p]);
00333              }
00334            }
00335 
00336            // Use fV to store lpos.
00337            // Use last/next plane average in the middle of shower
00338            // use next or last plane at ends.
00339            for(int p=model->fFirstPlane+1; p<model->fLastPlane;p++) {
00340              model->fV[p] = 0.5* model->fU[p-1] + 0.5 * model->fU[p+1];      
00341            }
00342            model->fV[model->fFirstPlane] = model->fU[model->fFirstPlane+1];
00343            model->fV[model->fLastPlane]  = model->fU[model->fLastPlane-1];
00344 
00345            // Get the widths.
00346            for(int i=0;i<shower->nstrip;i++) {
00347              int stripid = shower->stp[i];
00348              const NtpSRStrip* strip = dynamic_cast<const NtpSRStrip*>(fNtpStRecord->stp->At(stripid));
00349              if(strip){
00350                PlexPlaneId plane(fContext.GetDetector(),strip->plane);
00351                float w;
00352                float center = model->fU[strip->plane];
00353                w = fabs(strip->tpos - center);
00354                if(w > model->fWidth[strip->plane]) model->fWidth[strip->plane] = w;
00355              }  
00356            }
00357            
00358            // Rescramble to get UV correct:      
00359            for(int p=model->fFirstPlane; p<model->fLastPlane+1;p++) {  
00360              PlexPlaneId plane(fContext.GetDetector(),p);
00361              if(plane.GetPlaneView()==PlaneView::kV){
00362                float u = model->fV[p];
00363                model->fV[p] = model->fU[p];
00364                model->fU[p] = u;
00365              }
00366              //cout << Form("%3d: %s %4.1f %4.1f %4.1f",
00367              //                   p,
00368              //           PlaneView::AsString(plane.GetPlaneView()),
00369              //           model->GetU(p),
00370              //           model->GetV(p),
00371              //           model->GetWidth(p)) << endl;
00372            }
00373 
00374 
00375            models.AddModel(model);
00376            nmodel++;
00377            
00379            // Create the shower recostrips.
00380            for(int i=0;i<shower->nstrip;i++) {
00381              int stripid = shower->stp[i];
00382              const NtpSRStrip* strip = dynamic_cast<const NtpSRStrip*>(fNtpStRecord->stp->At(stripid));
00383              if(strip){
00384                PlexStripEndId seid(fContext.GetDetector(),strip->plane,strip->strip);
00385                UgliStripHandle ustrip = ugli.GetStripHandle(seid);
00386                Int_t plane = strip->plane;
00387                float width_u = 0.04;
00388                float width_v = 0.04;
00389                Float_t nu = 0;
00390                Float_t nv = 0;
00391                for(int p = plane-1; p<= plane+1; p++) {
00392                  if(model->IsValid(p)) {
00393                    PlexPlaneId planeId(fContext.GetDetector(),p);
00394                    if(planeId.GetPlaneView()==PlaneView::kU) {
00395                      width_u += model->GetWidth(p);
00396                      nu++;
00397                    } else {
00398                      width_v += model->GetWidth(p);
00399                      nv++;
00400                    }
00401                  }
00402                }
00403                if(nu>0) width_u /= nu;
00404                if(nv>0) width_v /= nv;
00405 
00406                TridModelRecoStrip* recostrip = 
00407                  new TridModelRecoStrip(ustrip,
00408                                         model->GetU(strip->plane),
00409                                         model->GetV(strip->plane),
00410                                         width_u,
00411                                         width_v,
00412                                         TridModelRecoStrip::kShower,
00413                                         model
00414                                         );
00415                
00416                recostrip->AddStrip(strip->index,fContext,
00417                                    strip,
00418                                    (fContext.GetDetector()==Detector::kNear)?StripEnd::kWest:StripEnd::kWhole
00419                                    );
00420                models.AddModel(recostrip);
00421                nmodel++;
00422                
00423              }  
00424            }
00425            
00426          }
00427        }
00428     }
00429   }
00430   
00431   return nmodel;
00432 }

Int_t TridModelMaker::CreateSliceModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 834 of file TridModelMaker.cxx.

References TridModelList::AddModel(), TridModel::AddStrip(), MuELoss::e, fContext, TridModelSlice::fHits, fNtpStRecord, TridModel::fSlice, VldContext::GetDetector(), TridModel::GetMeanTime(), VldTimeStamp::GetNanoSec(), VldContext::GetTimeStamp(), Detector::kFar, Detector::kNear, StripEnd::kWest, StripEnd::kWhole, NtpSRSlice::nstrip, NtpSRStrip::plane, TridModel::SetSortKey(), NtpStRecord::slc, NtpStRecord::stp, NtpSRSlice::stp, and NtpSRStrip::time1.

Referenced by TridPageSlice::CreateModels().

00836 {
00837   Int_t nmodel=0;
00838   Int_t maxplane = 120;
00839   if(fContext.GetDetector()==Detector::kFar) maxplane = 300;
00840 
00841   // Try from ntuple.
00842   if((nmodel==0) && (fNtpStRecord)) {
00843     if(fNtpStRecord->slc) {
00844       TIter iter(fNtpStRecord->slc);
00845       TObject* tobj;
00846       const NtpSRSlice* slice;
00847       int islice = 0;
00848       while( (tobj = iter.Next()) ) {
00849         if( (slice = dynamic_cast<const NtpSRSlice*>(tobj)) ) {
00850           TridModelSlice* model = new TridModelSlice;
00851           model->fSlice = islice++;
00852           for(int i=0;i<slice->nstrip;i++) {
00853              int stripid = slice->stp[i];
00854              const NtpSRStrip* strip = dynamic_cast<const NtpSRStrip*>(fNtpStRecord->stp->At(stripid));
00855              model->AddStrip(stripid, fContext, strip,
00856                              (fContext.GetDetector()==Detector::kNear)?StripEnd::kWest:StripEnd::kWhole
00857                              );
00858              if(strip){        
00859                if(strip->plane < maxplane) {
00860                  model->fHits.push_back(
00861                                         TridModelSlice::SliceHit(strip->plane,strip->time1-fContext.GetTimeStamp().GetNanoSec()*1e-9));
00862                }
00863              }
00864           }             
00865           model->SetSortKey((int)(model->GetMeanTime()*10000000)); // To sort on time to the nearest 0.1 us
00866           models.AddModel(model);
00867           nmodel++;       
00868         }
00869       }
00870     }
00871   }
00872   return nmodel;
00873 }

Int_t TridModelMaker::CreateStripModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 435 of file TridModelMaker.cxx.

References TridModelStrip::AddDigit(), TridModelList::AddModel(), TridModelStrip::AddStrip(), fContext, fNtpStRecord, PlexSEIdAltL::GetBestItem(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), TridModel::GetId(), TridModelList::GetIterator(), PlexSEIdAltLItem::GetSEId(), PlexSEIdAltL::GetSize(), TridModel::GetSortKey(), NtpSRStrip::index, Msg::kDebug, Detector::kNear, StripEnd::kNegative, StripEnd::kPositive, StripEnd::kUnknown, StripEnd::kWest, StripEnd::kWhole, MSG, TridModelItr::Next(), NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRPulseHeight::raw, TridModelStrip::ShouldContain(), NtpStRecord::stp, and NtpSRStrip::strip.

Referenced by TridUVPage::CreateModels(), and TridPageDetector::CreateModels().

00437 {
00438   Int_t nmodel=0;
00439   PlexHandle plex(fContext);
00440   bool fBestDemuxOnly = true; // FIXME: configurable.
00441   
00442   const CandDigitListHandle* digitList =
00443     DataUtil::GetCandidate<CandDigitListHandle>(mom,
00444                                                 "CandDigitListHandle",
00445                                                 "canddigitlist");
00446  
00447   // Create strip models.
00448 
00449   if(digitList) {
00450     CandDigitHandleItr cdhItr(digitList->GetDaughterIterator());
00451     while(CandDigitHandle *cdh = cdhItr()) {
00452       PlexSEIdAltL altList = cdh->GetPlexSEIdAltL();
00453       
00454       int numitems = altList.GetSize();
00455       
00456     // Do only one strip
00457     // unless we're explicitly doing all
00458     // or these digit(s) have been selected.
00459       if((numitems>1)&&(fBestDemuxOnly))
00460         numitems = 1;
00461       
00462       for(int i=0; i<numitems; i++) {
00463         PlexSEIdAltLItem item = altList[i];
00464         if(numitems==1) item = altList.GetBestItem();
00465         
00466         // Make a new model, which might be redundant.
00467         TridModelStrip* newmodel = new TridModelStrip(item.GetSEId());
00468         
00469         // Try to find a matching one.
00470         bool need_new = true;
00471         TridModel* oldmodel;
00472         TridModelItr itr = models.GetIterator(newmodel->GetSortKey());
00473         while( (oldmodel = itr.Next()) ) {
00474           TridModelStrip* oldstrip = dynamic_cast<TridModelStrip*>(oldmodel);
00475           if(oldstrip) {
00476             if(oldstrip->ShouldContain(item.GetSEId()) ) {
00477               oldstrip->AddDigit(*cdh);
00478               need_new = false;
00479               delete newmodel;
00480               break;
00481             }
00482           }
00483         }
00484         
00485         if(need_new){
00486           newmodel->AddDigit(*cdh);
00487           models.AddModel(newmodel);    
00488           nmodel++;
00489           MSG("TriD",Msg::kDebug) << "Created strip model - "
00490                                   << " ModelAdd:"     << newmodel 
00491                                   << " Model ID:"     << ((newmodel) ? (newmodel->GetId()) : 0)
00492                                   << " ModelKey:"     << ((newmodel) ? (newmodel->GetSortKey()) : 0)
00493                                   << std::endl;
00494         }
00495       }
00496       
00497     }
00498   } // have digitList
00499 
00500   // Try from ntuple.
00501   if((nmodel==0) && (fNtpStRecord)) {
00502     if(fNtpStRecord->stp) {
00503        TIter iter(fNtpStRecord->stp);
00504        TObject* tobj;
00505        const NtpSRStrip* strip;
00506        while( (tobj = iter.Next()) ) {
00507          if( (strip = dynamic_cast<const NtpSRStrip*>(tobj)) ) {
00508            PlexStripEndId seid(fContext.GetDetector(),
00509                                strip->plane,
00510                                strip->strip,
00511                                StripEnd::kUnknown);        
00512 
00513            if(strip->ph0.raw>0) {
00514              seid.SetEnd(StripEnd::kNegative);
00515              if(strip->ph1.raw>0) 
00516                seid.SetEnd(StripEnd::kWhole);
00517            } else if (strip->ph1.raw>0) 
00518              seid.SetEnd(StripEnd::kPositive);
00519 
00520            TridModelStrip* model = new TridModelStrip(seid);
00521            model->AddStrip(strip->index,fContext,strip,
00522                              (fContext.GetDetector()==Detector::kNear)?StripEnd::kWest:StripEnd::kWhole
00523                              );
00524            models.AddModel(model);
00525            nmodel++;
00526          }
00527        }
00528     }
00529   }
00530 
00531   return nmodel;
00532 }

Int_t TridModelMaker::CreateTrackModels ( const MomNavigator mom,
TridModelList list 
)

Definition at line 64 of file TridModelMaker.cxx.

References TridModel::AddCandidate(), TridModelList::AddModel(), TridModel::AddStrip(), NtpSRVertex::dcosu, NtpSRVertex::dcosv, NtpSRVertex::dcosz, NtpSRTrack::ds, MuELoss::e, NtpSRMomentum::eqp, fContext, TridModelTrack::fDescription, TridModelTrack::fFirstPlane, NtpSRTrack::fidend, NtpSRTrack::fidvtx, TridModelTrack::fLastPlane, TridModelTrack::fN, fNtpStRecord, Form(), TridModelTrack::fT, TridModel::fTotalCharge, TridModelTrack::fU, TridModelTrack::fV, CandHandle::GetDaughterIterator(), VldContext::GetDetector(), VldTimeStamp::GetNanoSec(), VldContext::GetTimeStamp(), NtpSRStripPulseHeight::gev, CalStripType::kGeV, CalStripType::kMIP, Detector::kNear, CalStripType::kNone, CalStripType::kPE, CalStripType::kSigCorr, CalStripType::kSigLin, CalStripType::kSigMapped, StripEnd::kWest, StripEnd::kWhole, NtpSRTrack::lin, NtpSRStripPulseHeight::mip, NtpSRTrack::momentum, NtpSRTrack::nstrip, NtpSRPulseHeight::pe, NtpSRTrack::ph, NtpSRStrip::plane, NtpSRMomentum::qp, NtpSRTrack::range, NtpSRPulseHeight::raw, NtpSRPulseHeight::sigcor, NtpSRPulseHeight::siglin, NtpSRStripPulseHeight::sigmap, NtpStRecord::stp, NtpSRTrack::stp, NtpSRTrack::stpph0gev, NtpSRTrack::stpph0mip, NtpSRTrack::stpph0sigmap, NtpSRTrack::stpph1gev, NtpSRTrack::stpph1mip, NtpSRTrack::stpph1sigmap, NtpSRTrack::stpu, NtpSRTrack::stpv, NtpSRStrip::time0, NtpSRStrip::time1, NtpSRFiducial::trace, NtpSRFiducial::tracez, NtpStRecord::trk, NtpSRVertex::u, NtpSRVertex::v, NtpSRTrack::vtx, and NtpSRVertex::z.

Referenced by TridUVPage::CreateModels(), and TridPageDetector::CreateModels().

00066 {
00068   // Create track models.
00070   Int_t nmodel=0;
00071 
00072   const CandTrackListHandle* tracklist =
00073     DataUtil::GetCandidate<CandTrackListHandle>(mom,
00074                                                 0,"CandTrackSRList");
00075   if (tracklist) {
00076     TIter trackItr(tracklist->GetDaughterIterator());
00077     while(CandTrackHandle* track = dynamic_cast<CandTrackHandle*>(trackItr())) {
00078       //cout << "Got a track! " << endl;
00079       if(track) {
00080         TridModelTrack* model = new TridModelTrack();
00081         model->AddCandidate(*track);
00082         for(int p=0;p<500;p++) {
00083           if(track->IsTPosValid(p)) {
00084             if(p<model->fFirstPlane) model->fFirstPlane = p;
00085             if(p>model->fLastPlane) model->fLastPlane = p;
00086             model->fN[p] = 1;
00087             model->fU[p] = track->GetU(p);
00088             model->fV[p] = track->GetV(p);
00089             model->fT[p] = track->GetT(p);          
00090           }
00091         }
00092         
00093         // Create description:
00094         model->fDescription = "Track: \n";
00095         model->fDescription+= Form("Distance: %f.1 m \n",track->GetdS());
00096         model->fDescription+= Form("Range:    %f.1 g/cm^2\n",track->GetRange());
00097         model->fDescription+= Form("Momentum: %f.1 GeV\n",track->GetMomentum());
00098         model->fDescription+= Form("Vertex: uvz=(%f.1, %f.1, %f.1)\n",
00099                                    track->GetVtxU(),track->GetVtxV(),track->GetVtxZ());
00100         model->fDescription+= Form("VtxDir: uvz=(%f.2, %f.2, %f.2)\n",
00101                                    track->GetVtxDirCosU(),track->GetVtxDirCosV(),track->GetVtxDirCosZ());
00102         model->fDescription+= Form("Dir:    uvz=(%f.2, %f.2, %f.2)\n",
00103                                    track->GetDirCosU(),track->GetDirCosV(),track->GetDirCosZ());
00104         model->fDescription+= Form("Planes: %d to %d\n",model->fFirstPlane,model->fLastPlane);
00105         model->fDescription+= Form("VtxDir: uvz=(%f.2,%f.2,%f.2)\n",
00106                                    track->GetVtxDirCosU(),track->GetVtxDirCosV(),track->GetVtxDirCosZ());
00107         model->fDescription+= Form("Vertex Trace: %.1f   TraceZ:%.1f \n",
00108                                    track->GetVtxTrace(), track->GetVtxTraceZ());
00109         model->fDescription+= Form("End Trace:    %.1f   TraceZ:%.1f \n",
00110                                    track->GetEndTrace(), track->GetEndTraceZ());
00111  
00112         models.AddModel(model);
00113         nmodel++;
00114       }
00115     }
00116   }
00117 
00118   // Try from ntuple.
00119   if((nmodel==0) && (fNtpStRecord)) {
00120     if(fNtpStRecord->trk) {
00121       TIter iter(fNtpStRecord->trk);
00122        TObject* tobj;
00123        const NtpSRTrack* track;
00124        while( (tobj = iter.Next()) ) {
00125          if( (track = dynamic_cast<const NtpSRTrack*>(tobj)) ) {
00126            TridModelTrack* tmodel = new TridModelTrack;    
00127            for(int i=0;i<track->nstrip;i++) {
00128              int stripid = track->stp[i];
00129              const NtpSRStrip* strip = dynamic_cast<const NtpSRStrip*>(fNtpStRecord->stp->At(stripid));
00130              tmodel->AddStrip(stripid,
00131                               fContext,
00132                               strip,
00133                               (fContext.GetDetector()==Detector::kNear)?StripEnd::kWest:StripEnd::kWhole
00134                              );
00135              if(strip) {
00136                int plane = strip->plane;
00137                if(plane < tmodel->fFirstPlane) tmodel->fFirstPlane = plane;
00138                if(plane > tmodel->fLastPlane)  tmodel->fLastPlane  = plane;
00139                tmodel->fN[plane] += 1;
00140                tmodel->fU[plane] += track->stpu[i];
00141                tmodel->fV[plane] += track->stpv[i];
00142                double t = 0;
00143                double ends = 0;
00144                if(strip->time0>-999990) { t+=(strip->time0 - fContext.GetTimeStamp().GetNanoSec()*1e-9); ends++; }
00145                if(strip->time1>-999990) { t+=(strip->time1 - fContext.GetTimeStamp().GetNanoSec()*1e-9); ends++; }
00146                tmodel->fT[strip->plane] += t/ends;
00147                tmodel->fTotalCharge[CalStripType::kSigMapped] += track->stpph0sigmap[i];
00148                tmodel->fTotalCharge[CalStripType::kSigMapped] += track->stpph1sigmap[i];
00149                tmodel->fTotalCharge[CalStripType::kMIP] += track->stpph0mip[i];
00150                tmodel->fTotalCharge[CalStripType::kMIP] += track->stpph1mip[i];
00151                tmodel->fTotalCharge[CalStripType::kGeV] += track->stpph0gev[i];
00152                tmodel->fTotalCharge[CalStripType::kGeV] += track->stpph1gev[i];
00153              }
00154            }
00155            tmodel->fTotalCharge[CalStripType::kNone]      = track->ph.raw;
00156            tmodel->fTotalCharge[CalStripType::kSigLin]    = track->ph.siglin;
00157            tmodel->fTotalCharge[CalStripType::kSigCorr]   = track->ph.sigcor;
00158            tmodel->fTotalCharge[CalStripType::kPE]        = track->ph.pe;
00159            tmodel->fTotalCharge[CalStripType::kSigMapped] = track->ph.sigmap;
00160            tmodel->fTotalCharge[CalStripType::kMIP]       = track->ph.mip;
00161            tmodel->fTotalCharge[CalStripType::kGeV]       = track->ph.gev;
00162 
00163            // Normalize to number of strips per plane.
00164            for(int i=0;i<500;i++) 
00165              if(tmodel->fN[i]>0) {
00166                tmodel->fU[i]/=(float)tmodel->fN[i];
00167                tmodel->fV[i]/=(float)tmodel->fN[i];            
00168                tmodel->fT[i]/=(double)tmodel->fN[i];           
00169              }
00170          
00171            
00172            // Create description:
00173            tmodel->fDescription = "Track: \n";
00174            tmodel->fDescription+= Form("Distance: %f.1 m \n",track->ds);
00175            tmodel->fDescription+= Form("Range:    %f.1 g/cm^2\n",track->range);
00176            tmodel->fDescription+= Form("Momentum: %f.1 GeV (range)\n",track->range);
00177            tmodel->fDescription+= Form("q/p:      %f.1 +/- %.1f \n",track->momentum.qp, track->momentum.eqp);
00178            tmodel->fDescription+= Form("Vertex: uvz=(%f.1, %f.1, %f.1)\n",
00179                                        track->vtx.u, track->vtx.v, track->vtx.z );
00180            tmodel->fDescription+= Form("VtxDir: uvz=(%f.2, %f.2, %f.2)\n",
00181                                        track->vtx.dcosu, track->vtx.dcosv, track->vtx.dcosz);
00182            tmodel->fDescription+= Form("Dir:    uvz=(%f.2, %f.2, %f.2)\n",
00183                                        track->lin.dcosu, track->lin.dcosv, track->lin.dcosz);
00184            tmodel->fDescription+= Form("Planes: %d to %d\n",
00185                                        tmodel->fFirstPlane,tmodel->fLastPlane);
00186            tmodel->fDescription+= Form("Vertex Trace: %.1f   TraceZ:%.1f \n",
00187                                        track->fidvtx.trace, track->fidvtx.tracez);
00188            tmodel->fDescription+= Form("End Trace:    %.1f   TraceZ:%.1f \n",
00189                                        track->fidend.trace, track->fidend.tracez);
00190  
00191            models.AddModel(tmodel);
00192            nmodel++;
00193          }
00194        }
00195     }
00196   }
00197 
00198 
00199   return nmodel;
00200 }

void TridModelMaker::Prepare ( const MomNavigator mom  ) 

Definition at line 43 of file TridModelMaker.cxx.

References fCandRecord, fContext, fNtpStRecord, MomNavigator::GetFragment(), GetVldContext(), Msg::kError, and MSG.

Referenced by TridUVPage::CreateModels(), TridPmtPage::CreateModels(), TridPageDetector::CreateModels(), TridPageSlice::CreateModels(), and TridCratePage::CreateModels().

00044 {
00045   // Explore Mom. See what there is to see.
00046 
00047   // Is there a CandRecord?
00048   fCandRecord = dynamic_cast<const CandRecord*> 
00049     (mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00050   
00051   // Is there an Ntuple record?
00052   fNtpStRecord = dynamic_cast<const NtpStRecord*> 
00053     (mom->GetFragment("NtpStRecord","Primary"));
00054    
00055   // Find VldContext.
00056   std::vector<VldContext> contexts = DataUtil::GetVldContext(mom);
00057   if(contexts.size()==0) {
00058     MSG("TriD",Msg::kError) << "No data in MOM: Unable to find VldContext." << std::endl;
00059   } else {
00060     fContext = DataUtil::GetVldContext(mom)[0];
00061   }
00062 }


Member Data Documentation

Definition at line 32 of file TridModelMaker.h.

Referenced by Prepare().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1