Split DAQ DA into two tasks
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Jul 2007 12:44:59 +0000 (12:44 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Jul 2007 12:44:59 +0000 (12:44 +0000)
TRD/AliTRDCalibPadStatus.cxx
TRD/AliTRDCalibPadStatus.h
TRD/AliTRDPreprocessor.cxx
TRD/AliTRDPreprocessor.h
TRD/Macros/AliTRDCheckPreprocessor.C
TRD/TRDPEDESTALda.cxx [new file with mode: 0644]
TRD/TRDVDRIFTda.cxx [moved from TRD/TRDda.cxx with 71% similarity]

index 65dfaee..5077bdc 100644 (file)
@@ -612,7 +612,7 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
             Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
            Double_t ret = AliMathBase::FitGaus(array_hP+offset,nbinsAdc,fAdcMin,fAdcMax,&param,&dummy);
             // if the fitting failed set noise and pedestal to 0
-           if ((ret == -4) || (ret == -1)) {
+           if ((ret==-4) || (ret==-1) || (ret==-2)) {
                param[1]=0.0;
                param[2]=0.0;
            }
@@ -629,7 +629,7 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
 AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
 {
   //
-  //
+  // Create Pad Status out of Mean and RMS values
   //
 
   AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus");
@@ -639,7 +639,6 @@ AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
       AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet);
 
       //Take the stuff
-      fCalEntries = ((AliTRDarrayF *)GetCalEntries(idet));
       AliTRDCalROC *calRocMean    = ((AliTRDCalROC *)GetCalRocMean(idet));
       AliTRDCalROC *calRocRMS     = ((AliTRDCalROC *)GetCalRocRMS(idet));
 
@@ -647,44 +646,25 @@ AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
        for(Int_t k = 0; k < calROC->GetNchannels(); k++){
          calROC->SetStatus(k,AliTRDCalPadStatus::kMasked);
        }
-       //printf("no fCalRocMean for %d\n",idet);
        continue;
       }
-
+      
       //Range
       Int_t channels = calROC->GetNchannels();
-          
-
-      //Mean 
-      Float_t meanentries = 0.0;
-      if(!fCalEntries){
-       if(GetHisto(idet)){
-         meanentries = GetHisto(idet)->GetEntries()/(channels);
-       }
-      }
-      else meanentries       = TMath::Mean(channels,((TArrayF *)fCalEntries)->GetArray());
-      //Double_t meanmean      = calRocMean->GetMean()*10.0;
-      //Double_t meansquares   = calRocRMS->GetMean()*10.0;
+      
+      Double_t rmsmean       = calRocMean->GetRMS()*10.0;
+      Double_t meanmean      = calRocMean->GetMean()*10.0;
+      Double_t meansquares   = calRocRMS->GetMean()*10.0;
 
 
       for(Int_t ich = 0; ich < channels; ich++){
        
-       Float_t entries = 0.0;
-       if(!fCalEntries){
-         if(GetHisto(idet)){
-           for(Int_t bin = 0; bin < (fAdcMax-fAdcMin); bin++){
-             entries += GetHisto(idet)->GetArray()[(ich+1)*(fAdcMax-fAdcMin+2)+(bin+1)];
-           }
-         }
-       }
-       else entries     = fCalEntries->At(ich);
-       //Float_t mean     = calRocMean->GetValue(ich)*10.0;
+       Float_t mean     = calRocMean->GetValue(ich)*10.0;
        Float_t rms      = calRocRMS->GetValue(ich)*10.0;
-       //if(ich > 1720) printf("rms %f\n",rms);
-               
-       //if((entries < 0.3*meanentries) || (TMath::Abs(rms-meansquares) > ((Float_t)(fAdcMax-fAdcMin)/2.0)) || (rms == 0.0)) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
-       if(rms <= 0.0001) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
-       }
+       
+       if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked);
+      
+      }
     }
   
   return obj;
@@ -719,6 +699,46 @@ void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir,
     if ( backup ) backup->cd();
 }
 
+//_____________________________________________________________________
+void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
+{
+    //
+    //  Put the AliTRDCalROC in the array fCalRocArrayMean
+    //
+
+
+  AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE);
+  
+  Int_t nChannels = rocMean->GetNchannels();
+  
+  for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
+    
+    rocMean->SetValue(iChannel,mean->GetValue(iChannel));
+    
+  }
+  
+}
+
+//_____________________________________________________________________
+void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
+{
+    //
+    //  Put the AliTRDCalROC in the array fCalRocArrayRMS
+    //
+
+
+  AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE);
+  
+  Int_t nChannels = rocRms->GetNchannels();
+  
+  for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
+    
+    rocRms->SetValue(iChannel,rms->GetValue(iChannel));
+    
+  }
+  
+}
+
 //_____________________________________________________________________________
 Int_t AliTRDCalibPadStatus::GetPlane(Int_t d) const
 {
index e6273a1..d671b1b 100644 (file)
@@ -43,10 +43,14 @@ public:
               const Int_t signal, const Int_t rowMax);
   Int_t UpdateHisto(const Int_t idet, const Int_t iRow, const Int_t iCol,
                    const Int_t signal, const Int_t crowMax);
+
   void Analyse();
   void AnalyseHisto();
   AliTRDCalPadStatus *CreateCalPadStatus();
 
+  void SetCalRocMean(AliTRDCalROC *mean, Int_t det);
+  void SetCalRocRMS(AliTRDCalROC *rms, Int_t det);  
+
   //
   AliTRDarrayF* GetCalEntries(Int_t det, Bool_t force=kFALSE);    // get calibration object
   AliTRDarrayF* GetCalMean(Int_t det, Bool_t force=kFALSE);       // get calibration object
index 74ab4f8..20d455d 100644 (file)
@@ -55,7 +55,9 @@ ClassImp(AliTRDPreprocessor)
 
 //______________________________________________________________________________________________
 AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle)
