Shuttle debugging line removed.
[u/mrichter/AliRoot.git] / TOF / TOFPreprocessor.C
index 85930df..ab6fe75 100644 (file)
@@ -10,44 +10,65 @@ $Id$
 //   ReadDCSAliasMap() reads from a file
 //   CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
 
-void TOFPreprocessor()
+extern TBenchmark *gBenchmark;
+void TOFPreprocessor(Char_t * RunType="PHYSICS")
 {
-  gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
+  gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
 
+  //AliLog::SetClassDebugLevel("AliTOFPreprocessor",1);
   // initialize location of CDB
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
 
   // create AliTestShuttle instance
   AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
+  //setting run type to physiscs
+  shuttle->SetInputRunType(RunType);
 
   // Generation of "fake" input DCS data
-  TMap* dcsAliasMap = CreateDCSAliasMap();
+  TMap* dcsAliasMap = CreateDCSAliasMap();  
 
   // now give the alias map to the shuttle
-  shuttle->SetDCSInput(dcsAliasMap);
+  shuttle->SetDCSInput(dcsAliasMap);   
 
   // processing files. for the time being, the files are local.
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
+  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.164003.4001");
+  char filename[100];
+  char LDCname[5];
+
+  for (Int_t iLDC=0;iLDC<2;iLDC++){
+    sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
+    sprintf(LDCname,"LDC%i",iLDC*2);
+    shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
+    sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
+    sprintf(LDCname,"LDC%i",iLDC*2);
+    shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
+  }
 
   // instantiation of the preprocessor
-  AliPreprocessor* pp = new AliTOFPreprocessor("TOF", shuttle);
+  AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
 
   // preprocessing
+  gBenchmark->Start("process");
   shuttle->Process();
+  gBenchmark->Stop("process");
+  gBenchmark->Print("process");
 
   // checking the file which should have been created  
-  AliCDBEntry* entry = AliCDBManager::Instance()->Get("TOF/Calib/OnlineDelay", 0);
-  if (!entry)
+  AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnline", 0);
+  if (!chkEntry)
   {
     printf("The file is not there. Something went wrong.\n");
     return;
   }
 
-  AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (entry->GetObject());
+  AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
   // If everything went fine, draw the result
   if (output)
-    output->Draw();
+    printf("Output found.\n");
+  //    output->Draw();
   
 }
 
@@ -77,94 +98,193 @@ TMap* CreateDCSAliasMap()
 
   //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
   //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
-  Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
-    tentFEEthr=0.5, tentFEEt=20, tentTemp=25, tentPress=900;
-  Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
-    sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
+  //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
+  //  tentFEEthr=0.5, te    result=0;
+  //ntFEEt=20, tentTemp=25, tentPress=900;
+  //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
+  //  sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
+
+  Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5,
+    tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48,
+    tentLVi33=100, tentLVi50=3.0, tentLVi48=10,
+    tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45;
+  Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0,
+    sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1,
+    sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2,
+    sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4;
 
   Float_t tent=0, sigma=0, thr=0;
