10 #define ProofStdVect_cxx
25 ProofStdVect::ProofStdVect()
39 ProofStdVect::~ProofStdVect()
49 void ProofStdVect::Begin(TTree * )
55 TString option = GetOption();
58 if (fInput && fInput->FindObject(
"ProofStdVect_Create")) {
60 }
else if (option.Contains(
"create")) {
66 void ProofStdVect::SlaveBegin(TTree * )
72 TString option = GetOption();
75 if (fInput && fInput->FindObject(
"ProofStdVect_Create")) {
77 }
else if (option.Contains(
"create")) {
84 UInt_t opt = TProofOutputFile::kRegister | TProofOutputFile::kOverwrite | TProofOutputFile::kVerify;
85 fProofFile =
new TProofOutputFile(
"ProofStdVect.root",
86 TProofOutputFile::kDataset, opt,
"TestStdVect");
89 fFile = fProofFile->OpenFile(
"RECREATE");
90 if (fFile && fFile->IsZombie()) SafeDelete(fFile);
94 Info(
"SlaveBegin",
"could not create '%s': instance is invalid!", fProofFile->GetName());
99 fTree =
new TTree(
"stdvec",
"Tree with std vector");
100 fTree->Branch(
"Vb",&fVb);
101 fTree->Branch(
"Vfx",&fVfx);
102 fTree->Branch(
"Vfy",&fVfy);
104 fTree->SetDirectory(fFile);
108 fRandom =
new TRandom3(0);
112 fHgood =
new TH1F(
"Hgood",
"Good hits", 100., -2.5, 2.5);
113 fHbad =
new TH1F(
"Hbad",
"Bad hits", 100., -6., 6.);
114 fOutput->Add(fHgood);
120 Bool_t ProofStdVect::Process(Long64_t entry)
141 if (!fTree)
return kTRUE;
144 Int_t nv = (Int_t) (entry % 10);
148 for (Int_t i = 0; i < nv; i++) {
149 std::vector<bool> vb;
150 std::vector<float> vfx, vfy;
151 Int_t np = (Int_t) (entry % 100);
153 for (Int_t j = 0; j < np; j++) {
156 Double_t sy = (Double_t) (0.1*y);
157 Double_t ym = fRandom->Gaus((Double_t)y, sy);
158 Double_t c2 = TMath::Abs((ym - y) / sy);
159 bool xb = (1. - TMath::Erfc(c2/TMath::Sqrt(2.)) > .95) ? 0 : 1;
162 vfy.push_back(
float(ym));
173 std::vector<std::vector<bool> >::iterator ivb;
174 for (ivb = fVb.begin(); ivb != fVb.end(); ivb++) {
178 std::vector<std::vector<float> >::iterator ivf;
179 for (ivf = fVfx.begin(); ivf != fVfx.end(); ivf++) {
183 for (ivf = fVfy.begin(); ivf != fVfy.end(); ivf++) {
191 for (UInt_t i = 0; i < fVfyr->size(); i++) {
192 std::vector<bool> &vb = fVbr->at(i);
193 std::vector<float> &vfx = fVfxr->at(i);
194 std::vector<float> &vfy = fVfyr->at(i);
195 for (UInt_t j = 0; j < vfy.size(); j++) {
196 Double_t ny = (vfy.at(j) - 5*vfx.at(j)) / (0.1 * 5 * vfx.at(j));
209 void ProofStdVect::SlaveTerminate()
216 if (!fCreate)
return;
221 Error(
"SlaveTerminate",
"'tree' is undefined!");
224 Bool_t cleanup = kFALSE;
225 TDirectory::TContext ctxt;
226 if (fTree->GetEntries() > 0) {
230 fOutput->Add(fProofFile);
234 fTree->SetDirectory(0);
238 TUrl uf(*(fFile->GetEndpointUrl()));
240 gSystem->Unlink(uf.GetFile());
241 SafeDelete(fProofFile);
247 void ProofStdVect::Terminate()
257 TCanvas *c1 =
new TCanvas(
"cvstdvec",
"Test StdVec", 800,10,700,780);
259 TPad *pad1 = (TPad *) c1->GetPad(1);
260 TPad *pad2 = (TPad *) c1->GetPad(2);
262 if (fHbad) fHbad->Draw();
264 if (fHgood) fHgood->Draw();
270 void ProofStdVect::Init(TTree *tree)
290 fChain->SetMakeClass(1);
292 fChain->SetBranchAddress(
"Vb", &fVbr, &b_Vb);
293 fChain->SetBranchAddress(
"Vfx", &fVfxr, &b_Vfx);
294 fChain->SetBranchAddress(
"Vfy", &fVfyr, &b_Vfy);
299 Bool_t ProofStdVect::Notify()
308 if (fCreate)
return kTRUE;
309 Info(
"Notify",
"processing file: %s",fChain->GetCurrentFile()->GetName());