-                   :AliPreprocessor("TRD", shuttle)
+  :AliPreprocessor("TRD", shuttle),
+  fResult(0),
+  fVdriftHLT(0)
 {
   //
   // Constructor
@@ -90,12 +92,42 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
   // Process DCS and calibration part for HLT
   //
 
-  UInt_t result = 0;
+  fResult = 0;
 
   //
   // DCS
   //
   
+  ProcessDCS(dcsAliasMap);
+
+  //
+  // Process the calibration data for the HLT and DAQ part
+  //
+
+  TString runType = GetRunType();
+  printf("runtype %s\n",(const char*)runType);
+
+
+  if (strcmp(runType, "PEDESTAL") == 0){
+    ExtractPedestals();
+  }
+  
+  if (strcmp(runType, "PHYSICS") == 0){
+    printf("test\n");
+    //if(GetRunParameter("HLTStatus")==1) ExtractHLT();
+    ExtractHLT();
+    ExtractDriftVelocityDAQ();
+  }
+  printf("result is %d\n",fResult);  
+  return fResult;  
+  
+}
+
+
+//______________________________________________________________________________
+void AliTRDPreprocessor::ProcessDCS(TMap * dcsAliasMap)
+{
+
   AliCDBMetaData metaData;
   metaData.SetBeamPeriod(0);
   metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
@@ -107,435 +139,490 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
   TObjArray * list = AliTRDSensorArray::GetList ();
        
   if (list == 0x0) {
-         Log ("Error during AliTRDSensorArray::GetList");
-         Log ("DCS will not be processing");
-  }else { 
-       
-       Int_t nEntries = list->GetEntries ();
-       Log (Form ("%d alias loaded", nEntries));
+    Log ("Error during AliTRDSensorArray::GetList");
+    Log ("DCS will not be processing");
+    return;
+  }
+
+  Int_t nEntries = list->GetEntries ();
+  Log (Form ("%d alias loaded", nEntries));
                
-       Bool_t * results = new Bool_t [nEntries];
-       Int_t  * nGraph = new Int_t [nEntries];
+  Bool_t * results=new Bool_t [nEntries];
+  Int_t  * nGraph=new Int_t [nEntries];
                
-       for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
+  for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
                        
-               AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
+    AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
                        
-               oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
-               oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
+    oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
+    oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
                        
-               Log (Form("Processing DCS : \"%s\"", 
-                       oneTRDDCS->GetStoreName ().Data ()));
+    Log (Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
                        
-               TMap * map = oneTRDDCS->ExtractDCS (dcsAliasMap);
+    TMap * map;
+
+    map=oneTRDDCS->ExtractDCS (dcsAliasMap);
                
-               nGraph [iAlias] = map->GetEntries ();
+    nGraph [iAlias] = map->GetEntries ();
                
-               if (nGraph [iAlias] == 0) {
-                       Log("No TGraph for this dcsDatapointAlias : not stored");
-                       results [iAlias] = kFALSE;
-                       result |= kEStoreRefDCS;
-                       continue;
-               }
+    if (nGraph [iAlias] == 0) {
+      Log("No TGraph for this dcsDatapointAlias : not stored");
+      results [iAlias] = kFALSE;
+      continue;
+    }
                
-               oneTRDDCS->SetGraph (map);
-
-               results [iAlias] = Store("Calib", 
-                                                                oneTRDDCS->GetStoreName ().Data (), 
-                                                                oneTRDDCS,  
-                                                                &metaData,
-                                                                0, 
-                                                                kTRUE); 
+    oneTRDDCS->SetGraph(map);
+    results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kTRUE); 
+    delete map;                
+
+    //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData); 
+
+
+    if (!results[iAlias]) {
+      AliError("Problem during StoreRef DCS"); 
+      fResult|=kEStore;
+    }
+
+
+    //BEGIN TEST (should not be removed ...)
+    /*
+    oneTRDDCS->ClearGraph();
+    oneTRDDCS->ClearFit();
+    oneTRDDCS->SetDiffCut2 (0.1);
+    map=oneTRDDCS->ExtractDCS (dcsAliasMap);
+    oneTRDDCS->SetGraph (map);
+    Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE); 
+    delete map;
+
+
+    if(iAlias==1 || iAlias==19) continue;
+    
+    oneTRDDCS->ClearGraph();
+    oneTRDDCS->ClearFit();
+    oneTRDDCS->SetDiffCut2(0);
+    map=oneTRDDCS->ExtractDCS(dcsAliasMap);
+    oneTRDDCS->MakeSplineFit(map);
+    Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); 
+    delete map;
+
+     
+    oneTRDDCS->ClearGraph(); 
+    oneTRDDCS->ClearFit();
+    oneTRDDCS->SetDiffCut2 (0.1);
+    map=oneTRDDCS->ExtractDCS (dcsAliasMap);
+    oneTRDDCS->MakeSplineFit(map);
+    Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); 
+    delete map;
+    */    
+    //END TEST
+
+      
+      
+  }
                
-               /*      
-               results [iAlias] = StoreReferenceData("Calib", 
-                                                                                               oneTRDDCS->GetStoreName ().Data (), 
-                                                                                               oneTRDDCS, 
-                                                                                               &metaData); 
-               */
-               if (!results [iAlias]) {
-                       AliError("Problem during StoreRef DCS"); 
-                       result |= kEStoreRefDCS;
-               }
-                       
-               delete map;
-                       
-               /*
-                       //BEGIN TEST
-               oneTRDDCS->SetDiffCut2 (0.1);
-               map = oneTRDDCS->ExtractDCS (dcsAliasMap);
-               oneTRDDCS->SetGraph (map);
-                       
-               StoreReferenceData("Calib", 
-                                                       (oneTRDDCS->GetStoreName ()+"Cut").Data(), 
-                                                       oneTRDDCS, &metaData); 
-               delete map;
-                       //END TEST
-               */
+  Log ("         Summury of DCS :\n");
+  Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph"));
+  for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
+    AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
+    Log (Form ("%30s %10s %4d", 
+              oneTRDDCS->GetStoreName ().Data (),
+              results[iAlias] ? "ok" : "X",
+              nGraph [iAlias]));
+  }
+  Log ("*********** End of DCS **********");
+  
+  delete results;
+  delete nGraph;
+
+
+}
+
+//______________________________________________________________________________________________
+void AliTRDPreprocessor::ExtractPedestals()
+{
+  //
+  // Pedestal running on LDCs at the DAQ
+  //
+
+  // Init a AliTRDCalibPadStatus
+  AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
+
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Raphaelle Bailhache");
+  metaData.SetComment("TRD calib test");
+  
+  // Sum the contributions of the LDCs
+  TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
+  if (listpad) {
+    
+    // loop through all files from LDCs
+
+    UInt_t index = 0;
+    while (listpad->At(index)!=NULL) {
+      TObjString* fileNameEntry = (TObjString*) listpad->At(index);
+      if (fileNameEntry != NULL) {
+        TString fileName = GetFile(kDAQ, "PADSTATUS",
+                                  fileNameEntry->GetString().Data());
+       if(fileName.Length() !=0){
+         TFile *f = TFile::Open(fileName);
+         AliTRDCalibPadStatus *calPed;
+         f->GetObject("calibpadstatus",calPed);
+         
+         if(calPed){
+
+           // analyse
+           calPed->AnalyseHisto();
+           
+           // store as reference data
+           TString name("PadStatus");
+           name += (Int_t)index;
+           if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
+             Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
+             fResult |= kEStore;
+           }
+           
+              
+           // Add to the calPedSum
+           for (Int_t idet=0; idet<540; idet++) {
+             AliTRDCalROC *rocMean  = calPed->GetCalRocMean(idet, kFALSE);
+             if ( rocMean )  calPedSum.SetCalRocMean(rocMean,idet);
+             AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
+             if ( rocRMS )  calPedSum.SetCalRocRMS(rocRMS,idet);
+           }// det loop
+           
+         } // calPed
        }
-               
-       Log ("         Summury of DCS :\n");
-       Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph"));
-       for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
-               AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
-               Log (Form ("%30s %10s %4d", 
-                       oneTRDDCS->GetStoreName ().Data (),
-                       results[iAlias] ? "ok" : "X",
-                       nGraph [iAlias]));
+       else{
+         Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
+         fResult |= kEGetFileDAQ;  
        }
-       Log ("*********** End of DCS **********");
-       
-       delete results;
-       delete nGraph;
+      }// fileNameEntry length
+      ++index;
+    }// while (list)
+    Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
+    if(index==0){
+      fResult |= kEEmptyListDAQ;
+    }
+    //
+    // Store pedestal entry to OCDB
+    //
+
+
+    // Create Pad Status
+    AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
+    AliCDBMetaData md3; 
+    md3.SetObjectClassName("AliTRDCalPadStatus");
+    md3.SetResponsible("Raphaelle Bailhache");
+    md3.SetBeamPeriod(1);
+    md3.SetComment("TRD calib test");
+    if(!Store("Calib","PadStatus"    ,(TObject *)calPadStatus, &md3, 0, kTRUE)){
+      Log("Error storing the pedestal");
+      fResult |= kEStore;    
+    }
+    delete listpad;
+  }
+  else {
+    Log("No list found for the PEDESTRAL Run");
+    fResult |= kEGetFileDAQ;    
   }
+  
 
