ROOT logo
// $Id$
// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007

/**************************************************************************
 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
 * full copyright notice.                                                 *
 **************************************************************************/
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TTree.h>
#include <TString.h>
#include <TGeoManager.h>
#include <TGeoPhysicalNode.h>
#include <TGeoMatrix.h>
#include <TEveManager.h>
#include <TEveElement.h>
#include <TEveTrans.h>
#include <TEveGeoShape.h>

#include <AliEveEventManager.h>
#include <AliRawReader.h>
#include <AliACORDERawStream.h>
#endif

TString acorde_module_path(Int_t module);

Color_t g_acorde_raw_color_on  = kRed;
Color_t g_acorde_raw_color_off = kBlue;

UChar_t g_acorde_raw_transp_on  = 30;
UChar_t g_acorde_raw_transp_off = 60;

void acorde_raw()
{

  // From Mario RC

  AliEveEventManager::AssertGeometry();

  AliRawReader       * reader = AliEveEventManager::AssertRawReader();
  AliACORDERawStream * stream = new AliACORDERawStream(reader);

  stream->Reset();
  stream->Next();

  UInt_t dy[4];
  dy[0] = stream->GetWord(0);
  dy[1] = stream->GetWord(1);
  dy[2] = stream->GetWord(2);
  dy[3] = stream->GetWord(3);

  printf ("ACORDE event 0x%08x 0x%08x 0x%08x 0x%08x\n", dy[0], dy[1], dy[2], dy[3]);

  if (acorde_module_path(0).IsNull())
  {
    Warning("acorde_raw", "Missing / wrong ACORDE module geometry.");
    return;
  }

  TEveElementList* acorde = new TEveElementList("ACORDE_Raw");

  gEve->AddElement(acorde);

  for (Int_t module=0; module < 60; module++)
  {
    TString path = acorde_module_path(module);

    if ( ! gGeoManager->cd(path))
    {
      Warning("acorde_raw", "Module id=%d, path='%s' not found.", module, path.Data());
      continue;
    }

    // From Matevz:
    // Here check state and assign color, I do it partially for now.
    Int_t  word_idx = module / 30;
    Int_t  bit_idx  = module % 30;
    Bool_t val      = (dy[word_idx] & (1 << bit_idx)) != 0; 

    TEveGeoShape* eg_shape = new TEveGeoShape(TString::Format("Module %d", module),
                                              TString::Format("Module %d, %s", module, val ? "Fired" : "Not fired"));
    eg_shape->SetMainColor       (val ? g_acorde_raw_color_on  : g_acorde_raw_color_off);
    eg_shape->SetMainTransparency(val ? g_acorde_raw_transp_on : g_acorde_raw_transp_off);
    eg_shape->SetPickable(kTRUE);
    eg_shape->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
    eg_shape->SetShape((TGeoShape*) gGeoManager->GetCurrentVolume()->GetShape()->Clone());

    acorde->AddElement(eg_shape);
  }

  delete stream;
  gEve->Redraw3D();
}

//==============================================================================
//==============================================================================

TString acorde_module_path(Int_t module)
{
  if (module < 0 || module > 59)
  {
    Error("acorde_module_path", "module %d out of range.", module);
    return "";
  }

  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("ACORDE/Array%d", module));
  if (!pne) return "";

  return Form("%s/ACORDESCINTILLATORMODULE_6", pne->GetTitle());

}
 acorde_raw.C:1
 acorde_raw.C:2
 acorde_raw.C:3
 acorde_raw.C:4
 acorde_raw.C:5
 acorde_raw.C:6
 acorde_raw.C:7
 acorde_raw.C:8
 acorde_raw.C:9
 acorde_raw.C:10
 acorde_raw.C:11
 acorde_raw.C:12
 acorde_raw.C:13
 acorde_raw.C:14
 acorde_raw.C:15
 acorde_raw.C:16
 acorde_raw.C:17
 acorde_raw.C:18
 acorde_raw.C:19
 acorde_raw.C:20
 acorde_raw.C:21
 acorde_raw.C:22
 acorde_raw.C:23
 acorde_raw.C:24
 acorde_raw.C:25
 acorde_raw.C:26
 acorde_raw.C:27
 acorde_raw.C:28
 acorde_raw.C:29
 acorde_raw.C:30
 acorde_raw.C:31
 acorde_raw.C:32
 acorde_raw.C:33
 acorde_raw.C:34
 acorde_raw.C:35
 acorde_raw.C:36
 acorde_raw.C:37
 acorde_raw.C:38
 acorde_raw.C:39
 acorde_raw.C:40
 acorde_raw.C:41
 acorde_raw.C:42
 acorde_raw.C:43
 acorde_raw.C:44
 acorde_raw.C:45
 acorde_raw.C:46
 acorde_raw.C:47
 acorde_raw.C:48
 acorde_raw.C:49
 acorde_raw.C:50
 acorde_raw.C:51
 acorde_raw.C:52
 acorde_raw.C:53
 acorde_raw.C:54
 acorde_raw.C:55
 acorde_raw.C:56
 acorde_raw.C:57
 acorde_raw.C:58
 acorde_raw.C:59
 acorde_raw.C:60
 acorde_raw.C:61
 acorde_raw.C:62
 acorde_raw.C:63
 acorde_raw.C:64
 acorde_raw.C:65
 acorde_raw.C:66
 acorde_raw.C:67
 acorde_raw.C:68
 acorde_raw.C:69
 acorde_raw.C:70
 acorde_raw.C:71
 acorde_raw.C:72
 acorde_raw.C:73
 acorde_raw.C:74
 acorde_raw.C:75
 acorde_raw.C:76
 acorde_raw.C:77
 acorde_raw.C:78
 acorde_raw.C:79
 acorde_raw.C:80
 acorde_raw.C:81
 acorde_raw.C:82
 acorde_raw.C:83
 acorde_raw.C:84
 acorde_raw.C:85
 acorde_raw.C:86
 acorde_raw.C:87
 acorde_raw.C:88
 acorde_raw.C:89
 acorde_raw.C:90
 acorde_raw.C:91
 acorde_raw.C:92
 acorde_raw.C:93
 acorde_raw.C:94
 acorde_raw.C:95
 acorde_raw.C:96
 acorde_raw.C:97
 acorde_raw.C:98
 acorde_raw.C:99
 acorde_raw.C:100
 acorde_raw.C:101
 acorde_raw.C:102
 acorde_raw.C:103
 acorde_raw.C:104
 acorde_raw.C:105
 acorde_raw.C:106
 acorde_raw.C:107
 acorde_raw.C:108
 acorde_raw.C:109
 acorde_raw.C:110
 acorde_raw.C:111
 acorde_raw.C:112