DemuxFast Class Reference

#include <DemuxFast.h>

Inheritance diagram for DemuxFast:
JobCModule

List of all members.

Public Member Functions

 DemuxFast ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
JobCResult Reco (MomNavigator *mom)
void EndJob ()
void ResetMap (int ne, int nw)
void PrintMap (int ne, int nw)
void PrintWhatRemains ()
void MakeMap (int iplane, bool useTargets=false)
void MakeMap (DemuxSearchTactic)
void GroupHits (int ecount, int wcount)
void MakeSearchTactics ()
void MakeSearchTacticsX ()
void MakeSearchTacticsY ()
void DemuxSingles (DemuxSearchTactic)
bool SelectHits (bool makeGold, bool useGold=false)
void DemuxHits (int ie, int iw, int is)
void GoldHits (int ie, int iw, int is)
void MakeGoldGuide ()
void DemuxHitE (PlexSEIdAltL *pAlt, int is)
void DemuxHitW (PlexSEIdAltL *pAlt, int is)
void DemuxHitE (int ie, int is)
void DemuxHitW (int iw, int is)
bool DemuxBigGroup (int ig, bool gold)
void NewTactic (DemuxSearchTactic oldTactic)
float IsItXTalk (int iew, int iplane, int iva, int ipixel)

Private Member Functions

 ClassDef (DemuxFast, 0)

Private Attributes

MyDemuxPatternMasterpMaster
std::vector< PlexSEIdAltL * > PlanesAltListsE [500]
std::vector< PlexSEIdAltL * > PlanesAltListsW [500]
std::vector< DemuxSearchTacticsearchTactics
PlaneView::PlaneView_t kView
UgliGeomHandle_pUgh
float _cutRatioLow
float _cutRatioHigh
float _cutPEmin
float _cutFractionMin
float _cutSigmaQ
float _cutTrackTargetQ
bool _amap [100][100]
int _smap [100][100]
bool _bmap [100][100]
int _UVmap [500]
bool amWriting
bool amPSing
bool amHisting
bool _searched [500]
float pixelE [500][3][16]
float pixelW [500][3][16]
float _qTotE [500]
float _qTotW [500]
float _qMaxE [500]
float _qMaxW [500]
float _goldGuide [500]
float _sgoldGuide [500]
std::vector< int > targets
PlexSEIdAltL_pAmapE [100]
PlexSEIdAltL_pAmapW [100]
int _vaChip0 [18]
int _rangeWindow
bool efound [100]
bool wfound [100]
int ngroup
int ningroupe [100]
int ningroupw [100]
int egroup [100][100]
int wgroup [100][100]
int ecount
int wcount
int currentPlane
int planehit [500]
int hitmap [500][100]
float qhitmapE [500][100]
float qhitmapW [500][100]
int NdemuxedHitsU
int NdemuxedHitsV
int NdemuxedHits
std::vector< int > demuxedHitPlane
std::vector< int > demuxedHitStrip
std::vector< float > demuxedHitQ
int demuxedmap [500][100]
int goldplanehit [500]
int goldhitmap [500][100]

Detailed Description

Definition at line 48 of file DemuxFast.h.


Constructor & Destructor Documentation

DemuxFast::DemuxFast (  ) 

Definition at line 43 of file DemuxFast.cxx.

References _UVmap, _vaChip0, and pMaster.

