Line data Source code
1 : /**************************************************************************
2 : * This file is property of and copyright by the ALICE HLT Project *
3 : * All rights reserved. *
4 : * *
5 : * Primary Authors: Freancesco Blanco *
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 : #include "AliHLTEMCALClusterMonitorComponent.h"
17 : #include "AliHLTEMCALClusterMonitor.h"
18 :
19 : #include "TFile.h"
20 : #include "TString.h"
21 :
22 :
23 :
24 : /**
25 : * @file AliHLTEMCALClusterMonitorComponent.cxx
26 : * @author Francesco Blanco
27 : * @date
28 : * @brief A component to pusk back histograms for EMCAL HLT
29 : */
30 :
31 : //FIXME
32 6 : AliHLTEMCALClusterMonitorComponent gAliHLTEMCALClusterMonitorComponent;
33 :
34 : AliHLTEMCALClusterMonitorComponent::AliHLTEMCALClusterMonitorComponent() :
35 3 : AliHLTCaloProcessor(),
36 3 : fRootFileName("histofile_local.root"),
37 3 : fPushFraction(10),
38 3 : fLocalEventCount(0),
39 3 : fBeVerbose(0),
40 3 : fHistoMakerPtr(0)
41 15 : {
42 : //see header file for documentation
43 6 : }
44 :
45 :
46 : AliHLTEMCALClusterMonitorComponent::~AliHLTEMCALClusterMonitorComponent()
47 12 : {
48 : //see header file for documentation
49 6 : }
50 :
51 :
52 : int
53 : AliHLTEMCALClusterMonitorComponent::DoInit(int argc, const char** argv )
54 : {
55 : //see header file for documentation
56 :
57 0 : fHistoMakerPtr = new AliHLTEMCALClusterMonitor();
58 0 : SetupCTPData();
59 0 : for(int i = 0; i < argc; i++)
60 : {
61 0 : if(!strcmp("-roothistofilename", argv[i]))
62 0 : fRootFileName = argv[i+1];
63 :
64 0 : if(!strcmp("-pushfraction", argv[i]))
65 0 : fPushFraction = atoi(argv[i+1]);
66 :
67 0 : if(!strcmp("-beverbose", argv[i]))
68 0 : fBeVerbose = atoi(argv[i+1]);
69 :
70 : }
71 :
72 0 : if (fBeVerbose) cout << "\nI-CLUSTERMONITORCOMPONENT: local root file name is: " << fRootFileName << endl;
73 :
74 0 : return 0;
75 0 : }
76 :
77 :
78 : int
79 : AliHLTEMCALClusterMonitorComponent::Deinit()
80 : {
81 : //see header file for documentation
82 0 : if(fHistoMakerPtr)
83 : {
84 0 : delete fHistoMakerPtr;
85 0 : fHistoMakerPtr = 0;
86 0 : }
87 :
88 0 : return 0;
89 : }
90 :
91 : const char*
92 : AliHLTEMCALClusterMonitorComponent::GetComponentID()
93 : {
94 : //see header file for documentation
95 360 : return "EmcalClusterMonitor";
96 : }
97 :
98 :
99 : void
100 : AliHLTEMCALClusterMonitorComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
101 : {
102 : //see header file for documentation
103 0 : list.clear();
104 0 : list.push_back(kAliHLTDataTypeCaloCluster);
105 0 : }
106 :
107 : AliHLTComponentDataType
108 : AliHLTEMCALClusterMonitorComponent::GetOutputDataType()
109 : {
110 : //see header file for documentation
111 0 : return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
112 : }
113 :
114 : void
115 : AliHLTEMCALClusterMonitorComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
116 : {
117 : //see header file for documentation
118 0 : constBase = 0;
119 : // to be reviewed later
120 0 : inputMultiplier = 100;
121 0 : }
122 :
123 : int
124 : AliHLTEMCALClusterMonitorComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
125 : AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
126 : std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
127 : {
128 :
129 :
130 : const AliHLTComponentBlockData* iter = 0;
131 : unsigned long ndx;
132 :
133 : UInt_t specification = 0;
134 0 : for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
135 : {
136 :
137 : AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = 0;
138 :
139 0 : iter = blocks+ndx;
140 :
141 0 : if (fBeVerbose) PrintComponentDataTypeInfo(iter->fDataType);
142 :
143 0 : if (iter->fDataType == kAliHLTDataTypeCaloCluster) caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(iter->fPtr);
144 : else {
145 0 : if(fBeVerbose) HLTWarning("\nI-CLUSTERMONITORCOMPONENT: Data block does not contain cluster type \n");
146 : }
147 :
148 :
149 0 : specification |= iter->fSpecification;
150 0 : fHistoMakerPtr->MakeHisto(caloClusterHeaderPtr);
151 :
152 : }
153 :
154 :
155 0 : fLocalEventCount++;
156 :
157 0 : TFile rootHistFile(fRootFileName,"recreate");
158 :
159 0 : fHistoMakerPtr->GetHistograms()->Write();
160 :
161 0 : if (fLocalEventCount%fPushFraction == 0) {
162 :
163 0 : if (fBeVerbose) cout << "\nI-CLUSTERMONITORCOMPONENT: pushback done at " << fLocalEventCount << " events " << endl;
164 :
165 0 : PushBack(fHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
166 : }
167 :
168 : return 0;
169 0 : }
170 :
171 :
172 : AliHLTComponent*
173 : AliHLTEMCALClusterMonitorComponent::Spawn()
174 : {
175 : //see header file for documentation
176 0 : return new AliHLTEMCALClusterMonitorComponent();
177 0 : }
|