+}
+//______________________________________________________________________________________________
+void AliTRDPreprocessor::ExtractDriftVelocityDAQ()
+{
   //
-  // Process the calibration data for the HLT part
+  // Drift velocity DA running on monitoring servers at the DAQ
   //
 
- // Objects for HLT and DAQ zusammen
+
+  // Objects for HLT and DAQ zusammen
   AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
-  Bool_t hltVdrifthisto = kFALSE;
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Raphaelle Bailhache");
+  metaData.SetComment("TRD calib test");
   // Store the infos for the detector
-  AliCDBMetaData *md1= new AliCDBMetaData(); 
-  md1->SetObjectClassName("AliTRDCalDet");
-  md1->SetResponsible("Raphaelle Bailhache");
-  md1->SetBeamPeriod(0);
-  md1->SetComment("TRD calib test");
+  AliCDBMetaData md1; 
+  md1.SetObjectClassName("AliTRDCalDet");
+  md1.SetResponsible("Raphaelle Bailhache");
+  md1.SetBeamPeriod(0);
+  md1.SetComment("TRD calib test");
   // Store the infos for the pads
-  AliCDBMetaData *md2= new AliCDBMetaData(); 
-  md2->SetObjectClassName("AliTRDCalPad");
-  md2->SetResponsible("Raphaelle Bailhache");
-  md2->SetBeamPeriod(0);
-  md2->SetComment("TRD calib test");
-  //
-  // Process the calibration data for the HLT part
-  //
+  AliCDBMetaData md2; 
+  md2.SetObjectClassName("AliTRDCalPad");
+  md2.SetResponsible("Raphaelle Bailhache");
+  md2.SetBeamPeriod(0);
+  md2.SetComment("TRD calib test");
 
-  // How long does it take for the HLT part?
-  TStopwatch timer;
-  timer.Start();
 
-  //Run type
-  TString runType = GetRunType();
-  Log(Form("Run type for run %d: %s", fRun, runType.Data()));
-  if (strcmp(runType, "PHYSICS") != 0){
-    Log("Nothing to do for HLT!");
-  }
-  else{
-    // note that the parameters are returned as character strings!
-    const char* nEvents = GetRunParameter("totalEvents");
-    if (nEvents) {
-      Log(Form("Number of events for run %d: %s",fRun, nEvents));
-    } else {
-      Log(Form("Number of events not put in logbook!"));
-    }
 
-    // Take the file from the HLT file exchange server
-    TList *filesourceshlt = GetFileSources(kHLT,"GAINDRIFTPRF");
-    if (!filesourceshlt) {
-      Log(Form("No sources found for GAINDRIFTPRF for run %d !",fRun));
-      result |= kEListFileHLT;
-    }
-    else{
-      if (filesourceshlt->GetSize() != 1) {
-       Log(Form("More than one source found for GAINDRIFTPRF for run %d!",fRun));
-       filesourceshlt->Print();
-       result |= kEListFileHLT;
-      }
-      else {
-
-       //Debug mode
-       //calibra->SetDebugLevel(2);       //Debug
-
-       // Loop over the files taken from the HLT
-       TIter iter(filesourceshlt);
-       TObjString *sourcehlt;
-       while ((sourcehlt = dynamic_cast<TObjString *> (iter.Next()))) {
-    
-         TString filenamehlt = GetFile(kHLT,"GAINDRIFTPRF",sourcehlt->GetName());
-         if (filenamehlt.Length() == 0) {
-           Log(Form("Error retrieving file from source %d failed!", sourcehlt->GetName()));
-           result |= kEOpenFileHLT;
-         }
-         else{
-
-           // Init some things
-           TH2I         *histogain           = 0x0; // Histogram taken from HLT for gain factor
-           TProfile2D   *histodriftvelocity  = 0x0; // Profile taken from HLT for drift velocity and time0
-           TProfile2D   *histoprf            = 0x0; // Profile taken from HLT for prf
-
-
-           // Take the histos
-           TFile *filehlt = TFile::Open(filenamehlt);
-           histogain = (TH2I *) filehlt->Get("CH2d");
-           histogain->SetDirectory(0);
-           if (!histogain) {
-             Log("Error retrieving 2D histos for gain failed!");
-             result |= kETakeHistoHLT;
-           }
-           histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
-           histodriftvelocity->SetDirectory(0);
-           if (!histodriftvelocity) {
-             Log("Error retrieving 2D Profile for average pulse height failed!");
-             result |= kETakeHistoHLT;
-           }
-           histoprf = (TProfile2D *) filehlt->Get("PRF2d");
-           histoprf->SetDirectory(0);
-           if (!histoprf) {
-             Log("Error retrieving 2D Profile for Pad Response Function failed!");
-             result |= kETakeHistoHLT;
-           }
-           filehlt->Close();
+
+  // Take the file from the DAQ file exchange server
+  TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
+  if (listdaq) {
+    if(listdaq->GetSize() ==1){
+      TObjString* fileNameEntry = (TObjString*) listdaq->At(0);
+      if(fileNameEntry != NULL){
+       TString fileName = GetFile(kDAQ, "VDRIFT",
+                                  fileNameEntry->GetString().Data());
+       if(fileName.Length() !=0){
+         TFile *filedaq = TFile::Open(fileName);
+         TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
+         if (histodriftvelocity) {
            
-           // try to fit them and store
-           if (histogain) {
-             if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
-               Log("Error storing 2D histos for gain as reference data");
-               result |= kEStoreHistoHLT;
-             }
-             Log("Take the CH reference data. Now we will try to fit\n");
-             calibra->SetMinEntries(100); // If there is less than 100 entries in the histo: no fit
-             calibra->AnalyseCH(histogain);
-             Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
-               + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
-             Int_t nbfit       = calibra->GetNumberFit();
-             Int_t nbE         = calibra->GetNumberEnt();
-             if ((nbtg >                  0) && 
-                 (nbfit        >= 0.95*nbE)) {
-               TObjArray object             = calibra->GetVectorFit();
-               AliTRDCalDet *objgaindet   = calibra->CreateDetObjectGain(&object,calibra->GetScaleFitFactor(),kTRUE);
-               TObject *objgainpad        = calibra->CreatePadObjectGain();
-               if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet         ,md1,0,kTRUE)){
-                 Log("Error storing the calibration object for the chamber gain");
-                 result |= kEStoreCalHLT;
-               }
-               if(!Store("Calib","LocalGainFactor"  ,(TObject *) objgainpad         ,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the local gain factor");
-                 result |= kEStoreCalHLT;
-               }
-             }
-             else{
-               Log("Not enough statistics for the gain");
-               result |= kEFitHistoHLT;
-             }
-             calibra->ResetVectorFit();
+           // store as reference data
+           if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
+             Log("Error storing 2D Profile for vdrift from the DAQ");
+             fResult |= kEStore;
            }
-    
-           if (histodriftvelocity) {
-             if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
-               Log("Error storing 2D Profile for average pulse height as reference data");
-               result |= kEStoreHistoHLT;
-             }
+           
+           // analyse
+           if(!fVdriftHLT){
              Log("Take the PH reference data. Now we will try to fit\n");
-             calibra->SetMinEntries(100*20); // If there is less than 2000
+             calibra->SetMinEntries(2000); // If there is less than 2000
              calibra->AnalysePH(histodriftvelocity);
+             
              Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
                + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
              Int_t nbfit        = calibra->GetNumberFit();
-             Int_t nbE          = calibra->GetNumberEnt();
+             Int_t nbE        = calibra->GetNumberEnt();
+             
+             // if enough statistics store the results
              if ((nbtg >                  0) && 
                  (nbfit        >= 0.95*nbE)) {
-               TObjArray object  = calibra->GetVectorFit();
+               // create the cal objects
+               TObjArray object      = calibra->GetVectorFit();
                AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
-               TObject *objdriftvelocitypad      = calibra->CreatePadObjectVdrift();
+               TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
                object              = calibra->GetVectorFit2();
-               AliTRDCalDet *objtime0det  = calibra->CreateDetObjectT0(&object,kTRUE);
-               TObject *objtime0pad       = calibra->CreatePadObjectT0();
-               if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,md1,0,kTRUE)){
-                 Log("Error storing the calibration object for the chamber vdrift");
-                 result |= kEStoreCalHLT;    
-               }
-               if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,md1,0,kTRUE)){
-                 Log("Error storing the calibration object for the chamber t0");
-                 result |= kEStoreCalHLT;    
+               AliTRDCalDet *objtime0det         = calibra->CreateDetObjectT0(&object,kTRUE);
+               TObject *objtime0pad         = calibra->CreatePadObjectT0();
+               calibra->ResetVectorFit();
+               // store
+               if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
+                 Log("Error storing the calibration object for the chamber vdrift (DAQ)");
+                 fResult |= kEStore;    
                }
-               if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the local drift velocity");
-                 result |= kEStoreCalHLT;
+               if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,&md1,0,kTRUE)){
+                 Log("Error storing the calibration object for the chamber t0 (DAQ)");
+                 fResult |= kEStore;    
                }
-               if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the local time0");
-                 result |= kEStoreCalHLT;
+               if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
+                 Log("Error storing the calibration object for the local drift velocity (DAQ)");
+                 fResult |= kEStore;
                }
-               hltVdrifthisto = kTRUE;
-             }
-             else{
-               Log("Not enough statistics for the average pulse height");
-               result |= kEFitHistoHLT;
-             }      
-             calibra->ResetVectorFit();
-           }
-           
-           if (histoprf) {
-             if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
-               Log("Error storing the 2D Profile for Pad Response Function as reference data");
-               result |= kEStoreHistoHLT;
-             }
-             Log("Take the PRF reference data. Now we will try to fit\n");
-             calibra->SetMinEntries(100*20); // If there is less than 2000
-             calibra->AnalysePRFMarianFit(histoprf);
-             Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
-               + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
-             Int_t nbfit        = calibra->GetNumberFit();
-             Int_t nbE          = calibra->GetNumberEnt();
-             if ((nbtg >                  0) && 
-                 (nbfit        >= 0.95*nbE)) {
-               TObjArray object              = calibra->GetVectorFit();
-               TObject *objPRFpad          = calibra->CreatePadObjectPRF(&object);
-               if(!Store("Calib","PRFWidth"         ,(TObject *) objPRFpad          ,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the Pad Response Function");
-                 result |= kEStoreCalHLT;
+               if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,&md2,0,kTRUE)){
+                 Log("Error storing the calibration object for the local time0 (DAQ)");
+                 fResult |= kEStore;
                }
              }
              else{
-               Log("Not enough statistics for the Pad Response Function");
-               result |= kEFitHistoHLT;
+               Log("Not enough statistics for the average pulse height (DAQ)");
              }
-             calibra->ResetVectorFit();
-           }
-         } // if HLT openfile
-       } // while iter list
-      } // if HLT size of tlist
-    } //if HLT tlist
-    delete filesourceshlt;
-  } //if run type physics
-  // time
-  timer.Stop();
-  timer.Print();
-
+           } // analyse
+         } // histo here
+       }
+       else{
+         Log("Error retrieving the file vdrift (DAQ)");
+         if(!fVdriftHLT) fResult |= kEGetFileDAQ;
+       }
+      }// if fileNameEntry
+    } // size DAQ list
+    else{
+      Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
+      if(!fVdriftHLT) fResult |= kEEmptyListDAQ;
+    }
+    delete listdaq; 
+  } 
+  else{
+    Log("No list found for vdrift (DAQ)");
+    if(!fVdriftHLT){
+      fResult |= kEGetFileDAQ;
+    }
+  }
+   
+}
+//______________________________________________________________________________________________
+void AliTRDPreprocessor::ExtractHLT()
+{
   //
-  // Process the calibration data for the DAQ part
+  // Gain, vdrift and PRF calibration running on HLT
+  // return kFALSE if NULL pointer to the list
   //
 
-  // How long does it take for the DAQ part?
-  timer.Reset();
-  timer.Start();
-  
-  // Take the file from the DAQ file exchange server
-  TList *filesourcesdaq = GetFileSources(kDAQ,"PADSTATUSVDRIFT");
-  if (!filesourcesdaq) {
-    Log(Form("No sources found for GAINDRIFTPRF for run %d !",fRun));
-    result |= kEListFileDAQ;
-  }
-  else{
-    if (filesourcesdaq->GetSize() != 1) {
-      Log(Form("More than one source found for PADSTATUSVDRIFT for run %d!",fRun));
-      filesourcesdaq->Print();
-      result |= kEListFileDAQ;
-    }
-    else{
-      // Loop over the files taken from the DAQ
-      TIter iter(filesourcesdaq);
-      TObjString *sourcedaq;
-      while ((sourcedaq = dynamic_cast<TObjString *> (iter.Next()))) {
-    
-       TString filenamedaq = GetFile(kDAQ,"PADSTATUSVDRIFT",sourcedaq->GetName());
-       if (filenamedaq.Length() == 0) {
-         Log(Form("Error retrieving file from source %d failed!", sourcedaq->GetName()));
-         result |= kEOpenFileDAQ;
-       }
-       else {
+  // Objects for HLT and DAQ zusammen
+  AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Raphaelle Bailhache");
+  metaData.SetComment("TRD calib test");
+  // Store the infos for the detector
+  AliCDBMetaData md1; 
+  md1.SetObjectClassName("AliTRDCalDet");
+  md1.SetResponsible("Raphaelle Bailhache");
+  md1.SetBeamPeriod(0);
+  md1.SetComment("TRD calib test");
+  // Store the infos for the pads
+  AliCDBMetaData md2; 
+  md2.SetObjectClassName("AliTRDCalPad");
+  md2.SetResponsible("Raphaelle Bailhache");
+  md2.SetBeamPeriod(0);
+  md2.SetComment("TRD calib test");
 
-         // Init some things
-         TProfile2D   *histodriftvelocity  = 0x0; // Profile taken from DAQ for drift velocity and time0
-         AliTRDCalibPadStatus *calibpadstatus = 0x0; // AliTRDCalibPadStatus from DAQ for pad status
+  
+  // Take the file from the HLT file exchange server
+  TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
+  if (listhlt) {
+    if (listhlt->GetSize() == 1) {
+      TObjString* fileNameEntry = (TObjString*) listhlt->At(0);
+      if(fileNameEntry != NULL){
+       TString fileName = GetFile(kHLT, "GAINDRIFTPRF",
+                                  fileNameEntry->GetString().Data());
+       if(fileName.Length() !=0){
+         // Take the file
+         TFile *filehlt = TFile::Open(fileName);
+         
          
-         // Take the histos
-         Bool_t something = kFALSE;
-         TFile *filedaq = TFile::Open(filenamedaq);
-         calibpadstatus = (AliTRDCalibPadStatus *) filedaq->Get("calibpadstatus");
-         if (!calibpadstatus) {
-           Log("No pedetral run!");
-         }
-         else something = kTRUE;
-         histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
-         if (!histodriftvelocity) {
-           Log("No Vdrift TProfile2D!");
-         }
-         else{
-           histodriftvelocity->SetDirectory(0);
-         }
-         if(histodriftvelocity) something = kTRUE;
-         if(!something){
-           Log("Error DAQ, nothing in the file!");
-           result |= kETakeObjectDAQ;
-         }
-                 
-         // try to fit and store reference data
-         if(calibpadstatus){
-           calibpadstatus->AnalyseHisto();
-           if(!StoreReferenceData("DAQData","PadStatus",(TObject *) calibpadstatus,&metaData)){
-             Log("Error storing AliTRDCalibPadStatus object as reference data");
-             result |= kEStoreRefDAQ;
+         // gain
+         TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
+         histogain->SetDirectory(0);
+         if (histogain) {
+           // store the reference data
+           if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
+             Log("Error storing 2D histos for gain");
+             fResult |= kEStore;
            }
-           AliTRDCalPadStatus *calPadStatus = calibpadstatus->CreateCalPadStatus();
-           AliCDBMetaData *md3= new AliCDBMetaData(); 
-           md3->SetObjectClassName("AliTRDCalPadStatus");
-           md3->SetResponsible("Raphaelle Bailhache");
-           md3->SetBeamPeriod(1);
-                   md3->SetComment("TRD calib test");
-           if(!Store("Calib","PadStatus"    ,(TObject *)calPadStatus, md3, 0, kTRUE)){
-             Log("Error storing the calibration object for the chamber vdrift");
-             result |= kEStoreCalDAQ;    
+           // analyse
+           Log("Take the CH reference data. Now we will try to fit\n");
+           calibra->SetMinEntries(1000); // If there is less than 1000 entries in the histo: no fit
+           calibra->AnalyseCH(histogain);
+           Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
+             + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
+           Int_t nbfit       = calibra->GetNumberFit();
+           Int_t nbE         = calibra->GetNumberEnt();
+           // enough statistics
+           if ((nbtg >                  0) && 
+               (nbfit        >= 0.95*nbE)) {
+             // create the cal objects
+             TObjArray object           = calibra->GetVectorFit();
+             AliTRDCalDet *objgaindet   = calibra->CreateDetObjectGain(&object,calibra->GetScaleFitFactor(),kTRUE);
+             TObject *objgainpad        = calibra->CreatePadObjectGain();
+             // store them
+             if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet         ,&md1,0,kTRUE)){
+               Log("Error storing the calibration object for the chamber gain");
+               fResult |= kEStore;
+             }
+             if(!Store("Calib","LocalGainFactor"  ,(TObject *) objgainpad         ,&md2,0,kTRUE)){
+               Log("Error storing the calibration object for the local gain factor");
+               fResult |= kEStore;
+             }
            }
-         }
+           calibra->ResetVectorFit();
+         }// if histogain
+         
+         
+         
+         // vdrift
+         fVdriftHLT = kFALSE;
+         TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
+         histodriftvelocity->SetDirectory(0);
          if (histodriftvelocity) {
-           if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
-             Log("Error storing 2D Profile for average pulse height as reference data");
-             result |= kEStoreRefDAQ;
+           // store the reference data
+           if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
+             Log("Error storing 2D Profile for average pulse height (HLT)");
+             fResult |= kEStore;
            }
-           if(!hltVdrifthisto){
-             Log("Take the PH reference data. Now we will try to fit\n");
-             calibra->SetMinEntries(100*20); // If there is less than 2000
-             calibra->AnalysePH(histodriftvelocity);
-             Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
-               + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
-             Int_t nbfit        = calibra->GetNumberFit();
-             Int_t nbE        = calibra->GetNumberEnt();
-             if ((nbtg >                  0) && 
-                 (nbfit        >= 0.95*nbE)) {
-               TObjArray object      = calibra->GetVectorFit();
-               AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
-               TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
-               object              = calibra->GetVectorFit2();
-               AliTRDCalDet *objtime0det         = calibra->CreateDetObjectT0(&object,kTRUE);
-               TObject *objtime0pad         = calibra->CreatePadObjectT0();
-               calibra->ResetVectorFit();
-               if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,md1,0,kTRUE)){
-                 Log("Error storing the calibration object for the chamber vdrift");
-                 result |= kEStoreCalDAQ;    
-               }
-               if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,md1,0,kTRUE)){
-                 Log("Error storing the calibration object for the chamber t0");
-                 result |= kEStoreCalDAQ;    
-               }
-               if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the local drift velocity");
-                 result |= kEStoreCalDAQ;
-               }
-               if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,md2,0,kTRUE)){
-                 Log("Error storing the calibration object for the local time0");
-                 result |= kEStoreCalDAQ;
-               }
+           // analyse
+           Log("Take the PH reference data. Now we will try to fit\n");
+           calibra->SetMinEntries(1000*20); // If there is less than 20000
+           calibra->AnalysePH(histodriftvelocity);
+           Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
+             + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
+           Int_t nbfit        = calibra->GetNumberFit();
+           Int_t nbE          = calibra->GetNumberEnt();
+           // enough statistics
+           if ((nbtg >                  0) && 
+               (nbfit        >= 0.95*nbE)) {
+             // create the cal objects
+             TObjArray object  = calibra->GetVectorFit();
+             AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
+             TObject *objdriftvelocitypad      = calibra->CreatePadObjectVdrift();
+             object              = calibra->GetVectorFit2();
+             AliTRDCalDet *objtime0det  = calibra->CreateDetObjectT0(&object,kTRUE);
+             TObject *objtime0pad       = calibra->CreatePadObjectT0();
+             // store them
+             if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
+               Log("Error storing the calibration object for the chamber vdrift (HLT)");
+               fResult |= kEStore;    
              }
-             else{
-               Log("Not enough statistics for the average pulse height");
-               result |= kEFitObjectDAQ;
+             if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,&md1,0,kTRUE)){
+               Log("Error storing the calibration object for the chamber t0 (HLT)");
+               fResult |= kEStore;    
              }
+             if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
+               Log("Error storing the calibration object for the local drift velocity (HLT)");
+               fResult |= kEStore;
+             }
+             if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,&md2,0,kTRUE)){
+               Log("Error storing the calibration object for the local time0 (HLT)");
+               fResult |= kEStore;
+             }
+             fVdriftHLT = kTRUE;
            }
