FEDRA emulsion software from the OPERA Collaboration
comptonmap.cpp File Reference
#include <string.h>
#include <iostream>
#include <TEnv.h>
#include "EdbLog.h"
#include "EdbScanProc.h"
#include "EdbPositionAlignment.h"
#include "EdbAlignmentMap.h"
#include "tlg2pattern.C"
Include dependency graph for comptonmap.cpp:

Functions

void add_pattern (EdbPattern &p, EdbPattern &padd, float wmin, float thetamax, float xmin, float xmax, float ymin, float ymax, float maxDens=2)
 
void AlignMap (TEnv *cenv)
 
void AlignMapJap (TEnv *cenv)
 
void AlignRunMap (TEnv *cenv)
 
void ApplyMap (TEnv *cenv)
 
void ApplyTestMap (TEnv *cenv)
 
void get_patterns_Jap (const char *listfile, TEnv *cenv, EdbPattern &p)
 
void get_patterns_Jap2 (const char *listfile, TEnv *cenv, EdbPattern &p)
 
void get_patterns_tlglist1 (const char *listfile, TEnv *cenv, EdbPattern *ptop, EdbPattern *pbot, EdbPattern *pbase)
 
void get_run_patterns (const char *runfile, TEnv *cenv, EdbPattern *ptop, EdbPattern *pbot)
 
void LinkJap2 (TEnv *cenv)
 
int main (int argc, char *argv[])
 
void print_help_message ()
 
void set_default (TEnv &cenv)
 

Variables

EdbScanProcsproc =0
 

Function Documentation

◆ add_pattern()

void add_pattern ( EdbPattern p,
EdbPattern padd,
float  wmin,
float  thetamax,
float  xmin,
float  xmax,
float  ymin,
float  ymax,
float  maxDens = 2 
)
550{
551 // add pattern padd to p with the requested selections
552
553 float min[2] = { kMaxInt, kMaxInt};
554 float max[2] = { kMinInt, kMinInt};
555 int n = padd.N();
556 TObjArray a(n);
557 EdbSegP *s=0;
558 for(int i=0; i<n; i++) {
559 s = padd.GetSegment(i);
560 if(s->W() < wmin) continue;
561 if(s->Theta() > thetamax) continue;
562 if(s->X() < xmin) continue;
563 if(s->X() > xmax) continue;
564 if(s->Y() < ymin) continue;
565 if(s->Y() > ymax) continue;
566 s->SetFlag(0);
567 a.Add( s );
568
569 if(s->X() < min[0]) min[0]=s->X();
570 if(s->Y() < min[1]) min[1]=s->Y();
571 if(s->X() > max[0]) max[0]=s->X();
572 if(s->Y() > max[1]) max[1]=s->Y();
573 }
574 int nmax = (int)(maxDens*(max[0]-min[0])*(max[1]-min[1]) /100/100);
575
576 TObjArray arr(n);
578 int nsel = arr.GetEntriesFast();
579 for(int i=0; i<nsel; i++) {
580 s = (EdbSegP *)arr.At(i);
581 p.AddSegment( *s );
582 }
583}
void a()
Definition: check_aligned.C:59
float min(TClonesArray *t)
Definition: bitview.cxx:275
static int SelectBestComptons(TObjArray &a, TObjArray &arr, int nmax)
Definition: EdbPositionAlignment.cxx:505
Definition: EdbSegP.h:21
Int_t N() const
Definition: EdbPattern.h:86
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
s
Definition: check_shower.C:55
int max
Definition: check_shower.C:41
p
Definition: testBGReduction_AllMethods.C:8

◆ AlignMap()

void AlignMap ( TEnv *  cenv)
279{
280 // read from tlglists the sides p1b and p2t and find the compton map
281
282 EdbPattern p1b(0,0,0,2000000),p2t(0,0,0,2000000); // read full patterns
283 get_patterns_tlglist1(cenv->GetValue("comptonmap.listA",""), cenv, 0, &p1b, 0);
284 get_patterns_tlglist1(cenv->GetValue("comptonmap.listB",""), cenv, &p2t, 0, 0);
285 printf("test 2 patterns with %d and %d segments\n",p1b.N(), p2t.N());
286
287 p1b.ProjectTo(-45.); // project to nominal contact surface position to simplify the alignment
288 p2t.ProjectTo( 45.);
289
290 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")), "RECREATE");
291 amap.eEnv = cenv; // pass parameters here
292 amap.ePat1 = &p1b;
293 amap.ePat2 = &p2t;
294 amap.AlignMap();
295 //amap.SaveAll();
296 amap.SaveMap(cenv->GetValue("comptonmap.out" , "out.map"));
297 //amap.ExtractMapFromTree();
298 amap.SaveAll();
299}
2-d alignment map finder
Definition: EdbAlignmentMap.h:16
Definition: EdbPattern.h:273
void get_patterns_tlglist1(const char *listfile, TEnv *cenv, EdbPattern *ptop, EdbPattern *pbot, EdbPattern *pbase)
Definition: comptonmap.cpp:431
TEnv cenv("emrec")