00044     :  fCanvas(" ","DemuxFast",800,800)
00045 {
00046   pMaster = new MyDemuxPatternMaster();
00047  
00048   _vaChip0[0] = -1;
00049   _vaChip0[1] = -1;
00050   _vaChip0[2] = 14;
00051   _vaChip0[3] =  0;
00052   _vaChip0[4] = 15;
00053   _vaChip0[5] =  1;
00054   _vaChip0[6] = 10;
00055   _vaChip0[7] =  4;
00056   _vaChip0[8] = 11;
00057   _vaChip0[9] =  5;
00058   _vaChip0[10] =  6;
00059   _vaChip0[11] =  8;
00060   _vaChip0[12] =  7;
00061   _vaChip0[13] =  9;
00062   _vaChip0[14] =  2;
00063   _vaChip0[15] = 13;
00064   _vaChip0[16] =  3;
00065   _vaChip0[17] =  12;
00066 
00067   for(int i=0;i<500;i++){
00068     if(i<249)_UVmap[i] = (i%2)+1;
00069     if(i>249)_UVmap[i] = ((i+1)%2)+1;
00070     if(i==249)_UVmap[i] = 0;
00071   }
00072 
00073 
00074 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 458 of file DemuxFast.cxx.

References JobCResult::kAOK, Msg::kDebug, and MSG.

00459 {
00460   MSG("DmxFast",Msg::kDebug) <<  " *** DemuxFast::Ana *** " << endl;
00461   return JobCResult::kAOK;
00462 }

void DemuxFast::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 76 of file DemuxFast.cxx.

00077 {
00078 }

DemuxFast::ClassDef ( DemuxFast  ,
 
) [private]
bool DemuxFast::DemuxBigGroup ( int  ig,
bool  gold 
)

Definition at line 1380 of file DemuxFast.cxx.

References _amap, _smap, DemuxHits(), egroup, GoldHits(), Msg::kDebug, MSG, ningroupe, ningroupw, and wgroup.

Referenced by SelectHits().

01381 { 
01382   bool success = false;
01383   MSG("DmxFast",Msg::kDebug) << "BIG GROUP TRY A DIFFERENT APPROACH" << endl;
01384   int strips[192];
01385   int estrips[192];
01386   int wstrips[192];
01387   for(int i=0;i<192;i++)strips[i]=0;
01388   for(int ie=1;ie<=ningroupe[ig];ie++){
01389     for(int iw=1;iw<=ningroupw[ig];iw++){
01390       if(_amap[(egroup[ig][ie])][(wgroup[ig][iw])]){
01391         int s = _smap[(egroup[ig][ie])][(wgroup[ig][iw])];
01392         strips[s]++;
01393         estrips[s] = ie;
01394         wstrips[s] = iw;
01395       }
01396     }
01397   }
01398   int istartStrip=-1;
01399   int iendStrip=-1;
01400   int ngroups = 0;
01401   int ming = ningroupe[ig];
01402   if(ningroupw[ig]<ming)ming = ningroupw[ig];
01403   int icount;
01404   for(int is=0; is<192-ming; is++){
01405     if(strips[is]==1){
01406       icount = 1;
01407       int iend = is+ming+5;
01408       int ie;
01409       if(iend>191)iend=192;
01410       for(ie=is+1; ie<iend && icount != ming; ie++){
01411         if(strips[ie]>0)icount++;
01412       }
01413       if(icount==ming){
01414         ngroups++;
01415         istartStrip = is;
01416         iendStrip   = ie-1;
01417         MSG("DmxFast",Msg::kDebug) << "Found a group : " << is << ":" << ie-1 << endl;
01418       }
01419     }
01420   }
01421   MSG("DmxFast",Msg::kDebug) << "Found " << ngroups << " groups " << endl;
01422   if(ngroups==1){
01423     success = true;
01424     int ie;
01425     int iw;
01426     for(int is=istartStrip; is<=iendStrip;is++){
01427       if(strips[is]==1){
01428         ie = estrips[is];
01429         iw = wstrips[is];
01430         MSG("DmxFast",Msg::kDebug) << " Strip : " << is << " ew " << ie << ":" << iw << endl;
01431         if(gold)this->GoldHits(egroup[ig][ie],wgroup[ig][iw],is);
01432         if(!gold)this->DemuxHits(egroup[ig][ie],wgroup[ig][iw],is);
01433       }     
01434     }
01435   } 
01436   return success;
01437 }

void DemuxFast::DemuxHitE ( int  ie,
int  is 
)

Definition at line 1681 of file DemuxFast.cxx.

References _pAmapE, and DemuxHitE().

01681                                        { 
01682 
01683   PlexSEIdAltL* pAltL;
01684 
01685   pAltL = _pAmapE[ie]; 
01686   this->DemuxHitE(pAltL,is);
01687   return;
01688 }

void DemuxFast::DemuxHitE ( PlexSEIdAltL pAlt,
int  is 
)

Definition at line 1700 of file DemuxFast.cxx.

References currentPlane, PlexSEIdAltL::GetCurrentItem(), PlexSEIdAltL::GetCurrentSEId(), PlexSEIdAltLItem::GetPE(), PlexStripEndId::GetStrip(), PlexSEIdAltL::IsValid(), PlexSEIdAltL::Next(), PlanesAltListsE, PlexSEIdAltL::SetCurrentWeight(), and PlexSEIdAltL::SetFirst().

Referenced by DemuxHitE(), DemuxHits(), and DemuxSingles().

01700                                                     { 
01701 
01702   vector <PlexSEIdAltL*>::iterator literA;
01703   bool notFound;
01704   float q;
01705 
01706   pAltL->SetFirst();
01707 
01708 
01709   q = pAltL->GetCurrentItem().GetPE();
01710   notFound = true;
01711   while(notFound && pAltL->IsValid()){
01712     if(pAltL->GetCurrentSEId().GetStrip()==is){
01713       pAltL->SetCurrentWeight(1.);
01714       notFound = false;
01715     }
01716     if(notFound)pAltL->Next();
01717   }
01718 
01719   literA = PlanesAltListsE[currentPlane].begin();
01720   notFound = true;
01721   while (notFound && literA != PlanesAltListsE[currentPlane].end()){
01722     if(*literA==pAltL){
01723       PlanesAltListsE[currentPlane].erase(literA);
01724       notFound = false;
01725     }
01726     literA++;
01727   }
01728 
01729 
01730   return;
01731 }

void DemuxFast::DemuxHits ( int  ie,
int  iw,
int  is 
)

Definition at line 1621 of file DemuxFast.cxx.

References _pAmapE, _pAmapW, currentPlane, demuxedHitPlane, demuxedHitQ, demuxedHitStrip, DemuxHitE(), DemuxHitW(), PlexSEIdAltL::GetBestItem(), PlexSEIdAltLItem::GetPE(), hitmap, CalDigitType::kPE, NdemuxedHits, planehit, qhitmapE, and qhitmapW.

Referenced by DemuxBigGroup(), and SelectHits().

01621                                                { 
01622 
01623   float qE;
01624   float qW;
01625 
01626   this->DemuxHitE(ie,is);
01627   this->DemuxHitW(iw,is);
01628 
01629   qE= _pAmapE[ie]->GetBestItem().GetPE()*CalDigitType::kPE;
01630   qW= _pAmapW[iw]->GetBestItem().GetPE()*CalDigitType::kPE;
01631   
01632   demuxedHitPlane.push_back(currentPlane);
01633   demuxedHitStrip.push_back(is);
01634   demuxedHitQ.push_back(qE+qW);
01635   NdemuxedHits++;
01636   
01637   planehit[currentPlane] += 1;
01638   hitmap[currentPlane][planehit[currentPlane]] = is;
01639   qhitmapE[currentPlane][planehit[currentPlane]] = qE;
01640   qhitmapW[currentPlane][planehit[currentPlane]] = qW;
01641 
01642   return;
01643 
01644 }

void DemuxFast::DemuxHitW ( int  iw,
int  is 
)

Definition at line 1691 of file DemuxFast.cxx.

References _pAmapW, and DemuxHitW().

01691                                        { 
01692 
01693   PlexSEIdAltL* pAltL;
01694   pAltL = _pAmapW[iw]; 
01695   this->DemuxHitW(pAltL,is);  
01696 
01697   return;
01698 }

void DemuxFast::DemuxHitW ( PlexSEIdAltL pAlt,
int  is 
)

Definition at line 1733 of file DemuxFast.cxx.

References currentPlane, PlexSEIdAltL::GetCurrentItem(), PlexSEIdAltL::GetCurrentSEId(), PlexSEIdAltLItem::GetPE(), PlexStripEndId::GetStrip(), PlexSEIdAltL::IsValid(), PlexSEIdAltL::Next(), PlanesAltListsW, PlexSEIdAltL::SetCurrentWeight(), and PlexSEIdAltL::SetFirst().

Referenced by DemuxHits(), DemuxHitW(), and DemuxSingles().

01733                                                     { 
01734 
01735 
01736   vector <PlexSEIdAltL*>::iterator literA;
01737   bool notFound;
01738   float q;
01739 
01740 
01741   pAltL->SetFirst();
01742 
01743   notFound = true;
01744   q = pAltL->GetCurrentItem().GetPE();
01745   while(notFound && pAltL->IsValid()){
01746     if(pAltL->GetCurrentSEId().GetStrip()==is){
01747       pAltL->SetCurrentWeight(1.);
01748       notFound = false;
01749     }
01750     if(notFound)pAltL->Next();
01751   }
01752   
01753   literA = PlanesAltListsW[currentPlane].begin();
01754   notFound = true;
01755   while (notFound && literA != PlanesAltListsW[currentPlane].end()){
01756     if(*literA==pAltL){
01757       PlanesAltListsW[currentPlane].erase(literA);
01758       notFound = false;
01759     }
01760     literA++;
01761   }
01762   return;
01763 }

void DemuxFast::DemuxSingles ( DemuxSearchTactic  tactic  ) 

Definition at line 1095 of file DemuxFast.cxx.

References _cutTrackTargetQ, currentPlane, demuxedHitPlane, demuxedHitQ, demuxedHitStrip, DemuxHitE(), DemuxHitW(), DemuxSearchTactic::highplane, hitmap, DemuxSearchTactic::iplane, it, Msg::kDebug, CalDigitType::kPE, PlaneView::kU, PlaneView::kV, kView, DemuxSearchTactic::lowplane, MSG, NdemuxedHits, NdemuxedHitsU, NdemuxedHitsV, planehit, PlanesAltListsE, PlanesAltListsW, qhitmapE, qhitmapW, size, and targets.

Referenced by Reco().

01096 {
01097 
01098   vector <PlexSEIdAltL*>::iterator literE;
01099   vector <PlexSEIdAltL*>::iterator literW;
01100 
01101   int i = tactic.iplane;
01102   int j = tactic.lowplane;
01103   int k = tactic.highplane;
01104   int itarget;
01105   int it;
01106   int s;
01107   int sbest;
01108   int closeness;
01109   float q;
01110 
01111   targets.erase(targets.begin(),targets.end());
01112 
01113   MSG("DmxFast",Msg::kDebug) << "DemuxFast::DemuxSingles " << i << endl;
01114 
01115   if(planehit[i]>0){
01116     for(int ii=1;ii<=planehit[i];ii++){
01117       itarget = hitmap[i][ii];
01118       targets.push_back(itarget);
01119       MSG("DmxFast",Msg::kDebug) << " I target " << ii << " : " << hitmap[i][ii] << endl;
01120     }
01121   }
01122   if(j>0){
01123     for(int jj=1;jj<=planehit[j];jj++){
01124       itarget = hitmap[j][jj];
01125       targets.push_back(itarget);
01126       MSG("DmxFast",Msg::kDebug) << " J target " << jj << " : " << hitmap[j][jj] << endl;
01127     }
01128   }
01129   if(k>0){
01130     for(int kk=1;kk<=planehit[k];kk++){
01131       itarget = hitmap[k][kk];
01132       targets.push_back(itarget);
01133       MSG("DmxFast",Msg::kDebug) << " K target " << kk << " : " << hitmap[k][kk] << endl;
01134     }
01135   }
01136   if(j>0&&k>0){
01137     for(int jj=1;jj<=planehit[j];jj++){
01138       if(qhitmapE[j][jj]>_cutTrackTargetQ && qhitmapW[j][jj]>_cutTrackTargetQ){
01139         for(int kk=1;kk<=planehit[k];kk++){
01140           if(qhitmapE[k][kk]>_cutTrackTargetQ && qhitmapW[k][kk]>_cutTrackTargetQ){
01141             it =hitmap[j][jj] + (hitmap[k][kk]-hitmap[j][jj])*(i-j)/(k-j);
01142             if(j<249 && i>249)it =hitmap[j][jj] + (hitmap[k][kk]-hitmap[j][jj])*(i-j-15)/(k-j-15);
01143             if(i<249 && k>249)it =hitmap[j][jj] + (hitmap[k][kk]-hitmap[j][jj])*(i-j)/(k+15-j);
01144             MSG("DmxFast",Msg::kDebug) << "JK target " << jj<<kk << " : " << it << endl;
01145             targets.push_back(it);  
01146           }
01147         }
01148       }
01149     }
01150   }
01151 
01152   if(targets.size()<1)return;
01153 
01154   currentPlane = i;
01155 
01156   if(PlanesAltListsE[i].size()>0){
01157     literE = PlanesAltListsE[i].begin();
01158     kView = (*literE)->GetPlaneView();
01159     currentPlane = (*literE)->GetPlane();
01160     while (PlanesAltListsE[i].size()>0){
01161       sbest =0;
01162       closeness = 999;
01163       literE = PlanesAltListsE[i].begin();
01164       (*literE)->SetFirst();
01165       q = (*literE)->GetCurrentItem().GetPE()*CalDigitType::kPE;
01166       while( (*literE)->IsValid() ){
01167         s = (*literE)->GetCurrentSEId().GetStrip();
01168         bool found = false;
01169         for(unsigned int t=0;t<targets.size()&&found==false;t++){
01170           if(abs(targets[t]-s)<closeness){
01171             closeness = abs(targets[t]-s);
01172             sbest = s;                  
01173             if(closeness==0)found = true;
01174           }
01175         }
01176         (*literE)->Next();
01177       }
01178       MSG("DmxFast",Msg::kDebug) << "Closest Strip : " << closeness << " --> " << sbest << endl;
01179       
01180       demuxedHitPlane.push_back(currentPlane);
01181       demuxedHitStrip.push_back(sbest);
01182       demuxedHitQ.push_back(q);
01183       NdemuxedHits++;
01184       if(kView==PlaneView::kV) NdemuxedHitsV++;
01185       if(kView==PlaneView::kU) NdemuxedHitsU++;
01186 
01187       MSG("DmxFast",Msg::kDebug) << "Adding  U " << NdemuxedHitsU << " : " << currentPlane << " : " << sbest << endl;
01188 
01189       this->DemuxHitE(*literE, sbest);
01190     }
01191   }
01192 
01193 
01194 
01195   if(PlanesAltListsW[i].size()>0){
01196     literW = PlanesAltListsW[i].begin();
01197     kView = (*literW)->GetPlaneView();
01198     currentPlane = (*literW)->GetPlane();
01199     MSG("DmxFast",Msg::kDebug) << " current W Plane : " << currentPlane << endl;
01200     while (PlanesAltListsW[i].size()>0){
01201       literW = PlanesAltListsW[i].begin();
01202       sbest =0;
01203       closeness = 999;
01204       (*literW)->SetFirst();
01205       q = (*literW)->GetCurrentItem().GetPE();  
01206       while( (*literW)->IsValid() ){
01207         s = (*literW)->GetCurrentSEId().GetStrip();
01208         bool found = false;
01209         for(unsigned int t=0;t<targets.size()&&found==false;t++){
01210           if(abs(targets[t]-s)<closeness){
01211             closeness = abs(targets[t]-s);
01212             sbest = s;                  
01213             if(closeness==0)found = true;
01214           }
01215         }
01216         (*literW)->Next();
01217       }
01218       MSG("DmxFast",Msg::kDebug) << "Closest Strip : " << closeness << " --> " << sbest << endl;
01219       
01220       demuxedHitPlane.push_back(currentPlane);
01221       demuxedHitStrip.push_back(sbest);
01222       demuxedHitQ.push_back(q);
01223       NdemuxedHits++;
01224       if(kView==PlaneView::kV) NdemuxedHitsV++;
01225       if(kView==PlaneView::kU) NdemuxedHitsU++;
01226       
01227       this->DemuxHitW(*literW, sbest);
01228       literW++;    }
01229   }
01230 
01231   return;
01232 }

void DemuxFast::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 1766 of file DemuxFast.cxx.

References Msg::kDebug, and MSG.

01767 {
01768 
01769   TFile *hfile = new TFile("FastDeMuxHistos.root","recreate");
01770  
01771   MSG("DmxFast",Msg::kDebug) << " Writing Histograms to file : DeMuxHistos.root " << endl;
01772 
01773   hfile->Close();
01774   delete hfile;
01775 
01776 }

void DemuxFast::GoldHits ( int  ie,
int  iw,
int  is 
)

Definition at line 1646 of file DemuxFast.cxx.

References currentPlane, goldhitmap, and goldplanehit.

Referenced by DemuxBigGroup(), and SelectHits().

01649 { 
01650   goldplanehit[currentPlane] += 1;
01651   goldhitmap[currentPlane][goldplanehit[currentPlane]] = is;
01652   
01653   return;
01654 }

void DemuxFast::GroupHits ( int  ecount,
int  wcount 
)

Definition at line 868 of file DemuxFast.cxx.

References _amap, _bmap, efound, egroup, ngroup, ningroupe, ningroupw, wfound, and wgroup.

Referenced by Reco().

00868                                                {
00869 
00870   // MSG("DmxFast",Msg::kDebug) << "DemuxFast::GroupHits" << endl;
00871 
00872   for(int iw=0;iw<=wcount; iw++){
00873     for(int iwp=0;iwp<=wcount; iwp++){
00874       _bmap[iw][iwp] = false;
00875     }
00876   }
00877 
00878   for(int ie =0; ie<=ecount; ie++){
00879     for(int iw=0;iw<=wcount; iw++){
00880       if(_amap[ie][iw]){
00881         for(int iwp =0;iwp<=wcount; iwp++){
00882           if(_amap[ie][iwp]){
00883             _bmap[iw][iwp] = true;
00884             _bmap[iwp][iw] = true;
00885           }
00886         }
00887       }
00888     }
00889   }
00890 
00891   // MSG("DmxFast",Msg::kDebug) << "Associator : " << endl;
00892   for(int iw=0;iw<=wcount; iw++){
00893     _bmap[iw][iw] = true;
00894     for(int iwp=0;iwp<=wcount; iwp++){
00895       if(_bmap[iw][iwp]==false){
00896         for(int k=0;k<=wcount; k++)_bmap[iw][iwp] |= _bmap[iw][k] && _bmap[k][iwp];
00897       }
00898       // MSG("DmxFast",Msg::kDebug) << _bmap[iw][iwp];
00899     }
00900     // MSG("DmxFast",Msg::kDebug) << endl;
00901   }
00902 
00903 
00904   ngroup = 0;
00905   for(int iw=0;iw<=wcount; iw++){wfound[iw]=false;}
00906   for(int ie=0;ie<=ecount; ie++){efound[ie]=false;}
00907 
00908   for(int iw=0;iw<=wcount; iw++){
00909     if(wfound[iw]==false){
00910       ngroup++;
00911       ningroupw[ngroup]=0;
00912       for(int iwp=0;iwp<=wcount; iwp++){
00913         if(_bmap[iw][iwp]){
00914           ningroupw[ngroup]++;
00915           wgroup[ngroup][ningroupw[ngroup]]=iwp;
00916           wfound[iwp]=true;
00917         }
00918       }
00919     }
00920   }
00921       
00922   if(ngroup>0){
00923     for(int ig=1;ig<=ngroup;ig++){
00924       ningroupe[ig]=0;
00925       for(int iw=1;iw<=ningroupw[ig];iw++){
00926         for(int ie=0;ie<=ecount;ie++){
00927           if(efound[ie]==false && _amap[ie][(wgroup[ig][iw])]){
00928             ningroupe[ig]++;
00929             egroup[ig][ningroupe[ig]]=ie;
00930             efound[ie] = true;
00931           }
00932         }
00933       }
00934     }
00935   }
00936 
00937   return;
00938 }

float DemuxFast::IsItXTalk ( int  iew,
int  iplane,
int  iva,
int  ipixel 
)

Definition at line 1440 of file DemuxFast.cxx.

References pixelE, and pixelW.

Referenced by Reco().

01441 { 
01442 
01443   float crossTalk;
01444   if(iew==0){
01445     switch(ipixel){
01446     case 0:
01447       crossTalk = pixelE[iplane][iva][1] + 
01448                   pixelE[iplane][iva][4];
01449       break;
01450     case 1:
01451       crossTalk = pixelE[iplane][iva][0] + 
01452                   pixelE[iplane][iva][2] +
01453                   pixelE[iplane][iva][5];
01454       break;
01455     case 2:
01456       crossTalk = pixelE[iplane][iva][1] + 
01457                   pixelE[iplane][iva][3] +
01458                   pixelE[iplane][iva][6];
01459       break;
01460     case 3:
01461       crossTalk = pixelE[iplane][iva][2] + 
01462                   pixelE[iplane][iva][7];
01463       break;
01464     case 4:
01465       crossTalk = pixelE[iplane][iva][0] + 
01466                   pixelE[iplane][iva][5] +
01467                   pixelE[iplane][iva][8];
01468       break;
01469     case 5:
01470       crossTalk = pixelE[iplane][iva][1] + 
01471                   pixelE[iplane][iva][4] +
01472                   pixelE[iplane][iva][6] +
01473                   pixelE[iplane][iva][9];
01474       break;
01475     case 6:
01476       crossTalk = pixelE[iplane][iva][2] + 
01477                   pixelE[iplane][iva][5] +
01478                   pixelE[iplane][iva][7] +
01479                   pixelE[iplane][iva][10];
01480       break;
01481     case 7:
01482       crossTalk = pixelE[iplane][iva][3] + 
01483                   pixelE[iplane][iva][6] +
01484                   pixelE[iplane][iva][11];
01485       break;
01486     case 8:
01487       crossTalk = pixelE[iplane][iva][4] + 
01488                   pixelE[iplane][iva][9] +
01489                   pixelE[iplane][iva][12];
01490       break;
01491     case 9:
01492       crossTalk = pixelE[iplane][iva][5] + 
01493                   pixelE[iplane][iva][8] +
01494                   pixelE[iplane][iva][10] +
01495                   pixelE[iplane][iva][13];
01496       break;
01497     case 10:
01498       crossTalk = pixelE[iplane][iva][6] + 
01499                   pixelE[iplane][iva][9] +
01500                   pixelE[iplane][iva][11] +
01501                   pixelE[iplane][iva][14];
01502       break;
01503     case 11:
01504       crossTalk = pixelE[iplane][iva][7] + 
01505                   pixelE[iplane][iva][10] +
01506                   pixelE[iplane][iva][15];
01507       break;
01508     case 12:
01509       crossTalk = pixelE[iplane][iva][8] + 
01510                   pixelE[iplane][iva][13];
01511       break;
01512     case 13:
01513       crossTalk = pixelE[iplane][iva][9] + 
01514                   pixelE[iplane][iva][12]+
01515                   pixelE[iplane][iva][14];
01516       break;
01517     case 14:
01518       crossTalk = pixelE[iplane][iva][10] + 
01519                   pixelE[iplane][iva][13]+
01520                   pixelE[iplane][iva][15];
01521       break;
01522     case 15:
01523       crossTalk = pixelE[iplane][iva][11]+ 
01524                   pixelE[iplane][iva][14];
01525       break;
01526     default:
01527       crossTalk = 0;
01528       break;
01529     }
01530   }else{
01531     switch(ipixel){
01532     case 0:
01533       crossTalk = pixelW[iplane][iva][1] + 
01534                   pixelW[iplane][iva][4];
01535       break;
01536     case 1:
01537       crossTalk = pixelW[iplane][iva][0] + 
01538                   pixelW[iplane][iva][2] +
01539                   pixelW[iplane][iva][5];
01540       break;
01541     case 2:
01542       crossTalk = pixelW[iplane][iva][1] + 
01543                   pixelW[iplane][iva][3] +
01544                   pixelW[iplane][iva][6];
01545       break;
01546     case 3:
01547       crossTalk = pixelW[iplane][iva][2] + 
01548                   pixelW[iplane][iva][7];
01549       break;
01550     case 4:
01551       crossTalk = pixelW[iplane][iva][0] + 
01552                   pixelW[iplane][iva][5] +
01553                   pixelW[iplane][iva][8];
01554       break;
01555     case 5:
01556       crossTalk = pixelW[iplane][iva][1] + 
01557                   pixelW[iplane][iva][4] +
01558                   pixelW[iplane][iva][6] +
01559                   pixelW[iplane][iva][9];
01560       break;
01561     case 6:
01562       crossTalk = pixelW[iplane][iva][2] + 
01563                   pixelW[iplane][iva][5] +
01564                   pixelW[iplane][iva][7] +
01565                   pixelW[iplane][iva][10];
01566       break;
01567     case 7:
01568       crossTalk = pixelW[iplane][iva][3] + 
01569                   pixelW[iplane][iva][6] +
01570                   pixelW[iplane][iva][11];
01571       break;
01572     case 8:
01573       crossTalk = pixelW[iplane][iva][4] + 
01574                   pixelW[iplane][iva][9] +
01575                   pixelW[iplane][iva][12];
01576       break;
01577     case 9:
01578       crossTalk = pixelW[iplane][iva][5] + 
01579                   pixelW[iplane][iva][8] +
01580                   pixelW[iplane][iva][10] +
01581                   pixelW[iplane][iva][13];
01582       break;
01583     case 10:
01584       crossTalk = pixelW[iplane][iva][6] + 
01585                   pixelW[iplane][iva][9] +
01586                   pixelW[iplane][iva][11] +
01587                   pixelW[iplane][iva][14];
01588       break;
01589     case 11:
01590       crossTalk = pixelW[iplane][iva][7] + 
01591                   pixelW[iplane][iva][10] +
01592                   pixelW[iplane][iva][15];
01593       break;
01594     case 12:
01595       crossTalk = pixelW[iplane][iva][8] + 
01596                   pixelW[iplane][iva][13];
01597       break;
01598     case 13:
01599       crossTalk = pixelW[iplane][iva][9] + 
01600                   pixelW[iplane][iva][12]+
01601                   pixelW[iplane][iva][14];
01602       break;
01603     case 14:
01604       crossTalk = pixelW[iplane][iva][10] + 
01605                   pixelW[iplane][iva][13]+
01606                   pixelW[iplane][iva][15];
01607       break;
01608     case 15:
01609       crossTalk = pixelW[iplane][iva][11]+ 
01610                   pixelW[iplane][iva][14];
01611       break;
01612     default:
01613       crossTalk = 0.0;
01614       break;
01615     }
01616   }
01617   
01618   return crossTalk;
01619 } 

void DemuxFast::MakeGoldGuide (  ) 

Definition at line 1657 of file DemuxFast.cxx.

References _goldGuide, goldhitmap, goldplanehit, Msg::kDebug, MSG, and n.

Referenced by Reco().

01657                              { 
01658 
01659   for(int ip=1;ip<500;ip++){
01660     if(goldplanehit[ip-1]>0||goldplanehit[ip+1]>0){
01661       float n =0;
01662       float tot = 0;
01663       for(int i=1;i<=goldplanehit[ip-1];i++){
01664         n+=1;
01665         tot += goldhitmap[ip-1][i];
01666       }
01667       for(int i=1;i<=goldplanehit[ip+1];i++){
01668         n+=1;
01669         tot += goldhitmap[ip+1][i];
01670       }
01671       _goldGuide[ip] = tot/n;
01672       MSG("DmxFast",Msg::kDebug) << "Gold Guide " << ip << " : " <<  _goldGuide[ip] << endl;
01673     }
01674   }
01675  
01676   return;
01677 
01678 }

void DemuxFast::MakeMap ( DemuxSearchTactic  tactic  ) 

Definition at line 1042 of file DemuxFast.cxx.

References _cutTrackTargetQ, DemuxSearchTactic::highplane, hitmap, DemuxSearchTactic::iplane, it, Msg::kDebug, DemuxSearchTactic::lowplane, MakeMap(), MSG, planehit, qhitmapE, qhitmapW, and targets.

01043 {
01044 
01045   int i = tactic.iplane;
01046   int j = tactic.lowplane;
01047   int k = tactic.highplane;
01048   int itarget;
01049   int it;
01050 
01051   targets.erase(targets.begin(),targets.end());
01052 
01053   if(planehit[i]>0){
01054     for(int ii=1;ii<=planehit[i];ii++){
01055       itarget = hitmap[i][ii];
01056       targets.push_back(itarget);
01057       MSG("DmxFast",Msg::kDebug) << " I target " << ii << " : " << hitmap[i][ii] << endl;
01058     }
01059   }
01060   if(j>0){
01061     for(int jj=1;jj<=planehit[j];jj++){
01062       
01063       itarget = hitmap[j][jj];
01064       targets.push_back(itarget);
01065       MSG("DmxFast",Msg::kDebug) << " J target " << jj << " : " << hitmap[j][jj] << endl;
01066     }
01067   }
01068   if(k>0){
01069     for(int kk=1;kk<=planehit[k];kk++){
01070       itarget = hitmap[k][kk];
01071       targets.push_back(itarget);
01072       MSG("DmxFast",Msg::kDebug) << " K target " << kk << " : " << hitmap[k][kk] << endl;
01073     }
01074   }
01075 
01076   if(j>0&&k>0){
01077     for(int jj=1;jj<=planehit[j];jj++){
01078       if(qhitmapE[j][jj]>_cutTrackTargetQ && qhitmapW[j][jj]>_cutTrackTargetQ){
01079         for(int kk=1;kk<=planehit[k];kk++){
01080           if(qhitmapE[k][kk]>_cutTrackTargetQ && qhitmapW[k][kk]>_cutTrackTargetQ){
01081             it =hitmap[j][jj] + (hitmap[k][kk]-hitmap[j][jj])*(i-j)/(k-j);
01082             MSG("DmxFast",Msg::kDebug) << "JK target " << jj<<kk << " : " << it << endl;
01083             targets.push_back(it);  
01084           }
01085         }
01086       }
01087     }
01088   }
01089 
01090   this->MakeMap(i,true);
01091 
01092   return;
01093 }

void DemuxFast::MakeMap ( int  iplane,
bool  useTargets = false 
)

Definition at line 940 of file DemuxFast.cxx.

References _amap, _cutFractionMin, _cutPEmin, _cutRatioHigh, _cutRatioLow, _cutSigmaQ, _goldGuide, _pAmapE, _pAmapW, _qMaxE, _qMaxW, _qTotE, _qTotW, _smap, currentPlane, ecount, Msg::kDebug, CalDigitType::kPE, PlaneView::kU, PlaneView::kV, kView, MSG, PlanesAltListsE, PlanesAltListsW, PlexSEIdAltL::SetFirst(), targets, and wcount.

Referenced by MakeMap(), and Reco().

00941 {
00942 
00943   vector <PlexSEIdAltL*>::iterator literE;
00944   vector <PlexSEIdAltL*>::iterator literW;
00945   float ratioQ;
00946   float ratioEW=0;
00947   float qE;
00948   float qW;
00949   float sigma;
00950   float r=0;
00951   float av;
00952   float ed;
00953   float ratio;
00954   int s;
00955  
00956   //MSG("DmxFast",Msg::kDebug) << "DemuxFast::MakeMap " << i << endl;
00957   if(_qTotW[i]>0)ratioEW =  _qTotE[i]/_qTotW[i];
00958 
00959   literE = PlanesAltListsE[i].begin();
00960   ecount = -1;
00961   kView = (*literE)->GetPlaneView();
00962   currentPlane = (*literE)->GetPlane();
00963   MSG("DmxFast",Msg::kDebug) << " current Plane : " << currentPlane << endl;
00964   while (literE != PlanesAltListsE[i].end()){
00965     ecount++;
00966     _pAmapE[ecount] = (*literE);
00967     literW = PlanesAltListsW[i].begin();
00968     wcount = -1;
00969     while ( literW != PlanesAltListsW[i].end()){
00970       wcount++;
00971       _pAmapW[wcount] = (*literW);
00972       //MSG("DmxFast",Msg::kDebug) << " Counts : " << ecount << " : " << wcount << endl; 
00973       (*literE)->SetFirst();
00974       while( (*literE)->IsValid() ){
00975         //      ushE = _pUgh->GetStripHandle((*literE)->GetCurrentSEId());
00976         qE = (*literE)->GetCurrentItem().GetPE()*CalDigitType::kPE;
00977         (*literW)->SetFirst();
00978         while( (*literW)->IsValid() ){
00979           qW = (*literW)->GetCurrentItem().GetPE()*CalDigitType::kPE;
00980           // In here we can check for a possibility
00981           if((*literE)->GetCurrentSEId().GetStrip()==(*literW)->GetCurrentSEId().GetStrip()){
00982             s = (*literE)->GetCurrentSEId().GetStrip();
00983             ratioQ =  qE/qW;
00984             // Define requirements for a good combination...
00985             bool goodComb = true;
00986 
00987             if(ratioQ<(ratioEW*_cutRatioLow))goodComb=false;
00988             if(ratioQ>(ratioEW*_cutRatioHigh))goodComb=false;
00989             if((*literE)->GetCurrentItem().GetPE()*CalDigitType::kPE < _cutPEmin)goodComb = false;
00990             if((*literW)->GetCurrentItem().GetPE()*CalDigitType::kPE < _cutPEmin)goodComb = false;
00991             if((*literE)->GetCurrentItem().GetPE()<_cutFractionMin*_qMaxE[i])goodComb=false;
00992             if((*literW)->GetCurrentItem().GetPE()<_cutFractionMin*_qMaxW[i])goodComb=false;
00993             
00994             av = _goldGuide[currentPlane];
00995             ed = 0.;
00996             if(av>0){
00997               ratio = (qE-qW)/(qE+qW);
00998               sigma = 4.0*sqrt( qE*qW*(qE+qW) )/(qE+qW)/(qE+qW);
00999               if(kView==PlaneView::kU)r = -0.55+1.1*(av/192.);
01000               if(kView==PlaneView::kV)r =  0.55-1.1*(av/192.);
01001               ed = (ratio-r)/sigma;
01002             }
01003 
01004             //float dt = (tW -tE)*1E9-(clearW-clearE)*6.0-(wlsW-wlsE)*4.6;
01005 
01006             MSG("DmxFast",Msg::kDebug) << "Poss : " << qE << " : " << qW << " : " << ed << " : " << (*literE)->GetCurrentSEId().GetStrip();
01007             if(goodComb){
01008               MSG("DmxFast",Msg::kDebug) << " *";
01009             }
01010             if( fabs(ed)-0.001 >= _cutSigmaQ )goodComb = false;
01011 
01012             if(goodComb&&useTargets){
01013               bool found = false;
01014               for(unsigned int t=0;t<targets.size()&&found==false;t++){
01015                 if(abs(targets[t]-s)<12){
01016                   found = true;
01017                 }
01018               } 
01019               goodComb = found;
01020             }
01021 
01022             if(goodComb){
01023               _amap[ecount][wcount] = true;
01024               MSG("DmxFast",Msg::kDebug) << "*";
01025             }
01026 
01027             MSG("DmxFast",Msg::kDebug) << endl;
01028 
01029             _smap[ecount][wcount] = s;
01030           }
01031           (*literW)->Next();
01032         }
01033         (*literE)->Next();
01034       }
01035       literW++;
01036     }
01037     literE++;
01038   }
01039   return;
01040 }

void DemuxFast::MakeSearchTactics (  ) 

Definition at line 641 of file DemuxFast.cxx.

References _searched, _UVmap, DemuxSearchTactic::goodTactic, DemuxSearchTactic::highplane, DemuxSearchTactic::iplane, Msg::kDebug, DemuxSearchTactic::lowplane, MSG, planehit, PlanesAltListsE, PlanesAltListsW, SEARCH_BACKWARDS, SEARCH_FORWARDS, SEARCH_GAP_B, SEARCH_GAP_F, searchTactics, DemuxSearchTactic::searchType, and size.

Referenced by Reco().

00642 {
00643 
00644   bool ifirstU=false;
00645   bool ifirstV=false;
00646   int firstUplane=0;
00647   int firstVplane=0;
00648   int lastUplane=0;
00649   int lastVplane=0;
00650   int foundPlane=0;
00651 
00652 
00653   searchTactics.erase(searchTactics.begin(),searchTactics.end());
00654 
00655   for(int i=0; i<500; i++){
00656     _searched[i] = false;
00657     if(planehit[i]>0){
00658       MSG("DmxFast",Msg::kDebug) << "Found a hit plane " << i << endl;
00659       if(ifirstU==false){
00660         if( _UVmap[i]==1){
00661           ifirstU = true;
00662           firstUplane = i;
00663         }
00664       }
00665       if(ifirstV==false){
00666         if( _UVmap[i]==2){
00667           ifirstV = true;
00668           firstVplane = i;
00669         }
00670       }
00671       if(_UVmap[i]==1)lastUplane =i;
00672       if(_UVmap[i]==2)lastVplane =i;
00673 
00674       int inext = i+2;
00675       if(inext==249)inext=250;
00676       if(inext==250)inext=251;
00677       if(planehit[inext]==0){
00678         MSG("DmxFast",Msg::kDebug) << "Found an empty plane " << inext << endl;
00679         int j = inext+2;
00680         bool found = false;
00681         while(found==false&&j-inext <=24){
00682           j++;
00683           if(_UVmap[j]==_UVmap[i]&&planehit[j]>0)found=true;
00684         }
00685         if(found){
00686           MSG("DmxFast",Msg::kDebug) << "Looking in GAP " << i << ":" << j << endl;
00687           bool lfound = false;
00688           // Step forward in gap
00689           for(int k=i+2; k<=j-2; k++){
00690             if(_UVmap[k]==_UVmap[i]){
00691               if(!lfound && PlanesAltListsE[k].size()&&PlanesAltListsW[k].size()){
00692                 lfound = true;
00693                 DemuxSearchTactic tactic;
00694                 foundPlane = k;
00695                 tactic.iplane = k;
00696                 tactic.searchType = SEARCH_GAP_F;
00697                 tactic.lowplane  = i;
00698                 tactic.highplane = j;
00699                 tactic.goodTactic = true;
00700                 searchTactics.push_back(tactic);
00701                 _searched[k] = true;
00702                 MSG("DmxFast",Msg::kDebug) << "Inserting F GAP search tactic : " << k<<"("<<i<<"," << j << ")" << endl; 
00703               }
00704             }
00705           }
00706           // Step backwards in gap
00707           if(lfound){
00708             MSG("DmxFast",Msg::kDebug) << " Loop : " << j-2 << ":" << foundPlane+2 << endl;
00709             bool found = false;
00710             for(int k=j-2; k>=foundPlane+2; k--){
00711               if(_UVmap[k]==_UVmap[i]){
00712                 if(!found &&PlanesAltListsE[k].size()&&PlanesAltListsW[k].size()){
00713                   found = true;
00714                   DemuxSearchTactic tactic;
00715                   tactic.iplane = k;
00716                   tactic.searchType = SEARCH_GAP_B;
00717                   tactic.lowplane  = i;
00718                   tactic.highplane = j;
00719                   tactic.goodTactic = true;
00720                   searchTactics.push_back(tactic);
00721                   _searched[k] = true;
00722                   MSG("DmxFast",Msg::kDebug) << "Inserting B GAP search tactic : " << k<<"("<<i<<"," << j << ")" << endl; 
00723                 }
00724               }
00725             }
00726           } 
00727         }       
00728       }
00729     }
00730   }
00731   if(ifirstU){
00732     DemuxSearchTactic tactic;
00733     tactic.iplane = firstUplane;
00734     tactic.lowplane = firstUplane;
00735     tactic.highplane = firstUplane;
00736     tactic.searchType = SEARCH_BACKWARDS;
00737     tactic.goodTactic = false;
00738     searchTactics.push_back(tactic);
00739 
00740 
00741     tactic.iplane = lastUplane;
00742     tactic.lowplane = lastUplane;
00743     tactic.highplane = lastUplane;
00744     tactic.searchType = SEARCH_FORWARDS;
00745     tactic.goodTactic = false;
00746     searchTactics.push_back(tactic);
00747   }
00748 
00749   if(ifirstV){
00750     DemuxSearchTactic tactic;
00751     tactic.iplane = firstVplane;
00752     tactic.lowplane = firstVplane;
00753     tactic.highplane = firstVplane;
00754     tactic.searchType = SEARCH_BACKWARDS;
00755     tactic.goodTactic = false;
00756     searchTactics.push_back(tactic);
00757 
00758     tactic.iplane = lastVplane;
00759     tactic.lowplane = lastVplane;
00760     tactic.highplane = lastVplane;
00761     tactic.searchType = SEARCH_FORWARDS;
00762     tactic.goodTactic = false;
00763     searchTactics.push_back(tactic);
00764   }
00765     
00766   return;
00767 }

void DemuxFast::MakeSearchTacticsX (  ) 

Definition at line 770 of file DemuxFast.cxx.

References DemuxSearchTactic::goodTactic, DemuxSearchTactic::highplane, DemuxSearchTactic::iplane, DemuxSearchTactic::lowplane, planehit, PlanesAltListsE, PlanesAltListsW, SEARCH_GAP, searchTactics, DemuxSearchTactic::searchType, and size.

Referenced by Reco().

00771 {
00772 
00773   searchTactics.erase(searchTactics.begin(),searchTactics.end());
00774   bool found;
00775 
00776   for(int i=0; i<500; i++){
00777     if(planehit[i]>0){
00778       if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00779         int j = -100;
00780         int k = -100;
00781         int jj = i-2;
00782         if(jj==248 || jj==249)jj--;
00783         int kk = i+2;
00784         if(kk==249 || kk==250)kk++;
00785         found = false;
00786         while(found==false){
00787           if(planehit[jj]){
00788             j=jj;
00789             found = true;
00790           }
00791           jj-=2;
00792           if(jj==248 || jj==249)jj--;
00793           if(jj<0||jj<i-12)found =true;
00794         }
00795         found = false;
00796         while(found==false){
00797           if(planehit[kk]){
00798             k=kk;
00799             found = true;
00800           }
00801           kk+=2;
00802           if(kk==249 || kk==250)kk++;
00803           if(kk>499||kk>i+12)found =true;
00804         }
00805         DemuxSearchTactic tactic;
00806         tactic.iplane = i;
00807         tactic.searchType = SEARCH_GAP;
00808         tactic.lowplane  = j;
00809         tactic.highplane = k;
00810         tactic.goodTactic = true;
00811         searchTactics.push_back(tactic);
00812         // MSG("DmxFast",Msg::kDebug) << "Inserting a search tactic : " << k<<"("<<i<<"," << j << ")" << endl; 
00813       }
00814     }
00815   }    
00816   return;
00817 }

