Index: /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 4860)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 4861)
@@ -52,5 +52,4 @@
 
 const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
-
 // --------------------------------------------------------------------------
 //
@@ -58,57 +57,96 @@
 //
 MCalibColorSet::MCalibColorSet(const char *name, const char *title)
-    : fHeader(0), fIsValid(kFALSE)
-{
-    fName  = name  ? name  : "MCalibColorSet";
-    fTitle = title ? title : "Task to set workaround missing colors calibration events";
-}
-
+    : fHeader(0)
+{
+  fName  = name  ? name  : "MCalibColorSet";
+  fTitle = title ? title : "Task to set workaround missing colors calibration events";
+
+  Clear();
+}
+
+void MCalibColorSet::Clear(const Option_t *o)
+{
+  
+  fPattern = 0;
+  fIsValid = kFALSE;
+  
+}
+
+
+// -----------------------------------------------------------------------------------
+//
+// The following container are searched for and execution aborted if not in MParList:
+//  - MRawEvtHeader
+//
 Int_t MCalibColorSet::PreProcess(MParList *pList)
 {
-    fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
-    if (!fHeader)
-    {
-       *fLog << err << "MRawEvtHeader not found... abort." << endl;
-        return kFALSE;
-    }
-    return kTRUE;
+
+  fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+  if (!fHeader)
+    {
+      *fLog << err << "MRawEvtHeader not found... abort." << endl;
+      return kFALSE;
+    }
+
+  return kTRUE;
 }
 
 // --------------------------------------------------------------------------
 //
-//  Try to find 'MGeomCam' in the Parameter List. If it is not found,
-//  processing is stopped.
+// Search for the following input containers and abort if not existing:
+// - MRawRunHeader
+//
+// If Runnumber < gkIFAEBoxInaugurationRun, set colour pattern: 0
+//
+// If Runnumber > gkIFAEBoxInaugurationRun, search for colour in 
+// the project name: Set colour pattern according to the following 
+// convention: 
+//    Green: assume slot 1  ( 5 Leds Green)
+//    Blue:  assume slot 14 ( 5 Leds Blue )
+//    UV:    assume slot 12 ( 5 Leds UV   )
+//    CT1:   take  'slot 17'
 //
 Bool_t MCalibColorSet::ReInit(MParList *pList)
 {
-    fIsValid = kFALSE;
-
-    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-    if (!header)
-    {
-       *fLog << err << "MRawRunHeader not found... abort." << endl;
-        return kFALSE;
-    }
-
-    enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
-
-    Int_t color = kNONE;
-
-    const Int_t num = header->GetRunNumber();
-    if (num<gkIFAEBoxInaugurationRun)
-    {
-        *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
-        color = kCT1;
-        return kTRUE;
-    }
-
-    switch (num)
+
+  Clear();
+
+  MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+  if (!header)
+    {
+      *fLog << err << "MRawRunHeader not found... abort." << endl;
+      return kFALSE;
+    }
+  
+  enum { kNONE, kGREEN, kBLUE, kUV, kCT1 };
+  
+  enum ColorCode_t 
+    {
+      k5LedGreen   = BIT(1),
+      k5LedUV      = BIT(12),
+      k5LedBlue    = BIT(14),
+      kCT1Pulser   = BIT(17)
+    };
+
+  const Int_t num = header->GetRunNumber();
+
+  if (num<gkIFAEBoxInaugurationRun)
+    {
+      *fLog << inf << "Run taken before inauguration of IFAE-box... using CT1 pulser." << endl;
+      fPattern |= kCT1Pulser;
+      fIsValid  = kTRUE;
+      return kTRUE;
+    }
+  
+  Int_t color = kNONE;
+
+  switch (num)
     {
     case 26402:
     case 22246:
     case 22253:
-        color = kBLUE;
-        break;
-
+      color = kBLUE;
+      break;
+      
     case 30090:
     case 20660:
@@ -119,56 +157,56 @@
     case 26568:
     case 26924:
+      color = kGREEN;
+      break;
+      
+    case 27474:
+      *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
+      return kFALSE;
+    }
+  
+  if (color!=kNONE)
+    *fLog << inf << "Color determined from the run-number... ";
+  else
+    {
+      const TString proj = header->GetProjectName();
+      
+      if (proj.Contains("gree",TString::kIgnoreCase))
         color = kGREEN;
-        break;
-
-    case 27474:
-        *fLog << err << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! " << endl;
-        return kFALSE;
-    }
-
-    if (color!=kNONE)
-        *fLog << inf << "Color determined from the run-number... ";
-    else
-    {
-        const TString proj = header->GetProjectName();
-
-        if (proj.Contains("green",TString::kIgnoreCase))
-            color = kGREEN;
-        if (proj.Contains("blue",TString::kIgnoreCase))
-            color = kBLUE;
-        if (proj.Contains("uv",TString::kIgnoreCase))
-            color = kUV;
-        if (proj.Contains("ct1",TString::kIgnoreCase))
-            color = kCT1;
-
-        *fLog << inf << "Color determined from project-name (" << proj << ")... ";
-    }
-
-    if (color==kNONE)
-    {
-        *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
-        *fLog << "flagged with a color by the digital modul and no color" << endl;
-        *fLog << "could be determined... abort." << endl;
-        return kFALSE;
-    }
-
-    switch (color)
-    {
-    case kGREEN: *fLog << "Green."; fPattern = 0; break;
-    case kBLUE:  *fLog << "Blue.";  fPattern = 0; break;
-    case kUV:    *fLog << "UV.";    fPattern = 0; break;
-    case kCT1:   *fLog << "CT1.";   fPattern = 0; break;
-    }
-    *fLog << endl;
-
-    fIsValid = kTRUE;
-
+      if (proj.Contains("blue",TString::kIgnoreCase))
+        color = kBLUE;
+      if (proj.Contains("uv",TString::kIgnoreCase))
+        color = kUV;
+      if (proj.Contains("ct1",TString::kIgnoreCase))
+        color = kCT1;
+      
+      *fLog << inf << "Color determined from project-name (" << proj << ")... ";
+    }
+  
+  if (color==kNONE)
+    {
+      *fLog << err << "Sorry, calibration run was taken before the events could be" << endl;
+      *fLog << "flagged with a color by the digital modul and no color" << endl;
+      *fLog << "could be determined... abort." << endl;
+      return kFALSE;
+    }
+  
+  switch (color)
+    {
+    case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
+    case kBLUE:  *fLog << "Blue.";  fPattern |= k5LedBlue ; break;
+    case kUV:    *fLog << "UV.";    fPattern |= k5LedUV   ; break;
+    case kCT1:   *fLog << "CT1.";   fPattern |= kCT1Pulser; break;
+    }
+  *fLog << endl;
+  
+  fIsValid = kTRUE;
+  
+  return kTRUE;
+}
+
+Int_t MCalibColorSet::Process()
+{
+    if (fIsValid)
+      fHeader->SetCalibrationPattern(fPattern);
     return kTRUE;
 }
-
-Int_t MCalibColorSet::Process()
-{
-    if (fIsValid)
-        fHeader->SetCalibrationPattern(fPattern);
-    return kTRUE;
-}
Index: /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 4860)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 4861)
@@ -26,4 +26,6 @@
     MCalibColorSet(const char *name=NULL, const char *title=NULL);
 
+    void Clear(const Option_t *o="");
+
     ClassDef(MCalibColorSet, 0) // Task to workaround missing colors
 };
