2 Contact: Jean-Luc Charvet <jean-luc.charvet@cea.fr>
3 Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_Mchda
4 Run Type: PEDESTAL, CALIBRATION
6 Number of events needed: 400 events for pedestal and each calibration run
7 Input Files: Rawdata file (DATE format)
8 Output Files: local dir (not persistent) -> MUONTRKda_ped_<run#>.ped , MUONTRKda_gain_<run#>.par
9 FXS -> run<#>_MCH_<ldc>_PEDESTALS, run<#>_MCH_<ldc>_GAINS
13 /**************************************************************************
14 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
16 * Author: The ALICE Off-line Project. *
17 * Contributors are mentioned in the code where appropriate. *
19 * Permission to use, copy, modify and distribute this software and its *
20 * documentation strictly for non-commercial purposes is hereby granted *
21 * without fee, provided that the above copyright notice appears in all *
22 * copies and that both the copyright notice and this permission notice *
23 * appear in the supporting documentation. The authors make no claims *
24 * about the suitability of this software for any purpose. It is *
25 * provided "as is" without express or implied warranty. *
26 **************************************************************************/
31 -------------------------------------------------------------------------
32 2008-10-08 New version: MUONTRKda.cxx,v 1.14
33 -------------------------------------------------------------------------
35 Version for MUONTRKda MUON tracking
36 (A. Baldisseri, J.-L. Charvet & Ch. Finck)
39 Rem: AliMUON2DMap stores all channels, even those which are not connected
40 if pedMean == -1, channel not connected to a pad
51 #include <Riostream.h>
57 #include "AliMUONLogger.h"
58 #include "AliMUONRawStreamTrackerHP.h"
59 #include "AliMUONDspHeader.h"
60 #include "AliMUONBlockHeader.h"
61 #include "AliMUONBusStruct.h"
62 #include "AliMUONDDLTracker.h"
63 #include "AliMUONVStore.h"
64 #include "AliMUON2DMap.h"
65 #include "AliMUONCalibParamND.h"
66 #include "AliMpIntPair.h"
67 #include "AliMpConstants.h"
68 #include "AliRawReaderDate.h"
69 #include "AliRawDataErrorLog.h"
77 #include "TStopwatch.h"
79 #include "TTimeStamp.h"
80 #include "TGraphErrors.h"
83 #include "TPluginManager.h"
85 #include "THashTable.h"
86 #include <THashList.h>
91 const Int_t gkNChannels = AliMpConstants::ManuNofChannels();
92 const Int_t gkADCMax = 4095;
94 AliMUONVStore* gPedestalStore = new AliMUON2DMap(kFALSE);
98 UInt_t gRunNumber = 0;
100 Int_t gNEventsRecovered = 0;
101 Int_t gNDateEvents = 0;
102 Int_t gPrintLevel = 1; // global printout variable (others: 2 and 3)
103 Int_t gPlotLevel = 0; // global plot variable
104 Int_t gFES = 1; // by default FES is used
106 TH1F* gPedMeanHisto = 0x0;
107 TH1F* gPedSigmaHisto = 0x0;
108 Char_t gHistoFileName[256];
110 // used for computing gain parameters
111 Int_t nbpf1 = 6; // linear fit over nbf1 points
113 Char_t gHistoFileName_gain[256]="MUONTRKda_gain.data";
114 Char_t gRootFileName[256];
115 Char_t gOutFolder[256]=".";
116 Char_t filename[256];
117 Char_t filenam[256]="MUONTRKda_gain";
118 Char_t flatFile[256]="";
123 TString flatOutputFile;
124 TString logOutputFile;
125 TString logOutputFile_comp;
126 TString gCommand("ped");
129 class ErrorCounter : public TNamed
132 ErrorCounter(Int_t bp = 0, Int_t manu = 0, Int_t ev = 1) : busPatch(bp), manuId(manu), events(ev) {}
133 void Increment() {events++;}
134 Int_t BusPatch() {return busPatch;}
135 Int_t ManuId() {return manuId;}
136 Int_t Events() {return events;}
137 Int_t Compare(const TObject*) const;
139 void Print(Option_t* option="") const
141 TNamed::Print(option);
142 cout<<"bp "<<busPatch<<" events "<<events<<endl;
144 void Print_uncal(Option_t* option="") const
146 TNamed::Print(option);
147 cout<<"bp = "<<busPatch<< " manu = " << manuId << " uncal = "<< events <<endl;
151 Int_t busPatch; // Buspath ID
152 Int_t manuId; // Manu ID
153 Int_t events; // Events with error in this buspatch
156 Int_t ErrorCounter::Compare(const TObject* obj) const
158 Int_t patch1, patch2, manu1, manu2;
161 patch2 = ((ErrorCounter*)obj)->BusPatch();
162 manu2 = ((ErrorCounter*)obj)->ManuId();
164 if (patch1 == patch2)
171 return (manu1 >= manu2) ? 1 : -1;
174 return (patch1 >= patch2) ? 1 : -1;
178 // Table for buspatches with parity errors
179 THashTable* gErrorBuspatchTable = new THashTable(100,2);
181 // Table for uncalibrated buspatches and manus
182 // THashTable* gUncalBuspatchManuTable = new THashTable(1000,2);
183 THashList* gUncalBuspatchManuTable = new THashList(1000,2);
190 Double_t funcLin(Double_t *x, Double_t *par)
192 return par[0] + par[1]*x[0];
196 Double_t funcParabolic(Double_t *x, Double_t *par)
198 return par[0]*x[0]*x[0];
202 Double_t funcCalib(Double_t *x, Double_t *par)
204 Double_t xLim= par[3];
206 if(x[0] <= xLim) return par[0] + par[1]*x[0];
208 Double_t yLim = par[0]+ par[1]*xLim;
209 return yLim + par[1]*(x[0] - xLim) + par[2]*(x[0] - xLim)*(x[0] - xLim);
214 void MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, Int_t charge)
217 AliMUONVCalibParam* ped =
218 static_cast<AliMUONVCalibParam*>(gPedestalStore->FindObject(busPatchId, manuId));
222 ped = new AliMUONCalibParamND(2, gkNChannels,busPatchId, manuId, -1.); // put default wise -1, not connected channel
223 gPedestalStore->Add(ped);
226 // if (gNEvents == 0) {
227 // ped->SetValueAsDouble(channelId, 0, 0.);
228 // ped->SetValueAsDouble(channelId, 1, 0.);
231 // Initialization for the first value
232 if (ped->ValueAsDouble(channelId, 0) == -1) ped->SetValueAsDouble(channelId, 0, 0.);
233 if (ped->ValueAsDouble(channelId, 1) == -1) ped->SetValueAsDouble(channelId, 1, 0.);
235 Double_t pedMean = ped->ValueAsDouble(channelId, 0) + (Double_t) charge;
236 Double_t pedSigma = ped->ValueAsDouble(channelId, 1) + (Double_t) charge*charge;
238 ped->SetValueAsDouble(channelId, 0, pedMean);
239 ped->SetValueAsDouble(channelId, 1, pedSigma);
244 void MakePedStore(TString flatOutputFile_1 = "")
245 //void MakePedStore()
256 TFile* histoFile = 0;
258 if (gCommand.CompareTo("ped") == 0)
260 sprintf(gHistoFileName,"%s/MUONTRKda_ped_%d.root",gOutFolder,gRunNumber);
261 histoFile = new TFile(gHistoFileName,"RECREATE","MUON Tracking pedestals");
265 sprintf(name,"pedmean_allch");
266 sprintf(title,"Pedestal mean all channels");
270 gPedMeanHisto = new TH1F(name,title,nx,xmin,xmax);
271 gPedMeanHisto->SetDirectory(histoFile);
273 sprintf(name,"pedsigma_allch");
274 sprintf(title,"Pedestal sigma all channels");
278 gPedSigmaHisto = new TH1F(name,title,nx,xmin,xmax);
279 gPedSigmaHisto->SetDirectory(histoFile);
281 tree = new TTree("t","Pedestal tree");
282 tree->Branch("bp",&busPatchId,"bp/I");
283 tree->Branch("manu",&manuId,",manu/I");
284 tree->Branch("channel",&channelId,",channel/I");
285 tree->Branch("pedMean",&pedMean,",pedMean/D");
286 tree->Branch("pedSigma",&pedSigma,",pedSigma/D");
289 if (!flatOutputFile_1.IsNull()) {
290 fileout.open(flatOutputFile_1.Data());
291 fileout<<"//===========================================================================" << endl;
292 fileout<<"// Pedestal file calculated by MUONTRKda"<<endl;
293 fileout<<"//===========================================================================" << endl;
294 fileout<<"// * Run : " << gRunNumber << endl;
295 fileout<<"// * Date : " << date.AsString("l") <<endl;
296 fileout<<"// * Statictics : " << gNEvents << endl;
297 fileout<<"// * # of MANUS : " << gNManu << endl;
298 fileout<<"// * # of channels : " << gNChannel << endl;
299 if (gErrorBuspatchTable->GetSize())
302 fileout<<"// * Buspatches with less statistics (due to parity errors)"<<endl;
303 TIterator* iter = gErrorBuspatchTable->MakeIterator();
304 ErrorCounter* parityerror;
305 while((parityerror = (ErrorCounter*) iter->Next()))
307 fileout<<"// bp "<<parityerror->BusPatch()<<" events used "<<gNEvents-parityerror->Events()<<endl;
312 fileout<<"//---------------------------------------------------------------------------" << endl;
313 fileout<<"//---------------------------------------------------------------------------" << endl;
314 fileout<<"// BP MANU CH. MEAN SIGMA"<<endl;
315 fileout<<"//---------------------------------------------------------------------------" << endl;
319 if (gErrorBuspatchTable->GetSize())
321 cout<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
322 filcout<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
323 TIterator* iter = gErrorBuspatchTable->MakeIterator();
324 ErrorCounter* parityerror;
325 while((parityerror = (ErrorCounter*) iter->Next()))
327 cout<<" bp "<<parityerror->BusPatch()<<": events used = "<<gNEvents-parityerror->Events()<<endl;
328 filcout<<" bp "<<parityerror->BusPatch()<<": events used = "<<gNEvents-parityerror->Events()<<endl;
334 // iterator over pedestal
335 TIter next(gPedestalStore->CreateIterator());
336 AliMUONVCalibParam* ped;
338 while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
340 busPatchId = ped->ID0();
344 // Correct the number of events for buspatch with errors
346 ErrorCounter* errorCounter;
347 sprintf(bpname,"bp%d",busPatchId);
348 if ((errorCounter = (ErrorCounter*)gErrorBuspatchTable->FindObject(bpname)))
350 eventCounter = gNEvents - errorCounter->Events();
354 eventCounter = gNEvents;
357 for (channelId = 0; channelId < ped->Size() ; ++channelId) {
358 pedMean = ped->ValueAsDouble(channelId, 0);
360 if (pedMean > 0) { // connected channels
362 ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter);
364 pedMean = ped->ValueAsDouble(channelId, 0);
365 pedSigma = ped->ValueAsDouble(channelId, 1);
367 ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
369 pedMean = ped->ValueAsDouble(channelId, 0);
370 pedSigma = ped->ValueAsDouble(channelId, 1);
373 if (!flatOutputFile_1.IsNull()) {
374 fileout << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t"
375 << pedMean <<"\t"<< pedSigma << endl;
378 if (gCommand.CompareTo("ped") == 0)
380 gPedMeanHisto->Fill(pedMean);
381 gPedSigmaHisto->Fill(pedSigma);
390 if (!flatOutputFile_1.IsNull()) fileout.close();
392 if (gCommand.CompareTo("ped") == 0)
403 void MakePedStoreForGain(Int_t injCharge)
405 // store pedestal map in root file
407 // Int_t injCharge = 200;
412 if (gCommand.Contains("gain") && !gCommand.Contains("comp")) {
413 if(flatOutputFile.IsNull())
415 sprintf(filename,"%s_%d_DAC_%d.par",filenam,gRunNumber,injCharge);
416 flatOutputFile=filename;
418 if(!flatOutputFile.IsNull())
420 pfilew = fopen (flatOutputFile.Data(),"w");
422 fprintf(pfilew,"//DUMMY FILE (to prevent Shuttle failure)\n");
423 fprintf(pfilew,"//================================================\n");
424 fprintf(pfilew,"// MUONTRKda: Calibration run \n");
425 fprintf(pfilew,"//=================================================\n");
426 fprintf(pfilew,"// * Run : %d \n",gRunNumber);
427 fprintf(pfilew,"// * Date : %s \n",date.AsString("l"));
428 fprintf(pfilew,"// * DAC : %d \n",injCharge);
429 fprintf(pfilew,"//-------------------------------------------------\n");
436 // compute and store pedestals
437 sprintf(flatFile,"%s/%s_%d_DAC_%d.ped",gOutFolder,filenam,gRunNumber,injCharge);
438 cout << "\nMUONTRKda : Flat file generated : " << flatFile << "\n";
439 MakePedStore(flatFile);
444 TString mode("UPDATE");
446 if (gCommand.Contains("cre")) {
449 TFile* histoFile = new TFile(gHistoFileName_gain, mode.Data(), "MUON Tracking Gains");
451 // second argument should be the injected charge, taken from config crocus file
452 // put also info about run number could be usefull
453 AliMpIntPair* pair = new AliMpIntPair(gRunNumber, injCharge);
455 if (mode.CompareTo("UPDATE") == 0) {
456 tree = (TTree*)histoFile->Get("t");
457 tree->SetBranchAddress("run",&pair);
458 tree->SetBranchAddress("ped",&gPedestalStore);
461 tree = new TTree("t","Pedestal tree");
462 tree->Branch("run", "AliMpIntPair",&pair);
463 tree->Branch("ped", "AliMUON2DMap",&gPedestalStore);
464 tree->SetBranchAddress("run",&pair);
465 tree->SetBranchAddress("ped",&gPedestalStore);
470 tree->Write("t", TObject::kOverwrite); // overwrite the tree
481 Int_t nInit = 1; // DAC=0 excluded from fit procedure
482 Double_t goodA1Min = 0.5;
483 Double_t goodA1Max = 2.;
484 // Double_t goodA1Min = 0.7;
485 // Double_t goodA1Max = 1.7;
486 Double_t goodA2Min = -0.5E-03;
487 Double_t goodA2Max = 1.E-03;
491 // open file mutrkgain.root
492 // read again the pedestal for the calibration runs (9 runs ?)
493 // need the injection charge from config file (to be done)
494 // For each channel make a TGraphErrors (mean, sigma) vs injected charge
495 // Fit with a polynomial fct
496 // store the result in a flat file.
499 TFile* histoFile = new TFile(gHistoFileName_gain);
501 AliMUON2DMap* map[11];
502 AliMUONVCalibParam* ped[11];
503 AliMpIntPair* run[11];
505 //read back from root file
506 TTree* tree = (TTree*)histoFile->Get("t");
507 Int_t nEntries = tree->GetEntries();
508 Int_t nbpf2 = nEntries - (nInit + nbpf1) + 1; // nb pts used for 2nd order fit
511 for (Int_t i = 0; i < nEntries; ++i) {
514 tree->SetBranchAddress("ped",&map[i]);
515 tree->SetBranchAddress("run",&run[i]);
517 // std::cout << map[i] << " " << run[i] << std::endl;
519 //jlc_feb_08 modif: gRunNumber=(UInt_t)run[0]->GetFirst();
520 gRunNumber=(UInt_t)run[nEntries-1]->GetFirst();
521 // sscanf(getenv("DATE_RUN_NUMBER"),"%d",&gRunNumber);
523 Double_t pedMean[11];
524 Double_t pedSigma[11];
525 for ( Int_t i=0 ; i<11 ; i++) {pedMean[i]=0.;pedSigma[i]=1.;};
526 Double_t injCharge[11];
527 Double_t injChargeErr[11];
528 for ( Int_t i=0 ; i<11 ; i++) {injCharge[i]=0.;injChargeErr[i]=1.;};
531 cout<<"\n ******** MUONTRKda for Gain computing (Run = " << gRunNumber << ")\n" << endl;
532 cout<<" * Date : " << date.AsString("l") << "\n" << endl;
533 cout << " Entries = " << nEntries << " DAC values \n" << endl;
534 for (Int_t i = 0; i < nEntries; ++i) {
535 cout<< " Run = " << run[i]->GetFirst() << " DAC = " << run[i]->GetSecond() << endl;
536 num_RUN[i] = run[i]->GetFirst();
537 injCharge[i] = run[i]->GetSecond();
538 injChargeErr[i] = 0.01*injCharge[i];
539 if(injChargeErr[i] <= 1.) injChargeErr[i]=1.;
545 sprintf(filename,"%s/%s_%d.log",gOutFolder,filenam,gRunNumber);
546 logOutputFile_comp=filename;
548 filcouc.open(logOutputFile_comp.Data());
549 filcouc<<"//====================================================" << endl;
550 filcouc<<"// MUONTRKda for Gain computing (Run = " << gRunNumber << ")" << endl;
551 filcouc<<"//====================================================" << endl;
552 filcouc<<"// * Date : " << date.AsString("l") << "\n" << endl;
556 // why 2 files ? (Ch. F.)
561 sprintf(filename,"%s/%s_%d.param",gOutFolder,filenam,gRunNumber);
562 cout << " fit parameter file = " << filename << "\n";
563 pfilen = fopen (filename,"w");
565 fprintf(pfilen,"//===================================================================\n");
566 fprintf(pfilen,"// BP MANU CH. a0 a1 a2 xlim P(chi2) p1 P(chi2)2 p2\n");
567 fprintf(pfilen,"//===================================================================\n");
568 fprintf(pfilen,"// * Run : %d \n",gRunNumber);
569 fprintf(pfilen,"//===================================================================\n");
571 sprintf(filename,"%s/%s_%d.bad",gOutFolder,filenam,gRunNumber);
572 cout << " Bad channel file = " << filename << "\n";
573 pfilef = fopen (filename,"w");
575 fprintf(pfilef,"//=================================================\n");
576 fprintf(pfilef,"// Bad Channel file calculated by MUONTRKda \n");
577 fprintf(pfilef,"//=================================================\n");
578 fprintf(pfilef,"// * Run : %d \n",gRunNumber);
579 fprintf(pfilef,"// * Date : %s \n",date.AsString("l"));
580 fprintf(pfilef,"//=======================================\n");
581 fprintf(pfilef,"// BP MANU CH. a1 a2 thres. Q\n");
582 fprintf(pfilef,"//=======================================\n");
586 if(flatOutputFile.IsNull())
588 sprintf(filename,"%s_%d.par",filenam,gRunNumber);
589 flatOutputFile=filename;
591 if(!flatOutputFile.IsNull())
593 pfilew = fopen (flatOutputFile.Data(),"w");
595 fprintf(pfilew,"//================================================\n");
596 fprintf(pfilew,"// Calibration file calculated by MUONTRKda \n");
597 fprintf(pfilew,"//=================================================\n");
598 fprintf(pfilew,"// * Run : %d \n",gRunNumber);
599 fprintf(pfilew,"// * Date : %s \n",date.AsString("l"));
600 fprintf(pfilew,"// * Statictics : %d \n",gNEvents);
601 fprintf(pfilew,"// * # of MANUS : %d \n",gNManu);
602 fprintf(pfilew,"// * # of channels : %d \n",gNChannel);
603 fprintf(pfilew,"//-------------------------------------------------\n");
605 fprintf(pfilew,"// %d DAC values fit: %d pts (1st order) %d pts (2nd order) \n",nEntries,nbpf1,nbpf2);
607 fprintf(pfilew,"// %d DAC values fit: %d pts (1st order) %d pts (2nd order) DAC=0 excluded\n",nEntries,nbpf1,nbpf2);
608 fprintf(pfilew,"// RUN DAC \n");
609 fprintf(pfilew,"//-----------------\n");
610 for (Int_t i = 0; i < nEntries; ++i) {
611 tree->SetBranchAddress("run",&run[i]);
612 fprintf(pfilew,"// %d %5.0f \n",num_RUN[i],injCharge[i]);
614 fprintf(pfilew,"//=======================================\n");
615 fprintf(pfilew,"// BP MANU CH. a1 a2 thres. Q\n");
616 fprintf(pfilew,"//=======================================\n");
622 sprintf(filename,"%s/%s_%d.peak",gOutFolder,filenam,gRunNumber);
623 cout << " File containing Peak mean values = " << filename << "\n";
624 pfilep = fopen (filename,"w");
626 fprintf(pfilep,"//==============================================================================================================================\n");
627 fprintf(pfilep,"// * Run : %d \n",gRunNumber);
628 fprintf(pfilep,"//==============================================================================================================================\n");
629 fprintf(pfilep,"// BP MANU CH. Ped. <0> <1> <2> <3> <4> <5> <6> <7> <8> <9> <10> \n");
630 fprintf(pfilep,"//==============================================================================================================================\n");
631 fprintf(pfilep,"// DAC= %9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f fC\n",injCharge[0],injCharge[1],injCharge[2],injCharge[3],injCharge[4],injCharge[5],injCharge[6],injCharge[7],injCharge[8],injCharge[9],injCharge[10]);
632 fprintf(pfilep,"// %9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f\n",injChargeErr[0],injChargeErr[1],injChargeErr[2],injChargeErr[3],injChargeErr[4],injChargeErr[5],injChargeErr[6],injChargeErr[7],injChargeErr[8],injChargeErr[9],injChargeErr[10]);
633 fprintf(pfilep,"//==============================================================================================================================\n");
640 TFile* gainFile = 0x0;
641 sprintf(gRootFileName,"%s/%s_%d.root",gOutFolder,filenam,gRunNumber);
642 gainFile = new TFile(gRootFileName,"RECREATE");
645 Double_t chi2P2 = 0.;
647 Double_t prChi2P2 =0;
648 Double_t a0=0.,a1=1.,a2=0.;
657 Double_t capa=0.2; // internal capacitor (pF)
659 TTree *tg = new TTree("tg","TTree avec class Manu_DiMu");
661 tg->Branch("bp",&busPatchId, "busPatchId/I");
662 tg->Branch("manu",&manuId, "manuId/I");
663 tg->Branch("channel",&channelId, "channelId/I");
665 tg->Branch("a0",&a0, "a0/D");
666 tg->Branch("a1",&a1, "a1/D");
667 tg->Branch("a2",&a2, "a2/D");
668 tg->Branch("Pchi2",&prChi2, "prChi2/D");
669 tg->Branch("Pchi2_2",&prChi2P2, "prChi2P2/D");
670 tg->Branch("Threshold",&threshold, "threshold/I");
671 tg->Branch("Q",&Q, "Q/I");
672 tg->Branch("p1",&p1, "p1/I");
673 tg->Branch("p2",&p2, "p2/I");
674 tg->Branch("gain",&gain, "gain/D");
678 // iterates over the first pedestal run
679 TIter next(map[0]->CreateIterator());
680 AliMUONVCalibParam* p;
683 Int_t nGoodChannel = 0;
684 Int_t nBadChannel = 0;
685 Int_t nBadChannel_a1 = 0;
686 Int_t nBadChannel_a2 = 0;
687 Int_t noFitChannel = 0;
689 Double_t sumProbChi2 = 0.;
691 Double_t sumProbChi2P2 = 0.;
694 Double_t x[11], xErr[11], y[11], yErr[11];
695 Double_t xp[11], xpErr[11], yp[11], ypErr[11];
697 Int_t uncalcountertotal=0 ;
699 while ( ( p = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
703 busPatchId = p->ID0();
706 // read back pedestal from the other runs for the given (bupatch, manu)
707 for (Int_t i = 1; i < nEntries; ++i) {
708 ped[i] = static_cast<AliMUONVCalibParam*>(map[i]->FindObject(busPatchId, manuId));
711 // compute for each channel the gain parameters
712 for ( channelId = 0; channelId < ped[0]->Size() ; ++channelId )
716 for (Int_t i = 0; i < nEntries; ++i) {
718 if (!ped[i]) continue; //shouldn't happen.
719 pedMean[i] = ped[i]->ValueAsDouble(channelId, 0);
720 pedSigma[i] = ped[i]->ValueAsDouble(channelId, 1);
722 if (pedMean[i] < 0) continue; // not connected
724 if (pedSigma[i] <= 0) pedSigma[i] = 1.; // should not happen.
729 // print_peak_mean_values
733 fprintf(pfilep,"%4i%5i%5i%10.3f",busPatchId,manuId,channelId,0.);
734 fprintf(pfilep,"%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f \n",pedMean[0],pedMean[1],pedMean[2],pedMean[3],pedMean[4],pedMean[5],pedMean[6],pedMean[7],pedMean[8],pedMean[9],pedMean[10]);
735 fprintf(pfilep," sig= %9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f \n",pedSigma[0],pedSigma[1],pedSigma[2],pedSigma[3],pedSigma[4],pedSigma[5],pedSigma[6],pedSigma[7],pedSigma[8],pedSigma[9],pedSigma[10]);
741 // Fit Method: Linear fit over nbpf1 points + parabolic fit over nbpf2 points)
742 // nInit=1 : 1st pt DAC=0 excluded
744 // 1. - linear fit over nbpf1 points
746 Double_t par[4] = {0.,0.5,0.,gkADCMax};
747 Int_t nbs = nEntries - nInit;
748 if(nbs < nbpf1)nbpf1=nbs;
751 for (Int_t j = 0; j < nbs; ++j)
755 if(x[j]==0.)FitProceed=0;
756 xErr[j] = pedSigma[k];
758 yErr[j] = injChargeErr[k];
762 TGraphErrors *graphErr;
763 if(!FitProceed) { p1=0; p2=0; noFitChannel++;}
768 TF1 *f1 = new TF1("f1",funcLin,0.,gkADCMax,2);
769 graphErr = new TGraphErrors(nbpf1, x, y, xErr, yErr);
771 f1->SetParameters(0,0);
773 graphErr->Fit("f1","RQ");
775 chi2 = f1->GetChisquare();
776 f1->GetParameters(par);
782 prChi2 = TMath::Prob(chi2, nbpf1 - 2);
784 Double_t xLim = pedMean[nInit + nbpf1 - 1];
785 Double_t yLim = par[0]+par[1] * xLim;
790 // 2. - Translation : new origin (xLim, yLim) + parabolic fit over nbf2 points
794 for (Int_t j = 0; j < nbpf2; j++)
796 Int_t k = j + (nInit + nbpf1) - 1;
797 xp[j] = pedMean[k] - xLim;
798 xpErr[j] = pedSigma[k];
800 yp[j] = injCharge[k] - yLim - par[1]*xp[j];
801 ypErr[j] = injChargeErr[k];
805 TF1 *f2 = new TF1("f2",funcParabolic,0.,gkADCMax,1);
806 graphErr = new TGraphErrors(nbpf2, xp, yp, xpErr, ypErr);
808 graphErr->Fit(f2,"RQ");
809 chi2P2 = f2->GetChisquare();
810 f2->GetParameters(par);
816 prChi2P2 = TMath::Prob(chi2P2, nbpf2-1);
831 p1 = TMath::Nint(ceil(prChi2*14))+1;
832 p2 = TMath::Nint(ceil(prChi2P2*14))+1;
833 Q = p1*16 + p2; // fit quality
835 Double_t x0 = -par[0]/par[1]; // value of x corresponding to à 0 fC
836 threshold = TMath::Nint(ceil(par[3]-x0)); // linear if x < threshold
840 fprintf(pfilen,"%4i %4i %2i",busPatchId,manuId,channelId);
841 fprintf(pfilen," %6.2f %6.4f %10.3e %4.2f %5.3f %x %5.3f %x\n",
842 par[0], par[1], par[2], par[3], prChi2, p1, prChi2P2, p2);
847 if(par[1]< goodA1Min || par[1]> goodA1Max)
851 if (gPrintLevel && nBadChannel_a1 < 1)
853 cout << " !!!!! " << nBadChannel_a1 << " !!!!!!!! Bad Calib.: BP= " << busPatchId << " Manu_Id= " << manuId <<
854 " Ch.= " << channelId << ":";
855 cout << " a1 = " << par[1] << " out of limit : [" << goodA1Min << "," << goodA1Max <<
861 if(par[2]< goodA2Min || par[2]> goodA2Max)
865 if (gPrintLevel && nBadChannel_a2 < 1)
867 cout << " !!!!! " << nBadChannel_a2 << " !!!!!!!! Bad Calib.: BP= " << busPatchId << " Manu_Id= " << manuId
868 << " Ch.= " << channelId << ":";
869 cout << " a2 = " << par[2] << " out of limit : [" << goodA2Min << "," << goodA2Max
872 for (Int_t j = 0; j < nbpf2; ++j)
873 {cout << j << " " << x[j] << " " << xErr[j] << " " << y[j] << " " << yErr[j] << endl;}
878 if(FitProceed && p1>0 && p2>0)
881 sumProbChi2 += prChi2;
883 gain=1./(par[1]*capa);
884 sumProbChi2P2 += prChi2P2;
887 else // bad calibration
891 if(gPrintLevel==2)fprintf(pfilef,"%4i %5i %2i %7.4f %10.3e %4i %2x\n",busPatchId,manuId,channelId,par[1],par[2],threshold,Q);
892 par[1]=0.5; a1=0.5; p1=0;
893 par[2]=0.; a2=0.; p2=0;
896 char bpmanuname[256];
897 ErrorCounter* uncalcounter;
899 sprintf(bpmanuname,"bp%dmanu%d",busPatchId,manuId);
900 if (!(uncalcounter = (ErrorCounter*)gUncalBuspatchManuTable->FindObject(bpmanuname)))
902 // New buspatch_manu name
903 uncalcounter= new ErrorCounter (busPatchId,manuId);
904 uncalcounter->SetName(bpmanuname);
905 gUncalBuspatchManuTable->Add(uncalcounter);
909 // Existing buspatch_manu name
910 uncalcounter->Increment();
912 // uncalcounter->Print_uncal()
913 uncalcountertotal ++;
917 // if(Q==0 and nplot < 100)
918 // if(p1>1 && p2==0 and nplot < 100)
919 if(p1>1 && p2>1 and nplot < 100)
920 // if(p1>=1 and p1<=2 and nplot < 100)
923 // cout << " nplot = " << nplot << endl;
924 TF1 *f2Calib = new TF1("f2Calib",funcCalib,0.,gkADCMax,NFITPARAMS);
926 graphErr = new TGraphErrors(nEntries,pedMean,injCharge,pedSigma,injChargeErr);
928 sprintf(graphName,"BusPatch_%d_Manu_%d_Ch_%d",busPatchId, manuId,channelId);
930 graphErr->SetTitle(graphName);
931 graphErr->SetMarkerColor(3);
932 graphErr->SetMarkerStyle(12);
933 graphErr->Write(graphName);
935 sprintf(graphName,"f2_BusPatch_%d_Manu_%d_Ch_%d",busPatchId, manuId,channelId);
936 f2Calib->SetTitle(graphName);
937 f2Calib->SetLineColor(4);
938 f2Calib->SetParameters(par);
939 f2Calib->Write(graphName);
950 if (!flatOutputFile.IsNull())
952 fprintf(pfilew,"%4i %5i %2i %7.4f %10.3e %4i %2x\n",busPatchId,manuId,channelId,par[1],par[2],threshold,Q);
957 if(fmod(nmanu,100)==0)std::cout << " Nb manu = " << nmanu << std::endl;
960 // file outputs for gain
961 if (!flatOutputFile.IsNull()) fclose(pfilew);
962 if(gPrintLevel==2){ fclose(pfilen); fclose(pfilef); fclose(pfilep); }
971 if (gUncalBuspatchManuTable->GetSize())
973 gUncalBuspatchManuTable->Sort(); // use compare
974 TIterator* iter = gUncalBuspatchManuTable->MakeIterator();
975 ErrorCounter* uncalcounter;
976 filcouc << "\n List of problematic BusPatch and Manu " << endl;
977 filcouc << " ========================================" << endl;
978 filcouc << " BP Manu Nb Channel " << endl ;
979 filcouc << " ========================================" << endl;
980 while((uncalcounter = (ErrorCounter*) iter->Next()))
982 filcouc << "\t" << uncalcounter->BusPatch() << "\t " << uncalcounter->ManuId() << "\t\t" << uncalcounter->Events() << endl;
984 filcouc << " ========================================" << endl;
986 filcouc << " Number of bad calibrated Manu = " << gUncalBuspatchManuTable->GetSize() << endl ;
987 filcouc << " Number of bad calibrated channel = " << uncalcountertotal << endl;
992 filcouc << "\n Nb of channels in raw data = " << nmanu*64 << " (" << nmanu << " Manu)" << endl;
993 filcouc << " Nb of calibrated channel = " << nGoodChannel << " (" << goodA1Min << "<a1<" << goodA1Max
994 << " and " << goodA2Min << "<a2<" << goodA2Max << ") " << endl;
995 filcouc << " Nb of uncalibrated channel = " << nBadChannel << " (" << noFitChannel << " unfitted)" << endl;
997 cout << "\n Nb of channels in raw data = " << nmanu*64 << " (" << nmanu << " Manu)" << endl;
998 cout << " Nb of calibrated channel = " << nGoodChannel << " (" << goodA1Min << "<a1<" << goodA1Max
999 << " and " << goodA2Min << "<a2<" << goodA2Max << ") " << endl;
1000 cout << " Nb of uncalibrated channel = " << nBadChannel << " (" << noFitChannel << " unfitted)" << endl;
1002 Double_t meanA1 = sumA1/(nGoodChannel);
1003 Double_t meanProbChi2 = sumProbChi2/(nGoodChannel);
1004 Double_t meanA2 = sumA2/(nGoodChannel);
1005 Double_t meanProbChi2P2 = sumProbChi2P2/(nGoodChannel);
1007 Double_t capaManu = 0.2; // pF
1008 filcouc << "\n linear fit : <a1> = " << meanA1 << "\t <gain> = " << 1./(meanA1*capaManu)
1009 << " mV/fC (capa= " << capaManu << " pF)" << endl;
1010 filcouc << " Prob(chi2)> = " << meanProbChi2 << endl;
1011 filcouc << "\n parabolic fit: <a2> = " << meanA2 << endl;
1012 filcouc << " Prob(chi2)> = " << meanProbChi2P2 << "\n" << endl;
1014 cout << "\n <gain> = " << 1./(meanA1*capaManu)
1015 << " mV/fC (capa= " << capaManu << " pF)"
1016 << " Prob(chi2)> = " << meanProbChi2 << endl;
1025 //*************************************************************//
1028 int main(Int_t argc, Char_t **argv)
1031 // needed for streamer application
1032 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
1038 TFitter *minuitFit = new TFitter(NFITPARAMS);
1039 TVirtualFitter::SetFitter(minuitFit);
1041 // ofstream filcout;
1043 Int_t skipEvents = 0;
1044 Int_t maxEvents = 1000000;
1045 Int_t MaxDateEvents = 1000000;
1046 Int_t injCharge = 0;
1047 Char_t inputFile[256]="";
1048 Char_t inputFile1[256]="";
1049 Char_t inputFile2[256]="";
1051 Int_t gGlitchErrors= 0;
1052 Int_t gParityErrors= 0;
1053 Int_t gPaddingErrors= 0;
1054 Int_t recoverParityErrors = 1;
1056 TString fesOutputFile;
1060 // decode the input line
1061 for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
1066 if (arg[0] != '-') continue;
1071 sprintf(inputFile1,argv[i]);
1075 sprintf(inputFile2,argv[i]);
1079 flatOutputFile = argv[i];
1083 sprintf(gOutFolder,argv[i]);
1091 gPrintLevel=atoi(argv[i]);
1099 gPlotLevel=atoi(argv[i]);
1103 nbpf1=atoi(argv[i]);
1107 skipEvents=atoi(argv[i]);
1111 injCharge=atoi(argv[i]);
1115 sscanf(argv[i],"%d",&MaxDateEvents);
1119 sscanf(argv[i],"%d",&maxEvents);
1123 sprintf(gHistoFileName_gain,argv[i]);
1127 sscanf(argv[i],"%d",&recoverParityErrors);
1131 printf("\n******************* %s usage **********************",argv[0]);
1132 printf("\n%s -options, the available options are :",argv[0]);
1133 printf("\n-h help (this screen)");
1136 printf("\n-f <raw data file> (default = %s)",inputFile1);
1137 printf("\n-z <raw data file2> (default = %s)",inputFile2);
1139 printf("\n Output");
1140 printf("\n-a <Flat ASCII file> (default = %s)",flatOutputFile.Data());
1142 printf("\n Options");
1143 printf("\n-b <output directory> (default = %s)",gOutFolder);
1144 printf("\n-c <FES switch> (default = %d)",gFES);
1145 printf("\n-d <print level> (default = %d)",gPrintLevel);
1146 printf("\n-g <plot level> (default = %d)",gPlotLevel);
1147 printf("\n-i <nb linear points> (default = %d)",nbpf1);
1148 printf("\n-l <DAC level> (default = %d)",injCharge);
1149 printf("\n-m <max date events> (default = %d)",MaxDateEvents);
1150 printf("\n-s <skip events> (default = %d)",skipEvents);
1151 printf("\n-n <max events> (default = %d)",maxEvents);
1152 printf("\n-r root file data for gain (default = %s)",gHistoFileName_gain);
1153 printf("\n-e <execute ped/gain> (default = %s)",gCommand.Data());
1154 printf("\n-e <gain create> make gain & create a new root file");
1155 printf("\n-e <gain> make gain & update root file");
1156 printf("\n-e <gain compute> make gain & compute gains");
1157 printf("\n-p <Recover parity errors> (default = %d)",recoverParityErrors);
1162 printf("%s : bad argument %s (please check %s -h)\n",argv[0],argv[i],argv[0]);
1163 argc = 2; exit(-1); // exit if error
1167 // set gCommand to lower case
1171 // decoding the events
1176 gPedMeanHisto = 0x0;
1177 gPedSigmaHisto = 0x0;
1181 timers.Start(kTRUE);
1186 TString key("MUONTRKda :");
1188 AliMUONRawStreamTrackerHP* rawStream = 0;
1191 if (strlen(inputFile2) > 0) nrawdata=2; // 2 raw data files to read (offline case)
1193 if (gCommand.CompareTo("comp") != 0)
1196 for(int iraw = 0; iraw < nrawdata; ++iraw)
1198 if(iraw==0) strcpy(inputFile,inputFile1);
1199 if(iraw==1) strcpy(inputFile,inputFile2);
1201 status = monitorSetDataSource(inputFile);
1204 cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1205 << " " << monitorDecodeError(status) << endl;
1208 status = monitorDeclareMp("MUON Tracking monitoring");
1210 cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1211 << " " << monitorDecodeError(status) << endl;
1216 cout << "\nMUONTRKda : Reading data from file " << inputFile << " gNEvents = " << gNEvents << endl;
1220 if (gNDateEvents >= MaxDateEvents) break;
1221 if (gNEvents >= maxEvents) break;
1222 if (gNDateEvents>0 && gNDateEvents % 100 == 0)
1223 cout<<"Cumulated: DATE events = " << gNDateEvents << " Used events = " << gNEvents << endl;
1225 // check shutdown condition
1226 if (daqDA_checkShutdown())
1229 // Skip Events if needed
1230 while (skipEvents) {
1231 status = monitorGetEventDynamic(&event);
1236 status = monitorGetEventDynamic(&event);
1238 cout<<"EOF found"<<endl;
1242 // decoding rawdata headers
1243 AliRawReader *rawReader = new AliRawReaderDate(event);
1245 Int_t eventType = rawReader->GetType();
1246 gRunNumber = rawReader->GetRunNumber();
1248 // Output log file initialisations
1252 if (gCommand.CompareTo("ped") == 0){
1253 sprintf(flatFile,"%s/MUONTRKda_ped_%d.log",gOutFolder,gRunNumber);
1254 logOutputFile=flatFile;
1256 filcout.open(logOutputFile.Data());
1257 filcout<<"//=================================================" << endl;
1258 filcout<<"// MUONTRKda for Pedestal run = " << gRunNumber << endl;
1259 cout<<"\n ******** MUONTRKda for Pedestal run = " << gRunNumber << "\n" << endl;
1262 if (gCommand.Contains("gain")){
1263 sprintf(flatFile,"%s/%s_%d_DAC_%d.log",gOutFolder,filenam,gRunNumber,injCharge);
1264 logOutputFile=flatFile;
1266 filcout.open(logOutputFile.Data());
1267 filcout<<"//=================================================" << endl;
1268 filcout<<"// MUONTRKda for Gain run = " << gRunNumber << " (DAC=" << injCharge << ")" << endl;
1269 cout<<"\n ******** MUONTRKda for Gain run = " << gRunNumber << " (DAC=" << injCharge << ")\n" << endl;
1272 filcout<<"//=================================================" << endl;
1273 filcout<<"// * Date : " << date.AsString("l") << "\n" << endl;
1274 cout<<" * Date : " << date.AsString("l") << "\n" << endl;
1280 if (eventType != PHYSICS_EVENT)
1281 continue; // for the moment
1283 // decoding MUON payload
1284 rawStream = new AliMUONRawStreamTrackerHP(rawReader);
1285 rawStream->DisableWarnings();
1286 rawStream->EnabbleErrorLogger();
1288 // First lopp over DDL's to find good events
1289 // Error counters per event (counters in the decoding lib are for each DDL)
1290 Bool_t eventIsErrorMessage = kFALSE;
1291 int eventGlitchErrors = 0;
1292 int eventParityErrors = 0;
1293 int eventPaddingErrors = 0;
1297 if (rawStream->IsErrorMessage()) eventIsErrorMessage = kTRUE;
1298 eventGlitchErrors += rawStream->GetGlitchErrors();
1299 eventParityErrors += rawStream->GetParityErrors();
1300 eventPaddingErrors += rawStream->GetPaddingErrors();
1301 } while(rawStream->NextDDL());
1303 AliMUONRawStreamTrackerHP::AliBusPatch* busPatch;
1304 if (!eventIsErrorMessage)
1306 // Good events (no error) -> compute pedestal for all channels
1308 while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
1310 for(int i = 0; i < busPatch->GetLength(); ++i)
1312 if (gNEvents == 0) gNChannel++;
1313 busPatch->GetData(i, manuId, channelId, charge);
1314 MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
1321 // Events with errors
1322 if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
1324 // Recover parity errors -> compute pedestal for all good buspatches
1325 if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
1328 filcout <<"Event recovered -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
1329 <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
1330 <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
1334 filcout <<"Event recovered -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
1335 <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
1336 <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
1339 while( (busPatch = (AliMUONRawStreamTrackerHP::AliBusPatch*) rawStream->Next()))
1341 // Check the buspatch -> if error not use it in the pedestal calculation
1343 for(int i = 0; i < busPatch->GetLength(); ++i)
1345 if (!busPatch->IsParityOk(i)) errorCount++;
1350 for(int i = 0; i < busPatch->GetLength(); ++i)
1352 if (gNEvents == 0) gNChannel++;
1353 busPatch->GetData(i, manuId, channelId, charge);
1354 // if (busPatch->GetBusPatchId()==1719 && manuId == 1 && channelId == 0) cout <<"Recovered charge "<<charge<<endl;
1355 MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
1361 ErrorCounter* errorCounter;
1362 // Bad buspatch -> not used (just print)
1363 filcout<<"bpId "<<busPatch->GetBusPatchId()<<" words "<<busPatch->GetLength()
1364 <<" parity errors "<<errorCount<<endl;
1365 // Number of events where this buspatch is missing
1366 sprintf(bpname,"bp%d",busPatch->GetBusPatchId());
1367 if (!(errorCounter = (ErrorCounter*)gErrorBuspatchTable->FindObject(bpname)))
1370 errorCounter = new ErrorCounter(busPatch->GetBusPatchId());
1371 errorCounter->SetName(bpname);
1372 gErrorBuspatchTable->Add(errorCounter);
1376 // Existing buspatch
1377 errorCounter->Increment();
1379 // errorCounter->Print();
1380 } // end of if (!errorCount)
1381 } // end of while( (busPatch = (AliMUONRawStreamTrackerHP ...
1383 gNEventsRecovered++;
1384 } //end of if (recoverParityErrors && eventParityErrors && !eventGlitchErrors&& !eventPaddingErrors)
1387 // Fatal errors reject the event
1388 if ( TEST_SYSTEM_ATTRIBUTE( rawReader->GetAttributes(),
1391 filcout <<"Event rejected -> Period:"<<EVENT_ID_GET_PERIOD( rawReader->GetEventId() )
1392 <<" Orbit:"<<EVENT_ID_GET_ORBIT( rawReader->GetEventId() )
1393 <<" BunchCrossing:"<<EVENT_ID_GET_BUNCH_CROSSING( rawReader->GetEventId() )<<endl;
1397 filcout <<"Event rejected -> nbInRun:"<<EVENT_ID_GET_NB_IN_RUN( rawReader->GetEventId() )
1398 <<" burstNb:"<<EVENT_ID_GET_BURST_NB( rawReader->GetEventId() )
1399 <<" nbInBurst:"<<EVENT_ID_GET_NB_IN_BURST( rawReader->GetEventId() )<<endl;
1402 } // end of if (!rawStream->GetGlitchErrors() && !rawStream->GetPaddingErrors() ...
1403 filcout<<"Number of errors : Glitch "<<eventGlitchErrors
1404 <<" Parity "<<eventParityErrors
1405 <<" Padding "<<eventPaddingErrors<<endl;
1407 } // end of if (!rawStream->IsErrorMessage())
1409 if (eventGlitchErrors) gGlitchErrors++;
1410 if (eventParityErrors) gParityErrors++;
1411 if (eventPaddingErrors) gPaddingErrors++;
1421 if (gCommand.CompareTo("ped") == 0)
1423 sprintf(flatFile,"MUONTRKda_ped_%d.ped",gRunNumber);
1424 if(flatOutputFile.IsNull())flatOutputFile=flatFile;
1425 MakePedStore(flatOutputFile);
1428 // option gain -> update root file with pedestal results
1429 // gain + create -> recreate root file
1430 // gain + comp -> update root file and compute gain parameters
1432 if (gCommand.Contains("gain"))
1434 MakePedStoreForGain(injCharge);
1438 delete gPedestalStore;
1441 TVirtualFitter::SetFitter(0);
1445 cout << "\nMUONTRKda : Nb of DATE events = " << gNDateEvents << endl;
1446 cout << "MUONTRKda : Nb of Glitch errors = " << gGlitchErrors << endl;
1447 cout << "MUONTRKda : Nb of Parity errors = " << gParityErrors << endl;
1448 cout << "MUONTRKda : Nb of Padding errors = " << gPaddingErrors << endl;
1449 cout << "MUONTRKda : Nb of events recovered = " << gNEventsRecovered<< endl;
1450 cout << "MUONTRKda : Nb of events without errors = " << gNEvents-gNEventsRecovered<< endl;
1451 cout << "MUONTRKda : Nb of events used = " << gNEvents << endl;
1453 filcout << "\nMUONTRKda : Nb of DATE events = " << gNDateEvents << endl;
1454 filcout << "MUONTRKda : Nb of Glitch errors = " << gGlitchErrors << endl;
1455 filcout << "MUONTRKda : Nb of Parity errors = " << gParityErrors << endl;
1456 filcout << "MUONTRKda : Nb of Padding errors = " << gPaddingErrors << endl;
1457 filcout << "MUONTRKda : Nb of events recovered = " << gNEventsRecovered<< endl;
1458 filcout << "MUONTRKda : Nb of events without errors = " << gNEvents-gNEventsRecovered<< endl;
1459 filcout << "MUONTRKda : Nb of events used = " << gNEvents << endl;
1461 if (gCommand.CompareTo("ped") == 0)
1463 cout << "\nMUONTRKda : Output logfile : " << logOutputFile << endl;
1464 cout << "MUONTRKda : Pedestal Histo file : " << gHistoFileName << endl;
1465 cout << "MUONTRKda : Pedestal file (to SHUTTLE) : " << flatOutputFile << endl;
1469 cout << "\nMUONTRKda : Output logfile : " << logOutputFile << endl;
1470 cout << "MUONTRKda : DAC data (root file) : " << gHistoFileName_gain << endl;
1471 cout << "MUONTRKda : Dummy file (to SHUTTLE) : " << flatOutputFile << endl;
1476 // Compute gain parameters
1479 if (gCommand.Contains("comp"))
1485 cout << "\nMUONTRKda : Output logfile : " << logOutputFile_comp << endl;
1486 cout << "MUONTRKda : Root Histo. file : " << gRootFileName << endl;
1487 cout << "MUONTRKda : Gain file (to SHUTTLE) : " << flatOutputFile << endl;
1491 if(gFES) // Store IN FES
1493 printf("\n ***** STORE FILE in FES ****** \n");
1495 // be sure that env variable DAQDALIB_PATH is set in script file
1496 // gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
1498 if (!flatOutputFile.IsNull())
1500 if (gCommand.CompareTo("ped") == 0)
1501 status = daqDA_FES_storeFile(flatOutputFile.Data(),"PEDESTALS");
1503 status = daqDA_FES_storeFile(flatOutputFile.Data(),"GAINS");
1507 printf(" Failed to export file : %d\n",status);
1509 else if(gPrintLevel) printf(" %s successfully exported to FES \n",flatOutputFile.Data());
1515 printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());