]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/programs/print-RAW-HLTdecision.C
changing AliEMCALGeoUtils --> AliEMCALGeomery
[u/mrichter/AliRoot.git] / HLT / programs / print-RAW-HLTdecision.C
1 // $Id$
2 /**
3  * @file print-RAW-HLTdecision.C
4  * @brief Print HLT decisions per event of RAW data
5  * The uses the RawReader interface for data access and can be used
6  * with different types of data as long as a RawReader is implemented.
7  *
8  * <pre>
9  * Usage: aliroot -b -q print-RAW-HLTdecision.C'(input, minEvent, maxEvent)'
10  * 
11  * For help: aliroot -b -q print-RAW-HLTdecision.C
12  * </pre>
13  *
14  * The input file can be a file on Grid like e.g.
15  * "alien:///alice/data/2009/LHC09d/000104321/raw/09000104321018.30.root"
16  * In that case you need a valid token in order to connect to the Grid.
17  * Use 'alien-token-init' from your alien installation.
18  *
19  * @author Matthias.Richter@ift.uib.no
20  * @ingroup alihlt_programs
21  */
22 void print_RAW_HLTdecision(const char* rawFileName,
23                            int minEvent=0, int maxEvent=-1)
24 {
25   AliHLTLogging log;
26   log.SetGlobalLoggingLevel(0x7c);
27
28   TString strfile=rawFileName;
29   if (strfile.Contains("://") && !strfile.Contains("local://")) {
30     TGrid::Connect("alien");
31   }
32
33   AliRawReader* rawReader=NULL;
34   if (rawFileName && rawFileName[0]!=0) rawReader=AliRawReader::Create(rawFileName);
35   if (!rawFileName || rawFileName[0]==0 || !rawReader) {
36     if (rawFileName && rawFileName[0]!=0)
37       cerr << "can not open raw reader " << rawFileName << endl;
38     else
39       cerr << "print-RAW-HLTdecision.C Print HLT decisions per event of RAW data" << endl;
40     cerr << "===============================================================" << endl;
41     cerr << "usage: aliroot -b -q -l print-RAW-HLTdecision.C'(rawFileName" << endl;
42     cerr << "                                                 minEvent, maxEvent)'" << endl << endl;
43     cerr << "  Parameter:" << endl;
44     cerr << "       rawFileName      e.g \"raw.root\", \"./\"" << endl;
45     cerr << "       minEvent         first event (optional)" << endl;
46     cerr << "       maxEvent         last event (optional)" << endl;
47     cerr << "===============================================================" << endl;
48     return;
49   }
50
51   rawReader->RewindEvents();
52   int event=0;
53   if (!rawReader->NextEvent()) {
54     cout << "no events found in " << rawFileName << endl;
55     return;
56   }
57
58   AliHLTOUT* pHLTOUT=AliHLTOUT::New(rawReader);
59   if (!pHLTOUT) {
60     cerr << "can not create HLTOUT instance" << endl;
61     return;
62   }
63
64   do {
65     if (minEvent>=0 && event<minEvent) continue;
66     cout << "=====================  event " << event << "  ==========================" << endl;
67     if (pHLTOUT->Init()<0) {
68       cerr << "failed to initialize HLTOUT for event " << event << endl;
69       break;
70     }
71     bool found=false;
72     
73     // in the original implementation, the GlobalTriggerDecision has been
74     // sent with data type kAliHLTDataTypeTObject, thats why we check for
75     // both
76     if (pHLTOUT->SelectFirstDataBlock(kAliHLTDataTypeGlobalTrigger)>=0 ||
77         pHLTOUT->SelectFirstDataBlock(kAliHLTDataTypeTObject)>=0) {
78       do {
79         TObject* decision = pHLTOUT->GetDataObject();
80         if (decision) {
81           if (decision->IsA() == AliHLTGlobalTriggerDecision::Class()) {
82             cout << "HLT Global Trigger: " << decision->GetOption() << "   " << decision->GetTitle() << endl;
83             decision->Print();
84             found=true;
85           }
86           pHLTOUT->ReleaseDataObject(decision);
87         }
88       } while (!found && pHLTOUT->SelectNextDataBlock());
89     }
90
91     if (!found) {
92       cout << "   no HLT decision found" << endl;
93     }
94     pHLTOUT->Reset();
95     event++;
96   } while (rawReader->NextEvent() && (maxEvent<0 || event<maxEvent));
97 }
98
99 void print_RAW_HLTdecision()
100 {
101   // print usage
102   print_RAW_HLTdecision(NULL);
103 }