◆ AlignMapJap()

void AlignMapJap ( TEnv *  cenv)
303{
304 // read from tlglists the sides p1b and p2t and find the compton map
305
306 EdbPattern p1b(0,0,0,200000),p2t(0,0,0,200000); // read full patterns
307 get_patterns_Jap(cenv->GetValue("comptonmap.listA",""), cenv, p1b);
308 get_patterns_Jap(cenv->GetValue("comptonmap.listB",""), cenv, p2t);
309 printf("test 2 Jap patterns with %d and %d segments\n",p1b.N(), p2t.N());
310
311 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")), "RECREATE");
312 amap.eEnv = cenv; // pass parameters here
313 amap.ePat1 = &p1b;
314 amap.ePat2 = &p2t;
315 amap.AlignMap();
316 //amap.SaveAll();
317 amap.SaveMap(cenv->GetValue("comptonmap.out" , "out.map"));
318 //amap.ExtractMapFromTree();
319 amap.SaveAll();
320}
void get_patterns_Jap(const char *listfile, TEnv *cenv, EdbPattern &p)
Definition: comptonmap.cpp:480

◆ AlignRunMap()

void AlignRunMap ( TEnv *  cenv)
255{
256 // read from root raw files sides p1b and p2t and find the compton map
257
258 EdbPattern p1b(0,0,0,2000000),p2t(0,0,0,2000000); // read full patterns
259 get_run_patterns(cenv->GetValue("comptonmap.runA",""), cenv, 0, &p1b);
260 get_run_patterns(cenv->GetValue("comptonmap.runB",""), cenv, &p2t, 0);
261 printf("test 2 patterns with %d and %d segments\n",p1b.N(), p2t.N());
262
263 p1b.ProjectTo(-45.); // project to nominal contact surface position to simplify the alignment
264 p2t.ProjectTo( 45.);
265
266 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")), "RECREATE");
267 amap.eEnv = cenv; // pass parameters here
268 amap.ePat1 = &p1b;
269 amap.ePat2 = &p2t;
270 amap.AlignMap();
271 //amap.SaveAll();
272 amap.SaveMap(cenv->GetValue("comptonmap.out" , "out.map"));
273 //amap.ExtractMapFromTree();
274 amap.SaveAll();
275}
void get_run_patterns(const char *runfile, TEnv *cenv, EdbPattern *ptop, EdbPattern *pbot)
Definition: comptonmap.cpp:643

◆ ApplyMap()

