acorde_raw.C 3.29 KB
Newer Older
mtadel's avatar
mtadel committed
1
// $Id$
mtadel's avatar
mtadel committed
2
3
4
5
6
7
8
// 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.                                                 *
 **************************************************************************/
quark's avatar
quark committed
9
10
11
12
13
14
15
16
17
18
19
#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>

20
21
22
#include <AliEveEventManager.h>
#include <AliRawReader.h>
#include <AliACORDERawStream.h>
quark's avatar
quark committed
23
#endif
mtadel's avatar
mtadel committed
24
25
26

TString acorde_module_path(Int_t module);

mtadel's avatar
mtadel committed
27
28
29
30
31
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;
mtadel's avatar
mtadel committed
32
33
34

void acorde_raw()
{
35
36
37

  // From Mario RC

38
  AliEveEventManager::GetMaster()->AssertGeometry();
39

mtadel's avatar
mtadel committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  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]);

54
55
56
57
58
59
  if (acorde_module_path(0).IsNull())
  {
    Warning("acorde_raw", "Missing / wrong ACORDE module geometry.");
    return;
  }

60
  TEveElementList* acorde = new TEveElementList("ACORDE_Raw");
mtadel's avatar
mtadel committed
61
62
63

  gEve->AddElement(acorde);

mtadel's avatar
mtadel committed
64
  for (Int_t module=0; module < 60; module++)
mtadel's avatar
mtadel committed
65
66
67
68
69
  {
    TString path = acorde_module_path(module);

    if ( ! gGeoManager->cd(path))
    {
70
      Warning("acorde_raw", "Module id=%d, path='%s' not found.", module, path.Data());
mtadel's avatar
mtadel committed
71
72
73
74
      continue;
    }

    // From Matevz:
mtadel's avatar
mtadel committed
75
    // Here check state and assign color, I do it partially for now.
mtadel's avatar
mtadel committed
76
77
    Int_t  word_idx = module / 30;
    Int_t  bit_idx  = module % 30;
78
    Bool_t val      = (dy[word_idx] & (1 << bit_idx)) != 0; 
mtadel's avatar
mtadel committed
79
80

    TEveGeoShape* eg_shape = new TEveGeoShape(TString::Format("Module %d", module),
81
                                              TString::Format("Module %d, %s", module, val ? "Fired" : "Not fired"));
mtadel's avatar
mtadel committed
82
83
    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);
mtadel's avatar
mtadel committed
84
85
86
    eg_shape->SetPickable(kTRUE);
    eg_shape->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
    eg_shape->SetShape((TGeoShape*) gGeoManager->GetCurrentVolume()->GetShape()->Clone());
mtadel's avatar
mtadel committed
87
88
89
90

    acorde->AddElement(eg_shape);
  }

mtadel's avatar
mtadel committed
91
  delete stream;
mtadel's avatar
mtadel committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  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 "";
  }

106
  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(Form("ACORDE/Array%d", module));
107
  if (!pne) return "";
mtadel's avatar
mtadel committed
108

mtadel's avatar
mtadel committed
109
110
  return Form("%s/ACORDESCINTILLATORMODULE_6", pne->GetTitle());

mtadel's avatar
mtadel committed
111
}