/*
-- "Contact:" - henrik.tydesjo@cern.ch
-- "Link:" -
-- "Run Type:" - DAQ_MIN_TH_SCAN,DAQ_MEAN_TH_SCAN,DAQ_UNIFORMITY_SCAN,DAQ_NOISY_PIX_SCAN,DAQ_PIX_DELAY_SCAN,DAQ_FO_UNIF_SCAN
-- "DA Type:" - LDC
-- "Number of events needed:"
-- "Input Files:" - daq db config files: spd_standal_params,spd_perm_noisy , previous noisy lists: ./calibResults/ScanNoisy/* , raw data
-- "Output Files:" - Ref Data: ./calibResults/ScanReference/* , DCS update: ./calibResults/ScanDCSconfigToFXS/* , OCDB update: ./calibResults/ScanNoisyToFXS/* , persistent files: ./calibResults/ScanNoisy/*
-- "Trigger types used:"
+Contact: henrik.tydesjo@cern.ch
+Link: tydes.home.cern.ch/tydes/doc/CalibrationOverview/CalibrationAlgorithms/
+Run Type: DAQ_MIN_TH_SCAN,DAQ_MEAN_TH_SCAN,DAQ_UNIFORMITY_SCAN,DAQ_NOISY_PIX_SCAN,DAQ_PIX_DELAY_SCAN
+DA Type: LDC
+Number of events needed: Depending on scan type
+Input Files: spd_standal_params,spd_perm_noisy , ./calibResults/ScanNoisy/* , raw data
+Output Files: ./calibResults/ScanReference/* , ./calibResults/ScanDCSconfigToFXS/* , ./calibResults/ScanNoisyToFXS/* , ./calibResults/ScanNoisy/*
+Trigger types used: PHYSICS
*/
////////////////////////////////////////////////////////////////////////////////
// //
////////////////////////////////////////////////////////////////////////////////
+#ifndef SPD_DA_OFF
extern "C" {
#include "daqDA.h"
}
+#endif
#include "event.h"
#include "monitor.h"
#include "AliRawReaderDate.h"
#include <TROOT.h>
#include <TPluginManager.h>
#include <TObjArray.h>
+#include <TObjString.h>
#include <TString.h>
+#include <TFitter.h>
+#include <cstdlib>
int main(int argc, char **argv) {
if (argc<2) {
char *saveDirNoisyToFXS = "./calibResults/ScanNoisyToFXS"; // may delete content
char *saveDirDCSconfigToFXS= "./calibResults/ScanDCSconfigToFXS"; // may delete content
char *saveDirRef = "./calibResults/ScanReference"; // may delete content
+ char *saveDirIdsToFXS = "./calibResults/IdsToFXS"; // may delete content
char *configFilesDir = "./configFiles"; // may delete content
+
// make sure the directory structure is correct:
system("mkdir ./calibResults >& /dev/null");
system("mkdir ./calibResults/ScanNoisy >& /dev/null");
system("mkdir ./calibResults/ScanNoisyToFXS >& /dev/null");
system("mkdir ./calibResults/ScanDCSconfigToFXS >& /dev/null");
system("mkdir ./calibResults/ScanReference >& /dev/null");
+ system("mkdir ./calibResults/IdsToFXS >& /dev/null");
system("mkdir ./configFiles >& /dev/null");
// prameters config files
TString paramsFileName = Form("%s/standal_params.txt",configFilesDir);
TString permNoisyFileName = Form("%s/perm_noisy.txt",configFilesDir);
+ TFitter *fitter = new TFitter(3);
+ TVirtualFitter::SetFitter(fitter);
+
// This line is needed in case of a stand-alone application w/o
// $ROOTSYS/etc/system.rootrc file
gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
"TStreamerInfo()");
// turn off annoying warning messages
- new AliLog;
- AliLog::Instance()->SetGlobalDebugLevel(-20);
+ // NB: Should not be handled here
+ AliLog* logger = AliLog::GetRootLogger();
+ logger->SetGlobalDebugLevel(-20);
// calib scan types
enum calib_types{MINTH,MEANTH,DAC,UNIMA,NOISE,DELAY};
status=daqDA_DB_getFile(idp.Data(),paramsFileName.Data());
if (status) {
printf("Failed to get config file %s: status=%d. Using default tuning parameters.\n",idp.Data(),status);
+ TString rmCmd = Form("rm -f %s",paramsFileName.Data());
+ system(rmCmd.Data());
}
#endif
if (status==0) {
paramsFile >> paramN;
if (paramsFile.eof()) break;
paramsFile >> paramV;
- TString* paramNS = new TString(paramN);
- TString* paramVS = new TString(paramV);
- paramNames.AddAtAndExpand((TObject*)paramNS,nrTuningParams);
- paramVals.AddAtAndExpand((TObject*)paramVS,nrTuningParams);
+ paramNames.AddAtAndExpand(new TObjString(paramN),nrTuningParams);
+ paramVals.AddAtAndExpand(new TObjString(paramV),nrTuningParams);
nrTuningParams++;
if (paramsFile.eof()) break;
}
}
}
// for (UInt_t i=0; i<nrTuningParams; i++) {
- // printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+ // // printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+ // printf("Entry %d: N=%s , V=%s\n",i,((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
// }
// perm noisy list:
permstatus=daqDA_DB_getFile(idn.Data(),permNoisyFileName.Data());
if (permstatus) {
printf("Failed to get config file %s: status=%d. No permanently noisy pixels will be added.\n",idn.Data(),permstatus);
+ TString rmCmd = Form("rm -f %s",permNoisyFileName.Data());
+ system(rmCmd.Data());
}
#endif
int startSeg = 1;
#ifndef SPD_DA_OFF
+ if (getenv("DATE_RUN_NUMBER")==0) {
+ printf("DATE_RUN_NUMBER not properly set.\n");
+ return -1;
+ }
int runNr = atoi(getenv("DATE_RUN_NUMBER"));
#else
int runNr = atoi(argv[1]);
}
}
- if (str->ReadCalibHeader()) {
+ if (str->ReadCalibHeader()>0) {
// first check the type:
if (bScanInit[eqId] && type[eqId]!=str->GetHtype()) {
printf("Calib header problem. Type changed (%d -> %d)!\n",type[eqId],str->GetHtype());
rowStart[eqId] = str->GetHrowStart();
rowEnd[eqId] = str->GetHrowEnd();
rowValue[eqId] = str->GetHrowValue();
- dacValue[eqId] = str->GetHdacValue();
+ dacValue[eqId] = str->GetHdacValue(); // this will change below for MEANTH scan
+
for (UInt_t hs=0; hs<6; hs++) {
halfStaveScanned[eqId][hs] = str->GetHhalfStaveScanned(hs);
dacHigh[eqId][hs] = str->GetHdacHigh(hs);
dacLow[eqId][hs] = str->GetHdacLow(hs);
TPAmp[eqId][hs] = str->GetHTPAmp(hs);
for (UInt_t chip=0; chip<10; chip++) {
- chipPresent[eqId][hs][chip] = str->GetHchipPresent(hs,chip);
+ chipPresent[eqId][hs][chip] = str->GetHchipPresent(hs,chip);
+ if (type[eqId]==MEANTH && chipPresent[eqId][hs][chip]) dacValue[eqId] = str->GetHdacLow(hs);
}
}
for (UInt_t chip=0; chip<10; chip++) {
}
scanObj[eqId]->SetType(type[eqId]);
scanObj[eqId]->SetDataFormat(dataFormat[eqId]);
- for (Int_t hs=0; hs<6; hs++) {
-
- // remove later when the chip present is set correctly !!!!!!!!!!!!!!!!!!!!!!!!!!!
- Bool_t halfStavePresent = str->GetHalfStavePresent(hs);
- // remove later when the chip present is set correctly !!!!!!!!!!!!!!!!!!!!!!!!!!!
-
+ for (Int_t hs=0; hs<6; hs++) {
for (UInt_t chip=0; chip<10; chip++) {
scanObj[eqId]->SetChipPresent(hs,chip,chipPresent[eqId][hs][chip]);
-
- // remove later when the chip present is set correctly !!!!!!!!!!!!!!!!!!!!!!!!!!!
- if (halfStavePresent) scanObj[eqId]->SetChipPresent(hs,chip,kTRUE);
- // remove later when the chip present is set correctly !!!!!!!!!!!!!!!!!!!!!!!!!!!
-
}
}
scanObj[eqId]->SetRowStart(rowStart[eqId]);
}
- // clean up scan objects (which also saves them)
+ // clean up scan objects (which also saves them) , check if something happened...
+ Bool_t somethingHappened = kFALSE;
for (UInt_t eqId=0; eqId<20; eqId++) {
- if (scanObj[eqId]!=NULL) delete scanObj[eqId];
+ if (scanObj[eqId]!=NULL) {
+ delete scanObj[eqId];
+ somethingHappened = kTRUE;
+ }
+ }
+ if (!somethingHappened) {
+ printf("WARNING: No data processed. Are the calibration headers missing?\n");
}
-
}
}
+ Bool_t reset_made = kFALSE;
// *** *** *** start loop over equipments (eq_id)
for (int eqId=0; eqId<20; eqId++) {
// configure analyzer with tuning parameters etc:
for (UInt_t i=0; i<nrTuningParams; i++) {
- analyzer->SetParam(((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+ analyzer->SetParam(((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
}
UInt_t type = analyzer->GetType();
}
else if (type==NOISE) {
- // read previous noisy list
+ // read previous noisy list (clear if overwriting)
handler->SetFileLocation(saveDirNoisy);
- handler->ReadFromFiles();
+ if (analyzer->IsOverWriteSet() && !reset_made) {
+ handler->ResetNoisy();
+ handler->WriteToFilesAlways();
+ reset_made=kTRUE;
+ }
+ else {
+ handler->ReadFromFiles();
+ }
if (analyzer->ProcessNoisyPixels(/*saveDirNoisy*/)) {
if (permstatus==0) {
handler->AddNoisyFrom(handlerPermNoisy);
dcsfile << "ActualDetConfiguration=" << "0,-1,-1\n"; // dummy values for now
dcsfile << "[NOISY]\n";
nrDCSconfigFilesProduced++;
- for (UInt_t iModule=0; iModule<12; iModule++) {
- UInt_t module = AliITSRawStreamSPD::GetModuleNumber(eqId,iModule);
- UInt_t nrNoisy = handler->GetNrNoisy(module);
- if (analyzer->IsModuleScanned(module) || analyzer->IsOverWriteSet()) {
- UInt_t headkey=20*10*6;
- for (UInt_t ind=0; ind<nrNoisy; ind++) {
- UInt_t nEqId = handler->GetNoisyEqIdAt(module,ind);
- UInt_t nHs = handler->GetNoisyHSAt(module,ind);
- UInt_t nChip = handler->GetNoisyChipAt(module,ind);
- UInt_t newkey = nEqId*10*6 + nHs*10 + nChip;
- if (newkey!=headkey) { // print eqId,hs,chip_header
- headkey = newkey;
- dcsfile << "-" << nEqId << "," << nHs << "," << nChip << "\n";
+
+ for (UInt_t hs=0; hs<6; hs++) {
+ for (UInt_t chip=0; chip<10; chip++) {
+ if (analyzer->IsChipPresent(hs,chip) || analyzer->IsOverWriteSet()) {
+ dcsfile << "-" << eqId << "," << hs << "," << chip << "\n";
+ UInt_t nrNoisy = handler->GetNrNoisyC(eqId,hs,chip);
+ for (UInt_t ind=0; ind<nrNoisy; ind++) {
+ UInt_t col = handler->GetNoisyColAtC(eqId,hs,chip,ind);
+ UInt_t row = handler->GetNoisyRowAtC(eqId,hs,chip,ind);
+ dcsfile << col << "," << row << "\n";
}
- dcsfile << handler->GetNoisyColAt(module,ind) << "," << handler->GetNoisyRowAt(module,ind) << "\n";
}
- handler->SetFileLocation(saveDirNoisy);
- handler->WriteNoisyToFile(module);
- handler->SetFileLocation(saveDirNoisyToFXS);
- handler->WriteNoisyToFile(module);
- nrNoisyFilesProduced++;
}
}
+ handler->SetFileLocation(saveDirNoisy);
+ handler->WriteNoisyToFile(eqId);
+ handler->SetFileLocation(saveDirNoisyToFXS);
+ handler->WriteNoisyToFile(eqId);
+ nrNoisyFilesProduced++;
+
dcsfile.close();
}
}
dcsfile << "RunNumber=" << runNr << "\n";
dcsfile << "Type=" << type << "\n";
dcsfile << "Router=" << routerNr << "\n";
- dcsfile << "ActualDetCoonfiguration=" << "0,-1,-1\n"; // dummy values for now
+ dcsfile << "ActualDetConfiguration=" << "0,-1,-1\n"; // dummy values for now
dcsfile << "[DACvalues]\n";
nrDCSconfigFilesProduced++;
- // TString ofileName = Form("%s/minth_eq_%d.txt",saveDirParameters,eqId);
- // ofstream ofile;
- // ofile.open (ofileName.Data());
for (UInt_t hs=0; hs<6; hs++) {
for (UInt_t chipNr=0; chipNr<10; chipNr++) {
Int_t minTh = -1;
printf("MinTh failed for Eq %d , HS %d , Chip %d\n",eqId,hs,chipNr);
}
}
- // ofile << minTh;
- // ofile << "\t";
}
- // ofile << "\n";
}
- // ofile.close();
dcsfile.close();
}
dcsfile << "ActualDetCoonfiguration=" << "0,-1,-1\n"; // dummy values for now
dcsfile << "[DACvalues]\n";
nrDCSconfigFilesProduced++;
-// TString ofileName = Form("%s/delay_eq_%d.txt",saveDirParameters,eqId);
-// ofstream ofile;
-// ofile.open (ofileName.Data());
for (UInt_t hs=0; hs<6; hs++) {
for (UInt_t chipNr=0; chipNr<10; chipNr++) {
Int_t clockCycle = -1;
printf("Delay failed for Eq %d , HS %d , Chip %d\n",eqId,hs,chipNr);
}
}
- // ofile << delayCtrl << "/" << miscCtrl;
- // ofile << "\t";
}
- // ofile << "\n";
}
- // ofile.close();
dcsfile.close();
}
}
// *** *** *** end loop over equipments (eq_id)
+
delete handler;
if (handlerPermNoisy!=NULL) {
delete handlerPermNoisy;
}
+ printf("Opening id list file\n");
+ TString idsFXSFileName = Form("%s/FXSids_run_%d.txt",saveDirIdsToFXS,runNr);
+ ofstream idsFXSfile;
+ idsFXSfile.open(idsFXSFileName.Data());
// send noisy data to FXS
if (nrNoisyFilesProduced>0) {
+ printf("Preparing noisy files\n");
// send a tared file of all new noisy maps
TString command = Form("cd %s; tar -cf noisy_scan.tar *",saveDirNoisyToFXS);
// printf("\n\n%s\n\n",command.Data());
system(command.Data());
-#ifndef SPD_DA_OFF
TString fileName = Form("%s/noisy_scan.tar",saveDirNoisyToFXS);
TString id = "SPD_scan_noisy";
+#ifndef SPD_DA_OFF
Int_t status = daqDA_FES_storeFile(fileName.Data(),id.Data());
if (status!=0) {
printf("Failed to export file %s , status %d\n",fileName.Data(),status);
return -1;
}
#endif
+ idsFXSfile << Form("%s\n",id.Data());
}
// send dcs config files to FXS
if (nrDCSconfigFilesProduced>0) {
+ printf("Preparing DCS config files\n");
// send a tared file of all the dcsConfig text files
TString command = Form("cd %s; tar -cf dcsConfig.tar *",saveDirDCSconfigToFXS);
// printf("\n\n%s\n\n",command.Data());
system(command.Data());
-#ifndef SPD_DA_OFF
TString fileName = Form("%s/dcsConfig.tar",saveDirDCSconfigToFXS);
TString id = "SPD_dcsConfig";
+#ifndef SPD_DA_OFF
Int_t status = daqDA_FES_storeFile(fileName.Data(),id.Data());
if (status!=0) {
printf("Failed to export file %s , status %d\n",fileName.Data(),status);
return -1;
}
#endif
+ //idsFXSfile << Form("%s\n",id.Data()); // do NOT write this id (this is not for preprocessor)
}
// send reference data to FXS
-#ifndef SPD_DA_OFF
for (UInt_t eqId=0; eqId<20; eqId++) {
if (bScanInit[eqId]) {
+ printf("Preparing reference data for eq %d\n",eqId);
TString fileName = Form("%s/SPDcal_run_%d_eq_%d.root",saveDirRef,runNr,eqId);
TString id = Form("SPD_ref_scan_%d",eqId);
+#ifndef SPD_DA_OFF
Int_t status = daqDA_FES_storeFile(fileName.Data(),id.Data());
if (status!=0) {
printf("Failed to export file %s , status %d\n",fileName.Data(),status);
return -1;
}
+#endif
+ idsFXSfile << Form("%s\n",id.Data());
}
}
-#endif
+ printf("Preparing id list file\n");
+ idsFXSfile.close();
+ TString id = "SPD_id_list";
+#ifndef SPD_DA_OFF
+ status = daqDA_FES_storeFile(idsFXSFileName.Data(),id.Data());
+ if (status!=0) {
+ printf("Failed to export file %s , status %d\n",idsFXSFileName.Data(),status);
+ return -1;
+ }
+#endif
+ printf("DA finished.\n");
return 0;
}