void DemuxFast::MakeSearchTacticsY (  ) 

Definition at line 820 of file DemuxFast.cxx.

References DemuxSearchTactic::goodTactic, DemuxSearchTactic::highplane, DemuxSearchTactic::iplane, DemuxSearchTactic::lowplane, planehit, PlanesAltListsE, PlanesAltListsW, SEARCH_SINGLES, searchTactics, DemuxSearchTactic::searchType, and size.

Referenced by Reco().

00821 {
00822 
00823   searchTactics.erase(searchTactics.begin(),searchTactics.end());
00824   bool found;
00825 
00826   for(int i=0; i<500; i++){
00827     if(PlanesAltListsE[i].size()||PlanesAltListsW[i].size()){
00828       int j = -100;
00829       int k = -100;
00830       int jj = i-2;
00831       if(jj==248 || jj==249)jj--;
00832       int kk = i+2;
00833       if(kk==249 || kk==250)kk++;
00834       found = false;
00835       while(found==false){
00836         if(planehit[jj]){
00837           j=jj;
00838           found = true;
00839         }
00840         jj-=2;
00841         if(jj==248 || jj==249)jj--;
00842         if(jj<0||jj<i-12)found =true;
00843       }
00844       found = false;
00845       while(found==false){
00846         if(planehit[kk]){
00847           k=kk;
00848           found = true;
00849         }
00850         kk+=2;
00851         if(kk==249 || kk==250)kk++;
00852         if(kk>499||kk>i+12)found =true;
00853       }
00854       DemuxSearchTactic tactic;
00855       tactic.iplane = i;
00856       tactic.searchType = SEARCH_SINGLES;
00857       tactic.lowplane  = j;
00858       tactic.highplane = k;
00859       tactic.goodTactic = true;
00860       searchTactics.push_back(tactic);
00861       // MSG("DmxFast",Msg::kDebug) << "Inserting a search tactic : " << k<<"("<<i<<"," << j << ")" << endl; 
00862     }
00863   }    
00864   return;
00865 }

