| 451 | 
   PKT = 0; | 
   PKT = 0; | 
| 452 | 
   atime = 0; | 
   atime = 0; | 
| 453 | 
   // | 
   // | 
| 454 | 
  | 
   clp = L2->GetCaloLevel2(); | 
| 455 | 
  | 
   // | 
| 456 | 
   sel = true; | 
   sel = true; | 
| 457 | 
   cont = false; | 
   cont = false; | 
| 458 | 
   N = 0; | 
   N = 0; | 
| 476 | 
   if ( sec.Contains("YE") ) maskYE = true; | 
   if ( sec.Contains("YE") ) maskYE = true; | 
| 477 | 
 } | 
 } | 
| 478 | 
  | 
  | 
| 479 | 
  | 
 void CaloLong::UnMaskSections(){ | 
| 480 | 
  | 
   this->UnMaskSection("XEXOYEYO"); | 
| 481 | 
  | 
 } | 
| 482 | 
  | 
  | 
| 483 | 
  | 
 void CaloLong::UnMaskSection(TString sec){ | 
| 484 | 
  | 
   sec.ToUpper(); | 
| 485 | 
  | 
   if ( sec.Contains("XO") ) maskXO = false; | 
| 486 | 
  | 
   if ( sec.Contains("YO") ) maskYO = false; | 
| 487 | 
  | 
   if ( sec.Contains("XE") ) maskXE = false; | 
| 488 | 
  | 
   if ( sec.Contains("YE") ) maskYE = false; | 
| 489 | 
  | 
 } | 
| 490 | 
  | 
  | 
| 491 | 
 void CaloLong::Clear(){ | 
 void CaloLong::Clear(){ | 
| 492 | 
   // | 
   // | 
| 493 | 
   memset(eplane,0, 2*22*sizeof(Float_t)); | 
   memset(eplane,0, 2*22*sizeof(Float_t)); | 
| 638 | 
   // | 
   // | 
| 639 | 
   Float_t ytgx = 0; | 
   Float_t ytgx = 0; | 
| 640 | 
   Float_t ytgy = 0; | 
   Float_t ytgy = 0; | 
| 641 | 
   ytgx = 0.76 * L2->GetCaloLevel2()->tanx[0]; | 
   ytgx = 0.76 * clp->tanx[0]; | 
| 642 | 
   ytgy = 0.76 * L2->GetCaloLevel2()->tany[0];   | 
   ytgy = 0.76 * clp->tany[0];   | 
| 643 | 
   X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) ); | 
   X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) ); | 
| 644 | 
   // | 
   // | 
| 645 | 
   // Find experimental plane of maximum | 
   // Find experimental plane of maximum | 
| 667 | 
   // | 
   // | 
| 668 | 
 }; | 
 }; | 
| 669 | 
  | 
  | 
| 670 | 
  | 
 void CaloLong::SetEnergies(Float_t myene[][22]){ | 
| 671 | 
  | 
   //   | 
| 672 | 
  | 
   if ( !L2 ){ | 
| 673 | 
  | 
     printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n"); | 
| 674 | 
  | 
     printf(" ERROR: CaloHough variables not filled \n"); | 
| 675 | 
  | 
     return; | 
| 676 | 
  | 
   }; | 
| 677 | 
  | 
   // | 
| 678 | 
  | 
   Bool_t newentry = false; | 
| 679 | 
  | 
   // | 
| 680 | 
  | 
   if ( L2->IsORB() ){ | 
| 681 | 
  | 
     if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime ){ | 
| 682 | 
  | 
       newentry = true; | 
| 683 | 
  | 
       OBT = L2->GetOrbitalInfo()->OBT; | 
| 684 | 
  | 
       PKT = L2->GetOrbitalInfo()->pkt_num; | 
| 685 | 
  | 
       atime = L2->GetOrbitalInfo()->absTime; | 
| 686 | 
  | 
     }; | 
| 687 | 
  | 
   } else { | 
| 688 | 
  | 
     newentry = true; | 
| 689 | 
  | 
   }; | 
| 690 | 
  | 
   // | 
| 691 | 
  | 
   if ( !newentry ) return; | 
| 692 | 
  | 
   // | 
