#include <Riostream.h>
#include <sstream>
-//
-//AMORE
-//
-#ifdef ALI_AMORE
-#include <AmoreDA.h>
-#include "TSystem.h"
-#endif
#define NFITPARAMS 4
+ Finalize();
+ MakeControlHistos();
if(fPrintLevel>0)
{
// compute and store mean DAC values (like pedestals)
sprintf(flatFile,"%s.ped",fprefixDA);
outputFile=flatFile;
cout << "\n" << fprefixDA << " : Flat file generated : " << flatFile << "\n";
- MakePedStore(outputFile);
+ if (!outputFile.IsNull())
+ {
+ ofstream out(outputFile.Data());
+ MakeASCIIoutput(out);
+ out.close();
+ }
}
- else
- MakePedStore("");
TString mode("UPDATE");
}
-
-
- // Write Ascii file -> Shuttle
+ // file outputs for gain
ofstream pfilew;
pfilew.open(shuttleFile.Data());
+ // Write Header Data of the .par file
pfilew << WriteGainHeader(fnInit,nEntries,nbpf2,numrun,injCharge);
-#ifdef ALI_AMORE
- ostringstream stringout; // String to be sent to AMORE_DB
- stringout << WriteGainHeader(fnInit,nEntries,nbpf2,numrun,injCharge);
-#endif
// print mean and sigma values in file
FILE *pfilep = 0;
}
- tempstring = WriteGainData(busPatchId,manuId,channelId,par[1],par[2],threshold,q);
- pfilew << tempstring;
-#ifdef ALI_AMORE
- stringout << tempstring;
-#endif
-
+ pfilew << WriteGainData(busPatchId,manuId,channelId,par[1],par[2],threshold,q);
}
nmanu++;
if(nmanu % 500 == 0)std::cout << " Nb manu = " << nmanu << std::endl;
<< " mV/fC (capa= " << capaManu << " pF)"
<< " Prob(chi2)> = " << meanProbChi2 << endl;
- // file outputs for gain
-
pfilew.close();
-#ifdef ALI_AMORE
- //
- //Send objects to the AMORE DB
- //
- const char *role=gSystem->Getenv("AMORE_DA_NAME");
- if ( role ){
- amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
-// TObjString peddata(stringout.str().c_str());
- TObjString gaindata(stringout.str().c_str());
- Int_t status =0;
- status = amoreDA.Send("Pedestals",&gaindata);
- if ( status )
- cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl;
- }
- else {
- cout << "Warning: environment variable 'AMORE_DA_NAME' not set. Cannot write to the AMORE database" << endl;
- }
-#endif
if(fPlotLevel>0){tg->Write();histoFile->Close();}
if(fPrintLevel>1){fclose(pfilep); fclose(pfilen);}
#include <Riostream.h>
#include <sstream>
-//
-//AMORE
-//
-#ifdef ALI_AMORE
-#include <AmoreDA.h>
-#include "TSystem.h"
-#endif
//-----------------------------------------------------------------------------
/// \class AliMUONPedestal
AliMUONPedestal::~AliMUONPedestal()
{
/// Destructor
+ delete fPedestalStore;
}
//______________________________________________________________________________
}
//______________________________________________________________________________
-TString AliMUONPedestal::WritePedHeader(void)
+void AliMUONPedestal::Finalize()
{
-///
-
- ostringstream stream;
- stream<<"//===========================================================================" << endl;
- stream<<"// Pedestal file calculated by MUONTRKda"<<endl;
- stream<<"//===========================================================================" << endl;
- stream<<"// * Run : " << fRunNumber << endl;
- stream<<"// * Date : " << fDate->AsString("l") <<endl;
- stream<<"// * Statictics : " << fNEvents << endl;
- stream<<"// * # of MANUS : " << fNManu << endl;
- stream<<"// * # of channels : " << fNChannel << endl;
- if (fErrorBuspatchTable->GetSize())
- {
- stream<<"//"<<endl;
- stream<<"// * Buspatches with less statistics (due to parity errors)"<<endl;
- TIterator* iter = fErrorBuspatchTable->MakeIterator();
- AliMUONErrorCounter* parityerror;
- while((parityerror = (AliMUONErrorCounter*) iter->Next()))
- {
- stream<<"// bp "<<parityerror->BusPatch()<<" events used "<<fNEvents-parityerror->Events()<<endl;
- }
- }
- stream<<"//"<<endl;
- stream<<"//---------------------------------------------------------------------------" << endl;
- stream<<"//---------------------------------------------------------------------------" << endl;
- stream<<"// BP MANU CH. MEAN SIGMA"<<endl;
- stream<<"//---------------------------------------------------------------------------" << endl;
-
- return TString(stream.str().c_str());
-}
-
-//______________________________________________________________________________
-TString AliMUONPedestal::WritePedData(Int_t BP, Int_t Manu, Int_t ch, Double_t pedMean, Double_t pedSigma)
-{
-///
-
- ostringstream stream("");
- stream << "\t" << BP << "\t" << Manu <<"\t"<< ch << "\t"
- << pedMean <<"\t"<< pedSigma << endl;
- return TString(stream.str().c_str());
-
-}
-
-//______________________________________________________________________________
-void AliMUONPedestal::MakePedStore(TString shuttleFile_1 = "")
-{
-
- /// Store pedestals in ASCII files
Double_t pedMean;
Double_t pedSigma;
- ofstream fileout;
-#ifdef ALI_AMORE
- ostringstream stringout; // String to be sent to AMORE_DB
-#endif
- TString tempstring;
Int_t busPatchId;
Int_t manuId;
Int_t channelId;
-// histo
- TFile* histoFile = 0;
- TTree* tree = 0;
- TH1F* pedMeanHisto = 0;
- TH1F* pedSigmaHisto = 0;
-
- if (fIndex<0) // Pedestal run (fIndex=-1)
- {
- sprintf(fHistoFileName,"%s.root",fprefixDA);
- histoFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking pedestals");
-
- Char_t name[255];
- Char_t title[255];
- sprintf(name,"pedmean_allch");
- sprintf(title,"Pedestal mean all channels");
- Int_t nx = kADCMax+1;
- Int_t xmin = 0;
- Int_t xmax = kADCMax;
- pedMeanHisto = new TH1F(name,title,nx,xmin,xmax);
- pedMeanHisto->SetDirectory(histoFile);
-
- sprintf(name,"pedsigma_allch");
- sprintf(title,"Pedestal sigma all channels");
- nx = 201;
- xmin = 0;
- xmax = 200;
- pedSigmaHisto = new TH1F(name,title,nx,xmin,xmax);
- pedSigmaHisto->SetDirectory(histoFile);
-
- tree = new TTree("t","Pedestal tree");
- tree->Branch("bp",&busPatchId,"bp/I");
- tree->Branch("manu",&manuId,",manu/I");
- tree->Branch("channel",&channelId,",channel/I");
- tree->Branch("pedMean",&pedMean,",pedMean/D");
- tree->Branch("pedSigma",&pedSigma,",pedSigma/D");
- }
-
- if (!shuttleFile_1.IsNull()) {
- fileout.open(shuttleFile_1.Data());
- tempstring = WritePedHeader();
- fileout << tempstring;
-#ifdef ALI_AMORE
- stringout << tempstring;
-#endif
- }
// print in logfile
if (fErrorBuspatchTable->GetSize())
{
}
-
// iterator over pedestal
TIter next(fPedestalStore ->CreateIterator());
AliMUONVCalibParam* ped;
manuCounter = (AliMUONErrorCounter*)fManuBuspatchTable->FindObject(bpmanuname);
occupancy = manuCounter->Events()/64/eventCounter;
if(occupancy>1)
- {
+ {
cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
(*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
- }
+ }
- for (channelId = 0; channelId < ped->Size() ; ++channelId) {
+ for (channelId = 0; channelId < ped->Size() ; ++channelId)
+ {
pedMean = ped->ValueAsDouble(channelId, 0);
if (pedMean > 0) // connected channels
- {
+ {
ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter);
pedMean = ped->ValueAsDouble(channelId, 0);
pedSigma = ped->ValueAsDouble(channelId, 1);
ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
if(manuId == 0 || occupancy>1)
- {
+ {
ped->SetValueAsDouble(channelId, 0, kADCMax);
ped->SetValueAsDouble(channelId, 1, kADCMax);
- }
- }
+ }
+ }
else
- {
+ {
ped->SetValueAsDouble(channelId, 0, kADCMax);
ped->SetValueAsDouble(channelId, 1, kADCMax);
- }
+ }
+ }
+ }
+}
- pedMean = ped->ValueAsDouble(channelId, 0);
- pedSigma = ped->ValueAsDouble(channelId, 1);
+//______________________________________________________________________________
+void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
+{
+/// put pedestal store in the output stream
+
+ out<<"//===========================================================================" << endl;
+ out<<"// Pedestal file calculated by MUONTRKda"<<endl;
+ out<<"//===========================================================================" << endl;
+ out<<"// * Run : " << fRunNumber << endl;
+ out<<"// * Date : " << fDate->AsString("l") <<endl;
+ out<<"// * Statictics : " << fNEvents << endl;
+ out<<"// * # of MANUS : " << fNManu << endl;
+ out<<"// * # of channels : " << fNChannel << endl;
+ if (fErrorBuspatchTable->GetSize())
+ {
+ out<<"//"<<endl;
+ out<<"// * Buspatches with less statistics (due to parity errors)"<<endl;
+ TIterator* iter = fErrorBuspatchTable->MakeIterator();
+ AliMUONErrorCounter* parityerror;
+ while((parityerror = (AliMUONErrorCounter*) iter->Next()))
+ {
+ out<<"// bp "<<parityerror->BusPatch()<<" events used "<<fNEvents-parityerror->Events()<<endl;
+ }
+ }
+ out<<"//"<<endl;
+ out<<"//---------------------------------------------------------------------------" << endl;
+ out<<"//---------------------------------------------------------------------------" << endl;
+ out<<"// BP MANU CH. MEAN SIGMA"<<endl;
+ out<<"//---------------------------------------------------------------------------" << endl;
- if (!shuttleFile_1.IsNull()) {
- tempstring = WritePedData(busPatchId,manuId,channelId,pedMean,pedSigma);
- fileout << tempstring;
-#ifdef ALI_AMORE
- stringout << tempstring;
-#endif
- }
- if(fIndex<0) // Pedestal Run
- {
- pedMeanHisto->Fill(pedMean);
- pedSigmaHisto->Fill(pedSigma);
- tree->Fill();
- }
+ // iterator over pedestal
+ TIter next(fPedestalStore ->CreateIterator());
+ AliMUONVCalibParam* ped;
+
+ while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
+ {
+ Int_t busPatchId = ped->ID0();
+ Int_t manuId = ped->ID1();
+
+ for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId )
+ {
+ Double_t pedMean = ped->ValueAsDouble(channelId, 0);
+ Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
+
+ out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
}
}
+}
+
+//______________________________________________________________________________
+void AliMUONPedestal::MakeControlHistos()
+{
-// file outputs
- if (!shuttleFile_1.IsNull()) fileout.close();
-
-// Outputs to root file and AMORE DB
-#ifdef ALI_AMORE
- //
- //Send objects to the AMORE DB
- //
- amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
- TObjString peddata(stringout.str().c_str());
- Int_t status =0;
- status = amoreDA.Send("Pedestals",&peddata);
- if ( status )
- cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl;
- else
- cout << "amoreDA.Send(Pedestals) ok" << endl;
-#else
- cout << "Warning: MCH DA not compiled with AMORE support" << endl;
-#endif
- if(fIndex<0) // Pedestal Run
- {
- histoFile->Write();
- histoFile->Close();
- delete fPedestalStore ;
+ if (fIndex>=0) return; // Pedestal run (fIndex=-1)
+
+ Double_t pedMean;
+ Double_t pedSigma;
+ Int_t busPatchId;
+ Int_t manuId;
+ Int_t channelId;
+
+// histo
+ TFile* histoFile = 0;
+ TTree* tree = 0;
+ TH1F* pedMeanHisto = 0;
+ TH1F* pedSigmaHisto = 0;
+
+ sprintf(fHistoFileName,"%s.root",fprefixDA);
+ histoFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking pedestals");
+
+ Char_t name[255];
+ Char_t title[255];
+ sprintf(name,"pedmean_allch");
+ sprintf(title,"Pedestal mean all channels");
+ Int_t nx = kADCMax+1;
+ Int_t xmin = 0;
+ Int_t xmax = kADCMax;
+ pedMeanHisto = new TH1F(name,title,nx,xmin,xmax);
+ pedMeanHisto->SetDirectory(histoFile);
+
+ sprintf(name,"pedsigma_allch");
+ sprintf(title,"Pedestal sigma all channels");
+ nx = 201;
+ xmin = 0;
+ xmax = 200;
+ pedSigmaHisto = new TH1F(name,title,nx,xmin,xmax);
+ pedSigmaHisto->SetDirectory(histoFile);
+
+ tree = new TTree("t","Pedestal tree");
+ tree->Branch("bp",&busPatchId,"bp/I");
+ tree->Branch("manu",&manuId,",manu/I");
+ tree->Branch("channel",&channelId,",channel/I");
+ tree->Branch("pedMean",&pedMean,",pedMean/D");
+ tree->Branch("pedSigma",&pedSigma,",pedSigma/D");
+
+ // iterator over pedestal
+ TIter next(fPedestalStore ->CreateIterator());
+ AliMUONVCalibParam* ped;
+
+ while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
+ {
+ busPatchId = ped->ID0();
+ manuId = ped->ID1();
+
+ for ( channelId = 0; channelId < ped->Size(); ++channelId )
+ {
+ pedMean = ped->ValueAsDouble(channelId, 0);
+ pedSigma = ped->ValueAsDouble(channelId, 1);
+
+ pedMeanHisto->Fill(pedMean);
+ pedSigmaHisto->Fill(pedSigma);
+ tree->Fill();
+ }
}
+
+ histoFile->Write();
+ histoFile->Close();
+
}