Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9573)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9574)
@@ -18,4 +18,32 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2010/04/21 Thomas Bretz
+
+   * macros/rootlogon.C:
+     - a small fix which gets rid of the annoying error about an
+       unlocked mutex when starting the MStatusDisplay in the
+       interpreter. It makes sure that fGThreadFactory gets initialized
+       from the main thread.
+
+   * mbase/MStatusDisplay.cc:
+     - added a console output if TryLock fails
+     - the return value of TString::Index was misinterpreted
+
+   * mmuon/MHSingleMuon.cc:
+     - removed another reference to gMinuit
+
+   * msimcamera/MSimRandomPhotons.cc:
+     - re-did the output
+     - choose the other rate f2 instead of f1
+
+   * msimcamera/MSimTrigger.[h,cc]:
+     - keep the index of the trigger channel which finnaly issued
+       the trigger and propagate it to the event header
+
+   * mraw/MrawEvtHeader.h:
+     - implementd setter for fNumTriggerLvl1
+
+
 
  2010/04/19 Thomas Bretz
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 9573)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 9574)
@@ -12,4 +12,11 @@
    * Allow for individual mirrors with parabolic shape (for details see
      MReflector::ReadFile)
+
+   * As an additional output artificial star-files are written. They
+     contain star output compatible output based on the signal as
+     in the artificial callisto output files.
+
+   * The trigger channel which issued the trigger is now stored in
+     MRawEvtHeader::fNumTriggerLvl1
 
 
Index: /trunk/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 9573)
+++ /trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 9574)
@@ -124,4 +124,10 @@
     MLog::RedirectErrorHandler(MLog::kColor);
 
+    // This initialized the thread factory. This is needed to supress
+    // an error which is displayed if the thread factory is initialized
+    // from another than the main thread (e.g. in the constructor
+    // of MStatusDisplay)
+    TThread::Self();
+
     gInterpreter->AddIncludePath(dir+"macros");
     gInterpreter->AddIncludePath(dir+"manalysis");
Index: /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9573)
+++ /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9574)
@@ -1223,5 +1223,9 @@
     // in the same thread
     //
-    if (fMutex->TryLock())
+    const Int_t rc = fMutex->TryLock();
+    if (rc==13)
+        gLog << warn << "MStatusDisplay::UpdateTab - mutex is already locked by this thread." << endl;
+
+    if (rc)
         return;
 
@@ -2638,5 +2642,5 @@
     {
         Bool_t found = kFALSE;
-        if (name.Index("%%%%name%%%%"))
+        if (name.Index("%%%%name%%%%")>=0)
         {
             name.ReplaceAll("%%name%%", c->GetName());
@@ -2644,5 +2648,5 @@
         }
 
-        if (name.Index("%%%%title%%%%"))
+        if (name.Index("%%%%title%%%%")>=0)
         {
             name.ReplaceAll("%%title%%", c->GetTitle());
@@ -2650,5 +2654,5 @@
         }
 
-        if (name.Index("%%%%tab%%%%"))
+        if (name.Index("%%%%tab%%%%")>=0)
         {
             name.ReplaceAll("%%tab%%", MString::Format("%d", i));
Index: /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 9573)
+++ /trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc	(revision 9574)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.20 2010-04-19 12:40:16 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.21 2010-04-21 15:42:24 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -433,7 +433,5 @@
     //           Q  quiet mode
 //    fHistWidth.Fit(&f1, "QRO");
-    fHistWidth.Fit(&f1, "QRN");
-
-    if (!gMinuit)
+    if (fHistWidth.Fit(&f1, "QRN"))
         return kFALSE;
 
Index: /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 9573)
+++ /trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 9574)
@@ -56,4 +56,5 @@
 
     UInt_t   fNumTrigLvl1;     // Number of 1st level tiggers between 2 events
+                               // Used in MSimTrigger for the index of the trigger channel
     UInt_t   fNumTrigLvl2;     // Number of 2nd level tiggers between 2 events
     UInt_t   fTrigPattern[2];  // Trigger configuration
@@ -98,4 +99,5 @@
     void  SetCalibrationPattern( const UInt_t pattern )  {  fTrigPattern[1] = pattern; }
     void  SetDAQEvtNumber(const UInt_t n) { fDAQEvtNumber = n; }
+    void  SetNumTrigLvl1(UInt_t num) { fNumTrigLvl1 = num; }
 
     // TObject
Index: /trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc
===================================================================
--- /trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9573)
+++ /trunk/MagicSoft/Mars/msimcamera/MSimRandomPhotons.cc	(revision 9574)
@@ -363,21 +363,21 @@
     // *fLog << 1.75e6/(600-300) * f2 * eff->GetSpline()->Integral() << " MHz" << endl;
 
