FlyoDoc_2011 Pisa 2011 by GmP --- 011
|
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 00008 #include "parm.h" 00009 #include "part_db.h" 00010 #include "apparato.h" 00011 #include "particella.h" 00012 #include "evento.h" 00013 00014 using namespace std; 00015 00016 00017 00018 00019 00020 00021 // attenzione Tet è passato come reference pointer... 00022 void Strawlib ( string Dir,string Nomef,double *&Tet, double **&Prob ); 00023 00024 00026 00027 DevStraw::DevStraw() : DevRtRt() 00028 { 00029 devtype=TypDevStraw; 00030 devclass="Straw Chamber"; 00031 Gout<<"\n\n < "<<nome <<" > Dev Id "<<idev<<" Device type <"<<devclass<<"> typ "<<devtype; 00032 static DevStraw *laststraw = 0; 00033 if ( laststraw== 0 ) FirstStraw=this; 00034 else laststraw->nextstraw = this; // linking 00035 upstraw=laststraw; 00036 laststraw = this; 00037 this->nextstraw = 0; // end linking 00038 00039 for (int i=0;i<16;i++) { 00040 Wirecoor[i]=Wiredtim[i]=Wiret0tim[i]=Wiredtempo[i]=Wiret0stim[i]=0.; 00041 }; 00042 00043 // attenzione questa istruzione va corretta a seconda del path...da aggiustare 00044 // char *Direttor={"../../mslibrary"}; 00045 string Direttor= "../../mslibrary"; 00046 00047 Gout<<"\n Multiple Scattering data for dev "<< nome; 00048 00049 if ( StrTetPip!=0 ) Gout<<" allready done."; 00050 else 00051 { 00052 00053 Strawlib ( Direttor,string("pionplus"),StrTetPip, StrProbPip ); 00054 Strawlib ( Direttor,string("muon" ), StrTetMup, StrProbMup ); 00055 Strawlib ( Direttor,string("positron"),StrTetElep,StrProbElep ); 00056 00057 00058 /* for ( int i=0;i<1200;i++ ) 00059 { 00060 Gout<<"\n "<<i<<" " <<StrProbPip[10][i]<<" " <<StrProbPip[40][i]<<" " <<StrProbPip[70][i]; 00061 } 00062 */ 00063 00064 } 00065 tubiseen=0; 00066 // test of this particular measured buffer dimension 00067 int dim= working_buffer; 00068 if (dim<MemoryBuffer) 00069 { 00070 dim=MemoryBuffer; 00071 Gout<<"\n In device ** "<<nome <<" ** measur_buffer adjusted to ==> "<<dim; 00072 } 00073 00074 00075 } 00076 00077 00078 DevStraw::~DevStraw() 00079 { 00080 } 00081 00082 void DevStraw::Prgeom() 00083 { 00084 00085 Gout<<"================== R i v e l a t o r e ================="; 00086 Gout<<"\n --> < "<<nome <<" > [ "<<fun 00087 <<" ] Straw chamber rettangolari "<<std::endl; 00088 Device::Prgeom(); 00089 } 00090 00091 00092 int DevStraw::Mscatter ( Particella * pr, double tratok ) 00093 { 00094 //------------------------------------------------- 00095 // M S C A T T E R 00096 //------------------------------------------------- 00097 00098 // ======= Multiple Scattering Routine ===== 00099 // at t e n z i o n e ... aggiustare per magnete e sfera!!! 00100 00101 00102 if (Scatter==0) return 0; // no multiple scattering required 00103 lrad=nowpos?lradb:lradi; 00104 00105 if (lrad <= 0.0 || // no multiscat. 00106 pr->charg == 0.0 || // no charge 00107 tratok < 0.001 ) // no crossed space 00108 return 0; 00109 //=============================== 00110 qvet Pprev; 00111 double randx,randy; 00112 int libMom,jbin,passx,passy; 00113 double libProb,dthx,dthy; 00114 int pplus,positron,muon; 00115 00116 00117 if ( pr->P.norma<=6. || pr->P.norma>65. ) { 00118 return Device::Mscatter ( pr,tratok ); 00119 } 00120 00121 if ( pr->Get_Nome() !=Pip && pr->Get_Nome() !=Elep && pr->Get_Nome() !=Mup ) 00122 { 00123 return Device::Mscatter ( pr,tratok ); 00124 } 00125 00127 00128 // Multiple Scattering library implementation 00129 // No gaussian multiple scattering for Pip,Elep,and Mup 00130 00131 // Define type of particle 00132 pplus = positron = muon = 0; 00133 if ( !strcmp ( pr->Get_Nome(),"pip" ) ) pplus = 1; 00134 if ( !strcmp ( pr->Get_Nome(),"elep" ) ) positron = 1; 00135 if ( !strcmp ( pr->Get_Nome(),"mup" ) ) muon = 1; 00136 00137 00138 // Smear the coordinate according to the MSlib 00139 libProb = 0; 00140 passx = passy = 0; 00141 dthx = dthy = 0; 00142 randx = Pran(); 00143 randy = Pran(); 00144 libMom = ( int ) pr->P.norma; 00145 for ( jbin=0;jbin<1200;jbin++ ) 00146 { 00147 if ( pplus ) libProb = StrProbPip[libMom][jbin]; 00148 if ( positron ) libProb = StrProbElep[libMom][jbin]; 00149 if ( muon ) libProb = StrProbMup[libMom][jbin]; 00150 // libProb = libMSProb[libMom][jbin]; 00151 if ( !passx && libProb>randx ) 00152 { 00153 if ( pplus ) dthx = StrTetPip[jbin]; 00154 if ( positron ) dthx = StrTetElep[jbin]; 00155 if ( muon ) dthx = StrTetMup[jbin]; 00156 // dthx = msTheta[jbin]; 00157 passx = 1; 00158 } 00159 if ( !passy && libProb>randy ) 00160 { 00161 if ( pplus ) dthy = StrTetPip[jbin]; 00162 if ( positron ) dthy = StrTetElep[jbin]; 00163 if ( muon ) dthy = StrTetMup[jbin]; 00164 // dthy = msTheta[jbin]; 00165 passy = 1; 00166 } 00167 } 00168 // cout << dthx << " " << dthy << endl; 00169 pr->P.x += pr->P.norma*dthx; 00170 pr->P.y += pr->P.norma*dthy; 00171 pr->Vers=pr->P.Verso(); 00172 00173 //------------------------------------------------- 00174 // D e g r a d o 00175 00176 // ======= Multiple Scattering energy loss ===== 00177 00178 // do nothing if .... 00179 if ( Perdita ==0 ) return 0; // no loss 00180 00181 if ( nowpos==0 ) { 00182 Ro=Roint; 00183 Dedx=Dedxint; 00184 } 00185 else if ( nowpos==-1 ) { 00186 Ro=Robuc; 00187 Dedx=Dedxbuc; 00188 } 00189 else return 0; 00190 00191 if ( Ro == 0.0 ) return 0; // no densita' 00192 if ( Dedx == 0.0 ) return 0; // no Dedx 00193 00194 // p=Puls.norma; 00195 double p=0.; 00196 double persa=0.0; 00197 persa= Dedx*tratok; //in GeV 00198 double ee=pr->P.e; 00199 if ( persa>= ( ee-pr->massa ) ) 00200 { 00201 persa=ee-pr->massa; 00202 p=0.0; 00203 ee=pr->massa; 00204 } 00205 else 00206 { 00207 ee-=persa; 00208 p = sqrt ( ee*ee - pr->massa*pr->massa ); 00209 } 00210 00211 00212 gvet Pscat=pr->Vers*p; 00213 pr->P.x=Pscat.x; 00214 pr->P.y=Pscat.y; 00215 pr->P.z=Pscat.z; 00216 pr->P.z = ee; 00217 pr->P.Norma(); 00218 if ( Debugon==1 ) 00219 Gout<<" de="<<setw ( 6 ) <<persa<<" P "<<setw ( 6 ) <<pr->P.norma; 00220 00221 // Gout<<"\n Msc "<<pr->nome<<" gnhit "<< gnhit<<" ghcir "<<ghcir; 00222 if ( rivela==0 ) Hits[nhit].e_rivela+=persa; // attenzione nello hit generato... 00223 return 0; 00224 } 00226 00227 00228 00233 void Strawlib ( string Dir,string Nomef,double * &Tet, double **&Prob ) 00234 { 00235 00236 // Dir = cartella dei dati 00237 // Nomef = nemo base dei nomi: pionplus, positron, muon. 00238 // Tet puntatore agli angoli 00239 // puntatore alla Prob 00240 00241 if ( Tet!=0 ) //nothing to do ..allready done... 00242 { 00243 cout<<"\n StrawLib for "<<Nomef<<" already done."; 00244 Gout<<"\n StrawLib for "<<Nomef<<" already done."; 00245 return; 00246 } 00247 00248 // first time here.. read the no gaussian m.s. straw library data 00250 //read data from files....to memorize data in memory. 00251 // int row=80; col=1200 array[raw][col]; 00252 // allocate memory for Tet[80] 00253 Tet= new double[1200]; 00254 // allocate memory for Prob[80][1200]; 00255 Prob= new double* [80]; 00256 for ( int j = 0; j < 80; j ++ ) 00257 Prob[j] = new double[1200]; 00259 00260 std::ifstream MSlibrary; 00261 char *Numero=new char[12]; 00262 // 00263 int j,k; 00264 double prb,msNcount[1200],msN; 00265 string Finput = string ( " " ); 00266 for ( j=0;j<80;j++ ) 00267 { 00268 // the input file = path/ 00269 sprintf ( Numero,"%d.db", ( j*1000+500 ) ); 00270 Finput= Dir + "/"+ Nomef + "_" + Numero; 00271 MSlibrary.open ( Finput.c_str(),ios::in ); 00272 if ( MSlibrary.is_open() ) 00273 { 00274 if ( j<1 ) cout<<"\n Reading Straw lib: " << Finput; 00275 if ( j<1 ) Gout<<"\n Reading Straw lib: " << Finput; 00276 } 00277 else 00278 { 00279 cout<<"\n The Straw lib: " << Finput 00280 <<" is missing --> Controllare DevStraw::DevStraw() exit!"; 00281 Gout<<"\n The Straw lib: " << Finput 00282 <<" is missing --> Controllare DevStraw::DevStraw() exit!"; 00283 exit ( 0 ); 00284 } 00285 msN = 0; 00286 for ( k=0;k<1200;k++ ) 00287 { 00288 MSlibrary >> Tet[k] >> msNcount[k]; 00289 msN += msNcount[k]; 00290 } 00291 MSlibrary.close(); 00292 00293 prb = 0; 00294 if ( !msN ) continue; 00295 for ( k=0;k<1200;k++ ) 00296 { 00297 Prob[j][1199-k] = 1.-prb; 00298 prb += msNcount[1199-k]/msN; 00299 } 00300 } 00301 cout << "\n MS library for Straw Chambers Loaded for " << Nomef<<endl; 00302 Gout << "\n MS library for Straw Chambers Loaded for " << Nomef<<endl; 00303 } 00304 00305 //==================================================================== 00306 // costanti della geometria per il posizionamento dei tubi.. !! 00307 // Nota: calcolo solo se un tubo è stato attraversato e non; non mi interessa il numero del tubo. 00308 const double Tubraggio= 0.46; 00309 const double passo=1.76; 00310 const double d12=1.524; 00311 const double d13=3.429; 00312 const double d14=4.953; 00313 const double XTref1= -55.5*passo; 00314 const double XTref2= XTref1+passo/2.; 00315 const double XTref3= XTref1+passo/4.; 00316 const double XTref4= XTref1-passo/4.; 00317 const double conv2time= 150./.44; 00318 const double tubo_res=60.; // da definire meglio 00319 const double deadtime=150.0; 00320 const double tleading_res=29.; 00321 const double t0_res=20.;//ns 00322 const double ts_res=6.; //ns 00323 const long trigger_res=6. ; //ns 00324 00325 00326 00327 // Distanza in zeta del piano 2 dal piano 1 d12= sqrt(3/4)*passo=1.524 cm 00328 // Distanza del piano 3 dal piano 1: d13= sqrt(3/4)*(2*passo+pass4) =3.429 cm 00329 // Distanza del piano 4 dal piano 1: d14= sqrt(3/4)*(3*passo+pass4) =4.953 cm 00330 00331 00332 00333 //===== 00334 00335 int DevStraw::SimulaDev() 00336 { 00337 00338 00339 tubiseen=ntub1=ntub2=ntub3=ntub4=0; 00340 for (int i=0;i<16;i++) toc_tubo1[i]=toc_tubo2[i]=toc_tubo3[i]=toc_tubo4[i]=0; 00341 00342 00343 00345 00346 // calcolo dei delle straw attraversate 00347 // 00348 // Ricordo alcuni parametri geometrici 00349 // passo = 1.76 cm uguale alla distanza tra i centri delle straw su di uno stesso piano 00350 // Distanza in zeta del piano 2 dal piano 1 d12= sqrt(3/4)*passo=1.524 cm 00351 // Distanza del piano 3 dal piano 1: d13= sqrt(3/4)*(2*passo+pass4) =3.429 cm 00352 // Distanza del piano 4 dal piano 1: d14= sqrt(3/4)*(3*passo+pass4) =4.953 cm 00353 00354 // centro in x dello straw tube più a destra del piano 1: Xt= -basecm 00355 // centro in x dello straw tube più a destra del piano 2: Xt= -104.56+passo/2 = -103.68 cm 00356 // centro in x dello straw tube più a destra del piano 3: Xt= -104.56+passo/4 = -104.12 cm 00357 // centro in x dello straw tube più a destra del piano 4: Xt= -104.56-passo/4 = -105.00 cm 00358 00359 00360 nwire=0; 00361 double X1=0.,X2=0.,X3=0.,X4=0., tgxz=0.; 00362 // cout<<"\n Device "<<nome<<" mhit "<<mhit<<"\n"; 00363 00364 for ( int k=0;k<mhit;k++ ) 00365 { 00366 // attenzione si lavora nel sistema del dev... 00367 gvet verso=Lab2Dev(M_Hits[k].Vers); 00368 tgxz=verso.x/verso.z; 00369 X1= M_Hits[k].Xdev.x ; 00370 double tempo_hit=M_Hits[k].tempo; 00371 // cout<<"\n\nhit Ev "<<evento_.Gen.Event<<" "<<M_Hits[k].pnome<<" x "<<X1<<" tgz "<<tgxz; 00372 00373 00374 ntub1=Set_tubo(ntub1,X1-XTref1,tempo_hit,tubo1,t0_tubo1,ts_tubo1,tmp_tubo1,toc_tubo1); 00375 X2= X1 + tgxz*d12; 00376 ntub2=Set_tubo(ntub2,X2-XTref2,tempo_hit,tubo2,t0_tubo2,ts_tubo2,tmp_tubo2,toc_tubo2); 00377 X3= X1 + tgxz*d13; 00378 ntub3=Set_tubo(ntub3,X3-XTref3,tempo_hit,tubo3,t0_tubo3,ts_tubo3,tmp_tubo3,toc_tubo3); 00379 X4= X1 + tgxz*d14; 00380 ntub4=Set_tubo(ntub4,X4-XTref4,tempo_hit,tubo4,t0_tubo4,ts_tubo4,tmp_tubo4,toc_tubo4); 00381 00382 } 00383 // set the errors.... 00384 // prima di definire gli errori occorre conoscere come viene esattamente generato 00385 // il segnale di trailing e tleading. 00386 00387 Set_tubi_errors(ntub1, ts_tubo1, t0_tubo1); 00388 Set_tubi_errors(ntub2, ts_tubo2, t0_tubo2); 00389 Set_tubi_errors(ntub3, ts_tubo3, t0_tubo3); 00390 Set_tubi_errors(ntub4, ts_tubo4, t0_tubo4); 00391 00392 tubiseen=ntub1+ntub2+ntub3+ntub4; 00393 Get_wire(); 00394 00395 return 1; 00396 00397 } 00398 00399 // ** Dedfinisce il tubo toccato e i parametri temporali... 00400 int DevStraw::Set_tubo(int nb,double DX,double hit_time,int *tubo,double *T0, double *Ts, double *Tmp,int *Tcc) 00401 { 00402 double tt0=0.0; 00403 double tts=0.0; 00404 double tth=0.0; 00405 00406 if (nb>15)return nb; 00407 int ntb =DX/passo +0.5; 00408 double resto= DX -ntb*passo ; 00409 if ( fabs(resto) > Tubraggio) return nb; 00410 00411 00412 00413 double T0now=hit_time; 00414 double Tsnow= hit_time+fabs(resto)*conv2time; 00415 00416 //************ Pipeline is off ! 00417 if (Pipeline==0) 00418 { 00419 // define new tubo... 00420 tubo[nb]=ntb; 00421 T0[nb]=T0now; 00422 Ts[nb]=Tsnow; 00423 Tmp[nb]=hit_time; 00424 nb++; 00425 return nb; 00426 } 00427 00428 //************ Pipeline is on! 00429 00430 // test tubi ... già toccato?? 00431 int toc=-1; 00432 for (int i=0;i<nb;i++) 00433 { 00434 if (tubo[i]==ntb) 00435 { 00436 toc=i; 00437 tt0=T0[i]; 00438 tts=Ts[i]; 00439 tth=Tmp[i]; 00440 Tcc[i]++; 00441 // cout<<"\n toc "<<i <<" "<< ntb; 00442 break; 00443 } 00444 } 00445 00446 // c'è sovrapposizione ? 00447 00448 if (toc==-1|| // qui non c'è! tubo differente 00449 (toc>-1&&( (tt0+deadtime)<Tsnow|| (T0now+deadtime)<tts)) ) // stesso tubo ma non c'è sovrapposizione temporale 00450 { 00451 // define new tubo... 00452 tubo[nb]=ntb; 00453 T0[nb]=T0now; 00454 Ts[nb]=Tsnow; 00455 Tmp[nb]=hit_time; 00456 nb++; 00457 return nb; 00458 } 00459 00460 if (toc>-1) // stesso tubo ma qui c'è sovrapposizione temporale 00461 { 00462 // ricordare la successione dei segnali: t_leading è la salita, t_trailing è alla fine impulso... 00463 // quindi un impulso pileup (or di due impulsi o più!) è in genera un segnale più largo... 00464 // a sinistra la salita corrisponde al t-leading prima arrivato, 00465 // mentre a destra il t_trailing corrisponde all'ultimo arrivato... 00466 // cout<<"\n ev " << evento_.Gen.Event<< " nt "<<tubo[toc]<< " T0now " <<T0now<<" ts "<<Tsnow; 00467 // cout<< " T0 " <<T0[toc]<<" ts "<<Ts[toc]; 00468 00469 if (T0now>tt0) T0[toc]=T0now; 00470 if (Tsnow<tts) Ts[toc]=Tsnow; 00471 if (hit_time<tth) Tmp[toc]=hit_time; 00472 // cout<< " T0new " <<T0[toc]<<" tsnew "<<Ts[toc]; 00473 00474 00475 return nb; 00476 } 00477 00478 return nb; 00479 } 00480 00481 // errori temporali 00482 00483 void DevStraw::Set_tubi_errors(int ntot, double *Ts, double *T0) 00484 { 00485 for (int itb=0;itb<ntot;itb++) 00486 { 00487 T0[itb]=Pgauss(t0_res,T0[itb]); 00488 Ts[itb]=Pgauss(ts_res,Ts[itb]); 00489 } 00490 } 00491 00492 00493 00494 00495 00496 double tempo_trigger; 00497 00499 00500 void DevStraw::Get_wire() 00501 { 00502 int ix=0; 00503 double Xwire[16],Xwiredtim[16],Xwiredtrailing[16],Xwiretrailsom[16],Xwiredtempo[16]; 00504 int piano[16]; 00505 for (int i=0;i<16;i++) use_tubo1[i]=use_tubo2[i]=use_tubo3[i]=use_tubo4[i]=-1; 00506 for (int i=0;i<16;i++) 00507 { 00508 Xwire[i]=Xwiredtim[i]=Xwiredtrailing[i]=Xwiretrailsom[i]=.0; 00509 Xwiredtempo[i]=-300.; 00510 } 00511 00512 double trailing0=0.; 00513 00514 int ntb,b3,b4; 00515 tempo_trigger=0.0; 00516 long Tnano= evento_.Gen.tempo; 00517 tempo_trigger=double((Tnano/trigger_res)*trigger_res) + trigger_res/2.; 00518 00519 // cout<<"\n\n Start Ev "<<evento_.Gen.Event<<" "<<nome<<" mhit "<<mhit; 00520 // cout<<"\n Primo piano "<<ntub1; 00521 00522 // primo piano 00523 for (int i=0;i<ntub1;i++) 00524 { 00525 00526 TbParm.Reset(); 00527 00528 trailing0=t0_tubo1[i]-tempo_trigger; 00529 if (fabs(trailing0)>tubo_res) continue; // qui si butta se siamo fuori tempo massimo.... 00530 TbParm.ntbc=TbParm.ntb=ntb =tubo1[i]; 00531 TbParm.tlead0=ts_tubo1[i]-tempo_trigger; // tempo di arrivo del segnale al filo centrale del tubo 00532 if (TbParm.tlead0<0.0||TbParm.tlead0>155.) continue; 00533 00535 00536 //test on plane 4 00537 b4=TbParm.FiloValida(ntub4,use_tubo4,tubo4,t0_tubo4,ts_tubo4); 00538 00539 //test on plane 3 00540 b3=TbParm.FiloValida(ntub3,use_tubo3,tubo3,t0_tubo3,ts_tubo3); 00541 00542 // test segno if defined.. 00543 if (TbParm.segno==0.0) continue; 00544 use_tubo1[i]=ntb; 00545 Xwire[ix]=TbParm.ntb*passo+XTref1+TbParm.segno*TbParm.tlead0/conv2time; 00546 Xwiredtim[ix]=TbParm.totdriftsav; 00547 Xwiredtrailing[ix]=TbParm.trailingsav-trailing0; 00548 Xwiretrailsom[ix]=TbParm.trailingsav+trailing0; 00549 Xwiredtempo[ix]=evento_.Gen.tempo-tmp_tubo1[i]; 00550 piano[ix]=ntb+1000*b3+1000000*b4; 00551 00552 ix++; 00553 } 00554 00555 // secondo piano 00556 //cout<<"\n Secondo piano "<<ntub2; 00557 00558 for (int i=0;i<ntub2;i++) 00559 { 00560 00561 TbParm.Reset(); 00562 00563 trailing0=t0_tubo2[i]-tempo_trigger; 00564 if (fabs(trailing0)>tubo_res) continue; // qui si butta se siamo fuori tempo massimo.... 00565 TbParm.ntb=ntb =tubo2[i]; 00566 TbParm.tlead0=ts_tubo2[i]-tempo_trigger; // tempo di arrivo del segnale al filo centrale del tubo 00567 if (TbParm.tlead0<0.0||TbParm.tlead0>155.) continue; 00568 00570 00571 //test on plane 3 00572 TbParm.ntbc=ntb; 00573 b3=TbParm.FiloValida(ntub3,use_tubo3,tubo3,t0_tubo3,ts_tubo3); 00574 00575 //test on plane 4 00576 TbParm.ntbc=ntb+1; 00577 b4=TbParm.FiloValida(ntub4,use_tubo4,tubo4,t0_tubo4,ts_tubo4); 00578 00579 00580 00581 // test segno if defined.. 00582 if (TbParm.segno==0.0) continue; 00583 use_tubo2[i]=ntb; 00584 Xwire[ix]=TbParm.ntb*passo+XTref2+TbParm.segno*TbParm.tlead0/conv2time; 00585 Xwiredtim[ix]=TbParm.totdriftsav; 00586 Xwiredtrailing[ix]=TbParm.trailingsav-trailing0; 00587 Xwiretrailsom[ix]=TbParm.trailingsav+trailing0; 00588 Xwiredtempo[ix]=evento_.Gen.tempo-tmp_tubo2[i]; 00589 piano[ix]=-(ntb+1000*b3+1000000*b4); 00590 ix++; 00591 00592 } 00593 00594 nwire=ix; 00595 00596 for (int i=0;i<nwire;i++) 00597 { 00598 Wirecoor[i]=Xwire[i]; 00599 Wiredtim[i]=Xwiredtim[i]; 00600 Wiret0tim[i]=Xwiredtrailing[i]; 00601 Wiret0stim[i]=Xwiretrailsom[i]; 00602 Wiredtempo[i]=Xwiredtempo[i]; 00603 } 00604 00605 // verifico se l'evento nella camera è stato costruito con pileup 00606 00607 flag_pileup=0; 00608 00609 for (int i=0;i<nwire;i++) 00610 { 00611 if (Wiredtempo[i]!=0) 00612 flag_pileup++; 00613 } 00614 00615 00616 00617 00618 //if (nwire!=mhit) 00619 if (nwire< -10) 00620 { 00621 cout<<"\n ****** Ev "<<evento_.Gen.Event<<" "<<nome<<" mhit "<<mhit<< " nwire "<<nwire<<"\n"; 00622 00623 for ( int k=0;k<mhit;k++ ) 00624 { 00625 double X1= M_Hits[k].Xdev.x ; 00626 cout<<" "<<M_Hits[k].pnome<<" "<<X1; 00627 } 00628 00629 00630 cout<<"\n "<< ntub1<<" "<<ntub2<<" " <<ntub3<< " "<<ntub4; 00631 for (int tb=0;tb<ntub1;tb++) cout<<"\n hit1 "<< tubo1[tb]<<" dt "<< ts_tubo1[tb]-evento_.Gen.tempo; 00632 for (int tb=0;tb<ntub2;tb++) cout<<"\n hit2 "<< tubo2[tb]<<" dt "<< ts_tubo2[tb]-evento_.Gen.tempo; 00633 for (int tb=0;tb<ntub3;tb++) cout<<"\n hit3 "<< tubo3[tb]<<" dt "<< ts_tubo3[tb]-evento_.Gen.tempo; 00634 for (int tb=0;tb<ntub4;tb++) cout<<"\n hit4 "<< tubo4[tb]<<" dt "<< ts_tubo4[tb]-evento_.Gen.tempo; 00635 00636 cout<<"\n Dev "<<nome<<" nwire "<<nwire<< " x: "; 00637 for (int ix=0;ix<nwire;ix++) 00638 00639 { 00640 cout<<" [ "<<piano[ix]<<" "<<Xwire[ix]<<" tt "<<Xwiredtim[ix]<<" ] "; 00641 } 00642 00643 cout<<"\n coordinate M_Hit "; 00644 for (int i=0;i<mhit;i++) 00645 cout<< " "<<M_Hits[i].Xdev.x; 00646 00647 00648 cout<<endl; 00649 } 00650 00651 00652 } 00653 00654 00655 00656 int Tubiparm::FiloValida(int n, int* flags, int *Tubo, double* T0, double* Ts) 00657 { 00658 // routine to test the tube correlations... 00659 nt=n; 00660 if (nt<1) return 0; 00661 // cout<<"\n Start valida "<<ntb<<" conf "<<ntbc; 00662 00663 for (int k=0;k<nt;k++) 00664 { 00665 bt=Tubo[k]; 00666 if (ntbc!=bt) continue; // cheack sul tubo 00667 if (flags[k]!=-1) continue; // filo già usato 00668 trailing=T0[k]-tempo_trigger; // get trailing -trigger_time 00669 // cout<<" k "<<k<<" tr " <<trailing; 00670 if (fabs(trailing)>tubo_res) continue; // trailing inside the res (80) 00671 tlead= Ts[k]-tempo_trigger; //get the leading - trigger_time 00672 00673 00674 // cout<<" cor "<<cor<<" tl " <<tlead; 00675 if (tlead<0.0||tlead>155.) continue; // has to be in 0.0<->160 00676 totdrift=tlead0+tlead-deadtime; // tot drift - deadtime (the best is 0!) 00677 // cout<<" tt " <<totdrift; 00678 // angle correction factor 00679 double cor = 1.+abs(bt-56)/33. ; // it depends o the tube distance from the center. 00680 if ( fabs(totdrift)>tleading_res*cor)continue; // has to be in tleading_res (60) 00681 if (fabs(totdrift)>fabs(totdriftsav)) continue; // select the best 00682 // selection done... save parms 00683 totdriftsav=totdrift; 00684 trailingsav=trailing; 00685 segno=+1.0; 00686 flags[k]=bt; 00687 // retuyrn il tubo scelto altrimenti zero. 00688 00689 00690 // cout<<" End valida "; 00691 return bt; 00692 00693 } 00694 return 0; 00695 } 00696 00697 00698 00699 00700