+//==================================================================================
+Float_t AliPHOSReconstructor::CorrectNonlinearity(Float_t en){
+
+ //For backward compatibility, if no RecoParameters found
+ if(!GetRecoParam()){
+ return 0.0241+1.0504*en+0.000249*en*en ;
+ }
+
+ if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"NoCorrection")==0){
+ return en ;
+ }
+ if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"Gustavo2005")==0){
+ const Float_t *par=GetRecoParam()->GetNonlinearityParams() ;
+ return par[0]+par[1]*en + par[2]*en*en ;
+ }
+ if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"Henrik2010")==0){
+ const Float_t *par=GetRecoParam()->GetNonlinearityParams() ;
+ return en*(par[0]+par[1]*TMath::Exp(-en*par[2]))*(1.+par[3]*TMath::Exp(-en*par[4]))*(1.+par[6]/(en*en+par[5])) ;
+ }
+ //For backward compatibility
+ if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"")==0){
+ return 0.0241+1.0504*en+0.000249*en*en ;
+ }
+ return en ;
+}
+
+void AliPHOSReconstructor::readTRUParameters(AliPHOSTriggerParameters* parameters) const
+{
+ //Read trigger parameters.
+
+ TString path(gSystem->Getenv("ALICE_ROOT"));
+ path += "/PHOS/macros/Trigger/OCDB/";
+
+ for (Int_t mod = 2; mod < 5; ++mod) { // module
+ for (Int_t tru = 0; tru < 4; tru++) { // tru row
+ for (Int_t branch = 0; branch < 2; branch++) { // branch
+
+ // Open the Appropriate pedestal file
+ TString fileName = path;
+ fileName += "pedestal_m";
+ fileName = fileName += mod;
+ fileName+="_r";
+ fileName+=tru;
+ fileName+="_b";
+ fileName+=branch;
+ fileName+=".dat";
+ std::ifstream instream;
+ instream.open(fileName.Data());
+
+ // Read pedestals from file
+ if( ! instream.is_open() )
+ Printf("E-TRUPedestals: could not open %s", fileName.Data());
+ else
+ {
+ Int_t ped[112];
+
+ char ch_s[36];
+ char *ch_s_p = ch_s;
+ //Int_t nlines = 0;
+
+ Int_t t_ped_0 =0;
+ Int_t t_ped_1 =0;
+ Int_t t_ped_2 =0;
+
+ for(Int_t n=0; n<112; n++)
+ {
+ instream.getline(ch_s_p,36);
+ if (ch_s_p[23]<='9' && ch_s_p[23]>='0')
+ {
+ t_ped_0 = ch_s_p[23]-'0';
+ }
+ else if (ch_s_p[23]>='A' && ch_s_p[23]<='Z')
+ {
+ t_ped_0 = ch_s_p[23]-'A'+10;
+
+ }
+
+ if (ch_s_p[22]<='9' && ch_s_p[22]>='0')
+ {
+ t_ped_1 = ch_s_p[22]-'0';
+ }
+ else if (ch_s_p[22]<='Z' && ch_s_p[22]>='A')
+ {
+ t_ped_1 = ch_s_p[22]-'A'+10;
+ }
+
+ if (ch_s_p[21]<='9' && ch_s_p[21]>='0')
+ {
+ t_ped_2 = ch_s_p[21]-'0';
+ }
+ else if (ch_s_p[21]<='Z' && ch_s_p[21]>='A')
+ {
+ t_ped_2 = ch_s_p[21]-'A'+10;
+ }
+
+ ped[n]=t_ped_2*256+t_ped_1*16+t_ped_0;
+
+
+ }
+ for (Int_t xrow = 0; xrow < 8; xrow++){
+ for (Int_t zcol = 0; zcol < 14; zcol++){
+ Int_t pedestal = ped[zcol*8+xrow];
+
+ if( pedestal < 612 && pedestal > 412 ) // resonable
+ parameters->SetTRUPedestal(pedestal, mod, tru, branch, xrow, zcol);
+ else // unresonable
+ continue;
+ }
+ }
+ } // Ends read of pedestals from branch from file.
+ instream.close();
+ }// end branch
+ }// end tru
+
+ }// end for mod
+}
+
+