StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StStrangeMuDstPlayer.cxx
1 #include <cstring>
2 
3 #include "StChain.h"
4 #include "StIOMaker/StIOMaker.h"
5 #include "StEventMaker/StEventMaker.h"
7 #include "StStrangeMuDstMaker/StV0MuDst.hh"
8 #include "StStrangeMuDstMaker/StXiMuDst.hh"
9 #include "StStrangeMuDstMaker/StKinkMuDst.hh"
10 #include "StStrangeMuDstMaker/StStrangeCuts.hh"
11 #include "StStrangeMuDstMaker/StStrangeEvMuDst.hh"
12 #include "StStrangeMuDstPlayer.h"
13 #include "StMessMgr.h"
14 #include "StMcEventMaker/StMcEventMaker.h"
15 #include "StAssociationMaker/StAssociationMaker.h"
16 // #include "StHbtMaker/StRandyTopMapMaker.h" // RWitt: Commented 7/24/15 to remove dependency on StHbtMaker
17 
18 ClassImp(StrangeMuDstPlayer)
19 
20 char empty = '\0';
21 char slash = '/';
22 void ParseFileName(const Char_t *output, const Char_t **file, const Char_t **dir) {
23  if ((*file = std::strrchr(output,slash))) {
24  (*file)++;
25  char *_dir = new char[strlen(output)+5];
26  strncpy(_dir,output,(strlen(output)-strlen(*file)));
27  *dir = _dir;
28  } else {
29  *file = output;
30  *dir = &empty;
31  }
32 }
33 
34 StrangeMuDstPlayer::StrangeMuDstPlayer() {
35  doFileSplit = kTRUE;
36  doMC = kFALSE;
37  doT0Abort = kTRUE;
38  doTopMapFix = kFALSE;
39  doReadDST = kFALSE;
40  doV0 = kTRUE;
41  doXi = kTRUE;
42  doKink = kTRUE;
43 
44  evPrimTracks = 0;
45  evPrimVertexZ = 100.;
46  v0DecayLength = 2.0;
47  v0DcaDaughtersToPrimVertex = 0.7;
48  v0DcaToPrimVertex = 0.8;
49  v0DcaDaughters = 0.75;
50  v0NumTpcHits = 15;
51  xiDecayLength = 0.;
52  xiDcaDaughters = 0.7;
53  xiDcaV0Daughters = 0.7;
54  xiDcaToPrimVertex = 0.7;
55  xiDcaV0ToPrimVertex = 0.;
56  xiDcaBachelorToPrimVertex = 0.;
57 }
58 
59 void StrangeMuDstPlayer::Make(Int_t NEvents, StFile* input, const Char_t* output) {
60 
61  StStrangeMuDstMaker *muDstMakers[3];
62  StStrangeMuDstMaker *v0MuDstMaker, *xiMuDstMaker, *kinkMuDstMaker;
63  StIOMaker *IOMaker;
64  StEventMaker *eventMaker;
65  StMcEventMaker *mcEventReader;
66  StAssociationMaker *associator;
67 // StRandyTopMapMaker *topoMapFixer; // RWitt: Commented 7/24/15 to remove dependency on StHbtMaker
68  const Char_t *file, *dir; Char_t *outfile[3], line[80];
69  TString prefix[3];
70  Int_t mNDstMakers = 0;
71 
72  // Create a chain
73  StChain chain("myChain");
74 
75  // Create Makers
76  IOMaker = new StIOMaker("IO","r",input,"bfcTree");
77  // Indicate input branches
78  IOMaker->SetBranch("*",0,"0"); //deactivate all branches
79  IOMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
80  if( doReadDST ) {
81  IOMaker->SetBranch("dstBranch",0,"r"); //activate dst Branch
82  eventMaker = new StEventMaker("events","title");
83  } else
84  IOMaker->SetBranch("eventBranch",0,"r"); //activate event Branch
85  // The following are needed for using Monte Carlo info
86  if( doMC ) {
87  IOMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
88  mcEventReader = new StMcEventMaker;
89  associator = new StAssociationMaker;
90  }
91  // RWitt: Commented 7/24/15 to remove dependency on StHbtMaker
92 // // The following is needed for MDC3 files with incorrect topology maps
93 // if( doTopMapFix )
94 // topoMapFixer = new StRandyTopMapMaker();
95 
96  if( doFileSplit ) {
97  if( doV0 ) {
98  v0MuDstMaker = new StStrangeMuDstMaker("v0MuDstMaker");
99  v0MuDstMaker->DoV0(); // Selects V0 vertices for new micro-DST
100  muDstMakers[mNDstMakers] = v0MuDstMaker;
101  prefix[mNDstMakers] = "v0_";
102  mNDstMakers++;
103  }
104  if( doXi ) {
105  xiMuDstMaker = new StStrangeMuDstMaker("xiMuDstMaker");
106  xiMuDstMaker->DoXi(); // Selects Xi vertices for new micro-DST
107  muDstMakers[mNDstMakers] = xiMuDstMaker;
108  prefix[mNDstMakers] = "xi_";
109  mNDstMakers++;
110  }
111  if( doKink ) {
112  kinkMuDstMaker = new StStrangeMuDstMaker("kinkMuDstMaker");
113  kinkMuDstMaker->DoKink(); // Selects Kink vertices for new micro-DST
114  muDstMakers[mNDstMakers] = kinkMuDstMaker;
115  prefix[mNDstMakers] = "kink_";
116  mNDstMakers++;
117  }
118  ParseFileName(output, &file, &dir);
119  for(Int_t i=0; i<mNDstMakers; i++) {
120  // outfile[i] = strdup(dir); // doesn't work - too short ?
121  outfile[i] = new char[strlen(output)+5];
122  strcpy(outfile[i],dir);
123  strcat(outfile[i],prefix[i].Data());
124  strcat(outfile[i],file);
125  muDstMakers[i]->SetWrite(outfile[i]);
126  if( doT0Abort )
127  muDstMakers[i]->DoT0JitterAbort();
128  if( doMC )
129  muDstMakers[i]->DoMc(); // Keep MC info if it is available
130  }
131  } else {
132  mNDstMakers = 1;
133  muDstMakers[0] = new StStrangeMuDstMaker("muDstMaker");
134  if( doV0 ) muDstMakers[0]->DoV0(); // Selects V0sfor new micro-DST
135  if( doXi ) muDstMakers[0]->DoXi(); // Selects Xis for new micro-DST
136  if( doKink ) muDstMakers[0]->DoKink(); // Selects Kinks for new micro-DST
137  muDstMakers[0]->SetWrite(output);
138  if( doT0Abort )
139  muDstMakers[0]->DoT0JitterAbort();
140  if( doMC )
141  muDstMakers[0]->DoMc(); // Keep MC info if it is available
142  }
143 
144  // Do init
145  Int_t istatus = chain.Init();
146  if( istatus ) { chain.FatalErr(istatus,"on init"); return; }
147 
148  // Loop over events
149  for( Int_t i=0; i<NEvents; i++ ) {
150  switch (istatus = chain.Make()) {
151  case 0: break;
152  case 2: { gMessMgr->Info("Last event from input."); break; }
153  case 3: { gMessMgr->Error() << "Event " << i << " had error " <<
154  istatus << ". Continuing."; gMessMgr->Print(); break; }
155  default: { gMessMgr->Warning() << "Event " << i << " returned status " <<
156  istatus << ". Continuing."; gMessMgr->Print(); }
157  }
158 
159  if( istatus == 2 ) break;
160 
161  if( i != NEvents) chain.Clear();
162  sprintf(line,"*** Finished processing event %d",i);
163  gMessMgr->Info(line);
164  }
165 
166  // Finish
167  if( NEvents >= 1 ) {
168  chain.Finish();
169  }
170 }
171 
172 void StrangeMuDstPlayer::Filter(Int_t NEvents, StFile* input, const Char_t* output) {
173 
174  StStrangeMuDstMaker *oldMuDstMaker=0;
175  StStrangeMuDstMaker *newMuDstMakers[3];
176  StStrangeMuDstMaker *v0MuDstMaker=0;
177  StStrangeMuDstMaker *xiMuDstMaker=0;
178  StStrangeMuDstMaker *kinkMuDstMaker=0;
179  const Char_t *file, *dir; Char_t *outfile[3], line[80];
180  TString prefix[3];
181  Int_t mNDstMakers = 0;
182 
183  // Create a chain
184  StChain chain("myChain");
185 
186  // Create Makers
187 
188  // The maker for the new micro DST must be constructed _before_ the
189  // maker to read the old micro DST. This is because the copying is
190  // done during chain.Clear(), and the new maker's Clear() must be
191  // called to do the copying before the old maker's Clear() is called,
192  // erasing the event.
193 
194  if( doFileSplit ) {
195  if( doV0 ) {
196  v0MuDstMaker = new StStrangeMuDstMaker("v0MuDstMaker");
197  v0MuDstMaker->DoV0(); // Selects V0 vertices for new micro-DST
198  newMuDstMakers[mNDstMakers] = v0MuDstMaker;
199  prefix[mNDstMakers] = "v0_";
200  mNDstMakers++;
201  }
202  if( doXi ) {
203  xiMuDstMaker = new StStrangeMuDstMaker("xiMuDstMaker");
204  xiMuDstMaker->DoXi(); // Selects Xi vertices for new micro-DST
205  newMuDstMakers[mNDstMakers] = xiMuDstMaker;
206  prefix[mNDstMakers] = "xi_";
207  mNDstMakers++;
208  }
209  if( doKink ) {
210  kinkMuDstMaker = new StStrangeMuDstMaker("kinkMuDstMaker");
211  kinkMuDstMaker->DoKink(); // Selects Kink vertices for new micro-DST
212  newMuDstMakers[mNDstMakers] = kinkMuDstMaker;
213  prefix[mNDstMakers] = "kink_";
214  mNDstMakers++;
215  }
216  ParseFileName(output, &file, &dir);
217  for(Int_t i=0; i<mNDstMakers; i++) {
218  // outfile[i] = strdup(dir); // doesn't work - too short ?
219  outfile[i] = new char[strlen(output)+5];
220  strcpy(outfile[i],dir);
221  strcat(outfile[i],prefix[i].Data());
222  strcat(outfile[i],file);
223  newMuDstMakers[i]->SetWrite(outfile[i]);
224  if( doT0Abort )
225  newMuDstMakers[i]->DoT0JitterAbort();
226  if( doMC )
227  newMuDstMakers[i]->DoMc(); // Keep MC info if it is available
228  }
229  } else {
230  mNDstMakers = 1;
231  newMuDstMakers[0] = new StStrangeMuDstMaker("newMuDstMaker");
232  if( doV0 ) newMuDstMakers[0]->DoV0(); // Selects V0s for new micro-DST
233  if( doXi ) newMuDstMakers[0]->DoXi(); // Selects Xis for new micro-DST
234  if( doKink ) newMuDstMakers[0]->DoKink();// Selects Kinks for new micro-DST
235  newMuDstMakers[0]->SetWrite(output);
236  if( doT0Abort )
237  newMuDstMakers[0]->DoT0JitterAbort();
238  if( doMC )
239  newMuDstMakers[0]->DoMc(); // Keep MC info if it is available
240  // Duplicate pointer to maker: access by name or generically
241  v0MuDstMaker = newMuDstMakers[0];
242  xiMuDstMaker = newMuDstMakers[0];
243  kinkMuDstMaker = newMuDstMakers[0];
244  }
245 
246  oldMuDstMaker = new StStrangeMuDstMaker("oldMuDstMaker");
247  oldMuDstMaker->SetRead(input); // Selects READ mode
248  // DoV0() and DoMc() are automatically called for the old maker by the new.
249  {for( Int_t i=0; i<mNDstMakers; i++ )
250  newMuDstMakers[i]->SubDst(oldMuDstMaker);}
251  // Next, any additional cuts that are being made should be added to
252  // the cuts information in the new DST.
253  char buff[80];
254  // Event-wise cuts go here
255  {for( Int_t i=0; i<mNDstMakers; i++ ) {
256  sprintf(buff,"< +/- %f",evPrimVertexZ);
257  newMuDstMakers[i]->Cuts().Add("evPrimVertexZ",buff);
258  sprintf(buff,"> %d",evPrimTracks);
259  newMuDstMakers[i]->Cuts().Add("evPrimTracks",buff);
260  }}
261  // Specific cuts follow
262  if( doV0 ) {
263  sprintf(buff,"> %f",v0DecayLength);
264  v0MuDstMaker->Cuts().Add("v0DecayLength",buff);
265  sprintf(buff,"> %f",v0DcaDaughtersToPrimVertex);
266  v0MuDstMaker->Cuts().Add("dcaPosToPrimVertex || dcaNegToPrimVertex",buff);
267  sprintf(buff,"< %f",v0DcaToPrimVertex);
268  v0MuDstMaker->Cuts().Add("v0DcaToPrimVertex",buff);
269  sprintf(buff,"< %f",v0DcaDaughters);
270  v0MuDstMaker->Cuts().Add("v0DcaDaughters",buff);
271  sprintf(buff,"> %f",v0NumTpcHits);
272  v0MuDstMaker->Cuts().Add("v0NumTpcHits",buff);
273  }
274  if( doXi ) {
275  sprintf(buff,"> %f",xiDecayLength);
276  xiMuDstMaker->Cuts().Add("xiDecayLength",buff);
277  sprintf(buff,"< %f",xiDcaDaughters);
278  xiMuDstMaker->Cuts().Add("xiDcaDaughters",buff);
279  sprintf(buff,"< %f",xiDcaV0Daughters);
280  xiMuDstMaker->Cuts().Add("xiDcaV0Daughters",buff);
281  sprintf(buff,"< %f",xiDcaToPrimVertex);
282  xiMuDstMaker->Cuts().Add("xiDcaToPrimVertex",buff);
283  sprintf(buff,"> %f",xiDcaV0ToPrimVertex);
284  xiMuDstMaker->Cuts().Add("xiDcaV0ToPrimVertex",buff);
285  sprintf(buff,"> %f",xiDcaBachelorToPrimVertex);
286  xiMuDstMaker->Cuts().Add("xiDcaBachelorToPrimVertex",buff);
287  }
288 
289  gMessMgr->Info() << "evPrimVertexZ < " << evPrimVertexZ << endm;
290  gMessMgr->Info() << "evPrimTracks > " << evPrimTracks << endm;
291  gMessMgr->Info() << "v0DecayLength > " << v0DecayLength << endm;
292  gMessMgr->Info() << "v0DcaToPrimVertex < " << v0DcaToPrimVertex << endm;
293  gMessMgr->Info() << "v0DcaDaughtersToPrimVertex > " <<
294  v0DcaDaughtersToPrimVertex << endm;
295  gMessMgr->Info() << "v0DcaDaughters < " << v0DcaDaughters << endm;
296  gMessMgr->Info() << "v0NumTpcHits > " << v0NumTpcHits << endm;
297  gMessMgr->Info() << "xiDecayLength > " << xiDecayLength << endm;
298  gMessMgr->Info() << "xiDcaDaughters < " << xiDcaDaughters << endm;
299  gMessMgr->Info() << "xiDcaV0Daughters < " << xiDcaV0Daughters << endm;
300  gMessMgr->Info() << "xiDcaToPrimVertex < " << xiDcaToPrimVertex << endm;
301  gMessMgr->Info() << "xiDcaV0ToPrimVertex > " << xiDcaV0ToPrimVertex << endm;
302  gMessMgr->Info() << "xiDcaBachelorToPrimVertex > " <<
303  xiDcaBachelorToPrimVertex << endm;
304 
305  // Do init
306  Int_t istatus = chain.Init();
307  if( istatus ) { chain.FatalErr(istatus,"on init"); return; }
308 
309  // Loop over events
310  for( Int_t i=0; i<NEvents; i++ ) {
311  switch (istatus = chain.Make(i)) {
312  case 0: break;
313  case 2: { gMessMgr->Info("Last event from input."); break; }
314  case 3: { gMessMgr->Error() << "Event " << i << " had error " <<
315  istatus << ". Ending."; gMessMgr->Print(); break; }
316  default: { gMessMgr->Warning() << "Event " << i << " returned status " <<
317  istatus << ". Ending."; gMessMgr->Print(); }
318  }
319 
320  if( istatus ) break;
321 
322  Float_t primZ = oldMuDstMaker->GetEvent()->primaryVertexZ();
323  unsigned int primaryTracks = oldMuDstMaker->GetEvent()->primaryTracks();
324  // Apply cut on the primary vertex Z position
325  if (TMath::Abs(primZ)<evPrimVertexZ && primaryTracks>evPrimTracks) {
326  if( doV0 )
327  // Apply selection criteria to the V0s
328  for( Int_t j=0; j<oldMuDstMaker->GetNV0(); j++ ) {
329  StV0MuDst *v0j = oldMuDstMaker->GetV0(j);
330  if( v0j->decayLengthV0() > v0DecayLength &&
331  v0j->dcaV0ToPrimVertex() < v0DcaToPrimVertex &&
332  ((v0j->dcaPosToPrimVertex() > v0DcaDaughtersToPrimVertex) ||
333  (v0j->dcaNegToPrimVertex() > v0DcaDaughtersToPrimVertex)) &&
334  v0j->dcaV0Daughters() < v0DcaDaughters &&
335  v0j->topologyMapPos().numberOfHits(kTpcId) > v0NumTpcHits &&
336  v0j->topologyMapNeg().numberOfHits(kTpcId) > v0NumTpcHits )
337  v0MuDstMaker->SelectV0(j);
338  }
339  if( doXi )
340  // Apply selection criteria to the Xis
341  for( Int_t j=0; j<oldMuDstMaker->GetNXi(); j++ ) {
342  StXiMuDst *xij = oldMuDstMaker->GetXi(j);
343  if( xij->decayLengthXi() > xiDecayLength &&
344  xij->dcaXiDaughters() < xiDcaDaughters &&
345  xij->dcaV0Daughters() < xiDcaV0Daughters &&
346  xij->dcaXiToPrimVertex() < xiDcaToPrimVertex &&
347  xij->dcaV0ToPrimVertex() > xiDcaV0ToPrimVertex &&
348  xij->dcaBachelorToPrimVertex() > xiDcaBachelorToPrimVertex )
349  xiMuDstMaker->SelectXi(j);
350  }
351  if( doKink )
352  // Just copy the kinks for now
353  for( Int_t j=0; j<oldMuDstMaker->GetNKink(); j++ ) {
354  kinkMuDstMaker->SelectKink(j);
355  }
356  } else {
357  {for( Int_t j=0; j<mNDstMakers; j++ )
358  newMuDstMakers[j]->AbortEvent();}
359  } // prim vertex Z and prim Tracks cut
360 
361  if( i != NEvents) chain.Clear();
362  sprintf(line,"*** Finished processing event %d",i);
363  gMessMgr->Info(line);
364  }
365 
366  // Finish
367  if( NEvents >= 1 ) {
368  chain.Finish();
369  }
370 }
371 
372 void StrangeMuDstPlayer::Play(Int_t NEvents, StFile* input, const Char_t* output) {
373 
374  StStrangeMuDstMaker *oldMuDstMaker=0;
375  StStrangeMuDstMaker *newMuDstMakers[3];
376  StStrangeMuDstMaker *v0MuDstMaker=0;
377  StStrangeMuDstMaker *xiMuDstMaker=0;
378  StStrangeMuDstMaker *kinkMuDstMaker=0;
379  StIOMaker *IOMaker;
380  StEventMaker *eventMaker;
381  StMcEventMaker *mcEventReader;
382  StAssociationMaker *associator;
383  // StRandyTopMapMaker *topoMapFixer; // RWitt: Commented 7/24/15 to remove dependency on StHbtMaker
384  const Char_t *file, *dir; Char_t *outfile[3], line[80];
385  TString prefix[3];
386  Int_t mNDstMakers = 0;
387 
388  // Create a chain
389  StChain chain("myChain");
390 
391  // Create Makers
392  IOMaker = new StIOMaker("IO","r",input,"bfcTree");
393  // Indicate input branches
394  IOMaker->SetBranch("*",0,"0"); //deactivate all branches
395  IOMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
396  if( doReadDST ) {
397  IOMaker->SetBranch("dstBranch",0,"r"); //activate dst Branch
398  eventMaker = new StEventMaker("events","title");
399  } else
400  IOMaker->SetBranch("eventBranch",0,"r"); //activate event Branch
401  // The following are needed for using Monte Carlo info
402  if( doMC ) {
403  IOMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
404  mcEventReader = new StMcEventMaker;
405  associator = new StAssociationMaker;
406  }
407  // RWitt: Commented 7/24/15 to remove dependency on StHbtMaker
408  // // The following is needed for MDC3 files with incorrect topology maps
409  // if( doTopMapFix )
410  // topoMapFixer = new StRandyTopMapMaker();
411 
412  // The maker for the new micro DST must be constructed _before_ the
413  // maker to read the old micro DST. This is because the copying is
414  // done during chain.Clear(), and the new maker's Clear() must be
415  // called to do the copying before the old maker's Clear() is called,
416  // erasing the event.
417 
418  if( doFileSplit ) {
419  if( doV0 ) {
420  v0MuDstMaker = new StStrangeMuDstMaker("v0MuDstMaker");
421  v0MuDstMaker->DoV0(); // Selects V0 vertices for new micro-DST
422  newMuDstMakers[mNDstMakers] = v0MuDstMaker;
423  prefix[mNDstMakers] = "v0_";
424  mNDstMakers++;
425  }
426  if( doXi ) {
427  xiMuDstMaker = new StStrangeMuDstMaker("xiMuDstMaker");
428  xiMuDstMaker->DoXi(); // Selects Xi vertices for new micro-DST
429  newMuDstMakers[mNDstMakers] = xiMuDstMaker;
430  prefix[mNDstMakers] = "xi_";
431  mNDstMakers++;
432  }
433  if( doKink ) {
434  kinkMuDstMaker = new StStrangeMuDstMaker("kinkMuDstMaker");
435  kinkMuDstMaker->DoKink(); // Selects Kink vertices for new micro-DST
436  newMuDstMakers[mNDstMakers] = kinkMuDstMaker;
437  prefix[mNDstMakers] = "kink_";
438  mNDstMakers++;
439  }
440  ParseFileName(output, &file, &dir);
441  for(Int_t i=0; i<mNDstMakers; i++) {
442  // outfile[i] = strdup(dir); // doesn't work - too short ?
443  outfile[i] = new char[strlen(output)+5];
444  strcpy(outfile[i],dir);
445  strcat(outfile[i],prefix[i].Data());
446  strcat(outfile[i],file);
447  newMuDstMakers[i]->SetWrite(outfile[i]);
448  if( doT0Abort )
449  newMuDstMakers[i]->DoT0JitterAbort();
450  if( doMC )
451  newMuDstMakers[i]->DoMc(); // Keep MC info if it is available
452  }
453  } else {
454  mNDstMakers = 1;
455  newMuDstMakers[0] = new StStrangeMuDstMaker("newMuDstMaker");
456  if( doV0 ) newMuDstMakers[0]->DoV0(); // Selects V0s for new micro-DST
457  if( doXi ) newMuDstMakers[0]->DoXi(); // Selects Xis for new micro-DST
458  if( doKink ) newMuDstMakers[0]->DoKink();// Selects Kinks for new micro-DST
459  newMuDstMakers[0]->SetWrite(output);
460  if( doT0Abort )
461  newMuDstMakers[0]->DoT0JitterAbort();
462  if( doMC )
463  newMuDstMakers[0]->DoMc(); // Keep MC info if it is available
464  // Duplicate pointer to maker: access by name or generically
465  v0MuDstMaker = newMuDstMakers[0];
466  xiMuDstMaker = newMuDstMakers[0];
467  kinkMuDstMaker = newMuDstMakers[0];
468  }
469 
470  oldMuDstMaker = new StStrangeMuDstMaker("oldMuDstMaker");
471  oldMuDstMaker->SetNoKeep(); // Reset tree after every event
472  if( doT0Abort )
473  oldMuDstMaker->DoT0JitterAbort();
474  // DoV0() and DoMc() are automatically called for the old maker by the new.
475  {for( Int_t i=0; i<mNDstMakers; i++ )
476  newMuDstMakers[i]->SubDst(oldMuDstMaker);}
477  // Next, any additional cuts that are being made should be added to
478  // the cuts information in the new DST.
479  char buff[80];
480  // Event-wise cuts go here
481  {for( Int_t i=0; i<mNDstMakers; i++ ) {
482  sprintf(buff,"< +/- %f",evPrimVertexZ);
483  newMuDstMakers[i]->Cuts().Add("evPrimVertexZ",buff);
484  sprintf(buff,"> %d",evPrimTracks);
485  newMuDstMakers[i]->Cuts().Add("evPrimTracks",buff);
486  }}
487  // Specific cuts follow
488  if( doV0 ) {
489  sprintf(buff,"> %f",v0DecayLength);
490  v0MuDstMaker->Cuts().Add("v0DecayLength",buff);
491  sprintf(buff,"> %f",v0DcaDaughtersToPrimVertex);
492  v0MuDstMaker->Cuts().Add("dcaPosToPrimVertex || dcaNegToPrimVertex",buff);
493  sprintf(buff,"< %f",v0DcaToPrimVertex);
494  v0MuDstMaker->Cuts().Add("v0DcaToPrimVertex",buff);
495  sprintf(buff,"< %f",v0DcaDaughters);
496  v0MuDstMaker->Cuts().Add("v0DcaDaughters",buff);
497  sprintf(buff,"> %f",v0NumTpcHits);
498  v0MuDstMaker->Cuts().Add("v0NumTpcHits",buff);
499  }
500  if( doXi ) {
501  sprintf(buff,"> %f",xiDecayLength);
502  xiMuDstMaker->Cuts().Add("xiDecayLength",buff);
503  sprintf(buff,"< %f",xiDcaDaughters);
504  xiMuDstMaker->Cuts().Add("xiDcaDaughters",buff);
505  sprintf(buff,"< %f",xiDcaV0Daughters);
506  xiMuDstMaker->Cuts().Add("xiDcaV0Daughters",buff);
507  sprintf(buff,"< %f",xiDcaToPrimVertex);
508  xiMuDstMaker->Cuts().Add("xiDcaToPrimVertex",buff);
509  sprintf(buff,"> %f",xiDcaV0ToPrimVertex);
510  xiMuDstMaker->Cuts().Add("xiDcaV0ToPrimVertex",buff);
511  sprintf(buff,"> %f",xiDcaBachelorToPrimVertex);
512  xiMuDstMaker->Cuts().Add("xiDcaBachelorToPrimVertex",buff);
513  }
514 
515  gMessMgr->Info() << "evPrimVertexZ < " << evPrimVertexZ << endm;
516  gMessMgr->Info() << "evPrimTracks > " << evPrimTracks << endm;
517  gMessMgr->Info() << "v0DecayLength > " << v0DecayLength << endm;
518  gMessMgr->Info() << "v0DcaToPrimVertex < " << v0DcaToPrimVertex << endm;
519  gMessMgr->Info() << "v0DcaDaughtersToPrimVertex > " <<
520  v0DcaDaughtersToPrimVertex << endm;
521  gMessMgr->Info() << "v0DcaDaughters < " << v0DcaDaughters << endm;
522  gMessMgr->Info() << "v0NumTpcHits > " << v0NumTpcHits << endm;
523  gMessMgr->Info() << "xiDecayLength > " << xiDecayLength << endm;
524  gMessMgr->Info() << "xiDcaDaughters < " << xiDcaDaughters << endm;
525  gMessMgr->Info() << "xiDcaV0Daughters < " << xiDcaV0Daughters << endm;
526  gMessMgr->Info() << "xiDcaToPrimVertex < " << xiDcaToPrimVertex << endm;
527  gMessMgr->Info() << "xiDcaV0ToPrimVertex > " << xiDcaV0ToPrimVertex << endm;
528  gMessMgr->Info() << "xiDcaBachelorToPrimVertex > " <<
529  xiDcaBachelorToPrimVertex << endm;
530 
531  // Do init
532  Int_t istatus = chain.Init();
533  if( istatus ) { chain.FatalErr(istatus,"on init"); return; }
534 
535  // Loop over events
536  for( Int_t i=0; i<NEvents; i++ ) {
537  switch (istatus = chain.Make()) {
538  case 0: break;
539  case 2: { gMessMgr->Info("Last event from input."); break; }
540  case 3: { gMessMgr->Error() << "Event " << i << " had error " <<
541  istatus << ". Continuing."; gMessMgr->Print(); break; }
542  default: { gMessMgr->Warning() << "Event " << i << " returned status " <<
543  istatus << ". Continuing."; gMessMgr->Print(); }
544  }
545 
546  if( istatus == 2 ) break;
547 
548  Float_t primZ = oldMuDstMaker->GetEvent()->primaryVertexZ();
549  unsigned int primaryTracks = oldMuDstMaker->GetEvent()->primaryTracks();
550  // Apply cut on the primary vertex Z position
551  if (TMath::Abs(primZ)<evPrimVertexZ && primaryTracks>evPrimTracks) {
552  if( doV0 )
553  // Apply selection criteria to the V0s
554  for( Int_t j=0; j<oldMuDstMaker->GetNV0(); j++ ) {
555  StV0MuDst *v0j = oldMuDstMaker->GetV0(j);
556  if( v0j->decayLengthV0() > v0DecayLength &&
557  v0j->dcaV0ToPrimVertex() < v0DcaToPrimVertex &&
558  ((v0j->dcaPosToPrimVertex() > v0DcaDaughtersToPrimVertex) ||
559  (v0j->dcaNegToPrimVertex() > v0DcaDaughtersToPrimVertex)) &&
560  v0j->dcaV0Daughters() < v0DcaDaughters &&
561  v0j->topologyMapPos().numberOfHits(kTpcId) > v0NumTpcHits &&
562  v0j->topologyMapNeg().numberOfHits(kTpcId) > v0NumTpcHits )
563  v0MuDstMaker->SelectV0(j);
564  }
565  if( doXi )
566  // Apply selection criteria to the Xis
567  for( Int_t j=0; j<oldMuDstMaker->GetNXi(); j++ ) {
568  StXiMuDst *xij = oldMuDstMaker->GetXi(j);
569  if( xij->decayLengthXi() > xiDecayLength &&
570  xij->dcaXiDaughters() < xiDcaDaughters &&
571  xij->dcaV0Daughters() < xiDcaV0Daughters &&
572  xij->dcaXiToPrimVertex() < xiDcaToPrimVertex &&
573  xij->dcaV0ToPrimVertex() > xiDcaV0ToPrimVertex &&
574  xij->dcaBachelorToPrimVertex() > xiDcaBachelorToPrimVertex )
575  xiMuDstMaker->SelectXi(j);
576  }
577  if( doKink )
578  // Just copy the kinks for now
579  for( Int_t j=0; j<oldMuDstMaker->GetNKink(); j++ ) {
580  kinkMuDstMaker->SelectKink(j);
581  }
582  } else {
583  {for( Int_t j=0; j<mNDstMakers; j++ )
584  newMuDstMakers[j]->AbortEvent();}
585  } // prim vertex Z and prim Tracks cut
586 
587  if( i != NEvents) chain.Clear();
588  sprintf(line,"*** Finished processing event %d",i);
589  gMessMgr->Info(line);
590  }
591 
592  // Finish
593  if( NEvents >= 1 ) {
594  chain.Finish();
595  }
596 }
597 
598 void StrangeMuDstPlayer::Copy(Int_t NEvents, StFile* input, const Char_t* output) {
599 
600  StStrangeMuDstMaker *oldMuDstMaker=0;
601  StStrangeMuDstMaker *newMuDstMakers[3];
602  StStrangeMuDstMaker *v0MuDstMaker=0;
603  StStrangeMuDstMaker *xiMuDstMaker=0;
604  StStrangeMuDstMaker *kinkMuDstMaker=0;
605  const Char_t *file, *dir; Char_t *outfile[3], line[80];
606  TString prefix[3];
607  Int_t mNDstMakers = 0;
608 
609  // Create a chain
610  StChain chain("myChain");
611 
612  // Create Makers
613 
614  // The maker for the new micro DST must be constructed _before_ the
615  // maker to read the old micro DST. This is because the copying is
616  // done during chain.Clear(), and the new maker's Clear() must be
617  // called to do the copying before the old maker's Clear() is called,
618  // erasing the event.
619 
620  if( doFileSplit ) {
621  if( doV0 ) {
622  v0MuDstMaker = new StStrangeMuDstMaker("v0MuDstMaker");
623  v0MuDstMaker->DoV0(); // Selects V0 vertices for new micro-DST
624  newMuDstMakers[mNDstMakers] = v0MuDstMaker;
625  prefix[mNDstMakers] = "v0_";
626  mNDstMakers++;
627  }
628  if( doXi ) {
629  xiMuDstMaker = new StStrangeMuDstMaker("xiMuDstMaker");
630  xiMuDstMaker->DoXi(); // Selects Xi vertices for new micro-DST
631  newMuDstMakers[mNDstMakers] = xiMuDstMaker;
632  prefix[mNDstMakers] = "xi_";
633  mNDstMakers++;
634  }
635  if( doKink ) {
636  kinkMuDstMaker = new StStrangeMuDstMaker("kinkMuDstMaker");
637  kinkMuDstMaker->DoKink(); // Selects Kink vertices for new micro-DST
638  newMuDstMakers[mNDstMakers] = kinkMuDstMaker;
639  prefix[mNDstMakers] = "kink_";
640  mNDstMakers++;
641  }
642  ParseFileName(output, &file, &dir);
643  for(Int_t i=0; i<mNDstMakers; i++) {
644  // outfile[i] = strdup(dir); // doesn't work - too short ?
645  outfile[i] = new char[strlen(output)+5];
646  strcpy(outfile[i],dir);
647  strcat(outfile[i],prefix[i].Data());
648  strcat(outfile[i],file);
649  newMuDstMakers[i]->SetWrite(outfile[i]);
650  if( doT0Abort )
651  newMuDstMakers[i]->DoT0JitterAbort();
652  if( doMC )
653  newMuDstMakers[i]->DoMc(); // Keep MC info if it is available
654  }
655  } else {
656  mNDstMakers = 1;
657  newMuDstMakers[0] = new StStrangeMuDstMaker("newMuDstMaker");
658  if( doV0 ) newMuDstMakers[0]->DoV0(); // Selects V0s for new micro-DST
659  if( doXi ) newMuDstMakers[0]->DoXi(); // Selects Xis for new micro-DST
660  if( doKink ) newMuDstMakers[0]->DoKink();// Selects Kinks for new micro-DST
661  newMuDstMakers[0]->SetWrite(output);
662  if( doT0Abort )
663  newMuDstMakers[0]->DoT0JitterAbort();
664  if( doMC )
665  newMuDstMakers[0]->DoMc(); // Keep MC info if it is available
666  // Duplicate pointer to maker: access by name or generically
667  v0MuDstMaker = newMuDstMakers[0];
668  xiMuDstMaker = newMuDstMakers[0];
669  kinkMuDstMaker = newMuDstMakers[0];
670  }
671 
672  oldMuDstMaker = new StStrangeMuDstMaker("oldMuDstMaker");
673  oldMuDstMaker->SetRead(input); // Selects READ mode
674  // DoV0() and DoMc() are automatically called for the old maker by the new.
675  {for( Int_t i=0; i<mNDstMakers; i++ )
676  newMuDstMakers[i]->SubDst(oldMuDstMaker);}
677 
678  // Do init
679  Int_t istatus = chain.Init();
680  if( istatus ) { chain.FatalErr(istatus,"on init"); return; }
681 
682  // Loop over events
683  for( Int_t i=0; i<NEvents; i++ ) {
684  switch (istatus = chain.Make(i)) {
685  case 0: break;
686  case 2: { gMessMgr->Info("Last event from input."); break; }
687  case 3: { gMessMgr->Error() << "Event " << i << " had error " <<
688  istatus << ". Ending."; gMessMgr->Print(); break; }
689  default: { gMessMgr->Warning() << "Event " << i << " returned status " <<
690  istatus << ". Ending."; gMessMgr->Print(); }
691  }
692 
693  if( istatus ) break;
694 
695  if( doV0 )
696  // Copy the V0s
697  for( Int_t j=0; j<oldMuDstMaker->GetNV0(); j++ )
698  v0MuDstMaker->SelectV0(j);
699  if( doXi )
700  // Copy the Xis
701  for( Int_t j=0; j<oldMuDstMaker->GetNXi(); j++ )
702  xiMuDstMaker->SelectXi(j);
703  if( doKink )
704  // Copy the kinks
705  for( Int_t j=0; j<oldMuDstMaker->GetNKink(); j++ )
706  kinkMuDstMaker->SelectKink(j);
707 
708  if( i != NEvents) chain.Clear();
709  sprintf(line,"*** Finished processing event %d",i);
710  gMessMgr->Info(line);
711  }
712 
713  // Finish
714  if( NEvents >= 1 ) {
715  chain.Finish();
716  }
717 }
718 
Float_t dcaV0ToPrimVertex() const
DCA of v0 to primary vertex.
Definition: StV0MuDst.hh:116
Definition: StTree.h:125
Float_t dcaPosToPrimVertex() const
DCA of pos v0 daughter to pri vertex.
Definition: StV0MuDst.hh:118
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Float_t decayLengthV0() const
3-d decay distance
Definition: StV0I.hh:298
StTrackTopologyMap & topologyMapPos()
Pos. daughter track topology map.
Definition: StV0MuDst.hh:128
Float_t decayLengthXi() const
3-d decay distance of Xi
Definition: StXiI.hh:245
Float_t dcaBachelorToPrimVertex() const
DCA of bachelor to primary vertex.
Definition: StXiMuDst.hh:111
virtual Int_t Finish()
Definition: StChain.cxx:85
Float_t dcaXiDaughters() const
DCA of xi daughters at decay vertex.
Definition: StXiMuDst.hh:107
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
Float_t dcaNegToPrimVertex() const
DCA of neg v0 daughter to pri vertex.
Definition: StV0MuDst.hh:120
StTrackTopologyMap & topologyMapNeg()
Neg. daughter track topology map.
Definition: StV0MuDst.hh:130
virtual Int_t Make()
Definition: StChain.cxx:110
Float_t dcaXiToPrimVertex() const
DCA of xi to primary vertex.
Definition: StXiMuDst.hh:109
Float_t dcaV0Daughters() const
DCA of v0 daughters at decay vertex.
Definition: StV0MuDst.hh:114
Float_t primaryVertexZ() const
Primary vtx position coordinates.