Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

AlgShowerEM Class Reference

#include <AlgShowerEM.h>

Inheritance diagram for AlgShowerEM:

AlgBase AlgReco List of all members.

Public Member Functions

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

Constructor & Destructor Documentation

AlgShowerEM::AlgShowerEM  ) 
 

Definition at line 43 of file AlgShowerEM.cxx.

00044 {
00045 }

AlgShowerEM::~AlgShowerEM  )  [virtual]
 

Definition at line 48 of file AlgShowerEM.cxx.

00049 {
00050 }


Member Function Documentation

void AlgShowerEM::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Read in info:

Implements AlgBase.

Definition at line 53 of file AlgShowerEM.cxx.

References abs(), CandShowerHandle::AddCluster(), CandHandle::AddDaughterLink(), AlgReco::Calibrate(), CandRecoHandle::GetCharge(), CandStripHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), Registry::GetInt(), Calibrator::GetMIP(), CandClusterHandle::GetNStrip(), CandStripHandle::GetPlane(), CandStripHandle::GetStrip(), CandStripHandle::GetStripEndId(), CandStripHandle::GetTime(), CandStripHandle::GetTPos(), CandHandle::GetVldContext(), CandStripHandle::GetZPos(), Calibrator::Instance(), MSG, CandShowerEMHandle::SetAvgDev(), CandRecoHandle::SetDirCosU(), CandRecoHandle::SetDirCosV(), CandRecoHandle::SetDirCosZ(), CandShowerEMHandle::SetEigenValues(), CandShowerEMHandle::SetEigenVectors(), CandShowerHandle::SetEnergy(), CandShowerEMHandle::SetOutPH(), CandShowerEMHandle::SetShwStatus(), CandRecoHandle::SetVtxPlane(), CandRecoHandle::SetVtxT(), CandRecoHandle::SetVtxU(), CandRecoHandle::SetVtxV(), and CandRecoHandle::SetVtxZ().

