3 /**************************************************************************
4 * This file is property of and copyright by the Experimental Nuclear *
5 * Physics Group, Dep. of Physics *
6 * University of Oslo, Norway, 2007 *
8 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
9 * Contributors are mentioned in the code where appropriate. *
10 * Please report bugs to perthi@fys.uio.no *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
20 #include "AliHLTPHOSIsolatedMipTrigger.h"
22 #include "AliHLTPHOSDigit.h"
25 #include "TClonesArray.h"
29 #include "AliHLTPHOSMipCluster.h"
30 #include "AliHLTPHOSMipClusterManager.h"
40 AliHLTPHOSIsolatedMipTrigger::AliHLTPHOSIsolatedMipTrigger() : fMipLowCut(3),
44 fClusterManager = new AliHLTPHOSMipClusterManager();
49 AliHLTPHOSIsolatedMipTrigger::~AliHLTPHOSIsolatedMipTrigger()
56 AliHLTPHOSIsolatedMipTrigger::SetFilePath(char *path)
58 sprintf(fCurrentFilePath, "%s", path);
59 printf("\n AliHLTPHOSIsolatedMipTrigger::SetFilePath, filepath was set to %s \n", fCurrentFilePath);
64 AliHLTPHOSIsolatedMipTrigger::SetMipLowCut(Float_t lCut)
70 AliHLTPHOSIsolatedMipTrigger::SetMipHighCut(Float_t hCut)
77 AliHLTPHOSIsolatedMipTrigger::ScanFileList()
80 FILE *fp = fopen("filelist.txt", "r");
84 fscanf(fp, "%d\n", &fNFiles);
85 cout << "there are " << fNFiles << " files " <<endl;
87 for(int i=0; i< fNFiles; i++)
89 fscanf(fp, "%s\n" ,fFileList[i]);
92 for(int i=0; i< fNFiles; i++)
94 cout << fFileList[i] << endl;
99 cout << "ERROR opening file, filelist.txt" << endl;
109 AliHLTPHOSIsolatedMipTrigger::Analyze()
111 // TClonesArray *digArray = new TClonesArray("AliHLTPHOSDigit" , 500);
114 cout << "AliHLTPHOSIsolatedMipTrigger::Analyze fNFiles = " << fNFiles <<endl;
116 for(int file=0; file < fNFiles; file ++)
119 printf("\n AliHLTPHOSIsolatedMipTrigger::Analyze, analyzing file %s\n", fFileList[file]);
121 TFile *infile = infile->Open(fFileList[file],"read");
122 // TFile *infile = infile->Open("/tmp/data2/digits151007/run8340_digitTree_5.root","read");
124 AliHLTPHOSDigit *tmpDigit = 0;
129 cout << "ERROR could not open file" << endl;
135 cout << "File successfully opened, creating" << endl;
136 TChain *cain= new TChain("digitTree");
137 TClonesArray *digArray = new TClonesArray("AliHLTPHOSDigit" , 100);
139 cain->Add(fFileList[file]);
141 int nThrees = cain->GetEntries() ;
142 cout << "there are " << nThrees << " entries in this file" << endl;
143 cain->SetBranchAddress("Digit", &digArray);
145 for(int i=0; i< nThrees; i++)
147 fClusterManager->ResetMipManager();
149 int nArrays = digArray->GetEntriesFast();
153 cout << "processing event " << i << " of file " << fFileList[file] <<endl;
157 for(int j=0; j < nArrays; j++)
160 tmpDigit = (AliHLTPHOSDigit*)digArray->At(j);
162 if( IsMipCandidate(tmpDigit) == true)
164 fClusterManager->AddDigit(tmpDigit);
168 FillClusterHistograms();
186 AliHLTPHOSIsolatedMipTrigger::IsMipCandidate(AliHLTPHOSDigit *digit)
189 Float_t amplitude = digit->GetAmplitude();
190 Int_t *data = digit->GetRawData();
194 if( amplitude > fMipLowCut && amplitude < fMipHighCut)
196 int start = digit->GetPreSamples();
197 int end = digit->GetTotalSamples() - start;
199 for(int i = start; i < end; i++)
204 q = ((Float_t)sum)/amplitude;
206 if( (q > Q_MIN) && (q < Q_MAX))
218 AliHLTPHOSIsolatedMipTrigger::Init()
221 char tmpHistoName[256];
223 for(int z = 0; z < N_ZROWS_MOD; z ++)
225 for(int x = 0; x < N_XCOLUMNS_MOD; x ++)
227 sprintf(tmpHistoName, "ClusterEnergies3x3_%d_%d_%d_%d",(int)fModuleId, z, x, 1);
228 fClusterHistograms[z][x] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
236 AliHLTPHOSIsolatedMipTrigger::FillClusterHistograms()
239 AliHLTPHOSMipCluster* tmp;
241 for(int z = 0; z < N_ZROWS_MOD; z ++)
243 for(int x = 0; x < N_XCOLUMNS_MOD; x ++)
245 tmp = fClusterManager->GetCluster(z, x);
248 fClusterHistograms[z][x]->Fill(tmp->Get3x3Sum());
254 // cout << "filled " << cnt <<" clusters" <<endl;
258 AliHLTPHOSIsolatedMipTrigger::WriteHistograms()
260 char tmpFileName[256];
261 sprintf(tmpFileName, "ClusterEnergies.root");
263 TFile *clusterFile = new TFile(tmpFileName, "recreate");
265 for(int z = 0; z < N_ZROWS_MOD; z ++)
267 for(int x = 0; x < N_XCOLUMNS_MOD; x ++)
269 if(fClusterHistograms[z][x]->GetEntries() > 10 )
271 fClusterHistograms[z][x]->Write();
276 clusterFile->Close();