void ApplyMap ( TEnv *  cenv)
386{
387 // read basetracks from tlglists and apply the compton map
388
389 EdbPattern p1t,p1b, p1bas, p2t,p2b, p2bas; // read full patterns
390 get_patterns_tlglist1(cenv->GetValue("comptonmap.listA",""), cenv, 0, 0, &p1bas);
391 printf("read %d %d %d (top:bot:base) segments for plate 1\n",p1t.N(),p1b.N(),p1bas.N());
392 get_patterns_tlglist1(cenv->GetValue("comptonmap.listB",""), cenv, 0, 0, &p2bas);
393 printf("read %d %d %d (top:bot:base) segments for plate 2\n",p2t.N(),p2b.N(),p2bas.N());
394
395 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")), "READ");
396 amap.eEnv = cenv; // pass parameters here
397 amap.ExtractMapFromTree();
398
399 p1bas.ProjectTo(-150.);
400 p2bas.ProjectTo( 150.);
401
402 amap.ApplyMap(p1bas);
403 //amap.ApplyMap(p1bas,p2bas);
404
405 EdbAlignmentMap amap2("atestBase.root", "RECREATE");
406
408 abase.eXcell = abase.eYcell = 100;
409 abase.eNZ1step = cenv->GetValue("comptonmap.apply.NZ1step", 100);
410 abase.eNZ2step = cenv->GetValue("comptonmap.apply.NZ2step", 100);
411 abase.eZ1from = cenv->GetValue("comptonmap.apply.Z1from", -400);
412 abase.eZ1to = cenv->GetValue("comptonmap.apply.Z1to", 400);
413 abase.eZ2from = cenv->GetValue("comptonmap.apply.Z2from", -400);
414 abase.eZ2to = cenv->GetValue("comptonmap.apply.Z2to", 400);
415 abase.eBinX = abase.eBinY = cenv->GetValue("comptonmap.apply.BinXY", 7);;
416 abase.eDTXmax = abase.eDTYmax = cenv->GetValue("comptonmap.apply.DTMax", 0.01 );
417
418 abase.FillArrays(p1bas, p2bas);
419 abase.DoubletsFilterOut(false);
420 abase.FillCombinations();
421 abase.ePC1.PrintStat();
422 abase.ePC2.PrintStat();
423 abase.ActivatePosTree();
424 abase.Align();
425 abase.PrintSummary();
426
427 amap2.FillMapTree(abase,0);
428}
void PrintStat()
Definition: EdbCell2.cpp:674
new alignment class developed mainly for compton search
Definition: EdbPositionAlignment.h:14
Float_t eZ1to
limits in Z for the peak search (ePat1)
Definition: EdbPositionAlignment.h:35
Float_t eZ2to
limits in Z for the peak search (ePat2)
Definition: EdbPositionAlignment.h:36
Float_t eDTYmax
max angular acceptance (ex: 0.15) for the coinsidences
Definition: EdbPositionAlignment.h:27
void PrintSummary()
Definition: EdbPositionAlignment.cxx:76
Float_t eZ1from
Definition: EdbPositionAlignment.h:35
bool ActivatePosTree(const char *name="postree")
Definition: EdbPositionAlignment.cxx:105
int DoubletsFilterOut(bool checkview=true)
Definition: EdbPositionAlignment.cxx:765
int Align()
Definition: EdbPositionAlignment.cxx:695
Float_t eZ2from
Definition: EdbPositionAlignment.h:36
int FillArrays(EdbPattern &p1, EdbPattern &p2)
Definition: EdbPositionAlignment.cxx:416
Float_t eDTXmax
Definition: EdbPositionAlignment.h:27
Float_t eXcell
Definition: EdbPositionAlignment.h:26
Float_t eBinY
bin size for the differential hist (for example 5 microns)
Definition: EdbPositionAlignment.h:28
Float_t eBinX
Definition: EdbPositionAlignment.h:28
Float_t eYcell
cell size (for example 50 microns)
Definition: EdbPositionAlignment.h:26
Int_t eNZ2step
number of steps for the z-selection
Definition: EdbPositionAlignment.h:37
EdbPatCell2 ePC2
cells with the pointers to segments
Definition: EdbPositionAlignment.h:17
Int_t eNZ1step
Definition: EdbPositionAlignment.h:37
EdbPatCell2 ePC1
Definition: EdbPositionAlignment.h:17
int FillCombinations()
Definition: EdbPositionAlignment.cxx:534
void ProjectTo(const float dz)
Definition: EdbPattern.cxx:268

◆ ApplyTestMap()

void ApplyTestMap ( TEnv *  cenv)
342{
343 // read the same layers used for the map production and do the global alignment
344 // to see the difference with what was before
345
346 EdbPattern p1t,p1b, p1bas, p2t,p2b, p2bas; // read full patterns
347 get_patterns_tlglist1(cenv->GetValue("comptonmap.listA",""), cenv, 0, &p1b, 0);
348 printf("read %d %d %d (top:bot:base) segments for plate 1\n",p1t.N(),p1b.N(),p1bas.N());
349 get_patterns_tlglist1(cenv->GetValue("comptonmap.listB",""), cenv, &p2t, 0, 0);
350 printf("read %d %d %d (top:bot:base) segments for plate 2\n",p2t.N(),p2b.N(),p2bas.N());
351
352 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")), "READ");
353 amap.eEnv = cenv; // pass parameters here
354 amap.ExtractMapFromTree();
355
356 amap.ApplyMap(p1b);
357 //amap.ApplyMap(p1b,p2t);
358
359 EdbAlignmentMap amap2("atest.root", "RECREATE");
360
362 abase.eXcell = abase.eYcell = 100;
363 abase.eNZ1step = cenv->GetValue("comptonmap.apply.NZ1step", 100);
364 abase.eNZ2step = cenv->GetValue("comptonmap.apply.NZ2step", 100);
365 abase.eZ1from = cenv->GetValue("comptonmap.apply.Z1from", -400);
366 abase.eZ1to = cenv->GetValue("comptonmap.apply.Z1to", 400);
367 abase.eZ2from = cenv->GetValue("comptonmap.apply.Z2from", -400);
368 abase.eZ2to = cenv->GetValue("comptonmap.apply.Z2to", 400);
369 abase.eBinX = abase.eBinY = cenv->GetValue("comptonmap.apply.BinXY", 7);;
370 abase.eDTXmax = abase.eDTYmax = cenv->GetValue("comptonmap.apply.DTMax", 0.01 );
371
372 abase.FillArrays(p1b, p2t);
373
374 abase.FillCombinations();
375 abase.ePC1.PrintStat();
376 abase.ePC2.PrintStat();
377 abase.ActivatePosTree();
378 abase.Align();
379 abase.PrintSummary();
380
381 amap2.FillMapTree(abase,0);
382}