00054 {
00055   
00056   MSG("ShowerEM", Msg::kDebug) << "Starting AlgShowerEM::RunAlg()" << endl;
00057   Calibrator& calibrator=Calibrator::Instance();
00058 
00059   assert(ch.InheritsFrom("CandShowerEMHandle"));
00060   CandShowerEMHandle &csh = dynamic_cast<CandShowerEMHandle &>(ch);
00061   assert(cx.GetDataIn());
00062   assert(cx.GetDataIn()->InheritsFrom("TObjArray"));
00063   const TObjArray *tary = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00064   
00065   Int_t nstp = 0;
00066   for (Int_t i=0; i<=tary->GetLast(); i++) {
00067     TObject *tobj = tary->At(i);
00068     assert(tobj->InheritsFrom("CandClusterHandle"));
00069     CandClusterHandle *clusterhandle = dynamic_cast<CandClusterHandle*>(tobj);
00070     nstp+=clusterhandle->GetNStrip();
00071   }
00072      
00073   if(nstp==0){
00074     MSG("ShowerEM", Msg::kError) 
00075       << "Found empty daughter list in CandShowerEM" << endl;
00076     csh.SetDirCosU(0.);
00077     csh.SetDirCosV(0.);
00078     csh.SetDirCosZ(1.);
00079     csh.SetVtxPlane(-1);
00080     csh.SetVtxZ(-1.);
00081     csh.SetVtxU(0.);
00082     csh.SetVtxV(0.);
00083     csh.SetVtxT(0.);
00084     csh.SetEnergy(0);
00085     csh.SetEigenVectors(0);
00086     csh.SetEigenValues(0);
00087     csh.SetOutPH(0);
00088     csh.SetAvgDev(0);
00089     csh.SetShwStatus(0);
00090     return;
00091   }
00092 
00093   Int_t ShwStatus = 1;
00094   Double_t fVertex[3] = {0};
00095   Double_t fVtxPlane = -1;
00096   Double_t fAngle[4] = {0};
00097 
00098   Double_t *fEigenVector = new Double_t[8];
00099   fEigenVector[0]=0; fEigenVector[1]=0; fEigenVector[2]=0; fEigenVector[3]=0;
00100   fEigenVector[4]=0; fEigenVector[5]=0; fEigenVector[6]=0; fEigenVector[7]=0;
00101   Double_t *fEigenValue = new Double_t[4];
00102   fEigenValue[0]=0; fEigenValue[1]=0; fEigenValue[2]=0; fEigenValue[3]=0;
00103   Double_t *fOutPH = new Double_t[5]; //0-Rad, 1-Lon, 2-Tmax, 3-MaxPl, 4-Redo
00104   fOutPH[0]=0; fOutPH[1]=0; fOutPH[2]=0; fOutPH[3]=0; fOutPH[4]=0;
00105   Double_t *fAvgDev = new Double_t[4];
00106   fAvgDev[0]=-1.; fAvgDev[1]=-1.; fAvgDev[2]=-1.; fAvgDev[3]=-1.;
00107 
00108   Double_t fMaxPlane = -1;
00109   Double_t fMaxStrip = -1;
00110   Double_t fMinStrip = 999;
00111   Double_t fMinTime = 999999999;
00112 
00113   Int_t fIter = ac.GetInt("NIter");   
00114   Double_t fCutOff = ac.GetDouble("CutOff");
00115   Double_t fShwFrac = ac.GetDouble("ShwFrac");
00116   Double_t fPECut = ac.GetDouble("PECut");
00117   Double_t fRadCut = ac.GetDouble("RadCut");
00118 
00119   Int_t fMaxBigPlaneSep = ac.GetInt("MaxBigPlaneSep");
00120   Int_t fIsolatedPlaneCut = ac.GetInt("IsolatedPlaneCut");
00121   Int_t fNGapPlanes = ac.GetInt("NGapPlanes");
00122   Int_t fNGapStrips = ac.GetInt("NGapStrips");
00123   Double_t fMaxAvgDev = ac.GetDouble("MaxAvgDev");
00124   Double_t fMaxOffFrac = ac.GetDouble("MaxOffFrac");
00125   Double_t fAvgDevCutForLargeOutliers = ac.GetDouble("AvgDevCutForLargeOutliers");
00126   Double_t fVtxBegPlaneDiffCut = ac.GetDouble("VtxBegPlaneDiffCut");
00127   Double_t fVtxPlaneDiffCut = ac.GetDouble("VtxPlaneDiffCut");
00128   Double_t fTrkFraCut = ac.GetDouble("TrkFraCut");
00129   Double_t fUVDiffCut = ac.GetDouble("UVDiffCut");
00130   Double_t mip2gev = ac.GetDouble("Mip2GeV");
00131 
00132   MSG("ShowerEM", Msg::kVerbose) 
00133     << "Configured Quantities: " 
00134     << "NIter = " << fIter << "\n"
00135     << "CutOff = " << fCutOff << "\n"
00136     << "ShwFrac = " << fShwFrac << "\n"
00137     << "PECut = " << fPECut << "\n"
00138     << "RadCut = " << fRadCut << "\n"    
00139     << "MaxBigPlaneSep = " << fMaxBigPlaneSep << "\n"
00140     << "IsolatedPlaneCut = " << fIsolatedPlaneCut << "\n"
00141     << "NGapPlanes = " << fNGapPlanes << "\n"
00142     << "NGapStrips = " << fNGapStrips << "\n"
00143     << "MaxAvgDev = " << fMaxAvgDev << "\n"
00144     << "MaxOffFrac = " << fMaxOffFrac << "\n"
00145     << "AvgDevCutForLargeOutliers = " << fAvgDevCutForLargeOutliers << "\n"
00146     << "VtxBegPlaneDiffCut = " << fVtxBegPlaneDiffCut << "\n"
00147     << "VtxPlaneDiffCut = " << fVtxPlaneDiffCut << "\n"
00148     << "TrkFraCut = " << fTrkFraCut << "\n"
00149     << "UVDiffCut = " << fUVDiffCut << "\n"
00150     << "Mip2GeV = " << mip2gev << "\n"
00151     << endl;
00152 
00153   //important hard coded values - don't change!
00154   Double_t Ec_eff = 21.6297;
00155   Double_t X0_eff = 0.0401542;
00156   Double_t d_eff = 0.06;
00157   Double_t d = .0595;
00158   Double_t t = .0411;
00159   
00161   Int_t *plane = new Int_t[nstp];
00162   Int_t *strip = new Int_t[nstp];
00163   Double_t *ph = new Double_t[nstp];
00164   Double_t *z = new Double_t[nstp];
00165   Double_t *tpos = new Double_t[nstp];
00166   Int_t *out = new Int_t[nstp];
00167   for(Int_t i=0;i<nstp;i++) out[i] = 0; 
00168   
00169   Float_t su[2][2] = {{0}};
00170   Float_t sv[2][2] = {{0}};
00171   Int_t woutstpu = -1;
00172   Int_t woutstpv = -1;
00173   Double_t totph = 0.;
00174 
00175   CandStripHandle *usefulStrip;
00176   Int_t icnt = 0;
00177   for (Int_t i=0; i<=tary->GetLast(); i++) {
00178     TObject *tobj = tary->At(i);
00179     assert(tobj->InheritsFrom("CandClusterHandle"));
00180     CandClusterHandle *clusterhandle = dynamic_cast<CandClusterHandle*>(tobj);
00181     CandStripHandleItr stripItr(clusterhandle->GetDaughterIterator());
00182     while (CandStripHandle *stp = stripItr()) {
00183       plane[icnt] = stp->GetPlane();
00184       strip[icnt] = stp->GetStrip();
00185       ph[icnt] = calibrator.GetMIP(stp->GetCharge(CalDigitType::kSigCorr));
00186       z[icnt] = stp->GetZPos();
00187       tpos[icnt] = stp->GetTPos();
00188       if(stp->GetCharge(CalDigitType::kPE)<=fPECut) out[icnt] = 1;
00189       else totph += ph[icnt];
00190       usefulStrip = stp;
00191       icnt++;
00192     }
00193   }
00194   UgliGeomHandle ugh(*usefulStrip->GetVldContext());
00195   
00197   
00198   Int_t maxpl = -1;
00199   Double_t maxz = 0;
00200   Int_t secmaxpl = -1;
00201   Int_t maxstp = -1;
00202   Double_t maxtpos[2] = {0,0};
00203   Int_t maxplu = -1;
00204   Double_t maxzu = 0;
00205   Int_t maxstpu = 0;
00206   Double_t maxtposu = 0;
00207   Int_t begstpu = 0;
00208   //Double_t begtposu = 0;
00209   Int_t begplu = -1;
00210   Double_t begzu = 0;
00211 
00212   Int_t maxplv = -1;
00213   Double_t maxzv = 0;  
00214   Int_t maxstpv = 0;
00215   Double_t maxtposv = 0;
00216   Int_t begstpv = 0;
00217   //Double_t begtposv = 0;
00218   Int_t begplv = -1;
00219   Double_t begzv = 0;
00220   
00221   Float_t totwu = 0.;
00222   Float_t totwv = 0.;
00223   Float_t normposu = 0;
00224   Float_t normposv = 0;
00225   
00226   Double_t out2Rmphu = 1;
00227   Double_t out2Rmphv = 1;
00228   
00229   Double_t Thetau = 0;
00230   Double_t Theta_radu = 0;
00231   Double_t Thetav = 0;
00232   Double_t Theta_radv = 0;
00233   Double_t Thetau1 = 0;
00234   Double_t Theta_radu1 = 0;
00235   Double_t Thetav1 = 0;
00236   Double_t Theta_radv1 = 0;
00237 
00238   Double_t avgdevu = 0.;
00239   Double_t wavgdevu = 0.;
00240   Double_t avgdevv = 0.;
00241   Double_t wavgdevv = 0.;
00242   Double_t *evalu = new Double_t[2];
00243   Double_t *evalv = new Double_t[2];
00244   TVector2 *evu0 = new TVector2(0.,0.);
00245   TVector2 *evu1 = new TVector2(0.,0.);
00246   TVector2 *evv0 = new TVector2(0.,0.);
00247   TVector2 *evv1 = new TVector2(0.,0.);
00248   for (Int_t i = 0; i<2; i++) {
00249     evalu[i] = 0.;
00250     evalv[i] = 0.;
00251   }
00252   bool redou = false;
00253   bool redov = false;
00254   bool oncemoreu = true;
00255   bool oncemorev = true;
00256   bool remax = true;
00257   Int_t countu = 0;
00258   Int_t countv = 0;
00259   int Nu = 0;
00260   int Nv = 0;
00261   int Nu1 = 0;
00262   int Nv1 = 0;
00263   double trkfra = 0.;
00264   double uvdif = 0.;
00265   while(((out2Rmphu>fCutOff||redou||oncemoreu)&&countu<fIter)
00266         ||((out2Rmphv>fCutOff||redov||oncemorev)&&countv<fIter)){
00267     while (remax){
00268       remax = false;
00269       Double_t Eguess = totph*mip2gev;
00270       if(Eguess==0) {ShwStatus = 0; return;}
00271       Double_t tmax = log(Eguess*1000./Ec_eff)-0.858; //t_max formula
00272       Double_t tmaxpl = tmax*X0_eff/d_eff;
00273 
00274       //find max plane
00275       TH1F *flspl = new TH1F("flspl","flspl",500,-0.5,499.5);
00276       TH1F *sflspl = new TH1F("sflspl","sflspl",500,-0.5,499.5);
00277       for(Int_t i=0;i<nstp;i++){
00278         if (out[i]<=0) flspl->Fill(plane[i],ph[i]);
00279       }
00280       maxpl = Int_t(flspl->GetBinCenter(flspl->GetMaximumBin()));
00281       Int_t getz = 0;
00282       for(Int_t i=0;i<nstp;i++){
00283         if (out[i]<=0&&plane[i]!=maxpl) sflspl->Fill(plane[i],ph[i]);
00284         else if (getz<1&&out[i]<=0&&plane[i]==maxpl) {
00285           maxz = z[i];
00286           getz++;
00287         }
00288       }
00289       secmaxpl = Int_t(sflspl->GetBinCenter(sflspl->GetMaximumBin()));      
00290 
00291       if (abs(maxpl-secmaxpl)>fMaxBigPlaneSep*tmaxpl){
00292         Bool_t pos = true;
00293         Bool_t neg = true;
00294         for(Int_t i=1;i<=fIsolatedPlaneCut;i++){
00295           if(neg&&flspl->GetBinContent(flspl->FindBin(maxpl-i))<=0) neg=true;
00296           else neg=false;
00297           if(pos&&flspl->GetBinContent(flspl->FindBin(maxpl+i))<=0) pos=true;
00298           else pos=false;
00299         }
00300         if(pos||neg){
00301           for(Int_t i=0;i<nstp;i++){
00302             if (out[i]<=0&&plane[i]==maxpl) {
00303               out[i] = 4;
00304             }
00305           }
00306           remax = true; 
00307         }
00308         MSG("ShowerEM", Msg::kDebug)  << "Using second maximum: "<<maxpl
00309                                       <<" "<<secmaxpl<<" "<<tmaxpl<<endl;
00310       }
00311 
00312       delete flspl;
00313       delete sflspl;
00314 
00315       if (maxpl*secmaxpl<=0) {ShwStatus = 0; return;}
00316     }  
00317 
00318 
00319     //find boundary of primary cluster:
00320     //plane:
00321     TH1F *flspl = new TH1F("flspl","flspl",500,-0.5,499.5);
00322     for(Int_t i=0;i<nstp;i++){
00323       if (out[i]<=0) flspl->Fill(plane[i],ph[i]);
00324     }
00325     maxpl = Int_t(flspl->GetBinCenter(flspl->GetMaximumBin()));
00326     
00327     Int_t k = 0;
00328     Bool_t FoundGap = false;
00329     while(!FoundGap){
00330       Bool_t allEmpty = true;
00331       for(Int_t i=0;i<fNGapPlanes;i++){
00332         if(allEmpty&&flspl->GetBinContent(flspl->FindBin(maxpl-k-i))<=0) {
00333           allEmpty=true;
00334         }
00335         else allEmpty = false;
00336       }
00337       if(allEmpty) FoundGap=true;
00338       k++;
00339     }
00340     
00341     Int_t l = 0;
00342     FoundGap = false;
00343     while(!FoundGap){
00344       Bool_t allEmpty = true;
00345       for(Int_t i=0;i<fNGapPlanes;i++){
00346         if(allEmpty&&flspl->GetBinContent(flspl->FindBin(maxpl+l+i))<=0) {
00347           allEmpty=true;
00348         }
00349         else allEmpty = false;
00350       }
00351       if(allEmpty) FoundGap=true;
00352       l++;
00353     }
00354     
00355     for(Int_t i=0;i<nstp;i++){
00356       if (out[i]<=0&&((plane[i]<=(maxpl-k))||(plane[i]>=(maxpl+l)))) {
00357         out[i] = 2;
00358       }
00359     }
00360     delete flspl;
00361     //Int_t npl = l+k-1;
00362     
00363     //strip:
00364     Int_t stplb[2] = {200,200};
00365     Int_t stpub[2] = {0,0};
00366     Int_t maxstpa[2] = {0,0};
00367     for (Int_t j = 0; j<2; j++){
00368       double maxph[2] = {0,0};
00369       for (int pl = maxpl-k+1;pl<maxpl+l;pl++){
00370         TH1F *flsstp = new TH1F("flsstp","flsstp",201,-0.5,200.5);
00371         if(j==0&&((pl<249&&pl%2==0)||(pl>=249&&pl%2==1))){
00372           for(Int_t i=0;i<nstp;i++){
00373             if(plane[i]==pl&&out[i]<=0) flsstp->Fill(strip[i],ph[i]);
00374           }
00375         }
00376         else if (j==1&&((pl<249&&pl%2==1)||(pl>=249&&pl%2==0))){
00377           for(Int_t i=0;i<nstp;i++){
00378             if(plane[i]==pl&&out[i]<=0) flsstp->Fill(strip[i],ph[i]);
00379           }
00380         }
00381         maxstp = Int_t(flsstp->GetBinCenter(flsstp->GetMaximumBin()));
00382         if((j==0&&((pl<249&&pl%2==0)||(pl>=249&&pl%2==1)))||
00383            (j==1&&((pl<249&&pl%2==1)||(pl>=249&&pl%2==0)))){
00384           if (maxph[j] < flsstp->GetBinContent(flsstp->GetMaximumBin())){
00385           maxph[j] = flsstp->GetBinContent(flsstp->GetMaximumBin());
00386           maxstpa[j] = maxstp;
00387           }
00388         }
00389           
00390         Int_t m[2] = {0};
00391         FoundGap = false;
00392         while(!FoundGap){
00393           Bool_t allEmpty = true;
00394           for(Int_t i=0;i<fNGapStrips;i++){
00395             if(allEmpty&&flsstp->GetBinContent(flsstp->FindBin(maxstp-m[j]-i))<=0){
00396               allEmpty=true;
00397             }
00398             else allEmpty = false;
00399           }
00400           if(allEmpty) FoundGap=true;
00401           m[j]++;
00402         }
00403         
00404         Int_t n[2] = {0};
00405         FoundGap = false;
00406         while(!FoundGap){
00407           Bool_t allEmpty = true;
00408           for(Int_t i=0;i<fNGapStrips;i++){
00409             if(allEmpty&&flsstp->GetBinContent(flsstp->FindBin(maxstp+n[j]+i))<=0){
00410               allEmpty=true;
00411             }
00412             else allEmpty = false;
00413           }
00414           if(allEmpty) FoundGap=true;
00415           n[j]++;
00416         }
00417         for(Int_t i=0;i<nstp;i++){
00418           if((j==0&&((pl<249&&pl%2==0)||(pl>=249&&pl%2==1)))||
00419              (j==1&&((pl<249&&pl%2==1)||(pl>=249&&pl%2==0)))){
00420             if (plane[i]==pl&&out[i]<=0
00421                 &&((strip[i]<=(maxstp-m[j]))||(strip[i]>=(maxstp+n[j])))) {
00422               out[i] = 1;         
00423             }
00424           }
00425         }
00426         if (maxstp>0&&(maxstp-m[j])<stplb[j]) stplb[j] = maxstp-m[j];
00427         if (maxstp>0&&(maxstp+n[j])>stpub[j]) stpub[j] = maxstp+n[j];
00428         delete flsstp;
00429       }
00430     }
00431     int ctpl = 0;
00432     int ctstp[2] = {0,0};
00433     for(Int_t i=0;i<nstp;i++){
00434       if(out[i]<=0){
00435         if(plane[i]==maxpl&&ctpl<1){
00436           maxz = z[i];
00437           ctpl++;
00438         }
00439         for (int j=0; j<2; j++){
00440           if((j==0&&((plane[i]<249&&plane[i]%2==0)
00441                      ||(plane[i]>=249&&plane[i]%2==1)))||
00442              (j==1&&((plane[i]<249&&plane[i]%2==1)
00443                      ||(plane[i]>=249&&plane[i]%2==0)))){
00444             if(strip[i]==maxstpa[j]&&ctstp[j]<1){
00445               maxtpos[j] = tpos[i];
00446               ctstp[j]++;
00447             }
00448           }
00449         }
00450       }
00451     }
00452     //      MSG("ShowerEM", Msg::kDebug)  <<stplb[0]<<" "<<stplb[1]<<" "<<stpub[0]<<" "<<stpub[1]<<" "<<maxz<<" "<<maxtpos[0]<<" "<<maxtpos[1]<<endl;    
00453 
00454     //iterate over U strips
00455     while((out2Rmphu>fCutOff||redou||oncemoreu)&&countu<fIter){
00456       redou = false;
00457       oncemoreu = false;
00458       totwu = 0;
00459       countu++;
00460       if(woutstpu!=-1&&out[woutstpu]==0) out[woutstpu] = 1;
00461       else if (out[woutstpu]<0) out[woutstpu] = 5;
00462       TH1F *flsplu = new TH1F("flsplu","flsplu",500,-0.5,499.5);      
00463       TH2F *u2d = new TH2F("u2d","u2d",l+k+1,maxz-(k+0.5)*d,maxz+(l+0.5)*d,
00464                            stpub[0]-stplb[0]+1,maxtpos[0]-(maxstpa[0]-stplb[0]+0.5)*t,
00465                            maxtpos[0]+(stpub[0]-maxstpa[0]+0.5)*t);
00466       for(Int_t i=0;i<nstp;i++){
00467 
00468         if(((plane[i]<249&&plane[i]%2==0)
00469             ||(plane[i]>=249&&plane[i]%2==1))&&out[i]<=0){
00470           flsplu->Fill(plane[i],ph[i]);
00471           u2d->Fill(z[i],tpos[i],ph[i]);
00472         }
00473       }
00474       maxplu = Int_t(flsplu->GetBinCenter(flsplu->GetMaximumBin()));
00475       Int_t nplu = 0;
00476       for (Int_t pl = maxpl-k+1;pl<maxpl+l;pl++){
00477         if (flsplu->GetBinContent(flsplu->FindBin(pl))>0) nplu++;
00478       }
00479       TProfile *up = u2d->ProfileX();
00480       TF1 *p1 = new TF1("p1","pol1");
00481       up->Fit("p1","NQ");
00482       Double_t slopeu = p1->GetParameter(1);
00483       //Double_t eslopeu = p1->GetParError(1);
00484       Double_t chi2u = p1->GetChisquare();
00485       Int_t j = 0;
00486       Double_t sumb = 0.;
00487       while(sumb==0&&j<=500) {
00488         j++;
00489         if(flsplu->GetBinContent(j)>0) {
00490           begplu = Int_t(flsplu->GetBinCenter(j));
00491           sumb += flsplu->GetBinContent(j);
00492         }
00493       }
00494       
00495       delete flsplu;
00496       delete u2d;
00497       delete up;
00498       delete p1;
00499       Float_t maxstpphu = 0.;
00500       Float_t begstpphu = 0.;
00501       Int_t nstpmaxplu = 0;
00502       for(Int_t i=0;i<nstp;i++){
00503         if(out[i]<=0){
00504           if(plane[i]==maxplu&&ph[i]>maxstpphu){
00505             maxstpu = strip[i];
00506             maxstpphu = ph[i];
00507             maxtposu = tpos[i];
00508           }
00509           if(plane[i]==maxplu){
00510             maxzu = z[i];
00511             nstpmaxplu++;
00512           }
00513           if(plane[i]==begplu&&ph[i]>begstpphu){
00514             begzu = z[i];
00515             begstpu = strip[i];
00516             begstpphu = ph[i];
00517           }
00518         }
00519       }
00520       
00521       Double_t cntu = 0;
00522       for(Int_t i=0;i<nstp;i++){
00523         if(out[i]<=0){  
00524           if((plane[i]<249&&plane[i]%2==0)||(plane[i]>=249&&plane[i]%2==1)){
00525             
00526             Double_t dtpos = tpos[i] - maxtposu;
00527             Double_t dz = z[i] - maxzu;
00528             su[0][0]+=dz*dz*ph[i];
00529             su[0][1]+=dtpos*dz*ph[i];
00530             su[1][1]+=dtpos*dtpos*ph[i];
00531             totwu += ph[i];
00532             cntu+=1;
00533             normposu += dtpos*dtpos+dz*dz;
00534             
00535           }
00536         }
00537       }
00538       su[1][0]=su[0][1];
00539       
00540       if(totwu*normposu!=0){
00541         
00542         TMatrixDSym mu(2);
00543         Double_t *angu = new Double_t[2];
00544         
00545         for(Int_t i=0;i<2;i++) angu[i] = -999;
00546         for (Int_t i=0;i<2;i++){
00547           for (Int_t j=0;j<2;j++){
00548             mu(i,j)=su[i][j]/totwu/normposu;
00549           }
00550         }
00551         
00552         if(mu.IsA()){
00553           TMatrixDSymEigen eigen(mu);
00554           TMatrixD EVect1 = eigen.GetEigenVectors();      
00555           TVectorD EVal1 = eigen.GetEigenValues();
00556           evu0 = new TVector2(EVect1(0,0),EVect1(1,0));
00557           evu1 = new TVector2(EVect1(0,1),EVect1(1,1));
00558           angu[0] = evu0->Phi()*180/TMath::Pi();
00559           angu[1] = evu1->Phi()*180/TMath::Pi();
00560           evalu[0] = EVal1(0);
00561           evalu[1] = EVal1(1);
00562         }
00563         else {
00564           evalu[0] = 0.;
00565           evalu[1] = 0.;
00566         }
00567         for (Int_t i=0;i<2;i++){
00568           if (angu[i]>90&&angu[i]<270) angu[i]-=180;
00569           if (angu[i]>270&&angu[i]<360) angu[i]-=360;
00570           if (angu[i]==90||angu[i]==270) angu[i]-=0.01;
00571         }
00572 
00573         Thetau = angu[0];
00574         Thetau1 = angu[1];
00575         Theta_radu = (Thetau/180)*TMath::Pi();
00576         Theta_radu1 = (Thetau1/180)*TMath::Pi();
00577         Double_t *shwstpc = new Double_t[nstp];
00578         Double_t *shwstpc1 = new Double_t[nstp];
00579         Double_t *shwstpc2 = new Double_t[nstp];
00580         Double_t *wshwstpc = new Double_t[nstp];
00581         for(Int_t i=0;i<nstp;i++) shwstpc[i] = -1.;
00582         for(Int_t i=0;i<nstp;i++) shwstpc1[i] = -1.;
00583         for(Int_t i=0;i<nstp;i++) shwstpc2[i] = -1.;
00584         for(Int_t i=0;i<nstp;i++) wshwstpc[i] = -1.;
00585         
00586         Double_t wdevmaxu = 0.;
00587         woutstpu = -1;
00588         avgdevu = 0.;
00589         wavgdevu = 0.;
00590         Double_t avgdevu1 = 0.;
00591         Double_t avgdevu2 = 0.;
00592         Double_t wavgdevu1 = 0.;
00593         Double_t wavgdevu2 = 0.;
00594         Int_t instpu = 0;
00595         //Int_t instpu1 = 0;
00596         Double_t winstpu = 0;
00597         Float_t offstpu = 0;
00598         Float_t offstpu2 = 0;
00599         //Float_t offstpu3 = 0;
00600         out2Rmphu = 0;
00601         for(Int_t i=0;i<nstp;i++){
00602           if(out[i]<=0){
00603             if((plane[i]<249&&plane[i]%2==0)||(plane[i]>=249&&plane[i]%2==1)){
00604               shwstpc[i]=fabs(tpos[i]
00605                               -(maxtposu+tan(Theta_radu)
00606                                 *(z[i]-maxzu)))*TMath::Cos(Theta_radu);
00607               shwstpc2[i]=fabs(tpos[i]
00608                                -(maxtposu+tan(Theta_radu1)
00609                                  *(z[i]-maxzu)))*TMath::Cos(Theta_radu1);
00610               avgdevu1 += shwstpc[i];
00611               avgdevu2 += shwstpc2[i];
00612               wavgdevu1 += shwstpc[i]*ph[i];
00613               wavgdevu2 += shwstpc2[i]*ph[i];
00614               instpu++;
00615               winstpu+=ph[i];
00616               if (shwstpc[i]>1.*t) offstpu++;
00617               if (shwstpc2[i]>1.*t) offstpu2++;
00618               //              if (shwstpc2[i]>6.*t) offstpu3++;
00619             }
00620           }
00621         }
00622         avgdevu1/=instpu;
00623         avgdevu2/=instpu;
00624         wavgdevu1/=winstpu;
00625         wavgdevu2/=winstpu;
00626         avgdevu = avgdevu1;
00627         wavgdevu = wavgdevu1;
00628         offstpu/=instpu;
00629         offstpu2/=instpu;
00630         for(Int_t i=0;i<nstp;i++){
00631           if((fabs(Thetau)>fabs(Thetau1))
00632              &&((avgdevu1>fMaxAvgDev*t&&avgdevu2>fMaxAvgDev*t)
00633                 ||(offstpu>fMaxOffFrac&&offstpu2>fMaxOffFrac))
00634              &&strip[i]==maxstpu&&nstpmaxplu==1) {
00635             out[i] = 4;
00636             oncemoreu = true;
00637             MSG("ShowerEM", Msg::kDebug) <<"u maxstp removed"<<endl;
00638           }
00639         }
00640         if(fabs(tan(Theta_radu)-slopeu)>fabs(tan(Theta_radu1)-slopeu)
00641            &&(wavgdevu1>wavgdevu2/1000.||nplu==1)){
00642           Thetau = angu[1];      
00643           Thetau1 = angu[0];
00644           avgdevu = avgdevu2;
00645           wavgdevu = wavgdevu2;
00646           for(Int_t i=0;i<nstp;i++){
00647             shwstpc[i] = shwstpc2[i];
00648           }
00649         }
00650         
00651         Theta_radu = (Thetau/180)*TMath::Pi();
00652         Theta_radu1 = (Thetau1/180)*TMath::Pi();
00653         for(Int_t i=0;i<nstp;i++){
00654           if(out[i]<=0){
00655             if((plane[i]<249&&plane[i]%2==0)||(plane[i]>=249&&plane[i]%2==1)){
00656               wshwstpc[i] = shwstpc[i]*ph[i];
00657               if(shwstpc[i]>fRadCut*t) {
00658                 out2Rmphu += ph[i];
00659                 if(wshwstpc[i]>wdevmaxu){ 
00660                   wdevmaxu = wshwstpc[i];
00661                   woutstpu = i;         }
00662               }
00663             }
00664           }
00665           else if(out[i]==1){
00666             if((plane[i]<249&&plane[i]%2==0)||(plane[i]>=249&&plane[i]%2==1)){
00667               shwstpc[i] = fabs(tpos[i]-(maxtposu+tan(Theta_radu)*(z[i]-maxzu)))*TMath::Cos(Theta_radu);;
00668               wshwstpc[i] = shwstpc[i]*ph[i];
00669               if(shwstpc[i]<=fRadCut*t) {
00670                 out[i] = -1;
00671                 redou = true;
00672               }
00673             }
00674           }
00675         }
00676         MSG("ShowerEM", Msg::kDebug)  <<"avgu "<< avgdevu <<" "<< avgdevu1 
00677                                       <<" "<<avgdevu2<<" "<<wavgdevu1 <<" "
00678                                       <<wavgdevu2<<" "<<offstpu<<" "
00679                                       <<offstpu2<<" "<<tan(Theta_radu)<<" "
00680                                       <<slopeu<<" "<<chi2u<<endl;
00681         if (avgdevu>fAvgDevCutForLargeOutliers*t){
00682           for(Int_t i=0;i<nstp;i++){
00683             if(((plane[i]<249&&plane[i]%2==0)
00684                 ||(plane[i]>=249&&plane[i]%2==1))&&out[i]<=0){
00685               if((shwstpc[i]-avgdevu)>fRadCut*t) {
00686                 if (out[i]==0) out[i] = 1;  
00687                 else if (out[i]<0) out[i] = 5;
00688                 oncemoreu = true;
00689               }
00690             }
00691           }
00692         }
00693         out2Rmphu /= totwu;
00694         Nu = 0;
00695         Nu1 = 0;
00696         for (int pl = maxpl-k+1;pl<maxpl+l;pl++){
00697           int nstppl = 0;
00698           for(int i=0;i<nstp;i++){
00699             if(plane[i]==pl&&((plane[i]<249&&plane[i]%2==0)
00700                               ||(plane[i]>=249&&plane[i]%2==1))
00701                &&out[i]<=0){
00702               nstppl++;
00703             }
00704           }
00705           if (nstppl>0) Nu++; 
00706           if (nstppl==1) Nu1++; 
00707         }
00708       }
00709     }
00710     
00711     //iterate over V strips    
00712     while((out2Rmphv>fCutOff||redov||oncemorev)&&countv<fIter){
00713       redov = false;
00714       oncemorev = false;
00715       totwv = 0;
00716       countv++;
00717       if(woutstpv!=-1&&out[woutstpv]==0) out[woutstpv] = 1;
00718       else if (out[woutstpv]<0) out[woutstpv] = 5;
00719       TH1F *flsplv = new TH1F("flsplv","flsplv",500,-0.5,499.5);
00720       TH2F *v2d = new TH2F("v2d","v2d",l+k+1,maxz-(k+0.5)*d,maxz+(l+0.5)*d,
00721                            stpub[1]-stplb[1]+1,maxtpos[1]-(maxstpa[1]-stplb[1]+0.5)*t,
00722                            maxtpos[1]+(stpub[1]-maxstpa[1]+0.5)*t);
00723       for(Int_t i=0;i<nstp;i++){
00724         if(((plane[i]>=249&&plane[i]%2==0)
00725             ||(plane[i]<249&&plane[i]%2==1))&&out[i]<=0){
00726           flsplv->Fill(plane[i],ph[i]);
00727           v2d->Fill(z[i],tpos[i],ph[i]);
00728         }
00729       }
00730       maxplv = Int_t(flsplv->GetBinCenter(flsplv->GetMaximumBin()));
00731       Int_t nplv = 0;
00732       for (Int_t pl = maxpl-k+1;pl<maxpl+l;pl++){
00733         if (flsplv->GetBinContent(flsplv->FindBin(pl))>0) nplv++;
00734       }
00735       TProfile *vp = v2d->ProfileX();
00736       TF1 *p1 = new TF1("p1","pol1");      
00737       vp->Fit("p1","NQ");
00738       Double_t slopev = p1->GetParameter(1);      
00739       //Double_t eslopev = p1->GetParError(1);      
00740       Double_t chi2v = p1->GetChisquare();
00741       Int_t j = 0;
00742       Double_t sumb = 0.; 
00743       while (sumb==0&&j<=500) {
00744         j++;
00745         if(flsplv->GetBinContent(j)>0) {
00746           begplv = Int_t(flsplv->GetBinCenter(j));
00747           sumb += flsplv->GetBinContent(j);
00748         }
00749       }
00750       delete flsplv;
00751       delete v2d;
00752       delete vp;
00753       delete p1;
00754       Float_t maxstpphv = 0.;
00755       Float_t begstpphv = 0.;
00756       Int_t nstpmaxplv = 0;
00757       for(Int_t i=0;i<nstp;i++){
00758         if(out[i]<=0){
00759           if(plane[i]==maxplv&&ph[i]>maxstpphv){
00760             maxstpv = strip[i];
00761             maxstpphv = ph[i];
00762             maxtposv = tpos[i];
00763           }
00764           if(plane[i]==maxplv){
00765             maxzv = z[i];
00766             nstpmaxplv++;
00767           }
00768           if (plane[i]==begplv&&ph[i]>begstpphv){
00769             begzv = z[i];
00770             begstpv = strip[i];
00771             begstpphv = ph[i];
00772           }
00773         }
00774       }
00775       
00776       Double_t cntv = 0;
00777       for(Int_t i=0;i<nstp;i++){
00778         if(out[i]<=0){
00779           if ((plane[i]>=249&&plane[i]%2==0)||(plane[i]<249&&plane[i]%2==1)){
00780             Double_t dtpos = tpos[i] - maxtposv;
00781             Double_t dz = z[i] - maxzv;
00782             sv[0][0]+=dz*dz*ph[i];
00783             sv[0][1]+=dtpos*dz*ph[i];
00784             sv[1][1]+=dtpos*dtpos*ph[i];
00785             totwv += ph[i];
00786             cntv+=1;
00787             normposv += dtpos*dtpos+dz*dz;
00788           }
00789         }
00790       }
00791       sv[1][0]=sv[0][1];
00792 
00793       if(totwv*normposv!=0){
00794         TMatrixDSym mv(2);
00795         Double_t *angv = new Double_t[2];
00796         
00797         for(Int_t i=0;i<2;i++) angv[i] = -999;
00798         for (Int_t i=0;i<2;i++){
00799           for (Int_t j=0;j<2;j++){
00800             mv(i,j)=sv[i][j]/totwv/normposv;
00801           }
00802         }
00803         
00804         if(mv.IsA()){
00805           TMatrixDSymEigen eigen(mv);
00806           TMatrixD EVect2 = eigen.GetEigenVectors();
00807           TVectorD EVal2 = eigen.GetEigenValues();      
00808           evv0 = new TVector2(EVect2(0,0),EVect2(1,0));
00809           evv1 = new TVector2(EVect2(0,1),EVect2(1,1));
00810           angv[0] = evv0->Phi()*180/TMath::Pi();
00811           angv[1] = evv1->Phi()*180/TMath::Pi();
00812           evalv[0] = EVal2(0);
00813           evalv[1] = EVal2(1);
00814         }
00815         else {
00816           evalv[0] = 0.;
00817           evalv[1] = 0.;
00818         }   
00819         for (Int_t i=0;i<2;i++){
00820           if (angv[i]>90&&angv[i]<270) angv[i]-=180;
00821           if (angv[i]>270&&angv[i]<360) angv[i]-=360;
00822           if (angv[i]==90||angv[i]==270) angv[i]-=0.01;
00823         }
00824         
00825         Thetav = angv[0];
00826         Thetav1 = angv[1];
00827         Theta_radv = (Thetav/180)*TMath::Pi();
00828         Theta_radv1 = (Thetav1/180)*TMath::Pi();
00829         Double_t *shwstpc = new Double_t[nstp];
00830         Double_t *shwstpc1 = new Double_t[nstp];
00831         Double_t *shwstpc2 = new Double_t[nstp];
00832         Double_t *wshwstpc = new Double_t[nstp];
00833         for(Int_t i=0;i<nstp;i++) shwstpc[i] = -1.;
00834         for(Int_t i=0;i<nstp;i++) shwstpc1[i] = -1.;
00835         for(Int_t i=0;i<nstp;i++) shwstpc2[i] = -1.;
00836         for(Int_t i=0;i<nstp;i++) wshwstpc[i] = -1.;
00837         
00838         Double_t wdevmaxv = 0.;
00839         woutstpv = -1;
00840         avgdevv = 0.;
00841         wavgdevv = 0.;
00842         Double_t avgdevv1 = 0.;
00843         Double_t avgdevv2 = 0.;
00844         Double_t wavgdevv1 = 0.;
00845         Double_t wavgdevv2 = 0.;
00846         Int_t instpv = 0;
00847         //Int_t instpv1 = 0;
00848         Double_t winstpv = 0;
00849         Float_t offstpv = 0;
00850         Float_t offstpv2 = 0;
00851         //      Float_t offstpv3 = 0;
00852         out2Rmphv = 0;
00853         for(Int_t i=0;i<nstp;i++){
00854           if(out[i]<=0){
00855             if((plane[i]<249&&plane[i]%2==1)||(plane[i]>=249&&plane[i]%2==0)){
00856               shwstpc[i]=fabs(tpos[i]
00857                               -(maxtposv+tan(Theta_radv)
00858                                 *(z[i]-maxzv)))*TMath::Cos(Theta_radv);
00859               shwstpc2[i]=fabs(tpos[i]
00860                                -(maxtposv+tan(Theta_radv1)
00861                                  *(z[i]-maxzv)))*TMath::Cos(Theta_radv1);
00862               avgdevv1 += shwstpc[i];
00863               avgdevv2 += shwstpc2[i];
00864               wavgdevv1 += shwstpc[i]*ph[i];
00865               wavgdevv2 += shwstpc2[i]*ph[i];
00866               instpv++;
00867               winstpv+=ph[i];
00868               if (shwstpc[i]>1) offstpv++;
00869               if (shwstpc2[i]>1) offstpv2++;
00870               //              if (shwstpc2[i]>6) offstpv3++;
00871             }
00872           }
00873         }
00874         avgdevv1/=instpv;
00875         avgdevv2/=instpv;
00876         wavgdevv1/=winstpv;
00877         wavgdevv2/=winstpv;
00878         avgdevv = avgdevv1;
00879         wavgdevv = wavgdevv1;
00880         offstpv/=instpv;
00881         offstpv2/=instpv;
00882         for(Int_t i=0;i<nstp;i++){
00883           if ((fabs(Thetav)>fabs(Thetav1))
00884               &&((avgdevv1>fMaxAvgDev*t&&avgdevv2>fMaxAvgDev*t)
00885                  ||(offstpv>fMaxOffFrac&&offstpv2>fMaxOffFrac))
00886               &&strip[i]==maxstpv&&nstpmaxplv==1) {
00887             out[i] = 4;
00888             oncemorev = true;
00889             MSG("ShowerEM", Msg::kDebug) <<"v maxstp removed"<<endl;
00890           }
00891         }
00892         if(fabs(tan(Theta_radv)-slopev)>fabs(tan(Theta_radv1)-slopev)
00893            &&(wavgdevv1>wavgdevv2/1000.||nplv==1)){
00894           Thetav = angv[1];      
00895           Thetav1 = angv[0];
00896           avgdevv = avgdevv2;
00897           wavgdevv = wavgdevv2;
00898           for(Int_t i=0;i<nstp;i++){
00899             shwstpc[i] = shwstpc2[i];
00900           }
00901         }
00902         
00903         Theta_radv = (Thetav/180)*TMath::Pi();
00904         Theta_radv1 = (Thetav1/180)*TMath::Pi();
00905 
00906         for(Int_t i=0;i<nstp;i++){
00907           if(out[i]<=0){
00908             if((plane[i]<249&&plane[i]%2==1)||(plane[i]>=249&&plane[i]%2==0)){
00909               wshwstpc[i] = shwstpc[i]*ph[i];
00910               if(shwstpc[i]>fRadCut*t) {
00911                 out2Rmphv += ph[i];
00912                 if(wshwstpc[i]>wdevmaxv){ 
00913                   wdevmaxv = wshwstpc[i];
00914                   woutstpv = i;         }
00915               }
00916             }
00917           }
00918           else if(out[i]==1){
00919             if((plane[i]<249&&plane[i]%2==1)||(plane[i]>=249&&plane[i]%2==0)){
00920               shwstpc[i] = fabs(tpos[i]-(maxtposv+tan(Theta_radv)*(z[i]-maxzv)))*TMath::Cos(Theta_radv);;
00921               wshwstpc[i] = shwstpc[i]*ph[i];
00922               if(shwstpc[i]<=fRadCut*t) {
00923                 out[i] = -1;
00924                 redov = true;
00925               }
00926             }
00927           }
00928         }
00929         MSG("ShowerEM", Msg::kDebug)  <<"avgv "<< avgdevv <<" "<<avgdevv1 
00930                                       <<" "<<avgdevv2<<" "<<wavgdevv1 <<" "
00931                                       <<wavgdevv2<<" "<<offstpv<<" "
00932                                       <<offstpv2<<" "<<tan(Theta_radv)<<" "
00933                                       <<slopev<<" "<<chi2v<<endl;
00934         if (avgdevv>fAvgDevCutForLargeOutliers*t){
00935           for(Int_t i=0;i<nstp;i++){
00936             if(((plane[i]<249&&plane[i]%2==1)
00937                 ||(plane[i]>=249&&plane[i]%2==0))&&out[i]<=0){
00938               if((shwstpc[i]-avgdevv)>fRadCut*t) {
00939                 if (out[i]==0) out[i] = 1;  
00940                 else if (out[i]<0) out[i] = 5;
00941                 oncemorev = true;
00942               }
00943             }
00944           }
00945         }
00946         out2Rmphv /= totwv;
00947         Nv = 0;
00948         Nv1 = 0;
00949         for (int pl = maxpl-k+1;pl<maxpl+l;pl++){
00950           int nstppl = 0;
00951           for(int i=0;i<nstp;i++){
00952             if(plane[i]==pl&&((plane[i]<249&&plane[i]%2==1)
00953                               ||(plane[i]>=249&&plane[i]%2==0))
00954                &&out[i]<=0){
00955               nstppl++;
00956             }
00957           }
00958           if (nstppl>0) Nv++; 
00959           if (nstppl==1) Nv1++; 
00960         }       
00961       }
00962     }
00963     if ((Nu+Nv)>0){
00964       trkfra = double(Nu1+Nv1)/double(Nu+Nv);
00965       uvdif = double(abs(Nu-Nv))/double(Nu+Nv);
00966     }
00967     else {
00968       trkfra = -1;
00969       uvdif = -1;
00970     }
00971     Double_t shwfra = (totwu+totwv)/totph;
00972     
00973     if(totwu*totwv==0||shwfra<fShwFrac||(countu==fIter&&out2Rmphu>fCutOff)
00974        ||(countv==fIter&&out2Rmphv>fCutOff)) ShwStatus = 0;
00975     if(ShwStatus==0) return;
00976 
00977     if (trkfra>fTrkFraCut) ShwStatus = 2;
00978     if (uvdif>fUVDiffCut) ShwStatus = 3;  
00979   
00980     Double_t Eguess = (totwu+totwv)*mip2gev;
00981     if(Eguess==0) {ShwStatus = 0; return;}
00982     Double_t tmax = log(Eguess*1000./Ec_eff)-0.858;
00983     Double_t tmaxz = tmax*X0_eff;
00984     
00985     Double_t begz = begzv;
00986     Double_t begpl = begplv;
00987     if(begzu<begzv) {
00988       begz = begzu;
00989       begpl = begplu;
00990     }
00991     Double_t vtxz = maxz-tmaxz/sqrt(TMath::Power(tan(Theta_radu),2)+TMath::Power(tan(Theta_radv),2)+1.);
00992 
00993     MSG("ShowerEM", Msg::kDebug) <<shwfra<<" "<<Eguess<<" "<<tmaxz<<" "
00994                                  <<vtxz<<" "<<begz<<" "<<maxz<<endl;
00995     
00996     if ((vtxz-begz)<=fVtxBegPlaneDiffCut*d) {
00997       fVertex[2] = begz;
00998       fVtxPlane = begpl;
00999     }
01000     else {
01001       fVertex[2] = vtxz;
01002       fVtxPlane = begpl+(vtxz-begz)/d;
01003       for(Int_t i=0;i<nstp;i++){
01004         if(((z[i]-vtxz)<-fVtxPlaneDiffCut*d)
01005            &&((plane[i]<249&&plane[i]%2==0)
01006               ||(plane[i]>=249&&plane[i]%2==1))
01007            &&out[i]<=0) {
01008           out[i] = 3;
01009           oncemoreu = true;
01010         }
01011         else if(((z[i]-vtxz)<-fVtxPlaneDiffCut*d)
01012                 &&((plane[i]<249&&plane[i]%2==1)
01013                    ||(plane[i]>=249&&plane[i]%2==0))
01014                 &&out[i]<=0) {
01015           out[i] = 3;
01016           oncemorev = true;
01017         }
01018       }
01019     }
01020   }
01021 
01022   fVertex[0] = maxtposu+tan(Theta_radu)*(fVertex[2]-maxzu);
01023   fVertex[1] = maxtposv+tan(Theta_radv)*(fVertex[2]-maxzv);
01024   fAngle[0] = Theta_radu;
01025   fAngle[1] = Theta_radv;
01026   fAngle[2] = Theta_radu1;
01027   fAngle[3] = Theta_radv1;
01028   fEigenValue[0] = evalu[0];
01029   fEigenValue[1] = evalv[0];
01030   fEigenValue[2] = evalu[1];
01031   fEigenValue[3] = evalv[1];
01032   fAvgDev[0] = avgdevu;
01033   fAvgDev[1] = avgdevv;
01034   fAvgDev[2] = wavgdevu;
01035   fAvgDev[3] = wavgdevv;
01036   fEigenVector[0] = evu0->X();
01037   fEigenVector[1] = evu0->Y();
01038   fEigenVector[2] = evv0->X();
01039   fEigenVector[3] = evv0->Y();
01040   fEigenVector[4] = evu1->X();
01041   fEigenVector[5] = evu1->Y();
01042   fEigenVector[6] = evv1->X();
01043   fEigenVector[7] = evv1->Y();
01044 
01045   icnt = 0;
01046   Int_t jcnt = 0;
01047 
01048   for (Int_t i=0; i<=tary->GetLast(); i++) {
01049     TObject *tobj = tary->At(i);
01050     assert(tobj->InheritsFrom("CandClusterHandle"));
01051     CandClusterHandle *clusterhandle = dynamic_cast<CandClusterHandle*>(tobj);
01052     CandStripHandleItr stripItr(clusterhandle->GetDaughterIterator());
01053     while (CandStripHandle *stp = stripItr()) {
01054       if(out[icnt]<=0){
01055         //get min/max number of strips
01056         if(stp->GetStrip()>fMaxStrip) fMaxStrip = stp->GetStrip();
01057         if(stp->GetStrip()<fMinStrip) fMinStrip = stp->GetStrip();
01058         if(stp->GetPlane()>fMaxPlane) fMaxPlane = stp->GetPlane();
01059         //find minimum strip time at vertex plane
01060         PlexStripEndId stripid = stp->GetStripEndId();
01061         if(stp->GetPlane()==int(fVtxPlane+0.5)){
01062           if(stp->GetTime()<fMinTime) fMinTime = stp->GetTime();
01063         }
01064         csh.AddDaughterLink(*stp);
01065         jcnt++;
01066       }
01067       else{
01068         fOutPH[out[icnt]-1] += calibrator.
01069           GetMIP(stp->GetCharge(CalDigitType::kSigCorr));
01070       }
01071       icnt++;
01072     }
01073     csh.AddCluster(clusterhandle);
01074   }
01075   
01076   csh.SetVtxPlane(int(fVtxPlane+0.5));
01077   csh.SetVtxZ(fVertex[2]);  
01078   csh.SetVtxU(fVertex[0]);
01079   csh.SetVtxV(fVertex[1]);
01080   csh.SetVtxT(fMinTime);
01081 
01082   double dudz = TMath::Tan(fAngle[0]);
01083   double dvdz = TMath::Tan(fAngle[1]);
01084   double dsdz = sqrt(dudz*dudz + dvdz*dvdz + 1.);
01085   csh.SetDirCosU(dudz/dsdz);
01086   csh.SetDirCosV(dvdz/dsdz);
01087   csh.SetDirCosZ(1./dsdz);
01088 
01089   csh.SetEigenVectors(fEigenVector);
01090   csh.SetEigenValues(fEigenValue);
01091   csh.SetAvgDev(fAvgDev);  
01092   csh.SetOutPH(fOutPH);
01093   csh.SetShwStatus(ShwStatus);
01094 
01095   //SetUV(&csh);
01096   Calibrate(&csh);
01097 
01098   Double_t TotMip = csh.GetCharge(CalStripType::kMIP);
01099   Double_t TotEnergy = csh.GetCharge(CalStripType::kGeV);
01100 
01101   MSG("ShowerEM", Msg::kVerbose) << endl
01102                                  << " TotMIP = " << TotMip
01103                                  << endl << "Setting shower energy to " 
01104                                  << TotEnergy << endl;
01105   
01106   csh.SetEnergy(TotEnergy);
01107   
01108 }

void AlgShowerEM::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 1111 of file AlgShowerEM.cxx.

01112 {
01113 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 1 15:55:27 2007 for loon by  doxygen 1.3.9.1