void DemuxFast::NewTactic ( DemuxSearchTactic  oldTactic  ) 

Definition at line 493 of file DemuxFast.cxx.

References _searched, DemuxSearchTactic::goodTactic, DemuxSearchTactic::highplane, DemuxSearchTactic::iplane, Msg::kDebug, DemuxSearchTactic::lowplane, MSG, planehit, PlanesAltListsE, PlanesAltListsW, SEARCH_BACKWARDS, SEARCH_FORWARDS, SEARCH_GAP, SEARCH_GAP_B, SEARCH_GAP_F, searchTactics, DemuxSearchTactic::searchType, and size.

Referenced by Reco().

00493                                                     {
00494   
00495   MSG("DmxFast",Msg::kDebug) << "DemuxFast::NewTactic" <<endl;
00496 
00497   bool foundh;
00498   bool foundl;
00499   bool found;
00500   DemuxSearchTactic newTactic;
00501 
00502   switch(oldTactic.searchType){
00503   case SEARCH_GAP:
00504 
00505     break;
00506   case SEARCH_GAP_B:
00507     MSG("DmxFast",Msg::kDebug) << " SEARCH_GAP_B : do something" << endl;
00508     found = false;
00509     MSG("DmxFast",Msg::kDebug) << " Old : " << oldTactic.lowplane << ":"
00510            << oldTactic.iplane << ":" << oldTactic.highplane << endl;
00511     for(int i=oldTactic.highplane-2;i>=oldTactic.iplane+2&&found==false;i-=2){
00512       if(!_searched[i]&&PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00513         MSG("DmxFast",Msg::kDebug) << "Make New Tactic for Plane " << i << endl;
00514         found = true;
00515         newTactic.iplane = i;
00516         newTactic.goodTactic = true;
00517         newTactic.lowplane = oldTactic.lowplane;
00518         newTactic.highplane = oldTactic.iplane;
00519         newTactic.searchType = SEARCH_GAP_F;
00520       }
00521     }
00522     if(found){
00523       MSG("DmxFast",Msg::kDebug) <<"Inserting new tactic : " << newTactic.lowplane << ":"
00524            << newTactic.iplane << ":" << newTactic.highplane << endl;
00525       searchTactics.push_back(newTactic);
00526       _searched[newTactic.iplane] = true;
00527     }
00528     break;
00529   case SEARCH_GAP_F:
00530     MSG("DmxFast",Msg::kDebug) << " SEARCH_GAP_F : do something" << endl;
00531     found = false;
00532     for(int i=oldTactic.iplane+2;i<=oldTactic.highplane-2&&found==false;i+=2){
00533       if(!_searched[i]&&PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00534         MSG("DmxFast",Msg::kDebug) << "Make New Tactic for Plane " << i << endl;
00535         found = true;
00536         newTactic.iplane = i;
00537         newTactic.goodTactic = true;
00538         newTactic.lowplane = oldTactic.iplane;
00539         newTactic.highplane = oldTactic.highplane;
00540         newTactic.searchType = SEARCH_GAP_F;
00541       }
00542     }
00543     if(found){
00544       MSG("DmxFast",Msg::kDebug) <<"Inserting new tactic : " << newTactic.lowplane<<":"    << newTactic.iplane << ":" << newTactic.highplane << endl;
00545       searchTactics.push_back(newTactic);
00546       _searched[newTactic.iplane] = true;
00547     }
00548     break;
00549   case SEARCH_FORWARDS:
00550     foundh = false;
00551     foundl = false;
00552     if(oldTactic.goodTactic){
00553       MSG("DmxFast",Msg::kDebug) << "Continuing forwards search " << endl;
00554       for(int i=oldTactic.iplane+2;i<500&&foundh==false;i+=2){
00555         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00556           MSG("DmxFast",Msg::kDebug) << "Make Tactic for Plane " << i << endl;
00557           foundh = true;
00558           newTactic.iplane = i;
00559           newTactic.goodTactic = true;
00560           newTactic.highplane = oldTactic.iplane;
00561           newTactic.lowplane = oldTactic.highplane;
00562           newTactic.searchType = SEARCH_FORWARDS;
00563         }
00564       }
00565     }else{
00566       MSG("DmxFast",Msg::kDebug) << "Starting forwards search " << endl;
00567       for(int i=oldTactic.iplane+2;i<500&&foundh==false;i+=2){
00568         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00569           MSG("DmxFast",Msg::kDebug) << "Make Tactic for Plane " << i << endl;
00570           foundh = true;
00571           newTactic.highplane = oldTactic.iplane;
00572           newTactic.iplane = i; 
00573           newTactic.goodTactic = true;
00574           newTactic.lowplane = -100;
00575           newTactic.searchType = SEARCH_FORWARDS;
00576         }
00577       }
00578       for(int i=oldTactic.iplane-2;i>oldTactic.iplane-12&&foundl==false;i-=2){
00579         if(planehit[i]>0){
00580           foundl = true;
00581           newTactic.lowplane = i;
00582         }
00583       }
00584     }
00585     if(foundh){
00586       MSG("DmxFast",Msg::kDebug) <<"Inserting new tactic : " << newTactic.lowplane << ":"
00587            << newTactic.iplane << ":" << newTactic.highplane << endl;
00588       searchTactics.push_back(newTactic);
00589     }
00590     break;
00591   case SEARCH_BACKWARDS:
00592     foundh = false;
00593     foundl = false;
00594     if(oldTactic.goodTactic){
00595       MSG("DmxFast",Msg::kDebug) << "Continuing backwards search " << endl;
00596       for(int i=oldTactic.iplane-2;i>0&&foundl==false;i-=2){
00597         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00598           MSG("DmxFast",Msg::kDebug) << "Make Tactic for Plane " << i << endl;
00599           foundl = true;
00600           newTactic.iplane = i;
00601           newTactic.lowplane = oldTactic.iplane;
00602           newTactic.goodTactic = true;
00603           newTactic.highplane = oldTactic.lowplane;
00604           newTactic.searchType = SEARCH_BACKWARDS;
00605         }
00606       }
00607     }else{
00608       MSG("DmxFast",Msg::kDebug) << "Starting backwards search " << endl;
00609       for(int i=oldTactic.iplane-2;i>0&&foundl==false;i-=2){
00610         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00611           MSG("DmxFast",Msg::kDebug) << "Make Tactic for Plane " << i << endl;
00612           foundl = true;
00613           newTactic.lowplane = oldTactic.iplane;
00614           newTactic.iplane = i; 
00615           newTactic.goodTactic = true;
00616           newTactic.highplane = -100;
00617           newTactic.searchType = SEARCH_BACKWARDS;
00618         }
00619       }
00620       for(int i=oldTactic.iplane+2;i<oldTactic.iplane+12&&foundh==false;i+=2){
00621         if(planehit[i]>0){
00622           foundh = true;
00623           newTactic.highplane = i;
00624         }
00625       }
00626     }
00627     if(foundl){
00628       MSG("DmxFast",Msg::kDebug) <<"Inserting new tactic : " << newTactic.lowplane << ":"
00629            << newTactic.iplane << ":" << newTactic.highplane << endl;
00630       searchTactics.push_back(newTactic);
00631     }
00632     break;
00633   default:
00634     break;
00635   }
00636   
00637   return;
00638 } 