◆ get_patterns_Jap()

void get_patterns_Jap ( const char *  listfile,
TEnv *  cenv,
EdbPattern p 
)
481{
482 // read data from the japanese compton sample
483 // apply cuts defined by wminTop, wminBot, wminBase, thetamax, xmin, xmax, ymin, ymax
484
485 float wmin = cenv->GetValue("comptonmap.MinGrainsTop" , 8.);
486 float thetamax = cenv->GetValue("comptonmap.ThetaMax", 1.);
487 float xmin = cenv->GetValue("comptonmap.Xmin", -1000000.);
488 float xmax = cenv->GetValue("comptonmap.Xmax", 1000000.);
489 float ymin = cenv->GetValue("comptonmap.Ymin", -1000000.);
490 float ymax = cenv->GetValue("comptonmap.Ymax", 1000000.);
491 float maxDens = cenv->GetValue("comptonmap.DensityMax", 2.) + 0.2;
492
493 printf("listfile = %s\n",listfile);
494 FILE *f = fopen( listfile, "r");
495 if(!f) return;
496 char *str = new char[512];
497 for(int i=0; i<4; i++) {fgets(str,512,f); printf("%s\n",str);}
498
499 EdbPattern ptmp(0,0,0,10000);
500 EdbSegP *s=0;
501 int id, id1, ipuls;
502 float tx, ty, x,y, vx, vy;
503 while(1) {
504 if( fscanf(f,"%d %d %d %f %f %f %f %f %f",&id, &id1, &ipuls, &tx, &ty, &x,&y, &vx, &vy) != 9) break;
505 s = ptmp.AddSegment(id, x,y,tx,ty, ipuls/10000 );
506 }
507 add_pattern(p, ptmp, wmin , thetamax, xmin, xmax, ymin, ymax, maxDens );
508 Log(2,"get_patterns_tlglist", "read %d segments from file: \"%s\"",
509 p.N() ,listfile );
510}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
FILE * f
Definition: RecDispMC.C:150
void add_pattern(EdbPattern &p, EdbPattern &padd, float wmin, float thetamax, float xmin, float xmax, float ymin, float ymax, float maxDens=2)
Definition: comptonmap.cpp:548
UInt_t id
Definition: tlg2couples.C:117

◆ get_patterns_Jap2()

void get_patterns_Jap2 ( const char *  listfile,
TEnv *  cenv,
EdbPattern p 
)
514{
515 // read data from the japanese event sample
516 // apply cuts defined by wminTop, wminBot, wminBase, thetamax, xmin, xmax, ymin, ymax
517
518 float wmin = cenv->GetValue("comptonmap.MinGrainsTop" , 8.);
519 float thetamax = cenv->GetValue("comptonmap.ThetaMax", 1.);
520 float xmin = cenv->GetValue("comptonmap.Xmin", -1000000.);
521 float xmax = cenv->GetValue("comptonmap.Xmax", 1000000.);
522 float ymin = cenv->GetValue("comptonmap.Ymin", -1000000.);
523 float ymax = cenv->GetValue("comptonmap.Ymax", 1000000.);
524 float maxDens = cenv->GetValue("comptonmap.DensityMax", 2.) + 0.2;
525
526 printf("listfile = %s\n",listfile);
527 FILE *f = fopen( listfile, "r"); if(!f) return;
528
529 EdbPattern ptmp(0,0,0,10000);
530 EdbSegP *s=0;
531 int idpl, id, id1, id2, ipuls, flag;
532 float tx, ty, x,y,z, z1,z2, vx, vy;
533 while(1) {
534 if( fscanf(f,"%d %d %d %d %d %f %f %f %f %f %f %f %f %f %d",
535 &idpl, &id, &id1, &id2, &ipuls, &tx, &ty, &x,&y,&z, &z1,&z2, &vx, &vy, &flag) != 15) break;
536 s = ptmp.AddSegment(id1, x,y,tx,ty, ipuls/10000 );
537 s->SetZ(z);
538 s->SetDZ(Abs(z2-z1));
539 //if(!(id1%1000)) { printf("id1 = %d\n",id1); s->PrintNice(); }
540 }
541
542 add_pattern(p, ptmp, wmin , thetamax, xmin, xmax, ymin, ymax, maxDens );
543 Log(2,"get_patterns_tlglist", "read %d (of %d) segments from file: \"%s\"",
544 p.N(), ptmp.N() ,listfile );
545}

