SDD PreProcessor updated (F. Prino)
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Apr 2007 10:53:15 +0000 (10:53 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 Apr 2007 10:53:15 +0000 (10:53 +0000)
ITS/AliITSPreprocessorSDD.cxx

index 097b49b..e12c19c 100644 (file)
@@ -9,9 +9,7 @@
 #include "AliShuttleInterface.h"
 #include "AliCDBMetaData.h"
 #include "TObjArray.h"
-#include "TH1F.h"
 #include "AliLog.h"
-#include "TFile.h"
 
 const Int_t AliITSPreprocessorSDD::fgkNumberOfSDD = 260;
 const Int_t AliITSPreprocessorSDD::fgkNumberOfChannels = 512;
@@ -24,77 +22,61 @@ UInt_t AliITSPreprocessorSDD::Process(TMap*/* dcsAliasMap*/){
 
   //preprocessing. 
 
-  UInt_t result = 0;
-  const char* filename = GetFile(kDAQ,"PEDESTALS","GDC");
-  const char* filenamen= GetFile(kDAQ,"NOISE","GDC");
-  const char* filenamed= GetFile(kDAQ,"DEADCHANNELS","GDC");
-  TFile* f1 = TFile::Open(filename,"r");
-  TFile* f2 = TFile::Open(filenamen,"r");
-  Char_t namehisto[20];
-  Char_t namehisto2[20];
-
-  FILE* filed = fopen(filenamed,"read");
-  Int_t numOfBadChannels[fgkNumberOfSDD];
-  Int_t** badCh = new Int_t*[fgkNumberOfSDD];
-  
-  Char_t row[50];
-  Int_t nSDD=0;
-  Char_t str[20];
-  char dims[1];
-  Int_t dim;
-  sprintf(str,"MODULE=%d",0);
-  while(!feof(filed)){
-    fscanf(filed,"%s\n",row);
-    if(strcmp(row,str)==0){
-      fscanf(filed,"%s %d\n",dims,&dim);
-      badCh[nSDD] = new Int_t[dim];
-      numOfBadChannels[nSDD]=dim;
-      for(Int_t ibad=0;ibad<dim;ibad++){
-       fscanf(filed,"%d\n",&badCh[nSDD][ibad]);
-      }      
-    }
-    nSDD++;
-    sprintf(str,"MODULE=%d",nSDD);
-  }
-  
-
 
   AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object
   md1->SetObjectClassName("AliITSCalibration");
-  md1->SetResponsible("Elisabetta Crescio");
+  md1->SetResponsible("Elisabetta Crescio, Francesco Prino");
   md1->SetBeamPeriod(0);
-  md1->SetAliRootVersion("head September 2005"); //root version
+  md1->SetAliRootVersion("head 5 April 2007"); //root version
   md1->SetComment("This is a test");
 
-  TObjArray respSDD(260);
+  TObjArray respSDD(fgkNumberOfSDD);
   respSDD.SetOwner(kFALSE);
   
+  Char_t filid[20];
+  Float_t baseline,rawnoise,cmn,gain;
+  Int_t isgoodan,i,im,is,isgoodmod;
+  Int_t numOfBadChannels[fgkNumberOfSDD];
   for(Int_t imod=0;imod<fgkNumberOfSDD;imod++){
     AliITSCalibrationSDD *cal = new AliITSCalibrationSDD("simulated");
-    cal->SetDeadChannels(numOfBadChannels[imod]);
-    for(Int_t ich=0;ich<numOfBadChannels[imod];ich++){
-      cal->SetBadChannel(ich,badCh[imod][ich]);
-    }
-    sprintf(namehisto,"%s_%d",fgkNameHistoPedestals.Data(),imod);
-    sprintf(namehisto2,"%s_%d",fgkNameHistoNoise.Data(),imod);
-    TH1F* hbas = (TH1F*)f1->Get(namehisto);
-    TH1F* hnoi = (TH1F*)f2->Get(namehisto2);
-    for(Int_t ien=0;ien<fgkNumberOfChannels;ien++){
-      cal->SetBaseline(ien,hbas->GetBinContent(ien+1));
-      cal->SetNoiseAfterElectronics(ien,hnoi->GetBinContent(ien+1));
+    numOfBadChannels[imod]=0;
+    Int_t badch[fgkNumberOfChannels];
+    for(Int_t isid=0;isid<=1;isid++){
+      sprintf(filid,"DAQDAm%03ds%d",imod,isid);
+      const char* filenamed= GetFile(kDAQ,filid,"GDC");
+      FILE* filed = fopen(filenamed,"read");
+      if (filed == 0) {
+       AliWarning("File not found"); 
+       continue;
+      }
+      
+      fscanf(filed,"%d %d %d\n",&im,&is,&isgoodmod);
+      if(!isgoodmod) cal->SetDead();
+      for(Int_t ian=0;ian<(fgkNumberOfChannels/2);ian++){
+       fscanf(filed,"%d %d %f %f %f %f\n",&i,&isgoodan,&baseline,&rawnoise,&cmn,&gain);
+       Int_t ich=ian;
+       if(isid==1) ich+=256;
+       if(!isgoodan){ 
+         Int_t ibad=numOfBadChannels[imod];
+         numOfBadChannels[imod]++;
+         badch[ibad]=ich;
+       }
+       cal->SetBaseline(ich,baseline);
+       cal->SetNoiseAfterElectronics(ich,rawnoise);    
+       //      cal->SetGain(gain,isid,ian/4,ian%4);
+      }
+      cal->SetDeadChannels(numOfBadChannels[imod]);
+      for(Int_t ibad=0;ibad<numOfBadChannels[imod];ibad++){
+       cal->SetBadChannel(ibad,badch[ibad]);
+      }
+      fclose(filed);
     }
     respSDD.Add(cal);
   }
 
-  result = Store("Calib","Data",&respSDD,md1);
+  Bool_t retcode = Store("Calib","Data",&respSDD,md1);
 
-  for(Int_t i=0;i<fgkNumberOfSDD;i++){
-    delete badCh[i];
-  }
-  delete [] badCh;
-  f1->Close();
-  f2->Close();
-  fclose(filed);
-  return result;
 
+  if(retcode) return 0;
+  else return 1;
 }