Index: trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 437)
+++ trunk/MagicSoft/Simulation/Detector/Camera/camera.cxx	(revision 438)
@@ -21,7 +21,7 @@
 //
 // $RCSfile: camera.cxx,v $
-// $Revision: 1.12 $
-// $Author: harald $ 
-// $Date: 2000-09-22 17:40:18 $
+// $Revision: 1.13 $
+// $Author: magicsol $ 
+// $Date: 2000-10-25 08:14:23 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -49,4 +49,5 @@
 #include "TROOT.h"
 
+#include "TRandom.h"
 #include "TApplication.h"
 
@@ -692,5 +693,5 @@
   if (Write_McTrig){
 
-    McTrig = new MMcTrig* [icontrigger];
+    McTrig = new MMcTrig * [icontrigger];
   
     for (i=0;i<icontrigger;i++) {
@@ -698,5 +699,5 @@
     }
 
-    HeaderTrig = new MHeaderTrig* [icontrigger];
+    HeaderTrig = new MHeaderTrig * [icontrigger];
   
     for (i=0;i<icontrigger;i++) {
@@ -740,17 +741,13 @@
     
     HeaderTree.Branch("MHeaderTrig","MHeaderTrig", 
-		      &HeaderTrig[0], bsize, split);    
-  }
-
+		 &HeaderTrig[0], bsize, split);    
+  }
   if (Trigger_Loop && Write_McTrig){
     for(char branchname[10],i=0;i<icontrigger;i++){
-      //
-      //   build the name of the branch for the different trigger conditions
-      //
+      
       sprintf(help,"%i",i+1);
       strcpy (branchname, "MHeaderTrig");
-      strcat (branchname,  &help[0]);
+      strcat (branchname, & help[0]);
       strcat (branchname, ".");
-      
       HeaderTree.Branch(branchname,"MHeaderTrig", 
 		     &HeaderTrig[i], bsize, split);
@@ -770,7 +767,6 @@
 
   }
-  
-
   if(Trigger_Loop && Write_McTrig){
+
     for (int iconcount=0,ithrescount=0;ithrescount<=Trigger_loop_uthres-Trigger_loop_lthres;ithrescount++){
       for (imulticount=0;imulticount<=Trigger_loop_umult-Trigger_loop_lmult;imulticount++){
@@ -789,11 +785,12 @@
 
   //  Fill the Header Tree with the current leaves of each branch
-  
   HeaderTree.Fill() ;
-  
+	    
+
   //      create a Tree for the Event data stream 
   TTree EvtTree("EvtTree","Events of Run");
 
   if (Write_McEvt){
+
     EvtTree.Branch("MMcEvt","MMcEvt", 
 		   &McEvt, bsize, split);  
@@ -801,4 +798,5 @@
 
   if(!Trigger_Loop){
+    
     if (Write_RawEvt){
       EvtTree.Branch("MRawEvt","MRawEvt", 
@@ -810,5 +808,5 @@
     }    
   }
-  else{                     // trigger lopp 
+  else{
     if (Write_McTrig){
       for(char branchname[10],i=0;i<icontrigger;i++){
@@ -880,5 +878,4 @@
 			  &cam,
 			  nsbrate_phepns );
-
     if (k != 0){
       cout << "Error when reading starfield... \nExiting.\n";
@@ -892,4 +889,5 @@
 	cam.dpixsizefactor[i] * cam.dpixsizefactor[i];
     }
+
   }
 
@@ -897,9 +895,11 @@
   // Read the reflector file with the Cherenkov data
   //			
-  
+
   // select input file 
 
   if ( Data_From_STDIN ) {
+
     inputfile = stdin;
+
   }
   else{
@@ -909,4 +909,5 @@
     if ( inputfile == NULL ) 
       error( SIGNATURE, "Cannot open input file: %s\n", inname );
+
   }
   
@@ -984,6 +985,5 @@
 
 	++nshow;
-        if ( fmod ( nshow, 1000. ) == 0. ) 
-          log(SIGNATURE, "Event %d(+%d)\n", nshow, ntshow);
+	log(SIGNATURE, "Event %d(+%d)\n", nshow, ntshow);
 	
 	// get MCEventHeader
@@ -1037,5 +1037,5 @@
 	
 	mcevth.get_deviations ( &thetaCT, &phiCT );
-	
+
 	if ( (thetaCT == 0.) && (phiCT == 0.) ) {
 	  
@@ -1134,8 +1134,7 @@
 	  exit(1);
 	}
-	
-	if ( fmod ( nshow, 1000. ) == 0. )   
-	  log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n",
-	      ncph, ntcph);
+	  
+	log(SIGNATURE, "End of this event: %d cphs(+%d). . .\n",
+	    ncph, ntcph);
 
 	ntcph += ncph;
@@ -1159,6 +1158,5 @@
 	}
 	
-	if ( fmod ( nshow, 1000. ) == 0. ) 
-	  log(SIGNATURE, "Total number of phe:  %d \n", inumphe ) ; 
+	cout << "Total number of phes: " << inumphe <<endl;
 	
 
@@ -1175,4 +1173,5 @@
 	// TRIGGER HERE
 
+
 	//
 	//   now the noise of the electronic 
@@ -1187,11 +1186,10 @@
 	if(Trigger_Loop){
 	  //  Loop over trigger threshold
-	  for (int iconcount=0,ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++) {
+	  for (int iconcount=0,ithrescount=Trigger_loop_lthres;ithrescount<=Trigger_loop_uthres;ithrescount++){
 	    for (i=0;i<TRIGGER_PIXELS;i++)
 	      fpixelthres[i]=(float) ithrescount;
-
 	    Trigger.SetThreshold(fpixelthres);
+
 	    Trigger.Diskriminate();
-
 	    //
 	    //   look if in all the signals in the trigger signal branch
@@ -1410,13 +1408,13 @@
 			   (UShort_t) ncph) ; 
 	    }
-
 	    //   We don not count photons out of the camera.	
-	    	    
+	    
+	    
 	    //
 	    //    write it out to the file outfile
 	    // 
 	    
-	    //EvtTree.Fill() ; 
-	    // huschel
+	    EvtTree.Fill() ; 
+	    
 	  
 	  
@@ -2973,4 +2971,7 @@
 
   float t;
+  TRandom random;             // Random numbers generator
+
+  random.SetSeed ((UInt_t) (RandomNumber*1000));
 
   ii = *inphe; // avoid dereferencing
@@ -3028,7 +3029,9 @@
 
       // randomize
-      
-      inumnsbphe =  ignpoi( inumnsbphe );
-      
+
+      if (inumnsbphe>0.0){
+	inumnsbphe = random.Poisson (inumnsbphe );
+      }
+
       // create the photoelectrons
       
@@ -3069,8 +3072,12 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.12  2000/09/22 17:40:18  harald
+// Added a lot of changes done by oscar.
+//
 // Revision 1.11  2000/09/21 11:47:33  harald
 // Oscar found some smaller errors in the calculation of the pixel shape and
 // corrected it.
 //
+// $Log: not supported by cvs2svn $
 // Revision 1.10  2000/07/04 14:10:20  MagicSol
 // Some changes have been done in the root output file. The RawEvt tree is only