◆ get_patterns_tlglist1()

void get_patterns_tlglist1 ( const char *  listfile,
TEnv *  cenv,
EdbPattern ptop,
EdbPattern pbot,
EdbPattern pbase 
)
432{
433 // read data from the list of tlgfiles,
434 // apply cuts defined by wminTop, wminBot, wminBase, thetamax, xmin, xmax, ymin, ymax
435
436 char *str = new char[512];
437
438 float wminTop = cenv->GetValue("comptonmap.MinGrainsTop" , 8.);
439 float wminBot = cenv->GetValue("comptonmap.MinGrainsBot" , 8.);
440 float wminBase = cenv->GetValue("comptonmap.MinGrainsBase",16);
441 float thetamax = cenv->GetValue("comptonmap.ThetaMax", 1.);
442 float xmin = cenv->GetValue("comptonmap.Xmin", -1000000.);
443 float xmax = cenv->GetValue("comptonmap.Xmax", 1000000.);
444 float ymin = cenv->GetValue("comptonmap.Ymin", -1000000.);
445 float ymax = cenv->GetValue("comptonmap.Ymax", 1000000.);
446 float maxDens = cenv->GetValue("comptonmap.DensityMax", 2.) + 0.2;
447
448 ifstream in1; in1.open(listfile); if(!in1.good()) return;
449
450 EdbPattern pt(0,0,0,10000), pb(0,0,0,10000), pbas(0,0,0,10000);
451 while(1) {
452 in1.getline( (str),512 );
453 if(!in1.good()) break; if(in1.eof()) break;
454
455 pt.Reset(); pb.Reset(); pbas.Reset();
456 tlg2patterns( str, pt, pb, pbas);
457
458 int ntr=0, nbr=0, nbasr=0;
459 if(ptop) {
460 int n0t=ptop->N();
461 add_pattern(*ptop, pt, wminTop , thetamax, xmin, xmax, ymin, ymax, maxDens );
462 ntr = ptop->N() - n0t;
463 }
464 if(pbot) {
465 int n0b=pbot->N();
466 add_pattern(*pbot, pb, wminBot , thetamax, xmin, xmax, ymin, ymax, maxDens );
467 nbr = pbot->N() - n0b;
468 }
469 if(pbase) {
470 int n0bas=pbase->N();
471 add_pattern(*pbase, pbas, wminBase, thetamax, xmin, xmax, ymin, ymax, maxDens );
472 nbasr = pbase->N() - n0bas;
473 }
474 Log(2,"get_patterns_tlglist", "read %d:%d:%d (top:bot:base) segments from file: \"%s\"",
475 ntr,nbr,nbasr ,str );
476 }
477}
TPaveText * pt
Definition: Canv_SYSTEMATICS_ALLCOMBINED__RMSEnergy__vs__Energy__ELECTRON.C:160
void tlg2patterns(const char *input_file, EdbPattern &ptop, EdbPattern &pbot, EdbPattern &base, float project_dz=-105.)
Definition: tlg2pattern.C:264

◆ get_run_patterns()

