if(runType=="STANDALONE") {
Bool_t ledOK = ProcessLEDRun();
+ Bool_t badmap_OK = FindBadChannelsEmc();
+ if(!badmap_OK) Log(Form("WARNING! FindBadChannels() completed with BAD status!"));
if(ledOK) return 0;
else
return 1;
if(runType=="PHYSICS") {
- Bool_t badmap_OK = FindBadChannelsEmc();
- if(!badmap_OK) Log(Form("WARNING!! FindBadChannels() completed with BAD status!"));
-
Bool_t calibEmc_OK = CalibrateEmc();
-
- if(calibEmc_OK && badmap_OK) return 0;
+
+ if(calibEmc_OK) return 0;
else
return 1;
}
Bool_t AliPHOSPreprocessor::ProcessLEDRun()
{
- //Process LED run, fill bad channels map.
+ //Process LED run, update High Gain/Low Gain ratios.
- AliPHOSEmcBadChannelsMap badMap;
+ AliPHOSEmcCalibData calibData;
TList* list = GetFileSources(kDAQ, "LED");
if(!list) {
return kFALSE;
}
+ if(!list->GetEntries()) {
+ Log("Sources list for LED run is empty, exit.");
+ return kFALSE;
+ }
+
+ //Retrieve the last EMC calibration object
+ const AliPHOSEmcCalibData* clb=0;
+ AliCDBEntry* entryCalib = GetFromOCDB("Calib", "EmcGainPedestals");
+
+ if(!entryCalib)
+ Log(Form("Cannot find any AliCDBEntry for [Calib, EmcGainPedestals]!"));
+ else
+ clb = (AliPHOSEmcCalibData*)entryCalib->GetObject();
+
TIter iter(list);
TObjString *source;
- char hnam[80];
- TH1F* histo=0;
+ Bool_t firedOK = kFALSE;
while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
-
+
AliInfo(Form("found source %s", source->String().Data()));
TString fileName = GetFile(kDAQ, "LED", source->GetName());
return kFALSE;
}
+ TH1I* fFiredCells = (TH1I*)f.Get("fFiredCells");
+
+ if(!fFiredCells) {
+ Log(Form("fFiredCells histogram not found in %s, skip this source.",fileName.Data()));
+ firedOK=kFALSE;
+ }
+ else {
+ const Double_t nFiredCells = fFiredCells->GetMean();
+ if(nFiredCells>100 && nFiredCells<600) {
+ firedOK = kTRUE;
+ Log(Form("Number of fired cells per event is %d.",nFiredCells));
+ }
+ else {
+ Log(Form("Number of fired cells per event is %d, possibly not a LED run!",nFiredCells));
+ firedOK = kFALSE;
+ }
+
+ }
+
const Int_t nMod=5; // 1:5 modules
const Int_t nCol=56; //1:56 columns in each module
const Int_t nRow=64; //1:64 rows in each module
-
- // Check for dead channels
- Log(Form("Begin check for dead channels."));
-
+
for(Int_t mod=0; mod<nMod; mod++) {
for(Int_t col=0; col<nCol; col++) {
for(Int_t row=0; row<nRow; row++) {
- sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
- histo = (TH1F*)f.Get(hnam);
- if(histo)
- if (histo->GetMean()<1) {
- Log(Form("Channel: [%d,%d,%d] seems dead, <E>=%.1f.",mod,col,row,histo->GetMean()));
- badMap.SetBadChannel(mod,col,row);
- }
+
+ //High Gain to Low Gain ratio
+ if(firedOK) {
+ Float_t ratio = HG2LG(mod,row,col,&f);
+ calibData.SetHighLowRatioEmc(mod+1,col+1,row+1,ratio);
+ if(ratio != 16.)
+ AliInfo(Form("mod %d iX %d iZ %d ratio %.3f\n",mod,row,col,ratio));
+ }
+
+ if(clb) {
+ Double_t coeff = clb->GetADCchannelEmc(mod+1,col+1,row+1);
+ calibData.SetADCchannelEmc(mod+1,col+1,row+1,coeff);
+ }
+ else
+ calibData.SetADCchannelEmc(mod+1,col+1,row+1,1.);
+
}
}
}
- }
+ } // end of loop over files
- //Store bad channels map
- AliCDBMetaData badMapMetaData;
+ //Store the updated High Gain/Low Gain ratios
+ AliCDBMetaData emcMetaData;
- //Bad channels data valid from current run fRun until updated (validityInfinite=kTRUE)
- Bool_t result = Store("Calib", "EmcBadChannels", &badMap, &badMapMetaData, fRun, kTRUE);
+ //Data valid from current run fRun until updated (validityInfinite=kTRUE)
+ Bool_t result = Store("Calib","EmcGainPedestals",&calibData,&emcMetaData,fRun,kTRUE);
return result;
}
Bool_t AliPHOSPreprocessor::FindBadChannelsEmc()
{
- //Creates the bad channels map for PHOS EMC.
+ //Loop over two systems: DAQ and HLT.
+ //For each system the same algorithm implemented in DoFindBadChannelsEmc() invokes.
- // The file fileName contains histograms which have been produced by DA2 detector algorithm.
- // It is a responsibility of the SHUTTLE framework to form the fileName.
+ TList* list=0;
+ TString path;
+
+ Int_t system[2] = { kDAQ, kHLT };
+ const char* sysn[] = { "DAQ","HLT" };
+ Bool_t result[2] = { kTRUE, kTRUE };
- AliPHOSEmcBadChannelsMap badMap;
+ for (Int_t i=0; i<2; i++) {
- TList* list = GetFileSources(kDAQ, "BAD_CHANNELS");
+ AliPHOSEmcBadChannelsMap badMap;
+ list = GetFileSources(system[i], "BAD_CHANNELS");
- if(!list) {
- Log("Sources list for BAD_CHANNELS not found, exit.");
- return kFALSE;
- }
+ if(!list) {
+ Log(Form("%s sources list for BAD_CHANNELS not found!",sysn[i]));
+ result[i] = kFALSE;
+ continue;
+ }
- if(!list->GetEntries()) {
- Log(Form("Got empty sources list. It seems DA2 did not produce any files!"));
- return kFALSE;
+ if(!list->GetEntries()) {
+ Log(Form("Got empty sources list. It seems %s DA2 did not produce any files!",sysn[i]));
+ result[i] = kFALSE;
+ continue;
+ }
+
+ result[i] *= DoFindBadChannelsEmc(system[i],list,badMap);
+
+ // Store the bad channels map.
+
+ AliCDBMetaData md;
+ md.SetResponsible("Boris Polishchuk");
+
+ if(system[i] == kDAQ)
+ path = "Calib";
+ else
+ path = "HLT";
+
+ // Data valid from current run fRun until being updated (validityInfinite=kTRUE)
+ result[i] *= Store(path.Data(), "EmcBadChannels", &badMap, &md, fRun, kTRUE);
+
}
+
+ if(result[0] || result[1]) return kTRUE;
+ else return kFALSE;
+}
+
+Bool_t AliPHOSPreprocessor::DoFindBadChannelsEmc(Int_t system, TList* list, AliPHOSEmcBadChannelsMap& badMap)
+{
+ //Creates the bad channels map for PHOS EMC.
+
+ // The file fileName contains histograms which have been produced by DA2 detector algorithm.
+ // It is a responsibility of the SHUTTLE framework to form the fileName.
TIter iter(list);
TObjString *source;
AliInfo(Form("found source %s", source->String().Data()));
- TString fileName = GetFile(kDAQ, "BAD_CHANNELS", source->GetName());
+ TString fileName = GetFile(system, "BAD_CHANNELS", source->GetName());
AliInfo(Form("Got filename: %s",fileName.Data()));
TFile f(fileName);
Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
return kFALSE;
}
+
+ TH1I* fFiredCells = (TH1I*)f.Get("fFiredCells");
+
+ if(!fFiredCells) {
+ Log(Form("fFiredCells histogram not found in %s, skip this source.",fileName.Data()));
+ continue;
+ }
+
+ const Double_t nFiredCells = fFiredCells->GetMean();
+
+ if(nFiredCells<100. || nFiredCells>600. ) {
+ Log(Form("Number of fired cells per event is %d, possibly not a LED run!",nFiredCells));
+ continue; // not a LED run!
+ }
- Log(Form("Begin check for bad channels."));
+ Log(Form("Number of fired cells per event %d. Begin check for bad channels.",nFiredCells));
for(Int_t mod=0; mod<5; mod++) {
for(Int_t iX=0; iX<64; iX++) {
} // end of loop over sources
- // Store the bad channels map.
-
- AliCDBMetaData md;
- md.SetResponsible("Boris Polishchuk");
-
- // Data valid from current run fRun until being updated (validityInfinite=kTRUE)
- Bool_t result = Store("Calib", "EmcBadChannels", &badMap, &md, fRun, kTRUE);
- return result;
-
+ return kTRUE;
}
Bool_t AliPHOSPreprocessor::CalibrateEmc()
{
- // I. Calculates the set of calibration coefficients to equalyze the mean energies deposited at high gain.
- // II. Extracts High_Gain/Low_Gain ratio for each channel.
+ //Loop over two systems: DAQ and HLT.
+ //For each system the same algorithm implemented in DoCalibrateEmc() invokes.
- // The file fileName contains histograms which have been produced by DA1 detector algorithm.
- // It is a responsibility of the SHUTTLE framework to form the fileName.
+ const AliPHOSEmcBadChannelsMap* badMap=0;
+ AliCDBEntry* entryBCM=0;
+ TList* list=0;
+ TString path;
+
+ Int_t system[2] = { kDAQ, kHLT };
+ const char* sysn[] = { "DAQ","HLT" };
+ Bool_t result[2] = { kTRUE, kTRUE };
- gRandom->SetSeed(0); //the seed is set to the current machine clock!
- AliPHOSEmcCalibData calibData;
+ for (Int_t i=0; i<2; i++) {
+
+ AliPHOSEmcCalibData calibData;
+ list = GetFileSources(system[i], "AMPLITUDES");
- TList* list = GetFileSources(kDAQ, "AMPLITUDES");
+ if(!list) {
+ Log(Form("%s sources list not found!",sysn[i]));
+ result[i] = kFALSE;
+ continue;
+ }
+
+ if(!list->GetEntries()) {
+ Log(Form("Got empty sources list. It seems %s DA1 did not produce any files!",sysn[i]));
+ result[i] = kFALSE;
+ continue;
+ }
+
+ // Retrieve the Bad Channels Map (BCM)
+
+ if(system[i] == kDAQ)
+ path = "Calib";
+ else
+ path = "HLT";
- if(!list) {
- Log("Sources list not found, exit.");
- return 1;
- }
+ entryBCM = GetFromOCDB(path.Data(), "EmcBadChannels");
- if(!list->GetEntries()) {
- Log(Form("Got empty sources list. It seems DA1 did not produce any files!"));
- return kFALSE;
+ if(!entryBCM)
+ Log(Form("WARNING!! Cannot find any AliCDBEntry for [%s, EmcBadChannels]!",path.Data()));
+ else
+ badMap = (AliPHOSEmcBadChannelsMap*)entryBCM->GetObject();
+
+ if(!badMap)
+ Log(Form("WARNING!! Nothing for %s in AliCDBEntry. All cells considered GOOD!",sysn[i]));
+
+ result[i] *= DoCalibrateEmc(system[i],list,badMap,calibData);
+
+ //Store EMC calibration data
+
+ AliCDBMetaData emcMetaData;
+ result[i] *= Store(path.Data(), "EmcGainPedestals", &calibData, &emcMetaData, 0, kTRUE);
+
}
+
+ if(result[0] || result[1]) return kTRUE;
+ else return kFALSE;
+}
- // Retrieve Bad Channels Map (BCM)
- const AliPHOSEmcBadChannelsMap* badMap=0;
- AliCDBEntry* entryBCM = GetFromOCDB("Calib", "EmcBadChannels");
+Bool_t AliPHOSPreprocessor::DoCalibrateEmc(Int_t system, TList* list, const AliPHOSEmcBadChannelsMap* badMap, AliPHOSEmcCalibData& calibData)
+{
+ // Return kTRUE if OK.
+ // I. Calculates the set of calibration coefficients to equalyze the mean energies deposited at high gain.
+ // II. Extracts High_Gain/Low_Gain ratio for each channel.
- if(!entryBCM)
- Log(Form("WARNING!! Cannot find any AliCDBEntry for [Calib, EmcBadChannels]!"));
- else
- badMap = (AliPHOSEmcBadChannelsMap*)entryBCM->GetObject();
+ // The file fileName contains histograms which have been produced by DA1 detector algorithm.
+ // It is a responsibility of the SHUTTLE framework to form the fileName.
- if(!badMap)
- Log(Form("WARNING!! No Bad Channels Map in AliCDBEntry. All cells considered _GOOD_!"));
+ gRandom->SetSeed(0); //the seed is set to the current machine clock!
TIter iter(list);
TObjString *source;
while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
AliInfo(Form("found source %s", source->String().Data()));
- TString fileName = GetFile(kDAQ, "AMPLITUDES", source->GetName());
+ TString fileName = GetFile(system, "AMPLITUDES", source->GetName());
AliInfo(Form("Got filename: %s",fileName.Data()));
TFile f(fileName);
if(!f.IsOpen()) {
Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
- return 1;
+ return kFALSE;
}
const Int_t nMod=5; // 1:5 modules
if(nkeys< 2){
Log(Form("Not enough histograms (%d) for calibration.",nkeys));
- return 1;
+ return 1; // it's not fatal! May be short run..
}
while(!ok){
if(!ok && counter > nkeys){
Log("No histogram with enough statistics for reference. Exit.");
- return 1;
+ return 1; // Not fatal, just wait..
}
}
for(Int_t mod=0; mod<nMod; mod++) {
for(Int_t col=0; col<nCol; col++) {
for(Int_t row=0; row<nRow; row++) {
-
- //High Gain to Low Gain ratio
- Float_t ratio = HG2LG(mod,row,col,&f);
- calibData.SetHighLowRatioEmc(mod+1,col+1,row+1,ratio);
sprintf(hnam,"%d_%d_%d_1",mod,row,col); // high gain!
h2 = (TH2F*)f.Get(hnam);
-
+
//TODO: dead channels exclusion!
if(h2) {
h1 = h2->ProjectionX();
f.Close();
}
- //Store EMC calibration data
-
- AliCDBMetaData emcMetaData;
- Bool_t result = Store("Calib", "EmcGainPedestals", &calibData, &emcMetaData, 0, kTRUE); // valid from 0 to infinity);
- return result;
-
+ return 1;
}