Index: trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx	(revision 409)
+++ trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.cxx	(revision 410)
@@ -293,6 +293,197 @@
   
   for ( i = 0 ; i < 5 ; i++) {
-    SlicesFirst[i]  = -50.0 ; 
-    SlicesSecond[i] = -50.0 ;
+    SlicesFirst[i]  = -50 ; 
+    SlicesSecond[i] = -50 ;
+    PixelsFirst[i]  = -1;
+    PixelsSecond[i] = -1;
+  }
+  cout << " end of MTrigger::MTrigger()" << endl ; 
+} 
+
+MTrigger::MTrigger(float gate, float ampl, float fwhm) { 
+  // ============================================================
+  //
+  //  constructor 
+  //  
+  //  The procedure is the following: 
+  //
+  //  1. Allocation of some memory needed
+  //  2. some parameters of the trigger are set.   
+  //  3. Then the all signals are set to zero
+
+  Int_t  i, ii ; 
+
+  Float_t threshold ; 
+ 
+  // 
+  //   allocate the memory for the 2dim arrays (a_sig, d_sig ) 
+  //
+
+  for( Int_t j=0; j<TRIGGER_PIXELS; j++ ) { 
+
+    a_sig[j] = new Float_t[TRIGGER_TIME_SLICES] ; 
+
+    d_sig[j] = new Float_t[TRIGGER_TIME_SLICES] ; 
+  } 
+
+  //
+  //   set the values for the standard response pulse
+  //
+
+  fwhm_resp = fwhm       ; 
+  ampl_resp = ampl  ; 
+    
+  threshold = CHANNEL_THRESHOLD  ; 
+  
+
+  gate_leng        = gate       ; 
+  trigger_multi    = TRIGGER_MULTI      ; 
+  trigger_geometry = TRIGGER_GEOM ; 
+
+  cout << endl
+       << "[MTrigger]  Setting up the MTrigger with this values "<< endl ; 
+  cout << "[MTrigger]    Gate Length:        " << gate_leng  << " ns"
+       << endl ; 
+  cout << "[MTrigger]    Response FWHM:      " << fwhm_resp  << " ns"
+       << endl ; 
+  cout << "[MTrigger]    Response Amplitude: " << ampl_resp  << " mV"
+       << endl ; 
+  cout << endl ; 
+
+
+  for (Int_t k=0; k<TRIGGER_PIXELS; k++ ) {
+    chan_thres[k] = threshold ; 
+  }
+  
+
+  //
+  //    set up the response shape
+  // 
+     
+  Float_t   sigma ; 
+  Float_t   x, x0 ; 
+
+  sigma = fwhm_resp / 2.35 ; 
+  x0 = 3*sigma ; 
+  
+  for (i=0; i< RESPONSE_SLICES ; i++ ) {  
+
+    x = i * (1./((Float_t)SLICES_PER_NSEC)) 
+      + (1./( 2 * (Float_t)SLICES_PER_NSEC ))  ; 
+    
+    sing_resp[i] = 
+      ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ; 
+  
+  }
+
+  //
+  //    look for the time between start of response function and the 
+  //    maximum value of the response function. This is needed by the
+  //    member functions FillNSB() and FillStar() 
+  //  
+
+  Int_t imax  = 0  ;
+  Float_t max = 0. ; 
+  for (i=0; i< RESPONSE_SLICES ; i++ ) {  
+    if ( sing_resp[i] > max ) {
+      imax = i ; 
+      max  = sing_resp[i] ; 
+    }
+  }
+ 
+  peak_time = ( (Float_t) imax )  / ( (Float_t) SLICES_PER_NSEC ) ;
+ 
+
+  //
+  //   the amplitude of one single photo electron is not a constant. 
+  //   There exists a measured distribution from Razmik. This distribution
+  //   is used to simulate the noise of the amplitude. 
+  //   For this a histogramm (histPmt) is created and filled with the
+  //   values. 
+  // 
+
+  histPmt = new TH1F ("histPmt","Noise of PMT", 40, 0., 40.) ;
+  
+  Stat_t ValRazmik[41] = { 0., 2.14, 2.06, 2.05, 2.05, 2.06, 2.07, 2.08,  2.15,
+			   2.27, 2.40, 2.48, 2.55, 2.50, 2.35, 2.20,  2.10,
+			   1.90, 1.65, 1.40, 1.25, 1.00, 0.80, 0.65,  0.50,
+			   0.35, 0.27, 0.20, 0.18, 0.16, 0.14, 0.12,  0.10, 
+			   0.08, 0.06, 0.04, 0.02, 0.01, 0.005,0.003, 0.001} ; 
+
+  histMean =  histPmt->GetMean() ;   
+  
+  histPmt->SetContent( ValRazmik) ; 
+
+  histMean =  histPmt->GetMean() ; 
+
+  //
+  //   create the random generator for the Electronic Noise
+  // 
+
+  GenElec = new TRandom() ; 
+
+  //
+  //  Read in the lookup table for NN trigger
+  //
+  
+  FILE *unit ;
+  int id ;
+
+  i = 0 ; 
+
+  if ( (unit = fopen("../include-MTrigger/TABLE_NEXT_NEIGHBOUR", "r" )) == 0 ) { 
+    cout << "ERROR: not able to read ../include-MTrigger/TABLE_NEXT_NEIGHBOUR"
+	 << endl ; 
+    exit(123) ; 
+  }  
+  else { 
+    while ( i < TRIGGER_PIXELS )
+      {
+	fscanf ( unit, " %d", &id ) ;
+	
+	for ( Int_t k=0; k<6; k++ ) { 
+	  fscanf ( unit, "%d ", &NN[i][k]  ) ; 
+	}
+	i++ ;
+      }
+    
+    fclose (unit) ;
+  }
+
+
+  //
+  //
+  //  set all the booleans used to FALSE, indicating that the pixel is not 
+  //  used in this event. 
+  //
+  
+  for ( i =0 ; i <TRIGGER_PIXELS ; i++ ) { 
+    used [i] = FALSE ;
+    dknt [i] = FALSE ;
+
+    nphotshow[i] = 0 ;
+    nphotnsb [i] = 0 ;
+    nphotstar[i] = 0 ;
+
+    baseline[i] = 0 ; 
+  }
+
+  for ( ii=0 ; ii<TRIGGER_TIME_SLICES; ii++ ) { 
+    sum_d_sig[ii] = 0. ;  
+  }
+  
+  //
+  //   set the information about the Different Level Triggers to zero
+  //
+
+  nZero = nFirst = nSecond = 0 ; 
+
+  for (ii=0 ; ii<TRIGGER_TIME_SLICES; ii++ ) { 
+    SlicesZero[ii] = FALSE;
+  }
+  
+  for ( i = 0 ; i < 5 ; i++) {
+    SlicesFirst[i]  = -50 ; 
+    SlicesSecond[i] = -50 ;
     PixelsFirst[i]  = -1;
     PixelsSecond[i] = -1;
@@ -361,5 +552,5 @@
   
   for ( i = 0 ; i < 5 ; i++) {
-    SlicesFirst[i]  = -50.0 ; 
+    SlicesFirst[i]  = -50 ; 
     PixelsFirst[i]  = -1;
   }
