]>
Commit | Line | Data |
---|---|---|
45e334f8 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to PHOS digits in raw data. | |
21 | /// | |
22 | /// It loops over all PHOS digits in the raw data given by the AliRawReader. | |
23 | /// The Next method goes to the next digit. If there are no digits left | |
24 | /// it returns kFALSE. | |
25 | /// Several getters provide information about the current digit. | |
26 | /// usage: | |
27 | /// root > AliRawReaderFile rawReader ; | |
28 | /// root > AliPHOSRawStream2004 input(&rawReader) ; | |
29 | /// root > while (input.Next()) ..... | |
30 | /////////////////////////////////////////////////////////////////////////////// | |
31 | ||
32 | #include "TClonesArray.h" | |
33 | #include "TClass.h" | |
34 | ||
35 | ||
36 | ||
37 | #include "AliPHOSRawStream2004.h" | |
38 | #include "AliRawReader.h" | |
39 | #include "AliRawEventHeaderBase.h" | |
40 | #include "AliPHOSConTableDB.h" | |
41 | #include "AliPHOSDigit.h" | |
42 | ||
43 | #define EVENT_TYPE_MASK ((UInt_t)0x0000FFFF) | |
44 | ||
45 | ClassImp(AliPHOSRawStream2004) | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliPHOSRawStream2004::AliPHOSRawStream2004(AliRawReader* rawReader) : TObject() | |
49 | { | |
50 | fRawReader = rawReader ; | |
51 | fctdb = 0 ; | |
52 | } | |
53 | //_____________________________________________________________________________ | |
54 | Bool_t AliPHOSRawStream2004::ReadDigits(TClonesArray * digits){ | |
55 | ||
56 | Bool_t isOK = kFALSE ; | |
57 | if(!fctdb){ | |
58 | Error("ReadDigits","Connection table not set") ; | |
59 | return kFALSE ; | |
60 | } | |
61 | ||
62 | if(!digits){ | |
63 | Error("ReadDigits","Output array not created") ; | |
64 | return kFALSE ; | |
65 | } | |
66 | ||
67 | if(!(digits->GetClass()->InheritsFrom("AliPHOSDigit"))){ | |
68 | Error("ReadDigits","Digits contanier made for %s, not AliPHOSDigits",digits->GetClass()->GetName()) ; | |
69 | return kFALSE ; | |
70 | } | |
71 | ||
72 | digits->Clear() ; | |
73 | ||
74 | //Check, if current event - PHYSICS event | |
75 | if(!((fRawReader->GetType() & EVENT_TYPE_MASK)==AliRawEventHeaderBase::kPhysicsEvent)){ | |
76 | return kFALSE ; | |
77 | } | |
78 | ||
79 | //Scan subevents until subevent with digits | |
80 | while(fRawReader->ReadNextData(fData)){ | |
81 | switch (fRawReader->GetEquipmentType()){ | |
82 | case kPattUnitMarker: | |
83 | if(fRawReader->GetEquipmentId() == kPattUnitEquipId){ //Read PHOS trigger | |
84 | Int_t * patt = (Int_t *)fData; | |
85 | if(fRawReader->GetEquipmentSize() >= (Int_t)sizeof(Int_t)) | |
86 | fTrig = patt[0]; | |
87 | else | |
88 | fTrig = 0 ; | |
89 | } | |
90 | break; | |
91 | case kPhosAdcMarker: | |
92 | if(fRawReader->GetEquipmentId() == kPhosAdcEquipId){ | |
93 | Int_t ndigits = fRawReader->GetEquipmentSize()/sizeof(Int_t); | |
94 | digits->Expand(ndigits) ; | |
95 | for(Int_t i=0; i<ndigits; i++){ | |
96 | Int_t * amps = (Int_t *)fData ; | |
97 | Int_t absID = fctdb->Raw2AbsId(i) ; | |
98 | Int_t time = 0; | |
99 | if(absID>0) //Only real digits are filled, last ADC numbers (if any) are scipped | |
100 | new((*digits)[i]) AliPHOSDigit( -1, absID, amps[i], time) ; | |
101 | } | |
102 | digits->Sort() ; | |
103 | digits->Compress() ; | |
104 | digits->Expand(digits->GetEntriesFast()) ; | |
105 | ||
106 | //Set indexes in list of digits and make true digitization of the energy | |
107 | for (Int_t id = 0 ; id < digits->GetEntriesFast() ; id++) { | |
108 | AliPHOSDigit * digit = dynamic_cast<AliPHOSDigit*>( digits->At(id) ) ; | |
109 | digit->SetIndexInList(id) ; | |
110 | } | |
111 | ||
112 | isOK = kTRUE ; | |
113 | } | |
114 | break; | |
115 | case kTdcMarker: | |
116 | if(fRawReader->GetEquipmentId() == kTdcEquipId){ | |
117 | // Probably sometime we will need to handle these data | |
118 | } | |
119 | break; | |
120 | case kChargeAdcMarker: | |
121 | if(fRawReader->GetEquipmentId() == kChargeAdcEquipId){ | |
122 | //Probably sometime we will need to handle these data | |
123 | } | |
124 | break; | |
125 | case kScalerMarker: | |
126 | if(fRawReader->GetEquipmentId() == kScalerEquipId){ | |
127 | //Probably sometime we will need to handle these data | |
128 | } | |
129 | break; | |
130 | default: | |
131 | break; | |
132 | } | |
133 | } | |
134 | return isOK ; | |
135 | } | |
136 |