void get_run_patterns ( const char *  runfile,
TEnv *  cenv,
EdbPattern ptop,
EdbPattern pbot 
)
644{
645 // read patterns from the raw files in the root format
646
647 float x = cenv->GetValue("comptonmap.x0" , 40000.);
648 float y = cenv->GetValue("comptonmap.y0" , 40000.);
649 float size = cenv->GetValue("comptonmap.size" , 500000.);
650 float pulsmin = cenv->GetValue("comptonmap.pulsmin" , 8);
651 int side1 = cenv->GetValue("comptonmap.side1" , 1); // usually top of the plate
652 int side2 = cenv->GetValue("comptonmap.side2" , 2); // usually bottom of the plate
653
654 Log(2,"get_run_patterns","read file: %s",runfile);
655
656 EdbRunAccess ra;
657 ra.InitRun(runfile);
658 ra.GetLayer(2)->SetZlayer( 0, 0, 0 );
659 ra.GetLayer(1)->SetZlayer( 214, 0, 0 );
660 ra.GetLayer(1)->SetShrinkage( 1. );
661 ra.GetLayer(2)->SetShrinkage( 1. );
662 ra.eAFID=1;
663
664 float min[5] = {-500,-500,-1.,-1., pulsmin};
665 float max[5] = { 500, 500, 1., 1., 50};
666 ra.AddSegmentCut(side1, 1, min, max);
667 ra.AddSegmentCut(side2, 1, min, max);
668
669 EdbSegP s(0, x, y, 0,0);
670
671 int n1=0, n2=0;
672 if(p1) { n1= ra.GetPatternXY(s, side1, *p1, size); p1->SetID(1); }
673 if(p2) { n2= ra.GetPatternXY(s, side2, *p2, size); p2->SetID(2); }
674
675 printf("read segments: n1=%d n2=%d \n",n1,n2);
676}
void SetZlayer(float z, float zmin, float zmax)
Definition: EdbLayer.h:101
void SetShrinkage(float shr)
Definition: EdbLayer.h:99
helper class for access to the run data
Definition: EdbRunAccess.h:23
bool InitRun(const char *runfile=0, bool do_update=false)
Definition: EdbRunAccess.cxx:112
EdbLayer * GetLayer(int id)
Definition: EdbRunAccess.h:113
void AddSegmentCut(int xi, const char *cutline)
Definition: EdbRunAccess.cxx:1187
Int_t eAFID
if =1 - use affine transformations of the fiducial marks
Definition: EdbRunAccess.h:26
int GetPatternXY(EdbSegP &s, int side, EdbPattern &pat, float rmin=200)
Definition: EdbRunAccess.cxx:377

◆ LinkJap2()

void LinkJap2 ( TEnv *  cenv)
324{
325 // read 2 sides from nagoya files and link them
326
327 EdbPattern p1b(0,0,0,200000),p2t(0,0,0,200000); // read full patterns
328 get_patterns_Jap2(cenv->GetValue("comptonmap.listA",""), cenv, p1b);
329 get_patterns_Jap2(cenv->GetValue("comptonmap.listB",""), cenv, p2t);
330 printf("test 2 Jap patterns with %d and %d segments\n",p1b.N(), p2t.N());
331
332 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "link_test")), "RECREATE");
333 amap.eEnv = cenv; // pass parameters here
334 amap.ePat1 = &p1b;
335 amap.ePat2 = &p2t;
336 amap.Link();
337 amap.SaveAll();
338}
void get_patterns_Jap2(const char *listfile, TEnv *cenv, EdbPattern &p)
Definition: comptonmap.cpp:513

◆ main()