-         }
-         filedaq->Close();
-       }// if DAQ open file
-      } // while iter DAQ list
-    } // size DAQ list
-  } // tlist
-  delete filesourcesdaq;
-  // time
-  timer.Stop();
-  timer.Print();
+           calibra->ResetVectorFit();
+         }// if TProfile2D
+         
+         
+         // prf
+         TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
+         histoprf->SetDirectory(0);
+         if (histoprf) {
+           // store reference data
+           if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
+             Log("Error storing the 2D Profile for Pad Response Function");
+             fResult |= kEStore;
+           }
+           // analyse
+           Log("Take the PRF reference data. Now we will try to fit\n");
+           calibra->SetMinEntries(600); // If there is less than 20000
+           calibra->AnalysePRFMarianFit(histoprf);
+           Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
+             + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
+           Int_t nbfit        = calibra->GetNumberFit();
+           Int_t nbE          = calibra->GetNumberEnt();
+           // enough statistics
+           if ((nbtg >                  0) && 
+               (nbfit        >= 0.95*nbE)) {
+             // create cal pad objects 
+             TObjArray object            = calibra->GetVectorFit();
+             TObject *objPRFpad          = calibra->CreatePadObjectPRF(&object);
+             // store them
+             if(!Store("Calib","PRFWidth"         ,(TObject *) objPRFpad          ,&md2,0,kTRUE)){
+               Log("Error storing the calibration object for the Pad Response Function");
+               fResult |= kEStore;
+             }
+           }
+           calibra->ResetVectorFit();
+         }// if PRF
+       }
+       else{
+         Log("Error retrieving the file (HLT)");
+         fResult |= kEGetFileHLT;
+       } 
+      } // fileNameEntry
+    } // if HLT size of tlist
+    else{
+      Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
+      fResult |= kEEmptyListHLT;
+    }
+    delete listhlt;
+  } //if HLT tlist
+  else{
+    Log("No list found for the HLT");
+    fResult |= kEGetFileHLT;
+  }
   
