AlgFarDetSlice Class Reference

#include <AlgFarDetSlice.h>

Inheritance diagram for AlgFarDetSlice:

AlgBase List of all members.

Public Member Functions

 AlgFarDetSlice ()
virtual ~AlgFarDetSlice ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Private Attributes

TObjArray fStrpList [500]

Detailed Description

Definition at line 8 of file AlgFarDetSlice.h.


Constructor & Destructor Documentation

AlgFarDetSlice::AlgFarDetSlice (  ) 

Definition at line 24 of file AlgFarDetSlice.cxx.

00025 {
00026 
00027 }   

AlgFarDetSlice::~AlgFarDetSlice (  )  [virtual]

Definition at line 29 of file AlgFarDetSlice.cxx.

00030 {
00031 
00032 }


Member Function Documentation

void AlgFarDetSlice::RunAlg ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Implements AlgBase.

Definition at line 34 of file AlgFarDetSlice.cxx.

References CandHandle::AddDaughterLink(), EVD::Clear(), digit(), fStrpList, CandContext::GetCandRecord(), CandContext::GetDataIn(), Registry::GetDouble(), Registry::GetInt(), FabPlnInstallLookup::GetLastNormalPlane(), PlexPlaneId::GetPlane(), CandStripHandle::GetPlaneView(), RecMinos::GetVldContext(), PlexPlaneId::IsValid(), Msg::kDebug, PlaneView::kU, PlaneView::kV, Msg::kVerbose, CandDeMuxDigit::kXTalk, MSG, FarDetSliceHandle::SetEdges(), FarDetSliceHandle::SetEdgesSM1(), FarDetSliceHandle::SetEdgesSM2(), FarDetSliceHandle::SetEventId(), FarDetSliceHandle::SetEventIdSM1(), FarDetSliceHandle::SetEventIdSM2(), FarDetSliceHandle::SetEventIdX(), FarDetSliceHandle::SetGoodPlanes(), FarDetSliceHandle::SetGoodStrips(), FarDetSliceHandle::SetGoodUPlanes(), FarDetSliceHandle::SetGoodVPlanes(), FarDetSliceHandle::SetMaxPlaneCharge(), FarDetSliceHandle::SetSM1(), and FarDetSliceHandle::SetSM2().

