Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9347)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9348)
@@ -18,4 +18,24 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2009/02/19 Thomas Bretz
+
+   * mcorsika/MCorsikaRunHeader.[h,cc]:
+     - reformatted output
+     - added "Options" to output
+     - made Has const
+
+   * msim/MHPhotonEvent.cc:
+     - improved automatic binning
+
+   * msim/MPhotonData.[h,cc]:
+     - added GetCosW2
+     - added GetSinW2
+     - added GetSinW
+
+   * msim/MSimAbsorption.cc:
+     - don't check wavelength range when theta should be used
+
+
+
  2009/02/18 Thomas Bretz
 
Index: trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.cc	(revision 9347)
+++ trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.cc	(revision 9348)
@@ -251,25 +251,25 @@
 {
     *fLog << all << endl;
-    *fLog << "Run Number:    " << fRunNumber << "  (" << fRunStart.GetStringFmt("%d.%m.%Y") << ", V" << fProgramVersion << ")" << endl;
-    *fLog << "Particle ID:   " << MMcEvt::GetParticleName(fParticleID) << endl;
+    *fLog << "Run Number:     " << fRunNumber << "  (" << fRunStart.GetStringFmt("%d.%m.%Y") << ", V" << fProgramVersion << ")" << endl;
+    *fLog << "Particle ID:    " << MMcEvt::GetParticleName(fParticleID) << endl;
     if (fNumEvents>0)
-        *fLog << "Num Events:    " << fNumEvents << endl;
-    *fLog << "Obs Level:    ";
+        *fLog << "Num Events:     " << fNumEvents << endl;
+    *fLog << "Obs Level:     ";
     for (Byte_t i=0; i<fNumObsLevel; i++)
         *fLog << " " << fObsLevel[i]/100. << "m";
     *fLog << endl;
 
-    *fLog << "MagneticField: X/Z=(" << fMagneticFieldX << "/";
+    *fLog << "MagneticField:  X/Z=(" << fMagneticFieldX << "/";
     *fLog << fMagneticFieldZ << ")  Az=" << fMagneticFieldAz*TMath::RadToDeg() << "deg" << endl;
 
-    *fLog << "Spectrum:      Slope=" << fSlopeSpectrum << "  (" << fEnergyMin << "GeV-" << fEnergyMax << "GeV)" <<  endl;
-    *fLog << "Wavelength:    " << fWavelengthMin << "nm - " << fWavelengthMax << "nm" << endl;
+    *fLog << "Spectrum:       Slope=" << fSlopeSpectrum << "  (" << fEnergyMin << "GeV-" << fEnergyMax << "GeV)" <<  endl;
+    *fLog << "Wavelength:     " << fWavelengthMin << "nm - " << fWavelengthMax << "nm" << endl;
 
     if (fViewConeOuterAngle>0)
-        *fLog << "ViewCone:      " << fViewConeInnerAngle << "deg-" << fViewConeOuterAngle << "deg" << endl;
+        *fLog << "ViewCone:       " << fViewConeInnerAngle << "deg-" << fViewConeOuterAngle << "deg" << endl;
 
     if (fZdMax>=0)
     {
-        *fLog << "Zd/Az:         " << fZdMin << "deg";
+        *fLog << "Zd/Az:          " << fZdMin << "deg";
         if (fZdMin==fZdMax)
             *fLog << " (fixed)";
@@ -284,16 +284,35 @@
     }
 
-    *fLog << "Atm.Coeff A:  ";
+    *fLog << "Atm.Coeff A:   ";
     for (int i=0; i<5; i++)
         *fLog << " " << fAtmosphericCoeffA[i];
     *fLog << endl;
-    *fLog << "Atm.Coeff B:  ";
+    *fLog << "Atm.Coeff B:   ";
     for (int i=0; i<5; i++)
         *fLog << " " << fAtmosphericCoeffB[i];
     *fLog << endl;
-    *fLog << "Atm.Coeff C:  ";
+    *fLog << "Atm.Coeff C:   ";
     for (int i=0; i<5; i++)
         *fLog << " " << fAtmosphericCoeffC[i];
     *fLog << endl;
-}
-
+
+    *fLog << "Options used:  ";
+    if (Has(kCerenkov))
+        *fLog << " CERENKOV";
+    if (Has(kIact))
+        *fLog << " IACT";
+    if (Has(kCeffic))
+        *fLog << " CEFFIC";
+    if (Has(kAtmext))
+        *fLog << " ATMEXT";
+    if (Has(kRefraction))
+        *fLog << " AtmRefraction";
+    if (Has(kVolumedet))
+        *fLog << " VOLUMEDET";
+    if (Has(kCurved))
+        *fLog << " CURVED";
+    if (Has(kSlant))
+        *fLog << " SLANT";
+    *fLog << endl;
+}
+
Index: trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.h	(revision 9347)
+++ trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.h	(revision 9348)
@@ -102,5 +102,5 @@
     Float_t GetObsLevel(UInt_t i=0) const { return i>9 ? -1 : fObsLevel[i]; }
 
-    Bool_t Has(CerenkovFlag_t opt) { return fCerenkovFlag&opt ? 1 : 0; }
+    Bool_t Has(CerenkovFlag_t opt) const { return fCerenkovFlag&opt ? 1 : 0; }
 
     static Double_t EarthRadius() { return fgEarthRadius; }
Index: trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc	(revision 9347)
+++ trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc	(revision 9348)
@@ -258,13 +258,13 @@
     */
 