-  return result;  
-
 }
index 703559f..71c6ec5 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "AliPreprocessor.h"
 
+class TMap;
+
 class AliTRDPreprocessor : public AliPreprocessor
 {
 
@@ -23,23 +25,12 @@ class AliTRDPreprocessor : public AliPreprocessor
     virtual ~AliTRDPreprocessor();
 
     enum {
-       kEExtractDCS    =   1   // error in case of failure by extracting DCS variables
-      ,kEStoreRefDCS   =   2   // error in case of failure by storing DCS variables references
-      ,kEFitDCS        =   4   // error in case of failure by fitting DCS variables
-      ,kEStoreDCS      =   8   // error in case of failure by storing DCS variables fit results
-      ,kEListFileHLT   =  16   // error in case of failure by taking the listof HLT files
-      ,kEOpenFileHLT   =  32   // error in case of failure by opening the HLTfile
-      ,kETakeHistoHLT  =  64   // error in case of failure by taking the histos HLT
-      ,kEStoreHistoHLT = 128   // error in case of failure by storing the reference data HLT
-      ,kEFitHistoHLT   = 256   // error in case of failure by fitting the histos HLT
-      ,kEStoreCalHLT   = 512   // error in case of failure by storing the HLTcal objects
-      ,kEListFileDAQ   = 1024  // error in case of failure by taking the list of DAQ files 
-      ,kEOpenFileDAQ   = 2048  // error in case of failure by opening the DAQfile
-      ,kETakeObjectDAQ = 4096  // error in case of failure by taking the objects DAQ
-      ,kEStoreRefDAQ   = 8192  // error in case of failure by storing the reference data DAQ
-      ,kEFitObjectDAQ  = 16384 // error in case of failure by fitting the DAQ objects
-      ,kEStoreCalDAQ   = 32768 // error in case of failure by storing the DAQcal objects   
-
+      kEExtractDCS    =   1   // error in case of failure by extracting DCS variables
+      ,kEStore        =   2   // Store or StoreReferenceData
+      ,kEGetFileHLT   =   4   // GetFileSources and GetFile HLT
+      ,kEEmptyListHLT =   8   // Empty list HLT
+      ,kEGetFileDAQ   =  16   // GetFileSources and GetFile DAQ
+      ,kEEmptyListDAQ =  32   // Empty list DAQ
     };
 
   protected:
@@ -47,8 +38,17 @@ class AliTRDPreprocessor : public AliPreprocessor
     virtual void   Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
     virtual UInt_t Process(TMap* dcsAliasMap);
 
+
+    void    ExtractPedestals();
+    void    ExtractDriftVelocityDAQ();
+    void    ExtractHLT();
+    void    ProcessDCS(TMap*dcsAliasMap);
+
   private:
     
+
+    UInt_t  fResult;                // result preprocessor
+    Bool_t  fVdriftHLT;             // HLT Vdrift
     ClassDef(AliTRDPreprocessor,1) // The SHUTTLE preprocessor for TRD
 
 };
