Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4992)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4993)
@@ -19,4 +19,16 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/09/14: Antonio Stamerra
+
+   * mtrigger/MTriggerIPR.h:
+     - added "=" to (idx >= gsNTrigPix) in GetPixelContent
+
+   * macros/readIPR.C:
+     - new macro to read and display the IPRs
+
+   * macro/dohtml.C:
+     - added readIPR
+		
+
  2004/09/14: Thomas Bretz
 
Index: /trunk/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 4992)
+++ /trunk/MagicSoft/Mars/macros/dohtml.C	(revision 4993)
@@ -125,3 +125,4 @@
     html.Convert("calibration.C",   "MARS - Example how to use the calibrationa camera ");
     html.Convert("bootcampstandardanalysis.C",  "MARS - Example of the status of the standard analysis at the bootcamp");
+    html.Convert("readIPR.C",       "MARS - Example to read and display the IPRs from a (merpped) report file");
 }
Index: /trunk/MagicSoft/Mars/macros/readIPR.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/readIPR.C	(revision 4993)
+++ /trunk/MagicSoft/Mars/macros/readIPR.C	(revision 4993)
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////
+// 
+//    readIPR.C
+//
+//   This macro shows how to read the Individual Pixel Rates from 
+//   a CC report file.
+//
+//   Input: 
+//     - root file obtained merpping a .rep CC file
+//       container: MTriggerIPR
+//
+//   Output:
+//     - a camera display showing the IPRs
+//     - Some histos for checking purposes
+//   
+//   Note: 
+//     a similar macro can be used to read the following trigger containers:
+//     - MTriggerIPR        (Individual Pixel Rates)
+//     - MTriggerCell       (Rate of trigger cells)
+//     - MTriggerBit        (Output Bits from prescaler (before/after presc.)
+//     - MTriggerPrescFact  (Prescaling factors for each bit)
+//     - MTriggerLiveTime   (Values of counters for dead/livetime)
+//
+//    Author(s): Antonio Stamerra. 09/04 <antonio.stamerra@pi.infn.it>
+//
+////////////////////////////////////////////////////////////////////////////
+void readIPR(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // Create the magic geometry
+    MGeomCamMagic geom;
+    plist.AddToList(&geom);
+
+    // First Task: Read ROOT file with Trigger-REPORT data
+    MReadTree read("Trigger", fname);
+    read.DisableAutoScheme();
+
+    tlist.AddToList(&read);
+
+    // Create the container for the IPRs
+    MTriggerIPR ipr;
+    plist.AddToList(&ipr);
+
+    // Create the histo to display the IPRs
+    MHCamEvent IPRhist("IPRhist","IPRs");
+    plist.AddToList(&IPRhist);
+        
+    // create a task to fill a histogram from the container
+    MFillH fillIPR(&IPRhist, "MTriggerIPR");
+    tlist.AddToList(&fillIPR);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute the analysis
+    //
+    if (!evtloop.PreProcess())
+      return;
+    
+    if (!evtloop.Eventloop())
+      return;
+
+    tlist.PrintStatistics();
+
+    //-----------------------------------
+    // Now display the result of the loop
+    //
+
+    // create a MHCamera histo where the sum off all events is filled
+    MHCamera &h = *(MHCamera*)IPRhist.GetHistByName("sum");
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(2, 2);
+
+    MHCamera *disp1=h.Clone();
+    MHCamera *disp2=h.Clone();
+    //MHCamera *disp3=h.Clone();
+    disp2->SetCamContent(h, 1);
+    //disp3->SetCamContent(h, 2);
+
+    disp1->SetYTitle("Rate [Hz]");
+    disp2->SetYTitle("\\sigma_{Rate} [Hz]");
+    //disp3->SetYTitle("\\sigma_{Rate} [%]");
+    disp1->SetName("IPRs;avg");
+    disp2->SetName("IPRs;err");
+    //disp3->SetName("IPRs;rel");
+    disp1->SetTitle("IPRs Average");
+    disp2->SetTitle("IPRs error");
+    //disp3->SetTitle("IPRs relative error");
+
+    c->cd(1);
+    TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.03);
+    text.DrawClone();
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetLogy();
+    disp1->Draw();
+    disp1->SetBit(kCanDelete);
+    c->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetLogy();
+    disp2->Draw();
+    disp2->SetBit(kCanDelete);
+    //c->cd(3);
+    //gPad->SetBorderMode(0);
+    //gPad->Divide(1,1);
+    //gPad->cd(1);
+    //gPad->SetLogy();
+    //disp3->Draw();
+    //disp3->SetBit(kCanDelete);
+    c->cd(3);
+    gPad->SetBorderMode(0);
+    disp1->Draw("EPhist");
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetLogy();
+    disp2->Draw("Phist");
+    //c->cd(6);
+    //gPad->SetBorderMode(0);
+    //gPad->SetLogy();
+    //disp3->Draw("Phist");
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
Index: /trunk/MagicSoft/Mars/mtrigger/MTriggerIPR.h
===================================================================
--- /trunk/MagicSoft/Mars/mtrigger/MTriggerIPR.h	(revision 4992)
+++ /trunk/MagicSoft/Mars/mtrigger/MTriggerIPR.h	(revision 4993)
@@ -33,5 +33,5 @@
     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
     {
-      if (idx > gsNTrigPix)
+      if (idx >= gsNTrigPix)
 	return kFALSE;
 
