]>
Commit | Line | Data |
---|---|---|
31af5828 | 1 | // --- ROOT system |
2 | #include <TFile.h> | |
79563ba1 | 3 | #include <TClonesArray.h> |
4 | #include <TList.h> | |
5 | #include <TObjString.h> | |
31af5828 | 6 | #include <TTimeStamp.h> |
64a7c78d | 7 | |
31af5828 | 8 | #include "AliZDCPreprocessor.h" |
9 | #include "AliCDBManager.h" | |
10 | #include "AliCDBEntry.h" | |
64a7c78d | 11 | #include "AliCDBMetaData.h" |
12 | #include "AliDCSValue.h" | |
79563ba1 | 13 | #include "AliAlignObj.h" |
14 | #include "AliAlignObjAngles.h" | |
64a7c78d | 15 | #include "AliLog.h" |
16 | #include "AliZDCDataDCS.h" | |
31af5828 | 17 | #include "AliZDCCalibData.h" |
64a7c78d | 18 | |
19 | // | |
7a78280f | 20 | // Class implementing ZDC pre-processor. |
21 | // It takes data from DCS and passes it to the class AliZDCDataDCS. | |
22 | // The class is then written to the CDB. | |
64a7c78d | 23 | // |
24 | ||
25 | ClassImp(AliZDCPreprocessor) | |
26 | ||
27 | //______________________________________________________________________________________________ | |
28 | AliZDCPreprocessor::AliZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle) : | |
29 | AliPreprocessor(detector, shuttle), | |
30 | fData(0) | |
31 | { | |
32 | // constructor | |
33 | } | |
34 | ||
35 | //______________________________________________________________________________________________ | |
36 | AliZDCPreprocessor::~AliZDCPreprocessor() | |
37 | { | |
38 | // destructor | |
39 | } | |
40 | ||
7a78280f | 41 | |
64a7c78d | 42 | //______________________________________________________________________________________________ |
43 | void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
44 | UInt_t endTime) | |
45 | { | |
46 | // Creates AliZDCDataDCS object | |
47 | ||
48 | AliPreprocessor::Initialize(run, startTime, endTime); | |
49 | ||
79563ba1 | 50 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, |
64a7c78d | 51 | TTimeStamp(startTime).AsString(), |
52 | TTimeStamp(endTime).AsString())); | |
53 | ||
79563ba1 | 54 | fRun = run; |
55 | fStartTime = startTime; | |
56 | fEndTime = endTime; | |
57 | ||
64a7c78d | 58 | fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime); |
59 | } | |
60 | ||
61 | //______________________________________________________________________________________________ | |
62 | UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap) | |
63 | { | |
79563ba1 | 64 | // *************** From DCS ****************** |
64a7c78d | 65 | // Fills data into a AliZDCDataDCS object |
31af5828 | 66 | if(!dcsAliasMap) return 0; |
64a7c78d | 67 | |
68 | // The processing of the DCS input data is forwarded to AliZDCDataDCS | |
31af5828 | 69 | Float_t DCSValues[26]; |
70 | fData->ProcessData(*dcsAliasMap, DCSValues); | |
e1ea0c63 | 71 | //dcsAliasMap->Print(""); |
31af5828 | 72 | // |
79563ba1 | 73 | // --- Writing ZDC table positions into alignment object |
74 | TClonesArray *array = new TClonesArray("AliAlignObjAngles",10); | |
75 | TClonesArray &alobj = *array; | |
76 | AliAlignObjAngles a; | |
77 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; | |
78 | Double_t dyZN1 = (Double_t) DCSValues[0]; | |
79 | Double_t dyZP1 = (Double_t) DCSValues[1]; | |
80 | Double_t dyZN2 = (Double_t) DCSValues[2]; | |
81 | Double_t dyZP2 = (Double_t) DCSValues[3]; | |
82 | const char *ZDCn1="ZDC/NeutronZDC1"; | |
83 | const char *ZDCp1="ZDC/ProtonZDC1"; | |
84 | const char *ZDCn2="ZDC/NeutronZDC2"; | |
85 | const char *ZDCp2="ZDC/ProtonZDC2"; | |
86 | UShort_t iIndex=0; | |
87 | AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; | |
88 | UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex); | |
89 | // | |
90 | new(alobj[0]) AliAlignObjAngles(ZDCn1, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE); | |
91 | new(alobj[1]) AliAlignObjAngles(ZDCp1, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE); | |
92 | new(alobj[2]) AliAlignObjAngles(ZDCn2, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE); | |
93 | new(alobj[3]) AliAlignObjAngles(ZDCp2, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE); | |
94 | // save in CDB storage | |
95 | AliCDBMetaData md; | |
96 | md.SetResponsible("Chiara Oppedisano"); | |
97 | md.SetComment("Alignment object for ZDC"); | |
98 | Store("Align","Data", array, &md, 0, 0); | |
99 | ||
100 | // --- Writing ZDC PTMs HV values into calibration object | |
e1ea0c63 | 101 | AliZDCCalibData *calibdata = new AliZDCCalibData("ZDC"); |
79563ba1 | 102 | for(Int_t j=0; j<22; j++) |
103 | calibdata->SetPMTHVVal(j,DCSValues[j+4]); | |
104 | ||
105 | ||
106 | // *************** From DAQ ****************** | |
107 | // [a] PEDESTALS | |
108 | TList* Pedfilesources = GetFileSources(kDAQ, "PEDESTALS"); | |
109 | if(!Pedfilesources){ | |
110 | AliError(Form("No PEDESTALS file source for run %d !", fRun)); | |
111 | return 0; | |
112 | } | |
113 | Log("\t List of sources for PEDESTALS"); | |
114 | Pedfilesources->Print(); | |
115 | // | |
116 | TIter iter(Pedfilesources); | |
117 | TObjString* source; | |
118 | Int_t i=0; | |
119 | UInt_t result = 0; | |
120 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
121 | Log(Form("\n\t Getting file #%d\n",++i)); | |
122 | TString stringp = GetFile(kDAQ, "PEDESTALS", source->GetName()); | |
123 | const char * PedFileName = stringp.Data(); | |
124 | const Int_t NZDCch = 44; | |
125 | if(PedFileName){ | |
126 | FILE *file; | |
127 | if((file = fopen(PedFileName,"r")) == NULL){ | |
128 | printf("Cannot open file %s \n",PedFileName); | |
129 | return 0; | |
130 | } | |
131 | Log(Form("File %s connected to analyze pedestal events", PedFileName)); | |
132 | Float_t PedVal[(3*NZDCch)][2]; | |
133 | for(Int_t i=0; i<(3*NZDCch); i++){ | |
134 | for(Int_t j=0; j<2; j++){ | |
135 | fscanf(file,"%f",&PedVal[i][j]); | |
136 | //if(j==1) printf("PedVal[%d] -> %f, %f \n",i,PedVal[i][0],PedVal[i][1]); | |
137 | } | |
138 | if(i<NZDCch){ | |
139 | calibdata->SetMeanPed(i,PedVal[i][0]); | |
140 | calibdata->SetMeanPedWidth(i,PedVal[i][1]); | |
141 | } | |
142 | else if(i>=NZDCch && i<(2*NZDCch)){ | |
143 | calibdata->SetOOTPed(i-NZDCch,PedVal[i][0]); | |
144 | calibdata->SetOOTPedWidth(i-NZDCch,PedVal[i][1]); | |
145 | } | |
146 | else if(i>=(2*NZDCch) && i<(3*NZDCch)){ | |
147 | calibdata->SetPedCorrCoeff(i-(2*NZDCch),PedVal[i][0],PedVal[i][1]); | |
148 | } | |
149 | } | |
e1ea0c63 | 150 | } |
79563ba1 | 151 | else{ |
152 | Log(Form("File %s not found", PedFileName)); | |
153 | return 0; | |
e1ea0c63 | 154 | } |
79563ba1 | 155 | // |
156 | //calibdata->Print(""); | |
64a7c78d | 157 | } |
79563ba1 | 158 | |
159 | // [a] EMD EVENTS | |
160 | TList* EMDfilesources = GetFileSources(kDAQ, "EMDCALIB"); | |
161 | if(!EMDfilesources){ | |
162 | AliError(Form("No EMDCALIB file source for run %d !", fRun)); | |
163 | return 0; | |
64a7c78d | 164 | } |
79563ba1 | 165 | Log("\t List of sources for EMDCALIB"); |
166 | EMDfilesources->Print(); | |
e1ea0c63 | 167 | // |
79563ba1 | 168 | TIter iter2(EMDfilesources); |
169 | TObjString* source2; | |
170 | Int_t j=0; | |
171 | while((source2=dynamic_cast<TObjString*> (iter2.Next()))){ | |
172 | Log(Form("\n\t Getting file #%d\n",++j)); | |
173 | TString stringe = GetFile(kDAQ, "EMDCALIB", source2->GetName()); | |
174 | const char* EMDFileName = stringe.Data(); | |
175 | if(EMDFileName){ | |
176 | FILE *file; | |
177 | if((file = fopen(EMDFileName,"r")) == NULL){ | |
178 | printf("Cannot open file %s \n",EMDFileName); | |
179 | return 0; | |
180 | } | |
181 | Log(Form("File %s connected to analyze EM dissociation events", EMDFileName)); | |
182 | Float_t EMDFitVal[2]; | |
183 | for(Int_t j=0; j<2; j++){ | |
184 | fscanf(file,"%f",&EMDFitVal[j]); | |
185 | } | |
186 | calibdata->SetEnCalib(EMDFitVal); | |
187 | } | |
188 | else{ | |
189 | Log(Form("File %s not found", EMDFileName)); | |
190 | return 0; | |
191 | } | |
192 | //calibdata->Print(""); | |
193 | } | |
31af5828 | 194 | |
e1ea0c63 | 195 | // note that the parameters are returned as character strings! |
196 | const char* nEvents = GetRunParameter("totalEvents"); | |
79563ba1 | 197 | if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents)); |
198 | else Log(Form("Number of events not put in logbook!")); | |
e1ea0c63 | 199 | |
79563ba1 | 200 | // Storing the final CDB file |
64a7c78d | 201 | AliCDBMetaData metaData; |
31af5828 | 202 | metaData.SetBeamPeriod(0); |
203 | metaData.SetResponsible("Chiara"); | |
79563ba1 | 204 | metaData.SetComment("Filling AliZDCCalibData object"); |
64a7c78d | 205 | |
79563ba1 | 206 | result = Store("Calib","Data",calibdata, &metaData, 0, 0); |
207 | ||
64a7c78d | 208 | return result; |
209 | } | |
210 |