index ef70975..677faeb 100644 (file)
@@ -53,7 +53,7 @@ void AliTRDCheckPreprocessorold()
   //Test reference data gain HLT
   //***************************
   Int_t ErrorRefDataGainHLT = 0;
-  AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/Gain", 12);  
+  AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/Gain", 8);  
   if(!entry) ErrorRefDataGainHLT = 1;
   else{
     TH2I *histogainhlt = (TH2I *) entry->GetObject();
@@ -72,7 +72,7 @@ void AliTRDCheckPreprocessorold()
   //***************************
   Int_t ErrorRefDataVdriftT0HLT = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/VdriftT0", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/VdriftT0", 8);
   if(!entry) ErrorRefDataVdriftT0HLT = 1;
   else{
     TProfile2D *histovdriftt0hlt = (TProfile2D *) entry->GetObject();
@@ -91,7 +91,7 @@ void AliTRDCheckPreprocessorold()
   //***************************
   Int_t ErrorRefDataPRFHLT = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/PRF", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/HLTData/PRF", 8);
   if(!entry) ErrorRefDataPRFHLT = 1;
   else{
     TProfile2D *histoprfhlt = (TProfile2D *) entry->GetObject();
@@ -109,72 +109,86 @@ void AliTRDCheckPreprocessorold()
   //Test reference data PadStatus DAQ
   //***************************
   Int_t ErrorRefDataPadStatus = 0;
-  if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/DAQData/PadStatus", 12);
-  if(!entry) ErrorRefDataPadStatus = 1;
-  else{
-    AliTRDCalibPadStatus *calpadstatus = (AliTRDCalibPadStatus *) entry->GetObject();
-    if(!calpadstatus) ErrorRefDataPadStatus = 2;
-    else{
-      //Make the AliTRDCalDet correspondant
-      AliTRDCalDet *calDet = new AliTRDCalDet("dummy","dummy for mean");
-      for(Int_t k = 0; k < 540; k++){
-       calDet->SetValue(k,10.0);
-      }
 
-      //Make the AliTRDCalPad correspondant
-      AliTRDCalPad *calPad1 = new AliTRDCalPad("meanpad","dummy for mean");
-      AliTRDCalPad *calPad2 = new AliTRDCalPad("squarespad","dummy for squares");
-      AliTRDCalROC *calROC1 = 0x0;
-      AliTRDCalROC *calROC2 = 0x0;
-      for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det)
-    {
-      AliTRDCalROC *calROC11 = calPad1->GetCalROC(det);
-      AliTRDCalROC *calROC22 = calPad2->GetCalROC(det);
-      calROC1                = calpadstatus->GetCalRocMean(det,kTRUE);
-      calROC2                = calpadstatus->GetCalRocRMS(det,kTRUE);
-      for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
-       calROC11->SetValue(k,calROC1->GetValue(k));
-       calROC22->SetValue(k,calROC2->GetValue(k));
+  Int_t nbsm = 0;
+  
+  for(Int_t k = 0; k < 18; k++){
+
+    TString padstatus("TRD/DAQData/PadStatus");
+    padstatus += k;
+    
+    if(entry) delete entry;
+    entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get((const char*)padstatus, 8);
+    if(entry){
+      AliTRDCalibPadStatus *calpadstatus = (AliTRDCalibPadStatus *) entry->GetObject();
+      if(!calpadstatus) ErrorRefDataPadStatus = 2;
+      else{
+       //Make the AliTRDCalDet correspondant
+       AliTRDCalDet calDet = AliTRDCalDet("dummy","dummy for mean");
+       for(Int_t l = 0; l < 540; l++){
+         calDet.SetValue(l,10.0);
+       }
+       
+       //Make the AliTRDCalPad correspondant
+       AliTRDCalPad calPad1 = AliTRDCalPad("meanpad","dummy for mean");
+       AliTRDCalPad calPad2 = AliTRDCalPad("squarespad","dummy for squares");
+       AliTRDCalROC *calROC1 = 0x0;
+       AliTRDCalROC *calROC2 = 0x0;
+       for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det)
+         {
+           AliTRDCalROC *calROC11 = calPad1.GetCalROC(det);
+           AliTRDCalROC *calROC22 = calPad2.GetCalROC(det);
+           calROC1                = calpadstatus->GetCalRocMean(det,kTRUE);
+           calROC2                = calpadstatus->GetCalRocRMS(det,kTRUE);
+           for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
+             calROC11->SetValue(k,calROC1->GetValue(k));
+             calROC22->SetValue(k,calROC2->GetValue(k));
+           }
+         }
+       TCanvas *cpadstatusm = new TCanvas((const char*)padstatus,(const char*)padstatus,50,50,600,800);
+       cpadstatusm->Divide(3,2);
+       cpadstatusm->cd(1);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,0,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       cpadstatusm->cd(2);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,1,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       cpadstatusm->cd(3);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,2,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       cpadstatusm->cd(4);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,3,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       cpadstatusm->cd(5);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,4,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       cpadstatusm->cd(6);
+       ((TH2F *)calPad1.MakeHisto2DSmPl(k,5,&calDet,0,9.0,11.0,-1))->Draw("colz");
+       
+       padstatus += 1982;
+
+       TCanvas *cpadstatusrms = new TCanvas((const char*)padstatus,(const char*)padstatus,50,50,600,800);
+       cpadstatusrms->Divide(3,2);
+       cpadstatusrms->cd(1);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,0,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       cpadstatusrms->cd(2);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,1,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       cpadstatusrms->cd(3);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,2,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       cpadstatusrms->cd(4);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,3,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       cpadstatusrms->cd(5);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,4,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       cpadstatusrms->cd(6);
+       ((TH2F *)calPad2.MakeHisto2DSmPl(k,5,&calDet,0,0.2,2.0,-1))->Draw("colz");
+       nbsm++;
       }
     }
-      TCanvas *cpadstatusm = new TCanvas("cpadstatusm","cpadstatusm",50,50,600,800);
-      cpadstatusm->Divide(3,2);
-      cpadstatusm->cd(1);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,0,calDet,0,9.0,11.0,-1))->Draw("colz");
-      cpadstatusm->cd(2);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,1,calDet,0,9.0,11.0,-1))->Draw("colz");
-      cpadstatusm->cd(3);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,2,calDet,0,9.0,11.0,-1))->Draw("colz");
-      cpadstatusm->cd(4);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,3,calDet,0,9.0,11.0,-1))->Draw("colz");
-      cpadstatusm->cd(5);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,4,calDet,0,9.0,11.0,-1))->Draw("colz");
-      cpadstatusm->cd(6);
-      ((TH2F *)calPad1->MakeHisto2DSmPl(1,5,calDet,0,9.0,11.0,-1))->Draw("colz");
-
-      TCanvas *cpadstatusrms = new TCanvas("cpadstatusrrms","cpadstatusrms",50,50,600,800);
-      cpadstatusrms->Divide(3,2);
-      cpadstatusrms->cd(1);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,0,calDet,0,0.2,2.0,-1))->Draw("colz");
-      cpadstatusrms->cd(2);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,1,calDet,0,0.2,2.0,-1))->Draw("colz");
-      cpadstatusrms->cd(3);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,2,calDet,0,0.2,2.0,-1))->Draw("colz");
-      cpadstatusrms->cd(4);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,3,calDet,0,0.2,2.0,-1))->Draw("colz");
-      cpadstatusrms->cd(5);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,4,calDet,0,0.2,2.0,-1))->Draw("colz");
-      cpadstatusrms->cd(6);
-      ((TH2F *)calPad2->MakeHisto2DSmPl(1,5,calDet,0,0.2,2.0,-1))->Draw("colz");
-    }
   }
