This fixes part of the crashe due to unknown kf's passed to pythia
[u/mrichter/AliRoot.git] / T0 / AliT0CalibOffsetChannelsTask.cxx
CommitLineData
dd162229 1#include "TChain.h"
2#include "TTree.h"
3#include "TH1D.h"
4#include "TF1.h"
5#include "TCanvas.h"
6#include "TObjArray.h"
7
8#include "AliAnalysisTask.h"
9#include "AliAnalysisManager.h"
10
11#include "AliESDEvent.h"
12#include "AliESDInputHandler.h"
13
14#include "AliT0CalibSeasonTimeShift.h"
15#include "AliT0CalibOffsetChannelsTask.h"
16
17#include "AliCDBMetaData.h"
18#include "AliCDBId.h"
19#include "AliCDBEntry.h"
20#include "AliCDBManager.h"
21#include "AliCDBStorage.h"
22
23// Task should calculate channels offset
24// Authors: Alla
25
26ClassImp(AliT0CalibOffsetChannelsTask)
27//________________________________________________________________________
28AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask()
29 : AliAnalysisTaskSE(), fESD(0), fTzeroObject(0),fRunNumber(0)
30{
31 // Constructor
32
33 // Define input and output slots here
34 // Input slot #0 works with a TChain
35 DefineInput(0, TChain::Class());
36 DefineOutput(1, TObjArray::Class());
37 fTzeroObject = new TObjArray(0);
38 fTzeroObject->SetOwner(kTRUE);
39 // Output slot #0 id reserved by the base class for AOD
40 // Output slot #1 writes into a TH1 container
41 // DefineOutput(1, TList::Class());
42}
43
44
45//________________________________________________________________________
46AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask(const char *name)
47 : AliAnalysisTaskSE(name), fESD(0), fTzeroObject(0),fRunNumber(0)
48{
49 // Constructor
50
51 // Define input and output slots here
52 // Input slot #0 works with a TChain
53 DefineInput(0, TChain::Class());
54 DefineOutput(1, TObjArray::Class());
55 // Output slot #0 id reserved by the base class for AOD
56 // Output slot #1 writes into a TH1 container
57 // DefineOutput(1, TList::Class());
58}
59
60//________________________________________________________________________
61AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask()
62{
63 // Destructor
64 printf("AliT0CalibOffsetChannels~AliT0CalibOffsetChannels() ");
65 if( fTzeroObject )fTzeroObject->Delete();
66}
67
68//________________________________________________________________________
69void AliT0CalibOffsetChannelsTask::ConnectInputData(Option_t *) {
70 //
71 //
72 //
73 TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
74 if (!tree) {
75 printf("ERROR: Could not read chain from input slot 0");
76 }
77 else {
78 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
79 if (!esdH) {
80 printf ("ERROR: Could not get ESDInputHandler");
81 }
82 else {
83 fESD = esdH->GetEvent();
84 printf ("*** CONNECTED NEW EVENT ****");
85 }
86 }
87}
88
89//________________________________________________________________________
90void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()
91{
92 // Create histograms
93 for (Int_t i=0; i<24; i++) {
94 fTimeDiff[i] = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",300, -300, 300);
95 fCFD[i] = new TH1F("CFD","CFD",500, 6000, 7000);
96 }
97 fTzeroObject = new TObjArray(0);
98 fTzeroObject->SetOwner(kTRUE);
99
100 PostData(1, fTzeroObject);
101
102 // Called once
103}
104
105//________________________________________________________________________
106void AliT0CalibOffsetChannelsTask::UserExec(Option_t *)
107{
108 // Main loop
109 // Called for each event
110
111 // Post output data.
112 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
113 if (!fESD) {
114 printf("ERROR: fESD not available\n");
115 return;
116 }
117
118 const Double32_t* time = fESD->GetT0time();
119 for (Int_t i=0; i<12; i++) {
120 if( time[i]>1 ){
121 fCFD[i]->Fill( time[i]);
122 if( time[0]>1 )
123 fTimeDiff[i]->Fill( time[i]-time[0]);
124 }
125 }
126 for (Int_t i=12; i<24; i++) {
127 if( time[i]>1) {
128 fCFD[i]->Fill( time[i]);
129 if( time[12]>1 )
130 fTimeDiff[i]->Fill( time[i]-time[12]);
131 }
132 }
133 fRunNumber = fESD->GetRunNumber() ;
134
135 // printf("%lf %lf %lf\n",orA,orC,time);
136 PostData(1, fTzeroObject);
137}
138 //________________________________________________________________________
139void AliT0CalibOffsetChannelsTask::Terminate(Option_t *)
140{
141
142 // Called once at the end of the query
143 for (Int_t i=0; i<24; i++)
144 fTzeroObject->AddAtAndExpand(fTimeDiff[i],i);
145
146 for (Int_t i=24; i<48; i++)
147 fTzeroObject->AddAtAndExpand(fCFD[i],i);
148
149}
150