void DemuxFast::PrintMap ( int  ne,
int  nw 
)

Definition at line 464 of file DemuxFast.cxx.

References _amap, Msg::kDebug, and MSG.

00464                                       {
00465   
00466 
00467   MSG("DmxFast",Msg::kDebug) << "Print Map " << ne << " : " << nw << endl;
00468   for(int ie=0;ie<=ne;ie++){
00469     for(int iw=0;iw<=nw;iw++){
00470       MSG("DmxFast",Msg::kDebug) << _amap[ie][iw];
00471     }
00472     MSG("DmxFast",Msg::kDebug) << endl;
00473   }
00474 
00475   return;
00476 } 

void DemuxFast::PrintWhatRemains (  ) 

Definition at line 1237 of file DemuxFast.cxx.

References Msg::kDebug, CalDigitType::kPE, MSG, PlanesAltListsE, PlanesAltListsW, and size.

01238 {
01239   vector <PlexSEIdAltL*>::iterator literE;
01240   vector <PlexSEIdAltL*>::iterator literW;
01241 
01242   for(int i=0; i<500; i++){
01243     if(PlanesAltListsE[i].size()||PlanesAltListsW[i].size()){
01244       //MSG("DmxFast",Msg::kDebug) << " PLANE : " << i << "has " << planehit[i] <<  " Demuxed Hits, Left With   E : " << PlanesAltListsE[i].size() << ", W : " << PlanesAltListsW[i].size() << endl;
01245     }
01246 
01247     if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
01248       literE = PlanesAltListsE[i].begin();
01249       while (literE != PlanesAltListsE[i].end()){
01250         literW = PlanesAltListsW[i].begin();
01251         while ( literW != PlanesAltListsW[i].end()){
01252           (*literE)->SetFirst();
01253           while( (*literE)->IsValid() ){
01254             (*literW)->SetFirst();
01255             while( (*literW)->IsValid() ){
01256               if((*literE)->GetCurrentSEId().GetStrip()==(*literW)->GetCurrentSEId().GetStrip()){
01257                 MSG("DmxFast",Msg::kDebug) << " We have a possibilility " << i << " : " << (*literE)->GetCurrentItem().GetPE()*CalDigitType::kPE << " : " << (*literW)->GetCurrentItem().GetPE()*CalDigitType::kPE << " : " << (*literE)->GetCurrentSEId().GetStrip() << endl;
01258               }
01259               (*literW)->Next();
01260             }
01261             (*literE)->Next();
01262           }
01263           literW++;
01264         }
01265         literE++;
01266       }
01267     }
01268     if(PlanesAltListsE[i].size()){
01269       literE = PlanesAltListsE[i].begin();
01270       while (literE != PlanesAltListsE[i].end()){
01271         (*literE)->SetFirst();
01272         while( (*literE)->IsValid() ){
01273           MSG("DmxFast",Msg::kDebug) << " Single possibilility : " << i << " : " << (*literE)->GetCurrentItem().GetPE()*CalDigitType::kPE << " : " << (*literE)->GetCurrentSEId().GetStrip() << endl;
01274           (*literE)->Next();
01275         }
01276         literE++;
01277       }
01278     }
01279     if(PlanesAltListsW[i].size()){
01280       literW = PlanesAltListsW[i].begin();
01281       while (literW != PlanesAltListsW[i].end()){
01282         (*literW)->SetFirst();
01283         while( (*literW)->IsValid() ){
01284           MSG("DmxFast",Msg::kDebug) << " Single possibilility : " << i << " : " << (*literW)->GetCurrentItem().GetPE()*CalDigitType::kPE << " : " << (*literW)->GetCurrentSEId().GetStrip() << endl;
01285           (*literW)->Next();
01286         }
01287         literW++;
01288       }
01289     }
01290   }
01291   
01292   return;
01293 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 80 of file DemuxFast.cxx.