int main ( int  argc,
char *  argv[] 
)
73{
74 if (argc < 2) { print_help_message(); return 0; }
75
76 TEnv *cenv = new TEnv("comptonenv");
78 cenv->ReadFile("comptonmap.rootrc",kEnvLocal);
79
80 bool do_ida = false;
81 bool do_idb = false;
82 //EdbID idA,idB;
83
84 bool do_tlglista = false;
85 bool do_tlglistb = false;
86
87 bool do_align_jap = false;
88 bool do_align_jap2 = false;
89
90 bool do_apply_map = false;
91 bool do_apply_test_map = false;
92 bool do_link = false;
93
94 for(int i=1; i<argc; i++ ) {
95 char *key = argv[i];
96
97 if (!strncmp(key,"-A",2))
98 {
99 // if(strlen(key)>2) sscanf(key+2,"%d.%d.%d.%d", &idA.eBrick, &idA.ePlate, &idA.eMajor, &idA.eMinor );
100 if(strlen(key)>2) cenv->SetValue("comptonmap.runA",key+2);
101 do_ida=true;
102 }
103 else if(!strncmp(key,"-B",2))
104 {
105 // if(strlen(key)>2) sscanf(key+2,"%d.%d.%d.%d", &idB.eBrick, &idB.ePlate, &idB.eMajor, &idB.eMinor );
106 if(strlen(key)>2) cenv->SetValue("comptonmap.runB",key+2);
107 do_idb=true;
108 }
109 else if(!strncmp(key,"-par=",5))
110 {
111 cenv->ReadFile(key+5,kEnvLocal);
112 }
113 else if(!strncmp(key,"-outmap=",8))
114 {
115 if(strlen(key)>8) cenv->SetValue("comptonmap.out",key+8);
116 }
117 else if(!strncmp(key,"-jap2",5))
118 {
119 do_align_jap2=true;
120 }
121 else if(!strncmp(key,"-jap",4))
122 {
123 do_align_jap=true;
124 }
125 else if(!strncmp(key,"-listA=",7))
126 {
127 do_tlglista=true;
128 if(strlen(key)>7) cenv->SetValue("comptonmap.listA",key+7);
129 }
130 else if(!strncmp(key,"-listB=",7))
131 {
132 do_tlglistb=true;
133 if(strlen(key)>7) cenv->SetValue("comptonmap.listB",key+7);
134 }
135 else if(!strncmp(key,"-o",2))
136 {
137 if(strlen(key)>2) cenv->SetValue("comptonmap.outdir",key+2);
138 }
139 else if(!strncmp(key,"-applytest",10))
140 {
141 do_apply_test_map = true;
142 }
143 else if(!strncmp(key,"-apply",6))
144 {
145 do_apply_map = true;
146 // if(strlen(key)>5) cenv->SetValue("comptonmap.ApplyMapFile",key+5);
147 }
148 else if(!strncmp(key,"-link=",6))
149 {
150 do_link = true;
151 if(strlen(key)>6) cenv->SetValue("comptonmap.link.runfile",key+6);
152 }
153 else if(!strncmp(key,"-v",2))
154 {
155 if(strlen(key)>2) cenv->SetValue("comptonmap.EdbDebugLevel",atoi(key+2));
156 }
157 }
158
159 cenv->Print();
160 gEDBDEBUGLEVEL = cenv->GetValue("comptonmap.EdbDebugLevel" , 1);
161
162 if(do_ida&&do_idb)
163 {
164 printf("\n----------------------------------------------------------------------------\n");
165 printf("make compton map for runs %s and %s\n",
166 cenv->GetValue("comptonmap.runA" , ""),
167 cenv->GetValue("comptonmap.runB" , "")
168 );
169 printf("----------------------------------------------------------------------------\n\n");
170
172 }
173 else if(do_link)
174 {
175
176 const char *runfile = cenv->GetValue("comptonmap.link.runfile","run.root");
177 EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.link.out" , "link_test")), "RECREATE");
178 amap.eEnv = cenv;
179 EdbPlateP p;
180 float DZ = cenv->GetValue("fedra.link.DZbase",214.);
181 p.SetPlateLayout(DZ,45,45);
182 amap.Link(runfile,p);
183
184// EdbPattern p1,p2;
185// const char *runfile = cenv->GetValue("comptonmap.link.runfile","run.root");
186// get_run_patterns( runfile , cenv, &p1, &p2);
187
188// p1.SetZ(0); p1.SetSegmentsZ();
189// p2.SetZ(DZ); p2.SetSegmentsZ();
190
191// Log(0,"LinkPlate", "with %d and %d segments (dz = %6.1f)", p1.N(), p2.N(), DZ );
192
193// EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.link.out" , "link_test")), "RECREATE");
194// amap.eEnv = cenv;
195// amap.ePat1 = &p1;
196// amap.ePat2 = &p2;
197// amap.Link();
198// cenv->Print();
199// amap.SaveAll();
200
201 }
202 else if(do_tlglista&&do_tlglistb)
203 {
204// EdbPattern p1t,p1b, p1bas, p2t,p2b, p2bas; // read full patterns
205// get_patterns_tlglist1(cenv->GetValue("comptonmap.listA",""), cenv, p1t, p1b, p1bas);
206// get_patterns_tlglist1(cenv->GetValue("comptonmap.listB",""), cenv, p2t, p2b, p2bas);
207
208// TFile f("pattmp.root","RECREATE"); // temporary file for the fast access
209// printf("save %d %d %d (top:bot:base) segments for plate 1\n",p1t.N(),p1b.N(),p1bas.N());
210// p1t.Write("p1t");
211// p1b.Write("p1b");
212// p1bas.Write("p1bas");
213// printf("save %d %d %d (top:bot:base) segments for plate 2\n",p2t.N(),p2b.N(),p2bas.N());
214// p2t.Write("p2t");
215// p2b.Write("p2b");
216// p2bas.Write("p2bas");
217// f.Close();
218
219// TFile f("pattmp.root","READ");
220// EdbPattern *p1 = (EdbPattern*)(f.Get("p1b"));
221// EdbPattern *p2 = (EdbPattern*)(f.Get("p2t"));
222// printf("test 2 patterns with %d and %d segments\n",p1->N(), p2->N());
223// EdbAlignmentMap amap(Form("%s.root", cenv->GetValue("comptonmap.out" , "out.map")));
224// amap.eEnv = cenv; // pass parameters here
225// amap.ePat1 = p1;
226// amap.ePat2 = p2;
227// amap.DoAll();
228// amap.SaveAll();
229
230 // NOTE: in the postree flag=0 - all comb; flag=1 - peak selected com
231
232 if (do_apply_map) ApplyMap(cenv);
233 else if(do_apply_test_map) ApplyTestMap(cenv);
234// else if(do_link_map)
235// {
236// EdbPattern p1t,p1b, p1bas, p2t,p2b, p2bas; // read full patterns
237// get_patterns_tlglist1(cenv->GetValue("comptonmap.listA",""), cenv, &p1t, &p1b, 0);
238// printf("read %d %d %d (top:bot:base) segments for plate 1\n",p1t.N(),p1b.N(),p1bas.N());
239// //Link1(cenv, p1b, p1t);
240// }
241 else if(do_align_jap) AlignMapJap(cenv);
242 else if(do_align_jap2) LinkJap2(cenv);
243 else AlignMap(cenv);
244
245 }
246 else { print_help_message(); return 0; }
247
248 cenv->WriteFile("comptonmap.save.rootrc");
249
250 return 1;
251}
Definition: EdbBrick.h:14
void LinkJap2(TEnv *cenv)
Definition: comptonmap.cpp:323
void set_default(TEnv &cenv)
Definition: comptonmap.cpp:48
void AlignMap(TEnv *cenv)
Definition: comptonmap.cpp:278
void print_help_message()
Definition: comptonmap.cpp:32
void AlignMapJap(TEnv *cenv)
Definition: comptonmap.cpp:302
void AlignRunMap(TEnv *cenv)
Definition: comptonmap.cpp:254
void ApplyMap(TEnv *cenv)
Definition: comptonmap.cpp:385
void ApplyTestMap(TEnv *cenv)
Definition: comptonmap.cpp:341
float DZ
Definition: hwinit.C:66
gEDBDEBUGLEVEL
Definition: energy.C:7

