3 #include <TClonesArray.h>
5 #include <TObjString.h>
6 #include <TTimeStamp.h>
8 #include "AliZDCPreprocessor.h"
9 #include "AliCDBManager.h"
10 #include "AliCDBEntry.h"
11 #include "AliCDBMetaData.h"
12 #include "AliDCSValue.h"
13 #include "AliAlignObj.h"
14 #include "AliAlignObjAngles.h"
16 #include "AliZDCDataDCS.h"
17 #include "AliZDCCalibData.h"
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.
25 ClassImp(AliZDCPreprocessor)
27 //______________________________________________________________________________________________
28 AliZDCPreprocessor::AliZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
29 AliPreprocessor(detector, shuttle),
35 //______________________________________________________________________________________________
36 AliZDCPreprocessor::~AliZDCPreprocessor()
42 //______________________________________________________________________________________________
43 void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime,
46 // Creates AliZDCDataDCS object
48 AliPreprocessor::Initialize(run, startTime, endTime);
50 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
51 TTimeStamp(startTime).AsString(),
52 TTimeStamp(endTime).AsString()));
55 fStartTime = startTime;
58 fData = new AliZDCDataDCS(fRun, fStartTime, fEndTime);
61 //______________________________________________________________________________________________
62 UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap)
64 // *************** From DCS ******************
65 // Fills data into a AliZDCDataDCS object
66 if(!dcsAliasMap) return 1;
68 // The processing of the DCS input data is forwarded to AliZDCDataDCS
69 Float_t DCSValues[26];
70 fData->ProcessData(*dcsAliasMap, DCSValues);
71 // Store DCS data for reference
72 AliCDBMetaData metadata;
73 metadata.SetResponsible("Chiara Oppedisano");
74 metadata.SetComment("DCS data for ZDC");
75 Bool_t resStore = kFALSE;
76 resStore = StoreReferenceData("DCS","Data",fData,&metadata);
77 //dcsAliasMap->Print("");
79 // --- Writing ZDC table positions into alignment object
80 TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
81 TClonesArray &alobj = *array;
83 Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
84 // Vertical table position in mm from DCS
85 Double_t dyZN1 = (Double_t) (DCSValues[0]/10.);
86 Double_t dyZP1 = (Double_t) (DCSValues[1]/10.);
87 Double_t dyZN2 = (Double_t) (DCSValues[2]/10.);
88 Double_t dyZP2 = (Double_t) (DCSValues[3]/10.);
89 const char *ZDCn1="ZDC/NeutronZDC1";
90 const char *ZDCp1="ZDC/ProtonZDC1";
91 const char *ZDCn2="ZDC/NeutronZDC2";
92 const char *ZDCp2="ZDC/ProtonZDC2";
94 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
95 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
97 new(alobj[0]) AliAlignObjAngles(ZDCn1, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE);
98 new(alobj[1]) AliAlignObjAngles(ZDCp1, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE);
99 new(alobj[2]) AliAlignObjAngles(ZDCn2, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE);
100 new(alobj[3]) AliAlignObjAngles(ZDCp2, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE);
101 // save in CDB storage
103 md.SetResponsible("Chiara Oppedisano");
104 md.SetComment("Alignment object for ZDC");
105 Bool_t resultAl = kFALSE;
106 resultAl = Store("Align","Data", array, &md, 0, 0);
108 // --- Writing ZDC PTMs HV values into calibration object
109 AliZDCCalibData *calibdata = new AliZDCCalibData("ZDC");
110 for(Int_t j=0; j<22; j++)
111 calibdata->SetPMTHVVal(j,DCSValues[j+4]);
114 // *************** From DAQ ******************
116 TString runType = GetRunType();
117 TList* daqSources = GetFileSources(kDAQ, "PEDESTALS");
119 Log(Form("No source for PEDESTALS run %d !", fRun));
122 Log("\t List of sources for PEDESTALS");
125 TIter iter(daqSources);
126 TObjString* source = 0;
128 while((source = dynamic_cast<TObjString*> (iter.Next()))){
129 Log(Form("\n\t Getting file #%d\n",++i));
130 TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName());
131 if(stringPedFileName.Length() <= 0){
132 Log(Form("No PEDESTAL file from source %s!", source->GetName()));
135 const char* PedFileName = stringPedFileName.Data();
136 const Int_t NZDCch = 44;
139 if((file = fopen(PedFileName,"r")) == NULL){
140 printf("Cannot open file %s \n",PedFileName);
143 Log(Form("File %s connected to analyze pedestal events", PedFileName));
144 Float_t PedVal[(3*NZDCch)][2];
145 for(Int_t i=0; i<(3*NZDCch); i++){
146 for(Int_t j=0; j<2; j++){
147 fscanf(file,"%f",&PedVal[i][j]);
148 //if(j==1) printf("PedVal[%d] -> %f, %f \n",i,PedVal[i][0],PedVal[i][1]);
151 calibdata->SetMeanPed(i,PedVal[i][0]);
152 calibdata->SetMeanPedWidth(i,PedVal[i][1]);
154 else if(i>=NZDCch && i<(2*NZDCch)){
155 calibdata->SetOOTPed(i-NZDCch,PedVal[i][0]);
156 calibdata->SetOOTPedWidth(i-NZDCch,PedVal[i][1]);
158 else if(i>=(2*NZDCch) && i<(3*NZDCch)){
159 calibdata->SetPedCorrCoeff(i-(2*NZDCch),PedVal[i][0],PedVal[i][1]);
164 Log(Form("File %s not found", PedFileName));
168 //calibdata->Print("");
170 delete daqSources; daqSources = 0;
172 if (runType != "PEDESTALS") {
173 TList* daqSources = GetFileSources(kDAQ, "EMDCALIB");
175 AliError(Form("No sources for EMDCALIB run %d !", fRun));
178 Log("\t List of sources for EMDCALIB");
181 TIter iter2(daqSources);
182 TObjString* source = 0;
184 while((source = dynamic_cast<TObjString*> (iter2.Next()))){
185 Log(Form("\n\t Getting file #%d\n",++j));
186 TString stringEMDFileName = GetFile(kDAQ, "EMDCALIB", source->GetName());
187 if(stringEMDFileName.Length() <= 0){
188 Log(Form("No EMDCALIB file from source %s!", source->GetName()));
191 const char* EMDFileName = stringEMDFileName.Data();
194 if((file = fopen(EMDFileName,"r")) == NULL){
195 printf("Cannot open file %s \n",EMDFileName);
198 Log(Form("File %s connected to analyze EM dissociation events", EMDFileName));
199 Float_t EMDFitVal[2];
200 for(Int_t j=0; j<2; j++){
201 fscanf(file,"%f",&EMDFitVal[j]);
203 calibdata->SetEnCalib(EMDFitVal);
206 Log(Form("File %s not found", EMDFileName));
209 //calibdata->Print("");
212 // note that the parameters are returned as character strings!
213 const char* nEvents = GetRunParameter("totalEvents");
214 if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents));
215 else Log(Form("Number of events not put in logbook!"));
217 // Storing the final CDB file
218 AliCDBMetaData metaData;
219 metaData.SetBeamPeriod(0);
220 metaData.SetResponsible("Chiara");
221 metaData.SetComment("Filling AliZDCCalibData object");
223 Bool_t resultCal = kFALSE;
224 resultCal = Store("Calib","Data",calibdata, &metaData, 0, 1);
227 if(resultAl!=0 && resultCal!=0){
228 if(resultAl==1 && resultCal==1) result = 1;