-    const Int_t f = fPermanentReset ? 2 : 1;
-
-    Double_t xmin = h->GetWavelengthMin();
-    Double_t xmax = h->GetWavelengthMax();
-    Int_t    num  = TMath::CeilNint((xmax-xmin)/(5*f));
-
-    MH::FindGoodLimits(num, num, xmin, xmax, kFALSE);
-
-    MBinning(abs(num), xmin, xmax).Apply(fHistWL);
+    const Int_t f = fPermanentReset ? 10 : 2;
+
+    Double_t xmin = h->GetWavelengthMin()-20;
+    Double_t xmax = h->GetWavelengthMax()+20;
+    Int_t    num  = TMath::CeilNint((xmax-xmin)/f);
+
+    MH::FindGoodLimits(num, num, xmin, xmax, kTRUE);
+
+    MBinning(abs(num), xmin-.5, xmax-.5).Apply(fHistWL);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/msim/MPhotonData.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MPhotonData.cc	(revision 9347)
+++ trunk/MagicSoft/Mars/msim/MPhotonData.cc	(revision 9348)
@@ -30,4 +30,6 @@
 //  Storage container to store Corsika events
 //
+// For details on the coordinate systems see our Wiki.
+//
 //   Version 1:
 //   ----------
@@ -97,9 +99,36 @@
 // --------------------------------------------------------------------------
 //
+// Return the square cosine of the Theta-angle == 1-CosU^2-CosV^2
+//
+Double_t MPhotonData::GetCosW2() const
+{
+    return 1 - GetSinW2();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the square sine of the Theta-angle == CosU^2+CosV^2
+//
+Double_t MPhotonData::GetSinW2() const
+{
+    return fCosU*fCosU + fCosV*fCosV;
+}
+
+// --------------------------------------------------------------------------
+//
 // return the cosine of the Theta-angle == sqrt(1-CosU^2-CosV^2)
 //
 Double_t MPhotonData::GetCosW() const
 {
-    return TMath::Sqrt(1 - fCosU*fCosU - fCosV*fCosV);
+    return TMath::Sqrt(GetCosW2());
+}
+
+// --------------------------------------------------------------------------
+//
+// return the sine of the Theta-angle == sqrt(CosU^2+CosV^2)
+//
+Double_t MPhotonData::GetSinW() const
+{
+    return TMath::Sqrt(GetSinW2());
 }
 
@@ -110,5 +139,5 @@
 Double_t MPhotonData::GetTheta() const
 {
-    return TMath::ACos(GetCosW());
+    return TMath::ASin(GetSinW());
 }
 
@@ -186,5 +215,5 @@
     {
         // FIXME: Could be done in MPhotonEvent::ReadCorsikaEvent
-        gLog << err << "ERROR - MPhotonData::FillCorsika: fNummPhotons not 1, but " << fNumPhotons << endl;
+        gLog << err << "ERROR - MPhotonData::FillCorsika: fNumPhotons not 1, but " << fNumPhotons << endl;
         gLog << "        This is not yet supported." << endl;
         return kERROR;
@@ -196,5 +225,5 @@
     //fCosU = f[3];  // cos to x
     //fCosV = f[4];  // cos to y
-    // x=east, y=north
+    // x=west, y=south
     fPosX =  f[2];  // [cm]
     fPosY = -f[1];  // [cm]
Index: trunk/MagicSoft/Mars/msim/MPhotonData.h
===================================================================
--- trunk/MagicSoft/Mars/msim/MPhotonData.h	(revision 9347)
+++ trunk/MagicSoft/Mars/msim/MPhotonData.h	(revision 9348)
@@ -49,8 +49,4 @@
     Float_t fWeight; //! A weight for external use
 
-protected:
-    virtual Int_t FillCorsika(Float_t f[7]);
-    virtual Int_t FillRfl(Float_t f[8]);
-
 public:
     MPhotonData(/*const char *name=NULL, const char *title=NULL*/);
@@ -64,4 +60,7 @@
     Float_t  GetCosV()  const { return fCosV; }
     Double_t GetCosW()  const;
+    Double_t GetSinW()  const;
+    Double_t GetCosW2()  const;
+    Double_t GetSinW2()  const;
     Double_t GetTheta() const;
 
@@ -111,4 +110,5 @@
     Int_t GetTag() const { return fTag; }
 
+    // TObject
     //void Clear(Option_t * = NULL);
     void Print(Option_t * = NULL) const;
@@ -124,26 +124,14 @@
         return 0;
     }
-/*
-    void FillRad(TH1 &hist, Float_t scale=1) const;
-    void FillRad(TH2 &hist, Double_t x, Float_t scale=1) const;
-    void Fill(TH2 &hist, Float_t scale=1) const;
-    void Fill(TH3 &hist, Double_t z, Float_t scale=1) const;
- */
+
+    // I/O
     Int_t ReadCorsikaEvt(istream &fin);
     Int_t ReadRflEvt(istream &fin);
 
+    Int_t FillCorsika(Float_t f[7]);
+    Int_t FillRfl(Float_t f[8]);
+
     ClassDef(MPhotonData, 1) //Container to store a cherenkov photon bunch from a CORSUKA file
 };
-/*
-class MPhotonDataWeighted : public MPhotonData
-{
-private:
-    Float_t fWeight; // A weight for external use
 
-public:
-    Float_t GetWeight() const { return fWeight; }
-
-    ClassDef(MPhotonData, 1)
-};
-*/
 #endif
Index: trunk/MagicSoft/Mars/msim/MSimAbsorption.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MSimAbsorption.cc	(revision 9347)
+++ trunk/MagicSoft/Mars/msim/MSimAbsorption.cc	(revision 9348)
@@ -264,4 +264,7 @@
 Bool_t MSimAbsorption::ReInit(MParList *pList)
 {
+    if (fUseTheta)
+        return kTRUE;
+
     MCorsikaRunHeader *h = (MCorsikaRunHeader*)pList->FindObject("MCorsikaRunHeader");
     if (!h)