| 693 | 
  | 
   if ( debug ) printf(" SET ENERGIES Start processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime); | 
| 694 | 
  | 
   // | 
| 695 | 
  | 
   Clear(); | 
| 696 | 
  | 
   // | 
| 697 | 
  | 
   // let's start | 
| 698 | 
  | 
   // | 
| 699 | 
  | 
   if ( cont ){ | 
| 700 | 
  | 
     for (Int_t i=0; i<22; i++){ | 
| 701 | 
  | 
       if ( i == (18+N) ){ | 
| 702 | 
  | 
         mask18b =  18 + N; | 
| 703 | 
  | 
         break; | 
| 704 | 
  | 
       }; | 
| 705 | 
  | 
     }; | 
| 706 | 
  | 
   };   | 
| 707 | 
  | 
   //   | 
| 708 | 
  | 
   if ( sel ){ | 
| 709 | 
  | 
     for (Int_t i=0; i<22; i++){ | 
| 710 | 
  | 
       if ( i == (18-N) ){ | 
| 711 | 
  | 
         mask18b =  18 - N; | 
| 712 | 
  | 
         break; | 
| 713 | 
  | 
       }; | 
| 714 | 
  | 
     }; | 
| 715 | 
  | 
   }; | 
| 716 | 
  | 
   // | 
| 717 | 
  | 
   //  if ( mask18b == 18 ) mask18b = -1; | 
| 718 | 
  | 
   // | 
| 719 | 
  | 
   Int_t view = 0; | 
| 720 | 
  | 
   Int_t plane = 0; | 
| 721 | 
  | 
   Bool_t gof = true; | 
| 722 | 
  | 
   for (view=0; view < 2; view++){ | 
| 723 | 
  | 
     for (plane=0; plane < 22; plane++){       | 
| 724 | 
  | 
       gof = true; | 
| 725 | 
  | 
       if ( maskXE && (plane%2)==0 && view==1 ) gof = false; | 
| 726 | 
  | 
       if ( maskXO && (plane%2)!=0 && view==1 ) gof = false; | 
| 727 | 
  | 
       if ( maskYE && (plane%2)!=0 && view==0 ) gof = false; | 
| 728 | 
  | 
       if ( maskYO && (plane%2)==0 && view==0 ) gof = false; | 
| 729 | 
  | 
       if ( gof ) eplane[view][plane] = myene[view][plane];  | 
| 730 | 
  | 
       if ( debug ) printf(" XE %i XO %i YE %i YO %i eplane %i %i = %f ........... myene %i %i = %f\n", maskXE, maskXO, maskYE, maskYO,view,plane,eplane[view][plane],view,plane,myene[view][plane]); | 
| 731 | 
  | 
     }; | 
| 732 | 
  | 
   }; | 
| 733 | 
  | 
   // | 
| 734 | 
  | 
   // inclination factor (stolen from Daniele's code) | 
| 735 | 
  | 
   // | 
| 736 | 
  | 
   Float_t ytgx = 0; | 
| 737 | 
  | 
   Float_t ytgy = 0; | 
| 738 | 
  | 
   ytgx = 0.76 * clp->tanx[0]; | 
| 739 | 
  | 
   ytgy = 0.76 * clp->tany[0];   | 
| 740 | 
  | 
   X0pl = sqrt( pow(0.76,2.) + pow(ytgx,2.) + pow(ytgy,2.) ); | 
| 741 | 
  | 
   // | 
| 742 | 
  | 
   // Find experimental plane of maximum | 
| 743 | 
  | 
   // | 
| 744 | 
  | 
   Int_t pmax = 0; | 
| 745 | 
  | 
   Int_t vmax = 0; | 
| 746 | 
  | 
   Float_t emax = 0.; | 
| 747 | 
  | 
   for (Int_t v=0; v<2; v++){ | 
| 748 | 
  | 
    for (Int_t i=0; i<22; i++){ | 
| 749 | 
  | 
      if ( eplane[v][i] > emax ){ | 
| 750 | 
  | 
        emax = eplane[v][i]; | 
| 751 | 
  | 
        vmax = v; | 
| 752 | 
  | 
        pmax = i; | 
| 753 | 
  | 
      }; | 
| 754 | 
  | 
    }; | 
| 755 | 
  | 
   }; | 
| 756 | 
  | 
   // | 
| 757 | 
  | 
   // | 
| 758 | 
  | 
   // | 
| 759 | 
  | 
   if ( vmax == 0 ) pmax++; | 
| 760 | 
  | 
   etmax = pmax * X0pl; | 
| 761 | 
  | 
   // | 
| 762 | 
  | 
   if ( debug ) this->Print(); | 
| 763 | 
  | 
   if ( debug ) printf(" exit \n"); | 
| 764 | 
  | 
   // | 
| 765 | 
  | 
 }; | 