References _cutFractionMin, _cutPEmin, _cutRatioHigh, _cutRatioLow, _cutSigmaQ, _cutTrackTargetQ, _goldGuide, _qMaxE, _qMaxW, _qTotE, _qTotW, _rangeWindow, _UVmap, _vaChip0, MomNavigator::At(), demuxedHitPlane, demuxedHitStrip, DemuxSingles(), ecount, OscFit::GetCharge(), PlexSEIdAltL::GetCurrentItem(), CandHandle::GetDaughterIterator(), PlexSEIdAltL::GetEnd(), MomNavigator::GetFragment(), PlexSEIdAltLItem::GetPE(), PlexSEIdAltL::GetPlane(), RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawDaqSnarlHeader::GetSnarl(), goldplanehit, GroupHits(), IsItXTalk(), PlexSEIdAltL::IsVetoShield(), JobCResult::kAOK, Msg::kDebug, StripEnd::kEast, JobCResult::kError, JobCResult::kFailed, Msg::kInfo, Msg::kWarning, MakeGoldGuide(), MakeMap(), MakeSearchTactics(), MakeSearchTacticsX(), MakeSearchTacticsY(), MSG, NdemuxedHits, NdemuxedHitsU, NdemuxedHitsV, NewTactic(), pixelE, pixelW, planehit, PlanesAltListsE, PlanesAltListsW, ResetMap(), run(), searchTactics, SelectHits(), PlexSEIdAltL::SetFirst(), size, and wcount.

