Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 378)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 379)
@@ -21,7 +21,7 @@
 //
 // $RCSfile: camera.cxx,v $
-// $Revision: 1.5 $
-// $Author: petry $ 
-// $Date: 2000-02-18 17:40:35 $
+// $Revision: 1.6 $
+// $Author: blanch $ 
+// $Date: 2000-03-20 18:35:11 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -52,4 +52,5 @@
 #include "TTree.h"
 #include "TBranch.h"
+#include "TCanvas.h"
 
 #include "MDiag.h"
@@ -57,4 +58,7 @@
 #include "MRawEvt.h"
 #include "MMcEvt.h"
+#include "MMcTrig.hxx"
+
+#include "MTrigger.hxx"
 
 /*!@" 
@@ -417,4 +421,7 @@
   int itrigger;               //@< index of pixel fired
   int ntrigger = 0;           //@< number of triggers in the whole file
+  //  MTrigger  Trigger ;         //@< A instance of the Class MTrigger 
+
+  //	MMcTrig *McTrig   = new MMcTrig() ; 
 
   float plateScale_cm2deg;    //@< plate scale (deg/cm)
@@ -780,5 +787,9 @@
     baseline_mv[i] = 0.;
   }
-        
+
+  //  Instance of the Trigger class
+
+  MTrigger  Trigger ;         //@< A instance of the Class MTrigger 
+       
   //!@' @#### Main loop.
   //@'
@@ -982,13 +993,50 @@
 //        cout << i << " " << baseline_mv[i] <<"\n";
 //      }
-  
-
-	cout << "Total number of phes: " << inumphe << "\n";
-
+
+	  cout << "Total number of phes: " << inumphe <<endl;
+	  
 	// TRIGGER HERE
 
-	trigger = FALSE;
-
-	if( TRUE ) trigger = TRUE; // put your trigger function here
+	//   
+	//   remove the prvious values of the analog signal for
+	//   each pixel and put the new ones from photoe array
+	//
+	Trigger.Reset();
+	
+	for(i=0;i<inumphe;i++){
+	  Trigger.FillShow(photoe[i].ipixnum,float((photoe[i].iarrtime_ns-arrtmin_ns+TOTAL_TRIGGER_TIME/10.0)));
+	}
+
+	//
+	//   now the noise of the electronic 
+	//   (preamps, optical transmission,..)  is introduced. 
+	//   This is done inside the class MTrigger by the method ElecNoise. 
+	//   
+	Trigger.ElecNoise() ;
+	
+	//
+	//   look if in all the signals in the trigger signal branch
+	//   is a possible Trigger. Therefore we habe to diskriminate all
+	//   the simulated analog signals (Method Diskriminate in class
+	//   MTrigger). We look simultanously for the moments at which
+	//   there are more than TRIGGER_MULTI pixels above the 
+	//   CHANNEL_THRESHOLD. 
+	//
+
+	Trigger.Diskriminate();
+
+	//McTrig->SetZeroLevel(trigger = (Short_t) Trigger.ZeroLevel()) ; 
+	trigger = (Short_t) Trigger.ZeroLevel();
+	
+	//
+	//   Start the First Level Trigger simulation
+	//
+	if ( trigger > 0 ) {
+	  //	  McTrig->SetFirstLevel ( trigger = Trigger.FirstLevel() )  ;
+	  trigger = Trigger.FirstLevel();
+	}
+	if ( trigger>0 ) {
+	  cout << "TRIG"<<"  "<<thetashw <<"  "<< trigger  << endl;
+	}
 
 // 	for( i=0; i<inumphe; i++){
@@ -996,5 +1044,5 @@
 // 	}
 	
-	if ( trigger == TRUE ) {
+	if ( trigger>0 ) {
 	  
 	  itrigger = i;
@@ -2779,4 +2827,18 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.5  2000/02/18 17:40:35  petry
+// This version includes drastic changes compared to camera.cxx 1.4.
+// It is not yet finished and not immediately useful because the
+// trigger simulation is not yet re-implemented. I had to take it
+// out together with some other stuff in order to tidy the whole
+// program up. This is not meant as an insult to anyone. I needed
+// to do this in order to be able to work on it.
+//
+// This version has been put in the repository in order to be
+// able to share the further development with others.
+//
+// If you need something working, wait or take an earlier one.
+// See file README.
+//
 // Revision 1.4  2000/01/25 08:36:23  petry
 // The pixelization in previous versions was buggy.
