]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/CheckRaw.C
Bug fix for reading raw data - thanks Frederic YERMIA, Diego, and Gines MARTINEZ
[u/mrichter/AliRoot.git] / FMD / scripts / CheckRaw.C
1 //____________________________________________________________________
2 //
3 // $Id$
4 //
5 // Script that contains a class to compare the raw data written to the
6 // digits it's created from.
7 //
8 // Use the script `Compile.C' to compile this class using ACLic. 
9 //
10 #include <AliLog.h>
11 #include <AliFMDDigit.h>
12 #include <AliFMDInput.h>
13 #include <AliFMDUShortMap.h>
14 #include <AliFMDParameters.h>
15 #include <iostream>
16 #include <TStyle.h>
17 #include <TArrayF.h>
18 #include <TCanvas.h>
19
20 /** @class CheckRaw
21     @brief Check raw I/O
22     @code 
23     Root> .L Compile.C
24     Root> Compile("CheckRaw.C")
25     Root> CheckRaw c
26     Root> c.Run();
27     @endcode
28     @ingroup FMD_script
29  */
30 class CheckRaw : public AliFMDInput
31 {
32 public:
33   CheckRaw()
34   {
35     AddLoad(kDigits);
36     AddLoad(kRaw);
37   }
38   Bool_t Init() 
39   {
40     Bool_t ret = AliFMDInput::Init();
41     // AliFMDGeometry* geom = AliFMDGeometry::Instance();
42     // geom->Init();
43     // geom->InitTransformations();
44     AliFMDParameters* param = AliFMDParameters::Instance();
45     param->Init();
46     return ret;
47   }
48   Bool_t ProcessDigit(AliFMDDigit* digit)
49   {
50     // Cache the energy loss 
51     if (!digit) return kFALSE;
52     UShort_t det = digit->Detector();
53     Char_t   rng = digit->Ring();
54     UShort_t sec = digit->Sector();
55     UShort_t str = digit->Strip();
56     if (str > 511) {
57       AliWarning(Form("Bad strip number %d in digit", str));
58       return kTRUE;
59     }
60     fMap(det, rng, sec, str) = digit->Counts();
61     return kTRUE;
62   }
63   Bool_t ProcessRawDigit(AliFMDDigit* digit)
64   {
65     // Cache the energy loss 
66     if (!digit) return kFALSE;
67     UShort_t det = digit->Detector();
68     Char_t   rng = digit->Ring();
69     UShort_t sec = digit->Sector();
70     UShort_t str = digit->Strip();
71     if (str > 511) {
72       AliWarning(Form("Bad strip number %d in digit", str));
73       return kTRUE;
74     }
75     if (digit->Counts() != fMap(det, rng, sec, str) && 
76         fMap(det, rng, sec, str) != 1024) {
77       AliWarning(Form("Mismatch in digit FMD%d%c[%2d,%3d] %d != %d", 
78                       det, rng, sec, str, digit->Counts(), 
79                       fMap(det, rng, sec, str)));
80       return kTRUE;
81     }
82     AliDebug(1, Form("Raw digit FMD%d%c[%2d,%3D] is good", 
83                      det, rng, sec, str));
84     return kTRUE;
85   }
86 protected:
87   AliFMDUShortMap fMap;
88 };
89
90
91 //____________________________________________________________________
92 //
93 // EOF
94 //
95
96
97   
98