00081 {
00082   int ndigits=0;
00083 
00084   for(int i=0; i<500;i++){
00085     PlanesAltListsE[i].erase(PlanesAltListsE[i].begin(),PlanesAltListsE[i].end());
00086     PlanesAltListsW[i].erase(PlanesAltListsW[i].begin(),PlanesAltListsW[i].end());
00087     planehit[i] = 0;
00088     goldplanehit[i] = 0;
00089     _goldGuide[i] = 0;
00090     _qTotE[i] = 0;
00091     _qTotW[i] = 0;
00092     _qMaxE[i] = 0;
00093     _qMaxW[i] = 0;
00094   }
00095 
00096 
00097   PlexSEIdAltL altlist;
00098   PlexSEIdAltL* paltlist;
00099 
00100 // Find PrimaryCandidateRecord fragment in MOM.
00101     CandRecord* candrecord = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00102 
00103   if (candrecord == 0) {
00104     MSG("DemuxFast", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00105                                                                 << endl;
00106     return JobCResult::kError;
00107   }
00108 
00109   int run;
00110   int snarl;
00111 
00112   TObject* obj;
00113   for (int i=0; (obj=mom->At(i)); ++i) {
00114     const RawRecord* rr = dynamic_cast<RawRecord*>(obj);
00115     if (rr) {
00116       const RawDaqSnarlHeader* 
00117         rdsh = dynamic_cast<const RawDaqSnarlHeader*>(rr->GetRawHeader());
00118       if (rdsh) {
00119         run   = rdsh->GetRun();
00120         snarl = rdsh->GetSnarl();
00121       }
00122     }
00123   }
00124   
00125   MSG("DmxFast",Msg::kInfo) << " Run : " << run << " Snarl : " << snarl << endl;
00126 
00127 
00128   // Find PrimaryCandidateRecord fragment in MOM.
00129   const CandDigitListHandle *canddigit = 
00130       DataUtil::GetCandidate<CandDigitListHandle>(mom,
00131                                                   "CandDigitListHandle", 
00132                                                   "canddigitlist");
00133   MSG("DmxFast",Msg::kDebug) << " *** DemuxFast::Ana CandDigit*** " <<canddigit << endl; 
00134   
00135   if (canddigit == 0) {
00136     MSG("DemuxFast",Msg::kWarning) << "Failed to get CandDigitListHandle!\n";
00137     return JobCResult::kFailed;
00138   }
00139 
00140 
00141   CandDigitHandleItr cdhItr(canddigit->GetDaughterIterator());
00142 
00143   while ( CandDigitHandle *cdh = cdhItr() ) {
00144     // for each digit
00145     paltlist = const_cast<PlexSEIdAltL*>(&(cdh->GetPlexSEIdAltL()));
00146     int iplane = paltlist->GetPlane();
00147     if(paltlist->IsVetoShield())MSG("DmxFast",Msg::kInfo) << " IS VETO SHIELD " << iplane << endl;
00148     if(iplane>0&&iplane<500){
00149       int pixel =  _vaChip0[cdh->GetChannelId().GetVaChannel()];
00150       if(paltlist->GetEnd()==StripEnd::kEast){
00151         pixelE[iplane][cdh->GetChannelId().GetVaChip()][pixel] += cdh->GetCharge();
00152       }else{
00153         //PlanesAltListsW[iplane].push_back(paltlist);
00154         pixelW[iplane][cdh->GetChannelId().GetVaChip()][pixel] += cdh->GetCharge();
00155       }
00156       ndigits++;
00157     }
00158   }
00159 
00160   
00161   CandDigitHandleItr cdhIt(canddigit->GetDaughterIterator());
00162   while ( CandDigitHandle *cdh = cdhIt() ) {
00163     // for each digit
00164     paltlist = const_cast<PlexSEIdAltL*>(&(cdh->GetPlexSEIdAltL()));
00165     int iplane = paltlist->GetPlane();
00166     if(iplane>0&&iplane<500){
00167       float crossTalk;
00168       int pixel =  _vaChip0[cdh->GetChannelId().GetVaChannel()];
00169       int va    =  cdh->GetChannelId().GetVaChip();
00170       if(paltlist->GetEnd()==StripEnd::kEast){
00171         crossTalk = this->IsItXTalk(0,iplane,va,pixel);
00172         if(crossTalk<10.*cdh->GetCharge()){
00173           PlanesAltListsE[iplane].push_back(paltlist);
00174           paltlist->SetFirst();
00175           _qTotE[iplane] += paltlist->GetCurrentItem().GetPE();
00176           if(paltlist->GetCurrentItem().GetPE()>_qMaxE[iplane])_qMaxE[iplane]=
00177                  paltlist->GetCurrentItem().GetPE();
00178         }
00179       }else{
00180         crossTalk = this->IsItXTalk(1,iplane,va,pixel);
00181         if(crossTalk<10.*cdh->GetCharge()){
00182           PlanesAltListsW[iplane].push_back(paltlist);
00183           paltlist->SetFirst();
00184           _qTotW[iplane] += paltlist->GetCurrentItem().GetPE();
00185           if(paltlist->GetCurrentItem().GetPE()>_qMaxW[iplane])_qMaxW[iplane]=
00186                   paltlist->GetCurrentItem().GetPE();
00187         }
00188       }
00189       if(crossTalk>10.*cdh->GetCharge())MSG("DmxFast",Msg::kDebug) << "Plane : " << iplane << " : " << cdh->GetCharge() << " cf " <<  crossTalk << endl;
00190     }
00191   }
00192   
00193 
00194   for(int i=0; i<500; i++){
00195     if(PlanesAltListsE[i].size()>0){
00196       for(int j=0;j<16;j++){
00197         pixelE[i][0][j]=0;
00198         pixelE[i][1][j]=0;
00199         pixelE[i][2][j]=0;
00200       }
00201     }
00202     if(PlanesAltListsE[i].size()>0){
00203       for(int j=0;j<16;j++){
00204         pixelW[i][0][j]=0;
00205         pixelW[i][1][j]=0;
00206         pixelW[i][2][j]=0;
00207       }
00208     }
00209   }
00210 
00211 
00212   _cutRatioLow    = 0.2;
00213   _cutRatioHigh   = 5.0;
00214   _cutPEmin       = 2.0;
00215   _cutFractionMin = 0.05;
00216   _cutSigmaQ      = 0.0;
00217   _cutTrackTargetQ=20.0;
00218 
00219 
00220   _rangeWindow = 4;
00221   for(int i=0; i<500; i++){
00222     if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00223       MSG("DmxFast",Msg::kDebug) << i << " : " << PlanesAltListsE[i].size() << " : " << PlanesAltListsW[i].size() << endl;
00224       this->ResetMap(PlanesAltListsE[i].size(),PlanesAltListsW[i].size());
00225       this->MakeMap(i);
00226       //  this->PrintMap(ecount,wcount);
00227       this->GroupHits(ecount,wcount);
00228       this->SelectHits(true);
00229     }
00230   }
00231   this->MakeGoldGuide();
00232 
00233 
00234 
00235   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00236   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00237   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 0           *" << endl;
00238   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00239   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00240 
00241 
00242 
00243   NdemuxedHits=NdemuxedHitsU = NdemuxedHitsV = 0;
00244   demuxedHitPlane.clear();
00245   demuxedHitStrip.clear();
00246 
00247   _cutRatioLow    = 0.2;
00248   _cutRatioHigh   = 5.0;
00249   _cutPEmin       = 4.0;
00250   _cutFractionMin = 0.1;
00251   _cutSigmaQ      = 3.0;
00252   _rangeWindow = 4;
00253 
00254 
00255   for(int i=0; i<500; i++){
00256     if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00257       MSG("DmxFast",Msg::kDebug) << i << " : " << PlanesAltListsE[i].size() << " : " << PlanesAltListsW[i].size() << endl;
00258       this->ResetMap(PlanesAltListsE[i].size(),PlanesAltListsW[i].size());
00259       this->MakeMap(i);
00260       //  this->PrintMap(ecount,wcount);
00261       this->GroupHits(ecount,wcount);
00262       this->SelectHits(false,true);
00263     }
00264   }
00265 
00266   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00267   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00268   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 1a           *" << endl;
00269   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00270   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00271 
00272   MSG("DmxFast",Msg::kDebug) << " N : " << NdemuxedHits  << endl;
00273 
00274   _cutFractionMin = 0.25;
00275 
00276   if(NdemuxedHitsU==0){
00277     for(int i=0; i<500; i++){
00278       if(_UVmap[i]==1){
00279         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00280           MSG("DmxFast",Msg::kDebug) << i << " : " << PlanesAltListsE[i].size() << " : " << PlanesAltListsW[i].size() << endl;
00281           this->ResetMap(PlanesAltListsE[i].size(),PlanesAltListsW[i].size());
00282           this->MakeMap(i);
00283           //  this->PrintMap(ecount,wcount);
00284           this->GroupHits(ecount,wcount);
00285           this->SelectHits(false,false);
00286         }
00287       }
00288     }
00289   }
00290 
00291 
00292   if(NdemuxedHitsV==0){
00293     for(int i=0; i<500; i++){
00294       if(_UVmap[i]==2){
00295         if(PlanesAltListsE[i].size()&&PlanesAltListsW[i].size()){
00296           MSG("DmxFast",Msg::kDebug) << i << " : " << PlanesAltListsE[i].size() << " : " << PlanesAltListsW[i].size() << endl;
00297           this->ResetMap(PlanesAltListsE[i].size(),PlanesAltListsW[i].size());
00298           this->MakeMap(i);
00299           //  this->PrintMap(ecount,wcount);
00300           this->GroupHits(ecount,wcount);
00301           this->SelectHits(false,false);
00302         }
00303       }
00304     }
00305   }
00306 
00307   
00308   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00309   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00310   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 1b           *" << endl;
00311   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00312   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00313 
00314   // Now use hitmap to fill in gaps.
00315 
00316   _cutRatioLow    = 0.1;
00317   _cutRatioHigh   =10.0;
00318   _cutPEmin       = 2.0;
00319   _cutFractionMin = 0.05;
00320   _cutSigmaQ      = 5.0;
00321   _rangeWindow    = 100;
00322 
00323   this->MakeSearchTactics();
00324 
00325   vector <DemuxSearchTactic>::iterator literS;
00326   vector <DemuxSearchTactic>::iterator literSE;
00327 
00328   for(unsigned int i=0; i<searchTactics.size(); i++){
00329     int plane = searchTactics[i].iplane;
00330     if(searchTactics[i].goodTactic){
00331       this->ResetMap(PlanesAltListsE[plane].size(),PlanesAltListsW[plane].size());
00332       this->MakeMap(searchTactics[i]);
00333       this->GroupHits(ecount,wcount);
00334       if(this->SelectHits(false)){
00335         MSG("DmxFast",Msg::kDebug) << " OK go and make a new tactic " << endl;
00336         this->NewTactic(searchTactics[i]);
00337       }
00338     }else{
00339       this->NewTactic(searchTactics[i]);
00340     }
00341     literS++;
00342   }
00343 
00344   literS  = searchTactics.begin();
00345   literSE = searchTactics.end();
00346 
00347   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00348   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00349   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 2           *" << endl;
00350   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00351   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00352 
00353   this->MakeSearchTacticsX();
00354   // MSG("DmxFast",Msg::kDebug) << " Number of Search Tactics : " << searchTactics.size() << endl;
00355 
00356   for(unsigned int i=0; i<searchTactics.size(); i++){
00357     int plane = searchTactics[i].iplane;
00358     if(searchTactics[i].goodTactic){
00359       this->ResetMap(PlanesAltListsE[plane].size(),PlanesAltListsW[plane].size());
00360       this->MakeMap(searchTactics[i]);
00361       // this->PrintMap(ecount,wcount);
00362       this->GroupHits(ecount,wcount);
00363       this->NewTactic( searchTactics[i] );
00364     }
00365     this->NewTactic( searchTactics[i] );
00366   }
00367 
00368   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00369   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00370   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 3           *" << endl;
00371   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00372   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00373 
00374   //this->PrintWhatRemains();
00375   // Time to mop up crap 
00376 
00377   this->MakeSearchTacticsY();
00378   // MSG("DmxFast",Msg::kDebug) << " Number of Singles Search Tactics : " << searchTactics.size() << endl;
00379 
00380   literS = searchTactics.begin();
00381   while(literS!=searchTactics.end()){
00382     if((*literS).goodTactic){
00383       this->DemuxSingles((*literS));
00384     }
00385     literS++;
00386   }
00387 
00388   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00389   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00390   MSG("DmxFast",Msg::kDebug) << "*          Finished Loop 4           *" << endl;
00391   MSG("DmxFast",Msg::kDebug) << "*                                    *" << endl;
00392   MSG("DmxFast",Msg::kDebug) << "**************************************" << endl;
00393 
00394   JobCResult result = JobCResult::kAOK;
00395 
00397   // NJT
00398   // Attempt to save the data.
00399   // Get the DeMuxDigitList.
00400 
00401   // Actually, this code is redundant, now that I fixed the 
00402   // bug elsewhere.
00403   /*
00404   cout << "Getting DeMuxDigitListHandle.\n";
00405   
00406   // Find PrimaryCandidateRecord fragment in MOM.
00407   CandRecord *candrec = dynamic_cast<CandRecord *>
00408     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00409   if (candrec == 0) {
00410     result.SetError().SetFailed();
00411     return result;
00412   }
00413 
00414   CandDigitListHandle *crdlh = dynamic_cast<CandDigitListHandle *>
00415     (candrec->FindCandHandle("CandDigitListHandle", "canddigitlist"));
00416   if (crdlh == 0) {
00417     result.SetError().SetFailed();
00418     MSG("DmxFast",Msg::kError) << "Couldn't get CandDigitListHandle.\n";
00419     return result;
00420   }
00421   cout << "Doing saving.\n";
00422 
00423   // Build a big map of the reults.
00424   typedef std::multimap<int,int> resMap_t;
00425   resMap_t resMap;
00426 
00427   for(int i=0;i<NdemuxedHits;i++){
00428     resMap.insert(pair<int,int>(demuxedHitPlane[i],demuxedHitStrip[i]));
00429   }
00430     
00431   CandDigitHandleItr cdhItr3(crdlh->GetDaughterIterator());
00432   while ( CandDigitHandle *cdh = cdhItr3() ) {
00433     // for each digit
00434     PlexSEIdAltL& altlist = (cdh->GetPlexSEIdAltLWritable());
00435     int iplane = altlist.GetPlane();
00436     // find the list of strips for this plane.
00437     pair<resMap_t::iterator,resMap_t::iterator> range = resMap.equal_range(iplane); 
00438 
00439     // Go through the altlist, assign values.
00440     altlist.ClearWeights();
00441     altlist.SetFirst();
00442     while(altlist.IsValid()) {
00443       for(resMap_t::iterator it=range.first; it!= range.second; it++) {
00444         int strip = it->second;
00445         cout << "Comparing (plane " << iplane << "): " << strip << "  " << altlist.GetCurrentSEId().GetStrip() << endl;
00446         if(altlist.GetCurrentSEId().GetStrip() == strip){
00447           altlist.SetCurrentWeight(99.0);
00448         }
00449       }
00450       altlist.Next();
00451     }
00452   }
00453   */
00454   return result;
00455 }

void DemuxFast::ResetMap ( int  ne,
int  nw 
)

Definition at line 480 of file DemuxFast.cxx.

References _amap.

Referenced by Reco().