-    *fLog << "Conversion factor Fnu:      " << f  << endl;
-    *fLog << "Total reflective area:      " << Form("%.2f", Ar) << " m" << UTF8::kSquare << endl;
-    *fLog << "Acceptance area of cone 0:  " << Form("%.2f", A0*1e6) << " mm" << UTF8::kSquare << " = ";
+    *fLog << "Conversion factor Fnu:         " << f  << endl;
+    *fLog << "Total reflective area:         " << Form("%.2f", Ar) << " m" << UTF8::kSquare << endl;
+    *fLog << "Acceptance area of cone 0:     " << Form("%.2f", A0*1e6) << " mm" << UTF8::kSquare << " = ";
     *fLog << A0*conv*conv << " sr" << endl;
-    *fLog << "Cones angular acceptance:   " << sr << " sr" << endl;
-    *fLog << "ConeArea*MirrorAngle (f1):  " << f1 << " m^2 sr" << endl;
-    *fLog << "MirrorArea*ConeAngle (f2):  " << f2 << " m^2 sr" << endl;
-    *fLog << "Effective. transmission:    " << Form("%.1f", nm) << " nm" << endl;
+    *fLog << "Cones angular acceptance:      " << sr << " sr" << endl;
+    *fLog << "ConeArea*ConeSolidAngle (f1):  " << f1 << " m^2 sr" << endl;
+    *fLog << "MirrorArea*ConeSkyAngle (f2):  " << f2 << " m^2 sr" << endl;
+    *fLog << "Effective. transmission:       " << Form("%.1f", nm) << " nm" << endl;
     *fLog << "NSB freq. in " << fNameGeomCam << "[0] (f1): " << Form("%.2f", rate * f1) << " MHz" << endl;
     *fLog << "NSB freq. in " << fNameGeomCam << "[0] (f2): " << Form("%.2f", rate * f2) << " MHz" << endl;
-    *fLog << "Using f1." << endl;
+    *fLog << "Using f2." << endl;
 
     // Scale the rate per mm^2 and to GHz
-    fScale = rate * f1 / (*fGeom)[0].GetA() / 1000;
+    fScale = rate * f2 / (*fGeom)[0].GetA() / 1000;
 
     // FIXME: Scale with the number of pixels
-    if (rate*f1>1000)
+    if (rate*f2>1000)
     {
         *fLog << err << "ERROR - Frequency exceeds 1GHz, this might leed to too much memory consumption." << endl;
Index: /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc
===================================================================
--- /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc	(revision 9573)
+++ /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.cc	(revision 9574)
@@ -422,4 +422,9 @@
         return sig ? sig->GetStart() : -1;
     }
+    Int_t GetFirstIndex() const
+    {
+        MDigitalSignal *sig = static_cast<MDigitalSignal*>(fSignals[0]);
+        return sig ? sig->GetIndex() : -1;
+    }
     Bool_t GetPixelContent(Double_t&, Int_t, const MGeomCam&, Int_t) const
     {
@@ -441,5 +446,5 @@
 
 
-void MSimTrigger::SetTrigger(Double_t pos)
+void MSimTrigger::SetTrigger(Double_t pos, Int_t idx)
 {
     // FIXME: Jitter! (Own class?)
@@ -453,4 +458,5 @@
     // Flag this event as triggered by the lvl1 trigger (FIXME?)
     fEvtHeader->SetTriggerPattern(pos<0 ? 0 : pat);
+    fEvtHeader->SetNumTrigLvl1((UInt_t)idx);
     fEvtHeader->SetReadyToSave();
 }
@@ -473,5 +479,5 @@
     if (!fSimulateElectronics)
     {
-        SetTrigger(min);
+        SetTrigger(min, -1);
         return kTRUE;
     }
@@ -611,6 +617,6 @@
             }
 
-            // Set trigger channel index
-            ttl->SetIndex(j);
+            // Set trigger-channel index to keep this information
+            //ttl->SetIndex(j);
         }
 
@@ -623,5 +629,10 @@
         // FIXME: Simulate trigger dead-time!
         if (arr->GetEntriesFast()>0)
-            triggers.Add(static_cast<MDigitalSignal*>(arr->RemoveAt(0)));
+        {
+            ttl = static_cast<MDigitalSignal*>(arr->RemoveAt(0));
+            // Set trigger-channel index to keep this information
+            ttl->SetIndex(j);
+            triggers.Add(ttl);
+        }
 
         // delete the allocated space
@@ -636,5 +647,5 @@
     // FIXME: Store triggers! (+ Reversed pixels?)
 
-    SetTrigger(triggers.GetFirstTrigger());
+    SetTrigger(triggers.GetFirstTrigger(), triggers.GetFirstIndex());
 
     // No trigger issued. Go on.
Index: /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.h
===================================================================
--- /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.h	(revision 9573)
+++ /trunk/MagicSoft/Mars/msimcamera/MSimTrigger.h	(revision 9574)
@@ -48,5 +48,5 @@
     TObjArray *CalcMinMultiplicity(const MArrayI &idx, const TObjArray &ttls, Int_t threshold) const;
     TObjArray *CalcCoincidences(const MArrayI &idx, const TObjArray &ttls) const;
-    void SetTrigger(Double_t pos);
+    void SetTrigger(Double_t pos, Int_t idx);
 
     // MTask
