2 contact: Boris.Polishchuk@cern.ch
3 link: http://aliceinfo.cern.ch/static/phpBB3/viewtopic.php?f=4&t=17
4 reference run: /alice/data/2009/LHC09c_PHOS/000098979/raw
7 number of events needed: 1000
8 number of events needed: 1000
9 input files: Mod0RCU0.data Mod0RCU1.data Mod0RCU2.data Mod0RCU3.data Mod1RCU0.data Mod1RCU1.data Mod1RCU2.data Mod1RCU3.data Mod2RCU0.data Mod2RCU1.data Mod2RCU2.data Mod2RCU3.data Mod3RCU0.data Mod3RCU1.data Mod3RCU2.data Mod3RCU3.data Mod4RCU0.data Mod4RCU1.data Mod4RCU2.data Mod4RCU3.data
10 Output files: PHOS_BCM.root
11 Trigger types used: CALIBRATION_EVENT
26 #include <TPluginManager.h>
30 #include "AliRawReader.h"
31 #include "AliRawReaderDate.h"
32 #include "AliPHOSDA2.h"
33 #include "AliPHOSRawFitterv3.h"
34 #include "AliCaloAltroMapping.h"
35 #include "AliCaloRawStreamV3.h"
41 1- monitoring data source
43 int main(int argc, char **argv) {
45 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
51 AliLog::SetGlobalDebugLevel(0) ;
52 AliLog::SetGlobalLogLevel(AliLog::kFatal);
57 printf("Wrong number of arguments\n");
64 /* Retrieve mapping files from DAQ DB */
65 const char* mapFiles[20] = {
88 for(Int_t iFile=0; iFile<20; iFile++) {
89 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
91 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
96 /* Open mapping files */
97 AliAltroMapping *mapping[20];
105 for(Int_t iMod = 0; iMod < 5; iMod++) {
110 for(Int_t iRCU=0; iRCU<4; iRCU++) {
114 mapping[iMap] = new AliCaloAltroMapping(path3.Data());
119 /* define data source : this is argument 1 */
120 status=monitorSetDataSource( argv[1] );
122 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
127 /* declare monitoring program */
128 status=monitorDeclareMp( __FILE__ );
130 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
135 /* define wait event timeout - 1s max */
137 monitorSetNoWaitNetworkTimeout(1000);
140 /* log start of process */
141 printf("DA2 (bad channels search) started.\n");
144 /* init some counters */
145 int nevents_physics=0;
148 AliRawReader *rawReader = NULL;
151 for(Int_t iMod=0; iMod<5; iMod++) {
155 Float_t q[64][56][2];
161 Int_t sigStart, sigLength;
164 /* main loop (infinite) */
166 struct eventHeaderStruct *event;
167 eventTypeType eventT;
169 /* check shutdown condition */
170 if (daqDA_checkShutdown()) {break;}
172 /* get next event (blocking call until timeout) */
173 status=monitorGetEventDynamic((void **)&event);
174 if (status==MON_ERR_EOF) {
175 printf ("End of File detected\n");
176 break; /* end of monitoring file has been reached */
180 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
184 /* retry if got no event */
190 /* use event - here, just write event id to result file */
191 eventT=event->eventType;
193 if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) {
195 for(Int_t iX=0; iX<64; iX++) {
196 for(Int_t iZ=0; iZ<56; iZ++) {
197 for(Int_t iGain=0; iGain<2; iGain++) {
198 q[iX][iZ][iGain] = 0.;
205 rawReader = new AliRawReaderDate((void*)event);
206 AliCaloRawStreamV3 stream(rawReader,"PHOS",mapping);
207 AliPHOSRawFitterv3 fitter;
208 fitter.SubtractPedestals(kTRUE); // assume that data is non-ZS
210 while (stream.NextDDL()) {
211 while (stream.NextChannel()) {
213 /* Retrieve ZS parameters from data*/
214 short value = stream.GetAltroCFG1();
215 bool ZeroSuppressionEnabled = (value >> 15) & 0x1;
216 bool AutomaticBaselineSubtraction = (value >> 14) & 0x1;
217 if(ZeroSuppressionEnabled) {
218 offset = (value >> 10) & 0xf;
219 threshold = value & 0x3ff;
220 fitter.SubtractPedestals(kFALSE);
221 fitter.SetAmpOffset(offset);
222 fitter.SetAmpThreshold(threshold);
225 cellX = stream.GetCellX();
226 cellZ = stream.GetCellZ();
227 caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
229 if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
231 // In case of oscillating signals with ZS, a channel can have several bunches
233 while (stream.NextBunch()) {
235 sigStart = stream.GetStartTimeBin();
236 sigLength = stream.GetBunchLength();
237 fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
238 fitter.Eval(stream.GetSignals(),sigStart,sigLength);
239 q[cellX][cellZ][caloFlag] = fitter.GetSignalQuality();
240 } // End of NextBunch()
242 if(caloFlag==1 && fitter.GetEnergy()>40)
247 if(stream.GetModule()<0 || stream.GetModule()>4) continue;
249 if(dAs[stream.GetModule()]) {
250 dAs[stream.GetModule()]->FillQualityHistograms(q);
251 dAs[stream.GetModule()]->FillFiredCellsHistogram(nFired);
254 dAs[stream.GetModule()] = new AliPHOSDA2(stream.GetModule(),0);
255 dAs[stream.GetModule()]->FillQualityHistograms(q);
256 dAs[stream.GetModule()]->FillFiredCellsHistogram(nFired);
268 /* exit when last event received, no need to wait for TERM signal */
269 if (eventT==END_OF_RUN) {
270 printf("EOR event detected\n");
275 for(Int_t i = 0; i < 20; i++) delete mapping[i];
277 /* Be sure that all histograms are saved */
288 TFile* f = new TFile("PHOS_BCM.root","recreate");
290 for(Int_t iMod=0; iMod<5; iMod++) {
291 if(!dAs[iMod]) continue;
293 printf("DA2 for module %d detected.\n",iMod);
295 sprintf(lnam,"gmaplow%d",iMod);
296 sprintf(ltitl,"Quality map for Low gain in Module %d",iMod);
298 sprintf(hnam,"gmaphigh%d",iMod);
299 sprintf(htitl,"Quality map for High gain in Module %d",iMod);
301 maps[0] = new TH2F(lnam, ltitl, 64,0.,64.,56,0.,56.);
302 maps[1] = new TH2F(hnam, htitl, 64,0.,64.,56,0.,56.);
304 for(Int_t iX=0; iX<64; iX++) {
305 for(Int_t iZ=0; iZ<56; iZ++) {
307 for(Int_t iGain=0; iGain<2; iGain++) {
308 hist1 = dAs[iMod]->GetQualityHistogram(iX,iZ,iGain);
311 Double_t mean = hist1->GetMean();
312 maps[iGain]->SetBinContent(iX+1,iZ+1,mean);
318 maps[0]->Write(); delete maps[0];
319 maps[1]->Write(); delete maps[1];
325 if(offset>0 && threshold>0)
326 printf("ZS parameters: offset %d, threshold %d.\n",offset,threshold);
328 /* Store output files to the File Exchange Server */
329 daqDA_FES_storeFile("PHOS_BCM.root","BAD_CHANNELS");