25 #define MDC_TREE_NAME "mdc" 31 iFile = TFile::Open(fName);
32 if((iFile==NULL) || (iFile!=NULL && !iFile->IsOpen())) {
33 cout <<
"injection::Init : Error opening root file " << fName.Data() << endl;
39 ndim = tree->GetUserInfo()->GetSize();
42 cout <<
"injection::Init : number of detectors declared in the constructor (" << n
43 <<
") are not equals to the one ("<<ndim<<
") declared in the root file : " 44 << fName.Data() << endl;
50 <<
" not present in the root file " << fName.Data() << endl;
55 cout <<
"injection::Init : number of detectors is not declared in the constructor or" 56 <<
" not present in the root file : " << endl << fName.Data() << endl;
66 if (tree == 0)
return;
112 else {
delete name;
name=
new string();}
113 if (!
log)
log=
new string();
114 else {
delete log;
log=
new string();}
115 if (!
psi)
psi= (Float_t*)malloc(2*
sizeof(Float_t));
116 else psi= (Float_t*)realloc(
psi,2*
sizeof(Float_t));
117 if (!
iota)
iota= (Float_t*)malloc(2*
sizeof(Float_t));
118 else iota= (Float_t*)realloc(
iota,2*
sizeof(Float_t));
119 if (!
phi)
phi= (Float_t*)malloc(2*
sizeof(Float_t));
120 else phi= (Float_t*)realloc(
phi,2*
sizeof(Float_t));
121 if (!
theta)
theta= (Float_t*)malloc(2*
sizeof(Float_t));
122 else theta= (Float_t*)realloc(
theta,2*
sizeof(Float_t));
123 if (!
bp)
bp= (Float_t*)malloc(
ndim*
sizeof(Float_t));
124 else bp= (Float_t*)realloc(
bp,
ndim*
sizeof(Float_t));
125 if (!
bx)
bx= (Float_t*)malloc(
ndim*
sizeof(Float_t));
126 else bx= (Float_t*)realloc(
bx,
ndim*
sizeof(Float_t));
128 if (!
time)
time= (Double_t*)malloc(
ndim*
sizeof(Double_t));
129 else time= (Double_t*)realloc(
time,
ndim*
sizeof(Double_t));
137 if (!
hrss)
hrss= (Double_t*)malloc(
ndim*
sizeof(Double_t));
138 else hrss= (Double_t*)realloc(
hrss,
ndim*
sizeof(Double_t));
139 if (!
snr)
snr= (Float_t*)malloc(
ndim*
sizeof(Float_t));
140 else snr= (Float_t*)realloc(
snr,
ndim*
sizeof(Float_t));
141 if (!
Deff)
Deff= (Float_t*)malloc(
ndim*
sizeof(Float_t));
142 else Deff= (Float_t*)realloc(
Deff,
ndim*
sizeof(Float_t));
143 if (!
mass)
mass= (Float_t*)malloc(2*
sizeof(Float_t));
144 else mass= (Float_t*)realloc(
mass,2*
sizeof(Float_t));
145 if (!
spin)
spin= (Float_t*)malloc(6*
sizeof(Float_t));
146 else spin= (Float_t*)realloc(
spin,6*
sizeof(Float_t));
203 return fChain->GetEntry(entry);
208 return fChain->GetEntries();
263 waveTree->Branch(
"ndim", &
ndim,
"ndim/I");
264 waveTree->Branch(
"run", &
run,
"run/I");
265 waveTree->Branch(
"nevent", &
nevent,
"nevent/I");
266 waveTree->Branch(
"eventID", &
eventID,
"eventID/I");
267 waveTree->Branch(
"type", &
type,
"type/I");
268 waveTree->Branch(
"name",
name);
269 waveTree->Branch(
"log",
log);
270 waveTree->Branch(
"factor", &
factor,
"factor/F");
271 waveTree->Branch(
"distance", &
distance,
"distance/F");
272 waveTree->Branch(
"mchirp", &
mchirp,
"mchirp/F");
273 waveTree->Branch(
"rp0", &
rp0,
"rp0/F");
274 waveTree->Branch(
"e0", &
e0,
"e0/F");
275 waveTree->Branch(
"redshift", &
redshift,
"redshift/F");
276 waveTree->Branch(
"gps", &
gps,
"gps/D");
277 waveTree->Branch(
"strain", &
strain,
"strain/D");
278 waveTree->Branch(
"psi",
psi, cpsi);
279 waveTree->Branch(
"iota",
iota, ciota);
280 waveTree->Branch(
"phi",
phi, cphi);
281 waveTree->Branch(
"theta",
theta, ctheta);
282 waveTree->Branch(
"bp",
bp, cbp);
283 waveTree->Branch(
"bx",
bx, cbx);
284 waveTree->Branch(
"time",
time, ctime);
285 waveTree->Branch(
"duration",
duration, cduration);
286 waveTree->Branch(
"frequency",
frequency, cfrequency);
287 waveTree->Branch(
"bandwidth",
bandwidth, cbandwidth);
288 waveTree->Branch(
"hrss",
hrss, chrss);
289 waveTree->Branch(
"snr",
snr, csnr);
290 waveTree->Branch(
"Deff",
Deff, cDeff);
291 waveTree->Branch(
"mass",
mass, cmass);
292 waveTree->Branch(
"spin",
spin, cspin);
327 for(i=0; i<6; i++) this->
spin[i] = a.
spin[i];
329 for(i=0; i<
ndim; i++){
357 int ID =
id<0 ? abs(
id+1) : abs(
id);
359 if(!N || !M || !I || ID<0)
return false;
365 double hphp, hxhx, hphx, T0, To, Eo;
366 double Pi = 3.14159265358979312;
382 this->
log->assign(ch, strlen(ch));
383 this->
log->erase(std::remove(this->
log->begin(), this->
log->end(),
'\n'), this->
log->end());
385 if((p = strtok(ch,
" \t")) == NULL)
return false;
387 p = strtok(NULL,
" \t");
390 p = strtok(NULL,
" \t");
391 p = strtok(NULL,
" \t");
392 p = strtok(NULL,
" \t");
395 this->
iota[1] = atof(p);
396 this->
phi[1] = atof(p);
397 p = strtok(NULL,
" \t");
398 this->
psi[1] = atof(p);
399 p = strtok(NULL,
" \t");
400 if(
fabs(atof(p))>1) {
401 cout<<
"injection:fill_in error: external theta not valid, must be [-1,1]\n"<<endl;
404 this->
theta[0] = acos(atof(p));
406 p = strtok(NULL,
" \t");
407 this->
phi[0] = atof(p) > 0 ? atof(p) : 2*Pi+atof(p);
408 this->
phi[0]*= 180/
Pi;
409 p = strtok(NULL,
" \t");
410 this->
psi[0] = atof(p);
411 this->
psi[0]*= 180/
Pi;
413 p = strtok(NULL,
" \t");
414 p = strtok(NULL,
" \t");
418 p = strtok(NULL,
" \t");
420 this->
name->assign(p, strlen(p));
424 if(itag.find(p) == string::npos)
continue;
425 this->
type = i+1;
break;
428 p = strtok(NULL,
" \t");
430 p = strtok(NULL,
" \t");
432 p = strtok(NULL,
" \t");
438 if(nst >=
str.length()) {
439 cout<<
"injection:fill_in error: no injections for detector " 440 << net->
getifo(m)->
Name <<
" was found in the injection list !!!\n\n";
445 itag =
str.substr(nst);
447 if((p = strtok(ch,
" \t")) == NULL)
continue;
449 p = strtok(NULL,
" \t");
450 this->
time[
m] = atof(p);
455 p = strtok(NULL,
" \t");
456 this->
bp[
m] = atof(p);
457 p = strtok(NULL,
" \t");
458 this->
bx[
m] = atof(p);
460 nst =
str.find(
"insp") <
str.find(
"ebbh") ?
str.find(
"insp") :
str.find(
"ebbh");
462 if(nst <
str.length()) {
463 p = strtok(NULL,
" \t");
464 this->
Deff[
m] = atof(p);
472 if(!save)
return save;
474 nst =
str.find(
"distance");
476 if(nst <
str.length()) {
477 itag =
str.substr(nst);
479 if((p = strtok(ch,
" \t")) != NULL)
480 this->
distance = atof(strtok(NULL,
" \t"));
483 nst =
str.find(
"mass1");
485 if(nst <
str.length()) {
486 itag =
str.substr(nst);
488 if((p = strtok(ch,
" \t")) != NULL)
489 this->
mass[0] = atof(strtok(NULL,
" \t"));
492 nst =
str.find(
"mass2");
494 if(nst <
str.length()) {
495 itag =
str.substr(nst);
497 if((p = strtok(ch,
" \t")) != NULL)
498 this->
mass[1] = atof(strtok(NULL,
" \t"));
501 nst =
str.find(
"mchirp");
503 if(nst <
str.length()) {
504 itag =
str.substr(nst);
506 if((p = strtok(ch,
" \t")) != NULL)
507 this->
mchirp = atof(strtok(NULL,
" \t"));
510 nst =
str.find(
"rp0");
512 if(nst <
str.length()) {
513 itag =
str.substr(nst);
515 if((p = strtok(ch,
" \t")) != NULL)
516 this->
rp0 = atof(strtok(NULL,
" \t"));
519 nst =
str.find(
"e0");
521 if(nst <
str.length()) {
522 itag =
str.substr(nst);
524 if((p = strtok(ch,
" \t")) != NULL)
525 this->
e0 = atof(strtok(NULL,
" \t"));
528 nst =
str.find(
"redshift");
530 if(nst <
str.length()) {
531 itag =
str.substr(nst);
533 if((p = strtok(ch,
" \t")) != NULL)
534 this->
redshift = atof(strtok(NULL,
" \t"));
537 nst =
str.find(
"spin1");
541 if(nst <
str.length()) {
542 itag =
str.substr(nst);
544 if((p = strtok(ch,
" \t")) != NULL) {
545 this->
spin[0] = atof(strtok(NULL,
" \t"));
546 this->
spin[1] = atof(strtok(NULL,
" \t"));
547 this->
spin[2] = atof(strtok(NULL,
" \t"));
551 nst =
str.find(
"spin2");
555 if(nst <
str.length()) {
556 itag =
str.substr(nst);
558 if((p = strtok(ch,
" \t")) != NULL) {
559 this->
spin[3] = atof(strtok(NULL,
" \t"));
560 this->
spin[4] = atof(strtok(NULL,
" \t"));
561 this->
spin[5] = atof(strtok(NULL,
" \t"));
573 if(pd->
TIME.
data[ID] < 1.) save =
false;
576 if(!save || Eo<=0.)
return save;
585 this->
time[
m] += To - T0;
590 int idSize = pd->
IWFID.size();
592 for (
int mm=0; mm<idSize; mm++)
if (pd->
IWFID[mm]==
id) wfIndex=mm;
593 this->
pwf[
m] = wfIndex>=0 ? pd->
IWFP[wfIndex] : NULL;
607 if(!N || !M || !I)
return;
608 double FACTOR =
fabs(factor);
609 factor = factor<=0 ? 1 :
fabs(factor);
616 int dsize = waveTree->GetUserInfo()->GetSize();
617 if(dsize!=0 && dsize!=M) {
618 cout<<
"injection::output(): wrong user detector list in header tree"<<endl;
exit(1);
621 for(
int n=0;n<
M;n++) {
625 waveTree->GetUserInfo()->Add(pD);
637 this->factor = FACTOR;
Int_t fCurrent
pointer to the analyzed TTree or TChain
detector * getifo(size_t n)
param: detector index
TTree * Init(TString fName, int n)
Double_t * time
beam pattern coefficients for hx
std::vector< double > * getmdcTime()
wavearray< double > a(hp.size())
void output(TTree *, network *, double, bool=true)
Float_t * snr
injected hrss in the detectors
string getmdcType(size_t n)
Float_t * iota
source psi angle
string getmdcList(size_t n)
Float_t * duration
injection gps time
Float_t * bandwidth
average center_of_hrss frequency
virtual void start(double s)
Float_t * theta
source phi angle
Int_t ndim
current Tree number in a TChain
network ** net
NOISE_MDC_SIMULATION.
virtual size_t size() const
void Show(Int_t entry=-1)
Float_t factor
injection log
Double_t * hrss
estimated bandwidth
virtual injection & operator=(const injection &)
Float_t * mass
detector specific effective distance
Int_t run
number of detectors
std::vector< wavearray< double > * > IWFP
Float_t * phi
source iota angle
Float_t * bx
beam pattern coefficients for hp
WSeries< double > * getTFmap()
param: no parameters
double fabs(const Complex &x)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
string * log
injection name
Float_t * bp
source theta angle
Float_t * frequency
estimated duration
Bool_t fill_in(network *, int, bool=true)
size_t getmdc__ID(size_t n)
wavearray< double > ** pwf
[x1,y1,z1,x2,y2,z2] components of spin vector
TBranch * b_ndim
pointer to the reconstructed waveform
Float_t * spin
[m1,m2], binary mass parameters
TTree * fChain
root input file cointainig the mdc TTree
Float_t * Deff
injected snr in the detectors