]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDGlobalMonitorComponent.cxx
adding new TRD trigger monitoring components (Stefan Kirsch, Felix Rettig)
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDGlobalMonitorComponent.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Felix Rettig, Stefan Kirsch                           *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
9 //* Permission to use, copy, modify and distribute this software and its   *
10 //* documentation strictly for non-commercial purposes is hereby granted   *
11 //* without fee, provided that the above copyright notice appears in all   *
12 //* copies and that both the copyright notice and this permission notice   *
13 //* appear in the supporting documentation. The authors make no claims     *
14 //* about the suitability of this software for any purpose. It is          *
15 //* provided "as is" without express or implied warranty.                  *
16 //**************************************************************************
17
18 /// @file   AliHLTTRDGlobalMonitorComponent.cxx
19 /// @author Felix Rettig, Stefan Kirsch
20 /// @date   2011-08-02
21 /// @brief  A processing component for TRD tracking/trigger data on CN-level
22 ///
23
24 #include "AliHLTTRDGlobalMonitorComponent.h"
25 #include "AliHLTDataTypes.h"
26 #include "AliHLTTRDDefinitions.h"
27 #include "TH1F.h"
28 #include "TH1I.h"
29 #include "TH2I.h"
30 #include "TObjString.h"
31 #include "TObjArray.h"
32
33 #define TRDMODULES 18
34 #define TRDMAXDDLSIZE 10000
35
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTTRDGlobalMonitorComponent)
38
39 AliHLTTRDGlobalMonitorComponent::AliHLTTRDGlobalMonitorComponent()
40   :
41     fHistArray(NULL)
42   , fHistTrackletY(NULL)
43   , fHistTrackletDy(NULL)
44   , fHistTrackletZ(NULL)
45   , fHistTrackletPID(NULL)
46   , fHistTrackletYDy(NULL)
47   , fHistTrackletHC(NULL)
48   , fHistTrackletBadY(NULL)
49   , fHistTrackletBadPID(NULL)
50   , fHistFirstTrackletTime(NULL)
51   , fHistLastTrackletTime(NULL)
52   , fHistTmuTime(NULL)
53   , fHistSmuTime(NULL)
54   , fHistTrackPt(NULL)
55   , fHistTrackPID(NULL)
56   , fHistTrackStack(NULL)
57   , fHistTrackletsTrack(NULL)
58   , fHistTrackletsTrackHpt(NULL)
59   , fHistTriggerContribs(NULL)
60 {
61   // see header file for class documentation
62   // or
63   // refer to README to build package
64   // or
65   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66 }
67
68 AliHLTTRDGlobalMonitorComponent::~AliHLTTRDGlobalMonitorComponent()
69 {
70   // see header file for class documentation
71 }
72
73 const char* AliHLTTRDGlobalMonitorComponent::GetComponentID()
74 {
75   // see header file for class documentation
76   return "TRDGlobalMonitorComponent";
77 }
78
79 void AliHLTTRDGlobalMonitorComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
80 {
81   // see header file for class documentation
82   // list.push_back(AliHLTTRDDefinitions::fgkSimpleIntegerDataType);
83   list.push_back(kAliHLTDataTypeTObject | kAliHLTDataOriginTRD);
84 }
85
86 AliHLTComponentDataType AliHLTTRDGlobalMonitorComponent::GetOutputDataType()
87 {
88   // see header file for class documentation
89   return (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTRD);
90 }
91
92 void AliHLTTRDGlobalMonitorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
93 {
94   // see header file for class documentation
95   constBase = 10000000;
96   inputMultiplier = 0;
97 }
98
99 AliHLTComponent* AliHLTTRDGlobalMonitorComponent::Spawn()
100 {
101   // see header file for class documentation
102   return new AliHLTTRDGlobalMonitorComponent;
103 }
104
105 int AliHLTTRDGlobalMonitorComponent::DoInit( int argc, const char** argv )
106 {
107   fHistArray = new TObjArray(25);
108   if(!fHistArray)
109     return -ENOMEM;
110   fHistArray->SetOwner(kTRUE);
111
112   fHistTrackletY = new TH1I("hist_tracklets_y", "Y-Position of online tracklets", 256, -4096, 4096);
113   fHistArray->AddLast(fHistTrackletY);
114
115   fHistTrackletDy = new TH1I("hist_tracklets_dy", "Deflections of online tracklets", 128, -64, 64);
116   fHistArray->AddLast(fHistTrackletDy);
117
118   fHistTrackletZ = new TH1I("hist_tracklets_z", "Z-Position of online tracklets", 12, 0, 12);
119   fHistArray->AddLast(fHistTrackletZ);
120
121   fHistTrackletPID = new TH1I("hist_tracklets_pid", "PID of online tracklets", 256, 0, 256);
122   fHistArray->AddLast(fHistTrackletPID);
123
124   fHistTrackletYDy = new TH2I("hist_tracklets_y_dy", "Tracklet deflection vs. tracklet position", 256, -4096, 4096, 64, -64, 64);
125   fHistArray->AddLast(fHistTrackletYDy);
126
127   fHistTrackletHC = new TH2I("hist_tracklets_hc", "Number of online tracklets by HC", 18, 0, 18, 60, 0, 60);
128   fHistArray->AddLast(fHistTrackletHC);
129
130   fHistTrackletBadY = new TH2I("hist_tracklets_bad_y", "Number of online tracklets with bad y-position by stack", 18, 0, 18, 5, 0, 5);
131   fHistArray->AddLast(fHistTrackletBadY);
132
133   fHistTrackletBadPID = new TH2I("hist_tracklets_bad_pid", "Number of online tracklets with bad PID value by stack", 18, 0, 18, 5, 0, 5);
134   fHistArray->AddLast(fHistTrackletBadPID);
135
136   fHistFirstTrackletTime = new TH1F("hist_first_tracklet_time", "Arrival time of first tracklet", 160, 0., 8.);
137   fHistArray->AddLast(fHistFirstTrackletTime);
138
139   fHistLastTrackletTime = new TH1F("hist_last_tracklet_time", "Arrival time of last tracklet", 160, 0., 8.);
140   fHistArray->AddLast(fHistLastTrackletTime);
141
142   fHistTmuTime = new TH1F("hist_tmu_time", "Tracking done time TMU-level", 160, 0., 8.);
143   fHistArray->AddLast(fHistTmuTime);
144
145   fHistSmuTime = new TH1F("hist_smu_time", "Tracking done time SMU-level", 160, 0., 8.);
146   fHistArray->AddLast(fHistSmuTime);
147
148   fHistTrackPt = new TH1F("hist_tracks_pt", "Transverse momentum of GTU  tracks", 100, 0., 20.);
149   fHistArray->AddLast(fHistTrackPt);
150
151   fHistTrackPID = new TH1I("hist_tracks_pid", "PID value of GTU  tracks", 256, 0, 256);
152   fHistArray->AddLast(fHistTrackPID);
153
154   fHistTrackStack = new TH2I("hist_tracks_stack", "Number of GTU tracks by stack", 18, 0, 18, 5, 0, 5);
155   fHistArray->AddLast(fHistTrackStack);
156
157   fHistTrackletsTrack = new TH1I("hist_tracklets_track", "Tracklets per GTU track", 7, 0, 7);
158   fHistArray->AddLast(fHistTrackletsTrack);
159
160   fHistTrackletsTrackHpt = new TH1I("hist_tracklets_track_hpt", "Tracklets per high-pt GTU track", 7, 0, 7);
161   fHistArray->AddLast(fHistTrackletsTrackHpt);
162
163   fHistTriggerContribs = new TH2I("hist_trigger_contribs", "Trigger contributions by segment", 18, 0, 18, 12, 0, 12);
164   fHistArray->AddLast(fHistTriggerContribs);
165
166   return 0;
167 }
168
169 int AliHLTTRDGlobalMonitorComponent::DoDeinit()
170 {
171   if(fHistArray){
172     fHistArray->Clear();
173     delete fHistArray;
174     fHistArray=NULL;
175   }
176   return 0;
177 }
178
179 int AliHLTTRDGlobalMonitorComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
180 {
181  
182   int iResult=0;
183   //  Int_t totaleventsize=0;
184
185   /*
186   //Loop over integers
187   for (const AliHLTComponentBlockData* pBlock = GetFirstInputBlock(AliHLTTRDDefinitions::fgkSimpleIntegerDataType);
188        pBlock!=NULL && iResult>=0;
189        pBlock=GetNextInputBlock()) {
190     // extract DDL id from specification
191     int ddlnum=-1;
192     for (unsigned pos=0; pos<8*sizeof(AliHLTUInt32_t); pos++) {
193       if (pBlock->fSpecification & (0x1<<pos)) {
194         if (ddlnum>=0) {
195           HLTWarning("Can not uniquely identify DDL number from specification, skipping data block %s 0x%08x",
196                      DataType2Text(pBlock->fDataType).c_str(),
197                      pBlock->fSpecification);
198           ddlnum=-1;
199           break;
200         }
201         ddlnum=pos;
202       }
203     }
204     if (ddlnum<0 || ddlnum >= TRDMODULES) continue;
205
206     if ( pBlock->fSize < sizeof(Int_t) ) {
207       HLTWarning("block size (%d) smaller than expected size (%d)!", pBlock->fSize, sizeof(Int_t) );
208       continue;
209     } 
210
211     Int_t* eventsize = (Int_t *) pBlock->fPtr;
212     if(*eventsize > TRDMAXDDLSIZE)
213       HLTWarning("eventsize (%d) larger than histogram range (%d)", *eventsize, TRDMAXDDLSIZE);
214     // Fill histo of ddl
215     TH1F* h = dynamic_cast<TH1F*>(fHistoArray->At(ddlnum));
216     h->Fill((Double_t)*eventsize);
217
218     totaleventsize += *eventsize;
219   }
220   */
221
222   // reset the high-level histograms, the accumulation over events is done in the lower level
223   fHistTrackletY->Reset();
224   fHistTrackletDy->Reset();
225   fHistTrackletZ->Reset();
226   fHistTrackletPID->Reset();
227   fHistTrackletYDy->Reset();
228   fHistTrackletHC->Reset();
229   fHistTrackletBadY->Reset();
230   fHistTrackletBadPID->Reset();
231   fHistFirstTrackletTime->Reset();
232   fHistLastTrackletTime->Reset();
233   fHistTmuTime->Reset();
234   fHistSmuTime->Reset();
235   fHistTrackPt->Reset();
236   fHistTrackPID->Reset();
237   fHistTrackStack->Reset();
238   fHistTrackletsTrack->Reset();
239   fHistTrackletsTrackHpt->Reset();
240   fHistTriggerContribs->Reset();
241
242   // loop over TObject-based input data
243   for (const TObject* obj = 
244          GetFirstInputObject(kAliHLTDataTypeTObject | kAliHLTDataOriginTRD, "TObjArray");
245        obj!=NULL && iResult>=0;
246        obj=GetNextInputObject()) {
247     // extract DDL id from specification
248     int ddlnum=-1;
249     AliHLTUInt32_t specification = GetSpecification(obj);
250     for (unsigned pos=0; pos<8*sizeof(AliHLTUInt32_t); pos++) {
251       if (specification & (0x1<<pos)) {
252         if (ddlnum>=0) {
253           HLTWarning("Can not uniquely identify DDL number from specification, skipping data block %s 0x%08x",
254                      DataType2Text(GetDataType(obj)).c_str(),
255                      specification);
256           ddlnum=-1;
257           break;
258         }
259               ddlnum=pos;
260       }
261     }
262     if (ddlnum<0 || ddlnum >= TRDMODULES) continue;
263     
264     // input object is a TObjArray containing the actual data containers
265     const TObjArray* histArray = dynamic_cast<const TObjArray*>(obj);
266     if (!histArray){
267       HLTWarning("Received object was not a TObjAarray");
268       continue;
269     }
270
271     // extract data containers and process the data
272
273     TH1I *hist1 = (TH1I*)histArray->FindObject("hist_tracklets_y");
274     if (hist1){
275       fHistTrackletY->Add(hist1);
276     } else
277       HLTWarning("Tracklet y-position histogram not found!");
278
279     hist1 = (TH1I*)histArray->FindObject("hist_tracklets_dy");
280     if (hist1){
281       fHistTrackletDy->Add(hist1);
282     } else
283       HLTWarning("Tracklet deflection histogram not found!");
284
285     hist1 = (TH1I*)histArray->FindObject("hist_tracklets_z");
286     if (hist1){
287       fHistTrackletZ->Add(hist1);
288     } else
289       HLTWarning("Tracklet z-position histogram not found!");
290
291     hist1 = (TH1I*)histArray->FindObject("hist_tracklets_pid");
292     if (hist1){
293       fHistTrackletPID->Add(hist1);
294     } else
295       HLTWarning("Tracklet PID histogram not found!");
296
297     TH2I *hist2 = (TH2I*)histArray->FindObject("hist_tracklets_y_dy");
298     if (hist2){
299       fHistTrackletYDy->Add(hist2);
300     } else
301       HLTWarning("Tracklet y vs. dy histogram not found!");
302
303     hist2 = (TH2I*)histArray->FindObject("hist_tracklets_hc");
304     if (hist2){
305       fHistTrackletHC->Add(hist2);
306     } else
307       HLTWarning("Tracklet number histogram not found!");
308
309     hist2 = (TH2I*)histArray->FindObject("hist_tracklets_bad_y");
310     if (hist2){
311       fHistTrackletBadY->Add(hist2);
312     } else
313       HLTWarning("Tracklet number with bad y-position histogram not found!");
314
315     hist2 = (TH2I*)histArray->FindObject("hist_tracklets_bad_pid");
316     if (hist2){
317       fHistTrackletBadPID->Add(hist2);
318     } else
319       HLTWarning("Tracklet number with bad y-position histogram not found!");
320
321     TH1F *hist3 = (TH1F*)histArray->FindObject("hist_first_tracklet_time");
322     if (hist3){
323       fHistFirstTrackletTime->Add(hist3);
324     } else
325       HLTWarning("First tracklet arrival  histogram not found!");
326
327     hist3 = (TH1F*)histArray->FindObject("hist_last_tracklet_time");
328     if (hist3){
329       fHistLastTrackletTime->Add(hist3);
330     } else
331       HLTWarning("Last tracklet arrival time histogram not found!");
332
333     hist3 = (TH1F*)histArray->FindObject("hist_tmu_time");
334     if (hist3){
335       fHistTmuTime->Add(hist3);
336     } else
337       HLTWarning("TMU-level tracking done time histogram not found!");
338
339     hist3 = (TH1F*)histArray->FindObject("hist_smu_time");
340     if (hist3){
341       fHistSmuTime->Add(hist3);
342     } else
343       HLTWarning("SMU-level tracking done time histogram not found!");
344
345     hist3 = (TH1F*)histArray->FindObject("hist_tracks_pt");
346     if (hist3){
347       fHistTrackPt->Add(hist3);
348     } else
349       HLTWarning("Track pt histogram not found!");
350
351     hist1 = (TH1I*)histArray->FindObject("hist_tracks_pid");
352     if (hist1){
353       fHistTrackPID->Add(hist1);
354     } else
355       HLTWarning("Tracklet PID histogram not found!");
356
357     hist2 = (TH2I*)histArray->FindObject("hist_tracks_stack");
358     if (hist2){
359       fHistTrackStack->Add(hist2);
360     } else
361       HLTWarning("Track number histogram not found!");
362
363     hist1 = (TH1I*)histArray->FindObject("hist_tracklets_track");
364     if (hist1){
365       fHistTrackletsTrack->Add(hist1);
366     } else
367       HLTWarning("Tracklets per GTU track histogram not found!");
368
369     hist1 = (TH1I*)histArray->FindObject("hist_tracklets_track_hpt");
370     if (hist1){
371       fHistTrackletsTrackHpt->Add(hist1);
372     } else
373       HLTWarning("Tracklets per high-pt GTU track histogram not found!");
374
375     hist2 = (TH2I*)histArray->FindObject("hist_trigger_contribs");
376     if (hist2){
377       fHistTriggerContribs->Add(hist2);
378     } else
379       HLTWarning("Trigger contribution histogram not found!");
380
381   }
382
383   iResult = PushBack(fHistArray, 
384                      (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTRD), 
385                      //Specification: all 18 bits (links) set
386                      (0xFFFFFFFF >> (32 - TRDMODULES) )
387                      );
388                        
389   return iResult;
390 }
391
392 int AliHLTTRDGlobalMonitorComponent::Configure(const char* arguments)
393 {
394   // see header file for class documentation
395   int iResult=0;
396
397   return iResult;
398 }
399
400 int AliHLTTRDGlobalMonitorComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
401 {
402   // see header file for class documentation
403   int iResult=0;
404
405   return iResult;
406 }