00480                                       {
00481   
00482   // MSG("DmxFast",Msg::kDebug) << "DemuxFast::ResetMap(" << ne << "," << nw << ")" << endl;
00483   for(int ie=0;ie<=ne;ie++){
00484     for(int iw=0;iw<=nw;iw++){
00485       _amap[ie][iw] = false;
00486     }
00487   }
00488 
00489   // MSG("DmxFast",Msg::kDebug) << "DemuxFast::ResetMap done" <<endl;
00490   return;
00491 } 

bool DemuxFast::SelectHits ( bool  makeGold,
bool  useGold = false 
)

Definition at line 1295 of file DemuxFast.cxx.

References _amap, _rangeWindow, _smap, count, currentPlane, DemuxBigGroup(), DemuxHits(), PatternPair::eEntry, egroup, MyDemuxPattern::GetI(), goldhitmap, GoldHits(), goldplanehit, Msg::kDebug, MSG, MyDemuxPatternMaster::Next(), ngroup, ningroupe, ningroupw, pMaster, MyDemuxPatternMaster::SelectPattern(), MyDemuxPattern::Size(), PatternPair::wEntry, and wgroup.

Referenced by Reco().

01296 {
01297   bool success = false;
01298 
01299   for(int ig=1;ig<=ngroup;ig++){
01300     
01301     MSG("DmxFast",Msg::kDebug) << "Asking Pattern Master for " << ningroupe[ig] << " : " << ningroupw[ig] << endl;
01302     MSG("DmxFast",Msg::kDebug) << "Returned : " << pMaster->SelectPattern(ningroupe[ig],ningroupw[ig]) << endl;
01303     MyDemuxPattern* pP;
01304     MyDemuxPattern* pBest;
01305     PatternPair wibble;
01306     int smin;
01307     int smax;
01308     int srange;
01309     int srange1;
01310     int srange2;
01311     int count;
01312 
01313     pBest = NULL;
01314     count  =0;
01315     srange1 = 1000;
01316     srange2 = 1000; 
01317     if(pMaster->SelectPattern(ningroupe[ig],ningroupw[ig])){
01318       while( (pP = pMaster->Next())!=NULL ){
01319         count++;
01320         bool patok = true;
01321         smin =999;
01322         smax =0;
01323         for(int i=0; i< pP->Size(); i++){
01324           wibble = pP->GetI(i);
01325           if(patok)patok = _amap[(egroup[ig][wibble.eEntry])][(wgroup[ig][wibble.wEntry])];
01326           // if(patok){
01327             int s = _smap[(egroup[ig][wibble.eEntry])][(wgroup[ig][wibble.wEntry])];
01328             if(s<smin)smin=s;
01329             if(s>smax)smax=s;
01330             //    }
01331         }
01332         if(patok){
01333           srange = smax-smin;
01334           if(srange<=srange1){
01335             srange2 = srange1;
01336             srange1 = srange;
01337             pBest = pP;
01338           }else{
01339             if(srange<=srange2)srange2=srange;
01340           }
01341         }
01342       }
01343 
01344       if(pBest==NULL)return false;
01345 
01346       if(srange1 < pBest->Size()+_rangeWindow && srange1+pBest->Size()<srange2){
01347         success = true;
01348         for(int i=0; i< pBest->Size(); i++){
01349           wibble = pBest->GetI(i);
01350           
01351           int s = _smap[(egroup[ig][wibble.eEntry])][(wgroup[ig][wibble.wEntry])];
01352 
01353           MSG("DmxFast",Msg::kDebug) << " **Using combination " << s << endl;
01354           if(gold)this->GoldHits(egroup[ig][wibble.eEntry],wgroup[ig][wibble.wEntry],s);
01355           if(!gold){
01356             bool found = false;
01357             if(useGold){
01358               for(int i=1;!found && i<=goldplanehit[currentPlane];i++){
01359                 if(s==goldhitmap[currentPlane][i])found=true;
01360               }
01361             }
01362             if(!useGold ||found)this->DemuxHits(egroup[ig][wibble.eEntry],wgroup[ig][wibble.wEntry],s);
01363             if( useGold && !found)MSG("DmxFast",Msg::kDebug) << "VETOING THIS HIT " << endl;
01364           }
01365         }
01366       }
01367     }else{
01368       // Pattern Master says no ! too big ? 
01369       if( (ningroupe[ig]>3) && (ningroupw[ig]>3) ){
01370         success = this->DemuxBigGroup(ig,gold);
01371       }
01372     }
01373   }  // end of loop over groups 
01374   MSG("DmxFast",Msg::kDebug) << "Returning " << success << endl;
01375   return success; 
01376 }


Member Data Documentation

bool DemuxFast::_amap[100][100] [private]

Definition at line 103 of file DemuxFast.h.

Referenced by DemuxBigGroup(), GroupHits(), MakeMap(), PrintMap(), ResetMap(), and SelectHits().

bool DemuxFast::_bmap[100][100] [private]

Definition at line 105 of file DemuxFast.h.

Referenced by GroupHits().

float DemuxFast::_cutFractionMin [private]

Definition at line 97 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_cutPEmin [private]

Definition at line 96 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_cutRatioHigh [private]

Definition at line 95 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_cutRatioLow [private]

Definition at line 94 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_cutSigmaQ [private]

Definition at line 98 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_cutTrackTargetQ [private]

Definition at line 99 of file DemuxFast.h.

Referenced by DemuxSingles(), MakeMap(), and Reco().

float DemuxFast::_goldGuide[500] [private]

Definition at line 119 of file DemuxFast.h.

Referenced by MakeGoldGuide(), MakeMap(), and Reco().

Definition at line 123 of file DemuxFast.h.

Referenced by DemuxHitE(), DemuxHits(), and MakeMap().

Definition at line 124 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxHitW(), and MakeMap().

Definition at line 87 of file DemuxFast.h.

float DemuxFast::_qMaxE[500] [private]

Definition at line 116 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_qMaxW[500] [private]

Definition at line 117 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_qTotE[500] [private]

Definition at line 114 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

float DemuxFast::_qTotW[500] [private]

Definition at line 115 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

int DemuxFast::_rangeWindow [private]

Definition at line 128 of file DemuxFast.h.

Referenced by Reco(), and SelectHits().

bool DemuxFast::_searched[500] [private]

Definition at line 110 of file DemuxFast.h.

Referenced by MakeSearchTactics(), and NewTactic().

float DemuxFast::_sgoldGuide[500] [private]

Definition at line 120 of file DemuxFast.h.

int DemuxFast::_smap[100][100] [private]

Definition at line 104 of file DemuxFast.h.

Referenced by DemuxBigGroup(), MakeMap(), and SelectHits().

int DemuxFast::_UVmap[500] [private]

Definition at line 106 of file DemuxFast.h.

Referenced by DemuxFast(), MakeSearchTactics(), and Reco().

int DemuxFast::_vaChip0[18] [private]

Definition at line 126 of file DemuxFast.h.

Referenced by DemuxFast(), and Reco().

bool DemuxFast::amHisting [private]

Definition at line 109 of file DemuxFast.h.

bool DemuxFast::amPSing [private]

Definition at line 108 of file DemuxFast.h.

bool DemuxFast::amWriting [private]

Definition at line 107 of file DemuxFast.h.

int DemuxFast::currentPlane [private]

Definition at line 140 of file DemuxFast.h.

Referenced by DemuxHitE(), DemuxHits(), DemuxHitW(), DemuxSingles(), GoldHits(), MakeMap(), and SelectHits().

std::vector<int> DemuxFast::demuxedHitPlane [private]

Definition at line 149 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and Reco().

std::vector<float> DemuxFast::demuxedHitQ [private]

Definition at line 151 of file DemuxFast.h.

Referenced by DemuxHits(), and DemuxSingles().

std::vector<int> DemuxFast::demuxedHitStrip [private]

Definition at line 150 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and Reco().

int DemuxFast::demuxedmap[500][100] [private]

Definition at line 153 of file DemuxFast.h.

int DemuxFast::ecount [private]

Definition at line 138 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

bool DemuxFast::efound[100] [private]

Definition at line 130 of file DemuxFast.h.

Referenced by GroupHits().

int DemuxFast::egroup[100][100] [private]

Definition at line 135 of file DemuxFast.h.

Referenced by DemuxBigGroup(), GroupHits(), and SelectHits().

int DemuxFast::goldhitmap[500][100] [private]

Definition at line 155 of file DemuxFast.h.

Referenced by GoldHits(), MakeGoldGuide(), and SelectHits().

int DemuxFast::goldplanehit[500] [private]

Definition at line 154 of file DemuxFast.h.

Referenced by GoldHits(), MakeGoldGuide(), Reco(), and SelectHits().

int DemuxFast::hitmap[500][100] [private]

Definition at line 142 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and MakeMap().

Definition at line 86 of file DemuxFast.h.

Referenced by DemuxSingles(), and MakeMap().

int DemuxFast::NdemuxedHits [private]

Definition at line 148 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and Reco().

int DemuxFast::NdemuxedHitsU [private]

Definition at line 146 of file DemuxFast.h.

Referenced by DemuxSingles(), and Reco().

int DemuxFast::NdemuxedHitsV [private]

Definition at line 147 of file DemuxFast.h.

Referenced by DemuxSingles(), and Reco().

int DemuxFast::ngroup [private]

Definition at line 132 of file DemuxFast.h.

Referenced by GroupHits(), and SelectHits().

int DemuxFast::ningroupe[100] [private]

Definition at line 133 of file DemuxFast.h.

Referenced by DemuxBigGroup(), GroupHits(), and SelectHits().

int DemuxFast::ningroupw[100] [private]

Definition at line 134 of file DemuxFast.h.

Referenced by DemuxBigGroup(), GroupHits(), and SelectHits().

float DemuxFast::pixelE[500][3][16] [private]

Definition at line 112 of file DemuxFast.h.

Referenced by IsItXTalk(), and Reco().

float DemuxFast::pixelW[500][3][16] [private]

Definition at line 113 of file DemuxFast.h.

Referenced by IsItXTalk(), and Reco().

int DemuxFast::planehit[500] [private]
std::vector<PlexSEIdAltL*> DemuxFast::PlanesAltListsE[500] [private]
std::vector<PlexSEIdAltL*> DemuxFast::PlanesAltListsW[500] [private]

Definition at line 82 of file DemuxFast.h.

Referenced by DemuxFast(), and SelectHits().

float DemuxFast::qhitmapE[500][100] [private]

Definition at line 143 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and MakeMap().

float DemuxFast::qhitmapW[500][100] [private]

Definition at line 144 of file DemuxFast.h.

Referenced by DemuxHits(), DemuxSingles(), and MakeMap().

std::vector<int> DemuxFast::targets [private]

Definition at line 121 of file DemuxFast.h.

Referenced by DemuxSingles(), and MakeMap().

int DemuxFast::wcount [private]

Definition at line 139 of file DemuxFast.h.

Referenced by MakeMap(), and Reco().

bool DemuxFast::wfound[100] [private]

Definition at line 131 of file DemuxFast.h.

Referenced by GroupHits().

int DemuxFast::wgroup[100][100] [private]

Definition at line 136 of file DemuxFast.h.

Referenced by DemuxBigGroup(), GroupHits(), and SelectHits().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1