| 766 | 
  | 
  | 
| 767 | 
 Double_t ccurve(Double_t *ti,Double_t *par){ | 
 Double_t ccurve(Double_t *ti,Double_t *par){ | 
| 768 | 
   // | 
   // | 
| 852 | 
     xpos = (st - mmin) * X0pl; | 
     xpos = (st - mmin) * X0pl; | 
| 853 | 
     if ( st > mmin && st < mmax ){       | 
     if ( st > mmin && st < mmax ){       | 
| 854 | 
       if ( no18x && ( st == 18+1 || st == mask18b+1 )){ | 
       if ( no18x && ( st == 18+1 || st == mask18b+1 )){ | 
| 855 | 
         enemip = 2. * eplane[1][st];  | 
         if ( !maskYO ){ | 
| 856 | 
  | 
           enemip = 2. * eplane[1][st];  | 
| 857 | 
  | 
         } else { | 
| 858 | 
  | 
           enemip = eplane[1][st];  | 
| 859 | 
  | 
         }; | 
| 860 | 
       } else { | 
       } else { | 
| 861 | 
         enemip = eplane[0][st-1] + eplane[1][st];  | 
         enemip = eplane[0][st-1] + eplane[1][st];  | 
| 862 | 
       }; | 
       }; | 
| 863 | 
     } else { | 
     } else { | 
| 864 | 
       if ( st == mmin ) enemip = 2. * eplane[1][st];  | 
       if ( st == mmin ){ | 
| 865 | 
       if ( st == mmax ) enemip = 2. * eplane[0][st-1];  | 
         if ( !maskYE ){ | 
| 866 | 
  | 
           enemip = 2. * eplane[1][st];  | 
| 867 | 
  | 
         } else { | 
| 868 | 
  | 
           enemip = eplane[1][st];  | 
| 869 | 
  | 
         }; | 
| 870 | 
  | 
       }; | 
| 871 | 
  | 
       if ( st == mmax ){ | 
| 872 | 
  | 
         if ( !maskXE ){ | 
| 873 | 
  | 
           enemip = 2. * eplane[0][st-1];  | 
| 874 | 
  | 
         } else { | 
| 875 | 
  | 
           enemip = eplane[0][st-1];  | 
| 876 | 
  | 
         }; | 
| 877 | 
  | 
       }; | 
| 878 | 
     }; | 
     }; | 
| 879 | 
     // | 
     // | 
| 880 | 
     qtotparz += enemip; | 
     qtotparz += enemip; | 
| 908 | 
   }; | 
   }; | 
| 909 | 
   // | 
   // | 
| 910 | 
   TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); | 
   TF1 *lfit = new TF1("lfit",ccurve,0.,xmax,3); | 
| 911 | 
   if ( debug ) printf("qtot %f qtotparz %f \n",L2->GetCaloLevel2()->qtot,qtotparz);  | 
   if ( debug ) printf("qtot %f qtotparz %f \n",clp->qtot,qtotparz);  | 
| 912 | 
   E0 = qtotparz; | 
   E0 = qtotparz; | 
| 913 | 
   //  E0 = L2->GetCaloLevel2()->qtot; | 
   //  E0 = clp->qtot; | 
| 914 | 
   a = 5.; | 
   a = 5.; | 
| 915 | 
   b = 0.5; | 
   b = 0.5; | 
| 916 | 
   if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b); | 
   if ( debug ) printf(" STARTING PARAMETERS: E0 %f a %f b %f \n",E0,a,b); |