/* History of cvs commits:
*
* $Log$
+ * Revision 1.7 2007/06/20 08:50:14 gustavo
+ * Change wrong directory data name from EmcGainPedestals to Data
+ *
+ * Revision 1.6 2007/04/29 15:06:19 gustavo
+ * New return value, and some minor fixes
+ *
+ * Revision 1.5 2007/02/01 15:02:42 gustavo
+ * Added log message in case there are no source files
+ *
+ * Revision 1.4 2007/01/24 16:57:14 gustavo
+ * Calibratio file sources machines are now not hardcoded but retreived from shuttle
+ *
* Revision 1.3 2006/12/20 10:53:28 gustavo
* Change const char * by TString, change AliInfos per AliPreprocessor::Log or AliDebug
*
AliPreprocessor("EMC",shuttle)
{
// Constructor
+ AddRunType("PHYSICS");
+ AddRunType("STANDALONE");
+
}
//_______________________________________________________________________________________
// The fileName with the histograms which have been produced by
// AliEMCALCalibHistoProducer.
// It is a responsibility of the SHUTTLE framework to form the fileName
-
+
+ gRandom->SetSeed(0); //the seed is set to the current machine clock!
AliEMCALCalibData calibData;
TList* list = GetFileSources(kDAQ, "AMPLITUDES");
- if (list)
- {
- AliInfo("The following sources produced files with the id AMPLITUDES");
- list->Print();
- TIter iter(list);
- TObjString *source;
- while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
- //TObjString * str = dynamic_cast<TObjString*> (list->At(0));//Only one source?
- AliInfo(Form("found source %s", source->String().Data()));
-
- TString fileName = GetFile(kDAQ, "AMPLITUDES", source->GetName());
-
- //TString fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
- Log(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 0;
- }
+ if(!list) {
+ Log("Sources list not found, exit.");
+ return 1;
+ }
+
+ AliInfo("The following sources produced files with the id AMPLITUDES");
+ list->Print();
+
+ 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());
+ Log(Form("Got filename: %s",fileName.Data()));
- const Int_t nMod=12; // 1:5 modules
- const Int_t nCol=48; //1:56 columns in each module
- Int_t nRow=24; //1:64 rows in each module
- const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
+ TFile f(fileName);
- Double_t coeff;
- char hnam[80];
- TH1F* histo=0;
+ if(!f.IsOpen()) {
+ Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
+ return 1;
+ }
- //Get reference histogram
- TList * keylist = f.GetListOfKeys();
- Int_t nkeys = f.GetNkeys();
- Bool_t ok = kFALSE;
- TKey *key;
- TString refHistoName= "";
- Int_t ikey = 0;
- Int_t counter = 0;
- TH1F* hRef = new TH1F();
+ const Int_t nMod=12; // 1:5 modules
+ const Int_t nCol=48; //1:56 columns in each module
+ Int_t nRow=24; //1:64 rows in each module
+ const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
- //Check if the file contains any histogram
- if(nkeys< 2){
- Log(Form("Not enough histograms for calibration, nhist = %d",nkeys));
- return 1;
- }
+ Double_t coeff;
+ char hnam[80];
+ TH1F* histo=0;
- while(!ok){
- ikey = gRandom->Integer(nkeys);
- key = (TKey*)keylist->At(ikey);
- refHistoName = key->GetName();
- hRef = (TH1F*)f.Get(refHistoName);
- counter++;
- // Check if the reference has too little statistics and
- // if the histogram has the correct name (2 kinds, mod#col#row for
- // reference here, and mod#, see AliEMCALHistoProducer.
- if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0)
- ok=kTRUE;
- if(!ok && counter >= nMod*nCol*nRow+nMod){
- Log("No histogram with enough statistics for reference");
- return 1;
- }
- }
+ //Get reference histogram
+ TList * keylist = f.GetListOfKeys();
+ Int_t nkeys = f.GetNkeys();
+ Bool_t ok = kFALSE;
+ TKey *key;
+ TString refHistoName= "";
+ Int_t ikey = 0;
+ Int_t counter = 0;
+ TH1F* hRef = new TH1F();
+
+ //Check if the file contains any histogram
+
+ if(nkeys< 2){
+ Log(Form("Not enough histograms for calibration, nhist = %d",nkeys));
+ return 1;
+ }
- Double_t refMean=hRef->GetMean();
+ while(!ok){
+ ikey = gRandom->Integer(nkeys);
+ key = (TKey*)keylist->At(ikey);
+ refHistoName = key->GetName();
+ hRef = (TH1F*)f.Get(refHistoName);
+ counter++;
+ // Check if the reference has too little statistics and
+ // if the histogram has the correct name (2 kinds, mod#col#row for
+ // reference here, and mod#, see AliEMCALHistoProducer.
+ if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0)
+ ok=kTRUE;
+ if(!ok && counter >= nMod*nCol*nRow+nMod){
+ Log("No histogram with enough statistics for reference");
+ return 1;
+ }
+ }
- // Calculates relative calibration coefficients for all non-zero channels
+ Double_t refMean=hRef->GetMean();
- for(Int_t mod=0; mod<nMod; mod++) {
- if(mod > 10) nRow = nRowHalfSM ;
- 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);
- //TODO: dead channels exclusion!
- if(histo && histo->GetMean() > 0) {
- coeff = histo->GetMean()/refMean;
- calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
- AliDebug(1,Form("mod %d col %d row %d coeff %f\n",mod,col,row,coeff));
- }
- else
- calibData.SetADCchannel(mod+1,col+1,row+1,-111);
- }
+ // Calculates relative calibration coefficients for all non-zero channels
+
+ for(Int_t mod=0; mod<nMod; mod++) {
+ if(mod > 10) nRow = nRowHalfSM ;
+ 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);
+ //TODO: dead channels exclusion!
+ if(histo && histo->GetMean() > 0) {
+ coeff = histo->GetMean()/refMean;
+ calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
+ AliDebug(1,Form("mod %d col %d row %d coeff %f\n",mod,col,row,coeff));
}
+ else
+ calibData.SetADCchannel(mod+1,col+1,row+1,-111);
}
- f.Close();
- }//while
- }//If list
+ }
+ }
+ f.Close();
+ }//while
- AliCDBMetaData metaData;
- Int_t result = Store("Calib", "Data", &calibData, &metaData);
+ //Store EMCAL calibration data
-
+ AliCDBMetaData emcalMetaData;
+ Bool_t emcalOK = Store("Calib", "Data", &calibData, &emcalMetaData);
- return result;
+ if(emcalOK) return 0;
+ else
+ return 1;
}