Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1888)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1891)
@@ -784,4 +784,11 @@
         return kFALSE;
 
+    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
+    if (!fBinningT)
+    {
+        *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
+        return kFALSE;
+    }
+
     fNumFilterEvts = 0;
     fNumEvents     = 0;
@@ -796,60 +803,19 @@
 // --------------------------------------------------------------------------
 //
-// Smear Theta uniformly in a bin of Theta; result is stored in ThetaSmeared
-// 
-//
-Bool_t MCT1ReadPreProc::SmearTheta(MParList *plist, Float_t *Theta,
-                             Float_t *ThetaSmeared)
-{
-  // both Theta and ThetaSmeared are in [radians]
-  // the edges are in [degrees]
-
-  const MBinning *binstheta = (MBinning*)plist->FindObject("BinningTheta");
-  if (!binstheta)
-  {
-    *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
-    return kFALSE;
-  }
-
-  Int_t nedges = binstheta->GetNumEdges();
-  Double_t *edges  = (Double_t*)binstheta->GetEdges();
-
-  Int_t bin = -1;
-  *ThetaSmeared = *Theta;
-
-  Float_t Thetadeg = (*Theta) * 180.0/TMath::Pi(); 
-  Float_t ThetaSmeareddeg;
- 
-  // search Theta bin
-  Int_t i;
-  for (i=1; i<nedges; i++)
-  {
-    if (Thetadeg >= *(edges+i)  ) continue;
-    if (Thetadeg  < *(edges+i-1)) break;
-    bin = i;
-    break;
-  }
-
-  Float_t low=0.0;
-  Float_t up =0.0;
-
-  // smear Theta within the Theta bin
-  ThetaSmeareddeg = -1.0;
-  if (bin != -1)
-  {
-    low = *(edges+bin-1);
-    up  = *(edges+bin);
-
-    Double_t ran = ran3.Rndm(1);
-    ThetaSmeareddeg = (low + ran * (up-low));
-  }
-  *ThetaSmeared = ThetaSmeareddeg * TMath::Pi()/180.0;
-
-  //*fLog << "SmearTheta : Thetadeg, ThetaSmeareddeg, low, up, bin = " 
-  //      << Thetadeg 
-  //      << ",  " << ThetaSmeareddeg << ",  " << low << ",  " << up << ",  "
-  //      << bin << endl;    
-
-  return kTRUE;
+// Smear Theta uniformly in a bin of Theta
+//
+Float_t MCT1ReadPreProc::SmearTheta(Float_t theta)
+{
+    // both Theta and ThetaSmeared are in [radians]
+    // the edges are in [degrees]
+    const Int_t bin = fBinningT->FindLoEdge(theta * 180.0/TMath::Pi());
+    if (bin == -1)
+        return theta;
+
+    // smear Theta within the Theta bin
+    const Double_t low = fBinningT->GetEdges()[bin];
+    const Double_t up  = fBinningT->GetEdges()[bin+1];
+
+    return (low + gRandom->Rndm(1) * (up-low)) * TMath::Pi()/180;
 }
 
@@ -942,14 +908,9 @@
 
     // smear Theta in its Theta bin
-    Float_t ThetaOrig =  TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600); // [radians] 
-    Float_t ThetaSmeared;                                               // [radians]
-    SmearTheta(fParList, &ThetaOrig, &ThetaSmeared);
-    fThetaOrig->SetVal(ThetaOrig);
+    Float_t theta = TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600);
+    fThetaOrig->SetVal(theta);
 
     // store hour angle
     fHourAngle->SetVal(event.fhourangle);
-
-    //*fLog << "MCt1ReadPreProc::ProcessEvent; fhourangle = " 
-    //      << event.fhourangle << endl;
 
     fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
@@ -969,6 +930,6 @@
                  fIsMcFile ? event.imcimpact_m*100 : 0,
                  TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds)
-                 ThetaSmeared,
-		 0, /* fTFirst */
+                 SmearTheta(theta),
+                 0, /* fTFirst */
 		 0, /* fTLast */
 		 0, /* fL_Nmax */
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1888)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1891)
@@ -9,6 +9,4 @@
 #include "MRead.h"
 #endif
-
-#include <TRandom3.h>
 
 class TList;
@@ -25,4 +23,5 @@
 class MParList;
 class MParameterD;
+class MBinning;
 
 struct outputpars;
@@ -47,4 +46,5 @@
     MParameterD   *fHourAngle;    // hour angle [deg]
     MParameterD   *fThetaOrig;    // original zenith angle [rad]
+    MBinning      *fBinningT;     // Theta binning for the smearing
 
     Bool_t fIsMcFile;       // Flag whether current run is a MC run
@@ -57,6 +57,4 @@
 
     TArrayF fPedRMS;
-
-    TRandom3 ran3;
 
     Bool_t OpenNextFile();
@@ -71,4 +69,6 @@
     void   ProcessRunHeader(const struct outputpars &outpars);
     void   ProcessEvent(const struct eventrecord &event);
+
+    Float_t SmearTheta(Float_t theta);
 
     Bool_t PreProcess(MParList *pList);
@@ -87,6 +87,4 @@
     UInt_t GetEntries() { return fEntries; }
 
-    Bool_t SmearTheta(MParList *plist, Float_t *theta, Float_t *thetasmeared);
-
     ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file
 };
