FlyoDoc_2011 Pisa 2011 by GmP --- 011

flyopunta/src/src_uti48/flyline.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Giuseppe Pierazzini          Pisa 20.02.05      *
00003  *   pierazzini@unipi.it                                                   * 
00004  *                                     F l y o                             *
00005  *   Epsi/NA48                                                             *
00006  ***************************************************************************/
00007 #include <math.h>
00008 #include "flyoh.h"
00009 
00010 //using namespace std;
00011 
00012 // track finder for one  spectrometer NA48 apparatus
00013 
00014 Flyline::Flyline()
00015 {
00016   // per il momento si pensa anche al nuovo esperimento??? kpivv
00017   Title= " Ricostruzione delle tracce: nuova procedura base";
00018   Gout<<"\n"<<Title;
00019   First_trk=0;
00020   Tot_trk=0;   //totale di particelle ricostruite
00021   Totrac=0;
00022   for(int i=0;i<5;i++)
00023     {
00024       index[i]=0;
00025       xct[i]=yct[i]=zct[i]=vxt[i]=vyt[i]=vzt[i]=0.0;
00026       chiq[i]=ptrk[i]=charge[i]=0.0;
00027     }
00028 
00029   mas_pip=ptr_Pip->Get_Massa();
00030   // campo magnetico supposto lungo y di segno Bsegno..
00031   Bsegno1=Bsegno2=1.;
00032   kick1=kick2=0.0;
00033 
00034   if(Mag48!=0)   // esperimenti apparato vecchio
00035     {
00036       if(Mag48->Get_Field()[1]<0.)
00037         Bsegno1=-1.;  //fix the magnetic  field segno respect to Y axis
00038       kick1=Mag48->Get_Kik();
00039       Gout<<"\n B  Mag48 "<<Mag48->Get_Field()[1]<<"   segno  "<<Bsegno1<<"  kick "<< kick1;
00040     }
00041   else if(mnp1!=0&&mnp2!=0)  // apparato nuovo a 6 camere
00042     {
00043       if(mnp1->Get_Field()[1]<0.)
00044         Bsegno1=-1.;  //fix the magnetic  field segno respect to Y axis
00045       kick1=mnp1->Get_Kik();
00046       if(mnp2->Get_Field()[1]<0.)
00047         Bsegno2=-1.;  //fix the magnetic  field segno respect to Y axis
00048       kick2=mnp2->Get_Kik();
00049       Gout<<"\n B  mnp1 "<<mnp1->Get_Field()[1]<<"   segno  "<<Bsegno1<<"  kick "<< kick1;
00050       Gout<<"\n B  mnp2 "<<mnp2->Get_Field()[1]<<"   segno  "<<Bsegno2<<"  kick "<< kick2;
00051     }
00052   else
00053     {
00054       Gout<<" Field and kik error ... seen flyline.cpp  ... exit"<<std::endl;
00055       exit(0);
00056     }
00057 
00058 }
00059 Flyline::~Flyline()
00060 {}
00061 
00062 void  Flyline::Get_Hits_from_Dev()
00063 {
00064   // procedure to get hits from the chamber.
00065   // It is general for four or three chambers...
00066   // the hits in dev coordinates are stored in xhit vectors
00067   // Gout<<"\n Ev: "<< evento_.Event<<"  "<<"Estraggo le coordinate dalle camere...";
00068   int i;
00069   // remeber : no hit nhit=-1;
00070   nhit1=nhit2=nhit3=nhit4=nhit5=nhit6=-1;
00071 
00072   if(Cam1!=0)
00073     {
00074       nhit1=Cam1->nhit;
00075       for(i=0;i<nhit1+1;i++)
00076         xhit1[i]=Cam1->M_Hits[i].Xlab;
00077     }
00078   if(Cam2!=0)
00079     {
00080       nhit2=Cam2->nhit;
00081       for(i=0;i<nhit2+1;i++)
00082         xhit2[i]=Cam2->M_Hits[i].Xlab;
00083     }
00084   if(Cam3!=0)
00085     {
00086       nhit3=Cam3->nhit;
00087       for(i=0;i<nhit3+1;i++)
00088         xhit3[i]=Cam3->M_Hits[i].Xlab;
00089     }
00090   if(Cam4!=0)
00091     {
00092       nhit4=Cam4->nhit;
00093       for(i=0;i<nhit4+1;i++)
00094         xhit4[i]=Cam4->M_Hits[i].Xlab;
00095     }
00096  
00097  //  Gout<<"\n Ev "<<evento_.Event<<"  Cordinate raccolte..."<<
00098  //        nhit1<<" "<<nhit2<<" "<<nhit3<<" "<<nhit4<<" "<<nhit5<<" "<<nhit6;
00099 }
00100 void Flyline::Find_Tracce()
00101 {
00102   Tracc[0]->Reset();
00103   Tracc[1]->Reset();
00104   Tracc[2]->Reset();
00105   Tracc[3]->Reset();
00106   Tracc[4]->Reset();
00107   Tracc[5]->Reset();
00108 
00109 
00110 
00111   // get out if some important chamber has not hits....
00112   Tot_trk=-1;
00113   i5=i6=0;
00114   Tot_Charge=0.;
00115   Totrac=0;
00116   if( nhit1<0||nhit2<0)
00117     return;
00118   if( nhit3<0||nhit4<0)
00119     return;
00120 
00121   for(int i=0;i<6;i++)
00122     {
00123       for(int j=0;j<10;j++)
00124         {
00125           used_trk[i][j]=0;
00126         }
00127     }
00128 
00129   // find the tracks... max 3
00130   for(int trk=0;trk<6;trk++)
00131     {
00132       Iter_trk=0;
00133       TrkNata=0;
00134       chiqlast=300.;   // Chiq trk cut : to be tuned.
00135       //  Gout<<"\n Ev "<<evento_.Event<<"  ===================    track finding  "<<trk+1<<
00136       //       "  === <"<<nhit1<<nhit2<<nhit3<<nhit4<<"> ===========";
00137       // loop to find the tracks...
00138       //for(i1=nhit1;i1>=-1;i1--)   // attenzione i1==-1 accepted to fake a lack of hit..
00139       // {if(i1>-1){if(used_trk[0][i1]>0)continue;    // puo' mancare for I1==nhit1
00140 
00141       for(i1=nhit1;i1>-1;i1--)
00142         {
00143           if(used_trk[0][i1]>0)
00144             continue;
00145           y1=xhit1[i1][1];
00146           z1=xhit1[i1][2];
00147           for(i2=nhit2;i2>-1;i2--)
00148             {
00149               if(used_trk[1][i2]>0)
00150                 continue;         // non puo' mancare???
00151               y2=xhit2[i2][1];
00152               z2=xhit2[i2][2];
00153               for(i3=nhit3;i3>-1;i3--)
00154                 {
00155                   if(used_trk[2][i3]>0)
00156                     continue;       // non puo' mancare in kpivv experimento
00157                   y3=xhit3[i3][1];
00158                   z3=xhit3[i3][2];
00159                   for(i4=nhit4;i4>-1;i4--)
00160                     {
00161                       if(used_trk[3][i4]>0)
00162                         continue;      // non puo' mancare
00163                       y4=xhit4[i4][1];
00164                       z4=xhit4[i4][2];
00165 
00166                       double mtg=(y4-y1)/(z4-z1);
00167                       //        double dy1 = y1-y1-mtg*(z1-z1);
00168                       double dy2 = y2-y1-mtg*(z2-z1);
00169                       double dy3 = y3-y1-mtg*(z3-z1);
00170                       //        double dy4 = y4-y1-mtg*(z4-z1);
00171 
00172                       chiq_ora=(dy2*dy2+dy3*dy3)*1700.;
00173 
00174                       
00175 
00176                       Iter_trk++;
00177                       if(chiq_ora<chiqlast)    //chiq good.. save hits...
00178                         { chiqlast=chiq_ora;
00179                           Save_Traccia();
00180                           TrkNata=1;
00181                           if(chiq_ora<15.)
00182                             {
00183                               TrkNata=10;
00184                               break;
00185                             }
00186                         }
00187 
00188                     }
00189                   if(TrkNata==10)
00190                     break;
00191                 }
00192               if(TrkNata==10)
00193                 break;
00194             }
00195           if(TrkNata==10)
00196             break;
00197         }
00198       // }}
00199       if( TrkNata==0)
00200         break;
00201       Tot_trk++;
00202 
00203       used_trk[0][isv1]=1;
00204       used_trk[1][isv2]=1;
00205       used_trk[2][isv3]=1;
00206       used_trk[3][isv4]=1;
00207 
00208       Tracc[Tot_trk]->Get_Traccia();
00209       if(Tot_trk>4)
00210         break;
00211     }
00212   Totrac=Tot_trk+1;
00213 }
00214 
00215 void Flyline::Save_Traccia()
00216 {
00217   isv1=i1;
00218   isv2=i2;
00219   isv3=i3;
00220   isv4=i4;
00221   isv5=i5;
00222   isv6=i6;
00223   IterSav=Iter_trk;
00224   chiqsav=chiq_ora;
00225   indexsav=i6*100000+i5*10000+i4*1000+i3*100+i2*10+i1;
00226 
00227   //  Gout<<"\n Selected: "<<" "<<isv1<<" "<<isv2<<" "<<isv3<<" "<<isv4<< setprecision(4)<<fixed<<
00228   //    "  chiqsav "<<chiqsav<<endl;
00229 }
00230 
 All Classes Namespaces Files Functions Variables