+  printf("there is %d with Padstatus reference entries\n",nbsm);
+  if(nbsm==0) ErrorRefDataPadStatus = 1;
+
 
   //Test reference data vdriftt0 DAQ
   //***************************
   Int_t ErrorRefDataVdriftT0DAQ = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/DAQData/VdriftT0", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainRefStorage())->Get("TRD/DAQData/VdriftT0", 8);
   if(!entry) ErrorRefDataVdriftT0DAQ = 1;
   else{
     TProfile2D *histovdriftt0daq = (TProfile2D *) entry->GetObject();
@@ -199,7 +213,7 @@ void AliTRDCheckPreprocessorold()
   AliTRDCalPad *calPad = 0x0;
   Int_t ErrorGainPad = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalGainFactor", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalGainFactor", 8);
   if(!entry) ErrorGainPad++;
   else{
     calPad = (AliTRDCalPad *) entry->GetObject();
@@ -219,7 +233,7 @@ void AliTRDCheckPreprocessorold()
   Int_t ErrorVdriftPad = 0;
   if(entry) delete entry;
   if(calPad) delete calPad;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalVdrift", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalVdrift", 8);
   if(!entry) ErrorVdriftPad++;
   else{
     calPad = (AliTRDCalPad *) entry->GetObject();
@@ -239,7 +253,7 @@ void AliTRDCheckPreprocessorold()
   Int_t ErrorT0Pad = 0;
   if(entry) delete entry;
   if(calPad) delete calPad;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalT0", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/LocalT0", 8);
   if(!entry) ErrorT0Pad++;
   else{
     calPad = (AliTRDCalPad *) entry->GetObject();
@@ -259,7 +273,7 @@ void AliTRDCheckPreprocessorold()
   //********
   Int_t ErrorPRFWidthPad = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PRFWidth", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PRFWidth", 8);
   if(!entry) ErrorPRFWidthPad++;
   else{
     AliTRDCalPad *calPadPrf = (AliTRDCalPad *) entry->GetObject();
@@ -297,27 +311,34 @@ void AliTRDCheckPreprocessorold()
   //Padstatus
   //********
   Int_t ErrorPadStatusPad = 0;
+    
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PadStatus", 12);
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/PadStatus", 8);
   if(!entry) ErrorPadStatusPad++;
   else{
     AliTRDCalPadStatus *calPadStatus = (AliTRDCalPadStatus *) entry->GetObject();
     if(!calPadStatus) ErrorPadStatusPad++;
     else{
-      TCanvas *cpadstatus = new TCanvas("cpadstatus","cpadstatus",50,50,600,800);
-      cpadstatus->Divide(3,2);
-      cpadstatus->cd(1);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,0))->Draw("colz");
-      cpadstatus->cd(2);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,1))->Draw("colz");
-      cpadstatus->cd(3);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,2))->Draw("colz");
-      cpadstatus->cd(4);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,3))->Draw("colz");
-      cpadstatus->cd(5);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,4))->Draw("colz");
-      cpadstatus->cd(6);
-      ((TH2F *)calPadStatus->MakeHisto2DSmPl(1,5))->Draw("colz");
+      for(Int_t k = 0; k < 18; k++){
+       
+       TString padstatus("PadStatus");
+       padstatus += k;
+
+       TCanvas *cpadstatus = new TCanvas((const char*)padstatus,(const char*)padstatus,50,50,600,800);
+       cpadstatus->Divide(3,2);
+       cpadstatus->cd(1);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,0))->Draw("colz");
+       cpadstatus->cd(2);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,1))->Draw("colz");
+       cpadstatus->cd(3);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,2))->Draw("colz");
+       cpadstatus->cd(4);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,3))->Draw("colz");
+       cpadstatus->cd(5);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,4))->Draw("colz");
+       cpadstatus->cd(6);
+       ((TH2F *)calPadStatus->MakeHisto2DSmPl(k,5))->Draw("colz");
+      }
     }
   }
 