◆ print_help_message()

void print_help_message ( )
33{
34 cout<< "\nExample: \n";
35 cout<< "\t comptonmap -listA=tlg1.lst -listB=tlg2.lst -outmap=map.out -par=comptonmap.rootrc -v2 \n";
36 cout<< "\t comptonmap -Arun1.root -Brun2.root \n";
37 cout<< "\nThe data location directory if not explicitly defined will be taken from comptonmap.rootrc as: \n";
38 cout<< "\t comptonmap.outdir: /scratch/BRICKS \n";
39 cout<< "\t comptonmap.EdbDebugLevel: 1\n";
40 cout<< "\nAdditional options: \n";
41 cout<< "\t -apply: apply map to the basetracks\n";
42 cout<< "\t -applytest: apply map to the same layers used for map production to test the result\n";
43 cout<< "\t -link: link raw data \n";
44 cout<<endl;
45}

◆ set_default()

void set_default ( TEnv &  cenv)
49{
50 // default parameters for the comptom map search
51 //tlglist case
52 cenv.SetValue("comptonmap.MinGrainsTop" , 8.);
53 cenv.SetValue("comptonmap.MinGrainsBot" , 8.);
54 cenv.SetValue("comptonmap.MinGrainsBase",16);
55 cenv.SetValue("comptonmap.ThetaMax", 1.);
56 cenv.SetValue("comptonmap.Xmin", -1000000.);
57 cenv.SetValue("comptonmap.Xmax", 1000000.);
58 cenv.SetValue("comptonmap.Ymin", -1000000.);
59 cenv.SetValue("comptonmap.Ymax", 1000000.);
60 cenv.SetValue("comptonmap.DensityMax", 2.);
61
62 //run case
63 cenv.SetValue("comptonmap.x0" , 40000.);
64 cenv.SetValue("comptonmap.y0" , 40000.);
65 cenv.SetValue("comptonmap.size" , 500000.);
66 cenv.SetValue("comptonmap.pulsmin" , 8 );
67 cenv.SetValue("comptonmap.side1" , 1 ); // usually top of the plate
68 cenv.SetValue("comptonmap.side2" , 2 ); // usually bottom of the plate
69}

Variable Documentation

◆ sproc

EdbScanProc* sproc =0