-  Int_t NAliases=10442, NHV=90, NLV=576, NFEEthr=1152, NFEEt=7776, NT=1, NP=1;
+  // to have all the aliases, deccoment the following line:
+  //  Int_t NAliases=10944, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840;
+
+  // if not all the aliases are there, use this:
+  Int_t NAliases=4104, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576;
 
   for(int nAlias=0;nAlias<NAliases;nAlias++) {
 
     TObjArray* valueSet = new TObjArray;
     valueSet->SetOwner(1);
 
+    TString sindex;
     TString aliasName;
     if (nAlias<NHV){
-      aliasName = "HVvpos";
-      aliasName += nAlias;
+      aliasName = "tof_hv_vp_";
+      sindex.Form("%02i",nAlias);
+      aliasName += sindex;
+      //aliasName += nAlias;
       tent=tentHVv;
       sigma=sigmaHVv;
       //      thr=thrHVv;
     }
     else if (nAlias<NHV*2){
-      aliasName = "HVvneg";
-      aliasName += nAlias-NHV;
+      //      aliasName = "HVvneg";
+      //aliasName += nAlias-NHV;
+      aliasName = "tof_hv_vn_";
+      sindex.Form("%02i",nAlias-NHV);
+      aliasName += sindex;
       tent=-tentHVv;
       sigma=-sigmaHVv;
       //thr=-thrHVv;
     }
     else if (nAlias<NHV*3){
-      aliasName = "HVcpos";
-      aliasName += nAlias-2*NHV;
-      tent=tentHVc;
-      sigma=sigmaHVc;
+      //      aliasName = "HVcpos";
+      //aliasName += nAlias-2*NHV;
+      aliasName = "tof_hv_ip_";
+      sindex.Form("%02i",nAlias-2*NHV);
+      aliasName += sindex;
+      tent=tentHVi;
+      sigma=sigmaHVi;
       //thr=thrHVc;
     }
     else if (nAlias<NHV*4){
-      aliasName = "HVcneg";
-      aliasName += nAlias-3*NHV;
-      tent=-tentHVc;
-      sigma=-sigmaHVc;
+      //      aliasName = "HVcneg";
+      //aliasName += nAlias-3*NHV;
+      aliasName = "tof_hv_in_";
+      sindex.Form("%02i",nAlias-3*NHV);
+      aliasName += sindex;
+      tent=-tentHVi;
+      sigma=-sigmaHVi;
       //thr=-thrHVc;
     }
     else if (nAlias<NHV*4+NLV){
-      aliasName = "LVv";
-      aliasName += nAlias-4*NHV;
+      //      aliasName = "LVv";
+      //aliasName += nAlias-4*NHV;
+      aliasName = "tof_lv_vfea_";
+      sindex.Form("%03i",nAlias-4*NHV);
+      aliasName += sindex;
       tent=tentLVv;
       sigma=sigmaLVv;
       //thr=thrLVv;
     }
     else if (nAlias<NHV*4+2*NLV){
-      aliasName = "LVc";
-      aliasName += nAlias-(4*NHV+NLV);
-      tent=tentLVc;
-      sigma=sigmaLVc;
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_ifea_";
+      sindex.Form("%03i",nAlias-(4*NHV+NLV));
+      aliasName += sindex;
+      tent=tentLVi;
+      sigma=sigmaLVi;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+NLV33){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_v33_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV));
+      aliasName += sindex;
+      tent=tentLVv33;
+      sigma=sigmaLVv33;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+2*NLV33){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_i33_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33));
+      aliasName += sindex;
+      tent=tentLVi33;
+      sigma=sigmaLVi33;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_v50_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33));
+      aliasName += sindex;
+      tent=tentLVv50;
+      sigma=sigmaLVv50;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_i50_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50));
+      aliasName += sindex;
+      tent=tentLVi50;
+      sigma=sigmaLVi50;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_v48_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50));
+      aliasName += sindex;
+      tent=tentLVv48;
+      sigma=sigmaLVv48;
       //thr=thrLVc;
     }
-    else if (nAlias<NHV*4+2*NLV+NFEEthr){
-      aliasName = "FEEthr";
-      aliasName += nAlias-(4*NHV+2*NLV);
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){
+      //      aliasName = "LVc";
+      //aliasName += nAlias-(4*NHV+NLV);
+      aliasName = "tof_lv_i48_";
+      sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48));
+      aliasName += sindex;
+      tent=tentLVi48;
+      sigma=sigmaLVi48;
+      //thr=thrLVc;
+    }
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){
+      //      aliasName = "FEEthr";
+      //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
+      aliasName = "tof_fee_th_";
+      sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48));
+      aliasName += sindex;
       tent=tentFEEthr;
       sigma=sigmaFEEthr;
       //thr=thrFEEthr;
     }
-    else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt){
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){
       //cout << " nalias fee temp = " << nAlias << endl;
-      aliasName = "FEEt";
-      aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
+      //      aliasName = "FEEt";
+      //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
+      aliasName = "tof_fee_tfeac_";
+      sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr));
+      aliasName += sindex;
       //cout << " nalias fee temp name = " << aliasName << endl;
-      tent=tentFEEt;
-      sigma=sigmaFEEt;
+      tent=tentFEEtfeac;
+      sigma=sigmaFEEtfeac;
       //thr=thrFEEthr;
     }
-    else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+1){
-      aliasName = "Temperature";
-      tent=tentTemp;
-      sigma=sigmaTemp;
-      //thr=thrTemp;
-    }
-    else if (nAlias<NHV*4+2*NLV+NFEEthr+NFEEt+2){
-      aliasName = "Pressure";
-      tent=tentPress;
-      sigma=sigmaPress;
-      //thr=thrPress;
+    /*
+    else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){
+      //cout << " nalias fee temp = " << nAlias << endl;
+      //      aliasName = "FEEt";
+      //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr);
+      aliasName = "tof_fee_ttrm_";
+      sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac));
+      aliasName += sindex;
+      //cout << " nalias fee temp name = " << aliasName << endl;
+      tent=tentFEEttrm;
+      sigma=sigmaFEEttrm;
+      //thr=thrFEEthr;
     }
-
-
+    */
     // gauss generation of values 
     for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
+    //for (int timeStamp=0;timeStamp<1;timeStamp++){
       Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
       if (TMath::Abs(gaussvalue-tent)>sigma){
        AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);