00035 {
00036   MSG("FarDetSlice",Msg::kDebug) << " AlgFarDetSlice::RunAlg(...) " << endl;
00037 
00038   FarDetSliceHandle& myslice = dynamic_cast<FarDetSliceHandle&>(ch);
00039 
00040   // Unpack AlgConfig
00041   Int_t fMinPlane,fMaxPlane,fCheckInstall;
00042   Int_t fEdgePlnCut;
00043   Double_t fEdgeRadCut,fEdgeWidthCut;
00044   Double_t fEdgeChargeCut,fFidChargeCut;
00045   fMinPlane = ac.GetInt("MinPlane");
00046   fMaxPlane = ac.GetInt("MaxPlane");
00047   fCheckInstall = ac.GetInt("CheckInstall");
00048   fEdgePlnCut = ac.GetInt("EdgePlnCut");
00049   fEdgeRadCut = ac.GetDouble("EdgeRadCut");
00050   fEdgeWidthCut = ac.GetDouble("EdgeWidthCut");
00051   fEdgeChargeCut = ac.GetDouble("EdgeChargeCut");
00052   fFidChargeCut = ac.GetDouble("FidChargeCut");
00053 
00054   MSG("FarDetSlice",Msg::kDebug) << endl
00055                                  << " AlgFarDetSlice Config: " << endl
00056                                  << "  MinPlane=" << fMinPlane 
00057                                  << "  MaxPlane=" << fMaxPlane 
00058                                  << "  CheckInstall=" << fCheckInstall << endl
00059                                  << "  EdgePlnCut=" << fEdgePlnCut 
00060                                  << "  EdgeRadCut=" << fEdgeRadCut 
00061                                  << "  EdgeWidthCut=" << fEdgeWidthCut
00062                                  << "  EdgeChargeCut=" << fEdgeChargeCut 
00063                                  << "  FidChargeCut=" << fFidChargeCut << endl;
00064 
00065   // Check installation status
00066   if( fCheckInstall ){
00067 
00068     // Find maximum installed plane
00069     MSG("FarDetSlice",Msg::kDebug) << " Checking Installation Status: " << endl;
00070     Int_t fMaxInstallPlane = 485, fTmpInstallPlane = 485;
00071     CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00072     VldContext *vldc = (VldContext*)(candrec->GetVldContext());
00073     FabPlnInstallLookup fMaxPlaneLookup(*vldc);
00074     PlexPlaneId fMaxPlaneId = fMaxPlaneLookup.GetLastNormalPlane();
00075     if(fMaxPlaneId.IsValid()) fTmpInstallPlane = fMaxPlaneId.GetPlane();
00076     if(fTmpInstallPlane<fMaxInstallPlane) fMaxInstallPlane = fTmpInstallPlane;
00077     MSG("FarDetSlice",Msg::kDebug) << "  Maximum Installed Plane=" << fMaxInstallPlane << endl;
00078   
00079     // Reset maximum plane
00080     if( fMaxInstallPlane<fMaxPlane ){
00081       MSG("FarDetSlice",Msg::kDebug) << "   ... resetting MaxPlane to: " << fMaxInstallPlane << endl;
00082       fMaxPlane=fMaxInstallPlane;
00083     }
00084 
00085     // Reset minimum plane
00086     if( fMaxInstallPlane<fMinPlane ){
00087       MSG("FarDetSlice",Msg::kDebug) << "   ... resetting MinPlane to: " << fMaxInstallPlane << endl;
00088       fMinPlane=fMaxInstallPlane;
00089     }
00090   }
00091 
00092   // Unpack CandContext
00093   const TObjArray* myarray = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00094 
00095   Int_t i,j;
00096   Int_t pln,vuw,sm;
00097   Int_t xtalk,ndigits;
00098   Double_t q;
00099   
00100   for(i=0;i<1+myarray->GetLast();i++){
00101     CandStripHandle* mystrip = (CandStripHandle*)(myarray->At(i));
00102     myslice.AddDaughterLink(*mystrip);
00103     pln=mystrip->GetPlane();
00104 
00105     xtalk=0;
00106     TIter digitr(mystrip->GetDaughterIterator());
00107     while(CandDeMuxDigitHandle* digit = dynamic_cast<CandDeMuxDigitHandle*>(digitr())){
00108       if(  (digit->GetDeMuxDigitFlagWord()<8)
00109         && ( (digit->GetDeMuxDigitFlagWord() & CandDeMuxDigit::kXTalk)==(CandDeMuxDigit::kXTalk) ) ){
00110         xtalk=1; 
00111       }
00112     }
00113 
00114     q=mystrip->GetCharge();
00115     ndigits=mystrip->GetNDigit();
00116     if( pln>0 && pln<500
00117      && pln>=fMinPlane && pln<=fMaxPlane
00118      && !xtalk && q>2.0 && ndigits>1 ){
00119       fStrpList[pln].Add(mystrip);
00120     }
00121   }
00122 
00123   // Good Planes
00124   Int_t flag=0,uflag=0,vflag=0;
00125   Int_t nplanes=0,uplanes=0,vplanes=0;
00126   Int_t nstrips=0;
00127 
00128   for(pln=0;pln<500;pln++){
00129     flag=0;
00130     uflag=0; vflag=0;
00131     if(1+fStrpList[pln].GetLast()>0){
00132       flag=1; nstrips+=1+fStrpList[pln].GetLast();
00133       CandStripHandle* firststrip = (CandStripHandle*)(fStrpList[pln].First());
00134       if(firststrip->GetPlaneView()==PlaneView::kU) uflag=1;
00135       if(firststrip->GetPlaneView()==PlaneView::kV) vflag=1;
00136     }
00137     if(flag){
00138       if(uflag) uplanes+=1; if(vflag) vplanes+=1;
00139       nplanes+=1;
00140     }
00141   }
00142 
00143   MSG("FarDetSlice",Msg::kDebug) << " nplanes=" << nplanes << " nstrips=" << nstrips << endl; 
00144 
00145   // Max Plane Charge
00146   Double_t thisplncharge=0.0;
00147   Double_t maxplncharge=0.0;
00148   for(pln=0;pln<500;pln++){
00149     if(1+fStrpList[pln].GetLast()>0){
00150       thisplncharge=0.0;
00151       for(j=0;j<1+fStrpList[pln].GetLast();j++){
00152         CandStripHandle* mystrip = (CandStripHandle*)(fStrpList[pln].At(j));
00153         thisplncharge+=mystrip->GetCharge();
00154       }
00155       if(thisplncharge>maxplncharge){
00156         maxplncharge=thisplncharge;
00157       }
00158     }
00159   }
00160 
00161   MSG("FarDetSlice",Msg::kDebug) << " maxplncharge=" << maxplncharge << endl;
00162 
00163   // Containment 
00164   Double_t qSM1[11],qSM2[11]; // 0=contained, 1-8=edges, 9-10=beg/end
00165   Double_t xSM1[11],xSM2[11];
00166   Double_t ySM1[11],ySM2[11];
00167   Double_t zSM1[11],zSM2[11]; 
00168   Int_t eventidSM1,eventidSM2,eventidX;
00169   Int_t edgesSM1,edgesSM2,edges;
00170   Int_t Tctr,Zctr;
00171   Double_t upos,vpos,tpos,opos,xpos,ypos,zpos;
00172   Double_t totqo,totq;
00173   Double_t xm,xp,ym,yp,um,up,vm,vp;
00174   Double_t dx,dy,dz,dr;
00175   Double_t rmin;
00176   Int_t id,cont;
00177   Int_t eventid;
00178 
00179   for(i=0;i<11;i++){
00180     qSM1[i]=0.0; qSM2[i]=0.0; 
00181     xSM1[i]=0.0; xSM2[i]=0.0;
00182     ySM1[i]=0.0; ySM2[i]=0.0;
00183     zSM1[i]=0.0; zSM2[i]=0.0;
00184   }
00185   
00186   for(pln=0;pln<500;pln++){
00187     for(i=0;i<1+fStrpList[pln].GetLast();i++){
00188       CandStripHandle* mystrip = (CandStripHandle*)(fStrpList[pln].At(i));
00189       cont=0; id=-1;   
00190       MSG("FarDetSlice",Msg::kVerbose) << "  STRIP : " 
00191                                        << " " << mystrip->GetPlane() 
00192                                        << " " << mystrip->GetStrip() 
00193                                        << " " << mystrip->GetCharge() << endl; 
00194 
00195       vuw=-1; sm=-1; 
00196       if(mystrip->GetPlaneView()==PlaneView::kU) vuw=0;
00197       if(mystrip->GetPlaneView()==PlaneView::kV) vuw=1;
00198       if(pln>0 && pln<249) sm=1; if(pln>249 && pln<498) sm=2;
00199       tpos=mystrip->GetTPos(); opos=0.0; 
00200       
00201       totqo=0.0; totq=0.0;
00202       if((pln>1&&pln<249)||(pln>250&&pln<498)){
00203         for(j=0;j<1+fStrpList[pln-1].GetLast();j++){
00204           CandStripHandle* tmpstrip = (CandStripHandle*)(fStrpList[pln-1].At(j));  
00205           totqo+=tmpstrip->GetCharge()*tmpstrip->GetTPos();
00206           totq+=tmpstrip->GetCharge();
00207         } 
00208       }        
00209       if((pln>0&&pln<248)||(pln>249&&pln<497)){
00210         for(j=0;j<1+fStrpList[pln+1].GetLast();j++){
00211           CandStripHandle* tmpstrip = (CandStripHandle*)(fStrpList[pln+1].At(j));  
00212           totqo+=tmpstrip->GetCharge()*tmpstrip->GetTPos();
00213           totq+=tmpstrip->GetCharge();
00214         }
00215       }
00216       if(totq>0.0){ opos=totqo/totq; } else{ opos=0.0; }
00217 
00218       upos=0.0; vpos=0.0;
00219       if(vuw==0){ upos=tpos; vpos=opos; } 
00220       if(vuw==1){ upos=opos; vpos=tpos; }
00221       xpos=0.7071*(upos-vpos); ypos=0.7071*(upos+vpos); 
00222       zpos=mystrip->GetZPos();
00223 
00224       MSG("FarDetSlice",Msg::kVerbose) << "  "
00225                                        << " u=" << upos << " v=" << vpos 
00226                                        << " x=" << xpos << " y=" << ypos 
00227                                        << " z=" << zpos << endl;
00228 
00229       if(sm>-1 && vuw>-1) cont=1;
00230 
00231       if(cont){
00232         if(sm==1){
00233           if( (pln<1+fEdgePlnCut)||(fMinPlane<249&&pln<fMinPlane+fEdgePlnCut) ) id=9;
00234           if( (pln>248-fEdgePlnCut)||(fMaxPlane<249&&pln>fMaxPlane-fEdgePlnCut) ) id=10; }
00235         if(sm==2){
00236           if( (pln<250+fEdgePlnCut)||(fMinPlane>249&&pln<fMinPlane+fEdgePlnCut) ) id=9;
00237           if( (pln>485-fEdgePlnCut)||(fMaxPlane>249&&pln>fMaxPlane-fEdgePlnCut) ) id=10; }
00238         
00239         if(id>0) cont=0;
00240         if(id>0) MSG("FarDetSlice",Msg::kVerbose) << "    ... id=" << id << endl;
00241       }
00242 
00243       if(cont){  
00244         rmin=4.0; 
00245         up=4.0-upos; if(up<rmin){ rmin=up; if(rmin<fEdgeRadCut) id=2; }
00246         um=4.0+upos; if(um<rmin){ rmin=um; if(rmin<fEdgeRadCut) id=6; }
00247         vp=4.0-vpos; if(vp<rmin){ rmin=vp; if(rmin<fEdgeRadCut) id=8; }
00248         vm=4.0+vpos; if(vm<rmin){ rmin=vm; if(rmin<fEdgeRadCut) id=4; }
00249         xp=4.0-xpos; if(xp<rmin){ rmin=xp; if(rmin<fEdgeRadCut) id=3; }
00250         xm=4.0+xpos; if(xm<rmin){ rmin=xm; if(rmin<fEdgeRadCut) id=7; }
00251         yp=4.0-ypos; if(yp<rmin){ rmin=yp; if(rmin<fEdgeRadCut) id=1; }
00252         ym=4.0+ypos; if(ym<rmin){ rmin=ym; if(rmin<fEdgeRadCut) id=5; }
00253       
00254         if(id>0) cont=0;
00255         if(id>0) MSG("FarDetSlice",Msg::kVerbose) << "    ... id=" << id << endl;
00256       }
00257 
00258       if(cont){
00259         id=0;
00260         if(id==0) MSG("FarDetSlice",Msg::kVerbose) << "    ... contained" << endl;
00261       }
00262 
00263       if(1+id>0){
00264         if(sm==1){
00265           qSM1[id]+=mystrip->GetCharge(); 
00266           xSM1[id]+=mystrip->GetCharge()*xpos;
00267           ySM1[id]+=mystrip->GetCharge()*ypos;
00268           zSM1[id]+=mystrip->GetCharge()*zpos; }
00269 
00270         if(sm==2){ 
00271           qSM2[id]+=mystrip->GetCharge(); 
00272           xSM2[id]+=mystrip->GetCharge()*xpos;
00273           ySM2[id]+=mystrip->GetCharge()*ypos;
00274           zSM2[id]+=mystrip->GetCharge()*zpos; }
00275       }
00276  
00277     }
00278   }
00279 
00280   for(i=0;i<11;i++){
00281     if( qSM1[i]>0.0 ){
00282       xSM1[i]=xSM1[i]/qSM1[i]; ySM1[i]=ySM1[i]/qSM1[i]; zSM1[i]=zSM1[i]/qSM1[i]; }
00283     else{
00284       xSM1[i]=-999.9; ySM1[i]=-999.9; zSM1[i]=-999.9; }
00285 
00286     if( qSM2[i]>0.0 ){
00287       xSM2[i]=xSM2[i]/qSM2[i]; ySM2[i]=ySM2[i]/qSM2[i]; zSM2[i]=zSM2[i]/qSM2[i]; }
00288     else{
00289       xSM2[i]=-999.9; ySM2[i]=-999.9; zSM2[i]=-999.9; }
00290   }
00291 
00292   MSG("FarDetSlice",Msg::kDebug) << " *** RESULTS *** " << endl;
00293   MSG("FarDetSlice",Msg::kDebug) << "  *** SM1 *** " << endl;
00294   for(i=0;i<11;i++){
00295     MSG("FarDetSlice",Msg::kDebug) << "  " << i << "  "
00296                                    << qSM1[i] << "   ( "
00297                                    << xSM1[i] << " , "
00298                                    << ySM1[i] << " , "
00299                                    << zSM1[i] << " )   " << endl; 
00300   }
00301    
00302   MSG("FarDetSlice",Msg::kDebug) << "  *** SM2 *** " << endl;
00303   for(i=0;i<11;i++){
00304     MSG("FarDetSlice",Msg::kDebug) << "  " << i << "  "
00305                                    << qSM2[i] << "   ( "
00306                                    << xSM2[i] << " , "
00307                                    << ySM2[i] << " , "
00308                                    << zSM2[i] << " )   " << endl;
00309   }
00310 
00311 
00312   edgesSM1=0;
00313   eventidSM1=-1;
00314   Tctr=0; Zctr=0;
00315   for(i=1;i<9;i++){
00316     if( qSM1[i]>fEdgeChargeCut ){
00317       if(Tctr<1) Tctr=1;
00318       for(j=1;j<9;j++){
00319         if( qSM1[j]>fEdgeChargeCut ){ 
00320           dx = xSM1[j]-xSM1[i];
00321           dy = ySM1[j]-ySM1[i];
00322           dz = zSM1[j]-zSM1[i];
00323           dr = sqrt(dx*dx+dy*dy+dz*dz);
00324           if( ( (i-j>-7&&i-j<-1)||(i-j>1&&i-j<7) )
00325            || ( dr>fEdgeWidthCut && i!=j ) ){      
00326             if(Tctr<2) Tctr=2;
00327           }
00328         }
00329       }
00330       edgesSM1++;
00331     }
00332   }
00333   for(j=9;j<11;j++){
00334     if( qSM1[j]>fEdgeChargeCut ){
00335       Zctr++; edgesSM1++;
00336     }
00337   }
00338   if( qSM1[0]>fFidChargeCut ){
00339     eventidSM1=Tctr+Zctr; if(eventidSM1>1) eventidSM1=2;
00340   }
00341   
00342   edgesSM2=0;
00343   eventidSM2=-1;
00344   Tctr=0; Zctr=0;
00345   for(i=1;i<9;i++){
00346     if( qSM2[i]>fEdgeChargeCut ){
00347       if(Tctr<1) Tctr=1;
00348       for(j=1;j<9;j++){
00349         if( qSM2[j]>fEdgeChargeCut ){ 
00350           dx = xSM2[j]-xSM2[i];
00351           dy = ySM2[j]-ySM2[i];
00352           dz = zSM2[j]-zSM2[i];
00353           dr = sqrt(dx*dx+dy*dy+dz*dz);
00354           if( ( (i-j>-7&&i-j<-1)||(i-j>1&&i-j<7) )
00355            || ( dr>fEdgeWidthCut && i!=j ) ){      
00356             if(Tctr<2) Tctr=2;
00357           }
00358         }
00359       }
00360       edgesSM2++;
00361     }
00362   }
00363   for(j=9;j<11;j++){
00364     if( qSM2[j]>fEdgeChargeCut ){
00365       Zctr++; edgesSM2++;
00366     }
00367   }
00368   if( qSM2[0]>fFidChargeCut ){
00369     eventidSM2=Tctr+Zctr; if(eventidSM2>1) eventidSM2=2; 
00370   }
00371   
00372   eventidX=0;
00373   if( eventidSM1>-1 && eventidSM2>-1
00374    && qSM1[10]>fEdgeChargeCut && qSM2[9]>fEdgeChargeCut ) eventidX=1;
00375  
00376   edges=0;
00377   if( eventidSM1>-1 ) edges+=edgesSM1;
00378   if( eventidSM2>-1 ) edges+=edgesSM2; 
00379   if( eventidX ) edges=edges-2;
00380 
00381   MSG("FarDetSlice",Msg::kDebug) << " eventid : "
00382                                  << " SM1=" << eventidSM1
00383                                  << " SM2=" << eventidSM2
00384                                  << " X=" << eventidX << endl;
00385   MSG("FarDetSlice",Msg::kDebug) << " edges : "
00386                                  << " SM1=" << edgesSM1
00387                                  << " SM2=" << edgesSM2
00388                                  << " total=" << edges << endl;
00389 
00390   eventid=-1;
00391   if( (eventidSM1<0&&eventidSM2==0) 
00392    || (eventidSM1==0&&eventidSM2<0)
00393    || (eventidSM1==1&&eventidSM2==1&&eventidX>0) ) eventid=0;
00394   if( (eventidSM1<0&&eventidSM2==1) 
00395    || (eventidSM1==1&&eventidSM2<0)
00396    || (eventidSM1==1&&eventidSM2==2&&eventidX>0)
00397    || (eventidSM1==2&&eventidSM2==1&&eventidX>0) ) eventid=1;
00398   if( (eventidSM1<0&&eventidSM2==2) 
00399    || (eventidSM1==2&&eventidSM2<0)
00400    || (eventidSM1==2&&eventidSM2==2&&eventidX>0) ) eventid=2;
00401 
00402   MSG("FarDetSlice",Msg::kDebug) << " eventid : " << eventid << endl;
00403 
00404 
00405   // Set slice parameters
00406   myslice.SetSM1(qSM1,xSM1,ySM1,zSM1);
00407   myslice.SetSM2(qSM2,xSM2,ySM2,zSM2);
00408   myslice.SetMaxPlaneCharge(maxplncharge);
00409   myslice.SetEventId(eventid);
00410   myslice.SetEventIdSM1(eventidSM1);
00411   myslice.SetEventIdSM2(eventidSM2);
00412   myslice.SetEventIdX(eventidX);
00413   myslice.SetEdgesSM1(edgesSM1);
00414   myslice.SetEdgesSM2(edgesSM2);
00415   myslice.SetEdges(edges);
00416   myslice.SetGoodUPlanes(uplanes);
00417   myslice.SetGoodVPlanes(vplanes);
00418   myslice.SetGoodPlanes(nplanes);
00419   myslice.SetGoodStrips(nstrips);
00420 
00421 
00422   for(i=0;i<500;i++){
00423     fStrpList[i].Clear();
00424   }
00425 
00426 }

void AlgFarDetSlice::Trace ( const char *  c  )  const [virtual]

Reimplemented from AlgBase.

Definition at line 428 of file AlgFarDetSlice.cxx.

00429 {
00430 
00431 }


Member Data Documentation

TObjArray AlgFarDetSlice::fStrpList[500] [private]

Definition at line 18 of file AlgFarDetSlice.h.

Referenced by RunAlg().


The documentation for this class was generated from the following files:
Generated on Fri Oct 10 22:45:10 2014 for loon by  doxygen 1.4.7