]>
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" |
90dbf5fb | 14 | #include "AliAlignObjParams.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 | //______________________________________________________________________________________________ | |
857ece97 | 28 | AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) : |
29 | AliPreprocessor("ZDC", shuttle), | |
64a7c78d | 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 |
f181c9b8 | 66 | if(!dcsAliasMap) return 1; |
64a7c78d | 67 | |
68 | // The processing of the DCS input data is forwarded to AliZDCDataDCS | |
c0aec6f6 | 69 | Float_t DCSValues[28]; // DCSAliases=28 |
31af5828 | 70 | fData->ProcessData(*dcsAliasMap, DCSValues); |
e1ea0c63 | 71 | //dcsAliasMap->Print(""); |
31af5828 | 72 | // |
79563ba1 | 73 | // --- Writing ZDC table positions into alignment object |
90dbf5fb | 74 | TClonesArray *array = new TClonesArray("AliAlignObjParams",10); |
79563ba1 | 75 | TClonesArray &alobj = *array; |
90dbf5fb | 76 | AliAlignObjParams a; |
79563ba1 | 77 | Double_t dx=0., dz=0., dpsi=0., dtheta=0., dphi=0.; |
cb50c7c8 | 78 | // Vertical table position in mm from DCS |
79 | Double_t dyZN1 = (Double_t) (DCSValues[0]/10.); | |
80 | Double_t dyZP1 = (Double_t) (DCSValues[1]/10.); | |
81 | Double_t dyZN2 = (Double_t) (DCSValues[2]/10.); | |
82 | Double_t dyZP2 = (Double_t) (DCSValues[3]/10.); | |
79563ba1 | 83 | const char *ZDCn1="ZDC/NeutronZDC1"; |
84 | const char *ZDCp1="ZDC/ProtonZDC1"; | |
85 | const char *ZDCn2="ZDC/NeutronZDC2"; | |
86 | const char *ZDCp2="ZDC/ProtonZDC2"; | |
87 | UShort_t iIndex=0; | |
ae079791 | 88 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
89 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
79563ba1 | 90 | // |
90dbf5fb | 91 | new(alobj[0]) AliAlignObjParams(ZDCn1, volid, dx, dyZN1, dz, dpsi, dtheta, dphi, kTRUE); |
92 | new(alobj[1]) AliAlignObjParams(ZDCp1, volid, dx, dyZP1, dz, dpsi, dtheta, dphi, kTRUE); | |
93 | new(alobj[2]) AliAlignObjParams(ZDCn2, volid, dx, dyZN2, dz, dpsi, dtheta, dphi, kTRUE); | |
94 | new(alobj[3]) AliAlignObjParams(ZDCp2, volid, dx, dyZP2, dz, dpsi, dtheta, dphi, kTRUE); | |
79563ba1 | 95 | // save in CDB storage |
96 | AliCDBMetaData md; | |
97 | md.SetResponsible("Chiara Oppedisano"); | |
98 | md.SetComment("Alignment object for ZDC"); | |
f181c9b8 | 99 | Bool_t resultAl = kFALSE; |
cb50c7c8 | 100 | resultAl = Store("Align","Data", array, &md, 0, 0); |
79563ba1 | 101 | |
e1ea0c63 | 102 | AliZDCCalibData *calibdata = new AliZDCCalibData("ZDC"); |
79563ba1 | 103 | |
104 | // *************** From DAQ ****************** | |
105 | // [a] PEDESTALS | |
06db4c54 | 106 | TString runType = GetRunType(); |
857ece97 | 107 | if (runType = "PEDESTAL_RUN") { |
cb50c7c8 | 108 | TList* daqSources = GetFileSources(kDAQ, "PEDESTALS"); |
109 | if(!daqSources){ | |
110 | Log(Form("No source for PEDESTALS run %d !", fRun)); | |
c58c7e82 | 111 | return 1; |
79563ba1 | 112 | } |
113 | Log("\t List of sources for PEDESTALS"); | |
cb50c7c8 | 114 | daqSources->Print(); |
79563ba1 | 115 | // |
cb50c7c8 | 116 | TIter iter(daqSources); |
117 | TObjString* source = 0; | |
79563ba1 | 118 | Int_t i=0; |
cb50c7c8 | 119 | while((source = dynamic_cast<TObjString*> (iter.Next()))){ |
79563ba1 | 120 | Log(Form("\n\t Getting file #%d\n",++i)); |
cb50c7c8 | 121 | TString stringPedFileName = GetFile(kDAQ, "PEDESTALS", source->GetName()); |
122 | if(stringPedFileName.Length() <= 0){ | |
123 | Log(Form("No PEDESTAL file from source %s!", source->GetName())); | |
c58c7e82 | 124 | return 1; |
cb50c7c8 | 125 | } |
126 | const char* PedFileName = stringPedFileName.Data(); | |
c0aec6f6 | 127 | // no. ADCch = (22 signal ch. + 2 reference PMs) * 2 gain chain = 48 |
128 | const Int_t NZDCch = 48; | |
79563ba1 | 129 | if(PedFileName){ |
130 | FILE *file; | |
131 | if((file = fopen(PedFileName,"r")) == NULL){ | |
132 | printf("Cannot open file %s \n",PedFileName); | |
c58c7e82 | 133 | return 1; |
79563ba1 | 134 | } |
135 | Log(Form("File %s connected to analyze pedestal events", PedFileName)); | |
136 | Float_t PedVal[(3*NZDCch)][2]; | |
137 | for(Int_t i=0; i<(3*NZDCch); i++){ | |
138 | for(Int_t j=0; j<2; j++){ | |
139 | fscanf(file,"%f",&PedVal[i][j]); | |
140 | //if(j==1) printf("PedVal[%d] -> %f, %f \n",i,PedVal[i][0],PedVal[i][1]); | |
141 | } | |
142 | if(i<NZDCch){ | |
143 | calibdata->SetMeanPed(i,PedVal[i][0]); | |
144 | calibdata->SetMeanPedWidth(i,PedVal[i][1]); | |
145 | } | |
146 | else if(i>=NZDCch && i<(2*NZDCch)){ | |
147 | calibdata->SetOOTPed(i-NZDCch,PedVal[i][0]); | |
148 | calibdata->SetOOTPedWidth(i-NZDCch,PedVal[i][1]); | |
149 | } | |
150 | else if(i>=(2*NZDCch) && i<(3*NZDCch)){ | |
151 | calibdata->SetPedCorrCoeff(i-(2*NZDCch),PedVal[i][0],PedVal[i][1]); | |
152 | } | |
153 | } | |
e1ea0c63 | 154 | } |
79563ba1 | 155 | else{ |
156 | Log(Form("File %s not found", PedFileName)); | |
c58c7e82 | 157 | return 1; |
e1ea0c63 | 158 | } |
79563ba1 | 159 | // |
160 | //calibdata->Print(""); | |
64a7c78d | 161 | } |
cb50c7c8 | 162 | delete daqSources; daqSources = 0; |
04bd7caa | 163 | } |
164 | // [b] EMD EVENTS | |
c58c7e82 | 165 | else if (runType == "PHYSICS") { |
166 | TList* daqSources = GetFileSources(kDAQ, "PHYSICS"); | |
cb50c7c8 | 167 | if(!daqSources){ |
c58c7e82 | 168 | AliError(Form("No sources for PHYSICS run %d !", fRun)); |
169 | return 1; | |
64a7c78d | 170 | } |
c58c7e82 | 171 | Log("\t List of sources for PHYSICS"); |
cb50c7c8 | 172 | daqSources->Print(); |
e1ea0c63 | 173 | // |
cb50c7c8 | 174 | TIter iter2(daqSources); |
06db4c54 | 175 | TObjString* source = 0; |
79563ba1 | 176 | Int_t j=0; |
cb50c7c8 | 177 | while((source = dynamic_cast<TObjString*> (iter2.Next()))){ |
79563ba1 | 178 | Log(Form("\n\t Getting file #%d\n",++j)); |
c58c7e82 | 179 | TString stringEMDFileName = GetFile(kDAQ, "PHYSICS", source->GetName()); |
cb50c7c8 | 180 | if(stringEMDFileName.Length() <= 0){ |
c58c7e82 | 181 | Log(Form("No PHYSICS file from source %s!", source->GetName())); |
182 | return 1; | |
cb50c7c8 | 183 | } |
184 | const char* EMDFileName = stringEMDFileName.Data(); | |
79563ba1 | 185 | if(EMDFileName){ |
186 | FILE *file; | |
187 | if((file = fopen(EMDFileName,"r")) == NULL){ | |
188 | printf("Cannot open file %s \n",EMDFileName); | |
c58c7e82 | 189 | return 1; |
79563ba1 | 190 | } |
191 | Log(Form("File %s connected to analyze EM dissociation events", EMDFileName)); | |
192 | Float_t EMDFitVal[2]; | |
193 | for(Int_t j=0; j<2; j++){ | |
194 | fscanf(file,"%f",&EMDFitVal[j]); | |
195 | } | |
196 | calibdata->SetEnCalib(EMDFitVal); | |
197 | } | |
198 | else{ | |
199 | Log(Form("File %s not found", EMDFileName)); | |
c58c7e82 | 200 | return 1; |
79563ba1 | 201 | } |
202 | //calibdata->Print(""); | |
203 | } | |
c58c7e82 | 204 | } |
205 | else { | |
bff168f8 | 206 | Log(Form("Nothing to do: run type is %s", runType.Data())); |
207 | return 0; | |
c58c7e82 | 208 | } |
e1ea0c63 | 209 | // note that the parameters are returned as character strings! |
210 | const char* nEvents = GetRunParameter("totalEvents"); | |
79563ba1 | 211 | if(nEvents) Log(Form("Number of events for run %d: %s",fRun, nEvents)); |
212 | else Log(Form("Number of events not put in logbook!")); | |
e1ea0c63 | 213 | |
79563ba1 | 214 | // Storing the final CDB file |
64a7c78d | 215 | AliCDBMetaData metaData; |
31af5828 | 216 | metaData.SetBeamPeriod(0); |
217 | metaData.SetResponsible("Chiara"); | |
79563ba1 | 218 | metaData.SetComment("Filling AliZDCCalibData object"); |
64a7c78d | 219 | |
f181c9b8 | 220 | Bool_t resultCal = kFALSE; |
b2324386 | 221 | resultCal = Store("Calib","Data",calibdata, &metaData, 0, 1); |
79563ba1 | 222 | |
cb50c7c8 | 223 | UInt_t result = 0; |
04bd7caa | 224 | if(resultAl == kFALSE || resultCal == kFALSE){ |
c58c7e82 | 225 | if(resultAl == kFALSE && resultCal == kFALSE ) result = 3; |
226 | else result = 2; | |
cb50c7c8 | 227 | } |
228 | ||
64a7c78d | 229 | return result; |
cb50c7c8 | 230 | |
64a7c78d | 231 | } |