@@ -328,7 +349,7 @@ void AliTRDCheckPreprocessorold()
   //******
   Int_t ErrorGainDetector = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberGainFactor", 12);  
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberGainFactor", 8);  
   if(!entry) ErrorGainDetector++;
   else{
     AliTRDCalDet *objectg = (AliTRDCalDet *) entry->GetObject();
@@ -348,7 +369,7 @@ void AliTRDCheckPreprocessorold()
   //******
   Int_t ErrorVdriftDetector = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberVdrift", 12);  
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberVdrift", 8);  
   if(!entry) ErrorVdriftDetector++;
   else{
     AliTRDCalDet *objectv = (AliTRDCalDet *) entry->GetObject();
@@ -368,7 +389,7 @@ void AliTRDCheckPreprocessorold()
   //******
   Int_t ErrorT0Detector = 0;
   if(entry) delete entry;
-  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberT0", 12);  
+  entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TRD/Calib/ChamberT0", 8);  
   if(!entry) ErrorT0Detector++;
   else{
     AliTRDCalDet *objectt = (AliTRDCalDet *) entry->GetObject();
diff --git a/TRD/TRDPEDESTALda.cxx b/TRD/TRDPEDESTALda.cxx
new file mode 100644 (file)
index 0000000..b869bac
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+
+TRDPEDESTALda.cxx - calibration algorithm for the pedestal to be run in parallel on the LDCs
+DAcase1.c
+
+
+AliTRDCalibPadStatus - pad status calibration
+
+This program reads the DAQ data files passed as argument using the monitoring library.
+
+It fills a TRD calib object AliTRDCalibPadStatus and write it in a local file trdPedestal.root before
+exporting it to the file exchange server.
+
+Messages on stdout are exported to DAQ log system.
+
+contact: alice-datesupport@cern.ch
+
+*/
+
+#define RESULT_FILE "trdCalibration.root"
+
+extern "C" {
+#include <daqDA.h>
+}
+
+#include "event.h"
+#include "monitor.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+//
+// Root includes
+//
+#include <TFile.h>
+#include <TStopwatch.h>
+
+//
+// AliRoot includes
+//
+#include "AliRawReader.h"
+#include "AliRawReaderDate.h"
+#include "AliTRDRawStream.h"
+#include "AliCDBManager.h"
+//
+// AliRoot TRD calib classes
+//
+#include "AliTRDCalibPadStatus.h"
+
+
+/* Main routine
+      Arguments: list of DATE raw data files
+*/
+int main(int argc, char **argv) {
+
+  int status;
+
+
+  /* log start of process */
+  printf("TRD DA PEDESTAL started\n");  
+
+
+  /* check that we got some arguments = list of files */
+  if (argc<2) {
+    printf("Wrong number of arguments\n");
+    return -1;
+  }
+
+
+  /* copy locally a file from daq detector config db */
+  //status=daqDA_DB_getFile("myconfig","./myconfig.txt");
+  //if (status) {
+  //  printf("Failed to get config file : %d\n",status);
+  //  return -1;
+  //}
+  /* and possibly use it */
+  
+
+  /* init some counters */
+  int nevents_total=0;
+  int nevents      =0;
+  //Instance of AliCDBManager: needed by AliTRDRawStream
+  AliCDBManager *man = AliCDBManager::Instance();
+  man->SetDefaultStorage("local://$ALICE_ROOT");
+  man->SetRun(0);
+  // AliTRDCalibPadStatus object
+  AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus();
+  Bool_t passpadstatus = kTRUE;
+
+
+  /*see the time*/
+  TStopwatch timer;
+  timer.Start();
+
+
+  /* read the data files */
+  int n;
+  for (n=1;n<argc;n++) {
+   
+    /* define data source : this is argument i */
+    printf("Processing file %s\n",argv[n]);
+    status=monitorSetDataSource( argv[n] );
+    if (status!=0) {
+      printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+      return -1;
+    }
+
+    /* read the file  until EOF */
+    for(;;) {
+      struct eventHeaderStruct *event;
+      
+      /* get next event */
+      status=monitorGetEventDynamic((void **)&event);
+      if (status==MON_ERR_EOF) {
+       printf("End of File %d detected\n",n);
+       break; /* end of monitoring file has been reached */
+      }
+      if (status!=0) {
+        printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+        break;
+      }
+
+      /* retry if got no event */
+      if (event==NULL) {
+        break;
+      }
+
+      if(passpadstatus){
+
+       AliRawReader *rawReader = new AliRawReaderDate((void*)event);
+       AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *)rawReader);
+       if(!calipad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE;
+       nevents++;
+       delete trdRawStream;
+       delete rawReader;
+     
+      }
+
+      nevents_total++;
+
+      /* free resources */
+      free(event);
+    }
+  }
+
+
+  /* report progress */
+  printf("%d events processed and %d used\n",nevents_total,nevents);
+
+  /*see the time*/
+  timer.Stop();
+  timer.Print();
+
+  /* write file in any case to see what happens in case of problems*/
+  TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
+  calipad.Write("calibpadstatus");
+  fileTRD->Close();   
+  printf("Wrote local file %s\n",RESULT_FILE);
+  
+  /* store the result file on FES */
+  status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);
+  if (status) {
+    printf("Failed to export file : %d\n",status);
+    return -1;
+  }
+  
+   
+  /* report progress */
+  daqDA_progressReport(100);
+
+  
+  return status;
+}
similarity index 71%
rename from TRD/TRDda.cxx
rename to TRD/TRDVDRIFTda.cxx
index 7d5f8db..985ad0f 100644 (file)
@@ -21,6 +21,9 @@ contact: alice-datesupport@cern.ch
 
 */
 
+#define RESULT_FILE "trdCalibrationv.root"
+
+
 extern "C" {
 #include <daqDA.h>
 }
@@ -52,7 +55,6 @@ extern "C" {
 //
 // TRD calibration algorithm includes
 //
-#include "AliTRDCalibPadStatus.h"
 #include "AliTRDCalibraFillHisto.h"
 
 
@@ -94,7 +96,7 @@ int main(int argc, char **argv) {
   
 
   /* log start of process */
-  printf("DA example case2 monitoring program started\n");  
+  printf("TRD DA VDRIFT started\n");  
 
 
   /* init some counters */
@@ -107,10 +109,6 @@ int main(int argc, char **argv) {
   man->SetRun(0);
   //Instance of AliTRDCalibraFillHisto
   AliTRDCalibraFillHisto *calibra      = AliTRDCalibraFillHisto::Instance();
-  //AliTRDCalibPadStatus
-  AliTRDCalibPadStatus      calibpad   = AliTRDCalibPadStatus();
-  // pad status on: no zero suppression (special runs)
-  Bool_t passpadstatus = kTRUE;
   // everythings are okey for vdrift
   Bool_t passvdrift  = kTRUE;    // if timebin okey
   Int_t  nbvdrift    = 0;     // number of events with entries for vdrift
@@ -121,7 +119,7 @@ int main(int argc, char **argv) {
   //for(Int_t k = 0; k < 20; k++) {
     struct eventHeaderStruct *event;
     eventTypeType eventT;
-  
+
     /* check shutdown condition */
     if (daqDA_checkShutdown()) {break;}
     
@@ -142,29 +140,17 @@ int main(int argc, char **argv) {
       continue;
     }
 
-    printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);  
+    if( ((Int_t)nevents_total)%100 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);  
 
 
     /* use event - here, just write event id to result file */
     eventT=event->eventType;
-    //
-    // pad status calibration: we try a first time to see if zero suppressed or not
-    //
-    if(passpadstatus){
-      printf("pad status calibration\n");
-      AliRawReader *rawReader = new AliRawReaderDate((void*)event);
-      AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
-      if(!calibpad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE;
-      
-      delete trdRawStream;
-      delete rawReader;
-    }
+    
     //
     // vdrift calibration: run only for physics events
     //
-    if ((eventT==PHYSICS_EVENT) && (!passpadstatus)  && (passvdrift)) {
+    if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
       //if (eventT==PHYSICS_EVENT) {
-      printf("vdrift calibration\n");
       AliRawReader *rawReader = new AliRawReaderDate((void*)event);
       AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
       Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
@@ -195,38 +181,27 @@ int main(int argc, char **argv) {
     }
   }
 
+
+  /* report progress */
+  printf("%d events processed and %d used\n",nevents_total,nbvdrift);
+  
   //
   // Write a local file and put it on the FX 
   //
-  TFile  *fileTRD     = new TFile("trdCalibration.root","recreate");
-  Bool_t passwrite   = kFALSE;
-  //
-  // pad status
-  //
-  if(passpadstatus){
-    // We do this at the shuttle maybe!
-    //calibpad.AnalyseHisto();
-    //AliTRDCalPadStatus *calPadStatus = calibpad.CreateCalPadStatus();
-    calibpad.Write("calibpadstatus");
-    passwrite  = kTRUE; 
-  }
-  //
-  // vdrift
-  //
+  TFile  *fileTRD     = new TFile(RESULT_FILE,"recreate");
   if((nbvdrift > 0) && passvdrift){
-    Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
-    // write only of enough statistics
-    if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
-      calibra->GetPH2d()->Write();
-      passwrite = kTRUE;
-    }
-    
+    //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
+    //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
+    // write the histogram in any case to see if problems
+    calibra->GetPH2d()->Write();
+    //}
   }
   fileTRD->Close();
   status=0;
-  if(passwrite) {
-    if(daqDA_FES_storeFile("trdCalibration.root","trdCalibration.root")) status = -2;
-  }
+  // Export the file in any case to see if problems
+  if(daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE)) status = -2;
+  
   delete fileTRD;  
 
   return status;